@@ -35,10 +35,11 @@ function HumanBehaviors.GetShootingSkill()
35
35
end
36
36
37
37
-- spot targets by casting a ray in a random direction
38
- function HumanBehaviors .LookForTargets (AI , Owner , Skill ) -- Skill is obsolete here
39
- local viewAngDeg = RangeRand (35 , 85 )
38
+ function HumanBehaviors .LookForTargets (AI , Owner , Skill )
39
+ local viewAngDeg = RangeRand (50 , 120 ) * ( 0.5 + Skill / 200 )
40
40
if AI .deviceState == AHuman .AIMING then
41
- viewAngDeg = 20
41
+ AI .Ctrl :SetState (Controller .AIM_SHARP , true ) -- reinforce sharp aim controller state to enable SharpLength in LookForMOs
42
+ viewAngDeg = 15 + (Skill / 10 )
42
43
end
43
44
44
45
local FoundMO = Owner :LookForMOs (viewAngDeg , rte .grassID , false )
@@ -52,7 +53,7 @@ function HumanBehaviors.LookForTargets(AI, Owner, Skill) -- Skill is obsolete he
52
53
end
53
54
end
54
55
55
- -- brains spot targets by casting rays at all nearby enemy actors
56
+ -- brains and snipers spot targets by casting rays at all nearby enemy actors
56
57
function HumanBehaviors .CheckEnemyLOS (AI , Owner , Skill )
57
58
if not AI .Enemies then -- add all enemy actors on our screen to a table and check LOS to them, one per frame
58
59
AI .Enemies = {}
@@ -273,15 +274,14 @@ end
273
274
274
275
-- deprecated since B30. make sure we equip our preferred device if we have one. return true if we must run this function again to be sure
275
276
function HumanBehaviors .EquipPreferredWeapon (AI , Owner )
276
- if AI .squadshoot == false then
277
- if AI .PlayerPreferredHD then
278
- Owner :EquipNamedDevice (AI .PlayerPreferredHD , true )
279
- elseif not Owner :EquipDeviceInGroup (" Weapons - Primary" , true ) then
280
- Owner :EquipDeviceInGroup (" Weapons - Secondary" , true )
281
- end
282
- return false
277
+ if AI .squadShoot == false then
278
+ if AI .PlayerPreferredHD then
279
+ Owner :EquipNamedDevice (AI .PlayerPreferredHD , true )
280
+ elseif not Owner :EquipDeviceInGroup (" Weapons - Primary" , true ) then
281
+ Owner :EquipDeviceInGroup (" Weapons - Secondary" , true )
282
+ end
283
+ return false
283
284
end
284
-
285
285
end
286
286
287
287
-- deprecated since B30. make sure we equip a primary weapon if we have one. return true if we must run this function again to be sure
@@ -1666,7 +1666,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
1666
1666
1667
1667
if Waypoint then -- move towards the waypoint
1668
1668
-- control horizontal movement
1669
- -- if Owner.FGLeg or Owner.BGLeg then -- test
1669
+ if Owner .FGLeg or Owner .BGLeg then
1670
1670
if not AI .flying then
1671
1671
if CurrDist .X < - 3 then
1672
1672
nextLatMove = Actor .LAT_LEFT
@@ -1675,14 +1675,14 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
1675
1675
else
1676
1676
nextLatMove = Actor .LAT_STILL
1677
1677
end
1678
- if not Owner .FGLeg and not Owner .BGLeg then
1678
+ if not ( Owner .FGLeg and Owner .BGLeg ) and not AI . jump then
1679
1679
Owner :GetController ():SetState (Controller .BODY_CROUCH ,true ) -- crawl if no legs
1680
1680
end
1681
1681
end
1682
- -- elseif ((CurrDist.X < -5 and Owner.HFlipped) or (CurrDist.X > 5 and not Owner.HFlipped)) and math.abs(Owner.Vel.X) < 1 then
1683
- -- -- no legs, jump forward
1684
- -- AI.jump = true
1685
- -- end
1682
+ elseif ((CurrDist .X < - 5 and Owner .HFlipped ) or (CurrDist .X > 5 and not Owner .HFlipped )) and math.abs (Owner .Vel .X ) < 1 then
1683
+ -- no legs, jump forward
1684
+ AI .jump = true
1685
+ end
1686
1686
1687
1687
if Waypoint .Type == " right" then
1688
1688
if CurrDist .X > - 3 then
@@ -2007,7 +2007,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
2007
2007
if (AI .Target and AI .BehaviorName ~= " AttackTarget" ) or
2008
2008
(Owner .AIMode ~= Actor .AIMODE_SQUAD and (AI .BehaviorName == " ShootArea" or AI .BehaviorName == " FaceAlarm" ))
2009
2009
then
2010
- if AI . behaviorType == 1 then -- aggressive (4zK)
2010
+ if Owner . aggressive then -- the aggressive behavior setting makes the AI pursue waypoint at all times
2011
2011
AI .lateralMoveState = nextLatMove
2012
2012
else
2013
2013
AI .lateralMoveState = Actor .LAT_STILL
@@ -2431,7 +2431,7 @@ function HumanBehaviors.ShootTarget(AI, Owner, Abort)
2431
2431
end
2432
2432
2433
2433
if AI .canHitTarget then
2434
- if AI . behaviorType ~= 1 then -- non-aggressive
2434
+ if not Owner . aggressive then
2435
2435
AI .lateralMoveState = Actor .LAT_STILL
2436
2436
end
2437
2437
if not AI .flying then
@@ -2818,36 +2818,33 @@ function HumanBehaviors.AttackTarget(AI, Owner, Abort)
2818
2818
if not AI .Target or not MovableMan :ValidMO (AI .Target ) then
2819
2819
break
2820
2820
end
2821
- -- Use following sequence to attack either with a suited melee weapon or arms
2822
- local meleeDist = 0 ;
2823
- local startPos = Vector (Owner .EyePos .X , Owner .EyePos .Y );
2821
+ -- use following sequence to attack either with a suited melee weapon or arms
2822
+ local meleeDist = 0
2823
+ local startPos = Vector (Owner .EyePos .X , Owner .EyePos .Y )
2824
2824
2825
2825
if Owner .EquippedItem then
2826
- if Owner .EquippedItem :HasObjectInGroup (" Tools - Diggers" )
2827
- or Owner .EquippedItem :HasObjectInGroup (" Weapons - Melee" ) then
2828
-
2829
- meleeDist = Owner .Radius + 25 ;
2830
- startPos = Vector (Owner .EquippedItem .Pos .X , Owner .EquippedItem .Pos .Y );
2831
- end
2832
- --[[ disabled
2833
- elseif Owner.FGArm then
2834
- meleeDist = Owner.Radius + Owner.FGArm.Radius;
2835
- startPos = Owner.FGArm.Pos;
2836
- elseif Owner.BGArm then
2837
- meleeDist = Owner.Radius + Owner.BGArm.Radius;
2838
- startPos = Owner.BGArm.Pos;
2839
- ]] --
2826
+ if Owner .EquippedItem :HasObjectInGroup (" Tools - Diggers" ) or Owner .EquippedItem :HasObjectInGroup (" Weapons - Melee" ) then
2827
+ meleeDist = Owner .Radius + 25
2828
+ startPos = Vector (Owner .EquippedItem .Pos .X , Owner .EquippedItem .Pos .Y )
2829
+ end
2830
+ elseif Owner .armSway then
2831
+ if Owner .FGArm then
2832
+ meleeDist = Owner .Radius + Owner .FGArm .Radius
2833
+ startPos = Owner .FGArm .Pos
2834
+ elseif Owner .BGArm then
2835
+ meleeDist = Owner .Radius + Owner .BGArm .Radius
2836
+ startPos = Owner .BGArm .Pos
2837
+ end
2840
2838
end
2841
2839
if meleeDist > 0 then
2842
-
2843
- local Dist = SceneMan :ShortestDistance (startPos , AI .Target .Pos , false )
2844
- if Dist .Magnitude < meleeDist then
2845
- AI .Ctrl .AnalogAim = SceneMan :ShortestDistance (Owner .EyePos , AI .Target .Pos , false ).Normalized ;
2840
+ local dist = SceneMan :ShortestDistance (startPos , AI .Target .Pos , false )
2841
+ if dist .Magnitude < meleeDist then
2842
+ AI .Ctrl .AnalogAim = SceneMan :ShortestDistance (Owner .EyePos , AI .Target .Pos , false ).Normalized
2846
2843
AI .fire = true
2847
2844
else
2848
2845
AI .fire = false
2849
2846
end
2850
- else -- if not Owner:EquipDiggingTool(true) then
2847
+ else
2851
2848
break
2852
2849
-- else TODO: periodically look for weapons?
2853
2850
end
@@ -3100,7 +3097,7 @@ function HumanBehaviors.FaceAlarm(AI, Owner, Abort)
3100
3097
AI .AlarmPos = nil
3101
3098
for _ = 1 , math.ceil (200 / TimerMan .DeltaTimeMS ) do
3102
3099
AI .deviceState = AHuman .AIMING
3103
- if AI . behaviorType ~= 1 then -- non-aggressive
3100
+ if not Owner . aggressive then
3104
3101
AI .lateralMoveState = Actor .LAT_STILL
3105
3102
end
3106
3103
AI .Ctrl .AnalogAim = AlarmDist .Normalized
0 commit comments