Browse Source

♻️ Remove monsterId from StartDeathFromMonster (#5072)

pull/5099/head
Cesar Canassa 4 years ago committed by GitHub
parent
commit
c79b15df1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      Source/monster.cpp

25
Source/monster.cpp

@ -1067,24 +1067,19 @@ void MonsterHitMonster(Monster &monster, int i, int dam)
HitMonster(monster, dam);
}
void StartDeathFromMonster(int i, int mid)
void StartDeathFromMonster(Monster &attacker, Monster &target)
{
assert(static_cast<size_t>(i) < MaxMonsters);
Monster &killer = Monsters[i];
assert(static_cast<size_t>(mid) < MaxMonsters);
Monster &monster = Monsters[mid];
delta_kill_monster(monster, monster.position.tile, *MyPlayer);
NetSendCmdLocParam1(false, CMD_MONSTDEATH, monster.position.tile, mid);
delta_kill_monster(target, target.position.tile, *MyPlayer);
NetSendCmdLocParam1(false, CMD_MONSTDEATH, target.position.tile, target.getId());
if (killer.type().type == MT_GOLEM)
monster.whoHit |= 1 << i;
if (attacker.type().type == MT_GOLEM)
target.whoHit |= 1 << attacker.getId(); // really the id the player who controls this golem
Direction md = GetDirection(monster.position.tile, killer.position.tile);
MonsterDeath(monster, md, true);
Direction md = GetDirection(target.position.tile, attacker.position.tile);
MonsterDeath(target, md, true);
if (gbIsHellfire)
M_StartStand(killer, killer.direction);
M_StartStand(attacker, attacker.direction);
}
void StartFadein(Monster &monster, Direction md, bool backwards)
@ -1204,6 +1199,7 @@ void MonsterAttackMonster(int i, int mid, int hper, int mind, int maxd)
{
assert(static_cast<size_t>(mid) < MaxMonsters);
auto &monster = Monsters[mid];
Monster &attackingMonster = Monsters[i];
if (!monster.isPossibleToHit())
return;
@ -1219,12 +1215,11 @@ void MonsterAttackMonster(int i, int mid, int hper, int mind, int maxd)
int dam = (mind + GenerateRnd(maxd - mind + 1)) << 6;
monster.hitPoints -= dam;
if (monster.hitPoints >> 6 <= 0) {
StartDeathFromMonster(i, mid);
StartDeathFromMonster(attackingMonster, monster);
} else {
MonsterHitMonster(monster, i, dam);
}
Monster &attackingMonster = Monsters[i];
if (monster.activeForTicks == 0) {
monster.activeForTicks = UINT8_MAX;
monster.position.last = attackingMonster.position.tile;

Loading…
Cancel
Save