public static void GrowAllInfestations(CLRScriptBase s) { InfestationGrowthCounterStarted = true; float delay = 0.0f; foreach (Infestation inf in LoadedInfestations) { s.DelayCommand(delay, delegate { inf.GrowInfestation(s); }); delay += 6.0f; } s.DelayCommand(s.HoursToSeconds(24), delegate { GrowAllInfestations(s); }); }
public static void InitializeInfestations(CLRScriptBase s) { // If we haven't even started caching areas, no point in starting here. if (ALFA.Shared.Modules.InfoStore.ActiveAreas == null) { s.DelayCommand(30.0f, delegate { InitializeInfestations(s); }); return; } // If we have areas, but haven't added any to ActiveAreas, we can't check on the areas. if (ALFA.Shared.Modules.InfoStore.ActiveAreas.Count == 0) { s.DelayCommand(30.0f, delegate { InitializeInfestations(s); }); return; } // If the first area we loop over hasn't mapped its area transitions, we can't be sure // that we have a complete list of areas. if (ALFA.Shared.Modules.InfoStore.ActiveAreas.First().Value.ExitTransitions == null) { s.DelayCommand(30.0f, delegate { InitializeInfestations(s); }); return; } // Once we know we at least have a complete list of areas, we can deserialize our infestations // and start infesting areas. foreach (string file in Directory.EnumerateFiles(QuestStore.InfestationStoreDirectory)) { using (FileStream stream = new FileStream(file, FileMode.Open)) { DataContractSerializer ser = new DataContractSerializer(typeof(Infestation)); Infestation ret = ser.ReadObject(stream) as Infestation; QuestStore.LoadedInfestations.Add(ret); ret.InfestedAreas = new List <ActiveArea>(); Dictionary <string, ActiveArea> areasToAdjust = new Dictionary <string, ActiveArea>(); foreach (string inf in ret.InfestedAreaLevels.Keys) { ActiveArea ar = GetAreaByTag(inf); if (ar != null) // Areas might be removed during a reset. { ret.InfestedAreas.Add(ar); areasToAdjust.Add(inf, ar); } } foreach (KeyValuePair <string, ActiveArea> area in areasToAdjust) { ret.InfestArea(area.Key, area.Value, ret.InfestedAreaLevels[area.Key], s); } } } }
public static void SortLists(CLRScriptBase script) { if (!ALFA.Shared.Modules.InfoStore.WaitForResourcesLoaded(false)) { script.DelayCommand(6.0f, delegate { SortLists(script); }); return; } if (ALFA.Shared.Modules.InfoStore.ActiveAreas == null) { script.DelayCommand(2.0f, delegate { SortLists(script); }); return; } AreaList = ALFA.Shared.Modules.InfoStore.ActiveAreas.Values.ToList <ALFA.Shared.ActiveArea>(); AreaList.Sort(); }
public static void WaitForSearch(CLRScriptBase script, User currentUser, ACR_ChooserCreator.ACR_CreatorCommand currentTab, CreatorSearch awaitedSearch) { if (awaitedSearch == null) { // Search has been removed. Abort. return; } if (awaitedSearch.CancellationPending) { // Search has been canceled. Abort. return; } if (currentUser.openCommand != currentTab) { // User has switched tabs. Kill the search. return; } if (currentUser.CreatorSearchResponse != null) { // Looks like we've finished. Draw a list! CreatorSearch oldSearch = currentUser.CurrentSearch; currentUser.CurrentSearch = null; oldSearch.Dispose(); Waiter.DrawNavigatorCategory(script, currentUser.CreatorSearchResponse); switch (currentUser.openCommand) { case ACR_ChooserCreator.ACR_CreatorCommand.ACR_CHOOSERCREATOR_FOCUS_CREATURE_TAB: currentUser.CurrentCreatureCategory = currentUser.CreatorSearchResponse; break; case ACR_ChooserCreator.ACR_CreatorCommand.ACR_CHOOSERCREATOR_FOCUS_ITEM_TAB: currentUser.CurrentItemCategory = currentUser.CreatorSearchResponse; break; case ACR_ChooserCreator.ACR_CreatorCommand.ACR_CHOOSERCREATOR_FOCUS_LIGHTS_TAB: currentUser.CurrentLightCategory = currentUser.CreatorSearchResponse; break; case ACR_ChooserCreator.ACR_CreatorCommand.ACR_CHOOSERCREATOR_FOCUS_PLACEABLE_TAB: currentUser.CurrentPlaceableCategory = currentUser.CreatorSearchResponse; break; case ACR_ChooserCreator.ACR_CreatorCommand.ACR_CHOOSERCREATOR_FOCUS_TRAP_TAB: currentUser.CurrentTrapCategory = currentUser.CreatorSearchResponse; break; case ACR_ChooserCreator.ACR_CreatorCommand.ACR_CHOOSERCREATOR_FOCUS_VFX_TAB: currentUser.CurrentVisualEffectCategory = currentUser.CreatorSearchResponse; break; case ACR_ChooserCreator.ACR_CreatorCommand.ACR_CHOOSERCREATOR_FOCUS_WAYPOINT_TAB: currentUser.CurrentWaypointCategory = currentUser.CreatorSearchResponse; break; } return; } script.DelayCommand(1.0f, delegate { WaitForSearch(script, currentUser, currentTab, awaitedSearch); }); }
private void RecoverFromTops(CLRScriptBase s) { bool changeMade = false; if (CachedGrowth < 0) { int highestDensity = 1; foreach (int dens in InfestedAreaLevels.Values) { if (dens > highestDensity) { highestDensity = dens; } } Dictionary <string, int> toChange = new Dictionary <string, int>(); foreach (KeyValuePair <string, int> inf in InfestedAreaLevels) { if (inf.Value == highestDensity) { #if DEBUG s.SendMessageToAllDMs(String.Format("RecoverFromTops: reducing {0} to {1}.", inf.Key, inf.Value - 1)); #endif toChange.Add(inf.Key, inf.Value - 1); CachedGrowth += 1; changeMade = true; } } foreach (KeyValuePair <string, int> inf in toChange) { ChangeAreaLevel(inf.Key, null, inf.Value - 1, s); } } #if DEBUG s.SendMessageToAllDMs("RecoverFromTops complete. CachedGrowth is " + CachedGrowth); #endif if (changeMade && CachedGrowth < 0) { s.DelayCommand(0.1f, delegate { RecoverFromTops(s); }); } else { s.DelayCommand(0.1f, delegate { GrowthWrapper(s); }); } }
private static void RidingHeartbeat(CLRScriptBase script, uint Character) { // Character has dismounted if (!isWarhorse.ContainsKey(Character)) { return; } script.DelayCommand(6.0f, delegate { RidingHeartbeat(script, Character); }); }
public static void WaitForResources(CLRScriptBase script, IBackgroundLoadedResource resource) { if (resource.WaitForResourcesLoaded(false) == true) { DrawListBox(script, (resource as IDrawableList).ListBox); return; } else { // TODO: Display the 'thinking' animation. script.DelayCommand(0.5f, delegate() { WaitForResources(script, resource); }); return; } }
public static void WaitForNavigator(CLRScriptBase script, Navigator nav) { if (nav.WaitForResourcesLoaded(false) == true) { DrawNavigatorCategory(script, nav.bottomCategory); return; } else { script.SendMessageToPC(script.OBJECT_SELF, "loading..."); script.DelayCommand(0.5f, delegate() { WaitForNavigator(script, nav); }); return; } }
private static bool IsTrapDetectedBy(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, uint detector) { if (trap.Detected) { return(false); } if (!IsInArea(s, trap, detector)) { return(false); } if (s.GetDetectMode(detector) == FALSE) { s.DelayCommand(6.0f, delegate { DetectHeartBeat(s, trap, detector); }); return(false); } if (trap.DetectDC > 20 && s.GetLevelByClass(CLASS_TYPE_ROGUE, detector) == FALSE && s.GetHasSpellEffect(SPELL_FIND_TRAPS, detector) == FALSE) { s.DelayCommand(6.0f, delegate { DetectHeartBeat(s, trap, detector); }); return(false); } int searchBonus = s.GetSkillRank(SKILL_SEARCH, detector, FALSE); int roll = s.d20(1); int finalDice = roll + searchBonus; if (trap.DetectDC <= finalDice) { return(true); } s.DelayCommand(6.0f, delegate { DetectHeartBeat(s, trap, detector); }); return(false); }
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 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 GrowthWrapper(CLRScriptBase s) { if (CachedGrowth > 0 && (GrowCurrent(s) || ExpandRemaining(s))) { s.DelayCommand(0.1f, delegate { GrowthWrapper(s); }); return; } MaxArea = 0; foreach (int val in InfestedAreaLevels.Values) { if (val > MaxArea) { MaxArea = val; } } CachedGrowth = 0; Save(); }
private void SmoothEdges(CLRScriptBase s) { bool changeMade = false; Dictionary <ActiveArea, int> areasToDo = new Dictionary <ActiveArea, int>(); foreach (ActiveArea area in InfestedAreas) { int areaLevel = InfestedAreaLevels[area.Tag]; foreach (ActiveArea adj in area.ExitTransitions.Values) { if (InfestedAreas.Contains(adj)) { int diff = areaLevel - InfestedAreaLevels[adj.Tag]; if (diff < -1) { int maxLevel = areaLevel + 1; int adjust = InfestedAreaLevels[adj.Tag] - maxLevel; #if DEBUG s.SendMessageToAllDMs(String.Format("SmoothEdges: subtracting {0} from {1} because of {2}.", adjust, adj.Tag, area.Tag)); #endif if (!areasToDo.ContainsKey(adj)) { areasToDo.Add(adj, maxLevel); } CachedGrowth += adjust; changeMade = true; } } else if (areaLevel > 1 && adj.GlobalQuests[ACR_Quest.GLOBAL_QUEST_INFESTATION_KEY] >= 0) { if (areaLevel - 1 > adj.GlobalQuests[ACR_Quest.GLOBAL_QUEST_INFESTATION_KEY] && adj.GlobalQuests[ACR_Quest.GLOBAL_QUEST_INFESTATION_KEY] != 0) { areaLevel = adj.GlobalQuests[ACR_Quest.GLOBAL_QUEST_INFESTATION_KEY] + 1; } #if DEBUG s.SendMessageToAllDMs(String.Format("SmoothEdges: infesting new area {0} at {1}.", areaLevel - 1, adj)); #endif if (!areasToDo.ContainsKey(adj)) { areasToDo.Add(adj, areaLevel - 1); } CachedGrowth -= (areaLevel - 1); changeMade = true; } } } foreach (KeyValuePair <ActiveArea, int> ar in areasToDo) { ChangeAreaLevel(ar.Key.Tag, ar.Key, ar.Value, s); } #if DEBUG s.SendMessageToAllDMs("SmoothEdges complete. CachedGrowth is " + CachedGrowth); #endif if (changeMade) { s.DelayCommand(0.1f, delegate { SmoothEdges(s); }); } else { s.DelayCommand(0.1f, delegate { RecoverFromTops(s); }); } }
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 static void ActivateLongTermBuffs(uint oCaster, CLRScriptBase s) { // Cast protection from good/evil based on alignment. if (s.GetAlignmentGoodEvil(oCaster) == CLRScriptBase.ALIGNMENT_EVIL) { _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_GOOD, s); } else { _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_EVIL, s); } // Buff armor, if the creature has any. uint oItem = s.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CHEST, s.OBJECT_SELF); if (oItem != CLRScriptBase.OBJECT_INVALID) { _QuickBuff(oCaster, CLRScriptBase.SPELL_MAGIC_VESTMENT, s, oItem); } // Buff the shield, if the creature has one. uint oLeftHandItem = s.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_LEFTHAND, oCaster); uint oRightHandItem = s.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_RIGHTHAND, oCaster); int nLeftItemType = s.GetBaseItemType(oLeftHandItem); int nRightItemType = s.GetBaseItemType(oRightHandItem); if (GetIsItemShield(oLeftHandItem, s) != CLRScriptBase.FALSE) { _QuickBuff(oCaster, CLRScriptBase.SPELL_MAGIC_VESTMENT, s, oLeftHandItem); } // FIX ME!! Weapon-buffing should be more intelligent. But we need to be // able to tell what a weapon is. _QuickBuff(oCaster, CLRScriptBase.SPELL_KEEN_EDGE, s); if (s.GetHasSpell(CLRScriptBase.SPELL_GREATER_MAGIC_WEAPON, oCaster) != CLRScriptBase.FALSE) { _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_MAGIC_WEAPON, s); } else { _QuickBuff(oCaster, CLRScriptBase.SPELL_MAGIC_WEAPON, s); } _QuickBuff(oCaster, CLRScriptBase.SPELL_WEAPON_OF_IMPACT, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_BARKSKIN, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_SPIDERSKIN, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_CONVICTION, s); if (s.GetHasSpell(CLRScriptBase.SPELL_PROTECTION_FROM_ENERGY, oCaster) != CLRScriptBase.FALSE) { _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_ENERGY, s); } else { _QuickBuff(oCaster, CLRScriptBase.SPELL_ENDURE_ELEMENTS, s); } _QuickBuff(oCaster, CLRScriptBase.SPELL_FREEDOM_OF_MOVEMENT, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_HEROISM, s); if (s.GetHasSpell(CLRScriptBase.SPELL_IMPROVED_MAGE_ARMOR, oCaster) != CLRScriptBase.FALSE) { _QuickBuff(oCaster, CLRScriptBase.SPELL_IMPROVED_MAGE_ARMOR, s); } else { _QuickBuff(oCaster, CLRScriptBase.SPELL_MAGE_ARMOR, s); } if (s.GetHasSpell(CLRScriptBase.SPELL_GREATER_PLANAR_BINDING, oCaster) != CLRScriptBase.FALSE) { _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_PLANAR_BINDING, s); } else if (s.GetHasSpell(CLRScriptBase.SPELL_PLANAR_BINDING, oCaster) != CLRScriptBase.FALSE) { _QuickBuff(oCaster, CLRScriptBase.SPELL_PLANAR_BINDING, s); } else if (s.GetHasSpell(CLRScriptBase.SPELL_PLANAR_ALLY, oCaster) != CLRScriptBase.FALSE) { _QuickBuff(oCaster, CLRScriptBase.SPELL_PLANAR_ALLY, s); } else { _QuickBuff(oCaster, CLRScriptBase.SPELL_LESSER_PLANAR_BINDING, s); } _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_RESISTANCE, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_MIND_BLANK, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_ONE_WITH_THE_LAND, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_PREMONITION, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_SPELLS, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_ARROWS, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_BULLS_STRENGTH, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_CATS_GRACE, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_EAGLE_SPLENDOR, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_BEARS_ENDURANCE, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_FOXS_CUNNING, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_OWLS_WISDOM, s); _QuickBuff(oCaster, CLRScriptBase.SPELL_SEE_INVISIBILITY, s); if (s.GetHasSpell(CLRScriptBase.SPELL_PREMONITION, oCaster) != CLRScriptBase.FALSE) { _QuickBuff(oCaster, CLRScriptBase.SPELL_PREMONITION, s); } else if (s.GetHasSpell(CLRScriptBase.SPELL_GREATER_STONESKIN, oCaster) != CLRScriptBase.FALSE) { _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_STONESKIN, s); } else { _QuickBuff(oCaster, CLRScriptBase.SPELL_STONESKIN, s); } // Delay party buffs a bit in case this guy has buddies spawning in next to him. s.DelayCommand(6.0f, delegate { _QuickBuff(oCaster, CLRScriptBase.SPELL_MASS_CAMOFLAGE, s); }); }
private static void SwimHeartbeat(CLRScriptBase script, uint Creature) { uint Trigger = AppearanceTypes.currentSwimTrigger[Creature]; foreach (uint contents in script.GetObjectsInPersistentObject(Trigger, CLRScriptBase.OBJECT_TYPE_CREATURE, CLRScriptBase.PERSISTENT_ZONE_ACTIVE)) { if (contents == Creature) { if (script.GetSubRace(Creature) != CLRScriptBase.RACIAL_SUBTYPE_WATER_GENASI && script.GetLocalInt(Creature, ACR_CREATURE_AQUATIC) == 0) { int SwimDC = script.GetLocalInt(Trigger, ACR_SWIM_DC); int SinkDC = SwimDC - 5; int NoAir = script.GetLocalInt(Trigger, ACR_NO_AIR); int Roll = script.d20(1); int Bonus = script.GetSkillRank(CLRScriptBase.SKILL_SWIM, Creature, CLRScriptBase.FALSE); ProcessWaterEffects(script, Creature, Trigger); if (10 + Bonus >= SwimDC) { // Can take 10 here. Roll = 10; } if (Roll + Bonus >= SwimDC) { script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectMovementSpeedDecrease(50)), Creature, 6.0f); script.SendMessageToPC(Creature, String.Format("*Swim: {0} + {1} = {2} v. DC {3} :: Success!*", Roll, Bonus, Roll + Bonus, SwimDC)); if (NoAir == CLRScriptBase.FALSE) { CurrentDrownStatus.Remove(Creature); CurrentDrownDC.Remove(Creature); } else { ProcessNoAir(script, Creature); } } else if (Roll + Bonus >= SinkDC) { script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectMovementSpeedDecrease(75)), Creature, 6.0f); script.SendMessageToPC(Creature, String.Format("*Swim: {0} + {1} = {2} v. DC {3} :: Failure!*", Roll, Bonus, Roll + Bonus, SwimDC)); script.SendMessageToPC(Creature, String.Format("You struggle to move through the water.")); if (NoAir == CLRScriptBase.FALSE) { CurrentDrownStatus.Remove(Creature); CurrentDrownDC.Remove(Creature); } else { ProcessNoAir(script, Creature); } } else { script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectMovementSpeedDecrease(75)), Creature, 6.0f); // TODO: Find a way to apply this penalty without completely screwing the PC's AC. //script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectACDecrease(2, CLRScriptBase.AC_DODGE_BONUS, CLRScriptBase.DAMAGE_TYPE_ALL)), Creature, 6.0f); script.SendMessageToPC(Creature, String.Format("*Swim: {0} + {1} = {2} v. DC {3} :: Failure!*", Roll, Bonus, Roll + Bonus, SwimDC)); script.SendMessageToPC(Creature, String.Format("You're completely overwhelmed by the pull of the water!")); ProcessNoAir(script, Creature); } } else { script.SendMessageToPC(Creature, "Your swim speed and capacity to breathe water allows you to move easily through the water."); return; } script.DelayCommand(6.0f, delegate { SwimHeartbeat(script, Creature); }); return; } } AppearanceTypes.currentSwimTrigger[Creature] = CLRScriptBase.OBJECT_INVALID; AppearanceTypes.characterMovement[Creature] = AppearanceTypes.MovementType.Walking; if (Swimming.CurrentDrownStatus.ContainsKey(Creature)) { Swimming.CurrentDrownStatus.Remove(Creature); } AppearanceTypes.RecalculateMovement(script, Creature); }
public static void Fire(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, uint specialTarget) { List <uint> targets = new List <uint>(); if (s.GetIsObjectValid(specialTarget) == TRUE) { targets.Add(specialTarget); } foreach (uint contents in s.GetObjectsInPersistentObject(s.GetObjectByTag(trap.Tag, 0), OBJECT_TYPE_CREATURE, 0)) { if (FitsTrapTargetRestriction(s, trap, contents)) { targets.Add(contents); } } if (targets.Count == 0) { // Might be that they all left. In any case // we have nothing to shoot trap.IsFiring = false; return; } uint target; if (targets.Count == 1) { target = targets[0]; } else { target = targets[s.Random(targets.Count)]; } uint caster; if (s.GetIsObjectValid(trap.TrapOrigin) == FALSE) { caster = s.GetObjectByTag(trap.Tag, 0); } else { caster = trap.TrapOrigin; } if (trap.SpellTrap) { // It's a spell-- guess this is simple. s.AssignCommand(caster, delegate { s.ActionCastSpellAtObject(trap.SpellId, target, METAMAGIC_NONE, TRUE, 0, 0, 1); }); } else { foreach (uint victim in s.GetObjectsInShape(trap.EffectArea, trap.EffectSize, s.GetLocation(target), false, OBJECT_TYPE_CREATURE, s.GetPosition(caster))) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, GetTrapEffect(s, trap, victim), victim, 0.0f); _doSoloVFX(s, trap, victim); } _doGroupVFX(s, trap, s.GetLocation(target)); } if (trap.NumberOfShots > -1) { if (trap.NumberOfShots < 2) { TrapDisable.RemoveTrap(s, trap); return; } else { trap.NumberOfShots--; } } trap.IsFiring = true; s.DelayCommand(6.0f, delegate { Fire(s, trap); }); }
private static void _doSoloVFX(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, uint target) { if (trap.EffectSize < 2.0f) { if (s.GetArea(trap.TrapOrigin) == s.GetArea(s.GetObjectByTag(trap.Tag, 0))) { if ((trap.DamageType & DAMAGE_TYPE_ACID) == DAMAGE_TYPE_ACID) { s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.EffectBeam(VFX_BEAM_ACID, trap.TrapOrigin, BODY_NODE_CHEST, FALSE), target, 1.0f); } if ((trap.DamageType & DAMAGE_TYPE_BLUDGEONING) == DAMAGE_TYPE_BLUDGEONING) { s.SpawnItemProjectile(trap.TrapOrigin, target, s.GetLocation(trap.TrapOrigin), s.GetLocation(target), BASE_ITEM_SLING, PROJECTILE_PATH_TYPE_HOMING, OVERRIDE_ATTACK_RESULT_HIT_SUCCESSFUL, 0); float fShotDelay = 0.1f; int c = 1; while (c < trap.DiceNumber) { s.DelayCommand(fShotDelay, delegate { s.SpawnItemProjectile(trap.TrapOrigin, target, s.GetLocation(trap.TrapOrigin), s.GetLocation(target), BASE_ITEM_SLING, PROJECTILE_PATH_TYPE_HOMING, OVERRIDE_ATTACK_RESULT_HIT_SUCCESSFUL, 0); }); fShotDelay += 0.1f; c++; } } if ((trap.DamageType & DAMAGE_TYPE_COLD) == DAMAGE_TYPE_COLD) { s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.EffectBeam(VFX_BEAM_ICE, trap.TrapOrigin, BODY_NODE_CHEST, FALSE), target, 1.0f); } if ((trap.DamageType & DAMAGE_TYPE_DIVINE) == DAMAGE_TYPE_DIVINE) { s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.EffectBeam(VFX_BEAM_HOLY, trap.TrapOrigin, BODY_NODE_CHEST, FALSE), target, 1.0f); } if ((trap.DamageType & DAMAGE_TYPE_ELECTRICAL) == DAMAGE_TYPE_ELECTRICAL) { s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.EffectBeam(VFX_BEAM_LIGHTNING, trap.TrapOrigin, BODY_NODE_CHEST, FALSE), target, 1.0f); } if ((trap.DamageType & DAMAGE_TYPE_FIRE) == DAMAGE_TYPE_FIRE) { s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.EffectBeam(VFX_BEAM_FIRE, trap.TrapOrigin, BODY_NODE_CHEST, FALSE), target, 1.0f); } if ((trap.DamageType & DAMAGE_TYPE_MAGICAL) == DAMAGE_TYPE_MAGICAL) { s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.EffectBeam(VFX_BEAM_MAGIC, trap.TrapOrigin, BODY_NODE_CHEST, FALSE), target, 1.0f); } if ((trap.DamageType & DAMAGE_TYPE_NEGATIVE) == DAMAGE_TYPE_NEGATIVE) { s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.EffectBeam(VFX_BEAM_EVIL, trap.TrapOrigin, BODY_NODE_CHEST, FALSE), target, 1.0f); } if ((trap.DamageType & DAMAGE_TYPE_PIERCING) == DAMAGE_TYPE_PIERCING) { s.SpawnItemProjectile(trap.TrapOrigin, target, s.GetLocation(trap.TrapOrigin), s.GetLocation(target), BASE_ITEM_DART, PROJECTILE_PATH_TYPE_HOMING, OVERRIDE_ATTACK_RESULT_HIT_SUCCESSFUL, 0); float fShotDelay = 0.1f; int c = 1; while (c < trap.DiceNumber) { s.SpawnItemProjectile(trap.TrapOrigin, target, s.GetLocation(trap.TrapOrigin), s.GetLocation(target), BASE_ITEM_DART, PROJECTILE_PATH_TYPE_HOMING, OVERRIDE_ATTACK_RESULT_HIT_SUCCESSFUL, 0); fShotDelay += 0.1f; c++; } } if ((trap.DamageType & DAMAGE_TYPE_POSITIVE) == DAMAGE_TYPE_POSITIVE) { s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.EffectBeam(VFX_BEAM_HOLY, trap.TrapOrigin, BODY_NODE_CHEST, FALSE), target, 1.0f); } if ((trap.DamageType & DAMAGE_TYPE_SLASHING) == DAMAGE_TYPE_SLASHING) { s.SpawnItemProjectile(trap.TrapOrigin, target, s.GetLocation(trap.TrapOrigin), s.GetLocation(target), BASE_ITEM_THROWINGAXE, PROJECTILE_PATH_TYPE_HOMING, OVERRIDE_ATTACK_RESULT_HIT_SUCCESSFUL, 0); float fShotDelay = 0.1f; int c = 1; while (c < trap.DiceNumber) { s.SpawnItemProjectile(trap.TrapOrigin, target, s.GetLocation(trap.TrapOrigin), s.GetLocation(target), BASE_ITEM_THROWINGAXE, PROJECTILE_PATH_TYPE_HOMING, OVERRIDE_ATTACK_RESULT_HIT_SUCCESSFUL, 0); fShotDelay += 0.1f; c++; } } if ((trap.DamageType & DAMAGE_TYPE_SONIC) == DAMAGE_TYPE_SONIC) { s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.EffectBeam(VFX_BEAM_SONIC, trap.TrapOrigin, BODY_NODE_CHEST, FALSE), target, 1.0f); } } else { // These are pretty much single-target effects. if ((trap.DamageType & DAMAGE_TYPE_ACID) == DAMAGE_TYPE_ACID) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_IMP_ACID_S, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_BLUDGEONING) == DAMAGE_TYPE_BLUDGEONING) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_COM_BLOOD_CRT_RED, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_COLD) == DAMAGE_TYPE_COLD) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_IMP_FROST_L, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_DIVINE) == DAMAGE_TYPE_DIVINE) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_COM_HIT_DIVINE, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_ELECTRICAL) == DAMAGE_TYPE_ELECTRICAL) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_IMP_LIGHTNING_S, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_FIRE) == DAMAGE_TYPE_FIRE) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_IMP_FLAME_S, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_MAGICAL) == DAMAGE_TYPE_MAGICAL) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_IMP_MAGBLUE, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_NEGATIVE) == DAMAGE_TYPE_NEGATIVE) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_IMP_NEGATIVE_ENERGY, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_PIERCING) == DAMAGE_TYPE_PIERCING) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_IMP_SPIKE_TRAP, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_POSITIVE) == DAMAGE_TYPE_POSITIVE) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_IMP_SUNSTRIKE, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_SLASHING) == DAMAGE_TYPE_SLASHING) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_COM_BLOOD_CRT_RED, FALSE), target, 0.0f); } if ((trap.DamageType & DAMAGE_TYPE_SONIC) == DAMAGE_TYPE_SONIC) { s.ApplyEffectToObject(DURATION_TYPE_INSTANT, s.EffectVisualEffect(VFX_IMP_SONIC, FALSE), target, 0.0f); } } } else { return; } }
public static void DrawObjects(CLRScriptBase script, User currentUser, uint currentArea) { float fDelay = 0.1f; List <uint> ChooserAoEs = new List <uint>(); List <uint> ChooserCreatures = new List <uint>(); List <uint> ChooserDoors = new List <uint>(); List <uint> ChooserItems = new List <uint>(); List <uint> ChooserLights = new List <uint>(); List <uint> ChooserPlaceables = new List <uint>(); List <uint> ChooserPlacedEffects = new List <uint>(); List <uint> ChooserStores = new List <uint>(); List <uint> ChooserTriggers = new List <uint>(); List <uint> ChooserWaypoints = new List <uint>(); script.DelayCommand(fDelay, delegate { foreach (uint thing in script.GetObjectsInArea(currentArea)) { int objectType = script.GetObjectType(thing); switch (objectType) { case OBJECT_TYPE_AREA_OF_EFFECT: ChooserAoEs.Add(thing); break; case OBJECT_TYPE_CREATURE: ChooserCreatures.Add(thing); break; case OBJECT_TYPE_DOOR: ChooserDoors.Add(thing); break; case OBJECT_TYPE_ITEM: ChooserItems.Add(thing); break; case OBJECT_TYPE_LIGHT: ChooserLights.Add(thing); break; case OBJECT_TYPE_PLACEABLE: ChooserPlaceables.Add(thing); break; case OBJECT_TYPE_PLACED_EFFECT: ChooserPlacedEffects.Add(thing); break; case OBJECT_TYPE_STORE: ChooserStores.Add(thing); break; case OBJECT_TYPE_TRIGGER: ChooserTriggers.Add(thing); break; case OBJECT_TYPE_WAYPOINT: ChooserWaypoints.Add(thing); break; } } script.ClearListBox(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS"); if (ChooserAoEs.Count > 0 && currentUser.ChooserShowAOE) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserAoEs) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetTag(thing), "LISTBOX_ITEM_ICON=trap.tga", "5=" + thing.ToString(), ""); } }); } if (ChooserCreatures.Count > 0 && currentUser.ChooserShowCreature) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserCreatures) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing), "LISTBOX_ITEM_ICON=creature.tga", "5=" + thing.ToString(), ""); } }); } if (ChooserDoors.Count > 0 && currentUser.ChooserShowDoor) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserDoors) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing), "LISTBOX_ITEM_ICON=door.tga", "5=" + thing.ToString(), ""); } }); } if (ChooserItems.Count > 0 && currentUser.ChooserShowItem) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserItems) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing), "LISTBOX_ITEM_ICON=item.tga", "5=" + thing.ToString(), ""); } }); } if (ChooserLights.Count > 0 && currentUser.ChooserShowLight) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserLights) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing) + ";LISTBOX_ITEM_TEXT2= Light", "LISTBOX_ITEM_ICON=light.tga", "5=" + thing.ToString(), ""); } }); } if (ChooserPlaceables.Count > 0 && currentUser.ChooserShowPlaceable) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserPlaceables) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing) + ";LISTBOX_ITEM_TEXT2= Placeable", "LISTBOX_ITEM_ICON=placeable.tga", "5=" + thing.ToString(), ""); } }); } if (ChooserPlacedEffects.Count > 0 && currentUser.ChooserShowPlacedEffect) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserPlacedEffects) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing) + ";LISTBOX_ITEM_TEXT2= Placed Effect", "LISTBOX_ITEM_ICON=vfx.tga", "5=" + thing.ToString(), ""); } }); } if (ChooserStores.Count > 0 && currentUser.ChooserShowStore) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserStores) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing) + ";LISTBOX_ITEM_TEXT2= Store", "LISTBOX_ITEM_ICON=store.tga", "5=" + thing.ToString(), ""); } }); } if (ChooserTriggers.Count > 0 && currentUser.ChooserShowTrigger) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserTriggers) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing) + ";LISTBOX_ITEM_TEXT2= Trigger", "LISTBOX_ITEM_ICON=trigger.tga", "5=" + thing.ToString(), ""); } }); } if (ChooserWaypoints.Count > 0 && currentUser.ChooserShowWaypoint) { fDelay += 0.1f; script.DelayCommand(fDelay, delegate { foreach (uint thing in ChooserWaypoints) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_CHOOSER_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing) + ";LISTBOX_ITEM_TEXT2= Waypoint", "LISTBOX_ITEM_ICON=waypoint.tga", "5=" + thing.ToString(), ""); } }); } }); }
public static void MountHorse(CLRScriptBase script, uint Character, uint Horse) { if (!isWarhorse.ContainsKey(Character)) { isWarhorse.Add(Character, true); } string cloakResRef; switch (script.GetTag(Horse)) { case "abr_cr_an_horse01": cloakResRef = "acr_ooc_horse01"; isWarhorse[Character] = true; break; case "abr_cr_an_horse02": cloakResRef = "acr_ooc_horse02"; isWarhorse[Character] = true; break; case "abr_cr_an_horse03": cloakResRef = "acr_ooc_horse03"; isWarhorse[Character] = true; break; default: cloakResRef = "acr_ooc_horse03"; isWarhorse[Character] = true; break; } uint horseCloak = script.CreateItemOnObject(cloakResRef, Character, 1, "", CLRScriptBase.FALSE); if (script.GetLocalInt(Horse, ACR_IS_WARHORSE) == 1) { script.RemoveHenchman(Character, Horse); script.SetLocalInt(horseCloak, ACR_IS_WARHORSE, 1); } script.SetLocalInt(horseCloak, ACR_HORSE_ID, script.GetLocalInt(Horse, ACR_HORSE_ID)); script.SetLocalInt(horseCloak, ACR_HORSE_HP, script.GetCurrentHitPoints(Horse)); uint equippedCloak = script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CLOAK, Character); if (script.GetIsObjectValid(equippedCloak) == CLRScriptBase.TRUE) { foreach (NWItemProperty prop in script.GetItemPropertiesOnItem(equippedCloak)) { // copying property duration type prevents us from turning temporary properties into // permanent ones. But because we don't know how long the non-permanent ones have left, // we pretty much have to assign them with the expectation that they immediately expire. script.AddItemProperty(script.GetItemPropertyDurationType(prop), prop, horseCloak, 0.0f); } script.SetFirstName(horseCloak, script.GetName(equippedCloak) + "(( Horse Appearance ))"); script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertyWeightReduction(CLRScriptBase.IP_CONST_REDUCEDWEIGHT_80_PERCENT), horseCloak, 0.0f); } script.SetPlotFlag(horseCloak, CLRScriptBase.TRUE); script.SetPlotFlag(Horse, CLRScriptBase.FALSE); script.AssignCommand(Horse, delegate { script.SetIsDestroyable(CLRScriptBase.TRUE, CLRScriptBase.FALSE, CLRScriptBase.FALSE); }); script.AssignCommand(Horse, delegate { script.DestroyObject(Horse, 0.0f, CLRScriptBase.FALSE); }); script.AssignCommand(Character, delegate { script.ActionEquipItem(horseCloak, CLRScriptBase.INVENTORY_SLOT_CLOAK); }); if (!isWarhorse[Character]) { script.DelayCommand(6.0f, delegate { RidingHeartbeat(script, Character); }); } }
public void SpawnOneAtTier(CLRScriptBase s) { string Area = s.GetTag(s.GetArea(s.OBJECT_SELF)); int Tier = InfestedAreaLevels[Area]; if (Tier == MaxArea) { if (!RecentBossSpawn) { if (s.d20(1) == 1) { RecentBossSpawn = true; s.DelayCommand(s.HoursToSeconds(12), delegate { RecentBossSpawn = false; }); if (BossTemplate != String.Empty) { uint spawn = Spawn.SpawnCreature(BossTemplate, s); s.SetLocalString(spawn, InfestNameVar, this.InfestationName); s.SetLocalInt(spawn, InfestBossVar, 1); } } } else if (!RecentMiniBossSpawn) { if (s.d10(1) == 1) { RecentMiniBossSpawn = true; s.DelayCommand(s.HoursToSeconds(4), delegate { RecentMiniBossSpawn = false; }); if (MiniBoss.Count > 0) { int spawnNumber = new Random().Next(0, MiniBoss.Count); uint spawn = Spawn.SpawnCreature(MiniBoss[spawnNumber], s); s.SetLocalString(spawn, InfestNameVar, this.InfestationName); s.SetLocalInt(spawn, InfestBossVar, 1); } } } } int spawnNum = 1; int spawnTier = Tier; if (Tier == 2) { if (s.d2(1) == 1) { spawnNum = s.d3(1); spawnTier = 1; } } else if (Tier > 2) { switch (s.d3(1)) { case 1: spawnNum = s.d3(1); spawnTier--; break; case 2: spawnNum = s.d4(1) + 1; spawnTier -= 2; break; } } while (spawnNum > 0) { string rand = GetRandomSpawnAtTier(spawnTier); if (rand != "") { uint spawn = Spawn.SpawnCreature(rand, s); s.SetLocalString(spawn, InfestNameVar, this.InfestationName); } spawnNum -= 1; } }