Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite joining/leaving bosspack #6739

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3673,6 +3673,7 @@ void ProcessStoneCurse(Missile &missile)
monster.animInfo.isPetrified = false;
} else {
AddCorpse(monster.position.tile, stonendx, monster.direction);
M_UpdateRelations(monster);
}
}
if (missile._miAnimType == MissileGraphicID::StoneCurseShatter)
Expand Down
33 changes: 22 additions & 11 deletions Source/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,15 +1602,12 @@ void GroupUnity(Monster &monster)

auto &leader = *monster.getLeader();
if (IsLineNotSolid(monster.position.tile, leader.position.future)) {
if (monster.leaderRelation == LeaderRelation::Separated
&& monster.position.tile.WalkingDistance(leader.position.future) < 4) {
if (monster.position.tile.WalkingDistance(leader.position.future) < 4) {
// Reunite the separated monster with the pack
leader.packSize++;
monster.leaderRelation = LeaderRelation::Leashed;
M_JoinLeaderPack(monster);
}
} else if (monster.leaderRelation == LeaderRelation::Leashed) {
leader.packSize--;
monster.leaderRelation = LeaderRelation::Separated;
} else {
M_SeparateFromLeaderPack(monster);
}

if (monster.leaderRelation == LeaderRelation::Leashed) {
Expand Down Expand Up @@ -2101,10 +2098,7 @@ void ScavengerAi(Monster &monster)
if (monster.mode != MonsterMode::Stand)
return;
if (monster.hitPoints < (monster.maxHitPoints / 2) && monster.goal != MonsterGoal::Healing) {
if (monster.leaderRelation != LeaderRelation::None) {
ShrinkLeaderPacksize(monster);
monster.leaderRelation = LeaderRelation::None;
}
M_SeparateFromLeaderPack(monster);
monster.goal = MonsterGoal::Healing;
monster.goalVar3 = 10;
}
Expand Down Expand Up @@ -3767,6 +3761,22 @@ void M_UpdateRelations(const Monster &monster)
ShrinkLeaderPacksize(monster);
}

void M_SeparateFromLeaderPack(Monster &monster)
{
if (monster.leaderRelation == LeaderRelation::Leashed) {
monster.getLeader()->packSize--;
monster.leaderRelation = LeaderRelation::Separated;
}
}

void M_JoinLeaderPack(Monster &monster)
{
if (monster.leaderRelation == LeaderRelation::Separated) {
monster.getLeader()->packSize++;
monster.leaderRelation = LeaderRelation::Leashed;
}
}

void DoEnding()
{
if (gbIsMultiplayer) {
Expand Down Expand Up @@ -4662,6 +4672,7 @@ void Monster::petrify()
{
mode = MonsterMode::Petrified;
animInfo.isPetrified = true;
M_SeparateFromLeaderPack(*this);
}

bool Monster::isWalking() const
Expand Down
2 changes: 2 additions & 0 deletions Source/monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ void KillMyGolem();
void M_StartKill(Monster &monster, const Player &player);
void M_SyncStartKill(Monster &monster, Point position, const Player &player);
void M_UpdateRelations(const Monster &monster);
void M_SeparateFromLeaderPack(Monster &monster);
void M_JoinLeaderPack(Monster &monster);
void DoEnding();
void PrepDoEnding();
bool Walk(Monster &monster, Direction md);
Expand Down