diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-10-02 19:22:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-10-02 19:22:04 +0300 |
commit | 58e216614ba0b1806a417f2cc2ea2323bbb230cf (patch) | |
tree | f4dabeb369de95b92325bb52de91568ff8245d26 | |
parent | 9656a691e1c8c68f7832f33b3777217f8953ba11 (diff) | |
download | evol-hercules-58e216614ba0b1806a417f2cc2ea2323bbb230cf.tar.gz evol-hercules-58e216614ba0b1806a417f2cc2ea2323bbb230cf.tar.bz2 evol-hercules-58e216614ba0b1806a417f2cc2ea2323bbb230cf.tar.xz evol-hercules-58e216614ba0b1806a417f2cc2ea2323bbb230cf.zip |
-rw-r--r-- | src/emap/data/mobd.c | 3 | ||||
-rw-r--r-- | src/emap/init.c | 2 | ||||
-rw-r--r-- | src/emap/mob.c | 64 | ||||
-rw-r--r-- | src/emap/mob.h | 5 | ||||
-rw-r--r-- | src/emap/struct/mobdext.h | 3 |
5 files changed, 77 insertions, 0 deletions
diff --git a/src/emap/data/mobd.c b/src/emap/data/mobd.c index 8f77994..e11a222 100644 --- a/src/emap/data/mobd.c +++ b/src/emap/data/mobd.c @@ -51,5 +51,8 @@ struct MobdExt *mobd_create(void) data->weaponAttacks[f] = 10000; for (int f = 0; f < MAX_SKILL_DB; f ++) data->skillAttacks[f] = 10000; + data->collisionDx = -1; + data->collisionDy = -1; + data->collisionMask = 1; return data; } diff --git a/src/emap/init.c b/src/emap/init.c index 948e10c..341f9dd 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -226,6 +226,7 @@ HPExport void plugin_init (void) addHookPre(pc, process_chat_message, epc_process_chat_message_pre); addHookPre(mob, deleteslave_sub, emob_deleteslave_sub_pre); addHookPre(mob, read_db_additional_fields, emob_read_db_additional_fields_pre); + addHookPre(mob, dead, emob_dead_pre); addHookPre(npc, parse_unknown_mapflag, enpc_parse_unknown_mapflag_pre); addHookPre(npc, buysellsel, enpc_buysellsel_pre); addHookPre(npc, db_checkid, enpc_db_checkid_pre); @@ -306,6 +307,7 @@ HPExport void plugin_init (void) addHookPost(status, change_end_, estatus_change_end__post); addHookPost(map, addflooritem, emap_addflooritem_post); addHookPost(mob, read_db_mode_sub, emob_read_db_mode_sub_post); + addHookPost(mob, spawn_dataset, emob_spawn_dataset_post); addHookPost(npc, get_viewdata, enpc_get_viewdata_post); addHookPost(skill, check_condition_castend, eskill_check_condition_castend_post); addHookPost(skill, get_index, eskill_get_index_post); diff --git a/src/emap/mob.c b/src/emap/mob.c index f12a936..b4f4f31 100644 --- a/src/emap/mob.c +++ b/src/emap/mob.c @@ -22,6 +22,7 @@ #include "plugins/HPMHooking.h" +#include "emap/map.h" #include "emap/mob.h" #include "emap/data/mobd.h" @@ -257,6 +258,26 @@ void emob_read_db_additional_fields_pre(struct mob_db **entryPtr, emob_load_skillattacks(config_setting_name(wpt), libconfig->setting_get_int(wpt), data, *entryPtr); } } + + if ((tt = libconfig->setting_get_member(*itPtr, "SpawnCollisionSize"))) + { + if (config_setting_is_aggregate(tt)) + { + data->collisionDx = libconfig->setting_get_int_elem(tt, 0); + if (libconfig->setting_length(tt) >= 2) + data->collisionDy = libconfig->setting_get_int_elem(tt, 1); + else if (libconfig->setting_length(tt) >= 1) + data->collisionDy = data->collisionDx; + } + else if (libconfig->setting_lookup_int(*itPtr, "SpawnCollisionSize", &i32)) + { + data->collisionDx = i32; + data->collisionDy = i32; + } + } + + if (mob->lookup_const(*itPtr, "SpawnCollisionMask", &i32)) + data->collisionMask = i32; } uint32 emob_read_db_mode_sub_post(uint32 retVal, @@ -270,3 +291,46 @@ uint32 emob_read_db_mode_sub_post(uint32 retVal, return retVal; } + +struct mob_data *emob_spawn_dataset_post(struct mob_data *retVal, + struct spawn_data *data __attribute__ ((unused))) +{ + if (retVal) + { + struct MobdExt *ext = mobd_get_by_mob(retVal); + const int dx = ext->collisionDx; + const int dy = ext->collisionDy; + if (ext && dx != -1 && dy != -1) + { + char name[100]; + const int m = retVal->bl.m; + sprintf(name, "mob_spawn_%d_%d", m, retVal->bl.id); + emap_iwall_set2(m, + 0, + retVal->bl.x - dx, retVal->bl.y - dy, + retVal->bl.x + dx, retVal->bl.y + dy, + ext->collisionMask, + name); + } + } + return retVal; +} + +int emob_dead_pre(struct mob_data **mdPtr, + struct block_list **srcPtr __attribute__ ((unused)), + int *typePtr __attribute__ ((unused))) +{ + struct mob_data *md = *mdPtr; + if (md) + { + struct MobdExt *ext = mobd_get_by_mob(md); + if (ext) + { + char name[100]; + const int m = md->bl.m; + sprintf(name, "mob_spawn_%d_%d", m, md->bl.id); + map->iwall_remove(name); + } + } + return 3; +} diff --git a/src/emap/mob.h b/src/emap/mob.h index 2074730..ea0013c 100644 --- a/src/emap/mob.h +++ b/src/emap/mob.h @@ -15,5 +15,10 @@ void emob_read_db_additional_fields_pre(struct mob_db **entryPtr, uint32 emob_read_db_mode_sub_post(uint32 retVal, struct mob_db *entry, struct config_setting_t *t); +struct mob_data *emob_spawn_dataset_post(struct mob_data *retVal, + struct spawn_data *data); +int emob_dead_pre(struct mob_data **mdPtr, + struct block_list **srcPtr, + int *typePtr); #endif // EVOL_MAP_MOB diff --git a/src/emap/struct/mobdext.h b/src/emap/struct/mobdext.h index 012485f..24c6f34 100644 --- a/src/emap/struct/mobdext.h +++ b/src/emap/struct/mobdext.h @@ -9,6 +9,9 @@ struct MobdExt int walkMask; int weaponAttacks[MAX_WEAPON_TYPE]; int skillAttacks[MAX_SKILL_DB]; + int collisionDx; + int collisionDy; + int collisionMask; }; #endif // EVOL_MAP_MOBDEXT |