Skip to content

Commit

Permalink
New No Crouch Zone actor, crouched XDeath, and fixes and changes.
Browse files Browse the repository at this point in the history
- Added a new SM_NoCrouchZone actor, located under the ZDoom category, more information on it can be found inside document.txt.
- Hopefully fixed most instances of the marines trying to dodge non-projectiles that are marked as missiles, by making only missiles with a damage property higher than zero be pushed in the ProjectileList array.
- Fixed a bug where marines would take cover behind windows with hitscan blocking window linedefs, making them unable to do anything besides sit in place until their target got behind the windows.
- Changed the grenades' timer to decrement in Tick() instead of inside the grenades' spawn state.
- Grenades are now marked as having exploded (Meaning marines don't need to fear them.) about half a second after exploding, instead of being marked as such right after A_Explode is called.
- The grenades' bounce sound now stops once it has lost enough momentum, and when the grenade is close to exploding, it will begin to play a beeping sound.
- Add a gib death for the marines when crouched down.
- Added the MoveWithSector flag on the empty magazines and grenade pins, now they shouldn't be stuck in mid air when they drop, and the sector they are on moves.
- Fixed a bug on the vanilla rifle that made the zooming in and out animation break if the player died while it was playing.
- Updated document.
  • Loading branch information
inkoalawetrust committed Jun 2, 2022
1 parent ac8a198 commit a025301
Show file tree
Hide file tree
Showing 20 changed files with 182 additions and 50 deletions.
12 changes: 10 additions & 2 deletions Document.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ 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

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.
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

The marines have 120 health, somewhat higher than the players'. You can turn on the Friendly flag for them in the editor to use them as smart allies.
In fact, I've sort of just made them with the intent of being used as allies, like the Allied Marines resource from Realm667. But they should work just as well as enemies.
In fact, I've sort of just made them with the intent of being used as allies, like the Allied Marines resource from Realm667. But they work just as well as enemies.

Their name in the editor is "AI Marine" and "AI Marine (Turret)", and they can be found under the Marines folder.
Their class names are "SmartMarine", "TurretMarine"
The turret's editor name is "Machine Gun Emplacement", and it can be found in the Weapons folder, its' class name is "SmartMarineMGTurret"
The editor name of their No Crouch Zone map spots (More info below) is "No Crouch Zone (AI Marines)", and it can be found in the ZDoom folder, its' class name is SM_NoCrouchZone.

================|WHAT THEY CAN DO|================

Expand Down Expand Up @@ -128,6 +129,13 @@ Marines that have found cover will only get out of cover in the following sitati
- 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.
- Their target is gone, and they haven't found any other target for several seconds.

NO CROUCH ZONE ACTOR:
If you do not want the marines to crouch in certain areas, such as behind particular staircases, you can use the SM_NoCrouchZone actor.
Which will prevent marines entering its' range from crouching at all. The actor can be found under the "ZDoom" folder.
It also uses custom arguments (Not user variables) that allow you to specify its' range and for how long marines will not crouch once out of said range.
The custom arguments can be accessed by selecting the no crouch zone actor(s( and going to the Action/Tag/Misc. tab.
In addition to the custom arguments, you can also disable and enable the no crouch zone actors with Thing_Activate and Thing_Deactivate.

MISCELLANEOUS:
- Marines also avoid projectiles when behind cover. By ducking back in again. Friendly marines in cover will also avoid other friendly projectiles. Unless they are on the ignore list.
- While crouched, marines will sometimes look up. This is a purely cosmetic visual effect.
Expand Down
1 change: 1 addition & 0 deletions MAPINFO
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ DoomEdNums
8574 = TurretMarine
8575 = VanillaRifle
8576 = SmartMarineMGTurret
8577 = SM_NoCrouchZone
}

GameInfo
Expand Down
44 changes: 32 additions & 12 deletions MarineFunctions.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Class SM_ProjectileHandler : EventHandler
Override Void WorldThingSpawned(WorldEvent E)
{
//Add every spawned projectile to a big list.
If (E.Thing && E.Thing.bMissile)
If (E.Thing && E.Thing.bMissile && E.Thing.Damage > 0)
{
ProjectileList.Push(E.Thing);
}
Expand Down Expand Up @@ -599,7 +599,7 @@ Mixin Class MarineFunctions
{
Mobj = GrenadeSearch.Thing;
//If the found actor is a grenade, that hasn't exploded already, but that will explode in about a second. And you are in the blast radius, and it's visible.
If (Mobj.GetClassName() == "SM_Grenade" && !(SM_Grenade(Mobj).Exploded) && Mobj.ReactionTime <= 6 && Distance3D (Mobj) <= SearchRadius && IsVisible (Mobj,True))
If (Mobj.GetClassName() == "SM_Grenade" && !(SM_Grenade(Mobj).Exploded) && Mobj.ReactionTime <= 40 && Distance3D (Mobj) <= SearchRadius && IsVisible (Mobj,True))
{
OriginalTarget = Target; //Keep the original target of the marine stored.
Target = Mobj; //Then change the target to the grenade that was found.
Expand All @@ -614,12 +614,12 @@ Mixin Class MarineFunctions
{
FLineTraceData EyeLevel;
FLineTraceData HipLevel;
Bool EyeLevelBlocked;
Bool EyeLevelUnblocked;
Bool HipLevelBlocked;
Int HasHit;
Actor Mobj;

If (User_NoCover)
If (User_NoCover || CrouchDelay)
Return False;

//Don't crouch if you have no target, or your target is your goal too. AKA you are patrolling.
Expand All @@ -637,16 +637,15 @@ Mixin Class MarineFunctions
*/

If (!Crouching)
LineTrace (AngleTo (Target),48,0,TRF_THRUHITSCAN,50,data:EyeLevel);
LineTrace (AngleTo (Target),48,0,0,50,data:EyeLevel);
Else
LineTrace (AngleTo (Target),128,0,TRF_THRUHITSCAN,50,data:EyeLevel);

HasHit = EyeLevel.HitType;
EyeLevelBlocked = (EyeLevel.HitActor || (HasHit == TRACE_HitWall || HasHit == TRACE_HitFloor || HasHit == Trace_HitCeiling));
LineTrace (AngleTo (Target),128,0,0,50,data:EyeLevel);

EyeLevelUnblocked = SM_EyeLevelBlocked (EyeLevel);

If (!Crouching)
LineTrace (AngleTo (Target),48,0,TRF_THRUHITSCAN,18,data:HipLevel);
Else
Else //Run a longer range trace when crouched to not go out of cover as easily when behind strangely shaped cover like star shaped fountains.
LineTrace (AngleTo (Target),128,0,TRF_THRUHITSCAN,18,data:HipLevel);

HasHit = HipLevel.HitType;
Expand All @@ -659,14 +658,14 @@ Mixin Class MarineFunctions
//Only run this if the marine is not crouched already, and also has a target, that isn't a patrol point.
If (!Crouching)
{
If (!EyelevelBlocked && HipLevelBlocked && CheckSight (Target,SF_SEEPASTSHOOTABLELINES|SF_IGNOREWATERBOUNDARY))
If (EyelevelUnblocked && HipLevelBlocked && CheckSight (Target,SF_SEEPASTSHOOTABLELINES|SF_IGNOREWATERBOUNDARY))
Return True;
}

//If you are crouching already and have a line of sight to your target.
If (Crouching && CheckSight (Target,SF_SEEPASTSHOOTABLELINES|SF_IGNOREWATERBOUNDARY))
{
//Then return if you can crouch based on where or not your hips are blocked by cover still.
//Then return if you can crouch based on whether or not your hips are blocked by cover still.
Return HipLevelBlocked;
}

Expand All @@ -677,6 +676,27 @@ Mixin Class MarineFunctions
Return False;
}

Bool SM_EyeLevelBlocked (FLineTraceData Data)
{
Int HasHit;

HasHit = Data.HitType;

If (Data.HitActor)
Return False;

If (HasHit == TRACE_HitWall)
Return False;

If (HasHit == TRACE_HitFloor)
Return False;

If (HasHit == Trace_HitCeiling)
Return False;

Return True;
}

//Makes the marine listen for any enemy marines playing the radio transmission sound, which is played when marines alert each other.
Void SM_ListenForEnemyAlerts (Double HearingRadius = 1024)
{
Expand Down
12 changes: 12 additions & 0 deletions Marine_Deaths.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,24 @@ Extend Class SmartMarine
MARP K -1;
Stop;
XDeath: //Mega oof
TNT1 A 0 A_JumpIf ((Crouching && Height < Default.Height),"CrouchXDeath");
PLAY O 5;
PLAY P 5 A_StartSound("Marine/XDeath",CHAN_VOICE);
PLAY Q 5 A_NoBlocking();
PLAY RSTUV 5;
PLAY W -1;
Stop;
CrouchXDeath:
MARP L 5
{
Crouching = False;
Height = Default.Height;
}
MARP M 5 A_StartSound("Marine/XDeath",CHAN_VOICE);
MARP N 5 A_NoBlocking();
MARP OPQRS 5;
MARP T -1;
Stop;
Raise:
TNT1 A 0
{
Expand Down
93 changes: 84 additions & 9 deletions Marine_OtherActors.zsc
Original file line number Diff line number Diff line change
@@ -1,7 +1,63 @@
//$GZDB_SKIP

//Miscellaneous actors related to the marine.

//Marines that are in range of this actor when it's active will be stopped from crouching.
//This actor uses custom arguments unlike the marines, because I don't have to worry about someone giving this actor a death special. Nor does it have that many parameters.
Class SM_NoCrouchZone : Actor
{
Default
{
//$Title No Crouch Zone (AI Marines)
//$Category ZDoom
//$Sprite MARCZ0
//$Arg0 Range
//$Arg0Tooltip The range in which the crouch zone will prevent marines from crouching.
//$Arg0Default 128
//$Arg1 Crouch Delay
//$Arg1Tooltip How long this zone should prevent marines from crouching after they leave it.
//$Arg1Default 35
//$NotAngled
Radius 16;
Height 32;
+NoBlockmap;
}

Override Void Activate(Actor Activator)
{
Super.Activate (Activator);
SetStateLabel ("Spawn");
}

Override Void Deactivate(Actor Activator)
{
Super.Deactivate (Activator);
SetStateLabel ("Idle");
}

States
{
Spawn:
TNT1 A 2 NoDelay; //If the actor is turned off right after being spawned, this initial delay prevents it from telling any marines around it to not crouch.
TNT1 A 1
{
BlockThingsIterator MarineFinder = BlockThingsIterator.Create(Self,args[0]);
Actor Mobj;

While (MarineFinder.Next())
{
Mobj = MarineFinder.Thing;
If (Mobj.GetClassName() == "SmartMarine" && Mobj.Health > 0 && !Mobj.bDormant && Distance2DSquared(Mobj) <= args[0]*args[0])
SmartMarine(Mobj).CrouchDelay = Clamp(args[1],2,INT.MAX); //The minimum acceptable value is a 2 tics before the marine can crouch again.
}
}
Wait;
Idle:
TNT1 A 1;
Loop;
}
}

//$GZDB_SKIP

Class SmartMarinePuff : BulletPuff
{
Default
Expand Down Expand Up @@ -85,7 +141,7 @@ Class SM_Grenade : Actor
Speed 30;
BounceFactor 0.4;
WallBounceFactor 0.5;
ReactionTime 12; //Used as the fuse timer, similar to how A_Countdown uses it. This makes the grenade take about 3 seconds to explode.
ReactionTime 35*3; //Used as the fuse timer, similar to how A_Countdown uses it.
BounceType "Hexen";
BounceSound "Grenade/Bounce";
DamageType "MarineGrenade";
Expand Down Expand Up @@ -118,6 +174,17 @@ Class SM_Grenade : Actor
{
Super.Tick();

If (IsFrozen())
Return;

//The actual timer.
If (InStateSequence(CurState,ResolveState("Spawn")))
ReactionTime--;

//Play the beeping sound when the grenades' fuse is halfway to detonaton. But not when the grenade has exploded.
If (ReactionTime > 0 && ReactionTime <= Default.ReactionTime/2)
A_StartSound ("Grenade/Warning",CHAN_WEAPON,CHANF_LOOPING,1.0,2);

//"Water physics"
If (WaterLevel >= 1 && Gravity != 0)
{
Expand All @@ -133,11 +200,16 @@ Class SM_Grenade : Actor
{
Spawn:
TNT1 A 0 NoDelay A_SpawnItemEx ("SM_GrenadeLever",yvel:FRandom(-2,-4),FRandom(2,4));
MGRE B 8
MGRE B 4
{
//Only roll when moving fast enough.
//Only roll and play the bounce sound when moving fast enough.
If (Vel.Length() >= 2)
{
BounceSound = Default.BounceSound;
Roll += 20;
}
Else
BounceSound = "";

//First, check if the grenade exploded near the floor of a sector or 3D floor with a liquid flat.
If (ReactionTime <= 0 && (SM_GrenadeExplodedOnLiquid() != SM_HitNoLiquid))
Expand All @@ -150,7 +222,6 @@ Class SM_Grenade : Actor
If (ReactionTime <= 0 && (Pos.Z - FloorZ) >= 32) {A_SetRenderStyle (1.0,Style_Add);Return ResolveState ("Death.Air");}
//If the fuse timer is 0 and the grenade exploded below 32 MU, enter the ground explosion state.
If (ReactionTime <= 0 && (Pos.Z - FloorZ) <= 32) {A_SetRenderStyle (1.0,Style_Add);Return ResolveState ("Death.Floor");}
ReactionTime--;
Return ResolveState(Null);
}
Goto Spawn+1;
Expand All @@ -168,8 +239,9 @@ Class SM_Grenade : Actor
}
GXPL A 2 Bright;
GXPL B 4 Bright A_Explode (128,192,fulldamagedistance:24);
GXPL CDEF 4 Bright;
TNT1 A 0 {Exploded = True;}
GXPL CDEFGHIJKLMNO 4 Bright;
GXPL GHIJKLMNO 4 Bright;
Stop;
Death.Floor.Liquid:
TNT1 A 0
Expand All @@ -195,8 +267,8 @@ Class SM_Grenade : Actor
}
#### A 3 A_StartSound ("Grenade/WaterBlast",CHAN_WEAPON,attenuation:0.6);
#### B 3 A_Explode (128,128,fulldamagedistance:16); //Explosions inside of liquids do less damage.
#### # 0 {Exploded = True;}
#### CDEF 4;
#### # 0 {Exploded = True;}
#### GHIJKLMNOPQRSTUVWXYZ 3;
Stop;
Death.Air:
Expand All @@ -212,8 +284,9 @@ Class SM_Grenade : Actor
}
GAXP A 5 Bright;
GAXP B 5 Bright A_Explode (128,224,fulldamagedistance:56);
GAXP CDEF 5 Bright;
TNT1 A 0 {Exploded = True;}
GAXP CDEFGHIJ 5 Bright;
GAXP GHIJ 5 Bright;
Stop;
DummySprites: //So GetSpriteIndex doesn't shit itself.
TNT1 A 0 A_Log ("An SM_Grenade actor entered the dummy sprites state, that shouldn't happen !");
Expand All @@ -235,6 +308,7 @@ Class SM_GrenadeLever : Actor //The lever the grenade drops once the pin is pull
Scale 0.5;
+NoBlockmap;
+RollSprite;
+MoveWithSector;
}
States
{
Expand All @@ -259,6 +333,7 @@ Class SmartMarineEmptyMagazine : Actor
Scale 0.7;
+NoBlockmap;
+RollSprite;
+MoveWithSector;
}
States
{
Expand Down
1 change: 1 addition & 0 deletions SNDINFO
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Turret/Impact "Sounds/MGImpact.ogg"
//Grenade sounds
Grenade/Bounce "Sounds/GrenadeBounce.ogg"
Grenade/Explode "Sounds/GrenadeBoom.ogg"
Grenade/Warning "Sounds/GrenadeBeep.ogg"
Grenade/WaterBlast "Sounds/WaterBoom.ogg"

$Attenuation Turret/Fire 0.25
Expand Down
Binary file added Sounds/GrenadeBeep.ogg
Binary file not shown.
Binary file added Sprites/Deaths/Crouched/MARPL0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprites/Deaths/Crouched/MARPM0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprites/Deaths/Crouched/MARPN0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprites/Deaths/Crouched/MARPO0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprites/Deaths/Crouched/MARPP0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprites/Deaths/Crouched/MARPQ0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprites/Deaths/Crouched/MARPR0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprites/Deaths/Crouched/MARPS0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprites/Deaths/Crouched/MARPT0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprites/MARCZ0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a025301

Please sign in to comment.