aboutsummaryrefslogtreecommitdiff
path: root/src/crnonpl.cc
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2026-05-25 18:19:39 -0300
committerfusion32 <marcopuzziello@gmail.com>2026-05-25 18:19:39 -0300
commitd1c4dce3be82aa7e50ddb5b43f15ecc00a16f985 (patch)
treec0fe2487aec4ea0cf90c74121992464344abd5b1 /src/crnonpl.cc
parent54c2169ec9a99e34e1270e43e9fd1fccd3d2a824 (diff)
downloadgame-d1c4dce3be82aa7e50ddb5b43f15ecc00a16f985.tar.gz
game-d1c4dce3be82aa7e50ddb5b43f15ecc00a16f985.zip
minor fix to monster targeting logic
Diffstat (limited to 'src/crnonpl.cc')
-rw-r--r--src/crnonpl.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/crnonpl.cc b/src/crnonpl.cc
index 477b18b..03be196 100644
--- a/src/crnonpl.cc
+++ b/src/crnonpl.cc
@@ -2459,7 +2459,7 @@ void TMonster::IdleStimulus(void){
int DistanceX = std::abs(Target->posx - this->posx);
int DistanceY = std::abs(Target->posy - this->posy);
if((Target->posz != this->posz || DistanceX > 10 || DistanceY > 10)
- ||(Target->Type == PLAYER && CheckRight(Target->ID, IGNORED_BY_MONSTERS))
+ || (Target->Type == PLAYER && CheckRight(Target->ID, IGNORED_BY_MONSTERS))
|| (Target->IsInvisible() && !RaceData[this->Race].SeeInvisible)
|| IsProtectionZone(Target->posx, Target->posy, Target->posz)
|| IsHouse(Target->posx, Target->posy, Target->posz)
@@ -2484,7 +2484,7 @@ void TMonster::IdleStimulus(void){
// NOTE(fusion): We're looking for the creature that maximizes
// the strategy parameter.
int TieBreaker = random(0, 99);
- if(StrategyParam >= BestStrategyParam
+ if(StrategyParam > BestStrategyParam
||(StrategyParam == BestStrategyParam && TieBreaker > BestTieBreaker)){
this->Target = TargetID;
BestTieBreaker = TieBreaker;
@@ -2786,6 +2786,8 @@ void TMonster::IdleStimulus(void){
if(this->State == ATTACKING || this->State == PANIC){
this->Rotate(Target);
+ // TODO(fusion): This condition should be always true because we're
+ // already running on the ELSE branch of `this->Master == this->Target`.
if(this->Master != this->Target){
this->ToDoAttack();
}else{
@@ -2841,6 +2843,9 @@ void TMonster::IdleStimulus(void){
this->ToDoWait(1000);
this->ToDoStart();
}catch(RESULT r){
+ // TODO(fusion): This shouldn't be possible? Otherwise the creature
+ // might become stuck since we're not calling ToDoStart or ToDoYield.
+ // Probably just fallback to ToDoWait(1000)?
error("TMonster::IdleStimulus: Exception %d.\n", r);
}
}else{