66using UnityEngine ;
77using NewMod . Utilities ;
88using MiraAPI . Keybinds ;
9+ using AmongUs . GameOptions ;
10+ using Reactor . Utilities ;
911
1012namespace NewMod . Buttons . Necromancer
1113{
@@ -54,13 +56,25 @@ public class ReviveButton : CustomActionButton
5456 /// </summary>
5557 protected override void OnClick ( )
5658 {
57- SoundManager . Instance . PlaySound ( NewModAsset . ReviveSound ? . LoadAsset ( ) , false , 2f ) ;
58-
5959 var closestBody = Utils . GetClosestBody ( ) ;
60- if ( closestBody != null )
60+ var killedPlayer = GameData . Instance . GetPlayerById ( closestBody . ParentId ) ? . Object ;
61+
62+ var killer = Utils . GetKiller ( killedPlayer ) ;
63+ if ( killer != null && killer . PlayerId == PlayerControl . LocalPlayer . PlayerId )
6164 {
62- Utils . HandleRevive ( PlayerControl . LocalPlayer , closestBody . ParentId , AmongUs . GameOptions . RoleTypes . Impostor , closestBody . TruePosition . x , closestBody . TruePosition . y ) ;
65+ Coroutines . Start ( CoroutinesHelper . CoNotify ( "Heads up: you tried to revive someone you killed, one use has been consumed" ) ) ;
66+ return ;
6367 }
68+
69+ SoundManager . Instance . PlaySound ( NewModAsset . ReviveSound ? . LoadAsset ( ) , false , 2f ) ;
70+
71+ Utils . HandleRevive (
72+ PlayerControl . LocalPlayer ,
73+ closestBody . ParentId ,
74+ RoleTypes . Impostor ,
75+ closestBody . transform . position . x ,
76+ closestBody . transform . position . y
77+ ) ;
6478 }
6579 /// <summary>
6680 /// Determines whether this button is enabled for the role, returning true if the role is <see cref="NecromancerRole"/>.
@@ -78,32 +92,15 @@ public override bool Enabled(RoleBehaviour role)
7892 /// <returns>True if all requirements to use this button are met; otherwise false.</returns>
7993 public override bool CanUse ( )
8094 {
81- bool isTimerDone = Timer <= 0 ;
82- bool hasUsesLeft = UsesLeft > 0 ;
95+ if ( Timer > 0 ) return false ;
96+ if ( UsesLeft <= 0 ) return false ;
97+
8398 var closestBody = Utils . GetClosestBody ( ) ;
84- bool isNearDeadBody = closestBody != null ;
85- bool isFakeBody = isNearDeadBody && PranksterUtilities . IsPranksterBody ( closestBody ) ;
99+ if ( closestBody == null ) return false ;
86100
87- if ( closestBody == null )
88- {
89- return false ;
90- }
101+ if ( PranksterUtilities . IsPranksterBody ( closestBody ) ) return false ;
91102
92- bool wasNotKilledByNecromancer = true ;
93- var deadBody = closestBody . GetComponent < DeadBody > ( ) ;
94- if ( deadBody != null )
95- {
96- var killedPlayer = GameData . Instance . GetPlayerById ( deadBody . ParentId ) ? . Object ;
97- if ( killedPlayer != null )
98- {
99- var killer = Utils . GetKiller ( killedPlayer ) ;
100- if ( killer != null && killer . Data . Role is NecromancerRole )
101- {
102- wasNotKilledByNecromancer = false ;
103- }
104- }
105- }
106- return isTimerDone && hasUsesLeft && isNearDeadBody && wasNotKilledByNecromancer && ! isFakeBody ;
103+ return true ;
107104 }
108105 }
109106}
0 commit comments