public bool ReducesItemCharge(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { return(false); }
public void OnCustomEnmityRule(NWCreature creature, int amount) { }
public string CanCastSpell(NWCreature oPC, NWObject oTarget, int spellTier) { return(string.Empty); }
public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier) { }
public void OnRemoved(NWCreature creature) { }
public int FPCost(NWCreature oPC, int baseFPCost, int spellTier) { return(baseFPCost); }
public float CooldownTime(NWCreature oPC, float baseCooldownTime, int spellTier) { return(baseCooldownTime); }
private void ApplyPCEffect(NWCreature caster, NWCreature target, int customEffectID, int ticks, int effectiveLevel, string data) { Data.Entity.CustomEffect customEffect = _data.Single <Data.Entity.CustomEffect>(x => x.ID == customEffectID); PCCustomEffect pcEffect = _data.SingleOrDefault <PCCustomEffect>(x => x.PlayerID == target.GlobalID && x.CustomEffectID == customEffectID); CustomEffectCategoryType category = (CustomEffectCategoryType)customEffect.CustomEffectCategoryID; if (category == CustomEffectCategoryType.FoodEffect) { var customEffectPC = _data.Get <Data.Entity.CustomEffect>(pcEffect.CustomEffectID); if (pcEffect != null && customEffectPC.CustomEffectCategoryID == (int)category) { caster.SendMessage("You are not hungry."); return; } } DatabaseActionType action = DatabaseActionType.Update; if (pcEffect == null) { pcEffect = new PCCustomEffect { PlayerID = target.GlobalID }; action = DatabaseActionType.Insert; } if (pcEffect.EffectiveLevel > effectiveLevel) { caster.SendMessage("A more powerful effect already exists on your target."); return; } pcEffect.CustomEffectID = customEffectID; pcEffect.EffectiveLevel = effectiveLevel; pcEffect.Ticks = ticks; pcEffect.CasterNWNObjectID = _.ObjectToString(caster); _data.SubmitDataChange(pcEffect, action); target.SendMessage(customEffect.StartMessage); App.ResolveByInterface <ICustomEffect>("CustomEffect." + customEffect.ScriptHandler, handler => { if (string.IsNullOrWhiteSpace(data)) { data = handler?.Apply(caster, target, effectiveLevel); } if (string.IsNullOrWhiteSpace(data)) { data = string.Empty; } pcEffect.Data = data; _data.SubmitDataChange(pcEffect, DatabaseActionType.Update); // Was already queued for removal, but got cast again. Take it out of the list to be removed. if (_cache.PCEffectsForRemoval.Contains(pcEffect.ID)) { _cache.PCEffectsForRemoval.Remove(pcEffect.ID); } }); }
public void ApplyCustomEffect(NWCreature caster, NWCreature target, CustomEffectType effectType, int ticks, int level, string data) { ApplyCustomEffect(caster, target, (int)effectType, ticks, level, data); }
private void ApplyFeatChanges(NWCreature creature, NWItem oItem) { NWItem equipped = oItem ?? creature.RightHand; RemoveAllFeats(creature); // Unarmed check NWItem mainHand = creature.RightHand; NWItem offHand = creature.LeftHand; if (oItem != null && Equals(oItem, mainHand)) { mainHand = (new NWGameObject()); } else if (oItem != null && Equals(oItem, offHand)) { offHand = (new NWGameObject()); } if (!mainHand.IsValid && !offHand.IsValid) { if (PerkService.GetCreaturePerkLevel(creature, PerkType.ImprovedCriticalMartialArts) > 0) { NWNXCreature.AddFeat(creature, FEAT_IMPROVED_CRITICAL_UNARMED_STRIKE); } return; } if (oItem != null && Equals(oItem, equipped)) { return; } // All other weapon types PerkType perkType; switch (equipped.CustomItemType) { case CustomItemType.Vibroblade: perkType = PerkType.ImprovedCriticalVibroblades; break; case CustomItemType.FinesseVibroblade: perkType = PerkType.ImprovedCriticalFinesseVibroblades; break; case CustomItemType.Baton: perkType = PerkType.ImprovedCriticalBatons; break; case CustomItemType.HeavyVibroblade: perkType = PerkType.ImprovedCriticalHeavyVibroblades; break; case CustomItemType.Polearm: perkType = PerkType.ImprovedCriticalPolearms; break; case CustomItemType.TwinBlade: perkType = PerkType.ImprovedCriticalTwinVibroblades; break; case CustomItemType.MartialArtWeapon: perkType = PerkType.ImprovedCriticalMartialArts; break; case CustomItemType.BlasterPistol: perkType = PerkType.ImprovedCriticalBlasterPistols; break; case CustomItemType.BlasterRifle: perkType = PerkType.ImprovedCriticalBlasterRifles; break; case CustomItemType.Throwing: perkType = PerkType.ImprovedCriticalThrowing; break; case CustomItemType.Lightsaber: perkType = PerkType.ImprovedCriticalLightsabers; break; case CustomItemType.Saberstaff: perkType = PerkType.ImprovedCriticalSaberstaffs; break; default: return; } if (equipped.GetLocalInt("LIGHTSABER") == TRUE) { perkType = PerkType.ImprovedCriticalLightsabers; } int perkLevel = PerkService.GetCreaturePerkLevel(creature, perkType); int type = equipped.BaseItemType; if (perkLevel > 0) { AddCriticalFeat(creature, type); } }
public void OnRemoved(NWCreature creature) { NWNXCreature.RemoveFeat(creature, Feat.WeaponFinesse); }
public void OnRemoved(NWCreature creature) { ApplyFeatChanges(creature, null); }
private void AddCriticalFeat(NWCreature creature, int type) { int feat; switch (type) { case (BASE_ITEM_BASTARDSWORD): feat = FEAT_IMPROVED_CRITICAL_BASTARD_SWORD; break; case (BASE_ITEM_BATTLEAXE): feat = FEAT_IMPROVED_CRITICAL_BATTLE_AXE; break; case (BASE_ITEM_CLUB): feat = FEAT_IMPROVED_CRITICAL_CLUB; break; case (BASE_ITEM_DAGGER): feat = FEAT_IMPROVED_CRITICAL_DAGGER; break; case (BASE_ITEM_DART): feat = FEAT_IMPROVED_CRITICAL_DART; break; case (BASE_ITEM_DIREMACE): feat = FEAT_IMPROVED_CRITICAL_DIRE_MACE; break; case (BASE_ITEM_DOUBLEAXE): feat = FEAT_IMPROVED_CRITICAL_DOUBLE_AXE; break; case (BASE_ITEM_DWARVENWARAXE): feat = FEAT_IMPROVED_CRITICAL_DWAXE; break; case (BASE_ITEM_GREATAXE): feat = FEAT_IMPROVED_CRITICAL_GREAT_AXE; break; case (BASE_ITEM_GREATSWORD): feat = FEAT_IMPROVED_CRITICAL_GREAT_SWORD; break; case (BASE_ITEM_HALBERD): feat = FEAT_IMPROVED_CRITICAL_HALBERD; break; case (BASE_ITEM_HANDAXE): feat = FEAT_IMPROVED_CRITICAL_HAND_AXE; break; case (BASE_ITEM_HEAVYCROSSBOW): feat = FEAT_IMPROVED_CRITICAL_HEAVY_CROSSBOW; break; case (BASE_ITEM_HEAVYFLAIL): feat = FEAT_IMPROVED_CRITICAL_HEAVY_FLAIL; break; case (BASE_ITEM_KAMA): feat = FEAT_IMPROVED_CRITICAL_KAMA; break; case (BASE_ITEM_KATANA): feat = FEAT_IMPROVED_CRITICAL_KATANA; break; case (BASE_ITEM_KUKRI): feat = FEAT_IMPROVED_CRITICAL_KUKRI; break; case (BASE_ITEM_LIGHTCROSSBOW): feat = FEAT_IMPROVED_CRITICAL_LIGHT_CROSSBOW; break; case (BASE_ITEM_LIGHTFLAIL): feat = FEAT_IMPROVED_CRITICAL_LIGHT_FLAIL; break; case (BASE_ITEM_LIGHTHAMMER): feat = FEAT_IMPROVED_CRITICAL_LIGHT_HAMMER; break; case (BASE_ITEM_LIGHTMACE): feat = FEAT_IMPROVED_CRITICAL_LIGHT_MACE; break; case (BASE_ITEM_LONGBOW): feat = FEAT_IMPROVED_CRITICAL_LONGBOW; break; case (BASE_ITEM_LONGSWORD): feat = FEAT_IMPROVED_CRITICAL_LONG_SWORD; break; case (BASE_ITEM_MORNINGSTAR): feat = FEAT_IMPROVED_CRITICAL_MORNING_STAR; break; case (BASE_ITEM_RAPIER): feat = FEAT_IMPROVED_CRITICAL_RAPIER; break; case (BASE_ITEM_SCIMITAR): feat = FEAT_IMPROVED_CRITICAL_SCIMITAR; break; case (BASE_ITEM_SCYTHE): feat = FEAT_IMPROVED_CRITICAL_SCYTHE; break; case (BASE_ITEM_SHORTBOW): feat = FEAT_IMPROVED_CRITICAL_SHORTBOW; break; case (BASE_ITEM_SHORTSWORD): feat = FEAT_IMPROVED_CRITICAL_SHORT_SWORD; break; case (BASE_ITEM_SHURIKEN): feat = FEAT_IMPROVED_CRITICAL_SHURIKEN; break; case (BASE_ITEM_SICKLE): feat = FEAT_IMPROVED_CRITICAL_SICKLE; break; case (BASE_ITEM_SLING): feat = FEAT_IMPROVED_CRITICAL_SLING; break; case (BASE_ITEM_SHORTSPEAR): feat = FEAT_IMPROVED_CRITICAL_SPEAR; break; case (BASE_ITEM_QUARTERSTAFF): feat = FEAT_IMPROVED_CRITICAL_STAFF; break; case (BASE_ITEM_THROWINGAXE): feat = FEAT_IMPROVED_CRITICAL_THROWING_AXE; break; case (BASE_ITEM_TRIDENT): feat = FEAT_IMPROVED_CRITICAL_TRIDENT; break; case (BASE_ITEM_TWOBLADEDSWORD): feat = FEAT_IMPROVED_CRITICAL_TWO_BLADED_SWORD; break; case (BASE_ITEM_INVALID): feat = FEAT_IMPROVED_CRITICAL_UNARMED_STRIKE; break; case (BASE_ITEM_WARHAMMER): feat = FEAT_IMPROVED_CRITICAL_WAR_HAMMER; break; case (BASE_ITEM_WHIP): feat = FEAT_IMPROVED_CRITICAL_WHIP; break; case (CustomBaseItemType.Lightsaber): feat = FEAT_IMPROVED_CRITICAL_LONG_SWORD; break; case (CustomBaseItemType.Saberstaff): feat = FEAT_IMPROVED_CRITICAL_TWO_BLADED_SWORD; break; default: return; } NWNXCreature.AddFeat(creature, feat); }
public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation) { return(null); }
public void OnItemEquipped(NWCreature creature, NWItem oItem) { ApplyFeatChanges(creature, null); }
public float CalculateEffectHPBonusPercent(NWCreature creature) { int effectLevel = GetCustomEffectLevel(creature, CustomEffectType.ShieldBoost); return(effectLevel * 0.05f); }
public void OnItemUnequipped(NWCreature creature, NWItem oItem) { ApplyFeatChanges(creature, oItem); }
public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data) { }
public float CastingTime(NWCreature oPC, float baseCastingTime, int spellTier) { return(baseCastingTime); }
public void WearOff(NWCreature oCaster, NWObject oTarget, int effectiveLevel, string data) { }
public int?CooldownCategoryID(NWCreature creature, int?baseCooldownCategoryID, int spellTier) { return(baseCooldownCategoryID); }
public string Apply(NWCreature oCaster, NWObject oTarget, int effectiveLevel) { return(null); }
public void OnPurchased(NWCreature creature, int newLevel) { }
private void OnFinishAbilityUse(OnFinishAbilityUse data) { using (new Profiler(nameof(FinishAbilityUse))) { // These arguments are sent from the AbilityService's ActivateAbility method. NWCreature activator = data.Activator; string spellUUID = data.SpellUUID; int perkID = data.PerkID; NWObject target = data.Target; int pcPerkLevel = data.PCPerkLevel; int spellTier = data.SpellTier; float armorPenalty = data.ArmorPenalty; // Get the relevant perk information from the database. Data.Entity.Perk dbPerk = DataService.Perk.GetByID(perkID); // The execution type determines how the perk behaves and the rules surrounding it. PerkExecutionType executionType = dbPerk.ExecutionTypeID; // Get the class which handles this perk's behaviour. IPerkHandler perk = PerkService.GetPerkHandler(perkID); // Pull back cooldown information. int?cooldownID = perk.CooldownCategoryID(activator, dbPerk.CooldownCategoryID, spellTier); CooldownCategory cooldown = cooldownID == null ? null : DataService.CooldownCategory.GetByIDOrDefault((int)cooldownID); // If the activator interrupted the spell or died, we can bail out early. if (activator.GetLocalInt(spellUUID) == (int)SpellStatusType.Interrupted || // Moved during casting activator.CurrentHP < 0 || activator.IsDead) // Or is dead/dying { activator.DeleteLocalInt(spellUUID); return; } // Remove the temporary UUID which is tracking this spell cast. activator.DeleteLocalInt(spellUUID); // Force Abilities, Combat Abilities, Stances, and Concentration Abilities if (executionType == PerkExecutionType.ForceAbility || executionType == PerkExecutionType.CombatAbility || executionType == PerkExecutionType.Stance || executionType == PerkExecutionType.ConcentrationAbility) { // Run the impact script. perk.OnImpact(activator, target, pcPerkLevel, spellTier); // If an animation is specified for this perk, play it now. if (dbPerk.CastAnimationID != null && dbPerk.CastAnimationID > 0) { activator.AssignCommand(() => { _.ActionPlayAnimation((int)dbPerk.CastAnimationID, 1f, 1f); }); } // If the target is an NPC, assign enmity towards this creature for that NPC. if (target.IsNPC) { AbilityService.ApplyEnmity(activator, target.Object, dbPerk); } } // Adjust creature's current FP, if necessary. // Adjust FP only if spell cost > 0 PerkFeat perkFeat = DataService.PerkFeat.GetByPerkIDAndLevelUnlocked(perkID, spellTier); int fpCost = perk.FPCost(activator, perkFeat.BaseFPCost, spellTier); if (fpCost > 0) { int currentFP = AbilityService.GetCurrentFP(activator); int maxFP = AbilityService.GetMaxFP(activator); currentFP -= fpCost; AbilityService.SetCurrentFP(activator, currentFP); activator.SendMessage(ColorTokenService.Custom("FP: " + currentFP + " / " + maxFP, 32, 223, 219)); } // Notify activator of concentration ability change and also update it in the DB. if (executionType == PerkExecutionType.ConcentrationAbility) { AbilityService.StartConcentrationEffect(activator, perkID, spellTier); activator.SendMessage("Concentration ability activated: " + dbPerk.Name); // The Skill Increase effect icon and name has been overwritten. Apply the effect to the player now. // This doesn't do anything - it simply gives a visual cue that the player has an active concentration effect. _.ApplyEffectToObject(_.DURATION_TYPE_PERMANENT, _.EffectSkillIncrease(_.SKILL_USE_MAGIC_DEVICE, 1), activator); } // Handle applying cooldowns, if necessary. if (cooldown != null) { AbilityService.ApplyCooldown(activator, cooldown, perk, spellTier, armorPenalty); } // Mark the creature as no longer busy. activator.IsBusy = false; // Mark the spell cast as complete. activator.SetLocalInt(spellUUID, (int)SpellStatusType.Completed); } }
public void OnItemUnequipped(NWCreature creature, NWItem oItem) { }
public void OnPurchased(NWCreature creature, int newLevel) { ApplyFeatChanges(creature, null); }
public void OnConcentrationTick(NWCreature creature, NWObject target, int perkLevel, int tick) { }
public void OnRemoved(NWCreature creature) { NWNXCreature.RemoveFeat(creature, _.FEAT_CIRCLE_KICK); }
public CustomData StartUseItem(NWCreature user, NWItem item, NWObject target, Location targetLocation) { return(null); }
public float MaxDistance(NWCreature user, NWItem item, NWObject target, Location targetLocation) { return(0); }