From ff678a2bc1f17d5f7faa8744c2c628b1f2b96a1e Mon Sep 17 00:00:00 2001 From: Joseph Botosh Date: Sun, 3 Jul 2016 19:55:49 +0300 Subject: add Physical Shield Skill (id 20001) --- src/Makefile.am | 2 + src/emap/effects.h | 4 +- src/emap/init.c | 7 ++- src/emap/skill.c | 23 ++++++++++ src/emap/skill.h | 7 +++ src/emap/skill_const.c | 1 + src/emap/skill_const.h | 3 +- src/emap/skill_targeted.c | 22 ++++++++++ src/emap/skill_targeted.h | 14 ++++++ src/emap/status.c | 110 +++++++++++++++++++++++++++++++++++++++++++++- src/emap/status.h | 32 +++++++++++++- 11 files changed, 220 insertions(+), 5 deletions(-) create mode 100644 src/emap/skill_targeted.c create mode 100644 src/emap/skill_targeted.h diff --git a/src/Makefile.am b/src/Makefile.am index a452554..072c20c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -82,6 +82,8 @@ MAP_SRC = emap/atcommand.c \ emap/skill_const.h \ emap/skill_ground.c \ emap/skill_ground.h \ + emap/skill_targeted.h \ + emap/skill_targeted.c \ emap/status.c \ emap/status.h \ emap/unit.c \ diff --git a/src/emap/effects.h b/src/emap/effects.h index 5d03b5b..5506877 100644 --- a/src/emap/effects.h +++ b/src/emap/effects.h @@ -6,7 +6,9 @@ enum { - EFFECT_PROVOKE = 23 + EFFECT_PROVOKE = 23, + EFFECT_MAGIC_SHIELD, + EFFECT_MAGIC_SHIELD_ENDS, }; #endif // EVOL_MAP_EFFECTS diff --git a/src/emap/init.c b/src/emap/init.c index 9d21ab0..3442b26 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -84,7 +84,6 @@ HPExport struct hplugin_info pinfo = HPExport void plugin_init (void) { isInit = false; - status_init(); htreg_init(); addAtcommand("setskill", setSkill); @@ -265,10 +264,15 @@ HPExport void plugin_init (void) addHookPost(clif, damage, eclif_damage_post); addHookPost(clif, set_unit_walking, eclif_set_unit_walking_post); addHookPost(clif, move, eclif_move_post); + addHookPost(status, init, estatus_init_post); addHookPost(status, set_viewdata, estatus_set_viewdata_post); addHookPost(status, read_job_db_sub, estatus_read_job_db_sub_post); addHookPost(status, calc_pc_, estatus_calc_pc__post); addHookPost(status, calc_speed, estatus_calc_speed_post); + addHookPost(status, calc_def, estatus_calc_def_post); + addHookPost(status, calc_fix_aspd, estatus_calc_fix_aspd_post); + addHookPost(status, change_start, estatus_change_start_post); + 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(npc, get_viewdata, enpc_get_viewdata_post); @@ -288,6 +292,7 @@ HPExport void plugin_init (void) addHookPost(pc, can_insert_card_into, epc_can_insert_card_into_post); addHookPost(pc, insert_card, epc_insert_card_post); + skill->castend_nodamage_id_unknown = eskill_castend_nodamage_id_unknown; skill->additional_effect_unknown = eskill_additional_effect_unknown; skill->counter_additional_effect_unknown = eskill_counter_additional_effect_unknown; skill->attack_combo2_unknown = eskill_attack_combo2_unknown; diff --git a/src/emap/skill.c b/src/emap/skill.c index 97bd93e..e0040b6 100644 --- a/src/emap/skill.c +++ b/src/emap/skill.c @@ -21,6 +21,8 @@ #include "emap/skill.h" #include "emap/skill_const.h" #include "emap/skill_ground.h" +#include "emap/skill_targeted.h" +#include "emap/status.h" #include "plugins/HPMHooking.h" @@ -63,6 +65,27 @@ int eskill_check_condition_castend_post(int retVal, return retVal; } +bool eskill_castend_nodamage_id_unknown(struct block_list *src, + struct block_list *bl, + uint16 *skill_id, + uint16 *skill_lv, + int64 *tick __attribute__ ((unused)), + int *flag __attribute__ ((unused))) +{ + switch (*skill_id) + { + case EVOL_PHYSICAL_SHIELD: + eskill_physical_shield(src, bl, *skill_id, *skill_lv); + break; + + default: + clif->skill_nodamage(src, bl, *skill_id, *skill_lv, 1); + break; + } + map->freeblock_unlock(); + return true; +} + void eskill_additional_effect_unknown(struct block_list* src __attribute__ ((unused)), struct block_list *bl __attribute__ ((unused)), uint16 *skill_id __attribute__ ((unused)), diff --git a/src/emap/skill.h b/src/emap/skill.h index 02c0607..edb533b 100644 --- a/src/emap/skill.h +++ b/src/emap/skill.h @@ -12,6 +12,13 @@ int eskill_check_condition_castend_post(int retVal, uint16 skill_id, uint16 skill_lv); +bool eskill_castend_nodamage_id_unknown(struct block_list *src, + struct block_list *bl, + uint16 *skill_id, + uint16 *skill_lv, + int64 *tick, + int *flag); + void eskill_additional_effect_unknown(struct block_list* src, struct block_list *bl, uint16 *skill_id, diff --git a/src/emap/skill_const.c b/src/emap/skill_const.c index c5fe22b..1572f78 100644 --- a/src/emap/skill_const.c +++ b/src/emap/skill_const.c @@ -11,5 +11,6 @@ void eskill_addskill_conststants(void) { script->constdb_comment("Evol skills"); script->set_constant("EVOL_MASS_PROVOKE", EVOL_MASS_PROVOKE, false, false); + script->set_constant("EVOL_PHYSICAL_SHIELD", EVOL_PHYSICAL_SHIELD, false, false); script->constdb_comment(NULL); } diff --git a/src/emap/skill_const.h b/src/emap/skill_const.h index 762bffb..bfd10f2 100644 --- a/src/emap/skill_const.h +++ b/src/emap/skill_const.h @@ -6,7 +6,8 @@ enum { - EVOL_MASS_PROVOKE = 20000 + EVOL_MASS_PROVOKE = 20000, + EVOL_PHYSICAL_SHIELD, }; void eskill_addskill_conststants(void); diff --git a/src/emap/skill_targeted.c b/src/emap/skill_targeted.c new file mode 100644 index 0000000..372e1b3 --- /dev/null +++ b/src/emap/skill_targeted.c @@ -0,0 +1,22 @@ + +#include "map/clif.h" +#include "map/map.h" +#include "map/status.h" +#include "map/skill.h" + +void eskill_physical_shield(struct block_list *src, + struct block_list *bl, + uint16 skill_id, + uint16 skill_lv) +{ + int val1, val2, time, matk; + enum sc_type type; + + type = status->skill2sc(skill_id); + matk = status->get_matk(src, 2); + val1 = skill_lv * 10 + matk / 20; // DEF bonus + val2 = skill_lv * 5 + matk / 25; // ASPD penalty + time = skill->get_time(skill_id, skill_lv); // doesn't depends on matk + clif->skill_nodamage(src, bl, skill_id, skill_lv, + sc_start2(src, bl, type, 100, val1, val2, time)); +} diff --git a/src/emap/skill_targeted.h b/src/emap/skill_targeted.h new file mode 100644 index 0000000..716e09d --- /dev/null +++ b/src/emap/skill_targeted.h @@ -0,0 +1,14 @@ +// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// Copyright (c) 2014 - 2016 Evol developers + +#ifndef EVOL_MAP_SKILL_TARGETED +#define EVOL_MAP_SKILL_TARGETED + +#include "map/map.h" + +void eskill_physical_shield(struct block_list *src, + struct block_list *bl, + uint16 skill_id, + uint16 skill_lv); + +#endif // EVOL_MAP_SKILL_TARGETED diff --git a/src/emap/status.c b/src/emap/status.c index 13592b5..861bbd8 100644 --- a/src/emap/status.c +++ b/src/emap/status.c @@ -13,6 +13,7 @@ #include "common/nullpo.h" #include "common/socket.h" #include "common/strlib.h" +#include "common/utils.h" #include "map/itemdb.h" #include "map/map.h" #include "map/npc.h" @@ -24,7 +25,10 @@ #include "emap/npc.h" +#include "emap/effects.h" #include "emap/horse.h" +#include "emap/skill_const.h" +#include "emap/status.h" #include "emap/data/itemd.h" #include "emap/data/npcd.h" #include "emap/struct/itemdext.h" @@ -32,11 +36,39 @@ int class_move_speed[CLASS_COUNT]; -void status_init(void) +// copy of set_sc from map/status.c, because it's not exported +static void eset_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) +{ + uint16 idx; + if( (idx = skill->get_index(skill_id)) == 0 ) { + ShowError("eset_sc: Unsupported skill id %d\n", skill_id); + return; + } + if( sc < 0 || sc >= SC_MAX ) { + ShowError("eset_sc: Unsupported status change id %d\n", sc); + return; + } + + status->dbs->SkillChangeTable[sc] = skill_id; + status->dbs->IconChangeTable[sc] = icon; + status->dbs->ChangeFlagTable[sc] |= flag; + status->dbs->Skill2SCTable[idx] = sc; +} + +void eInitChangeTables(void) +{ + eset_sc(EVOL_PHYSICAL_SHIELD, (sc_type)SC_PHYSICAL_SHIELD, SI_PHYSICAL_SHIELD, SCB_DEF|SCB_DEF2|SCB_ASPD); +} + +int estatus_init_post(int retVal, + bool minimal __attribute__ ((unused))) { int f; for (f = 0; f < CLASS_COUNT; f ++) class_move_speed[f] = 150; + + eInitChangeTables(); + return retVal; } void estatus_set_viewdata_pre(struct block_list **blPtr, @@ -151,3 +183,79 @@ unsigned short estatus_calc_speed_post(unsigned short retVal, { return horse_add_speed_bonus(BL_CAST(BL_PC, bl), retVal); } + +defType estatus_calc_def_post(defType retVal, + struct block_list *bl __attribute__ ((unused)), + struct status_change *sc, + int def __attribute__ ((unused)), + bool viewable __attribute__ ((unused))) +{ + if (!sc) + return retVal; + + if (sc->data[SC_PHYSICAL_SHIELD]) + retVal += sc->data[SC_PHYSICAL_SHIELD]->val1; + + return (defType)cap_value(retVal, DEFTYPE_MIN, DEFTYPE_MAX); +} + +short estatus_calc_fix_aspd_post(short retVal, + struct block_list *bl __attribute__ ((unused)), + struct status_change *sc, + int aspd __attribute__ ((unused))) +{ + if (!sc) + return retVal; + + if (sc->data[SC_PHYSICAL_SHIELD]) + retVal -= sc->data[SC_PHYSICAL_SHIELD]->val2; + + return (short)cap_value(retVal, 0, 2000); +} + +int estatus_change_start_post(int retVal, + struct block_list *src __attribute__ ((unused)), + struct block_list *bl __attribute__ ((unused)), + enum sc_type type, + int rate __attribute__ ((unused)), + int val1 __attribute__ ((unused)), + int val2 __attribute__ ((unused)), + int val3 __attribute__ ((unused)), + int val4 __attribute__ ((unused)), + int tick __attribute__ ((unused)), + int flag __attribute__ ((unused))) +{ + if (!retVal) + return retVal; + + switch ((esc_type)type) + { + case SC_PHYSICAL_SHIELD: + clif->misceffect(bl, EFFECT_MAGIC_SHIELD); + break; + default: + break; + } + return retVal; +} + +int estatus_change_end__post(int retVal, + struct block_list* bl __attribute__ ((unused)), + enum sc_type type, + int tid __attribute__ ((unused)), + const char* file __attribute__ ((unused)), + int line __attribute__ ((unused))) +{ + if (!retVal) + return retVal; + + switch ((esc_type)type) + { + case SC_PHYSICAL_SHIELD: + clif->misceffect(bl, EFFECT_MAGIC_SHIELD_ENDS); + break; + default: + break; + } + return retVal; +} diff --git a/src/emap/status.h b/src/emap/status.h index 62bbec7..8ad69ed 100644 --- a/src/emap/status.h +++ b/src/emap/status.h @@ -4,7 +4,15 @@ #ifndef EVOL_MAP_STATUS #define EVOL_MAP_STATUS -void status_init(void); +typedef enum esc_type { + SC_PHYSICAL_SHIELD = 642, +} esc_type; + +enum esi_type { + SI_PHYSICAL_SHIELD = 966, +}; + +int estatus_init_post(int retVal, bool minimal); void estatus_set_viewdata_pre(struct block_list **blPtr, int *classPtr_ __attribute__ ((unused))); void estatus_set_viewdata_post(struct block_list *bl, @@ -22,4 +30,26 @@ unsigned short estatus_calc_speed_post(unsigned short retVal, struct status_change *sc, int speed); +defType estatus_calc_def_post(defType retVal, + struct block_list *bl, + struct status_change *sc, + int def, bool viewable); + +short estatus_calc_fix_aspd_post(short retVal, + struct block_list *bl, + struct status_change *sc, + int aspd); + +int estatus_change_start_post(int retVal, + struct block_list *src, + struct block_list *bl, + enum sc_type type, + int rate, int val1, int val2, + int val3, int val4, int tick, int flag); + +int estatus_change_end__post(int retVal, + struct block_list* bl, + enum sc_type type, int tid, + const char* file, int line); + #endif // EVOL_MAP_STATUS -- cgit v1.2.3-60-g2f50