diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-05-22 00:11:55 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-05-22 00:11:55 -0300 |
commit | 7cfac55bf7c74e82ad31907094a27436690c8258 (patch) | |
tree | e5111b229785ab4a3206c53f62120c922813b6f7 | |
parent | 6cbd6ddfc240f0380cb2ce08b6973fca7a37b44b (diff) | |
download | evol-hercules-7cfac55bf7c74e82ad31907094a27436690c8258.tar.gz evol-hercules-7cfac55bf7c74e82ad31907094a27436690c8258.tar.bz2 evol-hercules-7cfac55bf7c74e82ad31907094a27436690c8258.tar.xz evol-hercules-7cfac55bf7c74e82ad31907094a27436690c8258.zip |
TMW2 Plugin: Support for skill target on script skills.
Moved around some other critical function details, be warned.
-rw-r--r-- | src/emap/battle.c | 1 | ||||
-rw-r--r-- | src/emap/init.c | 2 | ||||
-rw-r--r-- | src/emap/skill.c | 91 | ||||
-rw-r--r-- | src/emap/skill.h | 18 |
4 files changed, 108 insertions, 4 deletions
diff --git a/src/emap/battle.c b/src/emap/battle.c index 7ac0a60..2a7b642 100644 --- a/src/emap/battle.c +++ b/src/emap/battle.c @@ -98,6 +98,7 @@ struct Damage ebattle_calc_weapon_attack_post(struct Damage retVal, // (regardless of source or target) if (retVal.type == BDT_CRIT) { // Minimum damage for criticals (per ML rule) + // FIXME: Ignore plants/bifs/etc. if (retVal.damage <= 10) retVal.damage=10; /* This needs fixing diff --git a/src/emap/init.c b/src/emap/init.c index 7c51918..95f9e19 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -375,6 +375,8 @@ HPExport void plugin_init (void) // TMW2 Custom Pre Hooks //addHookPre(battle, calc_weapon_attack, ebattle_calc_weapon_attack_pre); + //addHookPre(skill, castend_type, eskill_castend_type_pre); + //addHookPost(skill, castend_type, eskill_castend_type_post); addHookPost(battle, calc_weapon_attack, ebattle_calc_weapon_attack_post); addHookPost(battle, calc_magic_attack, ebattle_calc_weapon_attack_post); diff --git a/src/emap/skill.c b/src/emap/skill.c index 2cf45cc..38fb265 100644 --- a/src/emap/skill.c +++ b/src/emap/skill.c @@ -48,7 +48,8 @@ int eskill_check_condition_castend_post(int retVal, uint16 skill_id, uint16 skill_lv) { - if (retVal && sd) + // TMW2: Disabled (see below) + if (0 && retVal && sd) { struct linkdb_node **label_linkdb = strdb_get(npc->ev_label_db, "OnSkillInvoke"); if (label_linkdb == NULL) @@ -70,6 +71,7 @@ int eskill_check_condition_castend_post(int retVal, return retVal; } +// TODO: eskill_castend_damage_id_unknown / Unused but now broken bool eskill_castend_nodamage_id_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, @@ -77,6 +79,7 @@ bool eskill_castend_nodamage_id_unknown(struct block_list *src, int64 *tick __attribute__ ((unused)), int *flag __attribute__ ((unused))) { + //ShowDebug("Cast end nodamage id unknown!\n"); switch (*skill_id) { case EVOL_PHYSICAL_SHIELD: @@ -87,6 +90,38 @@ bool eskill_castend_nodamage_id_unknown(struct block_list *src, clif->skill_nodamage(src, bl, *skill_id, *skill_lv, 1); break; } + //ShowDebug("Operation start!\n"); + // 1: Check if src can become a sd; If not, ABORT + struct map_session_data *sd = NULL; + sd = BL_CAST(BL_PC, src); + if (!sd) + return true; + + //ShowDebug("Source found!\n"); + // 2: Add skill target info + pc->setreg(sd, script->add_variable("@skillTarget"), bl->id); + pc->setreg(sd, script->add_variable("@skillTargetX"), bl->x); + pc->setreg(sd, script->add_variable("@skillTargetY"), bl->y); + //ShowDebug("Data filled! Targed was %d\n", bl->id); + if (sd) + { + struct linkdb_node **label_linkdb = strdb_get(npc->ev_label_db, "OnSkillInvoke"); + if (label_linkdb == NULL) + return true; + + struct linkdb_node *node = *label_linkdb; + while (node) + { + struct event_data* ev = node->data; + if (ev) + { + pc->setreg(sd, script->add_variable("@skillId"), *skill_id); + pc->setreg(sd, script->add_variable("@skillLv"), *skill_lv); + script->run(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id); + } + node = node->next; + } + } map->freeblock_unlock(); return true; } @@ -276,7 +311,7 @@ int eskill_calc_heal_post(int retVal, // Only affects healing if (sd && tsd && skill_id == AL_HEAL) { - ShowDebug("Skill is healing and SD is set. ACC ID %d.\n", sd->login_id2); + //ShowDebug("Skill is healing and SD is set. ACC ID %d.\n", sd->login_id2); // Only if self-target if (sd->login_id2 == tsd->login_id2) { // Recalculate everything with VIT instead @@ -296,8 +331,8 @@ int eskill_calc_heal_post(int retVal, hp+=tmp; else hp+=tmp1; - ShowDebug("Redefined (idx=%d original %d)\n", hp, retVal); - ShowDebug("TMP %d TMP1 %d Won %d)\n", tmp, tmp1, hp); + //ShowDebug("Redefined (idx=%d original %d)\n", hp, retVal); + //ShowDebug("TMP %d TMP1 %d Won %d)\n", tmp, tmp1, hp); } } if (hp) @@ -335,4 +370,52 @@ int eskill_consume_requirement_post(int retVal, return retVal; } +/* +void eskill_castend_type_post(int *type __attribute__ ((unused)), + struct block_list *src, + struct block_list *bl, + uint16 skill_id __attribute__ ((unused)), + uint16 skill_lv __attribute__ ((unused)), + int64 tick __attribute__ ((unused)), + int flag __attribute__ ((unused))) +{ + ShowDebug("Cast end type POST!\n"); + // 1: Check if src can become a sd; If not, ABORT + struct map_session_data *sd = NULL; + sd = BL_CAST(BL_PC, src); + if (!sd) + return; + + ShowDebug("Source found!\n"); + // 2: Add skill target info + pc->setreg(sd, script->add_variable("@skillTarget"), bl->id); + pc->setreg(sd, script->add_variable("@skillTargetX"), bl->x); + pc->setreg(sd, script->add_variable("@skillTargetY"), bl->y); + ShowDebug("Data filled! Targed was %d\n", bl->id); +} + +void eskill_castend_type_pre(int *type __attribute__ ((unused)), + struct block_list **src, + struct block_list **blPtr, + uint16 *skill_id __attribute__ ((unused)), + uint16 *skill_lv __attribute__ ((unused)), + int64 *tick __attribute__ ((unused)), + int *flag __attribute__ ((unused))) +{ + ShowDebug("Cast end type PRE!\n"); + // 1: Check if src can become a sd; If not, ABORT + struct map_session_data *sd = NULL; + sd = BL_CAST(BL_PC, *src); + if (!sd) + return; + + ShowDebug("Source found!\n"); + struct block_list *bl = *blPtr; + // 2: Add skill target info + pc->setreg(sd, script->add_variable("@skillTarget"), bl->id); + pc->setreg(sd, script->add_variable("@skillTargetX"), bl->x); + pc->setreg(sd, script->add_variable("@skillTargetY"), bl->y); + ShowDebug("Data filled! Targed was %d\n", bl->id); +} +*/ diff --git a/src/emap/skill.h b/src/emap/skill.h index aa400d8..a273121 100644 --- a/src/emap/skill.h +++ b/src/emap/skill.h @@ -109,4 +109,22 @@ int eskill_consume_requirement_post(int retVal, struct map_session_data *sd, uint16 skill_id, uint16 skill_lv, short type); +/* +void eskill_castend_type_post(int type __attribute__ ((unused)), + struct block_list *src, + struct block_list *bl, + uint16 skill_id __attribute__ ((unused)), + uint16 skill_lv __attribute__ ((unused)), + int64 tick __attribute__ ((unused)), + int flag __attribute__ ((unused))); + +void eskill_castend_type_pre(int *type __attribute__ ((unused)), + struct block_list **src, + struct block_list **blPtr, + uint16 *skill_id __attribute__ ((unused)), + uint16 *skill_lv __attribute__ ((unused)), + int64 *tick __attribute__ ((unused)), + int *flag __attribute__ ((unused))); +*/ + #endif // EVOL_MAP_SKILL |