Browse Source

Fixes a couple mob skill conditions (#7151)

* Fixes #7141.
* Follow up to 36b9b94.
* Fixes an issue with mob skill conditions closedattacked and longrangeattacked not triggering for skills with no aMotion.
Thanks to @datawulf!
Aleos 2 years ago
parent
commit
77b4b3ccea
2 changed files with 22 additions and 10 deletions
  1. 13 9
      src/map/battle.cpp
  2. 9 1
      src/map/skill.cpp

+ 13 - 9
src/map/battle.cpp

@@ -278,17 +278,21 @@ void battle_damage(struct block_list *src, struct block_list *target, int64 dama
 		skill_counter_additional_effect(src, target, skill_id, skill_lv, attack_type, tick);
 	// This is the last place where we have access to the actual damage type, so any monster events depending on type must be placed here
 	if (target->type == BL_MOB) {
-		struct mob_data* md = BL_CAST(BL_MOB, target);
+		mob_data *md = BL_CAST(BL_MOB, target);
 
-		if (!status_isdead(target) && src != target) {
-			if (damage > 0 )
-				mobskill_event(md, src, tick, attack_type);
-			if (skill_id)
-				mobskill_event(md, src, tick, MSC_SKILLUSED|(skill_id<<16));
-		}
+		if (md != nullptr) {
+			// Trigger monster skill condition for non-skill attacks.
+			if (!status_isdead(target) && src != target) {
+				if (damage > 0)
+					mobskill_event(md, src, tick, attack_type);
+				if (skill_id > 0)
+					mobskill_event(md, src, tick, MSC_SKILLUSED | (skill_id << 16));
+			}
 
-		if (damage && (attack_type&BF_NORMAL)) // Monsters differentiate whether they have been attacked by a skill or a normal attack
-			md->norm_attacked_id = md->attacked_id;
+			// Monsters differentiate whether they have been attacked by a skill or a normal attack
+			if (damage > 0 && (attack_type & BF_NORMAL))
+				md->norm_attacked_id = md->attacked_id;
+		}
 	}
 	map_freeblock_unlock();
 }

+ 9 - 1
src/map/skill.cpp

@@ -3891,6 +3891,14 @@ int64 skill_attack (int attack_type, struct block_list* src, struct block_list *
 				skill_counter_additional_effect(src, bl, skill_id, skill_lv, dmg.flag, tick);
 		} else
 			battle_delay_damage(tick, dmg.amotion,src,bl,dmg.flag,skill_id,skill_lv,damage,dmg.dmg_lv,dmg.dmotion, additional_effects, false);
+	} else {
+		// Trigger monster skill condition for damage skills with no amotion.
+		if (bl->type == BL_MOB && src != bl && !status_isdead(bl)) {
+			if (damage > 0)
+				mobskill_event(BL_CAST(BL_MOB, bl), src, tick, dmg.flag);
+			if (skill_id > 0)
+				mobskill_event(BL_CAST(BL_MOB, bl), src, tick, MSC_SKILLUSED | (skill_id << 16));
+		}
 	}
 
 	if (tsc  && skill_id != NPC_EVILLAND && skill_id != SP_SOULEXPLOSION && skill_id != SJ_NOVAEXPLOSING
@@ -12454,7 +12462,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 			status_change_end(src,SC_CURSEDCIRCLE_ATKER,INVALID_TIMER);
 	}
 
-	if (dstmd) { //Mob skill event for no damage skills (damage ones are handled in battle_calc_damage) [Skotlex]
+	if (dstmd) { //Mob skill event for no damage skills (damage ones are handled in battle_damage/skill_attack) [Skotlex]
 		mob_log_damage(dstmd, src, 0); //Log interaction (counts as 'attacker' for the exp bonus)
 		mobskill_event(dstmd, src, tick, MSC_SKILLUSED|(skill_id<<16));
 	}