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

Commit 21345af

Browse files
committed
Account for throw logic changes in the lua AI
1 parent 53ff223 commit 21345af

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Base.rte/AI/HumanBehaviors.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,14 +2754,21 @@ function HumanBehaviors.ThrowTarget(AI, Owner, Abort)
27542754
if Owner.ThrowableIsReady then
27552755
local Grenade = ToThrownDevice(Owner.EquippedItem)
27562756
if Grenade then
2757-
aim = HumanBehaviors.GetGrenadeAngle(AimPoint, Vector(), Grenade.MuzzlePos, Grenade.MaxThrowVel)
2757+
local maxThrowVel = Grenade.MaxThrowVel
2758+
local minThrowVel = Grenade.MinThrowVel
2759+
if maxThrowVel == 0 then
2760+
maxThrowVel = Owner.FGArm.ThrowStrength + math.abs(Owner.AngularVel * 0.5) * math.cos(Owner.RotAngle)/math.sqrt(math.abs(Grenade.Mass) + 1)
2761+
minThrowVel = maxThrowVel * 0.2
2762+
end
2763+
aim = HumanBehaviors.GetGrenadeAngle(AimPoint, Vector(), Grenade.MuzzlePos, maxThrowVel)
27582764
if aim then
2765+
aim = aim - Owner.RotAngle
27592766
ThrowTimer:Reset()
27602767
aimTime = Owner.ThrowPrepTime * RangeRand(0.9, 1.1)
27612768
local maxAim = aim
27622769

27632770
-- try again with an average throw vel
2764-
aim = HumanBehaviors.GetGrenadeAngle(AimPoint, Vector(), Grenade.MuzzlePos, (Grenade.MaxThrowVel+Grenade.MinThrowVel)/2)
2771+
aim = HumanBehaviors.GetGrenadeAngle(AimPoint, Vector(), Grenade.MuzzlePos, (maxThrowVel + minThrowVel)/2)
27652772
if aim then
27662773
aimTime = Owner.ThrowPrepTime * RangeRand(0.45, 0.55)
27672774
else

0 commit comments

Comments
 (0)