Esempio n. 1
0
        private static uint GetNearestTrapEmitter(CLRScriptBase script, NWLocation loc)
        {
            float   nearestDist   = -1.0f;
            uint    nearestObject = CLRScriptBase.OBJECT_INVALID;
            Vector3 trapPos       = script.GetPositionFromLocation(loc);

            foreach (uint obj in script.GetObjectsInArea(script.GetAreaFromLocation(loc)))
            {
                if (script.GetObjectType(obj) == OBJECT_TYPE_PLACEABLE &&
                    (script.GetTag(obj) == "TRAP_EMITTER" ||
                     script.GetTag(obj) == "TRAP_ORIGIN"))
                {
                    Vector3 emitterPos = script.GetPosition(obj);
                    float   newDist    = (trapPos.x - emitterPos.x) * (trapPos.x - emitterPos.x) + (trapPos.y - emitterPos.y) * (trapPos.y - emitterPos.y);
                    if (nearestDist < 0 || nearestDist > newDist)
                    {
                        nearestDist   = newDist;
                        nearestObject = obj;
                    }
                }
            }
            if (script.GetIsObjectValid(nearestObject) == CLRScriptBase.FALSE || nearestDist > 400.0f) // 20 meters; nearestDist is squared to be cheaper
            {
                nearestObject = CLRScriptBase.OBJECT_INVALID;
            }
            return(nearestObject);
        }
        /// <summary>
        /// This routine packages a location object into a string.
        /// </summary>
        /// <param name="Location">Supplies the location to convert.</param>
        /// <returns>The converted string is returned.</returns>
        public string ACR_LocationToString(NWLocation Location)
        {
            Vector3 Position = Script.GetPositionFromLocation(Location);

            return(String.Format(
                       "#A#{0}#X#{1}#Y#{2}#Z#{3}#O#{4}",
                       Script.GetTag(Script.GetAreaFromLocation(Location)),
                       Script.FloatToString(Position.x, 0, 9),
                       Script.FloatToString(Position.y, 0, 9),
                       Script.FloatToString(Position.z, 0, 9),
                       Script.FloatToString(Script.GetFacingFromLocation(Location), 0, 9)));
        }
Esempio n. 3
0
        public static void GenericDamage(CLRScriptBase script, NWLocation location, TriggerArea triggerArea, int effectArea, float effectSize, int damageType, int diceNumber, int diceType, int saveDC, int attackBonus, int numberOfShots, uint trapOrigin, int targetAlignment, int targetRace, int minimumToTrigger, int detectDC, int disarmDC, string description)
        {
            string tag       = uniqueTrapTag();
            string detectTag = tag + detectSuffix();

            script.ApplyEffectAtLocation(DURATION_TYPE_PERMANENT,
                                         script.SupernaturalEffect(script.EffectAreaOfEffect(triggerAreaToAreaOfEffect(triggerArea), "acr_traponenter", "****", "acr_traponexit", tag)),
                                         location,
                                         0.0f);

            script.ApplyEffectAtLocation(DURATION_TYPE_PERMANENT,
                                         script.SupernaturalEffect(script.EffectAreaOfEffect(triggerAreaToDetectArea(triggerArea), "acr_trapdtctenter", "****", "acr_trapdtctexit", detectTag)),
                                         location,
                                         0.0f);

            ALFA.Shared.ActiveTrap createdTrap = new ALFA.Shared.ActiveTrap();
            createdTrap.AreaName         = script.GetName(script.GetAreaFromLocation(location));
            createdTrap.AttackBonus      = attackBonus;
            createdTrap.ChallengeRating  = 0.0f;
            createdTrap.DamageType       = damageType;
            createdTrap.DetectTag        = detectTag;
            createdTrap.DiceNumber       = diceNumber;
            createdTrap.DiceType         = diceType;
            createdTrap.EffectArea       = effectArea;
            createdTrap.EffectSize       = effectSize;
            createdTrap.Location         = location;
            createdTrap.MinimumToTrigger = minimumToTrigger;
            createdTrap.NumberOfShots    = numberOfShots;
            createdTrap.SaveDC           = saveDC;
            createdTrap.SpellTrap        = false;
            createdTrap.Tag             = tag;
            createdTrap.TargetAlignment = targetAlignment;
            createdTrap.TargetRace      = targetRace;
            createdTrap.TrapTriggerVFX  = triggerAreaToTrapVFX(triggerArea);
            createdTrap.DetectDC        = detectDC;
            createdTrap.DisarmDC        = disarmDC;
            createdTrap.Detected        = false;
            createdTrap.Disabler        = 0;
            createdTrap.Helpers         = new List <uint>();
            createdTrap.TotalHelp       = 0;
            createdTrap.IsFiring        = false;
            createdTrap.Description     = description;
            createdTrap.ConfigureDisplayName();
            createdTrap.CalculateCR();

            createdTrap.TrapOrigin = GetNearestTrapEmitter(script, location);

            ALFA.Shared.Modules.InfoStore.SpawnedTrapDetect.Add(detectTag, createdTrap);
            ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers.Add(tag, createdTrap);

            script.SetLocalString(script.GetModule(), "ACR_TRAPS_LAST_TAG", tag);
        }
        public static void GenericDamage(CLRScriptBase script, NWLocation location, TriggerArea triggerArea, int effectArea, float effectSize, int damageType, int diceNumber, int diceType, int saveDC, int attackBonus, int numberOfShots, uint trapOrigin, int targetAlignment, int targetRace, int minimumToTrigger, int detectDC, int disarmDC, string description)
        {
            string tag = uniqueTrapTag();
            string detectTag = tag + detectSuffix();
            
            script.ApplyEffectAtLocation(DURATION_TYPE_PERMANENT,
                script.SupernaturalEffect(script.EffectAreaOfEffect(triggerAreaToAreaOfEffect(triggerArea), "acr_traponenter", "****", "acr_traponexit", tag)),
                location,
                0.0f);

            script.ApplyEffectAtLocation(DURATION_TYPE_PERMANENT,
                script.SupernaturalEffect(script.EffectAreaOfEffect(triggerAreaToDetectArea(triggerArea), "acr_trapdtctenter", "****", "acr_trapdtctexit", detectTag)),
                location,
                0.0f);

            ALFA.Shared.ActiveTrap createdTrap = new ALFA.Shared.ActiveTrap();
            createdTrap.AreaName = script.GetName(script.GetAreaFromLocation(location));
            createdTrap.AttackBonus = attackBonus;
            createdTrap.ChallengeRating = 0.0f;
            createdTrap.DamageType = damageType;
            createdTrap.DetectTag = detectTag;
            createdTrap.DiceNumber = diceNumber;
            createdTrap.DiceType = diceType;
            createdTrap.EffectArea = effectArea;
            createdTrap.EffectSize = effectSize;
            createdTrap.Location = location;
            createdTrap.MinimumToTrigger = minimumToTrigger;
            createdTrap.NumberOfShots = numberOfShots;
            createdTrap.SaveDC = saveDC;
            createdTrap.SpellTrap = false;
            createdTrap.Tag = tag;
            createdTrap.TargetAlignment = targetAlignment;
            createdTrap.TargetRace = targetRace;
            createdTrap.TrapTriggerVFX = triggerAreaToTrapVFX(triggerArea);
            createdTrap.DetectDC = detectDC;
            createdTrap.DisarmDC = disarmDC;
            createdTrap.Detected = false;
            createdTrap.Disabler = 0;
            createdTrap.Helpers = new List<uint>();
            createdTrap.TotalHelp = 0;
            createdTrap.IsFiring = false;
            createdTrap.Description = description;
            createdTrap.ConfigureDisplayName();
            createdTrap.CalculateCR();

            createdTrap.TrapOrigin = GetNearestTrapEmitter(script, location);

            ALFA.Shared.Modules.InfoStore.SpawnedTrapDetect.Add(detectTag, createdTrap);
            ALFA.Shared.Modules.InfoStore.SpawnedTrapTriggers.Add(tag, createdTrap);

            script.SetLocalString(script.GetModule(), "ACR_TRAPS_LAST_TAG", tag);
        }
        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); });
        }
        public static void JumpToArea(CLRScriptBase script, User currentUser)
        {
            uint currentArea = script.GetArea(currentUser.Id);

            if (!ALFA.Shared.Modules.InfoStore.ActiveAreas.Keys.Contains(currentUser.Id))
            {
            }

            // If this is an adjacent area, jump the DM to one of the ATs connecting the areas.
            foreach (ALFA.Shared.ActiveTransition exitTranstion in ALFA.Shared.Modules.InfoStore.ActiveAreas[currentArea].ExitTransitions.Keys)
            {
                if (exitTranstion.AreaTarget.Id == currentUser.FocusedArea)
                {
                    script.JumpToLocation(script.GetLocation(exitTranstion.Target));
                    return;
                }
            }

            // If these aren't adjacent areas, grab an AT if we can find one.
            if (ALFA.Shared.Modules.InfoStore.ActiveAreas[currentUser.FocusedArea].ExitTransitions.Count > 0)
            {
                foreach (ALFA.Shared.ActiveTransition enterTransition in ALFA.Shared.Modules.InfoStore.ActiveAreas[currentUser.FocusedArea].ExitTransitions.Keys)
                {
                    script.JumpToLocation(script.GetLocation(enterTransition.Id));
                    return;
                }
            }

            // If we can't find one, just try the middle of the area.
            float      x   = script.GetAreaSize(AREA_WIDTH, currentUser.FocusedArea) / 2;
            float      y   = script.GetAreaSize(AREA_HEIGHT, currentUser.FocusedArea) / 2;
            float      z   = 0.0f;
            NWLocation loc = script.Location(currentUser.FocusedArea, script.Vector(x, y, z), 0.0f);

            script.JumpToLocation(loc);
        }
 public Int32 GetSurfaceMaterialsAtLocation(NWLocation lLocation)
 {
     return ScriptHost.ExecuteActionService_1034_1_GetSurfaceMaterialsAtLocation(lLocation);
 }
 public UInt32 CreateTrapAtLocation(Int32 nTrapType, NWLocation lLocation, float fSize, String sTag, Int32 nFaction, String sOnDisarmScript, String sOnTrapTriggeredScript)
 {
     return ScriptHost.ExecuteActionService_968_7_CreateTrapAtLocation(nTrapType, lLocation, (Single)fSize, sTag, nFaction, sOnDisarmScript, sOnTrapTriggeredScript);
 }
 public NWLocation CalcPointAwayFromPoint(NWLocation lPoint, NWLocation lAwayFromPoint, float fDistance, float fAngularVariance, Int32 bComputeDistFromStart)
 {
     return ScriptHost.ExecuteActionService_874_5_CalcPointAwayFromPoint(lPoint, lAwayFromPoint, (Single)fDistance, (Single)fAngularVariance, bComputeDistFromStart);
 }
 public void SpawnItemProjectile(UInt32 oSource, UInt32 oTaget, NWLocation lSource, NWLocation lTarget, Int32 nBaseItemID, Int32 nProjectilePathType, Int32 nAttackType, Int32 nDamageTypeFlag)
 {
     ScriptHost.ExecuteActionService_837_8_SpawnItemProjectile(oSource, oTaget, lSource, lTarget, nBaseItemID, nProjectilePathType, nAttackType, nDamageTypeFlag);
 }
 public UInt32 SpawnRosterMember(String sRosterName, NWLocation lLocation)
 {
     return ScriptHost.ExecuteActionService_830_2_SpawnRosterMember(sRosterName, lLocation);
 }
 public UInt32 CopyObject(UInt32 oSource, NWLocation locLocation, UInt32 oOwner, String sNewTag)
 {
     return ScriptHost.ExecuteActionService_600_4_CopyObject(oSource, locLocation, oOwner, sNewTag);
 }
Esempio n. 13
0
        public static uint _SpawnObject(string sResRef, int nObjectType, uint oWP, NWLocation lLoc, int nFlags, int nAlternate, CLRScriptBase s)
        {
            // if the object is not being spawned at it's waypoint location, we need to make sure
            // the actual spawn-in location isn't violating the "in PC sight" guidelines.
            if ((nAlternate != CLRScriptBase.FALSE) && ((nFlags & _SPAWN_FLAGS_IN_PC_SIGHT) == 0))
            {
                uint oNeighbor = s.GetNearestCreatureToLocation(CLRScriptBase.CREATURE_TYPE_PLAYER_CHAR, CLRScriptBase.PLAYER_CHAR_IS_PC, lLoc, 1, -1, -1, -1, -1);
                if (s.GetIsObjectValid(oNeighbor) == CLRScriptBase.FALSE && (s.GetDistanceBetweenLocations(lLoc, s.GetLocation(oNeighbor)) <= PC_PERCEPTION_RANGE))
                { // ACR_GetPCVisualRange() )) {
                    return(CLRScriptBase.OBJECT_INVALID);
                }
                if (GetPrespawnPrediction(s) == CLRScriptBase.FALSE)
                {
                    uint oTestWP   = s.GetNearestObjectToLocation(CLRScriptBase.OBJECT_TYPE_WAYPOINT, lLoc, 1);
                    int  nWP_Index = 1;
                    while ((oTestWP != CLRScriptBase.OBJECT_INVALID) && (s.GetDistanceBetweenLocations(lLoc, s.GetLocation(oTestWP)) <= PC_PERCEPTION_RANGE))
                    { // ACR_GetPC_VisualRange() )) {
                        if (s.GetTag(oTestWP) == "ACR_SA_WP")
                        {
                            return(CLRScriptBase.OBJECT_INVALID);
                        }
                        else
                        {
                            nWP_Index = nWP_Index + 1;
                            oTestWP   = s.GetNearestObjectToLocation(CLRScriptBase.OBJECT_TYPE_WAYPOINT, lLoc, nWP_Index);
                        }
                    }
                }
            }

            uint oSpawned = s.CreateObject(nObjectType, sResRef, lLoc, nFlags & _SPAWN_FLAGS_WITH_ANIMATION, "");

            // Check to make sure it spawned ok, print an error and exit if not.
            if (s.GetIsObjectValid(oSpawned) == CLRScriptBase.FALSE)
            {
                return(CLRScriptBase.OBJECT_INVALID);
            }

            // If it should be in stealth mode, place it there.
            if ((nFlags & _SPAWN_IN_STEALTH) == _SPAWN_IN_STEALTH)
            {
                s.SetActionMode(oSpawned, CLRScriptBase.ACTION_MODE_STEALTH, 1);
            }

            // If it should be in detect mode, place it there.
            if ((nFlags & _SPAWN_IN_DETECT) == _SPAWN_IN_DETECT)
            {
                s.SetActionMode(oSpawned, CLRScriptBase.ACTION_MODE_DETECT, 1);
            }

            // If this creature should buff himself, do it.
            if ((nFlags & _SPAWN_BUFFED) == _SPAWN_BUFFED)
            {
                ActivateLongTermBuffs(oSpawned, s);
            }

            // Play the spawn animation.
            s.PlayAnimation(s.GetLocalInt(oWP, _WP_SPAWN_ANIMATION), 1.0f, 0.0f);

            // Play the spawn in VFX.
            s.ApplyEffectAtLocation(CLRScriptBase.DURATION_TYPE_INSTANT, s.EffectVisualEffect(s.GetLocalInt(oWP, _WP_SPAWN_IN_VFX), CLRScriptBase.FALSE), s.GetLocation(oSpawned), 0.0f);

            // Play the spawn in SFX.
            s.AssignCommand(oSpawned, delegate { s.PlaySound(s.GetLocalString(oWP, _WP_SPAWN_IN_SFX), CLRScriptBase.FALSE); });

            // Determine facing.
            if ((nFlags & _SPAWN_FLAGS_RANDOM_FACING) == _SPAWN_FLAGS_RANDOM_FACING)
            {
                // Spawn facing is random.
                s.AssignCommand(oSpawned, delegate { s.SetFacing(new Random().Next() * 360.0f, CLRScriptBase.FALSE); });
            }

            // Colorize name if needed.
            if (s.GetLocalString(oSpawned, ACR_COLOR_NAME) != "")
            {
                s.SetFirstName(oSpawned, "<C='" + s.GetLocalString(oSpawned, ACR_COLOR_NAME) + "'>" + s.GetName(oSpawned) + "</C>");
                s.SetLastName(oSpawned, "");
            }

            // Run the spawn-in scripts, if any.
            int i = 1;

            while (true)
            {
                string sScript = s.GetLocalString(oWP, _WP_SPAWN_IN_SCRIPT_ARRAY + s.IntToString(i));
                if (sScript == "")
                {
                    break;
                }
                s.ExecuteScript(sScript, oSpawned);
                i++;
            }

            _AddObjectToSpawnPoint(oWP, oSpawned, s);

            return(oSpawned);
        }
 public void ActionCastFakeSpellAtLocation(Int32 nSpell, NWLocation lTarget, Int32 nProjectilePathType)
 {
     ScriptHost.ExecuteActionService_502_3_ActionCastFakeSpellAtLocation(nSpell, lTarget, nProjectilePathType);
 }
 /// <summary>
 /// Set a vector value in the persistent store.
 /// </summary>
 /// <param name="Object">Supplies the object whose persistent store is
 /// to be accessed.</param>
 /// <param name="VarName">Supplies the variable keyword to set.</param>
 /// <param name="Value">Supplies the variable data.</param>
 public void ACR_SetPersistentLocation(UInt32 Object, string VarName, NWLocation Value)
 {
     ACR_SetPersistentString(Object, VarName, ACR_LocationToString(Value));
 }
 private static void _doGroupVFX(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, NWLocation target)
 {
     if (trap.EffectSize < 2.0f)
     {
         return;
     }                                       // these are probably single-target, and a group VFX would be overkill.
     else
     {
         if ((trap.DamageType & DAMAGE_TYPE_DIVINE) == DAMAGE_TYPE_DIVINE)
         {
             s.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_FNF_LOS_HOLY_10, FALSE), target, 0.0f);
         }
         else if ((trap.DamageType & DAMAGE_TYPE_FIRE) == DAMAGE_TYPE_FIRE)
         {
             s.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_FNF_FIREBALL, FALSE), target, 0.0f);
         }
         else if ((trap.DamageType & DAMAGE_TYPE_MAGICAL) == DAMAGE_TYPE_MAGICAL)
         {
             s.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_FNF_LOS_NORMAL_10, FALSE), target, 0.0f);
         }
         else if ((trap.DamageType & DAMAGE_TYPE_NEGATIVE) == DAMAGE_TYPE_NEGATIVE)
         {
             s.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD, FALSE), target, 0.0f);
         }
         else if ((trap.DamageType & DAMAGE_TYPE_POSITIVE) == DAMAGE_TYPE_POSITIVE)
         {
             s.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_FNF_LOS_HOLY_10, FALSE), target, 0.0f);
         }
         else
         {
             s.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_FNF_FIREBALL, FALSE), target, 0.0f);
         }
     }
 }
Esempio n. 17
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);
        }
Esempio n. 18
0
        public static void Dismount(CLRScriptBase script, uint Character, uint Cloak, NWLocation Location)
        {
            string resRef = "";

            if (script.GetLocalInt(Cloak, ACR_IS_WARHORSE) == 1)
            {
                resRef = "abr_cr_an_horse_pal_";
                int nPalLevel = script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_PALADIN, Character);
                if (nPalLevel >= 15)
                {
                    resRef += "15";
                }
                else if (nPalLevel >= 11)
                {
                    resRef += "11";
                }
                else if (nPalLevel >= 8)
                {
                    resRef += "8";
                }
                else if (nPalLevel >= 5)
                {
                    resRef += "5";
                }
                else
                {
                    resRef = "abr_cr_an_horse03";
                }
            }
            else
            {
                switch (script.GetTag(Cloak))
                {
                case "acr_ooc_horse01":
                    resRef = "abr_cr_an_horse01";
                    break;

                case "acr_ooc_horse02":
                    resRef = "abr_cr_an_horse02";
                    break;

                case "acr_ooc_horse03":
                    resRef = "abr_cr_an_horse03";
                    break;

                default:
                    // Looks like we're not actually dismounting a horse.
                    return;
                }
            }

            uint Horse = script.CreateObject(CLRScriptBase.OBJECT_TYPE_CREATURE, resRef, Location, CLRScriptBase.FALSE, "");

            script.SetLocalInt(Horse, ACR_HORSE_OWNER, script.GetLocalInt(Character, ACR_CID));
            script.SetLocalInt(Horse, ACR_HORSE_ID, script.GetLocalInt(Cloak, ACR_HORSE_ID));
            int damage = script.GetCurrentHitPoints(Horse) - script.GetLocalInt(Cloak, ACR_HORSE_HP);

            if (damage > 0)
            {
                script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_INSTANT, script.EffectDamage(damage, CLRScriptBase.DAMAGE_TYPE_MAGICAL, CLRScriptBase.DAMAGE_POWER_PLUS_TWENTY, CLRScriptBase.TRUE), Horse, 0.0f);
            }
            if (script.GetLocalInt(Cloak, ACR_IS_WARHORSE) == 1)
            {
                script.AddHenchman(Character, Horse);
                script.SetLocalInt(Horse, ACR_IS_WARHORSE, 1);
                script.SetLocalObject(Character, ACR_PAL_WARHORSE, Horse);
            }

            uint Item = GetOwnershipItemById(script, Character, script.GetLocalInt(Cloak, ACR_HORSE_ID));

            script.SetLocalObject(Item, ACR_HORSE_OBJECT, Horse);
            script.SetLocalObject(Horse, ACR_HORSE_OBJECT, Character);

            script.SetLocalString(Item, ACR_HORSE_PERS_LOC_AREA, script.GetTag(script.GetArea(Horse)));
            script.SetLocalFloat(Item, ACR_HORSE_PERS_LOC_X, script.GetPosition(Horse).x);
            script.SetLocalFloat(Item, ACR_HORSE_PERS_LOC_Y, script.GetPosition(Horse).y);
            script.SetLocalFloat(Item, ACR_HORSE_PERS_LOC_Z, script.GetPosition(Horse).z);

            script.SetPlotFlag(Cloak, CLRScriptBase.FALSE);
            script.DestroyObject(Cloak, 0.0f, CLRScriptBase.FALSE);
            isWarhorse.Remove(Character);
        }
 public UInt32 GetNextObjectInShape(Int32 nShape, float fSize, NWLocation lTarget, Int32 bLineOfSight, Int32 nObjectFilter, NWScript.Vector3 vOrigin)
 {
     return ScriptHost.ExecuteActionService_129_8_GetNextObjectInShape(nShape, (Single)fSize, lTarget, bLineOfSight, nObjectFilter, vOrigin.z, vOrigin.y, vOrigin.x);
 }
 public void SetTileSourceLightColor(NWLocation lTileLocation, Int32 nSourceLight1Color, Int32 nSourceLight2Color)
 {
     ScriptHost.ExecuteActionService_515_3_SetTileSourceLightColor(lTileLocation, nSourceLight1Color, nSourceLight2Color);
 }
        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); });
            }
        }
 public void SetTileMainLightColor(NWLocation lTileLocation, Int32 nMainLight1Color, Int32 nMainLight2Color)
 {
     ScriptHost.ExecuteActionService_514_3_SetTileMainLightColor(lTileLocation, nMainLight1Color, nMainLight2Color);
 }
 public Int32 GetTileSourceLight2Color(NWLocation lTile)
 {
     return ScriptHost.ExecuteActionService_520_1_GetTileSourceLight2Color(lTile);
 }
 public Int32 GetTileMainLight2Color(NWLocation lTile)
 {
     return ScriptHost.ExecuteActionService_518_1_GetTileMainLight2Color(lTile);
 }
 public UInt32 CreateObject(Int32 nObjectType, String sTemplate, NWLocation lLocation, Int32 bUseAppearAnimation, String sNewTag)
 {
     return ScriptHost.ExecuteActionService_243_5_CreateObject(nObjectType, sTemplate, lLocation, bUseAppearAnimation, sNewTag);
 }
 public void SetCampaignLocation(String sCampaignName, String sVarName, NWLocation locLocation, UInt32 oPlayer)
 {
     ScriptHost.ExecuteActionService_592_4_SetCampaignLocation(sCampaignName, sVarName, locLocation, oPlayer);
 }
 public void ActionMoveToLocation(NWLocation lDestination, Int32 bRun)
 {
     ScriptHost.ExecuteActionService_21_2_ActionMoveToLocation(lDestination, bRun);
 }
 public UInt32 RetrieveCampaignObject(String sCampaignName, String sVarName, NWLocation locLocation, UInt32 oOwner, UInt32 oPlayer)
 {
     return ScriptHost.ExecuteActionService_603_5_RetrieveCampaignObject(sCampaignName, sVarName, locLocation, oOwner, oPlayer);
 }
 public float GetDistanceBetweenLocations(NWLocation lLocationA, NWLocation lLocationB)
 {
     return ScriptHost.ExecuteActionService_298_2_GetDistanceBetweenLocations(lLocationA, lLocationB);
 }
 public void SpawnSpellProjectile(UInt32 oSource, UInt32 oTaget, NWLocation lSource, NWLocation lTarget, Int32 nSpellID, Int32 nProjectilePathType)
 {
     ScriptHost.ExecuteActionService_836_6_SpawnSpellProjectile(oSource, oTaget, lSource, lTarget, nSpellID, nProjectilePathType);
 }
 public void ActionUseTalentAtLocation(NWTalent tChosenTalent, NWLocation lTargetLocation)
 {
     ScriptHost.ExecuteActionService_310_2_ActionUseTalentAtLocation(tChosenTalent, lTargetLocation);
 }
 public float GetProjectileTravelTime(NWLocation lSource, NWLocation lTarget, Int32 nProjectilePathType, Int32 nSpellID)
 {
     return ScriptHost.ExecuteActionService_841_4_GetProjectileTravelTime(lSource, lTarget, nProjectilePathType, nSpellID);
 }
 public void JumpToLocation(NWLocation lDestination)
 {
     ScriptHost.ExecuteActionService_313_1_JumpToLocation(lDestination);
 }
 public NWLocation CalcSafeLocation(UInt32 oCreature, NWLocation lTestPosition, float fSearchRadius, Int32 bWalkStraighLineRequired, Int32 bIgnoreTestPosition)
 {
     return ScriptHost.ExecuteActionService_875_5_CalcSafeLocation(oCreature, lTestPosition, (Single)fSearchRadius, bWalkStraighLineRequired, bIgnoreTestPosition);
 }
 public void ActionMoveAwayFromLocation(NWLocation lMoveAwayFrom, Int32 bRun, float fMoveAwayRange)
 {
     ScriptHost.ExecuteActionService_360_3_ActionMoveAwayFromLocation(lMoveAwayFrom, bRun, (Single)fMoveAwayRange);
 }
 public Int32 GetIsLocationValid(NWLocation lLocation)
 {
     return ScriptHost.ExecuteActionService_1033_1_GetIsLocationValid(lLocation);
 }
 public void ActionForceMoveToLocation(NWLocation lDestination, Int32 bRun, float fTimeout)
 {
     ScriptHost.ExecuteActionService_382_3_ActionForceMoveToLocation(lDestination, bRun, (Single)fTimeout);
 }
 public void RecallCreatureFromLimboToLocation(UInt32 oCreature, NWLocation loc)
 {
     ScriptHost.ExecuteActionService_1057_2_RecallCreatureFromLimboToLocation(oCreature, loc);
 }
 public NWEvent EventActivateItem(UInt32 oItem, NWLocation lTarget, UInt32 oTarget)
 {
     return ScriptHost.ExecuteActionService_424_3_EventActivateItem(oItem, lTarget, oTarget);
 }
 public void SetLocalLocation(UInt32 oObject, String sVarName, NWLocation lValue)
 {
     ScriptHost.ExecuteActionService_152_3_SetLocalLocation(oObject, sVarName, lValue);
 }
 public NWEffect EffectDisappearAppear(NWLocation lLocation, Int32 nAnimation)
 {
     return ScriptHost.ExecuteActionService_480_2_EffectDisappearAppear(lLocation, nAnimation);
 }