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

Commit e773317

Browse files
authored
Merge pull request #109 from cortex-command-community/4zk-content
4zK's big-fuckall:tm: data PR b4 pre4
2 parents 8ce798f + fdaa695 commit e773317

File tree

416 files changed

+3443
-2826
lines changed

Some content is hidden

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

416 files changed

+3443
-2826
lines changed

Base.rte/AI/CrabBehaviors.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function CrabBehaviors.LookForTargets(AI, Owner)
4444
FoundMO = ToACRocket(FoundMO)
4545
elseif FoundMO.ClassName == "ACDropShip" then
4646
FoundMO = ToACDropShip(FoundMO)
47-
elseif FoundMO.ClassName == "ADoor" and HumanBehaviors.GetProjectileData(Owner).pen * 0.9 > ToADoor(FoundMO).Door.Material.StructuralIntegrity then
47+
elseif FoundMO.ClassName == "ADoor" and FoundMO.Team ~= Activity.NOTEAM and Owner.AIMode ~= Actor.AIMODE_SENTRY and ToADoor(FoundMO).Door and ToADoor(FoundMO).Door:IsAttached() and HumanBehaviors.GetProjectileData(Owner).pen * 0.9 > ToADoor(FoundMO).Door.Material.StructuralIntegrity then
4848
FoundMO = ToADoor(FoundMO)
4949
elseif FoundMO.ClassName == "Actor" then
5050
FoundMO = ToActor(FoundMO)

Base.rte/AI/HumanAI.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ function Create(self)
66
self.AI = NativeHumanAI:Create(self);
77
--You can turn features on and off here
88
self.armSway = true;
9-
self.automaticEquip = true;
109
self.alternativeGib = true;
11-
self.visibleInventory = true;
10+
self.visibleInventory = false;
1211
end
1312
function Update(self)
1413
self.controller = self:GetController();
15-
14+
--Order the AI of this actor to stop running around if selected by player
15+
if self.AI.scatter and self:IsPlayerControlled() then
16+
self.AIMode = Actor.AIMODE_SENTRY;
17+
self.AI.scatter = false;
18+
end
1619
if self.alternativeGib then
1720
HumanFunctions.DoAlternativeGib(self);
1821
end

Base.rte/AI/HumanBehaviors.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,7 @@ function HumanBehaviors.ProcessAlarmEvent(AI, Owner)
205205
if ID ~= rte.NoMOID then
206206
local FoundMO = MovableMan:GetMOFromID(ID)
207207
if FoundMO then
208-
if ID ~= FoundMO.RootID then
209-
FoundMO = MovableMan:GetMOFromID(FoundMO.RootID)
210-
end
208+
FoundMO = FoundMO:GetRootParent()
211209

212210
if not FoundMO.EquippedItem or not FoundMO.EquippedItem:HasObjectInGroup("Weapons - Explosive") then
213211
FoundMO = nil -- don't shoot at without weapons or actors using tools
@@ -2326,7 +2324,7 @@ function HumanBehaviors.ShootTarget(AI, Owner, Abort)
23262324
aimTarget = Dist.AbsRadAngle
23272325
AI.canHitTarget = true
23282326
if Owner.InventorySize > 0 then -- we have more things in the inventory
2329-
if range < 60 and Owner:HasObjectInGroup("Tools - Diggers") then
2327+
if range < 60 and (Owner:HasObjectInGroup("Tools - Diggers") or Owner:HasObjectInGroup("Weapons - Melee")) then
23302328
AI:CreateHtHBehavior(Owner)
23312329
break
23322330
elseif Owner:EquipLoadedFirearmInGroup("Any", "Weapons - Explosive", true) then
@@ -2768,7 +2766,7 @@ function HumanBehaviors.ThrowTarget(AI, Owner, Abort)
27682766
local maxAim = aim
27692767

27702768
-- try again with an average throw vel
2771-
aim = HumanBehaviors.GetGrenadeAngle(AimPoint, Vector(), Grenade.MuzzlePos, (maxThrowVel + minThrowVel)/2)
2769+
aim = HumanBehaviors.GetGrenadeAngle(AimPoint, Vector(), Grenade.MuzzlePos, (maxThrowVel + minThrowVel) * 0.5)
27722770
if aim then
27732771
aimTime = Owner.ThrowPrepTime * RangeRand(0.45, 0.55)
27742772
else

Base.rte/AI/HumanFunctions.lua

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,10 @@ function HumanFunctions.DoAlternativeGib(actor)
5656
end
5757
end
5858
end
59-
60-
function HumanFunctions.DoAutomaticEquip(actor)
61-
--Equip a weapon automatically if the one held by a player is destroyed (To-do: move this to cpp?)
62-
if actor.EquippedItem == nil and not actor.controller:IsState(Controller.WEAPON_FIRE) and (actor:IsPlayerControlled() or actor:UnequipBGArm()) then
63-
actor:EquipFirearm(true);
64-
end
65-
end
6659

6760
function HumanFunctions.DoArmSway(actor, pushStrength)
6861
local aimAngle = actor:GetAimAngle(false);
69-
if actor.weight then
70-
actor:RemoveAttachable(actor.weight);
71-
actor.weight = nil;
72-
end
7362
if actor.Status == Actor.STABLE and actor.lastHandPos then
74-
--Unequip weapons by pressing both weapon switch keys at once
75-
if actor.controller:IsState(Controller.WEAPON_CHANGE_NEXT) and actor.controller:IsState(Controller.WEAPON_CHANGE_PREV) then
76-
local item = CreateHeldDevice("Null Item");
77-
actor:AddInventoryItem(item);
78-
actor:EquipNamedDevice("Null Item", true);
79-
item.ToDelete = true;
80-
end
81-
--Control arm movements
8263
--Flail around if aiming around too fast
8364
local angleMovement = actor.lastAngle - aimAngle;
8465
actor.AngularVel = actor.AngularVel - (2 * angleMovement * actor.FlipFactor)/(math.abs(actor.AngularVel) * 0.1 + 1);
@@ -99,7 +80,7 @@ function HumanFunctions.DoArmSway(actor, pushStrength)
9980
if arm then
10081
arm = ToArm(arm);
10182

102-
local armLength = ToMOSprite(arm):GetSpriteWidth();
83+
local armLength = arm.MaxLength;
10384
local rotAng = actor.RotAngle - (1.57 * actor.FlipFactor);
10485
local legMain = armPairs[i][2];
10586
local legAlt = armPairs[i][3];
@@ -113,7 +94,7 @@ function HumanFunctions.DoArmSway(actor, pushStrength)
11394
if actor.controller:IsState(Controller.AIM_SHARP) then
11495
arm.IdleOffset = Vector(0, 1):RadRotate(aimAngle);
11596
else
116-
arm.IdleOffset = Vector(0, (armLength + arm.SpriteOffset.X) * 1.1):RadRotate(rotAng * actor.FlipFactor + 1.5 + (i * 0.2));
97+
arm.IdleOffset = Vector(0, armLength * 0.7):RadRotate(rotAng * actor.FlipFactor + 1.5 + (i * 0.2));
11798
end
11899
if actor.shoved or (actor.EquippedItem and IsTDExplosive(actor.EquippedItem) and actor.controller:IsState(Controller.WEAPON_FIRE)) then
119100
arm.IdleOffset = Vector(armLength + (pushStrength * armLength), 0):RadRotate(aimAngle);
@@ -138,11 +119,10 @@ function HumanFunctions.DoArmSway(actor, pushStrength)
138119
if actor.Mass > mo.Mass then
139120
ToActor(mo).Status = Actor.UNSTABLE;
140121
--Simulate target actor weight with an attachable
141-
if not actor.weight then
142-
actor.weight = CreateAttachable("Null Attachable");
143-
actor.weight.Mass = mo.Mass;
144-
actor:AddAttachable(actor.weight);
145-
end
122+
local weight = CreateAttachable("Null Attachable");
123+
weight.Mass = mo.Mass;
124+
weight.Lifetime = 1;
125+
actor:AddAttachable(weight);
146126
local shoveVel = shove.Vector/rte.PxTravelledPerFrame;
147127
mo.Vel = mo.Vel * 0.5 + shoveVel:SetMagnitude(math.min(shoveVel.Magnitude, math.sqrt(actor.IndividualDiameter))) - SceneMan.GlobalAcc * GetMPP() * rte.PxTravelledPerFrame;
148128
mo.AngularVel = (aimAngle - actor.lastAngle) * actor.FlipFactor * math.pi;
@@ -194,4 +174,31 @@ function HumanFunctions.DoVisibleInventory(actor, showAll)
194174
end
195175
end
196176
end
177+
end
178+
--Lunge forward, preferably as result of some dedicated input. Returns horizontal direction of lunge. (TODO: move this into another table?)
179+
function HumanFunctions.Lunge(actor, power)
180+
local flip = 0;
181+
if actor.Status == Actor.STABLE then
182+
flip = actor.FlipFactor;
183+
if actor.controller:IsState(Controller.MOVE_RIGHT) then
184+
flip = 1;
185+
elseif actor.controller:IsState(Controller.MOVE_LEFT) then
186+
flip = -1;
187+
end
188+
--Different factors that affect the lunge
189+
local angVel = math.abs(actor.AngularVel * 0.1) + 1;
190+
local vel = (actor.Vel.Magnitude + angVel)^2 * 0.0005 + 1;
191+
local mass = math.abs(actor.Mass * 0.005) + 1;
192+
local aimAng = actor:GetAimAngle(false);
193+
local vertical = math.abs(math.cos(aimAng))/vel;
194+
local strength = power * math.min(actor.Health/actor.MaxHealth, 1);
195+
196+
local jumpVec = Vector((power + strength/vel) * flip, -(power * 0.5 + (strength * 0.3)) * vertical):RadRotate(aimAng * actor.FlipFactor);
197+
198+
actor.Vel = actor.Vel + jumpVec/mass;
199+
actor.AngularVel = actor.AngularVel - (1/angVel * vertical) * flip * math.cos(actor.RotAngle);
200+
actor.Status = Actor.UNSTABLE;
201+
actor.tapTimer:Reset();
202+
end
203+
return flip;
197204
end

Base.rte/AI/NativeHumanAI.lua

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function NativeHumanAI:Create(Owner)
1818

1919
Members.squadShoot = false
2020
Members.useMedikit = false
21-
Members.scatter = false
2221

2322
-- timers
2423
Members.AirTimer = Timer()
@@ -251,6 +250,7 @@ function NativeHumanAI:Update(Owner)
251250
-- look for targets
252251
local FoundMO, HitPoint = self.SpotTargets(self, Owner, self.skill)
253252
if FoundMO then
253+
--TODO: decide whether to attack based on the material strength of found MO
254254
if self.Target and MovableMan:ValidMO(self.Target) and FoundMO.ID == self.Target.ID then -- found the same target
255255
self.OldTargetPos = Vector(self.Target.Pos.X, self.Target.Pos.Y)
256256
self.TargetOffset = SceneMan:ShortestDistance(self.Target.Pos, HitPoint, false)
@@ -278,8 +278,7 @@ function NativeHumanAI:Update(Owner)
278278
FoundMO = ToACRocket(FoundMO)
279279
elseif FoundMO.ClassName == "ACDropShip" then
280280
FoundMO = ToACDropShip(FoundMO)
281-
elseif FoundMO.ClassName == "ADoor" and Owner.AIMode ~= Actor.AIMODE_SENTRY and ToADoor(FoundMO).Door and ToADoor(FoundMO).Door:IsAttached()
282-
and (Owner:EquipNamedDevice("Heavy Digger", true) or (Owner.FirearmIsReady and HumanBehaviors.GetProjectileData(Owner).pen * 0.9 > ToADoor(FoundMO).Door.Material.StructuralIntegrity)) then
281+
elseif FoundMO.ClassName == "ADoor" and FoundMO.Team ~= Activity.NOTEAM and Owner.AIMode ~= Actor.AIMODE_SENTRY and ToADoor(FoundMO).Door and ToADoor(FoundMO).Door:IsAttached() then
283282
FoundMO = ToADoor(FoundMO)
284283
elseif FoundMO.ClassName == "Actor" then
285284
FoundMO = ToActor(FoundMO)
@@ -324,7 +323,8 @@ function NativeHumanAI:Update(Owner)
324323
end
325324
end
326325
end
327-
326+
327+
self.squadShoot = false
328328
if Owner.MOMoveTarget then
329329
-- make the last waypoint marker stick to the MO we are following
330330
if MovableMan:ValidMO(Owner.MOMoveTarget) then
@@ -558,7 +558,7 @@ function NativeHumanAI:Update(Owner)
558558
self.useMedikit = Owner:EquipNamedDevice("Medikit", true)
559559
else
560560
self.useMedikit = false
561-
if self.scatter ~= true and Owner.AIMode == Actor.AIMODE_SENTRY then
561+
if not self.scatter and Owner.AIMode == Actor.AIMODE_SENTRY then
562562
Owner.AIMode = Actor.AIMODE_PATROL
563563
self.scatter = true
564564
end
@@ -567,6 +567,9 @@ function NativeHumanAI:Update(Owner)
567567
if self.useMedikit == true then
568568
self.useMedikit = false
569569
Owner:EquipFirearm(true)
570+
if self.scatter and Owner.Health == Owner.MaxHealth then
571+
self.scatter = false
572+
end
570573
end
571574
if self.AlarmTimer:IsPastSimTimeLimit() and HumanBehaviors.ProcessAlarmEvent(self, Owner) then
572575
self.AlarmTimer:Reset()
@@ -727,9 +730,17 @@ function NativeHumanAI:CreateAttackBehavior(Owner)
727730

728731
local dist = SceneMan:ShortestDistance(Owner.Pos, self.Target.Pos, false).Magnitude
729732

730-
if self.Target and IsADoor(self.Target) and Owner:EquipNamedDevice("Heavy Digger", true) then
731-
self.NextBehavior = coroutine.create(HumanBehaviors.AttackTarget)
732-
self.NextBehaviorName = "AttackTarget"
733+
if IsADoor(self.Target) then
734+
if Owner:EquipNamedDevice("Heavy Digger", true) then
735+
self.NextBehavior = coroutine.create(HumanBehaviors.AttackTarget)
736+
self.NextBehaviorName = "AttackTarget"
737+
elseif Owner:EquipNamedDevice("Timed Explosive", true) then
738+
self.NextBehavior = coroutine.create(HumanBehaviors.ThrowTarget)
739+
self.NextBehaviorName = "ThrowTarget"
740+
elseif Owner.FirearmIsReady and HumanBehaviors.GetProjectileData(Owner).pen * 0.9 > (self.Target.Door or self.Target).Material.StructuralIntegrity then
741+
self.NextBehavior = coroutine.create(HumanBehaviors.ShootTarget)
742+
self.NextBehaviorName = "ShootTarget"
743+
end
733744
-- favor grenades as the initiator to a sneak attack
734745
elseif Owner.AIMode ~= Actor.AIMODE_SQUAD and Owner.AIMode ~= Actor.AIMODE_SENTRY and self.Target.HFlipped == Owner.HFlipped and Owner:EquipDeviceInGroup("Bombs - Grenades", true)
735746
and dist > 100 and dist < ToThrownDevice(Owner.EquippedItem).MaxThrowVel * GetPPM() and (self.Target.Pos.Y + 20) > Owner.Pos.Y then
@@ -758,10 +769,7 @@ function NativeHumanAI:CreateAttackBehavior(Owner)
758769

759770
return
760771
else -- there are probably no weapons around here (in the vicinity of an area adjacent to a location)
761-
if self.Target and MovableMan:ValidMO(self.Target) and
762-
not (self.isPlayerOwned and Owner.AIMode == Actor.AIMODE_SENTRY) and
763-
(self.Target.ClassName == "AHuman" or self.Target.ClassName == "ACrab")
764-
then
772+
if not (self.isPlayerOwned and Owner.AIMode == Actor.AIMODE_SENTRY) and (self.Target.ClassName == "AHuman" or self.Target.ClassName == "ACrab") then
765773
self.NextBehavior = coroutine.create(HumanBehaviors.AttackTarget)
766774
self.NextBehaviorName = "AttackTarget"
767775
else
@@ -782,7 +790,7 @@ end
782790

783791
-- force the use of a digger when attacking
784792
function NativeHumanAI:CreateHtHBehavior(Owner) -- has to be digger, not just "tool"
785-
if Owner.AIMode ~= Actor.AIMODE_SQUAD and self.Target and Owner:HasObjectInGroup("Tools - Diggers") then --Owner:EquipDiggingTool(true) then
793+
if Owner.AIMode ~= Actor.AIMODE_SQUAD and self.Target and (Owner:HasObjectInGroup("Tools - Diggers") or Owner:HasObjectInGroup("Weapons - Melee")) then
786794
self.NextBehavior = coroutine.create(HumanBehaviors.AttackTarget)
787795
self.NextBehaviorName = "AttackTarget"
788796
self.NextCleanup = function(AI)

Base.rte/AI/RocketAI.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ function UpdateAI(self)
138138
end
139139

140140
if self.AIMode == Actor.AIMODE_DELIVER and self:IsInventoryEmpty() then
141+
self.AIMode = Actor.AIMODE_RETURN;
141142
self.DeliveryState = ACraft.LAUNCH; -- Don't descend if we have nothing to deliver
142143
self.LZpos.Y = -10000; -- Go to orbit
143144
else
@@ -155,6 +156,7 @@ function UpdateAI(self)
155156
elseif self.DeliveryState == ACraft.UNLOAD then
156157
if self:IsInventoryEmpty() and self.AIMode ~= Actor.AIMODE_STAY then -- Return to orbit if empty
157158
if self.DoorTimer:IsPastSimMS(750) then -- Pause before returning to orbit
159+
self.AIMode = Actor.AIMODE_RETURN;
158160
self.DeliveryState = ACraft.LAUNCH;
159161
self.LZpos.Y = -10000; -- Go to orbit
160162
if self.HatchState == ACraft.OPEN then

Base.rte/Activities.ini

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,9 @@ AddActivity = GAScripted
112112
ScriptFile = Base.rte/Activities/BunkerBreach.lua
113113
InCampaignStage = 1
114114
LuaClassName = BunkerBreach
115-
CPUTeam = 1
116-
Team1Name = Players
117-
Team2Name = AI
118-
MinTeamsRequired = 1
115+
Team1Name = Attackers
116+
Team2Name = Defenders
117+
MinTeamsRequired = 2
119118
DefaultGoldCake = 6000
120119
DefaultGoldEasy = 5000
121120
DefaultGoldMedium = 4000
@@ -126,28 +125,6 @@ AddActivity = GAScripted
126125
DeployUnitsSwitchEnabled = 0
127126
128127
129-
AddActivity = GAScripted
130-
PresetName = Siege
131-
SceneName = Zekarra Mining Outpost
132-
Description = Defend a bunker attacked by an AI controlled faction, alone or with your friends.
133-
ScriptFile = Base.rte/Activities/Siege.lua
134-
InCampaignStage = 1
135-
LuaClassName = Siege
136-
CPUTeam = 0
137-
Team1Name = AI
138-
Team2Name = Players
139-
MinTeamsRequired = 1
140-
DefaultGoldCake = 2500
141-
DefaultGoldEasy = 1000
142-
DefaultGoldMedium = 500
143-
DefaultGoldHard = 0
144-
DefaultGoldNuts = 0
145-
DefaultDeployUnits = 1
146-
DeployUnitsSwitchEnabled = 0
147-
DefaultFogOfWar = 0
148-
FogOfWarSwitchEnabled = 0
149-
150-
151128
AddActivity = GAScripted
152129
PresetName = Keepie Uppie
153130
Description = Keep your rocket alive until time is up!

Base.rte/Activities/BrainVsBrain.lua

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,7 @@ function BrainvsBrain:CreateHeavyDrop(xPosLZ)
569569

570570
Craft:AddInventoryItem(Passenger)
571571

572-
local inventoryMass = 0;
573-
for item in Craft.Inventory do
574-
inventoryMass = inventoryMass + item.Mass;
575-
end -- Stop adding actors when exceeding the weight limit
576-
if inventoryMass > craftMaxMass then
572+
if Craft.InventoryMass > craftMaxMass then
577573
break
578574
end
579575
end
@@ -633,11 +629,7 @@ function BrainvsBrain:CreateMediumDrop(xPosLZ)
633629

634630
Craft:AddInventoryItem(Passenger)
635631

636-
local inventoryMass = 0;
637-
for item in Craft.Inventory do
638-
inventoryMass = inventoryMass + item.Mass;
639-
end -- Stop adding actors when exceeding the weight limit
640-
if inventoryMass > craftMaxMass then
632+
if Craft.InventoryMass > craftMaxMass then
641633
break
642634
end
643635
end
@@ -695,11 +687,7 @@ function BrainvsBrain:CreateLightDrop(xPosLZ)
695687

696688
Craft:AddInventoryItem(Passenger)
697689

698-
local inventoryMass = 0;
699-
for item in Craft.Inventory do
700-
inventoryMass = inventoryMass + item.Mass;
701-
end -- Stop adding actors when exceeding the weight limit
702-
if inventoryMass > craftMaxMass then
690+
if Craft.InventoryMass > craftMaxMass then
703691
break
704692
end
705693
end
@@ -757,11 +745,7 @@ function BrainvsBrain:CreateScoutDrop(xPosLZ)
757745

758746
Craft:AddInventoryItem(Passenger)
759747

760-
local inventoryMass = 0;
761-
for item in Craft.Inventory do
762-
inventoryMass = inventoryMass + item.Mass;
763-
end -- Stop adding actors when exceeding the weight limit
764-
if inventoryMass > craftMaxMass then
748+
if Craft.InventoryMass > craftMaxMass then
765749
break
766750
end
767751
end
@@ -795,11 +779,7 @@ function BrainvsBrain:CreateBombDrop(bombPosX)
795779
for _ = 1, math.random(3, 6) do
796780
Craft:AddInventoryItem(RandomTDExplosive("Bombs - Payloads", self.CPUTechID))
797781

798-
local inventoryMass = 0;
799-
for item in Craft.Inventory do
800-
inventoryMass = inventoryMass + item.Mass;
801-
end -- Stop adding actors when exceeding the weight limit
802-
if inventoryMass > craftMaxMass then
782+
if Craft.InventoryMass > craftMaxMass then
803783
break
804784
end
805785
end

0 commit comments

Comments
 (0)