Exemple #1
0
    public static void LeaderPreventsSplit(Clan clan)
    {
        float charismaFactor = clan.CurrentLeader.Charisma / 10f;
        float wisdomFactor   = clan.CurrentLeader.Wisdom / 15f;

        float attributesFactor = Mathf.Max(charismaFactor, wisdomFactor);

        attributesFactor = Mathf.Clamp(attributesFactor, 0.5f, 2f);

        int rngOffset = RngOffsets.CLAN_SPLITTING_EVENT_LEADER_PREVENTS_MODIFY_ATTRIBUTE;

        float randomFactor = clan.GetNextLocalRandomFloat(rngOffset++);
        float authorityPreferencePercentChange = (BaseMaxPreferencePercentChange - BaseMinPreferencePercentChange) * randomFactor + BaseMinPreferencePercentChange;

        authorityPreferencePercentChange /= attributesFactor;

        randomFactor = clan.GetNextLocalRandomFloat(rngOffset++);
        float cohesionPreferencePercentChange = (BaseMaxPreferencePercentChange - BaseMinPreferencePercentChange) * randomFactor + BaseMinPreferencePercentChange;

        cohesionPreferencePercentChange *= attributesFactor;

        clan.DecreasePreferenceValue(CulturalPreference.AuthorityPreferenceId, authorityPreferencePercentChange);
        clan.IncreasePreferenceValue(CulturalPreference.CohesionPreferenceId, cohesionPreferencePercentChange);

        clan.SetToUpdate();

        // Should reduce respect for authority and increase cohesion
        clan.Polity.AddEventMessage(new PreventClanSplitEventMessage(clan, clan.CurrentLeader, clan.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));
    }