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

Commit

Permalink
Merge branch 'pre5-patch'
Browse files Browse the repository at this point in the history
  • Loading branch information
garethyr committed Aug 10, 2023
2 parents e1e4d69 + 1ebd735 commit fb74b48
Show file tree
Hide file tree
Showing 130 changed files with 4,872 additions and 3,319 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Mods/
Userdata/

allegro.log
AbortScreen.bmp
AbortScreen.*
AbortLog.txt
MemCleanupInfo.txt
LogPublish.txt
Expand Down
4 changes: 2 additions & 2 deletions Data/Base.rte/AI/CrabBehaviors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ function CrabBehaviors.ShootArea(AI, Owner, Abort)

-- check if we can fire at the AimPoint
local Trace = SceneMan:ShortestDistance(Owner.EyePos, AimPoint, false);
local rayLenght = SceneMan:CastObstacleRay(Owner.EyePos, Trace, Vector(), Vector(), rte.NoMOID, Owner.IgnoresWhichTeam, rte.grassID, 11);
if Trace.Magnitude * 0.67 < rayLenght then
local rayLength = SceneMan:CastObstacleRay(Owner.EyePos, Trace, Vector(), Vector(), rte.NoMOID, Owner.IgnoresWhichTeam, rte.grassID, 11);
if Trace:MagnitudeIsLessThan(rayLength * 1.5) then
break; -- the AimPoint is close enough to the target, start shooting
end

Expand Down
12 changes: 5 additions & 7 deletions Data/Base.rte/AI/HumanBehaviors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,10 @@ end

function HumanBehaviors.GetGrenadeAngle(AimPoint, TargetVel, StartPos, muzVel)
local Dist = SceneMan:ShortestDistance(StartPos, AimPoint, false);
local range = Dist.Magnitude;

-- compensate for gravity if the point we are trying to hit is more than 2m away
if range > 40 then
local timeToTarget = range / muzVel;
if Dist:MagnitudeIsGreaterThan(40) then
local timeToTarget = Dist.Magnitude / muzVel;

-- lead the target if target speed and projectile TTT is above the threshold
if (timeToTarget * TargetVel.Magnitude) > 0.5 then
Expand Down Expand Up @@ -1452,8 +1451,7 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
local RandomWpt = WptList[test];
if RandomWpt then
Dist = SceneMan:ShortestDistance(Owner.Pos, RandomWpt.Pos, false);
local mag = Dist.Magnitude;
if mag < 50 and mag < SceneMan:ShortestDistance(Owner.Pos, Waypoint.Pos, false).Magnitude/3 then
if Dist:MagnitudeIsLessThan(50) and Dist:MagnitudeIsLessThan(SceneMan:ShortestDistance(Owner.Pos, Waypoint.Pos, false).Magnitude * 0.33) then
-- this waypoint is closer, check LOS
if -1 == SceneMan:CastObstacleRay(Owner.Pos, Dist, Vector(), Vector(), Owner.ID, Owner.IgnoresWhichTeam, rte.grassID, 4) then
Waypoint = RandomWpt; -- go here instead
Expand Down Expand Up @@ -2993,8 +2991,8 @@ function HumanBehaviors.ShootArea(AI, Owner, Abort)

-- check if we can fire at the AimPoint
local Trace = SceneMan:ShortestDistance(Owner.EyePos, AimPoint, false);
local rayLenght = SceneMan:CastObstacleRay(Owner.EyePos, Trace, Vector(), Vector(), rte.NoMOID, Owner.IgnoresWhichTeam, rte.grassID, 11);
if Trace.Magnitude * 0.67 < rayLenght then
local rayLength = SceneMan:CastObstacleRay(Owner.EyePos, Trace, Vector(), Vector(), rte.NoMOID, Owner.IgnoresWhichTeam, rte.grassID, 11);
if Trace:MagnitudeIsLessThan(rayLength * 1.5) then
break; -- the AimPoint is close enough to the target, start shooting
end

Expand Down
8 changes: 4 additions & 4 deletions Data/Base.rte/AI/NativeDropShipAI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ function NativeDropShipAI:Update(Owner)
self.Waypoint.Y = -500; -- Go to orbit
end
else
local dist = SceneMan:ShortestDistance(Owner.Pos, self.Waypoint, false).Magnitude;
if dist < Owner.Radius and math.abs(change) < 3 and math.abs(Owner.Vel.X) < 4 then -- If we passed the hover check, check if we can start unloading
local dist = SceneMan:ShortestDistance(Owner.Pos, self.Waypoint, false);
if dist:MagnitudeIsLessThan(Owner.Radius) and math.abs(change) < 3 and math.abs(Owner.Vel.X) < 4 then -- If we passed the hover check, check if we can start unloading
local WptL = SceneMan:MovePointToGround(Owner.Pos+Vector(-Owner.Radius, -Owner.Radius), self.hoverAlt, 12);
local WptC = SceneMan:MovePointToGround(Owner.Pos+Vector(0, -Owner.Radius), self.hoverAlt, 12);
local WptR = SceneMan:MovePointToGround(Owner.Pos+Vector(Owner.Radius, -Owner.Radius), self.hoverAlt, 12);
self.Waypoint = Vector(Owner.Pos.X, math.min(WptL.Y, WptC.Y, WptR.Y));

dist = SceneMan:ShortestDistance(Owner.Pos, self.Waypoint, false).Magnitude;
if dist < Owner.Diameter then
dist = SceneMan:ShortestDistance(Owner.Pos, self.Waypoint, false);
if dist:MagnitudeIsLessThan(Owner.Diameter) then
-- We are close enough to our waypoint
if Owner.AIMode == Actor.AIMODE_STAY then
self.DeliveryState = ACraft.STANDBY;
Expand Down
7 changes: 2 additions & 5 deletions Data/Base.rte/AI/RocketAI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,8 @@ function UpdateAI(self)
self.LZpos = SceneMan:MovePointToGround(self.Pos, self.groundDist, 6);
end

if self.AIMode ~= Actor.AIMODE_STAY then
local dist = SceneMan:ShortestDistance(self.Pos, self.LZpos, false).Magnitude;
if dist < 25 then -- If we passed the check, start unloading
self.DeliveryState = ACraft.UNLOAD;
end
if self.AIMode ~= Actor.AIMODE_STAY and SceneMan:ShortestDistance(self.Pos, self.LZpos, false):MagnitudeIsLessThan(25) then
self.DeliveryState = ACraft.UNLOAD;
end
end
elseif self.DeliveryState == ACraft.UNLOAD then
Expand Down
15 changes: 9 additions & 6 deletions Data/Base.rte/Activities.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ AddActivity = GAScripted
Description = Build a bunker and defend it against increasingly longer waves of AI-controlled enemies, with time to repair in between! Adjust the Difficulty to change wave difficulty.
SceneName = Ketanot Hills
ScriptPath = Base.rte/Activities/WaveDefense.lua
TeamOfPlayer1 = 0
TeamOfPlayer2 = 0
TeamOfPlayer3 = 0
TeamOfPlayer4 = 0
CPUTeam = 1
TeamOfPlayer1 = 1
TeamOfPlayer2 = 1
TeamOfPlayer3 = 1
TeamOfPlayer4 = 1
CPUTeam = 0
MinTeamsRequired = 2
DefaultGoldCakeDifficulty = 6000
DefaultGoldEasyDifficulty = 5000
Expand All @@ -60,9 +60,11 @@ AddActivity = GAScripted
DefaultGoldNutsDifficulty = 2000
DefaultGoldMaxDifficulty = 1000
LuaClassName = WaveDefense
Team1Name = Attackers
Team2Name = Defenders
DefaultRequireClearPathToOrbit = 1
DeployUnitsSwitchEnabled = 1
DefaultDeployUnits = 0
DefaultDeployUnits = 1
AddActivity = GAScripted
Expand Down Expand Up @@ -208,6 +210,7 @@ AddActivity = GAScripted
DeployUnitsSwitchEnabled = 1
ScriptPath = Base.rte/Activities/Test.lua
LuaClassName = Test
DefaultDeployUnits = 0
/*
Expand Down
69 changes: 43 additions & 26 deletions Data/Base.rte/Activities/BunkerBreach.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function BunkerBreach:SetupDefenderBrains()

-- Add defender brains, either using the Brain area or picking randomly from those created by deployments.
if SceneMan.Scene:HasArea("Brain") then
for actor in MovableMan.Actors do
if actor.Team == self.defenderTeam and actor:IsInGroup("Brains") then
for actor in MovableMan.AddedActors do
if actor:IsInGroup("Brains") then
actor.ToDelete = true;
end
end
Expand Down Expand Up @@ -141,35 +141,52 @@ function BunkerBreach:SetupDefenderActors()
local techID = PresetMan:GetModuleID(self:GetTeamTech(self.defenderTeam));
local crabToHumanSpawnRatio = self:GetCrabToHumanSpawnRatio(techID);

for _, loadoutName in pairs({"Light", "Heavy", "Sniper", "Engineer", "Mecha", "Turret"}) do
local loadoutNames = {"Light", "Heavy", "Sniper", "Engineer", "Mecha", "Turret"};

local hasSpawnAreas = false;
for _, loadoutName in pairs(loadoutNames) do
if SceneMan.Scene:HasArea(loadoutName .. " Defenders") then
local defenderArea = SceneMan.Scene:GetOptionalArea(loadoutName .. " Defenders");
if defenderArea ~= nil then
for defenderBox in defenderArea.Boxes do
local guard;
if loadoutName == "Mecha" or loadoutName == "Turret" then
guard = crabToHumanSpawnRatio > 0 and self:CreateCrab(techID, loadoutName == "Turret") or self:CreateInfantry(techID, "Heavy");
else
guard = self:CreateInfantry(techID, loadoutName);
end
if guard then
guard.Pos = defenderBox.Center;
guard.Team = self.defenderTeam;
guard.AIMode = Actor.AIMODE_SENTRY;
if loadoutName == "Engineer" then
guard.AIMode = Actor.AIMODE_GOLDDIG;
hasSpawnAreas = true;
end
end

for actor in MovableMan.AddedActors do
if not actor:IsInGroup("Brains") and not actor:IsInGroup("Bunker Systems - Automovers") then
if hasSpawnAreas then
actor.ToDelete = true;
elseif actor.Team ~= self.defenderTeam then
MovableMan:ChangeActorTeam(actor, self.defenderTeam);
end
end
end

if hasSpawnAreas then
for _, loadoutName in pairs({"Light", "Heavy", "Sniper", "Engineer", "Mecha", "Turret"}) do
if SceneMan.Scene:HasArea(loadoutName .. " Defenders") then
hasSpawnAreas = true;
local defenderArea = SceneMan.Scene:GetOptionalArea(loadoutName .. " Defenders");
if defenderArea ~= nil then
for defenderBox in defenderArea.Boxes do
local guard;
if loadoutName == "Mecha" or loadoutName == "Turret" then
guard = crabToHumanSpawnRatio > 0 and self:CreateCrab(techID, loadoutName == "Turret") or self:CreateInfantry(techID, "Heavy");
else
guard = self:CreateInfantry(techID, loadoutName);
end
if guard then
guard.Pos = defenderBox.Center;
guard.Team = self.defenderTeam;
guard.AIMode = Actor.AIMODE_SENTRY;
if loadoutName == "Engineer" then
guard.AIMode = Actor.AIMODE_GOLDDIG;
end
MovableMan:AddActor(guard);
end
MovableMan:AddActor(guard);
end
end
end
end
end
for actor in MovableMan.AddedActors do
if actor.Team ~= self.defenderTeam and not actor:IsInGroup("Brains") and not actor:IsInGroup("Bunker Systems - Automovers") then
MovableMan:ChangeActorTeam(actor, self.defenderTeam);
end
end
end

function BunkerBreach:SetupFogOfWar()
Expand Down Expand Up @@ -241,12 +258,12 @@ function BunkerBreach:StartActivity(isNewGame)

self:SetupAIVariables();

self:SetupHumanAttackerBrains();

self:SetupDefenderBrains();

self:SetupDefenderActors();

self:SetupHumanAttackerBrains();

self:SetupFogOfWar();
else
self:ResumeLoadedGame();
Expand Down
4 changes: 2 additions & 2 deletions Data/Base.rte/Activities/SkirmishDefense.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ function SkirmishDefense:StartNewGame(aiTeams)
soleHumanTeam = soleHumanTeam == -1 and team or false;
end
end
-- If there's only one Human team, set all existing doors to that team
-- If there's only one Human team, set all existing doors and actors to that team
if soleHumanTeam ~= false and soleHumanTeam >= 0 then
for actor in MovableMan.AddedActors do
if actor.Team ~= soleHumanTeam and actor.ClassName == "ADoor" then
if actor.Team ~= soleHumanTeam then
MovableMan:ChangeActorTeam(actor, soleHumanTeam);
end
end
Expand Down
23 changes: 20 additions & 3 deletions Data/Base.rte/Activities/WaveDefense.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end

function WaveDefense:StartActivity(isNewGame)
-- Get player team
self.playerTeam = Activity.TEAM_1;
self.playerTeam = Activity.TEAM_2;
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
if self:PlayerActive(player) and self:PlayerHuman(player) then
self.playerTeam = self:GetTeamOfPlayer(player);
Expand Down Expand Up @@ -94,7 +94,6 @@ end

function WaveDefense:StartNewGame()
self:SetTeamFunds(self:GetStartingGold(), self.playerTeam);
self:CheckBrains();

self.triggerWaveInit = true;
self.wave = 1;
Expand All @@ -105,7 +104,17 @@ function WaveDefense:StartNewGame()
if actor.ClassName == "AHuman" or actor.ClassName == "ACrab" then
actor.AIMode = Actor.AIMODE_SENTRY;
end
actor.Team = self.playerTeam;
MovableMan:ChangeActorTeam(actor, self.playerTeam);
end

self:CheckBrains();

for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
if self:PlayerActive(player) and self:PlayerHuman(player) then
if self:GetPlayerBrain(player) then
self:SwitchToActor(self:GetPlayerBrain(player), player, self:GetTeamOfPlayer(player));
end
end
end
end

Expand Down Expand Up @@ -258,6 +267,14 @@ function WaveDefense:UpdateActivity()
end
end

-- Reveal the main bunker area for the defender.
local mainBunkerArea = SceneMan.Scene:GetOptionalArea("Main Bunker");
if mainBunkerArea ~= nil then
for mainBunkerBox in mainBunkerArea.Boxes do
SceneMan:RevealUnseenBox(mainBunkerBox.Corner.X, mainBunkerBox.Corner.Y, mainBunkerBox.Width, mainBunkerBox.Height, self.playerTeam);
end
end

for Act in MovableMan.AddedActors do
if Act.ClassName ~= "ADoor" then
for ang = 0, math.pi*2, 0.15 do
Expand Down
61 changes: 1 addition & 60 deletions Data/Base.rte/Actors/Brains/Brainbot/Brainbot.ini
Original file line number Diff line number Diff line change
Expand Up @@ -742,66 +742,7 @@ AddActor = AHuman
FastTravelSpeed = 4.5
PushForce = 6000
ClimbLimbPath = LimbPath
PresetName = Brainbot Climb Path
StartOffset = Vector
X = 0
Y = -14
StartSegCount = 13
AddSegment = Vector
X = 4
Y = 4
AddSegment = Vector
X = 1
Y = 2
AddSegment = Vector
X = 1
Y = 2
AddSegment = Vector
X = 1
Y = 1
AddSegment = Vector
X = 1
Y = 1
AddSegment = Vector
X = 1
Y = 1
AddSegment = Vector
X = 1
Y = 1
AddSegment = Vector
X = 1
Y = 1
AddSegment = Vector
X = 1
Y = 1
AddSegment = Vector
X = 1
Y = 1
AddSegment = Vector
X = 1
Y = 1
AddSegment = Vector
X = 1
Y = 1
AddSegment = Vector
X = 0
Y = 1
AddSegment = Vector
X = 0
Y = 3
AddSegment = Vector
X = -2
Y = 5
AddSegment = Vector
X = -4
Y = 5
AddSegment = Vector
X = -6
Y = 5
SlowTravelSpeed = 1.5
NormalTravelSpeed = 1.5
FastTravelSpeed = 4.5
PushForce = 7000
CopyOf = Human Climb Path
JumpLimbPath = LimbPath
PresetName = Brainbot Jump Path
StartOffset = Vector
Expand Down
4 changes: 2 additions & 2 deletions Data/Base.rte/Actors/Mecha/Medic/Medic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function Update(self)
for _, healTarget in pairs(self.healTargets) do
if healTarget and IsActor(healTarget) and (healTarget.Health < healTarget.MaxHealth or healTarget.WoundCount > 0) and healTarget.Vel.Largest < 10 then
local trace = SceneMan:ShortestDistance(self.Pos, healTarget.Pos, false);
if (trace.Magnitude - healTarget.Radius) < healRange and SceneMan:CastObstacleRay(self.Pos, trace, Vector(), Vector(), parent.ID, parent.IgnoresWhichTeam, rte.grassID, 5) < 0 then
if trace:MagnitudeIsLessThan(healRange + healTarget.Radius) and SceneMan:CastObstacleRay(self.Pos, trace, Vector(), Vector(), parent.ID, parent.IgnoresWhichTeam, rte.grassID, 5) < 0 then
healTarget.Health = math.min(healTarget.Health + self.healStrength, healTarget.MaxHealth);
if self.crossTimer:IsPastSimTimeLimit() then
local cross = CreateMOSParticle("Particle Heal Effect", "Base.rte");
Expand All @@ -65,7 +65,7 @@ function Update(self)
for actor in MovableMan.Actors do
if actor.Team == parent.Team and actor.ID ~= parent.ID and (actor.Health < actor.MaxHealth or actor.WoundCount > 0) and actor.Vel.Largest < 5 then
local trace = SceneMan:ShortestDistance(self.Pos, actor.Pos, false);
if (trace.Magnitude - actor.Radius) < (healRange * 0.9) then
if trace:MagnitudeIsLessThan(healRange * 0.9 + actor.Radius) then
if SceneMan:CastObstacleRay(self.Pos, trace, Vector(), Vector(), parent.ID, parent.IgnoresWhichTeam, rte.airID, 3) < 0 then
table.insert(self.healTargets, actor);
end
Expand Down
Loading

0 comments on commit fb74b48

Please sign in to comment.