private void OnHourlyTickEvent(MobileParty mobileParty) { Hero companion = mobileParty.LeaderHero; if (mobileParty == MobileParty.MainParty || companion == null || !mobileParty.IsLordParty || companion.Clan != Clan.PlayerClan) { return; } Settlement target = mobileParty.TargetSettlement; if (mobileParty.DefaultBehavior != AiBehavior.PatrolAroundPoint || target.OwnerClan != Clan.PlayerClan) { return; } if (mobileParty.Position2D.DistanceSquared(target.Position2D) > MinPatrolDistance) { //InformationManager.DisplayMessage(new InformationMessage(companion.Name + " too far away from " + target.Name)); mobileParty.SetMoveGoToSettlement(target); return; } //InformationManager.DisplayMessage(new InformationMessage(companion.Name + " patrolling around " + target.Name)); int companion_relation; foreach (Hero notable in target.Notables) { companion_relation = CharacterRelationManager.GetHeroRelation(companion, notable) + 1; if (companion_relation % HoursRequirement == 0) { // reset companion personal relation companion_relation = 0; // increase player relation int oldRelation = notable.GetRelation(Hero.MainHero); ChangeRelationAction.ApplyPlayerRelation(notable, 1, false, false); int newRelation = notable.GetRelation(Hero.MainHero); int relation_change = newRelation - oldRelation; if (relation_change > 0) { TextObject textObject = GameTexts.FindText("str_your_relation_increased_with_notable", null); TextObject heroText = new TextObject(); ZenDzeeCompatibilityHelper.SetTextVariable(heroText, "NAME", notable.Name); ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "HERO", heroText); ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "VALUE", newRelation); ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "MAGNITUDE", relation_change); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString())); } } CharacterRelationManager.SetHeroRelation(companion, notable, companion_relation); } }
public CompanionsPatrolsBehavior() { CompanionAiPatrolProperty = new PropertyObject("zenDzeeMods_patrol_player_lands"); PropertyObject tmp = ZenDzeeCompatibilityHelper.RegisterPresumedObject(CompanionAiPatrolProperty); if (tmp != null) { CompanionAiPatrolProperty = tmp; } CompanionAiPatrolProperty.Initialize(new TextObject("zenDzeeMods_patrol_player_lands"), new TextObject("Non-zero value tells companion to patrol player lands.")); }
public HeroFixBehavior() { PropertyObject FixEquipmentProperty = new PropertyObject("zenDzeeMods_fix_equipment"); PropertyObject tmp = ZenDzeeCompatibilityHelper.RegisterPresumedObject(FixEquipmentProperty); if (tmp != null) { FixEquipmentProperty = tmp; } FixEquipmentProperty.Initialize(new TextObject("zenDzeeMods_fix_equipment"), new TextObject("Non-zero value - equipment is fixed.")); HeroFixHelper.HeroFixEquipmentProperty = FixEquipmentProperty; }