Browse Source

♻️ pass monster by reference on MonsterHitMonster

- Sending the monster by reference instead of id
- Changed the golem check to be equal to StartDeathFromMonster
- Changed the parameters order so that the attacker comes first
pull/5106/head
Cesar Canassa 4 years ago committed by Anders Jenbo
parent
commit
c58e8b0353
  1. 14
      Source/monster.cpp

14
Source/monster.cpp

@ -1055,16 +1055,16 @@ void HitMonster(Monster &monster, int dam)
} }
} }
void MonsterHitMonster(Monster &monster, int i, int dam) void MonsterHitMonster(Monster &attacker, Monster &target, int dam)
{ {
if (i < MAX_PLRS) if (attacker.type().type == MT_GOLEM)
monster.whoHit |= 1 << i; target.whoHit |= 1 << attacker.getId(); // really the id the player who controls this golem
if (IsAnyOf(monster.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= monster.level + 3) { if (IsAnyOf(target.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= target.level + 3) {
monster.direction = Opposite(Monsters[i].direction); target.direction = Opposite(attacker.direction);
} }
HitMonster(monster, dam); HitMonster(target, dam);
} }
void StartDeathFromMonster(Monster &attacker, Monster &target) void StartDeathFromMonster(Monster &attacker, Monster &target)
@ -1217,7 +1217,7 @@ void MonsterAttackMonster(int i, int mid, int hper, int mind, int maxd)
if (monster.hitPoints >> 6 <= 0) { if (monster.hitPoints >> 6 <= 0) {
StartDeathFromMonster(attackingMonster, monster); StartDeathFromMonster(attackingMonster, monster);
} else { } else {
MonsterHitMonster(monster, i, dam); MonsterHitMonster(attackingMonster, monster, dam);
} }
if (monster.activeForTicks == 0) { if (monster.activeForTicks == 0) {

Loading…
Cancel
Save