Skip to content

Commit

Permalink
New user variable, service class changes, and other stuff.
Browse files Browse the repository at this point in the history
- Updated the SM_SmartMarines service to return if the specified marine can follow orders, return the value of CurrentMarineOrder, and to allow for changing the value of the marines' CurrentMarineOrder variable, which can be used in conjunction with calling Used() on the marine to order them around.
- Added User_ClipPlayers, which allows specified marines to not collide with players friendly to them.
- Changed around the marine command code a bit.
- Removed forgotten debug messages.
- Hopefully permanently fixed the bug that makes marines walk in place.
  • Loading branch information
inkoalawetrust committed Oct 17, 2022
1 parent 8f17c9a commit c5d5f18
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Document.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ This ensures that they will only take cover behind obstacles that can protect th
Do note that they will not take cover when patrolling or heading to a turret.

WHEN THEY GET OUT:
Marines that have found cover will only get out of cover in the following sitations:
Marines that have found cover will only get out of cover in the following situations:
- Their target has gone over or around their cover, or is within melee range.
- A grenade is nearby and about to explode.
- The area of the map they are taking cover at has changed, e.g the wall they were hiding behind lowered, or the actor they were behind moved or was destroyed.
Expand Down Expand Up @@ -203,6 +203,7 @@ User_GrenadeThreshold: How likely the marine is to throw a grenade, the lower th
User_DisobeyCommands: Friendly marines will not wander, follow, stay in place, or leave turrets when the player presses use on them.
User_NoReload: Marines do not need to ever reload their gun.
User_NoCover: Marines do not take cover when attacking.
User_ClipPlayers: Marines and players on the same side phase through each other.
User_NoRifleDrop: Marines will never drop their rifles when killed.
User_RetreatAttempts: The amount of times the marine tries to run out of sight of his target, when he needs to reload.
- Default is 10. -1 makes the marine reload in the open, without trying to get behind cover at all.
Expand Down
13 changes: 12 additions & 1 deletion MarineFunctions.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ Class SM_SmartMarines : Service
If (!Marine)
Return -1;

Return Marine.OnTurret;
If (Request ~== "IsOnTurret")
Return Marine.OnTurret;
Else If (Request ~== "FollowsOrders")
If (!Marine.User_DisobeyCommands || !(Marine.Master && SmartMarine(Marine.Master).Squad))
Return True;
Else If (Request ~== "CurrentMarineOrder")
Return Marine.CurrentMarineOrder;

If (Request ~== "SetCurrentMarineOrder")
SmartMarine(ObjectArg).CurrentMarineOrder = IntArg;

Return -1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Marine_Squads.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Class SM_MarineSquad Play
Return (Marine == Leader || Members.Find(Marine) != Members.Size());
}

//Checks if everyone in the squad is dead, returns false if at least one marine is alove.
//Checks if everyone in the squad is dead, returns false if at least one marine is alive.
//The exception parameter is for resurrected marines to assign themselves as leader if everyone besides them is dead.
Bool IsEveryoneDead (SmartMarine Exception = Null)
{
Expand Down
5 changes: 3 additions & 2 deletions Marine_UserVariables.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ Extend Class SmartMarine

//Found at least one visible friendly player to follow.
If (VisibleFriends.Size() - 1 >= 0)
{a_log ("friend found");
{
SetFriendPlayer (VisibleFriends[Random (0, VisibleFriends.Size() - 1)].Player); //Randomly pick a visible friend to follow.
CurrentMarineOrder = ORDER_FOLLOW;
}
//No friendplayer, or they are out of sight
Else If (!FriendPlayer || FriendPlayer && !CheckSight (Players[FriendPlayer].Mo, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY))
{if (!FriendPlayer) a_log ("no friend in sight");
{
CurrentMarineOrder = ORDER_WANDER;
bDontFollowPlayers = True;
}
Expand Down Expand Up @@ -95,6 +95,7 @@ Extend Class SmartMarine
Bool User_DisobeyCommands;
Bool User_NoReload;
Bool User_NoCover;
Bool User_ClipPlayers;
Bool User_RandomPersonality;
Bool User_NoRifleDrop;
String User_Color;
Expand Down
22 changes: 17 additions & 5 deletions ZScript.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Version "4.8.0"
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.*/
//I want to make more marines in the future, but to do that properly, I'll have to rewrite the code base for the 7th time, for my response to that, please refer to the above to do entry.
//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.

Expand Down Expand Up @@ -152,7 +153,7 @@ Class SmartMarine : Actor
//Increment the different orders by one. And loop around to standing still if it exceeds the maximum number of possible orders.
CurrentMarineOrder += 1;
If (CurrentMarineOrder > 3)
CurrentMarineOrder = 0;
CurrentMarineOrder = 0;

//Ordered to wander around randomly.
If (CurrentMarineOrder == ORDER_WANDER)
Expand Down Expand Up @@ -215,6 +216,13 @@ Class SmartMarine : Actor
Return Super.OkayToSwitchTarget(Other);
}

Override Bool CanCollideWith (Actor Other, Bool Passive)
{
If (User_ClipPlayers && Other && Other.Player && IsFriend (Other)) Return False;

Return Super.CanCollideWith(Other, Passive);
}

Mixin MarineFunctions;
SM_MarineSquad Squad; //A reference to the squad the marine is in.
Actor Icon; //The icon that appears above the marine when he is in a squad.
Expand Down Expand Up @@ -253,10 +261,10 @@ Class SmartMarine : Actor
Int CurrentMarineOrder;
Enum MarineOrders
{
ORDER_NONE,
ORDER_FOLLOW,
ORDER_WANDER,
ORDER_STANDSTILL
ORDER_NONE = 0,
ORDER_FOLLOW = 1,
ORDER_WANDER = 2,
ORDER_STANDSTILL = 3
};

States
Expand Down Expand Up @@ -381,6 +389,10 @@ Class SmartMarine : Actor
Return ResolveState ("Crouch");

SM_ShouldBeScared();

//Stops the marines from ever walking in place, or I sure hope it does anyway.
//It does seem to do that, as long as I don't try putting it in SM_Chase, since that's somehow different from putting it here, makes sense, right ?
bStandStill = False;
SM_Chase();

Return State (Null);
Expand Down

0 comments on commit c5d5f18

Please sign in to comment.