private void OnHeroGrows(Hero hero) { HeroFixHelper.FixHeroStats(hero); if (hero.Age > 6f && !hero.CharacterObject.IsOriginalCharacter) { HeroFixHelper.FixEquipment(hero); } }
private void OnChangeClanLeader(float dt) { MobileParty leaderParty = leader.PartyBelongedTo; MobileParty newLeaderParty = newLeader.PartyBelongedTo; if (leader == null || newLeader == null || leaderParty == null || newLeaderParty == null || leaderParty == newLeaderParty) { return; } if (newLeader.GovernorOf != null) { ChangeGovernorAction.ApplyByGiveUpCurrent(newLeader); } if (leader.GovernorOf != null) { ChangeGovernorAction.ApplyByGiveUpCurrent(leader); } var qm = Campaign.Current.QuestManager; if (qm != null) { QuestBase q; while ((q = qm.Quests.FirstOrDefault(s => !s.IsSpecialQuest)) != null) { q.CompleteQuestWithFail(); } } string evt; while ((evt = newLeader.GetHeroOccupiedEvents().FirstOrDefault()) != default) { newLeader.RemoveEventFromOccupiedHero(evt); } while ((evt = leader.GetHeroOccupiedEvents().FirstOrDefault()) != default) { leader.RemoveEventFromOccupiedHero(evt); } GiveGoldAction.ApplyBetweenCharacters(leader, newLeader, leader.Gold, true); leader.Clan.SetLeader(newLeader); ChangePlayerCharacterAction.Apply(newLeader); TroopRosterElement t; while (leaderParty.MemberRoster.Count(x => x.Character != leader.CharacterObject) > 0) { t = leaderParty.MemberRoster.First(x => x.Character != leader.CharacterObject); leaderParty.MemberRoster.AddToCounts(t.Character, -t.Number); newLeaderParty.MemberRoster.AddToCounts(t.Character, t.Number); } while (leaderParty.PrisonRoster.Count() > 0) { t = leaderParty.PrisonRoster.First(); leaderParty.PrisonRoster.AddToCounts(t.Character, -t.Number); newLeaderParty.PrisonRoster.AddToCounts(t.Character, t.Number); } ItemRosterElement i; while (leaderParty.ItemRoster.Count() > 0) { i = leaderParty.ItemRoster.First(); leaderParty.ItemRoster.AddToCounts(i.EquipmentElement, -i.Amount); newLeaderParty.ItemRoster.AddToCounts(i.EquipmentElement, i.Amount); } leaderParty.RemoveParty(); AddHeroToPartyAction.Apply(leader, newLeaderParty); newLeader.Clan.Influence = Math.Max(0, newLeader.Clan.Influence - 100); HeroFixHelper.FixHeroStats(newLeader); HeroFixHelper.FixEquipment(newLeader); newLeader = null; leader = null; CampaignEvents.RemoveListeners(this); }