Skip to content

Commit 077e597

Browse files
authored
Merge pull request #181 from cortex-command-community/browncoat-lmg
Browncoat Campaign Mission
2 parents 8e44fd4 + c8c7b44 commit 077e597

File tree

1,518 files changed

+161299
-623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,518 files changed

+161299
-623
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ luac.out
4545
CortexCommand
4646
CortexCommand_debug
4747

48+
# Debug databases
49+
*.pdb
50+
4851
# Manifest files
4952
*.manifest
5053

Data/Base.rte/AI/CrabAI.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
require("AI/NativeCrabAI"); --dofile("Base.rte/Actors/AI/NativeCrabAI.lua")
1+
require("AI/NativeCrabAI");
22

33
function Create(self)
44
self.AI = NativeCrabAI:Create(self);
55
end
66

7-
function UpdateAI(self)
7+
function ThreadedUpdateAI(self)
88
self.AI:Update(self);
99
end
1010

Data/Base.rte/AI/CrabBehaviors.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ function CrabBehaviors.GoToWpt(AI, Owner, Abort)
358358
Waypoint = table.remove(WptList, 1);
359359
if WptList[1] then
360360
Owner:RemoveMovePathBeginning();
361-
elseif not Owner.MOMoveTarget and SceneMan:ShortestDistance(Owner.Pos, Waypoint.Pos, false).X < 10 then -- the last waypoint
361+
elseif not Owner.MOMoveTarget and SceneMan:ShortestDistance(Owner.Pos, Waypoint.Pos, false):MagnitudeIsLessThan(Owner.MoveProximityLimit) then -- the last waypoint
362362
Owner:ClearMovePath();
363363
WptList = nil;
364364
Waypoint = nil;
@@ -371,7 +371,9 @@ function CrabBehaviors.GoToWpt(AI, Owner, Abort)
371371
AI.lateralMoveState = Actor.LAT_LEFT;
372372
elseif CurrDist.X > 3 then
373373
AI.lateralMoveState = Actor.LAT_RIGHT;
374-
else
374+
end
375+
376+
if CurrDist:MagnitudeIsLessThan(Owner.MoveProximityLimit) then
375377
Waypoint = nil;
376378
end
377379
end

Data/Base.rte/AI/DropShipAI.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
require("AI/NativeDropShipAI"); --dofile("Base.rte/Actors/AI/NativeDropShipAI.lua");
1+
require("AI/NativeDropShipAI");
22

33
function Create(self)
44
self.AI = NativeDropShipAI:Create(self);
55
end
66

7-
function UpdateAI(self)
7+
function ThreadedUpdateAI(self)
88
self.AI:Update(self);
99
end

Data/Base.rte/AI/HumanAI.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require("AI/NativeHumanAI");
33
function Create(self)
44
self.AI = NativeHumanAI:Create(self);
55
end
6-
function UpdateAI(self)
6+
function ThreadedUpdateAI(self)
77
self.AI:Update(self);
88
end
99
function Destroy(self)

Data/Base.rte/AI/HumanBehaviors.lua

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
HumanBehaviors = {};
33

44
function HumanBehaviors.GetTeamShootingSkill(team)
5-
local skill = 50;
5+
local skill = 80;
66
local Activ = ActivityMan:GetActivity();
77
if Activ then
8-
skill = Activ:GetTeamAISkill(team);
8+
-- i am fancy mathematician, doing fancy mathematics
9+
-- this weigh actor skill heavily towards 100
10+
local num = (Activ:GetTeamAISkill(team)/100);
11+
skill = (1 - math.pow(1 - num, 3)) * 100;
912
end
1013

1114
local aimSpeed, aimSkill;
@@ -52,14 +55,14 @@ end
5255
function HumanBehaviors.CheckEnemyLOS(AI, Owner, Skill)
5356
if not AI.Enemies then -- add all enemy actors on our screen to a table and check LOS to them, one per frame
5457
AI.Enemies = {};
55-
for Act in MovableMan.Actors do
56-
if Act.Team ~= Owner.Team then
57-
if not AI.isPlayerOwned or not SceneMan:IsUnseen(Act.Pos.X, Act.Pos.Y, Owner.Team) then -- AI-teams ignore the fog
58-
local Dist = SceneMan:ShortestDistance(Owner.ViewPoint, Act.Pos, false);
59-
if (math.abs(Dist.X) - Act.Diameter < FrameMan.PlayerScreenWidth * (0.4 + Skill * 0.005)) and (math.abs(Dist.Y) - Act.Diameter < FrameMan.PlayerScreenHeight * (0.4 + Skill * 0.005)) then
60-
table.insert(AI.Enemies, Act);
61-
end
62-
end
58+
local box = Box();
59+
local skillFactor = (0.4 + Skill * 0.005);
60+
box.Corner = Vector(Owner.ViewPoint.X - (FrameMan.PlayerScreenWidth/2) * skillFactor, Owner.ViewPoint.Y - (FrameMan.PlayerScreenHeight/2) * skillFactor);
61+
box.Width = FrameMan.PlayerScreenWidth * skillFactor;
62+
box.Height = FrameMan.PlayerScreenHeight * skillFactor;
63+
for Act in MovableMan:GetMOsInBox(box, Owner.Team, true) do
64+
if IsActor(Act) and not AI.isPlayerOwned or not SceneMan:IsUnseen(Act.Pos.X, Act.Pos.Y, Owner.Team) then -- AI-teams ignore the fog
65+
table.insert(AI.Enemies, Act);
6366
end
6467
end
6568

@@ -1267,7 +1270,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
12671270
AI.jump = false;
12681271
AI.lateralMoveState = Actor.LAT_STILL;
12691272
end
1270-
elseif not AI.flying and UpdatePathTimer:IsPastSimTimeLimit() then
1273+
elseif UpdatePathTimer:IsPastSimTimeLimit() then
12711274
UpdatePathTimer:Reset();
12721275

12731276
AI.deviceState = AHuman.STILL;
@@ -1366,9 +1369,6 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
13661369
CornerPos = (NextWptPos + Free) / 2; -- compensate for obstacles
13671370
end
13681371

1369-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
1370-
if _abrt then return true end
1371-
13721372
-- check if we have LOS
13731373
Dist = SceneMan:ShortestDistance(Owner.Pos, CornerPos, false);
13741374
if 0 <= SceneMan:CastObstacleRay(Owner.Pos, Dist, Vector(), Vector(), Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, 2) then
@@ -1377,9 +1377,6 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
13771377
cornerType = "air";
13781378
end
13791379

1380-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
1381-
if _abrt then return true end
1382-
13831380
Waypoint = {Pos=CornerPos, Type=cornerType};
13841381
if WptList[2] and not WptList[1].Type then -- remove the waypoint after the corner if possible
13851382
table.remove(WptList, 1);
@@ -1460,7 +1457,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
14601457
elseif Waypoint.Type == "last" then
14611458
ArrivedTimer:SetSimTimeLimitMS(600);
14621459
else -- air or corner wpt
1463-
ArrivedTimer:SetSimTimeLimitMS(25);
1460+
ArrivedTimer:SetSimTimeLimitMS(0);
14641461
end
14651462
end
14661463
elseif WptList[2] then -- check if some other waypoint is closer
@@ -1485,11 +1482,6 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
14851482
end
14861483
end
14871484
end
1488-
1489-
if not AI.jump and not AI.flying then
1490-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
1491-
if _abrt then return true end
1492-
end
14931485
end
14941486
end
14951487
end
@@ -1520,9 +1512,6 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
15201512
WptList = nil; -- update the path
15211513
break;
15221514
end
1523-
1524-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
1525-
if _abrt then return true end
15261515
else -- MOMoveTarget gone
15271516
return true;
15281517
end
@@ -1637,9 +1626,6 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
16371626
Waypoint = nil;
16381627
end
16391628
end
1640-
1641-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
1642-
if _abrt then return true end
16431629
elseif Owner.AIMode == Actor.AIMODE_GOLDDIG then
16441630
Waypoint.Pos = SceneMan:MovePointToGround(Waypoint.Pos, Owner.Height*0.2, 4);
16451631
end
@@ -1659,7 +1645,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
16591645
end
16601646

16611647
-- Scan for obstacles
1662-
local Trace = Vector(Owner.Diameter*0.85, 0):RadRotate(scanAng);
1648+
local Trace = Vector(Owner.Radius*0.75, 0):RadRotate(scanAng);
16631649
local Free = Vector();
16641650
local index = math.floor(scanAng*2.5+2.01);
16651651
if SceneMan:CastObstacleRay(Owner.Pos, Trace, Vector(), Free, Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, 3) > -1 then
@@ -1682,12 +1668,12 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
16821668
end
16831669
end
16841670

1685-
if not AI.jump and not AI.flying then
1686-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
1687-
if _abrt then return true end
1671+
local tolerance = Owner.MoveProximityLimit;
1672+
if AI.jump then
1673+
tolerance = tolerance * 2;
16881674
end
16891675

1690-
if CurrDist:MagnitudeIsGreaterThan(Owner.Height * 0.4) then -- not close enough to the waypoint
1676+
if CurrDist:MagnitudeIsGreaterThan(tolerance) then -- not close enough to the waypoint
16911677
ArrivedTimer:Reset();
16921678

16931679
-- check if we have LOS to the waypoint
@@ -1702,11 +1688,6 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
17021688
return true; -- end this behavior and look for gold again
17031689
end
17041690
end
1705-
1706-
if not AI.jump and not AI.flying then
1707-
local _ai, _ownr, _abrt = coroutine.yield(); -- wait until next frame
1708-
if _abrt then return true end
1709-
end
17101691
elseif ArrivedTimer:IsPastSimTimeLimit() then -- only remove a waypoint if we have been close to it for a while
17111692
if Waypoint.Type == "last" then
17121693
if not AI.flying and Owner.Vel.Largest < 5 then
@@ -1742,13 +1723,6 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
17421723
else
17431724
nextLatMove = Actor.LAT_STILL;
17441725
end
1745-
if not (Owner.FGLeg and Owner.BGLeg) then
1746-
if CurrDist.X * Owner.FlipFactor > 5 and -CurrDist.Y > math.abs(CurrDist.X) then
1747-
AI.flying = true;
1748-
elseif not AI.jump then
1749-
AI.proneState = AHuman.GOPRONE;
1750-
end
1751-
end
17521726
end
17531727

17541728
if Waypoint.Type == "right" then
@@ -2097,7 +2071,7 @@ end
20972071

20982072
-- go prone if we can shoot from the prone position and return the result
20992073
function HumanBehaviors.GoProne(AI, Owner, TargetPos, targetID)
2100-
if not Owner.Head or AI.proneState == AHuman.PRONE then
2074+
if (not Owner.Head or AI.proneState == AHuman.PRONE) or (Owner:NumberValueExists("AIDisableProne")) then
21012075
return false;
21022076
end
21032077

@@ -2700,8 +2674,8 @@ function HumanBehaviors.ThrowTarget(AI, Owner, Abort)
27002674
end
27012675

27022676
ID = rte.NoMOID;
2703-
if Owner:IsWithinRange(Vector(AimPoint.X, AimPoint.Y)) then -- TODO: use grenade properties to decide this
2704-
--if true then
2677+
--if Owner:IsWithinRange(Vector(AimPoint.X, AimPoint.Y)) then -- TODO: use grenade properties to decide this
2678+
if true then
27052679
Dist = SceneMan:ShortestDistance(Owner.EyePos, AimPoint, false);
27062680
ID = SceneMan:CastMORay(Owner.EyePos, Dist, Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, false, 3);
27072681
if ID < 1 or ID == rte.NoMOID then -- not found, look for any head or legs

Data/Base.rte/AI/NativeCrabAI.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
require("Constants")
22
require("AI/HumanBehaviors");
33
require("AI/CrabBehaviors");
44

0 commit comments

Comments
 (0)