Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit c8320a2

Browse files
committed
AI fixes: Perceptiveness now affects lua AI, AHumans look around when sentrying, drop ships drop bombs at a proper height
1 parent 8ee9a35 commit c8320a2

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Base.rte/AI/CrabBehaviors.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
CrabBehaviors = {}
33

44
function CrabBehaviors.LookForTargets(AI, Owner)
5-
local viewAngDeg = RangeRand(35, 85)
5+
local viewAngDeg = RangeRand(35, 85) * Owner.Perceptiveness
66
if AI.deviceState == AHuman.AIMING then
7-
viewAngDeg = 20
7+
AI.Ctrl:SetState(Controller.AIM_SHARP, true)
8+
viewAngDeg = 20 * Owner.Perceptiveness
89
end
910

1011
local HitPoint

Base.rte/AI/HumanBehaviors.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ end
3636

3737
-- spot targets by casting a ray in a random direction
3838
function HumanBehaviors.LookForTargets(AI, Owner, Skill)
39-
local viewAngDeg = RangeRand(50, 120) * (0.5 + Skill / 200)
39+
local viewAngDeg = RangeRand(50, 120) * Owner.Perceptiveness * (0.5 + Skill / 200)
4040
if AI.deviceState == AHuman.AIMING then
4141
AI.Ctrl:SetState(Controller.AIM_SHARP, true) -- reinforce sharp aim controller state to enable SharpLength in LookForMOs
42-
viewAngDeg = 15 + (Skill / 10)
42+
viewAngDeg = 15 * Owner.Perceptiveness + (Skill / 10)
4343
end
4444

4545
local FoundMO = Owner:LookForMOs(viewAngDeg, rte.grassID, false)
@@ -500,6 +500,13 @@ function HumanBehaviors.Sentry(AI, Owner, Abort)
500500
elseif AI.SentryFacing and Owner.HFlipped ~= AI.SentryFacing then
501501
Owner.HFlipped = AI.SentryFacing -- turn to the direction we have been order to guard
502502
break -- restart this behavior
503+
elseif math.random() < Owner.Perceptiveness then
504+
505+
-- turn around occasionally if there is open space behind our back
506+
local backAreaRay = Vector(-math.random(FrameMan.PlayerScreenWidth/4, FrameMan.PlayerScreenWidth/2) * Owner.FlipFactor, 0):DegRotate(math.random(-25, 25) * Owner.Perceptiveness)
507+
if not SceneMan:CastStrengthRay(Owner.EyePos, backAreaRay, 10, Vector(), 10, rte.grassID, SceneMan.SceneWrapsX) then
508+
Owner.HFlipped = Owner.FlipFactor == 1 and true or false
509+
end
503510
end
504511
end
505512
end

Base.rte/AI/NativeDropShipAI.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ function NativeDropShipAI:Create(Owner)
1616

1717
Members.LastAIMode = Actor.AIMODE_NONE
1818

19+
local item = Owner:Inventory();
20+
if item and IsTDExplosive(item) then
21+
Members.AIMode = Actor.AIMODE_BOMB;
22+
end
23+
1924
-- The drop ship tries to hover this many pixels above the ground
2025
if Members.AIMode == Actor.AIMODE_BRAINHUNT then
2126
Members.hoverAlt = Owner.Radius * 1.7
2227
elseif Members.AIMode == Actor.AIMODE_BOMB then
23-
Members.hoverAlt = Owner.Radius * 7
28+
Members.hoverAlt = Owner.Radius * 6
2429
else
2530
Members.hoverAlt = Owner.Radius * 2
2631
end

0 commit comments

Comments
 (0)