Hi.
Tried to create my own rule, but it doesn`t seem to work. The point of this rule is to create starting relationships between player and other factions based on player choices.
The rule is packed into a jar and put in 'package com.fs.starfarer.api.impl.campaign.rulecmd' as it must be present there in order to use it in rules.csv. Here is the code that it uses:
Spoiler
package com.fs.starfarer.api.impl.campaign.rulecmd;
import java.util.List;
import java.util.Map;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
//import com.fs.starfarer.api.campaign.ReputationActionResponsePlugin.ReputationAdjustme ntResult;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
//import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepActionEnvelope;
//import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepActions;
import com.fs.starfarer.api.util.Misc.Token;
/**
* SetRep <factionId> <RepActions action>
*/
public class SetStartingRep extends BaseCommandPlugin {
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
String Faction = params.get(0).getString(memoryMap);
String prefix = "";
if (Faction.contains("rsf"))
{
Global.getSector().getFaction("player").setRelationship("ISA", -0.2f);
Global.getSector().getFaction("player").setRelationship("XLE", 0f);
Global.getSector().getFaction("player").setRelationship("UIN", 0f);
Global.getSector().getFaction("player").setRelationship("FFS", -0.1f);
prefix = "RSF";
}
else if (Faction.contains("xle"))
{
Global.getSector().getFaction("player").setRelationship("ISA", 0f);
Global.getSector().getFaction("player").setRelationship("RSF", 0f);
Global.getSector().getFaction("player").setRelationship("UIN", 0f);
Global.getSector().getFaction("player").setRelationship("FFS", -0.5f);
prefix = "XLE";
}
else if (Faction.contains("uin"))
{
Global.getSector().getFaction("player").setRelationship("ISA", 0f);
Global.getSector().getFaction("player").setRelationship("RSF", 0f);
Global.getSector().getFaction("player").setRelationship("XLE", 0f);
Global.getSector().getFaction("player").setRelationship("FFS", -0.5f);
prefix = "UIN";
}
else if (Faction.contains("isa"))
{
Global.getSector().getFaction("player").setRelationship("UIN", 0f);
Global.getSector().getFaction("player").setRelationship("RSF", -0.1f);
Global.getSector().getFaction("player").setRelationship("XLE", 0f);
Global.getSector().getFaction("player").setRelationship("FFS", -0.1f);
prefix = "ISA";
}
if (Faction.contains("_t"))
{
Global.getSector().getFaction("player").setRelationship(prefix, RepLevel.NEUTRAL);
Global.getSector().getFaction("player").setRelationship("independent",RepLevel.FAVORABLE);
Global.getSector().getFaction("player").setRelationship("pirates", RepLevel.HOSTILE);
}
else if (Faction.contains("_s"))
{
Global.getSector().getFaction("player").setRelationship(prefix, RepLevel.SUSPICIOUS);
Global.getSector().getFaction("player").setRelationship("independents", RepLevel.NEUTRAL);
Global.getSector().getFaction("player").setRelationship("pirates", RepLevel.SUSPICIOUS);
}
else if (Faction.contains("_b"))
{
Global.getSector().getFaction("player").setRelationship(prefix, RepLevel.FAVORABLE);
Global.getSector().getFaction("player").setRelationship("independents", RepLevel.NEUTRAL);
Global.getSector().getFaction("player").setRelationship("pirates",RepLevel.HOSTILE);
}
return !Faction.isEmpty();
}
}
The rules.csv has ' SetStartingRep "rsf_t" ' as one of the options. I don`t get any errors nither in the way of crashes or any entries in the log. The rule seems to be running (as it compiles without problems), but has no effect.
A little example. If you select trader and then RSF as your faction - you get a call for SetStartingRep with "rsf_t" string, so it should trigger the 'contains "rsf"' check and 'contains "_t"' check. Those should set pirates and ISA to be hostile towards you, but i get only neutral stance with all factions.
Guess there is something i`m doing wrong with the return value or this whole thing should not work that way at all.
I wonder what is generated first - player or factions? If it is the later - than there is no way to set up starting relationship at all via rules other than somehow wire your choices with SectorGen.