private uint getHide( CLRScriptBase script ) { uint oHide = script.GetItemPossessedBy(m_oCreature, "acr_pchide"); if (script.GetIsObjectValid(oHide) == CLRScriptBase.FALSE) { oHide = script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CARMOUR, m_oCreature); if (script.GetIsObjectValid(oHide) == CLRScriptBase.FALSE || script.GetResRef(oHide) != "acr_pchide") { oHide = CLRScriptBase.OBJECT_INVALID; } } return oHide; }
public bool clear(CLRScriptBase script) { if (script.GetIsObjectValid(m_oCreature) == CLRScriptBase.FALSE || script.GetIsObjectValid(m_oCreature) == CLRScriptBase.FALSE) { return false; } uint oOldHide = getHide(script); foreach(ItemProperty prop in script.GetItemPropertiesOnItem(oOldHide)) { if (script.GetItemPropertyDurationType(prop) == CLRScriptBase.DURATION_TYPE_PERMANENT) { script.RemoveItemProperty(oOldHide, prop); } } script.SendMessageToPC(m_oCreature, "PC Hide refreshed."); return true; }
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 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); } } } }
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; }
public static int GetWealthMultiplierInt(CLRScriptBase script, uint Character, bool CombatDrop) { if (script.GetIsPC(Character) == CLRScriptBase.FALSE) return 0; int lootValue = GetTotalValueOfKit(script, Character); int level = GetEffectiveLevel(script, Character); int retVal = 4000; // very poor level 20. No multiplier should be more than this. if (recentlyDroppedItems.ContainsKey(Character)) { List<uint> checkedPCs = new List<uint>(); List<uint> removedItems = new List<uint>(); checkedPCs.Add(Character); // We already checked the PC outside of this loop. uint partyMate = script.GetFirstFactionMember(Character, CLRScriptBase.TRUE); while (script.GetIsObjectValid(partyMate) == CLRScriptBase.TRUE) { if(!checkedPCs.Contains(partyMate)) { checkedPCs.Add(partyMate); int tempMult = WealthToMultiplier(GetTotalValueOfKit(script, partyMate), GetEffectiveLevel(script, partyMate), CombatDrop); if (tempMult < retVal) retVal = tempMult; } partyMate = script.GetNextFactionMember(Character, CLRScriptBase.TRUE); } foreach (uint Item in recentlyDroppedItems[Character]) { if (script.GetIsObjectValid(Item) == CLRScriptBase.TRUE) { if(!checkedPCs.Contains(script.GetItemPossessor(Item))) { uint itemOwner = script.GetItemPossessor(Item); if (script.GetIsObjectValid(itemOwner) != CLRScriptBase.FALSE) { // Remember that this might be OBJECT_INVALID, if it's just on the // ground. checkedPCs.Add(itemOwner); } if(script.GetIsPC(itemOwner) != CLRScriptBase.FALSE) { int tempMult = WealthToMultiplier(GetTotalValueOfKit(script, itemOwner), GetEffectiveLevel(script, itemOwner), CombatDrop); if (tempMult < retVal) retVal = tempMult; } else if(script.GetObjectType(itemOwner) != CLRScriptBase.OBJECT_TYPE_STORE) { lootValue += script.GetGoldPieceValue(Item); } } } else { removedItems.Add(Item); } } foreach(uint Item in removedItems) { recentlyDroppedItems[Character].Remove(Item); } } int chaMult = WealthToMultiplier(lootValue, level, CombatDrop); if (chaMult < retVal) retVal = chaMult; return retVal; }
public static int GetTotalValueOfKit(CLRScriptBase script, uint Character) { int lootValue = 0; foreach (uint item in script.GetItemsInInventory(Character)) { lootValue += script.GetGoldPieceValue(item); } lootValue += script.GetGold(Character); for (int slot = 0; slot < 14; slot++) { uint equip = script.GetItemInSlot(slot, Character); if (script.GetIsObjectValid(equip) == CLRScriptBase.TRUE) { lootValue += script.GetGoldPieceValue(equip); } } if (pChestAccess.ContainsKey(Character)) { foreach (string chest in pChestAccess[Character]) { lootValue += pChestValues[chest]; } } return lootValue; }
public void TransitionToArea(CLRScriptBase script, ExitDirection exit) { string doorTag = "DOOR_NORTH"; switch(exit) { case ExitDirection.North: doorTag = "DOOR_NORTH"; break; case ExitDirection.East: doorTag = "DOOR_EAST"; break; case ExitDirection.South: doorTag = "DOOR_SOUTH"; break; case ExitDirection.West: doorTag = "DOOR_WEST"; break; case ExitDirection.Up: doorTag = "DOOR_UP"; break; case ExitDirection.Down: doorTag = "DOOR_DOWN"; break; } if(script.GetIsObjectValid(script.GetLocalObject(AreaId, doorTag)) == CLRScriptBase.TRUE) { uint door = script.GetLocalObject(AreaId, doorTag); script.JumpToObject(door, CLRScriptBase.TRUE); return; } foreach(uint obj in script.GetObjectsInArea(AreaId)) { if(script.GetTag(obj) == doorTag) { script.SetLocalObject(AreaId, doorTag, obj); script.JumpToObject(obj, CLRScriptBase.TRUE); return; } } script.SendMessageToPC(script.OBJECT_SELF, "I can't find a door to jump you to."); }
public bool recalculate(CLRScriptBase script) { // Ensure that both our hide and our creature are still valid. if (script.GetIsObjectValid(m_oCreature) == CLRScriptBase.FALSE || script.GetIsObjectValid(m_oCreature) == CLRScriptBase.FALSE) { return false; } // Recreate the hide. script.AssignCommand(m_oCreature, delegate { script.ClearAllActions(CLRScriptBase.FALSE); }); uint oOldHide = getHide(script); m_oHide = script.CreateItemOnObject("acr_pchide", m_oCreature, 1, "acr_pchide", CLRScriptBase.FALSE); // Temp variables to store bonuses, to allow stacking from different sources. Dictionary<int, int> saveBonuses = new Dictionary<int, int>(); Dictionary<int, int> skillBonuses = new Dictionary<int, int>(); Dictionary<string, int> otherBonuses = new Dictionary<string, int>(); // Initialize dictionaries. for (int i = 0; i < 68; i++) { skillBonuses.Add(i, 0); } for (int i = 0; i < 4; i++) { saveBonuses.Add(i, 0); } #region Skill Focus feats // Handle all new shiny skill focus feats. if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_BALANCE, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_BALANCE] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CLIMB, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CLIMB] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CRFT_ALCH, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CRAFT_ALCHEMY] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CRFT_ARM, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CRAFT_ARMORSMITHING] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CRFT_BOW, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CRAFT_BOWMAKING] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CRFT_WPN, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CRAFT_WEAPONSMITHING] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_DECIPHER, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_DECIPHER_SCRIPT] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_DISGUISE, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_DISGUISE] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_ESC_ART, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_ESCAPE_ARTIST] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_HAND_ANIM, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_HANDLE_ANIMAL] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_JUMP, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_JUMP] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_ARC, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_ARCANA] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_DUNG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_DUNGEONEERING] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_ENG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_ENGINEERING] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_GEO, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_GEOGRAPHY] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_HIST, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_HISTORY] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_LOC, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_LOCAL] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_NATR, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_NATURE] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_NOBL, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_NOBILITY] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_PLAN, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_THE_PLANES] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_RELG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_RELIGION] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_ACT, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_ACT] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_COMD, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_COMEDY] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_DANC, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_DANCE] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_KEYB, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_KEYBOARD] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_ORAT, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_ORATORY] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_PERC, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_PERCUSSION] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_SING, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_SING] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_STRG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_STRING_INSTRUMENTS] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_WIND, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_WIND_INSTRUMENTS] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PROF, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PROFESSION] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_RIDE, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_RIDE] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_SENS_MOTV, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_SPEAK_LANGUAGE] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_SPK_LANG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_LOCAL] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_SWIM, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_SWIM] += 3; if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_USE_ROPE, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_USE_ROPE] += 3; #endregion // Artist is one bad-ass feat. if (script.GetHasFeat(CLRScriptBase.FEAT_ARTIST, m_oCreature, 1) == CLRScriptBase.TRUE) { // Previously: +2 perform, +2 diplomacy // Currently: +2 perform (all), 3 extra bardic music uses per day skillBonuses[CLRScriptBase.SKILL_DIPLOMACY] -= 2; skillBonuses[(int)SKILLS.SKILL_PERFORM_ACT] += 2; skillBonuses[(int)SKILLS.SKILL_PERFORM_COMEDY] += 2; skillBonuses[(int)SKILLS.SKILL_PERFORM_DANCE] += 2; skillBonuses[(int)SKILLS.SKILL_PERFORM_KEYBOARD] += 2; skillBonuses[(int)SKILLS.SKILL_PERFORM_ORATORY] += 2; skillBonuses[(int)SKILLS.SKILL_PERFORM_PERCUSSION] += 2; skillBonuses[(int)SKILLS.SKILL_PERFORM_SING] += 2; skillBonuses[(int)SKILLS.SKILL_PERFORM_STRING_INSTRUMENTS] += 2; skillBonuses[(int)SKILLS.SKILL_PERFORM_WIND_INSTRUMENTS] += 2; } // Add skill bonuses to item. foreach (int skill in skillBonuses.Keys) { if (skillBonuses[skill] == 0) { continue; } else if (skillBonuses[skill] > 0) { script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skill, skillBonuses[skill]), m_oHide, 0.0f); } else if (skillBonuses[skill] < 0) { script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertyDecreaseSkill(skill, Math.Abs(skillBonuses[skill])), m_oHide, 0.0f); } } // Add save bonuses to item. foreach (int save in saveBonuses.Keys) { if (saveBonuses[save] == 0) { continue; } else if (saveBonuses[save] > 0) { script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrow(save, saveBonuses[save]), m_oHide, 0.0f); } else if (saveBonuses[save] < 0) { script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertyReducedSavingThrow(save, Math.Abs(saveBonuses[save])), m_oHide, 0.0f); } } // Make the person equip the new item. script.AssignCommand(m_oCreature, delegate { script.ClearAllActions(CLRScriptBase.FALSE); }); script.AssignCommand(m_oCreature, delegate { script.ActionEquipItem(m_oHide, CLRScriptBase.INVENTORY_SLOT_CARMOUR); }); script.DestroyObject(oOldHide, 0.0f, CLRScriptBase.FALSE); script.SendMessageToPC(m_oCreature, "PC Hide refreshed."); // Everything looks fine, return our success. return true; }
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); }); }
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 static void DrawLimbo(CLRScriptBase script, User currentUser) { script.ClearListBox(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_LIMBO_OBJECTS"); int max = script.GetLimboCreatureCount(); int count = 0; while (count < max) { uint thing = script.GetCreatureInLimbo(count); if (script.GetIsObjectValid(thing) == TRUE) { script.AddListBoxRow(currentUser.Id, "SCREEN_DMC_CHOOSER", "LISTBOX_ACR_LIMBO_OBJECTS", thing.ToString(), "LISTBOX_ITEM_TEXT= " + script.GetName(thing), "LISTBOX_ITEM_ICON=creature.tga", "5=" + thing.ToString(), ""); } count++; } }
private static void ProcessWaterEffects(CLRScriptBase script, uint Creature, uint Trigger) { if(script.GetIsImmune(Creature, CLRScriptBase.IMMUNITY_TYPE_MOVEMENT_SPEED_DECREASE, Trigger) != CLRScriptBase.FALSE) { return; } uint weapon = script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_RIGHTHAND, Creature); if (script.GetIsObjectValid(weapon) == CLRScriptBase.TRUE) { int weaponType = script.GetBaseItemType(weapon); if (ALFA.Shared.Modules.InfoStore.BaseItems[weaponType].WeaponType != 1 && ALFA.Shared.Modules.InfoStore.BaseItems[weaponType].WeaponType != 0) // unfortunately, this is magic numbered in the 2da as well { script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectAttackDecrease(2, CLRScriptBase.ATTACK_BONUS_ONHAND)), Creature, 6.0f); int damagePenalty = ALFA.Shared.Modules.InfoStore.BaseItems[weaponType].DieToRoll / 4; damagePenalty += script.GetAbilityModifier(CLRScriptBase.ABILITY_STRENGTH, Creature) / 2; int damageType = CLRScriptBase.DAMAGE_TYPE_SLASHING; switch (ALFA.Shared.Modules.InfoStore.BaseItems[weaponType].WeaponType) { case 2: damageType = CLRScriptBase.DAMAGE_TYPE_BLUDGEONING; break; case 3: damageType = CLRScriptBase.DAMAGE_TYPE_SLASHING; break; case 4: damageType = CLRScriptBase.DAMAGE_TYPE_SLASHING; break; case 5: damageType = CLRScriptBase.DAMAGE_TYPE_BLUDGEONING; break; } script.EffectDamageDecrease(damagePenalty, damageType); } weapon = script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_LEFTHAND, Creature); if (script.GetIsObjectValid(weapon) == CLRScriptBase.TRUE) { weaponType = script.GetBaseItemType(weapon); if (ALFA.Shared.Modules.InfoStore.BaseItems[weaponType].WeaponType != 1 && ALFA.Shared.Modules.InfoStore.BaseItems[weaponType].WeaponType != 0) // unfortunately, this is magic numbered in the 2da as well { script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectAttackDecrease(2, CLRScriptBase.ATTACK_BONUS_OFFHAND)), Creature, 6.0f); } } } else { script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectAttackDecrease(2, CLRScriptBase.ATTACK_BONUS_ONHAND)), Creature, 6.0f); int damagePenalty = 1 + script.GetAbilityModifier(CLRScriptBase.ABILITY_STRENGTH, Creature) / 2; if(damagePenalty > 0) { script.EffectDamageDecrease(damagePenalty, CLRScriptBase.DAMAGE_TYPE_BLUDGEONING); } } }
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; }
public static uint GetOwnershipItemById(CLRScriptBase script, uint Character, int HorseId) { uint item = script.GetFirstItemInInventory(Character); while(script.GetIsObjectValid(item) == CLRScriptBase.TRUE) { if(script.GetLocalInt(item, ACR_HORSE_ID) == HorseId) { return item; } item = script.GetNextItemInInventory(Character); } return CLRScriptBase.OBJECT_INVALID; }