public static void StallForTime(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, uint disabler, float delay, NWLocation loc) { delay -= 2.0f; if (delay <= 0.5f) { DisableResult result = IsDisableSuccessful(s, trap, trap.DisarmDC, disabler); if (result == DisableResult.Success) { RemoveTrap(s, trap); s.SendMessageToPC(disabler, "<c=#98FFFF>This trap is now gone, and needs no more work from you.</c>"); return; } else if (result == DisableResult.CriticalFailure) { trap.Disabler = 0; trap.Helpers = new List <uint>(); trap.TotalHelp = 0; TrapTrigger.Fire(s, trap, disabler); s.SendMessageToPC(disabler, "<c=#98FFFF>Your disable attempt has backfired, causing you to cease work.</c>"); return; } else { trap.Disabler = 0; trap.Helpers = new List <uint>(); trap.TotalHelp = 0; s.SendMessageToPC(disabler, "<c=#98FFFF>Your disable attempt has failed. You may retry if you like.</c>"); return; } } else { Vector3 oldPos = s.GetPositionFromLocation(loc); NWLocation newLoc = s.GetLocation(disabler); Vector3 newPos = s.GetPosition(disabler); if (Math.Abs(oldPos.x - newPos.x) > DisarmMovementThreshhold || Math.Abs(oldPos.y - newPos.y) > DisarmMovementThreshhold) { // The disabler has moved. Interpret as canceling. trap.Disabler = 0; trap.Helpers = new List <uint>(); trap.TotalHelp = 0; s.SendMessageToPC(disabler, "<c=#98FFFF>You stop working on the trap, due to having moved from your workspace.</c>"); return; } int action = s.GetCurrentAction(disabler); if (action == ACTION_ANIMALEMPATHY || action == ACTION_ATTACKOBJECT || action == ACTION_CASTSPELL || action == ACTION_CLOSEDOOR || action == ACTION_COUNTERSPELL || action == ACTION_DIALOGOBJECT || action == ACTION_DROPITEM || action == ACTION_EXAMINETRAP || action == ACTION_FLAGTRAP || action == ACTION_FOLLOW || action == ACTION_HEAL || action == ACTION_ITEMCASTSPELL || action == ACTION_KIDAMAGE || action == ACTION_LOCK || action == ACTION_MOVETOPOINT || action == ACTION_OPENDOOR || action == ACTION_OPENLOCK || action == ACTION_PICKPOCKET || action == ACTION_PICKUPITEM || action == ACTION_RANDOMWALK || action == ACTION_RECOVERTRAP || action == ACTION_REST || action == ACTION_SETTRAP || action == ACTION_SIT || action == ACTION_SMITEGOOD || action == ACTION_TAUNT || action == ACTION_USEOBJECT) { // Disabler isn't working on the trap any more. Abort. trap.Disabler = 0; trap.Helpers = new List <uint>(); trap.TotalHelp = 0; s.SendMessageToPC(disabler, "<c=#98FFFF>You stop working on the trap, due to having begun another task.</c>"); return; } s.SendMessageToPC(disabler, "<c=#98FFFF>You continue work on the trap...</c>"); s.PlayAnimation(ANIMATION_FIREFORGET_KNEELFIDGET, 1.0f, 2.0f); s.DelayCommand(2.0f, delegate { StallForTime(s, trap, disabler, delay, newLoc); }); } }