Ludeon Forums

RimWorld => Mods => Help => Topic started by: Berengar on December 22, 2014, 03:04:26 PM

Title: Faction war
Post by: Berengar on December 22, 2014, 03:04:26 PM
I got 2 new factions.. the stormtroopers, and the rebels.
And normaly that two guys realy dont like eatch other..
But when they meet each other on the plains of rimworld.. they just ignore.
Any Idea how to change that?

Mfg: Berengar
Title: Re: Faction war
Post by: Lord Fappington on December 22, 2014, 07:12:52 PM
Personally don't have an answer, but you may find the answer when looking at pre-existing factions and how they are set up (e.g., settler types tend to be hostile to pirates as well)
Title: Re: Faction war
Post by: Shinzy on December 23, 2014, 08:09:42 AM
Don't know either but the way I *like to think it is*
the factions just might generate the relations when they're created
kinda like how they do it to your colony

so if you'd put your Stormtroopers hostile like 100% of time they'd be hostile to everyone
(might not be something you'd want to do but)

but I don't think you can get them to be hostile towards one specific faction without
some genious coding taking place =P
Title: Re: Faction war
Post by: Evul on December 23, 2014, 08:34:08 AM
Unless there are some kind of hidden code Ty made. The only easy way to do it is make them hate all.
Title: Re: Faction war
Post by: JuliaEllie on December 23, 2014, 09:40:46 AM
You could try this

Code: [Select]
Find.FactionManager.FirstFactionOfDef(DefDatabase<FactionDef>.GetNamed("Imperium")).AffectGoodwillWith(Find.FactionManager.FirstFactionOfDef(DefDatabase<FactionDef>.GetNamed("Rebels")), -100);
Find.FactionManager.FirstFactionOfDef(DefDatabase<FactionDef>.GetNamed("Rebels")).AffectGoodwillWith(Find.FactionManager.FirstFactionOfDef(DefDatabase<FactionDef>.GetNamed("Imperium")), -100);

Well this is spaghetti code *yummy* lets do it a little bit less spaghetti-ish but with way more lines:

Code: [Select]
FactionDef imperiumdef = DefDatabase<FactionDef>.GetNamed("Imperium");
               Faction imperium = Find.FactionManager.FirstFactionOfDef(imperiumdef);

               FactionDef rebeldef = DefDatabase<FactionDef>.GetNamed("Rebels");
               Faction rebel = Find.FactionManager.FirstFactionOfDef(rebeldef);

               imperium.AffectGoodwillWith(rebel, -100);
               rebel.AffectGoodwillWith(imperium, -100);

thats basically the same but looks better and is easier to understand. Have fun :)

P.S. the second one occupies 4 variables while the first one uses none. Doesnt matter in this scale but if you have a few million of those..
Title: Re: Faction war
Post by: Berengar on December 23, 2014, 10:19:22 AM
Thats perfect. Thanks! Will try it later^^