ACR_Traps.TrapDisable.Disable C# (CSharp) Метод

Disable() публичный статический Метод

public static Disable ( CLRScriptBase s, ALFA trap, uint disabler ) : void
s CLRScriptFramework.CLRScriptBase
trap ALFA
disabler uint
Результат void
        public static void Disable(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, uint disabler)
        {
            if (trap.Disabler == 0)
            {
                // no one is currently working on this trap.
                s.SendMessageToPC(disabler, "<c=#98FFFF>You begin to disable the trap...</c>");
                trap.Disabler = disabler;
                trap.Helpers = new List<uint>();
            }
            else
            {
                if (trap.Disabler == disabler)
                {
                    s.SendMessageToPC(disabler, "<c=#98FFFF>Error: You are already disabling this device.</c>");
                }
                else if (trap.Helpers.Contains(disabler))
                {
                    s.SendMessageToPC(disabler, "<c=#98FFFF>Disable Device: * Failure * You have already given aid to this attempt.</c>");
                    return;
                }
                else
                {
                    trap.Helpers.Add(disabler);
                    if (IsDisableSuccessful(s, trap, 10, disabler) == DisableResult.Success)
                    {
                        s.SendMessageToPC(disabler, String.Format("<c=#98FFFF>Disable Device: You grant {0} useful assistance with the trap.</c>", s.GetName(trap.Disabler)));
                        trap.TotalHelp += 2;
                        return;
                    }
                    else
                    {
                        s.SendMessageToPC(disabler, String.Format("<c=#98FFFF>Disable Device: You are unable to grant {0} useful assistance with the trap.</c>", s.GetName(trap.Disabler)));
                        return;
                    }
                }
            }
            if (s.GetIsDM(disabler) == TRUE && s.GetIsDMPossessed(disabler) == FALSE)
            {
                RemoveTrap(s, trap);
                s.SendMessageToPC(disabler, String.Format("<c=#98FFFF>Removing trap {0}</c>", trap.Tag));
                return;
            }
            float neededTime = s.d4(2) * 6.0f;
            NWLocation oldLoc = s.GetLocation(disabler);
            s.DelayCommand(2.0f, delegate { StallForTime(s, trap, disabler, neededTime, oldLoc); });
        }

Usage Example

Пример #1
0
        public Int32 ScriptMain([In] object[] ScriptParameters, [In] Int32 DefaultReturnCode)
        {
            int Value = (int)ScriptParameters[0]; // ScriptParameterTypes[0] is typeof(int)

            TrapEvent currentEvent = (TrapEvent)ScriptParameters[0];

            switch (currentEvent)
            {
            case TrapEvent.CreateGeneric:
            {
                NWLocation loc    = Location((uint)ScriptParameters[4], Vector((float)ScriptParameters[1], (float)ScriptParameters[2], (float)ScriptParameters[3]), 0.0f);
                string     resRef = (string)ScriptParameters[20];
                if (resRef == "")
                {
                    TriggerArea triggerArea      = (TriggerArea)ScriptParameters[5];
                    int         effectArea       = (int)ScriptParameters[6];
                    float       effectSize       = (float)ScriptParameters[7];
                    int         damageType       = (int)ScriptParameters[8];
                    int         diceNumber       = (int)ScriptParameters[9];
                    int         diceType         = (int)ScriptParameters[10];
                    int         saveDC           = (int)ScriptParameters[11];
                    int         attackBonus      = (int)ScriptParameters[12];
                    int         numberOfShots    = (int)ScriptParameters[13];
                    uint        trapOrigin       = (uint)ScriptParameters[14];
                    int         targetAlignment  = (int)ScriptParameters[15];
                    int         targetRace       = (int)ScriptParameters[16];
                    int         minimumToTrigger = (int)ScriptParameters[17];
                    int         detectDC         = (int)ScriptParameters[18];
                    int         disarmDC         = (int)ScriptParameters[19];
                    CreateTraps.GenericDamage(this, loc, triggerArea, effectArea, effectSize, damageType, diceNumber, diceType, saveDC, attackBonus, numberOfShots, trapOrigin, targetAlignment, targetRace, minimumToTrigger, detectDC, disarmDC, "");
                    break;
                }
                else
                {
                    ALFA.Shared.TrapResource trapToSpawn = ALFA.Shared.Modules.InfoStore.ModuleTraps[(string)ScriptParameters[20]];
                    if (trapToSpawn.SpellTrap)
                    {
                        CreateTraps.Spell(this, loc, (TriggerArea)trapToSpawn.TriggerArea, trapToSpawn.SpellId, trapToSpawn.NumberOfShots, trapToSpawn.TrapOrigin, trapToSpawn.TargetAlignment, trapToSpawn.TargetRace, trapToSpawn.MinimumToTrigger, trapToSpawn.DetectDC, trapToSpawn.DisarmDC, trapToSpawn.Description);
                    }
                    else
                    {
                        CreateTraps.GenericDamage(this, loc, (TriggerArea)trapToSpawn.TriggerArea, trapToSpawn.EffectArea, trapToSpawn.EffectSize, trapToSpawn.DamageType, trapToSpawn.DiceNumber, trapToSpawn.DiceType, trapToSpawn.SaveDC, trapToSpawn.AttackBonus, trapToSpawn.NumberOfShots, trapToSpawn.TrapOrigin, trapToSpawn.TargetAlignment, trapToSpawn.TargetRace, trapToSpawn.MinimumToTrigger, trapToSpawn.DetectDC, trapToSpawn.DisarmDC, trapToSpawn.Description);
                    }
                }
                break;
            }

            case TrapEvent.CreateSpell:
            {
                NWLocation  loc              = Location((uint)ScriptParameters[4], Vector((float)ScriptParameters[1], (float)ScriptParameters[2], (float)ScriptParameters[3]), 0.0f);
                TriggerArea triggerArea      = (TriggerArea)ScriptParameters[5];
                int         spellId          = (int)ScriptParameters[8];
                int         numberOfShots    = (int)ScriptParameters[13];
                uint        trapOrigin       = (uint)ScriptParameters[14];
                int         targetAlignment  = (int)ScriptParameters[15];
                int         targetRace       = (int)ScriptParameters[16];
                int         minimumToTrigger = (int)ScriptParameters[17];
                int         detectDC         = (int)ScriptParameters[18];
                int         disarmDC         = (int)ScriptParameters[19];
                CreateTraps.Spell(this, loc, triggerArea, spellId, numberOfShots, trapOrigin, targetAlignment, targetRace, minimumToTrigger, detectDC, disarmDC, "");
                break;
            }

            case TrapEvent.DetectEnter:
            {
                string trapTag = GetTag(OBJECT_SELF);
                if (ALFA.Shared.Modules.InfoStore.SpawnedTrapDetect.Keys.Contains(trapTag))
                {
                    TrapDetect.Enter(this, ALFA.Shared.Modules.InfoStore.SpawnedTrapDetect[trapTag]);
                }
                else
                {
                    uint enteringObject = GetEnteringObject();
                    SendMessageToPC(enteringObject, String.Format("Error: This appears to be a trap detection trigger, but I can not find any trap named {0}", trapTag));
                }
                break;
            }

            case TrapEvent.DetectExit:
            {
                string trapTag        = GetTag(OBJECT_SELF);
                uint   enteringObject = GetEnteringObject();
                if (ALFA.Shared.Modules.InfoStore.SpawnedTrapDetect.Keys.Contains(trapTag))
                {
                    TrapDetect.Exit(this, ALFA.Shared.Modules.InfoStore.SpawnedTrapDetect[trapTag]);
                }
                break;
            }

            case TrapEvent.TriggerEnter:
            {
                string trapTag = GetTag(OBJECT_SELF);
                if (ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers.Keys.Contains(trapTag))
                {
                    TrapTrigger.Enter(this, ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers[trapTag]);
                }
                else
                {
                    uint enteringObject = GetEnteringObject();
                    SendMessageToPC(enteringObject, String.Format("Error: This appears to be a trap firing trigger, but I can not find any trap named {0}", trapTag));
                }
                break;
            }

            case TrapEvent.TriggerExit:
            {
                string trapTag        = GetTag(OBJECT_SELF);
                uint   enteringObject = GetEnteringObject();
                if (ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers.Keys.Contains(trapTag))
                {
                    TrapTrigger.Exit(this, ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers[trapTag]);
                }
                break;
            }

            case TrapEvent.TrapDisarm:
            {
                string trapTag = GetTag(OBJECT_SELF);
                trapTag = trapTag.Substring(0, trapTag.Length - 1);
                uint disabler = GetLastUsedBy();
                if (ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers.Keys.Contains(trapTag))
                {
                    TrapDisable.Disable(this, ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers[trapTag], disabler);
                }
                break;
            }

            case TrapEvent.TrapDespawn:
            {
                string trapTag = GetTag(OBJECT_SELF);
                if (ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers.Keys.Contains(trapTag))
                {
                    TrapDisable.RemoveTrap(this, ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers[trapTag]);
                }
                if (ALFA.Shared.Modules.InfoStore.SpawnedTrapDetect.Keys.Contains(trapTag))
                {
                    TrapDisable.RemoveTrap(this, ALFA.Shared.Modules.InfoStore.SpawnedTrapDetect[trapTag]);
                }
                break;
            }
            }

            return(0);
        }