aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cract.cc2
-rw-r--r--src/crnonpl.cc9
2 files changed, 8 insertions, 3 deletions
diff --git a/src/cract.cc b/src/cract.cc
index e0af29f..52355c1 100644
--- a/src/cract.cc
+++ b/src/cract.cc
@@ -1016,7 +1016,7 @@ void TCreature::ToDoGo(int DestX, int DestY, int DestZ, bool MustReach, int MaxS
// NOTE(fusion): The number of steps between two points is the same as the
// their manhattan distance, if we exclude diagonal movement. We can skip
- // the path finder if we know we're step away from the destination.
+ // the path finder if we know we're one step away from the destination.
if(DistanceX + DistanceY == 1){
TToDoEntry TD = {};
TD.Code = TDGo;
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{