Skip to content

Commit

Permalink
random dnr fix for real this time final final v2 final
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkmajia committed Nov 16, 2024
1 parent 45c337b commit 5635773
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions Content.Server/Medical/DefibrillatorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,8 @@ public bool TryStartZap(EntityUid uid, EntityUid target, EntityUid user, Defibri
});
}

public void Zap(EntityUid uid,
EntityUid target,
EntityUid user,
DefibrillatorComponent? component = null,
MobStateComponent? mob = null,
MobThresholdsComponent? thresholds = null)
public void Zap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorComponent? component = null, MobStateComponent? mob = null, MobThresholdsComponent? thresholds = null)
{
var revive = true;
if (!Resolve(uid, ref component) || !Resolve(target, ref mob, ref thresholds, false))
return;

Expand Down Expand Up @@ -167,37 +161,33 @@ public void Zap(EntityUid uid,
Loc.GetString("defibrillator-rotten"),
InGameICChatType.Speak,
true);
revive = false;
return;
}

if (HasComp<UnrevivableComponent>(target) && revive)
if (HasComp<UnrevivableComponent>(target))
{
_chatManager.TrySendInGameICMessage(uid,
Loc.GetString("defibrillator-unrevivable"),
InGameICChatType.Speak,
true);
revive = false;
return;
}

if (revive && HasComp<RandomUnrevivableComponent>(target))
if (HasComp<RandomUnrevivableComponent>(target))
{
var dnrComponent = Comp<RandomUnrevivableComponent>(target);

if (dnrComponent.Chance > _random.NextDouble())
if (dnrComponent.Chance < _random.NextDouble())
{
_chatManager.TrySendInGameICMessage(uid,
Loc.GetString("defibrillator-unrevivable"),
InGameICChatType.Speak,
true);

dnrComponent.Chance = 0.0f;
revive = false;
_chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-unrevivable"), InGameICChatType.Speak, true);
dnrComponent.Chance = 0f;
AddComp<UnrevivableComponent>(target);
return;
}
else
{
dnrComponent.Chance -= 0.1f;
}
}

if (!revive)
{
return;
}

if (_mobState.IsDead(target, mob))
Expand Down

0 comments on commit 5635773

Please sign in to comment.