Skip to content

Commit d5d72a4

Browse files
committed
Further AI tweaks and fixes, maybe I'm starting to understand
1 parent ddc6b56 commit d5d72a4

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

Data/Base.rte/AI/HumanBehaviors.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ function HumanBehaviors.WeaponSearch(AI, Owner, Abort)
670670
prevSceneWaypoint = SceneMan:MovePointToGround(Owner:GetLastAIWaypoint(), Owner.Height/5, 4); -- last wpt or current pos
671671
end
672672

673-
Owner:ClearMovePath();
673+
Owner:ClearAIWaypoints();
674674
Owner:AddAIMOWaypoint(AI.PickupHD);
675675

676676
if prevMoveTarget then
@@ -786,7 +786,7 @@ function HumanBehaviors.ToolSearch(AI, Owner, Abort)
786786
prevSceneWaypoint = SceneMan:MovePointToGround(Owner:GetLastAIWaypoint(), Owner.Height/5, 4); -- last wpt or current pos
787787
end
788788

789-
Owner:ClearMovePath();
789+
Owner:ClearAIWaypoints();
790790
Owner:AddAIMOWaypoint(AI.PickupHD);
791791

792792
if Owner.AIMode ~= Actor.AIMODE_GOLDDIG then

Data/Base.rte/AI/SharedBehaviors.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
612612
if Owner.MOMoveTarget and MovableMan:ValidMO(Owner.MOMoveTarget) then
613613
local Trace = SceneMan:ShortestDistance(Owner.Pos, Owner.MOMoveTarget.Pos, false);
614614

615+
-- WTF is the following code for? It causes us to idle and do nothing forever??
615616
if Owner.MOMoveTarget.Team == Owner.Team then
616617
if Trace.Largest > Owner.Height * 0.3 + (Owner.MOMoveTarget.Height or 100) * 0.3 then
617618
Waypoint.Pos = Owner.MOMoveTarget.Pos;
@@ -1008,7 +1009,7 @@ function SharedBehaviors.GoToWpt(AI, Owner, Abort)
10081009
end
10091010

10101011
-- movement commands
1011-
if (AI.Target and AI.BehaviorName ~= "AttackTarget") or (Owner.AIMode ~= Actor.AIMODE_SQUAD and (AI.BehaviorName == "ShootArea" or AI.BehaviorName == "FaceAlarm")) then
1012+
if (AI.Target and AI.BehaviorName ~= "AttackTarget" and not AI.PickupHD) or (Owner.AIMode ~= Actor.AIMODE_SQUAD and (AI.BehaviorName == "ShootArea" or AI.BehaviorName == "FaceAlarm")) then
10121013
if Owner.aggressive then -- the aggressive behavior setting makes the AI pursue waypoint at all times
10131014
AI.lateralMoveState = nextLatMove;
10141015
else

Source/System/PathFinder.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ int PathFinder::CalculatePath(Vector start, Vector end, std::list<Vector>& pathR
174174

175175
// How high up we can jump from this node
176176
s_JumpHeightVertical = std::max(1, static_cast<int>(jumpHeight / (m_NodeDimension * c_MPP))); // min of 1 so automovers work a bit better
177-
s_JumpHeightDiagonal = static_cast<int>((jumpHeight * 0.7F) / (m_NodeDimension * c_MPP));
177+
s_JumpHeightDiagonal = std::max(1, static_cast<int>((jumpHeight * 0.7F) / (m_NodeDimension * c_MPP)));
178178

179179
// Actors capable of digging can use s_DigStrength to modify the node adjacency cost.
180180
s_DigStrength = digStrength;
@@ -206,10 +206,8 @@ int PathFinder::CalculatePath(Vector start, Vector end, std::list<Vector>& pathR
206206
}
207207

208208
// Adjust the last point to be exactly where the end is supposed to be (really?).
209-
if (pathResult.size() > 2) {
210-
pathResult.pop_back();
211-
pathResult.push_back(end);
212-
}
209+
pathResult.pop_back();
210+
pathResult.push_back(end);
213211
} else {
214212
// Empty path, give exact start and end.
215213
pathResult.push_back(start);

0 commit comments

Comments
 (0)