@@ -109,8 +109,9 @@ static __declspec(naked) void new_obj_id_hook() {
109109}
110110
111111// Reassigns object IDs to all critters upon first loading a map and updates their HP stats
112+ // also fixes their combat_data.who_hit_me values (same as map_fix_critter_combat_data_)
112113// TODO: for items?
113- static void map_fix_critter_id () {
114+ static void __stdcall map_fix_critter_id_combat_data () {
114115 long npcStartID = 4096 ; // 0x1000
115116 fo::GameObject* obj = fo::func::obj_find_first ();
116117 while (obj) {
@@ -119,19 +120,15 @@ static void map_fix_critter_id() {
119120 obj->id = npcStartID++;
120121 Objects::SetScriptObjectID (obj);
121122 }
123+ if (obj->critter .whoHitMe == (fo::GameObject*)-1 ) {
124+ obj->critter .whoHitMe = nullptr ;
125+ }
122126 Stats::UpdateHPStat (obj);
123127 }
124128 obj = fo::func::obj_find_next ();
125129 }
126130}
127131
128- static __declspec (naked) void map_load_file_hook() {
129- __asm {
130- call map_fix_critter_id;
131- jmp fo::funcoffs::map_fix_critter_combat_data_;
132- }
133- }
134-
135132static __declspec (naked) void queue_add_hack() {
136133 using namespace fo ;
137134 using namespace Fields ;
@@ -270,7 +267,7 @@ void Objects::init() {
270267 MakeCall (0x477A0E , item_identical_hack); // don't put item with unique ID to items stack
271268
272269 // Fix mapper bug by reassigning object IDs to critters (for unvisited maps)
273- HookCall (0x482DE2 , map_load_file_hook);
270+ HookCall (0x482DE2 , map_fix_critter_id_combat_data); // replace map_fix_critter_combat_data_
274271 // Additionally fix object IDs for queued events
275272 MakeCall (0x4A25BA , queue_add_hack);
276273
0 commit comments