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; }
private static NWEffect GetTrapEffect(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, uint target) { int damage = 0; for (int count = 0; count < trap.DiceNumber; count++) { damage += s.Random(trap.DiceType) + 1; } if (trap.SaveDC > -1) { if (s.ReflexSave(target, trap.SaveDC, SAVING_THROW_TYPE_TRAP, s.GetObjectByTag(trap.Tag, 0)) != TRUE) { if (s.GetHasFeat(FEAT_IMPROVED_EVASION, target, TRUE) == TRUE) damage /= 2; } else { if (s.GetHasFeat(FEAT_EVASION, target, TRUE) == TRUE) damage = 0; else damage /= 2; } } else { int roll = new Random().Next(20) + 1; int final = roll + trap.AttackBonus; string hitormiss = " *hit* "; if (final < s.GetAC(target, FALSE) && roll != 20) { hitormiss = " *miss* "; damage = 0; } s.SendMessageToPC(target, "<C=DarkViolet>Trap</C><C=DarkOrange> attacks " + s.GetName(target) + ":" + hitormiss + ": " + roll + " + " + trap.AttackBonus + " = " + final); } NWEffect eVis = s.EffectVisualEffect(VFX_COM_HIT_DIVINE, FALSE); List<int> damageTypes = new List<int>(); if ((trap.DamageType & DAMAGE_TYPE_ACID) == DAMAGE_TYPE_ACID) { damageTypes.Add(DAMAGE_TYPE_ACID); eVis = s.EffectVisualEffect(VFX_COM_HIT_ACID, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_BLUDGEONING) == DAMAGE_TYPE_BLUDGEONING) { damageTypes.Add(DAMAGE_TYPE_BLUDGEONING); eVis = s.EffectVisualEffect(VFX_COM_BLOOD_CRT_RED, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_COLD) == DAMAGE_TYPE_COLD) { damageTypes.Add(DAMAGE_TYPE_COLD); eVis = s.EffectVisualEffect(VFX_COM_HIT_FROST, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_DIVINE) == DAMAGE_TYPE_DIVINE) { damageTypes.Add(DAMAGE_TYPE_DIVINE); eVis = s.EffectVisualEffect(VFX_COM_HIT_DIVINE, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_ELECTRICAL) == DAMAGE_TYPE_ELECTRICAL) { damageTypes.Add(DAMAGE_TYPE_ELECTRICAL); eVis = s.EffectVisualEffect(VFX_COM_HIT_ELECTRICAL, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_FIRE) == DAMAGE_TYPE_FIRE) { damageTypes.Add(DAMAGE_TYPE_FIRE); eVis = s.EffectVisualEffect(VFX_COM_HIT_FIRE, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_MAGICAL) == DAMAGE_TYPE_MAGICAL) { damageTypes.Add(DAMAGE_TYPE_MAGICAL); eVis = s.EffectVisualEffect(VFX_COM_HIT_DIVINE, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_NEGATIVE) == DAMAGE_TYPE_NEGATIVE) { damageTypes.Add(DAMAGE_TYPE_NEGATIVE); eVis = s.EffectVisualEffect(VFX_COM_HIT_NEGATIVE, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_PIERCING) == DAMAGE_TYPE_PIERCING) { damageTypes.Add(DAMAGE_TYPE_PIERCING); eVis = s.EffectVisualEffect(VFX_COM_BLOOD_CRT_RED, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_POSITIVE) == DAMAGE_TYPE_POSITIVE) { damageTypes.Add(DAMAGE_TYPE_POSITIVE); eVis = s.EffectVisualEffect(VFX_COM_HIT_DIVINE, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_SLASHING) == DAMAGE_TYPE_SLASHING) { damageTypes.Add(DAMAGE_TYPE_SLASHING); eVis = s.EffectVisualEffect(VFX_COM_BLOOD_CRT_RED, FALSE); } if ((trap.DamageType & DAMAGE_TYPE_SONIC) == DAMAGE_TYPE_SONIC) { damageTypes.Add(DAMAGE_TYPE_SONIC); eVis = s.EffectVisualEffect(VFX_COM_HIT_SONIC, FALSE); } if (damage == 0) { return eVis; } NWEffect eDam = eVis; damage /= damageTypes.Count; if (damage < 1) damage = 1; foreach (int dmgType in damageTypes) { eDam = s.EffectLinkEffects(eDam, s.EffectDamage(damage, dmgType, DAMAGE_POWER_NORMAL, FALSE)); } return eDam; }
private bool _GetIsProficient(CLRScriptBase script, uint item) { int baseItem = script.GetBaseItemType(item); if (baseItem == CLRScriptBase.BASE_ITEM_INVALID) return false; // this doesn't even look like a real item. ALFA.Shared.BaseItem itemType = ALFA.Shared.Modules.InfoStore.BaseItems[baseItem]; if (itemType.ReqFeat0 != 0 && script.GetHasFeat(itemType.ReqFeat0, this.ObjectId, CLRScriptBase.TRUE) == CLRScriptBase.TRUE) return true; if (itemType.ReqFeat1 != 0 && script.GetHasFeat(itemType.ReqFeat1, this.ObjectId, CLRScriptBase.TRUE) == CLRScriptBase.TRUE) return true; if (itemType.ReqFeat2 != 0 && script.GetHasFeat(itemType.ReqFeat2, this.ObjectId, CLRScriptBase.TRUE) == CLRScriptBase.TRUE) return true; if (itemType.ReqFeat3 != 0 && script.GetHasFeat(itemType.ReqFeat3, this.ObjectId, CLRScriptBase.TRUE) == CLRScriptBase.TRUE) return true; if (itemType.ReqFeat4 != 0 && script.GetHasFeat(itemType.ReqFeat4, this.ObjectId, CLRScriptBase.TRUE) == CLRScriptBase.TRUE) return true; if (itemType.ReqFeat5 != 0 && script.GetHasFeat(itemType.ReqFeat5, this.ObjectId, CLRScriptBase.TRUE) == CLRScriptBase.TRUE) return true; return false; }
public static void RecalculateMovement(CLRScriptBase script, uint Creature) { int appType = GetBaseAppearance(script, Creature); if (appType < 0) { return; } if(overlandMap[Creature]) { if(characterMovement[Creature] == MovementType.Riding) { appType += Ride_02; script.SetCreatureAppearanceType(Creature, appType); return; } else { appType += Walk_01; script.SetCreatureAppearanceType(Creature, appType); return; } } else if(characterMovement[Creature] == MovementType.Riding) { appType += Ride_12; script.SetCreatureAppearanceType(Creature, appType); return; } else if (characterMovement[Creature] == MovementType.Swimming) { appType += Swim; script.SetCreatureAppearanceType(Creature, appType); return; } else { int moveRate = 10; if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_BARBARIAN, Creature) >= 1) { // Barbarians get +0.4m/s when not wearing heavy armor and not carrying a heavy load. if (script.GetEncumbranceState(Creature) != CLRScriptBase.ENCUMBRANCE_STATE_OVERLOADED && script.GetArmorRank(script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CHEST, Creature)) != CLRScriptBase.ARMOR_RANK_HEAVY) { moveRate += 1; } } if(script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 3) { // Unarmored monks get +0.4m/s of movement for every 3 levels, up to level 18. if(script.GetEncumbranceState(Creature) != CLRScriptBase.ENCUMBRANCE_STATE_HEAVY && script.GetEncumbranceState(Creature) != CLRScriptBase.ENCUMBRANCE_STATE_OVERLOADED && script.GetArmorRank(script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CHEST, Creature)) == CLRScriptBase.ARMOR_RANK_NONE) { if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 18) moveRate++; if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 15) moveRate++; if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 12) moveRate++; if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 9) moveRate++; if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 6) moveRate++; moveRate++; } } if(script.GetHasFeat(CLRScriptBase.FEAT_NW9_FRANTIC_REACTIONS, Creature, CLRScriptBase.TRUE) == CLRScriptBase.TRUE) { // Level 3+ knight protectors have frantic reactions, and thus +0.4m/s moveRate++; } switch (moveRate) { case 10: appType += Walk_10; break; case 11: appType += Walk_11; break; case 12: appType += Walk_12; break; case 13: appType += Walk_13; break; case 14: appType += Walk_14; break; case 15: appType += Walk_15; break; case 16: appType += Walk_16; break; case 17: appType += Walk_17; break; case 18: appType += Walk_18; break; case 19: appType += Walk_19; break; case 20: appType += Walk_20; break; case 21: appType += Walk_21; break; case 22: appType += Walk_22; break; } if(script.GetHasFeat(CLRScriptBase.FEAT_MONK_ENDURANCE, Creature, CLRScriptBase.TRUE) == CLRScriptBase.TRUE) { script.FeatRemove(Creature, CLRScriptBase.FEAT_MONK_ENDURANCE); script.FeatAdd(Creature, 3742, CLRScriptBase.FALSE, CLRScriptBase.FALSE, CLRScriptBase.FALSE); } if(script.GetHasFeat(CLRScriptBase.FEAT_BARBARIAN_ENDURANCE, Creature, CLRScriptBase.TRUE) == CLRScriptBase.TRUE) { script.FeatRemove(Creature, CLRScriptBase.FEAT_BARBARIAN_ENDURANCE); script.FeatAdd(Creature, 3743, CLRScriptBase.FALSE, CLRScriptBase.FALSE, CLRScriptBase.FALSE); } script.SetCreatureAppearanceType(Creature, appType); return; } }