public Hero CreateRandomLeader(Clan clan, BaseSettlementInfo settlementInfo) { var templateBase = clan.Leader.CharacterObject; var characterTemplate = CharacterObject.Templates.Where(go => go.Culture == clan.Culture && (go.Occupation == Occupation.Lord || go.Occupation == Occupation.Lady)).GetRandomElement(); characterTemplate.InitializeEquipmentsOnLoad(templateBase.AllEquipments.ToList()); foreach (var attribute in CharacterAttributes.All) { characterTemplate.SetAttributeValue(attribute.AttributeEnum, 255); } foreach (var skill in SkillObject.All) { characterTemplate.SetSkillValue(skill, 255); } characterTemplate.SetSkillValue(SkillObject.GetSkill(13), 1000); var hero = HeroCreator.CreateSpecialHero(characterTemplate, settlementInfo.Settlement); hero.IsNoble = true; hero.IsMinorFactionHero = false; foreach (var perk in PerkObject.All) { hero.SetPerkValue(perk, true); } hero.ChangeState(Hero.CharacterStates.Active); Get(hero.CharacterObject).IsCustomCharacter = true; return(hero); }
public static SkillObject FsmObjectPopup(GUIContent label, Skill fsm, SkillObject fsmObject, Type objectType) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); fsmObject = VariableEditor.DoFsmObjectPopup(label, fsm, fsmObject, objectType); VariableEditor.EndVariableEditor(fsmObject); return(fsmObject); }
public static void GetRequiredFocusPointsToAddFocus(ref SkillObject skill, ref int __result) { if (BannerlordCheatsSettings.Instance.FreeFocusPointAssignment) { __result = 0; } }
public SpellScript(int index, PlayerStats player = null, SkillObject source = null) { this.Index = index; this.PlayerOwner = player; this.source = source; SetSkill(); }
public static void Postfix(PartyBase party, StatExplainer explanation, ref int __result) { XmlNode settings = ClanTweakerSubModule.settings.xmlSettings.ChildNodes[1].SelectSingleNode("PartySizeSettings"); bool flag; if (settings.SelectSingleNode("AffectClanParties").InnerText == "true") { flag = party.LeaderHero != null && (party.LeaderHero == Hero.MainHero || party.LeaderHero.Clan.Name == Hero.MainHero.Clan.Name); } else { flag = party.LeaderHero != null && party.LeaderHero == Hero.MainHero; } if (party.LeaderHero != null && party.LeaderHero == Hero.MainHero) { SkillObject leadership = SkillObject.FindFirst((SkillObject x) => x.Name.ToString() == "Leadership"); SkillObject steward = SkillObject.FindFirst((SkillObject x) => x.Name.ToString() == "Steward"); int num = (int)Math.Ceiling((double)party.LeaderHero.GetSkillValue(leadership) * float.Parse(settings.SelectSingleNode("LeadershipBonus").InnerText) * 0.25f); __result += num; if (explanation != null) { explanation.AddLine("Leadership bonus", (float)num, StatExplainer.OperationType.Add); } num = (int)Math.Ceiling((double)party.LeaderHero.GetSkillValue(steward) * float.Parse(settings.SelectSingleNode("StewardBonus").InnerText) * 0.25f); __result += num; if (explanation != null) { explanation.AddLine("Steward bonus", (float)num, StatExplainer.OperationType.Add); } } }
public static void AddSkill(SkillObject skill) { if (!playerSkills.Contains(skill)) { playerSkills.Add(skill); } }
public void Execute(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj, CastAction castObj, Skill skill, SkillObject skillObject, DateTime time, int Value1, int Value2, int Value3, int Value4) { if (caster is Character character) { character.DisabledSetPosition = true; character.SendPacket( new SCLoadInstancePacket( 1, character.WorldPosition.ZoneId, character.WorldPosition.X, character.WorldPosition.Y, character.WorldPosition.Z, 0, 0, 0 ) ); character.InstanceId = 1; // TODO .... character.Position = character.WorldPosition.Clone(); character.WorldPosition = null; } }
public void InitAttack(string attackName) { //could be a BUFF tho... Debug.Log("Init attack or buff"); SkillObject attackSkillObject; skillDictionary.TryGetValue(attackName, out attackSkillObject); if (attackSkillObject != null && attackSkillObject.skillType == "ATTACK") { //then initialize isAttacking to true. our state will react to it. //but we need to pass our AttackState the skillObject. isAttacking = true; currentSkillObject = attackSkillObject; } else if (attackSkillObject != null && attackSkillObject.skillType == "BUFF") { //wee need to trigger the BUFF state...how tho? well.. it can only transition to BUFF state from IDLEACTIVE //so idle active needs to be told to go to BUFF state. //just follow the same pattern for now... isBuffing = true; currentSkillObject = attackSkillObject; } else { return; } }
public SkillModel(SkillObject skillObject) { this.BaseValue = skillObject.Value; this.Incrementvalue = skillObject.IncrementValue; this.ModifiedValue = 0; this.Level = 0; }
static void AddSkillXpPrefix(Hero __instance, SkillObject skill, ref float xpAmount) { if (__instance != null && skill != null && __instance.HeroDeveloper != null && skill.GetName() != null && Hero.MainHero != null) { xpAmount *= SKILL_XP_MULTIPLIER; } }
public static void SkillXPToAllPartyHeroes(SkillObject skill, int amount, bool IncluedMainHero) { if (MobileParty.MainParty.Army != null) { foreach (MobileParty party in MobileParty.MainParty.Army.Parties) { foreach (CharacterObject troop in party.MemberRoster.Troops) { if (troop.IsHero && (troop.HeroObject != Hero.MainHero || IncluedMainHero)) { troop.HeroObject.AddSkillXp(skill, amount); } } } } else { foreach (var troop in MobileParty.MainParty.MemberRoster.Troops) { if (troop.IsHero && (troop.HeroObject != Hero.MainHero || IncluedMainHero)) { troop.HeroObject.AddSkillXp(skill, amount); } } } }
public static int GetSkillTotalForParty(SkillObject skill) { int Sum = Hero.MainHero.GetSkillValue(skill); if (MobileParty.MainParty.Army != null) { foreach (MobileParty party in MobileParty.MainParty.Army.Parties) { foreach (CharacterObject troop in party.MemberRoster.Troops) { if (troop.IsHero) { Sum += troop.HeroObject.GetSkillValue(skill); } } } } else { foreach (CharacterObject troop in MobileParty.MainParty.MemberRoster.Troops) { if (troop.IsHero) { Sum += troop.HeroObject.GetSkillValue(skill); } } } return(Sum); }
public SkillLearningSelectorItemVM(SkillObject skill, bool isAvailable, string hint) : base("") { Skill = skill; base.StringItem = skill.Name.ToString(); base.CanBeSelected = isAvailable; }
public override void Apply(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj, CastAction castObj, Skill skill, SkillObject skillObject, DateTime time) { _log.Debug("InteractionEffect, {0}", WorldInteraction); var classType = Type.GetType("AAEmu.Game.Models.Game.World.Interactions." + WorldInteraction); if (classType == null) { _log.Error("InteractionEffect, Unknown world interaction: {0}", WorldInteraction); return; } _log.Debug("InteractionEffect, Action: {0}", classType); // TODO help to debug... var action = (IWorldInteraction)Activator.CreateInstance(classType); action.Execute(caster, casterObj, target, targetObj, skill.Template.Id); if (caster is Character character) { character.Quests.OnInteraction(WorldInteraction); } }
public void SetSecondarySkill(SkillObject secondarySkill) { //manaBar.color = Color.yellow; skillImage.sprite = secondarySkill.icon; skillImage.color = secondarySkill.icon_color; manaBar.color = secondarySkill.icon_color; }
/** * Adds stats to the player using the data in the SkillObject. * */ public void AddSkill(SkillObject skill) { if (Skills.ContainsKey(skill.name)) // Adds to the stack of skills { Skills[skill.name] = Skills[skill.name] + 1; } else { skillobjects.Add(skill); Skills.Add(skill.name, 1); if (skill.IsAbility) { abilityamount++; if (ability1 == "") { SetAbility1(skill.name); } else if (ability2 == "") { SetAbility2(skill.name); } } } AddSkillStats(skill, true); skillamount++; }
public static bool OnHeroGainedSkillPrefix(Hero hero, SkillObject skill, bool hasNewPerk, int change = 1, bool shouldNotify = true) { if (!shouldNotify || !IDontCareMenu.Instance.IsFilterEnabled) { return(true); } var filterModeIndex = IDontCareMenu.Instance.OnHeroGainedSkillFilterMode.SelectedIndex; bool shouldPlayerCare; if (filterModeIndex == (int)FilterMode.OnlyMe) { shouldPlayerCare = hero == Hero.MainHero; } else { shouldPlayerCare = ShouldPlayerCare(IDontCareMenu.Instance.OnHeroGainedSkillFilterMode.SelectedIndex, new List <IFaction>() { hero?.MapFaction }); } if (!shouldPlayerCare) { DebugLogNotificationIfEnabled("OnHeroLevelledUp"); } return(shouldPlayerCare); }
private void SetModifier(int amount, Hero hero, SkillObject skill, SkillObject flag, bool displayMessage = true, bool quickInformation = false) //Warning: SkillObject flag never used. { if (amount == 0) { if ((displayMessage || quickInformation) && hero.GetSkillValue(skill) > 0) { TextObject textObject = GameTexts.FindText("str_CE_level_start"); textObject.SetTextVariable("SKILL", skill.Name); textObject.SetTextVariable("HERO", hero.Name); if (hero.GetSkillValue(skill) > 1) { if (displayMessage) { InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green)); } if (quickInformation) { InformationManager.AddQuickInformation(textObject, 0, hero.CharacterObject, "event:/ui/notification/relation"); } } } hero.SetSkillValue(skill, 0); } else { int currentValue = hero.GetSkillValue(skill); int valueToSet = currentValue + amount; if (valueToSet < 1) { valueToSet = 1; } hero.SetSkillValue(skill, valueToSet); if (!displayMessage && !quickInformation) { return; } TextObject textObject = GameTexts.FindText("str_CE_level_skill"); textObject.SetTextVariable("HERO", hero.Name); textObject.SetTextVariable("SKILL", skill.Name); textObject.SetTextVariable("NEGATIVE", amount >= 0 ? 0 : 1); textObject.SetTextVariable("PLURAL", amount >= 2 ? 1 : 0); textObject.SetTextVariable("SKILL_AMOUNT", Math.Abs(amount)); textObject.SetTextVariable("TOTAL_AMOUNT", valueToSet); if (displayMessage) { InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green)); } if (quickInformation) { InformationManager.AddQuickInformation(textObject, 0, hero.CharacterObject, "event:/ui/notification/relation"); } } }
public void import_info(SkillObject tmp) { this.FullInfo = tmp; this.id = tmp.id; this.feat_no = tmp.feat_no; this.is_ex = (tmp.name.jp).Contains("EX"); }
public override (float killedSideMoraleChange, float killerSideMoraleChange) CalculateMoraleChangeAfterAgentKilled( Agent killedAgent, Agent killerAgent, SkillObject killerWeaponRelevantSkill) { return(0.0f, 0.0f); }
internal void GainSkills(SkillObject skillObject, int amount, int chance, Hero hero = null) { if (MBRandom.Random.Next(30) >= chance) { return; } if (hero == null) { hero = Hero.MainHero; } try { hero.HeroDeveloper.AddSkillXp(skillObject, amount); } catch (Exception) { CECustomHandler.LogToFile("Failed to add to skill"); } //TextObject textObject = new TextObject("{HERO} has learned {SKILL_AMOUNT} {SKILL} XP.", null); //textObject.SetTextVariable("HERO", Hero.MainHero.Name); //Hero.MainHero.AddSkillXp(skilltoget, 1f); //textObject.SetTextVariable("SKILL", skilltoget.Name); //textObject.SetTextVariable("SKILL_AMOUNT", amount); //InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green)); }
//private static float GetMultiplier() //{ // if (Settings.Instance.HeroSkillExperienceOverrideMultiplierEnabled) //return Settings.Instance.HeroSkillExperienceMultiplier; //else // return Math.Max(1, 0.0315769 * Math.Pow(skillLevel, 1.020743)); //} static bool Prefix(Hero __instance, SkillObject skill, float xpAmount) { try { if (hdFieldInfo == null) { GetFieldInfo(); } HeroDeveloper hd = (HeroDeveloper)hdFieldInfo.GetValue(__instance); if (hd != null) { if (xpAmount > 0) { float newXpAmount = (int)Math.Ceiling(xpAmount * Settings.Instance.HeroSkillExperienceMultiplier); hd.AddSkillXp(skill, newXpAmount, true, true); } else { hd.AddSkillXp(skill, xpAmount, true, true); } } } catch (Exception ex) { ModDebug.ShowError($"An exception occurred whilst trying to apply the hero xp multiplier.", "", ex); } return(false); }
private void TryAttack() { for (int i = 0; i < skillObjects.Count; i++) { SkillObject skillObject = (SkillObject)skillObjects[i]; Vector2 v = BattleUtils.PositionToGrid(skillObject.transform.position); ArrayList gameObjects = BattleControllor.GetGameObjectsByPosition(v); for (int j = 0; j < gameObjects.Count; j++) { Charactor c = (Charactor)gameObjects[j]; if (c.GetType() != this.attackOne.GetType() && c.IsActive() == true) { bool crit = BattleControllor.Crit(skillConfig.crit); float damage = BattleControllor.Attack(attackOne.GetAttribute(), c.GetAttribute(), skillConfig.demageratio, skillConfig.b, crit); c.ChangeHP(damage, crit); if (c.GetAttribute().hp > 0) { c.PlayAttacked(); } else { c.PlayDead(); } } } } }
private static void AddSetPropertyAction() { Type actionType = ActionData.GetActionType("HutongGames.PlayMaker.Actions.SetProperty"); if (actionType == null) { Dialogs.MissingAction("Set Property"); return; } SkillStateAction fsmStateAction = SkillEditor.Builder.InsertAction(SkillEditorMacros.droppedOnState, actionType, SkillEditorMacros.droppedOnAction); FieldInfo field = actionType.GetField("targetProperty", 20); if (field != null) { FieldInfo arg_6B_0 = field; object arg_6B_1 = fsmStateAction; SkillProperty fsmProperty = new SkillProperty(); SkillProperty arg_5E_0 = fsmProperty; SkillObject fsmObject = new SkillObject(); fsmObject.set_Value(SkillEditorMacros.droppedObject); arg_5E_0.TargetObject = fsmObject; fsmProperty.setProperty = true; arg_6B_0.SetValue(arg_6B_1, fsmProperty); } SkillEditor.SetFsmDirty(SkillEditorMacros.droppedOnFsm, true, false, true); SkillEditor.SaveActions(SkillEditorMacros.droppedOnFsm); }
public override float[] GetDailyRecruitedPrisoners(MobileParty mainParty) { // Default Taleworlds values are { 1f, 0.5f, 0.3f, 0.2f, 0.1f, 0f, 0f } // Target values for an "average character" (used as reference) are: float[] referenceValues = new[] { 0.95f, 0.55f, 0.4f, 0.3f, 0.2f, 0.1f, 0.075f }; const float ReferenceMorale = 50f; float moraleRecruitmentChange = (mainParty.Morale - ReferenceMorale) / (2 * ReferenceMorale); // 2 * to reduce scaling const float ReferenceCharisma = 100f; SkillObject charismaSkill = SkillObject.FindFirst((x) => { return(x.StringId == "Charm"); }); float leaderCharisma = (float)mainParty.LeaderHero.GetSkillValue(charismaSkill); float charmRecruitmentChange = (leaderCharisma - ReferenceCharisma) / (4 * ReferenceCharisma); // 4 * to reduce scaling float totalAdjustmentPercent = moraleRecruitmentChange + charmRecruitmentChange; InformationManager.DisplayMessage(new InformationMessage(string.Format("Chance to recruit adjustment: {0}%", totalAdjustmentPercent * 100f))); for (int troopTier = 0; troopTier < referenceValues.Length; ++troopTier) { referenceValues[troopTier] += totalAdjustmentPercent * referenceValues[troopTier]; referenceValues[troopTier] = Mathf.Clamp(referenceValues[troopTier], MinimumValues[troopTier], MaximumValues[troopTier]); } return(referenceValues); }
public void Execute(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj, CastAction castObj, Skill skill, SkillObject skillObject, DateTime time, int Value1, int Value2, int Value3, int Value4) { var owner = (Character)caster; var skillData = (SkillItem)casterObj; var itemInfo = owner.Inventory.GetItem(skillData.ItemId); if (itemInfo == null || itemInfo.Count <= 0) { return; } var tasks = new List <ItemTask> { InventoryHelper.GetTaskAndRemoveItem(owner, itemInfo, 1) }; owner.BmPoint += Value1; owner.SendPacket(new SCBmPointPacket(owner.BmPoint)); owner.SendPacket(new SCItemTaskSuccessPacket(ItemTaskType.SkillReagents, tasks, new List <ulong>())); // TODO - LOYALT IS ACCOUNT WIDE }
public static void CalculateLearningRate(Hero hero, SkillObject skill, StatExplainer explainer, ref float __result) { if (hero?.IsHumanPlayerCharacter ?? false) { __result *= BannerlordCheatsSettings.Instance.LearningRateMultiplier; } }
static bool Prefix(Hero __instance, SkillObject skill, int xpAmount) { try { HeroDeveloper hd = (HeroDeveloper)(typeof(Hero).GetField("_heroDeveloper", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(__instance)); if (hd != null) { if (xpAmount > 0) { double multiplier = GetMultiplier(__instance.GetSkillValue(skill)); int newXpAmount = (int)Math.Ceiling(xpAmount * multiplier); hd.AddSkillXp(skill, newXpAmount); } else { hd.AddSkillXp(skill, xpAmount); } } } catch (Exception ex) { ModDebug.ShowError($"An exception occurred whilst trying to apply the hero xp multiplier.", "", ex); } return(false); }
static bool Prefix(Hero __instance, SkillObject skill, float xpAmount) { try { if (hdFieldInfo == null) { GetFieldInfo(); } HeroDeveloper hd = (HeroDeveloper)hdFieldInfo !.GetValue(__instance); if (!(BannerlordTweaksSettings.Instance is { } settings)) { return(true); } if (hd != null) { if (xpAmount > 0) { if (settings.HeroSkillExperienceMultiplierEnabled && hd.Hero.IsHumanPlayerCharacter) { if (settings.PerSkillBonusEnabled) { float PerSkillBonus = GetPerSkillBonus(skill, xpAmount); xpAmount = PerSkillBonus; } float newXpAmount = (int)Math.Ceiling(xpAmount * settings.HeroSkillExperienceMultiplier); hd.AddSkillXp(skill, newXpAmount, true, true); } else if (settings.CompanionSkillExperienceMultiplierEnabled && !hd.Hero.IsHumanPlayerCharacter && (hd.Hero.Clan == Hero.MainHero.Clan)) { if (settings.PerSkillBonusEnabled) { float PerSkillBonus = GetPerSkillBonus(skill, xpAmount); xpAmount = PerSkillBonus; } float newXpAmount = (int)Math.Ceiling(xpAmount * settings.CompanionSkillExperienceMultiplier); hd.AddSkillXp(skill, newXpAmount, true, true); } else { hd.AddSkillXp(skill, xpAmount, true, true); } } else { hd.AddSkillXp(skill, xpAmount, true, true); } } } catch (Exception ex) { DebugHelpers.ShowError("An exception occurred while trying to apply the hero xp multiplier.", "", ex); } return(false); }
protected override void SpawnObject() { if (TheCaster.gameObject.GetComponent <NPC>() != null || Target.GetComponent <NPC>() != null) { switch (HealingType) { case HealType.Projectile: { GameObject newProjectile = Instantiate(SkillObject, SourceLocation.position, npc.transform.rotation); newProjectile.GetComponent <Projectile>().target = Target; newProjectile.GetComponent <Projectile>().HParent = this; newProjectile.GetComponent <Projectile>().speed = speed; break; } case HealType.Strom: { SkillObject.GetComponent <ParticleCollisionInstance>().HParent = this; SkillObject.GetComponent <ParticleCollisionInstance>().Targeter = Target; break; } case HealType.LavaGround: { SkillObject.GetComponent <OffanceGroundDmg>().HskillStat = this; SkillObject.GetComponent <OffanceGroundDmg>().father = TheCaster; SkillObject.GetComponent <OffanceGroundDmg>().Duraion = Duraion; SkillObject.GetComponent <OffanceGroundDmg>().DMGTicks = DMGTick; break; } case HealType.PricingShot: { SkillObject.GetComponent <PricingProjectile>().speed = speed; SkillObject.GetComponent <PricingProjectile>().hit = EfectOnHit; SkillObject.GetComponent <PricingProjectile>().flash = SpawnParticles; SkillObject.GetComponent <PricingProjectile>().father = TheCaster; SkillObject.GetComponent <PricingProjectile>().healingStat = this; break; } case HealType.BouncingProjectile: { SkillObject.GetComponent <BouncingProjectile>().bounceTime = BouncingTimes; SkillObject.GetComponent <BouncingProjectile>().speed = speed; SkillObject.GetComponent <BouncingProjectile>().father = TheCaster; SkillObject.GetComponent <BouncingProjectile>().HealingStat = this; SkillObject.GetComponent <BouncingProjectile>().AreaOfEffect = BouncingSearchAOE; break; } case HealType.None: { SkillAbility(Target); break; } } } }