Skip to content

Commit

Permalink
Marines now wear armor, new user variable, and
Browse files Browse the repository at this point in the history
- Marines now wear actual armor, specifically, they wear the vanilla GreenArmor, so their health has also been lowered down to 100, since they no longer need 120 health to account for their lack of armor.
- Marines now have a User_DefaultOrder variable, that specified if they should be spawned following the player or wandering, more info is in the documentation.
- Significantly buffed the marines' berserk attack, now it does 10 times higher damage than the standard rifle swing, just like the players' berserk attacks.
- Fixed a sprite name conflict with the marines' lying down and death sprites.
- Updated documentation.
  • Loading branch information
inkoalawetrust committed Sep 21, 2022
1 parent 5f1f3d8 commit 8f17c9a
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Document.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ 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_DefaultOrder: Specifies if the marine should follow the player or wander around by default.
- By default, the marine looks for any friendly players in its' line of sight, if there are none, he will wonder by default, if there is one, he will follow them by default.
- The other two options are "follow" and "wander", which are fairly self explanatory.
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.
Expand Down
2 changes: 1 addition & 1 deletion MarineFunctions.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ Mixin Class MarineFunctions

XY_Spread = Angle + BulletSpreadXY;

Actor Puff = LineAttack (XY_Spread,8192,SlopeBullshit,Random (6,10),"HitScan","SmartMarinePuff",LAF_OVERRIDEZ,offsetz:SpawnHeight,0,-6);
Actor Puff = LineAttack (XY_Spread,8192,SlopeBullshit,Random[GunShot] (6,10),"HitScan","SmartMarinePuff",LAF_OVERRIDEZ,offsetz:SpawnHeight,0,-6);

//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.
Expand Down
40 changes: 40 additions & 0 deletions Marine_UserVariables.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,45 @@ Extend Class SmartMarine
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.

If (!bFriendly) Return; //The rest is only relevant to player allies.

Array <PlayerPawn> VisibleFriends;
//Friendly marine with no default order specified.
If (!User_DefaultOrder || User_DefaultOrder ~== "")
{
//This tries to pick a random visible player for the marine to follow, if no friendly players are in sight, the marine will wander instead.
//Find all visible players friendly to you.
For (Int I = 0; I < MAXPLAYERS; I++)
{
If (!PlayerInGame[I]) Continue;

If (IsFriend (Players[I].Mo) && CheckSight (Players[I].Mo, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY))
VisibleFriends.Push (Players[I].Mo);
}

//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;
}
}
Else If (User_DefaultOrder ~== "Follow")
{
CurrentMarineOrder = ORDER_FOLLOW;
}
Else If (User_DefaultOrder ~== "Wander")
{
CurrentMarineOrder = ORDER_WANDER;
bDontFollowPlayers = True;
}
}

Void HandleRandomPersonalityMidGame()
Expand Down Expand Up @@ -61,4 +100,5 @@ Extend Class SmartMarine
String User_Color;
String User_SquadName;
Bool User_Leader;
String User_DefaultOrder;
}
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
18 changes: 9 additions & 9 deletions ZScript.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Class SmartMarine : Actor
//$Title AI Marine
//$Category Marines
//$Sprite MARIC1
Health 120;
Health 100;
GibHealth 20;
Height 56;
DeathHeight 12;
Expand Down Expand Up @@ -66,6 +66,7 @@ Class SmartMarine : Actor
{
Super.PostBeginPlay();

GiveInventory ("GreenArmor",1); //Yep, the marines wear actual armor.
InitializeSquad();
SetUserVariableDefaults();
HandleRandomPersonalityMidGame();
Expand Down Expand Up @@ -434,9 +435,8 @@ Class SmartMarine : Actor
{
//Uses the same RNG as A_Jump's random jump chance, but also only jumps if the marine has no goal. And is ordered to wander around aimlessly.
If (CurrentMarineOrder == ORDER_WANDER && !Goal && Random[pr_cajump](0,256) < 12)
{
Return ResolveState ("StandStill");
}

Return State (Null);
}
Loop;
Expand Down Expand Up @@ -816,15 +816,15 @@ Class SmartMarine : Actor
TNT1 A 0 A_JumpIf (SM_ShouldDodgeProjectile(User_DodgeRange),"Evade");
MARM A 3;
TNT1 A 0 A_JumpIf (CountInv("PowerStrength") > 0,3);
MARM B 8 A_CustomMeleeAttack (Random(4,8),"Marine/Melee","Marine/MeleeMiss",'Melee',False); //Blunt force attack, so no blood.
MARM B 8 A_CustomMeleeAttack (Random[Punch](4,8),"Marine/Melee","Marine/MeleeMiss",'Melee',False); //Blunt force attack, so no blood.
MARM A 0 A_Jump (96,"ChangePosition"); //If you are in melee range of your enemy, you are probably fucked.
Goto See;

MARM B 6 A_CustomMeleeAttack (Random(16,32),"Marine/PowerMelee","Marine/MeleeMiss",'Melee'); //Powerful blunt force attack, so YES blood.
MARM B 6 A_CustomMeleeAttack (Random[Punch](40,80),"Marine/PowerMelee","Marine/MeleeMiss",'Melee'); //Powerful blunt force attack, so YES blood.
MARM A 0 A_Jump (96/2,"ChangePosition"); //If you are in melee range of your enemy with a berserk pack, you are probably not THAT fucked.
Goto See;
RifleBurst:
MARD AB 0 {LieDown = (!Crouching && Random[pr_cajump](0,255) < 32);} //Small chance for the marine to shoot lying down. If not already behind cover. Or in the air.
MAR3 AB 0 {LieDown = (!Crouching && Random[pr_cajump](0,255) < 32);} //Small chance for the marine to shoot lying down. If not already behind cover. Or in the air.
MAR2 A 0 //Run out of sight of the target to reload.
{
If (AmmoUsed > 19)
Expand All @@ -840,7 +840,7 @@ Class SmartMarine : Actor
If (LieDown)
{
Height = 16;
Sprite = GetSpriteIndex ("MARD");
Sprite = GetSpriteIndex ("MAR3");
}
}
MAR2 A 0 //The bullet spread is determined before the shot, so that it can be checked by SM_CantHitTarget(), so the marines won't even shoot their allies by accident.
Expand Down Expand Up @@ -880,7 +880,7 @@ Class SmartMarine : Actor
{
SM_MarineBulletAttack(8); //Shoot down lower than normal, since you are lying down.
Height = 16;
Sprite = GetSpriteIndex ("MARD");
Sprite = GetSpriteIndex ("MAR3");
Frame = 1;
}
Else
Expand Down Expand Up @@ -914,7 +914,7 @@ Class SmartMarine : Actor
If (LieDown)
{
Height = 16;
Sprite = GetSpriteIndex ("MARD");
Sprite = GetSpriteIndex ("MAR3");
}

If (Random[pr_monsterrefire](0,255) < 96)
Expand Down

0 comments on commit 8f17c9a

Please sign in to comment.