aboutsummaryrefslogtreecommitdiffstats
path: root/code/phase
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2023-07-29 02:55:08 +0100
committerLeonardo Bishop <me@leonardobishop.com>2023-07-29 02:55:08 +0100
commit95b2259eb4d7362b137d26037f8312b3d80f0244 (patch)
tree430f4b61bba71e93802d0edaf61f97a162627666 /code/phase
parent743c93752eccb4d243c5869ec82dceb1c443acac (diff)
Add fall damage
Diffstat (limited to 'code/phase')
-rw-r--r--code/phase/PlayPhase.cs16
-rw-r--r--code/phase/WaitPhase.cs15
2 files changed, 21 insertions, 10 deletions
diff --git a/code/phase/PlayPhase.cs b/code/phase/PlayPhase.cs
index b6210b3..8b4ff7f 100644
--- a/code/phase/PlayPhase.cs
+++ b/code/phase/PlayPhase.cs
@@ -98,18 +98,24 @@ public class PlayPhase : BasePhase
[MurderEvent.Kill]
public void OnKill(Entity killer, Entity victim)
{
- if (killer == null || killer is not Player || victim == null || victim is not Player )
+ if (killer is not Player && victim is not Player )
{
return;
}
Player victimPlayer = (Player)victim;
- Player killerPlayer = (Player)killer;
-
Team victimTeam = victimPlayer.CurrentTeam;
- Team killerTeam = killerPlayer.CurrentTeam;
-
victimPlayer.CurrentTeam = Team.Spectator;
+ if (killer == null)
+ {
+ Log.Info( victimPlayer + " died mysteriously" );
+ return;
+ }
+
+
+ Player killerPlayer = (Player)killer;
+ Team killerTeam = killerPlayer.CurrentTeam;
+
Log.Info( victimPlayer + " died to " + killerPlayer );
if (victimTeam != Team.Murderer && killerTeam != Team.Murderer)
diff --git a/code/phase/WaitPhase.cs b/code/phase/WaitPhase.cs
index 9eab094..6014467 100644
--- a/code/phase/WaitPhase.cs
+++ b/code/phase/WaitPhase.cs
@@ -52,21 +52,26 @@ public class WaitPhase : BasePhase
pawn.Transform = tx;
}
- pawn.CurrentTeam = Team.Bystander;
pawn.Spawn();
- pawn.Respawn();
+ RespawnPlayer( pawn );
} else
{
var pawn = (Player)client.Pawn;
- if (pawn.LifeState == LifeState.Dead)
+ if (pawn.LifeState == LifeState.Dead && pawn.TimeSinceDeath > 3)
{
- pawn.CurrentTeam = Team.Bystander;
- pawn.Respawn();
+ RespawnPlayer( pawn );
}
}
}
}
+ private void RespawnPlayer(Player pawn)
+ {
+ pawn.CurrentTeam = Team.Spectator;
+ pawn.DressFromClient( pawn.Client );
+ pawn.Respawn();
+ }
+
public override void HandleClientJoin( ClientJoinedEvent e )
{