Skip to content

Commit

Permalink
Bugfixes and updates to the turret marine.
Browse files Browse the repository at this point in the history
- Removed a forgotten debug message, because apparently, constantly forgetting to remove debug code is a thing I do now.
- Fixed a bug where the game froze if a friendly marine that is pre-spawned on a turret heard the player.
- Made the stationary turret marines work with the SM_ImInDanger token.
  • Loading branch information
inkoalawetrust committed Sep 1, 2022
1 parent f94329d commit 5f1f3d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
17 changes: 14 additions & 3 deletions MarineFunctions.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -1015,20 +1015,31 @@ Mixin Class TurretMarineFunctions
Return False;
}

//Searches for grenades that are about to explode near the marine.
//Searches for grenades that are about to explode near the marine. Or for generic danger tokens.
Bool STM_FindNearbyGrenade (Double SearchRadius = 256)
{
Inventory Token;
If (bDormant || !User_RunFromGrenades) Return False;

Token = FindInventory ("SM_ImInDanger");

If (Token && Token.Master)
{
TakeInventory ("SM_ImInDanger",1); //Remove the token now, if the marine still needs to run, the warning source should give another token for the next function call.
Return True; //And return true.
}
//The token is in the inventory, but has no master e.g it was given by a danger source, but the source was removed while the marine was already running away.
Else If (Token && !Token.Master)
TakeInventory ("SM_ImInDanger",1); //Just remove the token.

Actor Mobj;
BlockThingsIterator GrenadeSearch = BlockThingsIterator.Create (Self,SearchRadius);

While (GrenadeSearch.Next())
{
Mobj = GrenadeSearch.Thing;
If (Mobj.GetClassName() == "SM_Grenade" && !(SM_Grenade(Mobj).Exploded) && Mobj.ReactionTime <= 40 && Distance3DSquared (Mobj) <= SearchRadius*SearchRadius && IsVisible (Mobj,True))
{
Return True; //And return true.
}
}
Return False; //No grenades were found near the marine.
}
Expand Down
5 changes: 2 additions & 3 deletions Marine_Turret.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Class TurretMarine : Actor
+NoPain;
+AvoidHazards; //This ONLY works for crushing ceilings and NOTHING ELSE. So it's largely useless but I'm still adding it.
+SeeFriendlyMonsters;
+StandStill; //Fixes a fucking stupid bug where friendly turret marines freeze the game when hearing the player.
}

Override Void Tick()
Expand Down Expand Up @@ -191,7 +192,7 @@ Class TurretMarine : Actor
Return ResolveState ("LeaveTurret");
}

A_LookEx (0,0,8192,4096,160,"AlertOtherMarines");
A_LookEx (0,0,8192,4096,160,"See");
Return State (Null);
}
MTUR B 0 {If (Random (0,256) > 235) {Angle += RandomPick(45,90,-45,-90);}}
Expand All @@ -201,9 +202,7 @@ Class TurretMarine : Actor
{
//Have the marine run away from grenades about to explode.
If (STM_FindNearbyGrenade())
{
Return ResolveState ("LeaveTurret");
}

If (Target && Target.Health <= 0) Target = Null; //Remove dead targets.

Expand Down
3 changes: 2 additions & 1 deletion ZScript.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ THERE ARE 86,000,000,000 NEURONS THAT MY BRAIN IS COMPOSED OF.
IF THE WORD HATE WAS ENGRAVED ON EACH NANOANGSTROM OF THOSE TENS OF BILLIONS OF NEURONS IT WOULD NOT EQUAL ONE ONE-BILLIONTH OF THE HATE I FEEL FOR
MARINES AT THIS MICRO-INSTANT FOR YOU. HATE. HATE.*/
//Maybe add a secondary melee attack to the rifle weapon, like what the marines have. I'll need first person sprites of the rifle being swung though.
//Possibly make an actual API that mods can use, such as multiple services that can return if variables like OnTurret and Crouching are on.

Class SmartMarine : Actor
{
Expand Down Expand Up @@ -802,7 +803,7 @@ Class SmartMarine : Actor
bFrightened = False;
bChaseGoal = WasChaseGoalOn;
WasChaseGoalOn = False;
Speed = Default.Speed;a_log ("i have finished running");
Speed = Default.Speed;
}
Goto See; //Go back to the see state.
DecideAttack: //Decide if you should use a turret, throw a grenade, or just shoot.
Expand Down

0 comments on commit 5f1f3d8

Please sign in to comment.