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 bool LoadArea(CLRScriptBase script)
        {
            if(TemplateAreaId == 0)
            {
                // No template? Can't instance anything. Report failure.
                return false;
            }
            if(AreaId != 0)
            {
                // Got an Id? Great! Job's already done.
                return true;
            }

            // Guess we need an area. Check the cache first.
            if(DungeonStore.CachedAreas.ContainsKey(TemplateAreaId))
            {
                if(DungeonStore.CachedAreas[TemplateAreaId].Count > 0)
                {
                    AreaId = DungeonStore.CachedAreas[TemplateAreaId][0];
                    DungeonStore.CachedAreas[TemplateAreaId].Remove(DungeonStore.CachedAreas[TemplateAreaId][0]);
                    script.SetLocalString(AreaId, "DUNGEON_NAME", DungeonName);
                    PopulateArea(script);
                    return true;
                }
            }

            // No dice? OK, time to make an instance
            AreaId = script.CreateInstancedAreaFromSource(TemplateAreaId);
            if(script.GetIsObjectValid(AreaId) == CLRScriptBase.TRUE)
            {
                script.SetLocalString(AreaId, "DUNGEON_NAME", DungeonName);
                PopulateArea(script);
                return true;
            }

            return false;
        }
Exemplo n.º 3
0
 public static void LoadAreas(CLRScriptBase s)
 {
     if (!ACR_Candlekeep.ArchivesInstance.WaitForResourcesLoaded(false))
     {
         s.DelayCommand(6.0f, delegate { LoadAreas(s); });
         return;
     }
     ALFA.Shared.Modules.InfoStore.ActiveAreas = new Dictionary<uint, ALFA.Shared.ActiveArea>();
     List<uint> areas = new List<uint>();
     foreach (uint area in s.GetAreas())
     {
         ALFA.Shared.ActiveArea activeArea = new ALFA.Shared.ActiveArea();
         activeArea.Id = area;
         activeArea.Name = s.GetName(area).Trim();
         activeArea.Tag = s.GetTag(area);
         activeArea.GlobalQuests.Add("Infestation", s.GetLocalInt(area, "ACR_QST_MAX_INFESTATION"));
         ALFA.Shared.Modules.InfoStore.ActiveAreas.Add(area, activeArea);
         areas.Add(area);
     }
     int count = 0;
     foreach(KeyValuePair<string, string> keyValue in ALFA.Shared.Modules.InfoStore.AreaNames)
     {
         ALFA.Shared.Modules.InfoStore.ActiveAreas[areas[count]].LocalizedName = keyValue.Value;
         ALFA.Shared.Modules.InfoStore.ActiveAreas[areas[count]].ConfigureDisplayName();
         s.SetLocalString(areas[count], "ACR_AREA_RESREF", keyValue.Key);
         count++;
     }
     foreach (ALFA.Shared.ActiveArea activeArea in ALFA.Shared.Modules.InfoStore.ActiveAreas.Values)
     {
         foreach (uint thing in s.GetObjectsInArea(activeArea.Id))
         {
             uint target = s.GetTransitionTarget(thing);
             if (s.GetIsObjectValid(target) != FALSE)
             {
                 ALFA.Shared.ActiveTransition activeTransition = new ALFA.Shared.ActiveTransition();
                 activeTransition.AreaTarget = ALFA.Shared.Modules.InfoStore.ActiveAreas[s.GetArea(target)];
                 activeTransition.Id = thing;
                 activeTransition.Target = target;
                 activeArea.ExitTransitions.Add(activeTransition, activeTransition.AreaTarget);
             }
         }
     }
 }
 private void PopulateArea(CLRScriptBase script)
 {
     List<Vector3> trapsToSpawn = new List<Vector3>();
     if (!DungeonStore.DungeonSpawns.ContainsKey(SpawnType)) return;
     foreach(uint wp in script.GetObjectsInArea(AreaId))
     {
         if(script.GetTag(wp) == "MONSTER_LOW")
         {
             if (DungeonStore.DungeonSpawns[SpawnType].ContainsKey(CR / 3))
             {
                 script.CreateObject(CLRScriptBase.OBJECT_TYPE_CREATURE, DungeonStore.DungeonSpawns[SpawnType][CR/3][rand.Next(DungeonStore.DungeonSpawns[SpawnType][CR/3].Count)], script.GetLocation(wp), CLRScriptBase.TRUE, "");
             }
         }
         else if(script.GetTag(wp) == "MONSTER_MED")
         {
             if (DungeonStore.DungeonSpawns[SpawnType].ContainsKey(CR / 2))
             {
                 script.CreateObject(CLRScriptBase.OBJECT_TYPE_CREATURE, DungeonStore.DungeonSpawns[SpawnType][CR/2][rand.Next(DungeonStore.DungeonSpawns[SpawnType][CR/2].Count)], script.GetLocation(wp), CLRScriptBase.TRUE, "");
             }
         }
         else if(script.GetTag(wp) == "MONSTER_HIGH")
         {
             
             if (DungeonStore.DungeonSpawns[SpawnType].ContainsKey(CR))
             {
                 script.CreateObject(CLRScriptBase.OBJECT_TYPE_CREATURE, DungeonStore.DungeonSpawns[SpawnType][CR][rand.Next(DungeonStore.DungeonSpawns[SpawnType][CR].Count)], script.GetLocation(wp), CLRScriptBase.TRUE, "");
             }
             if (!questSpawned)
             {
                 questSpawned = true;
                 NWEffect AoE = script.EffectAreaOfEffect(86, "acf_trg_onenter", "acf_trg_onheartbeat", "acf_trg_onexit", "AOE"+Quest);
                 script.ApplyEffectAtLocation(CLRScriptBase.DURATION_TYPE_PERMANENT, script.SupernaturalEffect(AoE), script.GetLocation(wp), 0.0f);
                 uint spawnedAoE = script.GetObjectByTag("AOE" + Quest, 0);
                 script.SetLocalString(spawnedAoE, "ACR_QST_NAME", Quest);
                 script.SetLocalInt(spawnedAoE, "ACR_QST_LOWER_STATE", 1);
                 script.SetLocalInt(spawnedAoE, "ACR_QST_UPPER_STATE", 2);
                 script.SetLocalString(spawnedAoE, "ACR_QST_MESSAGE", "This appears to be the end of the dungeon, and your path here is scouted.");
             }
         }
         else if (script.GetTag(wp) == "TRAP")
         { 
             if(DungeonStore.DungeonTraps[TrapType].ContainsKey(CR))
             {
                 trapsToSpawn.Add(script.GetPosition(wp));
             }
         }
     }
     foreach (Vector3 trap in trapsToSpawn)
     {
         script.ClearScriptParams();
         script.AddScriptParameterInt(1);
         script.AddScriptParameterFloat(trap.x);
         script.AddScriptParameterFloat(trap.y);
         script.AddScriptParameterFloat(trap.z);
         script.AddScriptParameterObject(AreaId);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterFloat(-1.0f);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterObject(CLRScriptBase.OBJECT_INVALID);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterInt(-1);
         script.AddScriptParameterString(DungeonStore.DungeonTraps[TrapType][CR][rand.Next(DungeonStore.DungeonTraps[TrapType][CR].Count)]);
         script.ExecuteScriptEnhanced("ACR_Traps", script.GetModule(), CLRScriptBase.FALSE);
     }
 }
Exemplo n.º 5
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);
        }