From a3158d2110a2a846d39a5ddc364adb40c212241d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 31 Aug 2016 23:50:14 +0300 Subject: Add into mob_db weapot type attacks modifier. New group in mob_db: WeaponAttacks Example: WeaponAttacks: { Bows: 5000 // mean bow attack do 50% of normal attack } Default value is 10000 mean 100% --- src/emap/mob.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) (limited to 'src/emap/mob.c') diff --git a/src/emap/mob.c b/src/emap/mob.c index 0bddb02..534e858 100644 --- a/src/emap/mob.c +++ b/src/emap/mob.c @@ -7,6 +7,7 @@ #include #include +#include "common/cbasetypes.h" #include "common/conf.h" #include "common/HPMi.h" #include "common/memmgr.h" @@ -59,6 +60,145 @@ int emob_deleteslave_sub_pre(struct block_list **blPtr, return 0; } +static void emob_load_weaponattacks(const char *type, + int val, + struct MobdExt *data, + struct mob_db *entry) +{ + int key = -1; + if (strcmp(type, "NoWeapon") == 0) + { + key = W_FIST; + } + else if (strcmp(type, "Daggers") == 0) + { + key = W_DAGGER; + } + else if (strcmp(type, "1HSwords") == 0) + { + key = W_1HSWORD; + } + else if (strcmp(type, "2HSwords") == 0) + { + key = W_2HSWORD; + } + else if (strcmp(type, "1HSpears") == 0) + { + key = W_1HSPEAR; + } + else if (strcmp(type, "2HSpears") == 0) + { + key = W_2HSPEAR; + } + else if (strcmp(type, "1HAxes") == 0) + { + key = W_1HAXE; + } + else if (strcmp(type, "2HAxes") == 0) + { + key = W_2HAXE; + } + else if (strcmp(type, "Maces") == 0) + { + key = W_MACE; + } + else if (strcmp(type, "2HMaces") == 0) + { + key = W_2HMACE; + } + else if (strcmp(type, "Staves") == 0) + { + key = W_STAFF; + } + else if (strcmp(type, "Bows") == 0) + { + key = W_BOW; + } + else if (strcmp(type, "Knuckles") == 0) + { + key = W_KNUCKLE; + } + else if (strcmp(type, "Instruments") == 0) + { + key = W_MUSICAL; + } + else if (strcmp(type, "Whips") == 0) + { + key = W_WHIP; + } + else if (strcmp(type, "Books") == 0) + { + key = W_BOOK; + } + else if (strcmp(type, "Katars") == 0) + { + key = W_KATAR; + } + else if (strcmp(type, "Revolvers") == 0) + { + key = W_REVOLVER; + } + else if (strcmp(type, "Rifles") == 0) + { + key = W_RIFLE; + } + else if (strcmp(type, "GatlingGuns") == 0) + { + key = W_GATLING; + } + else if (strcmp(type, "Shotguns") == 0) + { + key = W_SHOTGUN; + } + else if (strcmp(type, "GrenadeLaunchers") == 0) + { + key = W_GRENADE; + } + else if (strcmp(type, "FuumaShurikens") == 0) + { + key = W_HUUMA; + } + else if (strcmp(type, "2HStaves") == 0) + { + key = W_2HSTAFF; + } + else if (strcmp(type, "DWDaggers") == 0) + { + key = W_DOUBLE_DD; + } + else if (strcmp(type, "DWSwords") == 0) + { + key = W_DOUBLE_SS; + } + else if (strcmp(type, "DWAxes") == 0) + { + key = W_DOUBLE_AA; + } + else if (strcmp(type, "DWDaggerSword") == 0) + { + key = W_DOUBLE_DS; + } + else if (strcmp(type, "DWDaggerAxe") == 0) + { + key = W_DOUBLE_DA; + } + else if (strcmp(type, "DWSwordAxe") == 0) + { + key = W_DOUBLE_SA; + } + else if (strcmp(type, "All") == 0) + { + for (int f = 0; f < MAX_WEAPON_TYPE; f ++) + data->weaponAttacks[f] = val; + } + else + { + ShowError("Mob %d. Unknown weapon type %s\n", entry->mob_id, type); + return; + } + data->weaponAttacks[key] = val; +} + void emob_read_db_additional_fields_pre(struct mob_db **entryPtr, struct config_setting_t **itPtr, int *nPtr __attribute__ ((unused)), @@ -75,6 +215,18 @@ void emob_read_db_additional_fields_pre(struct mob_db **entryPtr, if (mob->lookup_const(*itPtr, "WalkMask", &i32)) data->walkMask = i32; + + struct config_setting_t *tt = libconfig->setting_get_member(*itPtr, "WeaponAttacks"); + + if (tt && config_setting_is_group(tt)) + { + int j = 0; + struct config_setting_t *wpt = NULL; + while ((wpt = libconfig->setting_get_elem(tt, j++)) != NULL) + { + emob_load_weaponattacks(config_setting_name(wpt), libconfig->setting_get_int(wpt), data, *entryPtr); + } + } } uint32 emob_read_db_mode_sub_post(uint32 retVal, -- cgit v1.2.3-70-g09d2