|
@@ -81,14 +81,12 @@ void npc_dynamic_reset() {
|
81
|
81
|
}
|
82
|
82
|
}
|
83
|
83
|
|
84
|
|
-void npc_dynamic_remove_entry(u8 id, u16 tag) {
|
85
|
|
- if (stored_palettes[id].tag == tag) {
|
86
|
|
- if (stored_palettes[id].reference_count > 0) {
|
87
|
|
- stored_palettes[id].reference_count--;
|
88
|
|
- dprintf("npc_dynamic: removed entry #%d\n", id);
|
89
|
|
- if (stored_palettes[id].reference_count == 0)
|
90
|
|
- stored_palettes[id].tag = 0;
|
91
|
|
- }
|
|
84
|
+void npc_dynamic_remove_entry(u8 id) {
|
|
85
|
+ if (stored_palettes[id].reference_count > 0) {
|
|
86
|
+ stored_palettes[id].reference_count--;
|
|
87
|
+ dprintf("npc_dynamic: removed entry #%d\n", id);
|
|
88
|
+ if (stored_palettes[id].reference_count == 0)
|
|
89
|
+ stored_palettes[id].tag = 0;
|
92
|
90
|
}
|
93
|
91
|
}
|
94
|
92
|
|
|
@@ -106,8 +104,7 @@ void npc_restore_state(u8 id, u16 x, u16 y) {
|
106
|
104
|
|
107
|
105
|
struct Template template_to_load;
|
108
|
106
|
u32 f14;
|
109
|
|
- npc_to_objtemplate__with_indexed_objfunc(type_id, npc_to_load->running_behavior, &template_to_load,
|
110
|
|
- &f14);
|
|
107
|
+ npc_to_objtemplate__with_indexed_objfunc(type_id, npc_to_load->running_behavior, &template_to_load, &f14);
|
111
|
108
|
template_to_load.pal_tag = 0xFFFF;
|
112
|
109
|
s8 pal_slot = npc_dynamic_load_palette(type_to_load->pal_num);
|
113
|
110
|
|
|
@@ -222,3 +219,15 @@ void oec02_load_pal_impl(u32 *oe_script) {
|
222
|
219
|
}
|
223
|
220
|
*oe_script += 4;
|
224
|
221
|
}
|
|
222
|
+
|
|
223
|
+void npc_delete_obj_and_free_tiles_for_npc_hack(struct NpcState *state) {
|
|
224
|
+ struct SpriteTiles tiles;
|
|
225
|
+ u16 npc_id = ((u16)state->type_id) | (((u16)state->field1A << 8));
|
|
226
|
+ struct NpcType *type = npc_get_type(npc_id);
|
|
227
|
+ tiles.size = type->field_6;
|
|
228
|
+ objects[state->oam_id].gfx_table = &tiles;
|
|
229
|
+ u8 pal_num = objects[state->oam_id].final_oam.palette_num;
|
|
230
|
+ obj_delete_and_free(&objects[state->oam_id]);
|
|
231
|
+ npc_dynamic_remove_entry(pal_num);
|
|
232
|
+ dprintf("deleted npc state at x: %d y: %d\n", state->to.x, state->to.y);
|
|
233
|
+}
|