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

Commit 4515dc3

Browse files
authored
Merge pull request #33 from cortex-command-community/4zK-content
4zk's content update #2: Base.rte v0.1.1
2 parents 5e0c32d + 4765d35 commit 4515dc3

File tree

269 files changed

+1398
-1307
lines changed

Some content is hidden

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

269 files changed

+1398
-1307
lines changed

Base.rte/AI/CrabBehaviors.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
CrabBehaviors = {}
33

44
function CrabBehaviors.LookForTargets(AI, Owner)
5-
local viewAngDeg = RangeRand(35, 85)
5+
local viewAngDeg = RangeRand(35, 85) * Owner.Perceptiveness
66
if AI.deviceState == AHuman.AIMING then
7-
viewAngDeg = 20
7+
AI.Ctrl:SetState(Controller.AIM_SHARP, true)
8+
viewAngDeg = 20 * Owner.Perceptiveness
89
end
910

1011
local HitPoint

Base.rte/AI/HumanAI.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
dofile("Base.rte/Constants.lua")
22
require("AI/NativeHumanAI")
3-
require("AI/HumanFunctions");
3+
require("AI/HumanFunctions")
44

55
function Create(self)
66
self.AI = NativeHumanAI:Create(self);
7-
-- You can turn features on and off here
7+
--You can turn features on and off here
88
self.armSway = true;
99
self.automaticEquip = true;
1010
self.alternativeGib = true;
@@ -21,10 +21,10 @@ function Update(self)
2121
HumanFunctions.DoAutomaticEquip(self);
2222
end
2323
if self.armSway then
24-
HumanFunctions.DoArmSway(self, 10); -- Argument: shove strength
24+
HumanFunctions.DoArmSway(self, (self.Health / self.MaxHealth)); --Argument: shove strength
2525
end
2626
if self.visibleInventory then
27-
HumanFunctions.DoVisibleInventory(self, false); -- Argument: whether to show all items
27+
HumanFunctions.DoVisibleInventory(self, false); --Argument: whether to show all items
2828
end
2929
end
3030
function UpdateAI(self)

Base.rte/AI/HumanBehaviors.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ end
3636

3737
-- spot targets by casting a ray in a random direction
3838
function HumanBehaviors.LookForTargets(AI, Owner, Skill)
39-
local viewAngDeg = RangeRand(50, 120) * (0.5 + Skill / 200)
39+
local viewAngDeg = RangeRand(50, 120) * Owner.Perceptiveness * (0.5 + Skill / 200)
4040
if AI.deviceState == AHuman.AIMING then
4141
AI.Ctrl:SetState(Controller.AIM_SHARP, true) -- reinforce sharp aim controller state to enable SharpLength in LookForMOs
42-
viewAngDeg = 15 + (Skill / 10)
42+
viewAngDeg = 15 * Owner.Perceptiveness + (Skill / 10)
4343
end
4444

4545
local FoundMO = Owner:LookForMOs(viewAngDeg, rte.grassID, false)
@@ -500,6 +500,13 @@ function HumanBehaviors.Sentry(AI, Owner, Abort)
500500
elseif AI.SentryFacing and Owner.HFlipped ~= AI.SentryFacing then
501501
Owner.HFlipped = AI.SentryFacing -- turn to the direction we have been order to guard
502502
break -- restart this behavior
503+
elseif math.random() < Owner.Perceptiveness then
504+
505+
-- turn around occasionally if there is open space behind our back
506+
local backAreaRay = Vector(-math.random(FrameMan.PlayerScreenWidth/4, FrameMan.PlayerScreenWidth/2) * Owner.FlipFactor, 0):DegRotate(math.random(-25, 25) * Owner.Perceptiveness)
507+
if not SceneMan:CastStrengthRay(Owner.EyePos, backAreaRay, 10, Vector(), 10, rte.grassID, SceneMan.SceneWrapsX) then
508+
Owner.HFlipped = Owner.FlipFactor == 1 and true or false
509+
end
503510
end
504511
end
505512
end

Base.rte/AI/HumanFunctions.lua

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
HumanFunctions = {};
22

33
function HumanFunctions.DoAlternativeGib(actor)
4-
-- Detach limbs instead of regular gibbing
4+
--Detach limbs instead of regular gibbing
55
if not actor.detachLimit then
66
actor.detachLimit = actor.GibWoundLimit;
77
actor.GibWoundLimit = actor.GibWoundLimit * 1.5;
88
end
99
if actor.WoundCount > actor.detachLimit then
1010
actor.detachLimit = actor.WoundCount + 1;
11-
local parts = {actor.BGArm, actor.BGLeg, actor.FGArm, actor.FGLeg, actor.Head}; -- Piority order
11+
local parts = {actor.BGArm, actor.BGLeg, actor.FGArm, actor.FGLeg, actor.Head}; --Piority order
1212
local mostWounds = -1;
1313
local detachLimb;
14-
-- Pick the limb with most wounds and detach it
14+
--Pick the limb with most wounds and detach it
1515
for i = 1, #parts do
1616
local limb = parts[i];
1717
if limb and limb.WoundCount > mostWounds then
@@ -26,87 +26,101 @@ function HumanFunctions.DoAlternativeGib(actor)
2626
end
2727

2828
function HumanFunctions.DoAutomaticEquip(actor)
29-
-- Equip a weapon automatically if the one held by a player is destroyed
29+
--Equip a weapon automatically if the one held by a player is destroyed
3030
if actor:IsPlayerControlled() and actor.EquippedItem == nil and actor.InventorySize > 0 and not actor.controller:IsState(Controller.WEAPON_FIRE) then
3131
actor:EquipFirearm(true);
3232
end
3333
end
3434

3535
function HumanFunctions.DoArmSway(actor, pushStrength)
36-
-- Control arm movements
37-
if not actor.lastHandPos then
38-
actor.lastAngle = actor:GetAimAngle(false);
36+
--Control arm movements
37+
local aimAngle = actor:GetAimAngle(false);
38+
if not actor.lastHandPos then --Initialize
39+
actor.lastAngle = aimAngle;
3940
actor.lastHandPos = {actor.Pos, actor.Pos};
4041
end
4142
if actor.controller:IsMouseControlled() then
42-
-- Flail around if moving mouse too fast
43+
--Flail around if moving mouse too fast
4344
local mouseVec = Vector(actor.controller.MouseMovement.X, actor.controller.MouseMovement.Y):SetMagnitude(math.sqrt(actor.controller.MouseMovement.Magnitude));
44-
local ang = actor.lastAngle - actor:GetAimAngle(false);
45+
local ang = actor.lastAngle - aimAngle;
4546

4647
actor.AngularVel = actor.AngularVel - (2 * ang * actor.FlipFactor + mouseVec.Y * actor.FlipFactor /10) /math.sqrt(math.abs(actor.AngularVel) + 1);
4748

48-
actor.lastAngle = actor:GetAimAngle(false);
49+
actor.lastAngle = aimAngle;
4950
end
50-
-- Shove when unarmed
51+
--Shove when unarmed
5152
if actor.controller:IsState(Controller.WEAPON_FIRE) and (actor.FGArm or actor.BGArm) and not (actor.EquippedItem or actor.EquippedBGItem) and actor.Status == Actor.STABLE then
52-
actor.AngularVel = actor.AngularVel /(actor.shoved and 1.5 or 3) + (actor:GetAimAngle(false) - actor.RotAngle * actor.FlipFactor - 1.57) * (actor.shoved and 0.5 or 3) * actor.FlipFactor /(1 + math.abs(actor.RotAngle));
53+
actor.AngularVel = actor.AngularVel /(actor.shoved and 1.3 or 3) + (aimAngle - actor.RotAngle * actor.FlipFactor - 1.57) * (actor.shoved and 0.3 or 3) * actor.FlipFactor /(1 + math.abs(actor.RotAngle));
5354
if not actor.shoved then
54-
actor.Vel = actor.Vel + Vector(3 /(1 + actor.Vel.Magnitude), 0):RadRotate(actor:GetAimAngle(true)) * math.abs(math.cos(actor:GetAimAngle(true)));
55+
actor.Vel = actor.Vel + Vector(2 /(1 + actor.Vel.Magnitude), 0):RadRotate(actor:GetAimAngle(true)) * math.abs(math.cos(actor:GetAimAngle(true)));
5556
actor.shoved = true;
5657
end
5758
else
5859
actor.shoved = false;
5960
end
60-
local arms = {{actor.FGArm, actor.FGLeg, actor.BGLeg}, {actor.BGArm, actor.BGLeg, actor.FGLeg}};
61-
for i = 1, #arms do
62-
local arm = arms[i][1];
61+
local armPairs = {{actor.FGArm, actor.FGLeg, actor.BGLeg}, {actor.BGArm, actor.BGLeg, actor.FGLeg}};
62+
for i = 1, #armPairs do
63+
local arm = armPairs[i][1];
6364
if arm then
64-
local arm = ToArm(arms[i][1]);
65+
arm = ToArm(arm);
66+
6567
local armLength = ToMOSprite(arm):GetSpriteWidth();
6668
local rotAng = actor.RotAngle - (1.57 * actor.FlipFactor);
67-
local legMain = arms[i][2];
68-
local legAlt = arms[i][3];
69+
local legMain = armPairs[i][2];
70+
local legAlt = armPairs[i][3];
6971

7072
if actor.controller:IsState(Controller.MOVE_LEFT) or actor.controller:IsState(Controller.MOVE_RIGHT) then
71-
if legAlt then
72-
rotAng = legAlt.RotAngle;
73-
elseif legMain then
74-
rotAng = -legMain.RotAngle + math.pi;
75-
end
73+
rotAng = (legAlt and legAlt.RotAngle) or (legMain and (-legMain.RotAngle + math.pi) or rotAng);
7674
elseif legMain then
7775
rotAng = legMain.RotAngle;
7876
end
79-
-- Flail arms in tandem with leg movement
80-
ToArm(arm).IdleOffset = Vector(0, armLength * 0.7):RadRotate(rotAng * actor.FlipFactor + 1.5 + (i /5));
81-
77+
--Flail arms in tandem with leg movement or raise them them up for a push if aiming
78+
if actor.controller:IsState(Controller.AIM_SHARP) then
79+
arm.IdleOffset = Vector(0, 1):RadRotate(aimAngle);
80+
else
81+
arm.IdleOffset = Vector(0, (armLength + arm.SpriteOffset.X) * 1.1):RadRotate(rotAng * actor.FlipFactor + 1.5 + (i /5));
82+
end
8283
if actor.shoved or (actor.EquippedItem and IsTDExplosive(actor.EquippedItem) and actor.controller:IsState(Controller.WEAPON_FIRE)) then
83-
arm.IdleOffset = Vector(armLength, 0):RadRotate(actor:GetAimAngle(false));
84-
local dist = SceneMan:ShortestDistance(actor.lastHandPos[i], arm.HandPos, SceneMan.SceneWrapsX);
85-
86-
local dots = math.sqrt(arm.Radius) * (arm.Frame /arm.FrameCount);
87-
84+
arm.IdleOffset = Vector(armLength + (pushStrength * armLength), 0):RadRotate(aimAngle);
85+
local handVector = SceneMan:ShortestDistance(actor.lastHandPos[i], arm.HandPos, SceneMan.SceneWrapsX);
86+
--Diminish hand relocation vector to potentially prevent post-superhuman pushing powers
87+
handVector:SetMagnitude(handVector.Magnitude / (1 + handVector.Magnitude / 100));
88+
--Emphasize the first frames that signify contracted arm = highest potential energy
89+
local dots = math.sqrt(arm.Radius) / (1 + arm.Frame /arm.FrameCount);
90+
local armStrength = (arm.Mass + arm.Material.StructuralIntegrity) * pushStrength;
8891
for i = 1, dots do
8992
local part = CreateMOPixel("Smack Particle Light");
9093
part.Pos = arm.HandPos;
91-
part.Vel = (actor.Vel + dist):SetMagnitude(math.sqrt(dist.Magnitude * pushStrength + math.abs(actor.AngularVel) * actor.Vel.Magnitude)):RadRotate(0.8 /dots * i) + Vector(0, -0.5);
92-
part.Mass = (arm.Mass + arm.Material.StructuralIntegrity) * pushStrength; part.Sharpness = math.random() * 0.1;
94+
part.Vel = Vector(handVector.X, handVector.Y):RadRotate(RangeRand(-0.1, 0.1)) * pushStrength + Vector(0, -0.5);
95+
part.Mass = armStrength; part.Sharpness = math.random() * 0.1;
9396
part.Team = actor.Team; part.IgnoresTeamHits = true;
9497
MovableMan:AddParticle(part);
9598
end
99+
--Apply some additional forces if the travel vector of the moving hand is half an arms length
100+
if handVector.Magnitude > (armLength /2) then
101+
local moCheck = SceneMan:GetMOIDPixel(arm.HandPos.X, arm.HandPos.Y)
102+
if moCheck ~= rte.NoMOID then
103+
local mo = MovableMan:GetMOFromID(MovableMan:GetMOFromID(moCheck).RootID);
104+
if mo and mo.Team ~= actor.Team and IsActor(mo) and actor.Mass > (mo.Mass / 2) then
105+
mo:AddForce(handVector * (actor.Mass / 2), Vector());
106+
ToActor(mo).Status = Actor.UNSTABLE;
107+
end
108+
end
109+
end
96110
end
97111
actor.lastHandPos[i] = arm.HandPos;
98112
end
99113
end
100114
end
101115

102116
function HumanFunctions.DoVisibleInventory(actor, showAll)
103-
-- Visualize inventory with primitive bitmaps
117+
--Visualize inventory with primitive bitmaps
104118
if actor.Status < Actor.DYING and not actor:IsInventoryEmpty() then
105119
local heldCount, thrownCount, largestItem = 0, 0, 0;
106120
for i = 1, actor.InventorySize do
107121
local item = actor:Inventory();
108122
if item then
109-
local fixNum = actor.HFlipped and -1 or 0; -- Fix offsets slightly when facing left
123+
local fixNum = actor.HFlipped and -1 or 0; --Fix offsets slightly when facing left
110124
if item.ClassName == "TDExplosive" then
111125
thrownCount = thrownCount + 1;
112126
elseif item.ClassName == "HDFirearm" or item.ClassName == "HeldDevice" then
@@ -119,16 +133,13 @@ function HumanFunctions.DoVisibleInventory(actor, showAll)
119133

120134
fixNum = fixNum + item.Radius * 0.2 + math.sqrt(heldCount);
121135

122-
-- Bigger actors carry weapons higher up, smaller weapons are carried lower down
136+
--Bigger actors carry weapons higher up, smaller weapons are carried lower down
123137
local drawPos = actor.Pos + Vector((-actorSize - fixNum) * actor.FlipFactor, -actorSize - itemSize + 1 + isFirearm * 3):RadRotate(actor.RotAngle);
124138

125139
local itemCount = math.sqrt(math.abs(actor.InventorySize - thrownCount));
126-
127-
-- Display tall objects upright
128-
local tallAng = 1.57;
129-
if ToMOSprite(item):GetSpriteWidth() < ToMOSprite(item):GetSpriteHeight() then
130-
tallAng = 0;
131-
end
140+
--Display tall objects upright
141+
local tallAng = ToMOSprite(item):GetSpriteWidth() > ToMOSprite(item):GetSpriteHeight() and 1.57 or 0;
142+
132143
local tilt = 0.3;
133144
local rotAng = actor.RotAngle + tallAng + (heldCount * tilt - itemCount * tilt + isFirearm /itemSize) /itemCount * actor.FlipFactor;
134145

Base.rte/AI/NativeDropShipAI.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ function NativeDropShipAI:Create(Owner)
1616

1717
Members.LastAIMode = Actor.AIMODE_NONE
1818

19+
local item = Owner:Inventory();
20+
if item and IsTDExplosive(item) then
21+
Members.AIMode = Actor.AIMODE_BOMB;
22+
end
23+
1924
-- The drop ship tries to hover this many pixels above the ground
2025
if Members.AIMode == Actor.AIMODE_BRAINHUNT then
2126
Members.hoverAlt = Owner.Radius * 1.7
2227
elseif Members.AIMode == Actor.AIMODE_BOMB then
23-
Members.hoverAlt = Owner.Radius * 7
28+
Members.hoverAlt = Owner.Radius * 6
2429
else
2530
Members.hoverAlt = Owner.Radius * 2
2631
end

0 commit comments

Comments
 (0)