AndroidQuazar / VanillaExpandedFramework

Vanilla Expanded Framework for RimWorld
Other
36 stars 18 forks source link

VFE Core: Allow custom initial relations/goodwill between NPC factions #15

Closed sumghai closed 3 years ago

sumghai commented 3 years ago

Additions

Rationale

Currently, relations between all NPC factions either default to neutral or hostile (if set as permanent enemy to everyone).

However, there may be gameplay/lore reasons to specify custom goodwill between two or more NPC factions - for instance, FactionA and FactionB could set as hostile to each other while both being neutral or friendly to the player faction, such that if caravans from both factions show up on the player colony map at the same time, they would immediately attack each other.

This could open up new gameplay possibilities, where player can either choose to side with one of the factions, keep them apart so the player maintains good relations with both rivals, or even taking advantage of their feud to steal dropped resources and downed pawns.

The proposed code works as follows:

Usage

Example 1 While the game is setting up FactionA, if it comes across any factions of the type FactionB, it will set their mutual relations to a random number between -100 and -80 (i.e. hostile).

<FactionDef>
        <defName>FactionA</defName>
        <!-- Other fields omitted for clarity -->
        <modExtensions>
            <li Class="VFECore.FactionDefExtension">
                <startingGoodwillByFactionDefs>
                    <FactionB>-100~-80</FactionB>
                </startingGoodwillByFactionDefs>
            </li>
        </modExtensions>
</FactionDef>

Example 2 Both FactionA and FactionB (for some reason) defined goodwill ranges for each other, so the code picks the lowest possible combination of the two different goodwill ranges (i.e. -100 and -70), and sets their mutual relations between the revised range.

<FactionDef>
        <defName>FactionA</defName>
        <!-- Other fields omitted for clarity -->
        <modExtensions>
            <li Class="VFECore.FactionDefExtension">
                <startingGoodwillByFactionDefs>
                    <FactionB>-100~-60</FactionB>
                </startingGoodwillByFactionDefs>
            </li>
        </modExtensions>
</FactionDef>

<FactionDef>
        <defName>FactionB</defName>
        <!-- Other fields omitted for clarity -->
        <modExtensions>
            <li Class="VFECore.FactionDefExtension">
                <startingGoodwillByFactionDefs>
                    <FactionA>-90~-70</FactionA>
                </startingGoodwillByFactionDefs>
            </li>
        </modExtensions>
</FactionDef>

Example 3 If there is more than one Mousekin Kingdom, it will randomly set relations between each possible pair of Mice Kingdoms to be either neutral or hostile

<FactionDef>
        <defName>Mousekin_FactionKingdom</defName>
        <!-- Other fields omitted for clarity -->
        <modExtensions>
            <li Class="VFECore.FactionDefExtension">
                <startingGoodwillByFactionDefs>
                    <Mousekin_FactionKingdom>-20~-20</Mousekin_FactionKingdom>
                </startingGoodwillByFactionDefs>
            </li>
        </modExtensions>
</FactionDef>

Testing

kingdom

indy

gypsy