Skip to content

Commit

Permalink
Bug fixes and a generic way to make marines run from danger.
Browse files Browse the repository at this point in the history
- Added easter egg.
- Added the SM_ImInDanger inventory token, which allows for other mods to warn marines of a danger, it is checked for in SM_FindNearbyGrenade(). (Currently broken, just causes the marines to run in place usually.)
- Fixed a VM aborts caused by the marines' master not being another marine.
- Fixed a bug that caused the NoPain flag to not really be set to true when the marines run to reload.
- Updated document and readme.
  • Loading branch information
inkoalawetrust committed Aug 22, 2022
1 parent 9a1d2d3 commit ef7cd26
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Document.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The credits for every asset used on this NPC, can be found inside credits.txt.

SHOWCASE VIDEO AND DOCUMENTATION OF THE MARINES: https://www.youtube.com/watch?v=PlZSs5XyEdU
UPDATE VIDEO: https://youtu.be/unfIzwMtQJ4

If you have any issues with the marines or some other NPC made by me, you can ask me for help on Discord at inkoalawetrust#9783, or Twitter at @inkoalawetrust. Or put them on the issue tracker: https://github.com/inkoalawetrust/Smart-Marines/issues

Expand Down Expand Up @@ -54,6 +55,7 @@ The editor name of their No Crouch Zone map spots (More info below) is "No Crouc
- The rifle fires at full auto, and needs reloading after firing 20 rounds, just like when the marines use them. You can reload before the magazine fully runs out too.
- It also features animated digital sights complete with an animation for looking in and out of them, using the sights increases your accuracy as well.
- The rifle can be entirely disabled from dropping from dead marines, by enabling User_NoRifleDrop on the marine.
- Has easter eggs.

================|PROJECTILE DODGING|================
Marines are also able to dodge projectiles that are heading in their direction, the text below will explain how the dodging behavior works exactly.
Expand Down
38 changes: 32 additions & 6 deletions MarineFunctions.zsc
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
Class SM_SmartMarines : Service {} //This service can be searched for by other mods to check if the marine NPC is loaded.
//This service can be searched for by other mods to check if the marine NPC is loaded.
Class SM_SmartMarines : Service
{
Override Int GetInt (String Request, string stringArg, int intArg, double doubleArg, Object objectArg)
{
Let Marine = SmartMarine(ObjectArg);
If (!Marine)
Return -1;

Return Marine.OnTurret;
}
}

Class SM_ProjectileHandler : EventHandler
{
Expand Down Expand Up @@ -42,11 +53,11 @@ Class SM_LiquidTextureNameList : EventHandler
The lists already contain some names of liquid flats that don't exist in the vanilla game, for built-in mod compatibility.
Such as by having waterfall textures that don't exist like WFALL# and NFALL#.
===============================================================*/
Static Const String WaterTextures[] ={"FWATER1", "FWATER2", "FWATER3", "FWATER4", "WFALL1", "WFALL2", "WFALL3", "WFALL4"};
Static Const String NukageTextures[] ={"NUKAGE1", "NUKAGE2", "NUKAGE3", "NFALL1", "NFALL2", "NFALL3", "NFALL4"};
Static Const String BloodTextures[] ={"BLOOD1", "BLOOD2", "BLOOD3", "BFALL1", "BFALL2", "BFALL3", "BFALL4"};
Static Const String LavaTextures[] ={"LAVA1","LAVA2", "LAVA3", "LAVA4", "DBRAIN1", "DBRAIN2", "DBRAIN3", "DBRAIN4", "LFALL1", "LFALL2", "LFALL3", "LFALL4"};
Static Const String SlimeTextures[] ={"SLIME01","SLIME02", "SLIME03", "SLIME04", "SLIME05","SLIME06", "SLIME07", "SLIME08", "SFALL1", "SFALL2", "SFALL3", "SFALL4"};
Static Const String WaterTextures[] = {"FWATER1", "FWATER2", "FWATER3", "FWATER4", "WFALL1", "WFALL2", "WFALL3", "WFALL4"};
Static Const String NukageTextures[] = {"NUKAGE1", "NUKAGE2", "NUKAGE3", "NFALL1", "NFALL2", "NFALL3", "NFALL4"};
Static Const String BloodTextures[] = {"BLOOD1", "BLOOD2", "BLOOD3", "BFALL1", "BFALL2", "BFALL3", "BFALL4"};
Static Const String LavaTextures[] = {"LAVA1","LAVA2", "LAVA3", "LAVA4", "DBRAIN1", "DBRAIN2", "DBRAIN3", "DBRAIN4", "LFALL1", "LFALL2", "LFALL3", "LFALL4"};
Static Const String SlimeTextures[] = {"SLIME01","SLIME02", "SLIME03", "SLIME04", "SLIME05","SLIME06", "SLIME07", "SLIME08", "SFALL1", "SFALL2", "SFALL3", "SFALL4"};

}

Expand Down Expand Up @@ -631,7 +642,22 @@ Mixin Class MarineFunctions
//Searches for grenades that are about to explode near the marine.
Bool SM_FindNearbyGrenade (Double SearchRadius = 256)
{
Inventory Token;
If (bDormant) Return False;

Token = FindInventory ("SM_ImInDanger");

If (Token && Token.Master)
{a_log ("*chuckles*, im in danger");
OriginalTarget = Target; //Keep the original target of the marine stored.
Target = Token.Master; //Then change the target to the actor that droped the token.
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); a_log ("i got 99 problems and a token aint one");} //Just remove the token.

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

Expand Down
4 changes: 2 additions & 2 deletions Marine_Deaths.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Extend Class SmartMarine

Squad.AssignNewSquadLeader(Self);
}
Else If (Master && SmartMarine(Master).Squad && Health <= GetGibHealth())
Else If (Master && Master Is "SmartMarine" && SmartMarine(Master).Squad && Health <= GetGibHealth())
SmartMarine(Master).Squad.LeaveSquad (Self);
}

Expand All @@ -37,7 +37,7 @@ Extend Class SmartMarine
}

//If you were in a squad, access the squad class from your leader to remove yourself from the member list.
If (Master && SmartMarine(Master).Squad)
If (Master && Master Is "SmartMarine" && SmartMarine(Master).Squad)
SmartMarine(Master).Squad.Members.Delete(SmartMarine(Master).Squad.Members.Find(Self));

If (!bDormant && Random (0,512) == Random (0,512))
Expand Down
29 changes: 29 additions & 0 deletions Marine_OtherActors.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ Class SmartMarineFollowingMessage : SmartMarineStandingMessage
}
}

Class SmartMarineSuperDuperSecretUndertaleReference : SmartMarineStandingMessage
{
States
{
Spawn:
MARC G 16 NoDelay A_StartSound ("Marine/AltDodge");
MARC G 1 A_FadeOut (0.05);
Wait;
}
}

Class SmartMarineSquadIcon : Actor
{
Default
Expand Down Expand Up @@ -439,4 +450,22 @@ Class SM_TurretLocationMarker : PatrolPoint

Warp (Master); //If the turret moves horizontally somehow, then move too, to update the location the marine has to go to.
}
}

//Le DECORATE hack to allow other mods to alert marines by giving them this token, because Services apparently only allow cross mod communication, not interaction.
//When marines call SM_FindNearbyGrenade, they will trigger their running away state if they have this in their inventory. But to do that, you must
//set the actor they should run away from as the tokens' master. So that they will make it into the actor to actually run away from.
Class SM_ImInDanger : Inventory
{
Default
{
Inventory.MaxAmount 1;
Inventory.Amount 1;
+Inventory.Undroppable;
+Inventory.Unclearable;
+Inventory.HubPower;
+Inventory.PersistentPower;
+Inventory.Untossable;
+Inventory.NoScreenFlash;
}
}
8 changes: 5 additions & 3 deletions Marine_Squads.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ Extend Class SmartMarine
//Makes marines in squads and their leaders alert the rest of their squad of an enemy.
Void SM_AlertSquadmates ()
{
If (!(Master Is "SmartMarine"))
Return;

If (Master && SmartMarine(Master).Squad)
SmartMarine(Master).Squad.AlertSquad(Self);
Else If (Squad && Squad.Leader == Self)
Expand All @@ -99,7 +102,7 @@ Extend Class SmartMarine
FollowPlayers = bDontFollowPlayers;

//Don't run this if the marine doesn't have a squad leader, or has a patrol point.
If (Master && SmartMarine(Master).Squad && !Goal)
If (Master && Master Is "SmartMarine" && SmartMarine(Master).Squad && !Goal)
{
bDontFollowPlayers = True; //Don't follow the player when in a squad, only your leader.
//If you have a target, then follow your leader if he is further than 640 map units, but don't get too close.
Expand Down Expand Up @@ -153,7 +156,7 @@ Extend Class SmartMarine
Bool FollowPlayers;
FollowPlayers = bDontFollowPlayers;
//If you are in a squad.
If (Master && SmartMarine(Master).Squad)
If (Master && Master Is "SmartMarine" && SmartMarine(Master).Squad)
{
bDontFollowPlayers = True;
//Move towards your squad leader if you are too far away from him.
Expand Down Expand Up @@ -242,7 +245,6 @@ Class SM_MarineSquad Play
//If the above search didn't return a single marine who hasn't been gibbed already. Then remove the squad.
If (!NextLeader)
{

If (Caller.Squad)
SquadList.RemoveSquad (Caller.Squad);
Caller.Squad = Null;
Expand Down
1 change: 1 addition & 0 deletions SNDINFO
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Marine/Pain DSPLPAIN
Marine/AlertAllies "Sounds/Alert.ogg"
Marine/AlertAlliesAlt "Sounds/AltAlert.ogg"
Marine/Throw DSNOWAY //https://www.youtube.com/watch?v=UhVHp1cFTTc
Marine/AltDodge "Sounds/AltDodge.ogg" //It's a beautiful day outside...
Marine/Wahoo "Sounds/AltJump.ogg" //Super Doomguy Bros
Marine/Fire "Sounds/RifleFire.ogg"
Marine/Reload "Sounds/RifleReload.ogg"
Expand Down
Binary file added Sounds/AltDodge.ogg
Binary file not shown.
Binary file added Sprites/MARCG0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 17 additions & 12 deletions ZScript.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Class SmartMarine : Actor
Super.Used (User);

//Don't follow any player commands if in a squad. Unless you are the leader.
If (Master && SmartMarine(Master).Squad)
If (Master && Master Is "SmartMarine" && SmartMarine(Master).Squad)
Return False;

//Trying to command an enemy marine just makes them attack you.
Expand All @@ -131,7 +131,7 @@ Class SmartMarine : Actor
Return True;
}

If (User_DisobeyCommands || Goal || Master) Return False; //Ignore all this when patrolling, if it is disabled. Or if you are in a squad.
If (User_DisobeyCommands || Goal) Return False; //Ignore all this when patrolling, if it is disabled. Or if you are in a squad.

If (OnTurret && IsFriend (User) && !Target) //If you are on a turret, your user was friendly, and you have no target currently.
{
Expand Down Expand Up @@ -266,10 +266,10 @@ Class SmartMarine : Actor
Return ResolveState ("RunAway");

//If you are in a squad, and your leader is too far away from you, start following him.
If (Master && SmartMarine(Master).Squad && Distance3DSquared (Master) >= 512*512 && CurrentMarineOrder != ORDER_STANDSTILL)
If (Master && Master Is "SmartMarine" && SmartMarine(Master).Squad && Distance3DSquared (Master) >= 512*512 && CurrentMarineOrder != ORDER_STANDSTILL)
Return ResolveState ("Idle");

If (Master && SmartMarine(Master).Squad && SmartMarine(Master).CurrentMarineOrder != ORDER_STANDSTILL)
If (Master && Master Is "SmartMarine" && SmartMarine(Master).Squad && SmartMarine(Master).CurrentMarineOrder != ORDER_STANDSTILL)
CurrentMarineOrder = ORDER_NONE;

bStandStill = True; //Prevents friendly marines from moving because they heard a friendly player.
Expand All @@ -283,7 +283,7 @@ Class SmartMarine : Actor
MAR2 AAAABBBBCCCCDDDD 2
{
If((Target && Target Is 'PatrolPoint') && ((Goal && Target != Goal) || !Goal)) Target = Null; //Don't target patrol points you aren't heading to.

//If your goal is a marker to a turret for you to enter.
//======================================================
If (Goal && Goal.GetClassName() == "SM_TurretLocationMarker")
Expand Down Expand Up @@ -494,7 +494,11 @@ Class SmartMarine : Actor

//May shoot at the shooter of the projectile he is dodging while in mid air, if the marine has ammo left.
StrafeAttack = (AmmoUsed < 19 && Random (0,255) < 180);


//what? you think i'm just gonna stand there and take it?
If (Random (0,255) == Random (0,255))
Spawn ("SmartMarineSuperDuperSecretUndertaleReference",(Pos.X,Pos.Y,Pos.Z+Height+4));

If (!(Random (0,255) == Random (0,255)))
A_StartSound ("Marine/Throw",CHAN_VOICE); //Umf
Else
Expand Down Expand Up @@ -738,7 +742,8 @@ Class SmartMarine : Actor
TNT1 A 0
{
A_SetSpeed (Default.Speed*1.5);
RunningToReload = True;
RunningToReload = bNoPain = True;
bNoPain = True;
}
PLAY AABBCCDD 2
{
Expand All @@ -748,21 +753,21 @@ Class SmartMarine : Actor
If (User_RetreatAttempts == -1 || bChaseGoal && Goal || Crouching)
{
Speed = Default.Speed;
RunningToReload = False;
RunningToReload = bNoPain = False;
QuickReload = True;
Return ResolveState ("Reload");
}
bFrightened = True; bNoPain = True;
bFrightened = True;
A_Chase (Null,Null); //Just run away from your target.
bNoPain = False; bFrightened = False;
bFrightened = False;
Return State (Null);
}
PLAY A 0
{
EscapeAttempts++;
If (EscapeAttempts >= User_RetreatAttempts || Target && (!IsVisible (Target,True) || Target.Health <= 0))
{
RunningToReload = False;
RunningToReload = bNoPain = False;
EscapeAttempts = 0;
Speed = Default.Speed;
Return ResolveState ("Reload");
Expand Down Expand Up @@ -797,7 +802,7 @@ Class SmartMarine : Actor
bFrightened = False;
bChaseGoal = WasChaseGoalOn;
WasChaseGoalOn = False;
Speed = Default.Speed;
Speed = Default.Speed;a_log ("i have finished running");
}
Goto See; //Go back to the see state.
DecideAttack: //Decide if you should use a turret, throw a grenade, or just shoot.
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Smart marines are NPCs for Doom that are far more intelligent than vanilla monst
- The rifle fires at full auto, and needs reloading after firing 20 rounds, just like when the marines use them. You can reload before the magazine fully runs out too.
- It also features animated digital sights complete with an animation for looking in and out of them, using the sights increases your accuracy as well.
- The rifle can be entirely disabled from dropping from dead marines, by enabling User_NoRifleDrop on the marine.
- Has easter eggs.

More information, such as info on what all the user variables available on the marines are, and what they do. Can be found inside Document.txt

Expand Down

0 comments on commit ef7cd26

Please sign in to comment.