public static void TribeLeaderPreventedSplit(Clan splitClan, Clan dominantClan, Tribe tribe) { splitClan.SetToUpdate(); dominantClan.SetToUpdate(); tribe.AddEventMessage(new PreventTribeSplitEventMessage(tribe, splitClan, tribe.CurrentLeader, splitClan.World.CurrentDate)); }
public static void DominantClanRejectedDemand(Clan demandClan, Clan dominantClan, Tribe tribe) { demandClan.SetToUpdate(); dominantClan.SetToUpdate(); tribe.AddEventMessage(new RejectedClanInlfuenceDemandEventMessage(tribe, demandClan, dominantClan, dominantClan.CurrentLeader, tribe.World.CurrentDate)); }
public static void TargetTribeRejectedOffer(Tribe sourceTribe, Tribe targetTribe) { sourceTribe.DominantFaction.SetToUpdate(); targetTribe.DominantFaction.SetToUpdate(); WorldEventMessage message = new RejectedMergeTribesOfferEventMessage(sourceTribe, targetTribe, targetTribe.CurrentLeader, sourceTribe.World.CurrentDate); sourceTribe.AddEventMessage(message); targetTribe.AddEventMessage(message); }
public static void LeaderAvoidsOpeningTribe(Tribe tribe) { // int rngOffset = RngOffsets.FOSTER_TRIBE_RELATION_EVENT_SOURCETRIBE_LEADER_AVOIDS_ATTEMPT_MODIFY_ATTRIBUTE; Clan dominantClan = tribe.DominantFaction as Clan; dominantClan.SetToUpdate(); tribe.AddEventMessage(new AvoidOpeningTribeEventMessage(tribe, tribe.CurrentLeader, tribe.World.CurrentDate)); }
public static void TargetTribeAcceptedOffer(Tribe sourceTribe, Tribe targetTribe) { sourceTribe.DominantFaction.SetToUpdate(); targetTribe.DominantFaction.SetToUpdate(); WorldEventMessage message = new AcceptedFosterRelationshipAttemptEventMessage(sourceTribe, targetTribe, targetTribe.CurrentLeader, sourceTribe.World.CurrentDate); sourceTribe.AddEventMessage(message); targetTribe.AddEventMessage(message); }
public static void LeaderAvoidsFosteringRelationship(Tribe sourceTribe, Tribe targetTribe) { int rngOffset = RngOffsets.FOSTER_TRIBE_RELATION_EVENT_SOURCETRIBE_LEADER_AVOIDS_ATTEMPT_MODIFY_ATTRIBUTE; Effect_IncreasePreference(sourceTribe, CulturalPreference.IsolationPreferenceId, BaseMinIsolationPreferencePercentIncrease, BaseMaxIsolationPreferencePercentIncrease, rngOffset++); Clan sourceDominantClan = sourceTribe.DominantFaction as Clan; sourceDominantClan.SetToUpdate(); sourceTribe.AddEventMessage(new AvoidFosterRelationshipEventMessage(sourceTribe, targetTribe, sourceTribe.CurrentLeader, sourceTribe.World.CurrentDate)); }
public static void LeaderAvoidsDemandingInfluence(Clan demandClan, Clan dominantClan, Tribe tribe) { int rngOffset = RngOffsets.CLAN_DEMANDS_INFLUENCE_EVENT_DEMANDCLAN_LEADER_AVOIDS_DEMAND_MODIFY_ATTRIBUTE; Effect_DecreasePreference(demandClan, CulturalPreference.AuthorityPreferenceId, BaseMinPreferencePercentChange, BaseMaxPreferencePercentChange, rngOffset++); Effect_IncreaseRelationship(demandClan, dominantClan, BaseMinRelationshipPercentChange, BaseMaxRelationshipPercentChange, rngOffset++); demandClan.SetToUpdate(); dominantClan.SetToUpdate(); tribe.AddEventMessage(new DemandClanAvoidInfluenceDemandEventMessage(demandClan, dominantClan, tribe, demandClan.CurrentLeader, demandClan.World.CurrentDate)); }
public static void LeaderOpensTribe(Tribe tribe) { int rngOffset = RngOffsets.OPEN_TRIBE_EVENT_SOURCETRIBE_LEADER_MAKES_ATTEMPT_MODIFY_ATTRIBUTE; Effect_DecreasePreference(tribe, CulturalPreference.IsolationPreferenceId, BaseMinIsolationPreferencePercentDecrease, BaseMaxIsolationPreferencePercentDecrease, rngOffset++); Clan dominantClan = tribe.DominantFaction as Clan; dominantClan.SetToUpdate(); tribe.AddEventMessage(new OpenTribeEventMessage(tribe, tribe.CurrentLeader, tribe.World.CurrentDate)); }
public static void LeaderAvoidsMergeTribesAttempt(Tribe sourceTribe, Tribe targetTribe) { int rngOffset = RngOffsets.MERGE_TRIBES_EVENT_SOURCETRIBE_LEADER_AVOIDS_ATTEMPT_MODIFY_ATTRIBUTE; Effect_IncreasePreference(sourceTribe, CulturalPreference.IsolationPreferenceId, BaseMinPreferencePercentChange, BaseMaxPreferencePercentChange, rngOffset++); Effect_DecreasePreference(sourceTribe, CulturalPreference.CohesionPreferenceId, BaseMinPreferencePercentChange, BaseMaxPreferencePercentChange, rngOffset++); Clan sourceDominantClan = sourceTribe.DominantFaction as Clan; sourceDominantClan.SetToUpdate(); sourceTribe.AddEventMessage(new AvoidMergeTribesAttemptEventMessage(sourceTribe, targetTribe, sourceTribe.CurrentLeader, sourceTribe.World.CurrentDate)); }
public static void LeaderAllowsSplit(Clan splitClan, Clan dominantClan, Tribe originalTribe) { Tribe newTribe = new Tribe(splitClan, originalTribe); newTribe.Initialize(); splitClan.World.AddPolityInfo(newTribe.Info); splitClan.SetToUpdate(); dominantClan.SetToUpdate(); originalTribe.AddEventMessage(new TribeSplitEventMessage(splitClan, originalTribe, newTribe, splitClan.World.CurrentDate)); }
public static void LeaderPreventsSplit(Clan splitClan, Clan dominantClan, Tribe tribe) { float charismaFactor = splitClan.CurrentLeader.Charisma / 10f; float wisdomFactor = splitClan.CurrentLeader.Wisdom / 15f; float attributesFactor = Mathf.Max(charismaFactor, wisdomFactor); attributesFactor = Mathf.Clamp(attributesFactor, 0.5f, 2f); int rngOffset = RngOffsets.TRIBE_SPLITTING_EVENT_SPLITCLAN_LEADER_PREVENTS_MODIFY_ATTRIBUTE; // Authority preference float randomFactor = splitClan.GetNextLocalRandomFloat(rngOffset++); float authorityPreferencePercentChange = (BaseMaxPreferencePercentChange - BaseMinPreferencePercentChange) * randomFactor + BaseMinPreferencePercentChange; authorityPreferencePercentChange /= attributesFactor; splitClan.DecreasePreferenceValue(CulturalPreference.AuthorityPreferenceId, authorityPreferencePercentChange); // Influence randomFactor = splitClan.GetNextLocalRandomFloat(rngOffset++); float influencePercentChange = (BaseMaxInfluencePercentChange - BaseMinInfluencePercentChange) * randomFactor + BaseMinInfluencePercentChange; influencePercentChange /= attributesFactor; Polity.TransferInfluence(splitClan, dominantClan, influencePercentChange); // Relationship randomFactor = splitClan.GetNextLocalRandomFloat(rngOffset++); float relationshipPercentChange = (BaseMaxRelationshipPercentChange - BaseMinRelationshipPercentChange) * randomFactor + BaseMinRelationshipPercentChange; relationshipPercentChange *= attributesFactor; float newValue = MathUtility.IncreaseByPercent(splitClan.GetRelationshipValue(dominantClan), relationshipPercentChange); Faction.SetRelationship(splitClan, dominantClan, newValue); // Updates splitClan.SetToUpdate(); dominantClan.SetToUpdate(); tribe.AddEventMessage(new SplitClanPreventTribeSplitEventMessage(splitClan, tribe, splitClan.CurrentLeader, splitClan.World.CurrentDate)); }
public override void Split() { int randomOffset = unchecked ((int)(RngOffsets.CLAN_SPLIT + Id)); float randomValue = GetNextLocalRandomFloat(randomOffset++); float splitFactionInfluence = _splitFactionMinInfluence + (randomValue * (_splitFactionMaxInfluence - _splitFactionMinInfluence)); Influence -= splitFactionInfluence; if (_splitFactionCoreGroup == null) { throw new System.Exception("_splitFactionCoreGroup is null - Clan Id: " + Id + ", Event Id: " + _splitFactionEventId); } float polityProminenceValue = _splitFactionCoreGroup.GetPolityProminenceValue(Polity); PolityProminence highestPolityProminence = _splitFactionCoreGroup.HighestPolityProminence; if (highestPolityProminence == null) { throw new System.Exception( "highestPolityProminence is null - Clan Id: " + Id + ", Group Id: " + _splitFactionCoreGroup.Id + ", Event Id: " + _splitFactionEventId); } if (CurrentLeader == null) { throw new System.Exception("CurrentLeader is null - Clan Id: " + Id + ", Event Id: " + _splitFactionEventId); } Tribe parentTribe = Polity as Tribe; if (parentTribe == null) { throw new System.Exception("parentTribe is null - Clan Id: " + Id + ", Event Id: " + _splitFactionEventId); } // If the polity with the highest prominence is different than the source clan's polity and it's value is twice greater switch the new clan's polity to this one. // NOTE: This is sort of a hack to avoid issues with clan/tribe split coincidences (issue #8 github). Try finding a better solution... if (highestPolityProminence.Value > (polityProminenceValue * 2)) { if (highestPolityProminence.Polity is Tribe) { parentTribe = highestPolityProminence.Polity as Tribe; //#if DEBUG // Debug.Log("parent tribe replaced from " + Polity.Id + " to " + parentTribe.Id + " due to low polity prominence value in new core: " + polityProminenceValue); //#endif } else { throw new System.Exception("Failed to replace new parent polity as it is not a Tribe. Id: " + highestPolityProminence.Polity.Id + ", Event Id: " + _splitFactionEventId); } } Clan newClan = new Clan(parentTribe, _splitFactionCoreGroup, splitFactionInfluence, this); if (newClan == null) { throw new System.Exception("newClan is null - Clan Id: " + Id + ", Event Id: " + _splitFactionEventId); } newClan.Initialize(); // We can initialize right away since the containing polity is already initialized // set relationship with parent clan float parentClanRelationshipValue = AvgClanSplitRelationshipValue + (CurrentLeader.Charisma - 10) / ClanSplitRelationshipValueCharismaFactor; randomValue = GetNextLocalRandomFloat(randomOffset++); float relationshipValue = parentClanRelationshipValue + (ClanSplitRelationshipValueSpread * (2f * randomValue - 1f)); SetRelationship(this, newClan, relationshipValue); parentTribe.AddFaction(newClan); parentTribe.UpdateDominantFaction(); World.AddFactionToUpdate(this); World.AddFactionToUpdate(newClan); World.AddPolityToUpdate(Polity); parentTribe.AddEventMessage(new ClanSplitEventMessage(this, newClan, World.CurrentDate)); }