From 8effba5658ac3026dc2b0d93d4d6186efa3d29d4 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 22 May 2020 05:02:36 +0200 Subject: Implement MSC_MAGICATTACKED cast condition for monster skills [TMW2 CHERRYPICK] --- src/map/mob.c | 4 +++- src/map/mob.h | 1 + src/map/script.c | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/map/mob.c b/src/map/mob.c index 0e89c37da..f953c3c7c 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3560,6 +3560,8 @@ static int mobskill_event(struct mob_data *md, struct block_list *src, int64 tic res = mob->skill_use(md, tick, MSC_CLOSEDATTACKED); else if (flag&BF_LONG && !(flag&BF_MAGIC)) //Long-attacked should not include magic. res = mob->skill_use(md, tick, MSC_LONGRANGEATTACKED); + else if ((flag & BF_MAGIC) != 0) + res = mob->skill_use(md, tick, MSC_MAGICATTACKED); if (!res) //Restore previous target only if skill condition failed to trigger. [Skotlex] @@ -5398,7 +5400,7 @@ static bool mob_skill_db_libconfig_sub_skill(struct config_setting_t *it, int n, ms->target = MST_TARGET; } - if (mob->lookup_const(it, "CastCondition", &i32) && (i32 < MSC_ALWAYS || i32 > MSC_SPAWN)) { + if (mob->lookup_const(it, "CastCondition", &i32) && (i32 < MSC_ALWAYS || i32 > MSC_MAGICATTACKED)) { ShowWarning("mob_skill_db_libconfig_sub_skill: Invalid skill condition %d for skill id %d in monster %d, defaulting to MSC_ALWAYS.\n", i32, skill_id, mob_id); ms->cond1 = MSC_ALWAYS; } diff --git a/src/map/mob.h b/src/map/mob.h index 9b0f6ffe0..608c28d61 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -321,6 +321,7 @@ enum { MSC_MASTERATTACKED, MSC_ALCHEMIST, MSC_SPAWN, + MSC_MAGICATTACKED, }; /** diff --git a/src/map/script.c b/src/map/script.c index d40f197e2..cf2a0c2d1 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -27101,6 +27101,7 @@ static void script_hardcoded_constants(void) script->set_constant("MSC_MASTERATTACKED", MSC_MASTERATTACKED, false, false); script->set_constant("MSC_ALCHEMIST", MSC_ALCHEMIST, false, false); script->set_constant("MSC_SPAWN", MSC_SPAWN, false, false); + script->set_constant("MSC_MAGICATTACKED", MSC_MAGICATTACKED, false, false); script->constdb_comment("monster skill targets"); script->set_constant("MST_TARGET", MST_TARGET, false, false); -- cgit v1.2.3-60-g2f50