Skip to content

Commit

Permalink
Changed handling of damaged marine spawning.
Browse files Browse the repository at this point in the history
- Changed how damaging marines as they exit vehicles works to do so in a manner that allows their armor to work properly.
- Slightly increased the MBT's MaxStepHeight to no avail.
  • Loading branch information
inkoalawetrust committed Nov 23, 2024
1 parent 64aa409 commit 13cc97d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ZScript/Vehicles/APC/APC.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ Class MVP_APC : MVP_BaseVehicle
Actor Marine;
Marine = SpawnMarine ((-112, FRandom (10,-10),0));
Marine.SetOrigin ((Marine.Pos.X,Marine.Pos.Y,Marine.Pos.Z+48),False);
Marine.DamageMobj (Target,Target,Random (24,96),DeathType,DMG_NO_PAIN|DMG_THRUSTLESS); //Harm the marine by a random amount, the source being the APC's killer.
MVP_NPCDamageAfterExit (Marine,Target,Random (24,96),DeathType,DMG_NO_PAIN|DMG_THRUSTLESS);//Harm the marine by a random amount, the source being the APC's killer.
If (User_MarineTID != 0) Marine.ChangeTID (User_MarineTID);
MVP_NPCDropoffMove ((-120, 0,48),Marine);
User_MarineAmount--;
Expand Down
18 changes: 18 additions & 0 deletions ZScript/Vehicles/Base/Base.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,22 @@ Class MVP_HazardZone : KAI_MixinActor
KAIS A 4 Bright;
Loop;
}*/
}

/*HACK: This is here to damage marines that exit a destroyed vehicle after 1 tic instead of immediately, because that
otherwise won't work with the smart marines wearing armor. If the marines' armor code is in PostBeginPlay(), he
user_armor variable they have will work. But they will be damaged before they get their armor. If I put that code in
BeginPlay(), they can put on the armor immediately after spawning, but then user_armor doesn't work.*/
Class MVP_DamageOnExit : Inventory
{
Override Void DoEffect ()
{
Super.DoEffect();

If (GetAge() >= 1 && Owner)
{
Owner.DamageMobj (Target,Target,Health,DeathType,Threshold);
GoAwayAndDie();
}
}
}
20 changes: 20 additions & 0 deletions ZScript/Vehicles/Base/CommonFunctions.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,26 @@ Mixin Class MVP_MarineFunctions

Return True;
}

//HACK: Damage the actor drop with the specified parameters after one tic.
Bool MVP_NPCDamageAfterExit (Actor Who, Actor Inflictor, Int Damage, Name DamageType, Int DmgFlags = DMG_NO_PAIN|DMG_THRUSTLESS)
{
If (!Who)
Return False;

Let Harm = Who.GiveInventoryType("MVP_DamageOnExit");

If (Harm)
{console.printf ("passed damage token");
Harm.Target = Inflictor;
Harm.Health = Damage;
Harm.DeathType = DamageType;
Harm.Threshold = DmgFlags;
Return True;
}

Return False;
}
}

//A generic check used to find where a projectile will roughly land, to place a warning zone for marines there.
Expand Down
3 changes: 2 additions & 1 deletion ZScript/Vehicles/MBT/MBT.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Class MVP_MBT : MVP_BaseVehicle
DeathHeight 61;
MeleeRange 88;
MaxSlopeSteepness 0.65;
MaxStepHeight 35;
Mass 30000;
FriendlySeeBlocks 128;
MaxTargetRange 16384;
Expand Down Expand Up @@ -1807,7 +1808,7 @@ Class MVP_MBTTurret : MVP_BaseTurret
{
Actor Marine; //Gunner comes out the left hatch.
Marine = SpawnMarine (PosOfs);
Marine.DamageMobj (Target,Target,Random (16,48),DeathType,DMG_NO_PAIN|DMG_THRUSTLESS); //Harm the marine by a random amount, the source being the MBT's killer.
MVP_NPCDamageAfterExit (Marine,Target,Random (16,48),DeathType,DMG_NO_PAIN|DMG_THRUSTLESS); //Harm the marine by a random amount, the source being the MBT's killer.
//SpawnItemEx velocity code.
Marine.Vel.X = XVel * Cos (Angle) + YVel * Sin (Angle);
Marine.Vel.Y = XVel * Sin (Angle) - YVel * Cos (Angle);
Expand Down

0 comments on commit 13cc97d

Please sign in to comment.