From 7bb506fe036c7bc457e91ed4d2be67941353c99d Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Mon, 20 Jul 2026 22:09:45 +0200 Subject: [PATCH 1/2] rename new Npc metod to start with try when returning bool TryMethod --- EXILED/Exiled.API/Features/Npc.cs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/EXILED/Exiled.API/Features/Npc.cs b/EXILED/Exiled.API/Features/Npc.cs index a52cee705..dea683039 100644 --- a/EXILED/Exiled.API/Features/Npc.cs +++ b/EXILED/Exiled.API/Features/Npc.cs @@ -442,12 +442,10 @@ public bool TryLookAtDirection(Vector3 dir, float lerp = 1) /// /// The strength used to jump. Null will choose the default one. /// True if successful. - public bool Jump(float? jumpStrength = null) + public bool TryJump(float? jumpStrength = null) { if (Role is not FpcRole fpcRole) - { return false; - } fpcRole.Jump(jumpStrength); return true; @@ -458,16 +456,14 @@ public bool Jump(float? jumpStrength = null) /// /// The kind of candy to eat. /// True if successful. - public bool EatCandy(CandyKindID candyKind) + public bool TryEatCandy(CandyKindID candyKind) { foreach(Item? item in Items) { if (item is not Scp330 scp330) - { continue; - } - return EatCandy(scp330, candyKind); + return TryEatCandy(scp330, candyKind); } return false; @@ -479,7 +475,7 @@ public bool EatCandy(CandyKindID candyKind) /// The bag. /// The kind of candy to eat. /// True if successful. - public bool EatCandy(Scp330 from, CandyKindID candyKind) + public bool TryEatCandy(Scp330 from, CandyKindID candyKind) { for (int i = 0; i < from.Candies.Count; i++) { @@ -535,7 +531,7 @@ public void CancelUseItem(Item item) /// /// Specifies if the shooting is to be held. /// True if successful. - public bool Shoot(bool hold) => + public bool TryShoot(bool hold) => RunItemAction(CurrentItem, ActionName.Shoot, hold); /// @@ -543,7 +539,7 @@ public bool Shoot(bool hold) => /// /// Specifies if the reloading is to be held. /// True if successful. - public bool Reload(bool hold) => + public bool TryReload(bool hold) => RunItemAction(CurrentItem, ActionName.Reload, hold); /// @@ -551,7 +547,7 @@ public bool Reload(bool hold) => /// /// Specifies if the zooming is to be held. /// True if successful. - public bool Zoom(bool hold) => + public bool TryZoom(bool hold) => RunItemAction(CurrentItem, ActionName.Zoom, hold); /// @@ -561,7 +557,7 @@ public bool Zoom(bool hold) => /// The name of action to force. /// Specifies if the action is to be held. /// True if successful. - public bool RunItemAction(Item item, ActionName name, bool hold = true) => + public bool TryRunItemAction(Item item, ActionName name, bool hold = true) => RunAction(item?.DummyEmulator, name, hold); /// @@ -570,7 +566,7 @@ public bool RunItemAction(Item item, ActionName name, bool hold = true) => /// The to stop action for. /// The name of action to stop. /// True if successful. - public bool StopItemAction(Item item, ActionName name) => + public bool TryStopItemAction(Item item, ActionName name) => StopAction(item?.DummyEmulator, name); /// @@ -590,7 +586,7 @@ public bool IsBeingDone(Item item, ActionName name) => /// Specifies if the action is to be held. /// . /// True if successful. - public bool RunSubroutineAction(T subroutine, ActionName name, bool hold = true) + public bool TryRunSubroutineAction(T subroutine, ActionName name, bool hold = true) where T : SubroutineBase => RunAction(subroutine?.DummyEmulator, name, hold); @@ -601,7 +597,7 @@ public bool RunSubroutineAction(T subroutine, ActionName name, bool hold = tr /// The name of action to stop. /// . /// True if successful. - public bool StopSubroutineAction(T subroutine, ActionName name) + public bool TryStopSubroutineAction(T subroutine, ActionName name) where T : SubroutineBase => StopAction(subroutine?.DummyEmulator, name); @@ -623,7 +619,7 @@ public bool IsBeingDone(T subroutine, ActionName name) /// The name of action to force. /// Specifies if the action is to be held. /// True if successful. - public bool RunAction(DummyKeyEmulator? emulator, ActionName name, bool hold) + public bool TryRunAction(DummyKeyEmulator? emulator, ActionName name, bool hold) { if (emulator == null) return false; @@ -638,7 +634,7 @@ public bool RunAction(DummyKeyEmulator? emulator, ActionName name, bool hold) /// The to stop action for. /// The name of action to stop. /// True if successful. - public bool StopAction(DummyKeyEmulator? emulator, ActionName name) + public bool TryStopAction(DummyKeyEmulator? emulator, ActionName name) { if (emulator == null) return false; From 6d021e939b05f890832796a585d5d3479a0e2b97 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Mon, 20 Jul 2026 23:39:41 +0200 Subject: [PATCH 2/2] fix: error --- EXILED/Exiled.API/Features/Npc.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/EXILED/Exiled.API/Features/Npc.cs b/EXILED/Exiled.API/Features/Npc.cs index dea683039..fac23db4f 100644 --- a/EXILED/Exiled.API/Features/Npc.cs +++ b/EXILED/Exiled.API/Features/Npc.cs @@ -532,7 +532,7 @@ public void CancelUseItem(Item item) /// Specifies if the shooting is to be held. /// True if successful. public bool TryShoot(bool hold) => - RunItemAction(CurrentItem, ActionName.Shoot, hold); + TryRunItemAction(CurrentItem, ActionName.Shoot, hold); /// /// Forces the Npc to reload. @@ -540,7 +540,7 @@ public bool TryShoot(bool hold) => /// Specifies if the reloading is to be held. /// True if successful. public bool TryReload(bool hold) => - RunItemAction(CurrentItem, ActionName.Reload, hold); + TryRunItemAction(CurrentItem, ActionName.Reload, hold); /// /// Forces the Npc to zoom. @@ -548,7 +548,7 @@ public bool TryReload(bool hold) => /// Specifies if the zooming is to be held. /// True if successful. public bool TryZoom(bool hold) => - RunItemAction(CurrentItem, ActionName.Zoom, hold); + TryRunItemAction(CurrentItem, ActionName.Zoom, hold); /// /// Forces the Npc to run generic action with item. @@ -558,7 +558,7 @@ public bool TryZoom(bool hold) => /// Specifies if the action is to be held. /// True if successful. public bool TryRunItemAction(Item item, ActionName name, bool hold = true) => - RunAction(item?.DummyEmulator, name, hold); + TryRunAction(item?.DummyEmulator, name, hold); /// /// Forces the Npc to stop generic action with item. @@ -567,7 +567,7 @@ public bool TryRunItemAction(Item item, ActionName name, bool hold = true) => /// The name of action to stop. /// True if successful. public bool TryStopItemAction(Item item, ActionName name) => - StopAction(item?.DummyEmulator, name); + TryStopAction(item?.DummyEmulator, name); /// /// Checks if certain action is currently active. @@ -588,7 +588,7 @@ public bool IsBeingDone(Item item, ActionName name) => /// True if successful. public bool TryRunSubroutineAction(T subroutine, ActionName name, bool hold = true) where T : SubroutineBase => - RunAction(subroutine?.DummyEmulator, name, hold); + TryRunAction(subroutine?.DummyEmulator, name, hold); /// /// Forces the Npc to stop generic action with subroutine. @@ -599,7 +599,7 @@ public bool TryRunSubroutineAction(T subroutine, ActionName name, bool hold = /// True if successful. public bool TryStopSubroutineAction(T subroutine, ActionName name) where T : SubroutineBase => - StopAction(subroutine?.DummyEmulator, name); + TryStopAction(subroutine?.DummyEmulator, name); /// /// Checks if certain action is currently active.