Multiple dynamic npc (#7486)
* Vectorize npc_id_dynamic to support multiple dynamic npc with different ids Co-authored-by: Lemongrass3110 <lemongrass@kstp.at> Thanks to @dimasshotta and @eppc0330 !
This commit is contained in:
@@ -3423,17 +3423,22 @@ int unit_free(struct block_list *bl, clr_type clrtype)
|
||||
sd->npc_id = 0;
|
||||
}
|
||||
|
||||
if( sd->npc_id_dynamic != 0 ){
|
||||
struct npc_data* nd = map_id2nd( sd->npc_id_dynamic );
|
||||
if( !sd->npc_id_dynamic.empty() ){
|
||||
for (const auto &it : sd->npc_id_dynamic) {
|
||||
struct npc_data* nd = map_id2nd( it );
|
||||
|
||||
if( nd != nullptr ){
|
||||
// Delete the NPC
|
||||
npc_unload( nd, true );
|
||||
// Update NPC event database
|
||||
npc_read_event_script();
|
||||
if( nd != nullptr ){
|
||||
// Erase the owner first to prevent loops from npc_unload
|
||||
nd->dynamicnpc.owner_char_id = 0;
|
||||
|
||||
// Delete the NPC
|
||||
npc_unload( nd, true );
|
||||
}
|
||||
}
|
||||
// Update NPC event database
|
||||
npc_read_event_script();
|
||||
|
||||
sd->npc_id_dynamic = 0;
|
||||
sd->npc_id_dynamic.clear();
|
||||
}
|
||||
|
||||
sd->combos.clear();
|
||||
|
||||
Reference in New Issue
Block a user