Skip to content

Commit

Permalink
1.3.2 update
Browse files Browse the repository at this point in the history
- Marines now have a small chance to decide to lie down to fire when shooting out in the open, this shrinks their hitbox appropriately, and for friendly marines, also increases their accuracy slightly.
- Marines now wait for about a second after throwing a grenade, before they decide to throw another one. This will hopefully alleviate any issues people have with them spamming them too often.
- Hostile marines will now increase their chance of using a turret based on how many fellow hostile monsters have the SeeFriendlyMonsters flag, as that flag is now a universal way to make monsters react to player allies.
- Marines that are behind cover have a slightly higher chance to throw a grenade.
- Changed the marines' default species to Military, and the species of hostile marines to MilitaryHostile.
- Added an empty service class called SM_SmartMarines, looking for it with a ServiceIterator allows for other mods to check if the marines are loaded.
- Updated tooltip description for the No Crouch Zone actor.
- Reverted the changes from version 1.3.1, to fix a bug with //$UserDefaultValue that makes the default user variables of any actor not initialize, if they weren't spawned by being placed in the map through a map editor.
- Updated credits
  • Loading branch information
inkoalawetrust committed Aug 7, 2022
1 parent 58e2f00 commit 9a1d2d3
Show file tree
Hide file tree
Showing 19 changed files with 163 additions and 56 deletions.
9 changes: 7 additions & 2 deletions Document.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The editor name of their No Crouch Zone map spots (More info below) is "No Crouc
- Attack stuff by:
- Bashing it with their rifle. But they normally avoid it if they can help it. (Melee)
- Can also use berserk packs, if one is somehow in their inventory, which triple their melee damage, and make them more likely to engage in melee.
- Shoot at it, with a random chance of changing position while doing so. (Ranged)
- Shooting at it, with a random chance of changing position or lying down while doing so. (Ranged)
- Throw a grenade at it, more likely to throw it at crowds of enemies. (Area of effect)
- They avoid firing their rifles, grenades, or turrets if their line of fire to the target is blocked by obstacles or allies.
- Run away from the grenades they throw, if those grenades are about to explode.
Expand Down Expand Up @@ -49,6 +49,7 @@ The editor name of their No Crouch Zone map spots (More info below) is "No Crouc
- Random (Randomly pick a color.)
- Default (Use the default shade of green. Similar to just leaving User_Color empty.)
- Most of the marines' behaviour can be configured on a per actor basis using user variables.
- Can have a randomized personality, that gives the marine a random armor color, different attention spans and chances to throw a grenade etc. Adding a custom value to a user variable prevents it from being randomized.
- They also have a rifle that they sometimes drop, which you can pick up and use yourself.
- 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.
Expand Down Expand Up @@ -134,7 +135,7 @@ 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.
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:
Expand Down Expand Up @@ -217,6 +218,10 @@ User_FearDistance: The distance that the marine runs away to, if his target is s
- Default is 2048 map units, a value of 0 or less makes them fearless. (Within reason, so they still avoid grenades for example.)
User_Color: Can be used to give the marines different armor colors.
- Default is no translation, the available colors are Default, Gray, Red, White, Black, Blue, Yellow, Orange, Pink, Dark Green, Dark Red, and Random, which randomly picks any of the afformentioned colors.
User_RandomPersonality: When on, it randomizes several user variables that could be considered aspects of the marines' personality, such as:
- User_SearchTime, User_GrenadeThreshold, User_TurretThreshold, User_RetreatAttempts, User_FearDistance, and User_Color.
- If any of those variables have any values besides their defaults, then they won't be randomized, so you can still for example have marines with random grenade and turret thresholds, but the same melee chance.
- The variable can be set to true again in-game using SetUserVariable() in ACS, allowing you to randomize a marines' personality mid-game, if you want to do that for some reason.

STATIONARY TURRET MARINE VARIABLES:
- User_RunFromGrenades: When turned on, the stationary marine will leave his turret to run from any grenades about to explode, like the marines normally do.
Expand Down
29 changes: 19 additions & 10 deletions MarineFunctions.zsc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Class SM_SmartMarines : Service {} //This service can be searched for by other mods to check if the marine NPC is loaded.

Class SM_ProjectileHandler : EventHandler
{
//Much faster alternative to just using a ThinkerIterator.
Expand Down Expand Up @@ -186,6 +188,7 @@ Mixin Class MarineFunctions
ThrowChance = Random (0,256);
BlockThingsIterator FindTargets = BlockThingsIterator.Create (Target,BlastRadius);

If (Crouching) ThrowChance += 20; //Marines behind cover are a bit more likely to throw grenades.
If (Target.Health >= 10000) ThrowChance += 230;
Else If (Target.Health >= 4000) ThrowChance += 80;
Else If (Target.Player) ThrowChance += 20;
Expand Down Expand Up @@ -333,7 +336,7 @@ Mixin Class MarineFunctions
//Bullet impact splash handling.
//The splashes only work with solid surfaces because I tried getting them to work with swimmable 3D floors for 2 days straight to no avail.
//Also, the rifle the marines drop doesn't produce splashes because calling this exact same code from the player produces pitch differences
//between where the line trace is fired, and where the actual hitscan attack is fired because reason I guess.
//between where the line trace is fired, and where the actual hitscan attack is fired because reasons I guess.
FLineTraceData LiquidCheck;
Actor Splash;
Let LiquidList = SM_LiquidTextureNameList(EventHandler.Find("SM_LiquidTextureNameList"));
Expand Down Expand Up @@ -540,7 +543,7 @@ Mixin Class MarineFunctions

If (EpicFail) Continue;

//Hostile marines and any marines currently in cover will ignore all projectiles, except for ones on the Ignored Projectiles list.
//Hostile marines and any marines currently in cover will dodge all projectiles, except for ones on the Ignored Projectiles list.
If (!bFriendly || Crouching) SkipAllyCheck = True;

//If the projectile heading towards you will do way too much damage, then avoid it even if it was shot by a friend. This has to account for Doom's absurd damage variation.
Expand Down Expand Up @@ -765,8 +768,14 @@ Mixin Class MarineFunctions
FLineTraceData LOFCheck;

A_FaceTarget(0,0,flags:FAF_MIDDLE);

LineTrace (Angle+BulletSpreadXY,8192+2,Pitch+BulletSpreadZ,0,42,0,-6,LOFCheck);

//Not lying down, fire the raycast at normal eye height.
If (!LieDown)
LineTrace (Angle+BulletSpreadXY,8192+2,Pitch+BulletSpreadZ,0,42,0,-6,LOFCheck);
//Lying down, lower the raycast spawn height
Else
LineTrace (Angle+BulletSpreadXY,8192+2,Pitch+BulletSpreadZ,0,8,0,-6,LOFCheck);

Mobj = LOFCheck.HitActor;
HitLine = LOFCheck.HitLine;
If (Mobj) //Only run this if an actor was hit by the raycast.
Expand Down Expand Up @@ -816,7 +825,7 @@ Mixin Class MarineFunctions

While (FindTurrets.Next())
{
If (FindTurrets.Thing Is "SmartMarineMGTurret" && !(SmartMarineMGTurret(FindTurrets.Thing).Occupied) && IsVisible (FindTurrets.Thing,True) && Distance3DSquared (FindTurrets.Thing) <= TurretRadius*TurretRadius)
If (FindTurrets.Thing Is "SmartMarineMGTurret" && !(SmartMarineMGTurret(FindTurrets.Thing).Operator) && IsVisible (FindTurrets.Thing,True) && Distance3DSquared (FindTurrets.Thing) <= TurretRadius*TurretRadius)
{
FoundTurret = FindTurrets.Thing;
//Break;
Expand Down Expand Up @@ -869,18 +878,18 @@ Mixin Class MarineFunctions
UseChance += 10;
}
//Also increase the chance for every ally you found around you, that could support you while you are stationary and vulnerable.
If (bFriendly || !bFriendly && Target.Player)
If (bFriendly)
{
If (Mobj.Health >= 10 && !IsHostile (Mobj) && Mobj.Distance3DSquared (Target) <= ((EnemyRadius/2)*(EnemyRadius/2)) && IsVisible (Mobj,True))
{
If ((Mobj.bIsMonster && Mobj != Self)) {UseChance += 30; FoundAllies = True;}
Else If (Mobj.Player) {UseChance += 60; FoundAllies = True;}
}
}
//Since hostile monsters don't attack friendly ones on sight by default, hostile marines can't rely on other fellow hostile monsters, besides other marines.
Else
//Since hostile monsters don't attack friendly ones on sight by default, hostile marines can't rely on other fellow hostile monsters, unless they have the SEEFRIENDLYMONSTERS flag enabled.
Else If (!bFriendly && (Target.Player || Target.bFriendly))
{
If (Mobj Is "SmartMarine" && !IsHostile (Mobj) && Mobj.Distance3DSquared (Target) <= ((EnemyRadius/2)*(EnemyRadius/2)) && IsVisible (Mobj,True))
If (Mobj.bSeeFriendlyMonsters && !IsHostile (Mobj) && Mobj.Distance3DSquared (Target) <= ((EnemyRadius/2)*(EnemyRadius/2)) && IsVisible (Mobj,True))
{
UseChance += 30;
}
Expand Down Expand Up @@ -931,7 +940,7 @@ Mixin Class MarineFunctions
If (Turret && OnTurret)
{
Turret.A_ChangeLinkFlags (False,False);
SmartMarineMGTurret(Turret).Occupied = False;
SmartMarineMGTurret(Turret).Operator = Null;
Warp(Turret,-Turret.Radius*2,flags:WARPF_NOCHECKPOSITION); //Warp the marine at about the same position he is visibly at while on the turret.
Turret.Angle = Angle;
Turret = Null;
Expand Down
2 changes: 2 additions & 0 deletions Marine_Deaths.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Extend Class SmartMarine
Override Void Die (Actor Source, Actor Inflictor, Int DmgFlags, Name MeansOfDeath)
{
LeaveTurret();
LieDown = False;
Height = Default.Height;
Super.Die (Source, Inflictor, DmgFlags, MeansOfDeath);
If (Icon)
Icon.Alpha = 0.0;
Expand Down
6 changes: 3 additions & 3 deletions Marine_OtherActors.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class SM_NoCrouchZone : Actor
//$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.
//$Arg1Tooltip How long (In tics) this zone should prevent marines from crouching after they leave it.
//$Arg1Default 35
//$NotAngled
Radius 16;
Expand Down Expand Up @@ -62,7 +62,7 @@ Class SmartMarinePuff : BulletPuff
{
Default
{
Species "SmartMarine";
Species "Military";
DamageType "MarineRifle";
Decal "BulletChip";
+MThruSpecies;
Expand All @@ -73,7 +73,7 @@ Class SmartMarinePuff : BulletPuff
Super.PostBeginPlay();

If (Target && !Target.bFriendly)
Species = "HostileSmartMarine";
Species = "MilitaryHostile";
}
}

Expand Down
22 changes: 8 additions & 14 deletions Marine_Turret.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Extend Class SmartMarine
If (Target && Target.Health <= 0) Target = Null; //Remove dead targets.

//If the target is in your line of sight, attack it normally, if not, go back to looking.
If (CheckIfTargetInLOS(160,JLOSF_CLOSENOFOV|JLOSF_DEADNOJUMP,6144,128)) A_Chase (Null,"TurretFire",CHF_DONTMOVE|CHF_NODIRECTIONTURN);
If (CheckIfTargetInLOS(160,JLOSF_CLOSENOFOV|JLOSF_DEADNOJUMP,6144*2,128)) A_Chase (Null,"TurretFire",CHF_DONTMOVE|CHF_NODIRECTIONTURN);
Else A_LookEx (0,0,8192,4096,160,"TurretFire");

Return State (Null);
Expand Down Expand Up @@ -99,7 +99,7 @@ Class TurretMarine : Actor
MaxTargetRange 8192;
MinMissileChance 100;
Tag "Marine NPC";
Species "SmartMarine";
Species "Military";
Obituary "%o was turned into swiss cheese by a marines' turret !";
DropItem "Clip";
DropItem "Clip", 128, 2;
Expand Down Expand Up @@ -129,9 +129,9 @@ Class TurretMarine : Actor
Return;

If (!bFriendly)
Species = "HostileSmartMarine";
Species = "MilitaryHostile";
Else
Species = "SmartMarine";
Species = "Military";
}

Override Void OnDestroy ()
Expand Down Expand Up @@ -303,7 +303,6 @@ Class SmartMarineMGTurret : Actor
{
Actor operator;
uint active_frame; // Switches between not active, active and firing.
Bool Occupied; //Only really used when players are using it.
Bool curbarrel; //Makes the gun visibly change firing sprites, yes, it's out of sync from the first person weapon. No, I will not try to sync it.

Default
Expand All @@ -329,7 +328,6 @@ Class SmartMarineMGTurret : Actor
A_StartSound ("Turret/Ready",CHAN_WEAPON); //Because playing the sound from the gun doesn't work.
Translation = Operator.Translation; //So the color of the player on and out of the gun are the same, instead of only the default green.
bSolid = False;
Occupied = True; //Mark the gun as being used.

SmartMarineMGWeapon.Enable(User);
}
Expand All @@ -348,19 +346,15 @@ Class SmartMarineMGTurret : Actor
// Remove operator.
Operator = Null;
bSolid = True; //Become solid again.
Occupied = False; //Unmark it as being used.
Translation = Default.Translation; //Reset the translation.
}

Override Bool Used(Actor User)
{
//If (!Occupied || operator.player.ReadyWeapon Is "SmartMarineMGWeapon")
//{
If(!Operator)
TakeOperator(User);
Else If (User == Operator) // Only allow the operator to exit themselves.
RemoveOperator(User);
//}
If(!Operator)
TakeOperator(User);
Else If (User == Operator) // Only allow the operator to exit themselves.
RemoveOperator(User);

Return False;
}
Expand Down
36 changes: 28 additions & 8 deletions Marine_UserVariables.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,45 @@ Extend Class SmartMarine
A_SetTranslation (String.Format("Marine_%s", User_Color));
}

//$UserDefaultValue 500
Void SetUserVariableDefaults()
{
//The //$UserDefaultValue editor key is buggy, so this code still needs to be used.
If (User_SearchTime == 0) User_SearchTime = 500; //The amount of time the marine tries to chase it's target, after it has died or gone out of sight.
If (User_GrenadeThreshold == 0) User_GrenadeThreshold = 240; //Default threshold that needs to be reached or surpassed, for the marine to throw a grenade.
If (User_RetreatAttempts == 0) User_RetreatAttempts = 10; //Default amount of attempts the marine makes to run for cover to reload.
If (User_AlertRange == 0) User_AlertRange = 384; //Default range in which marines alert each other of enemies.
If (User_EnemyAlertHearingRange == 0) User_EnemyAlertHearingRange = 1024; //Default range in which marines can hear the alerts of enemy marines.
If (User_DodgeRange == 0) User_DodgeRange = 384; //Default range in which marines dodge projectiles.
If (User_TurretThreshold == 0) User_TurretThreshold = 100; //Default chance for the marine to use a turret.
If (User_FearDistance == 0) User_FearDistance = 2048; //The default distance the marines keeps from powerful enemies.
}

Void HandleRandomPersonalityMidGame()
{
If (User_RandomPersonality)
{
If (!User_SearchTime) User_SearchTime = 500*FRandom (-0.6,3.0);
If (!User_GrenadeThreshold) User_GrenadeThreshold = 240*FRandom (-0.75,2.0);
If (!User_RetreatAttempts) User_RetreatAttempts = Random (7,15);
If (!User_FearDistance) User_FearDistance = 2048*FRandom (0.75,2.0);
If (!User_TurretThreshold) User_TurretThreshold = 100*Frandom (0.5,1.5);
If (!User_Color || User_Color ~== "") User_Color = "Random";
User_RandomPersonality = False;
}
}

Int User_SearchTime;
//$UserDefaultValue 240
Int User_GrenadeThreshold;
//$UserDefaultValue 10
Int User_RetreatAttempts;
//$UserDefaultValue 100
Int User_TurretThreshold;
//$UserDefaultValue 384
Double User_AlertRange;
//$UserDefaultValue 1024
Double User_EnemyAlertHearingRange;
//$UserDefaultValue 2048
Double User_FearDistance;
//$UserDefaultValue 384
Double User_DodgeRange;
Bool User_DisobeyCommands;
Bool User_NoReload;
Bool User_NoCover;
Bool User_RandomPersonality;
Bool User_NoRifleDrop;
String User_Color;
String User_SquadName;
Expand Down
Binary file added Sprites/Lying down/MARDA1.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/Lying down/MARDA2A8.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/Lying down/MARDA3A7.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/Lying down/MARDA4A6.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/Lying down/MARDA5.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/Lying down/MARDB1.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/Lying down/MARDB2B8.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/Lying down/MARDB3B7.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/Lying down/MARDB4B6.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/Lying down/MARDB5.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 9a1d2d3

Please sign in to comment.