Alright, so wrote a script to return true or false based upon the player's replevel with the interaction target and a randomly generated 'fireChance'
The idea here is that the event more or less often based on the players rep level.
Anywhoo, compiling my first script with IntelliJ and everything seems to check out and compile without any errors but I get an error message about rules saying it can't find the custom script when I try and actually run the game.
Code:
Spoiler
package archeus.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.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.rules.MemKeys;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.util.Misc.Token;
import com.fs.starfarer.api.impl.campaign.rulecmd.BaseCommandPlugin;
/**
* Consortium Tribute Calculation
* by Morrokain
*/
public class ConsortiumTributeCalc extends BaseCommandPlugin {
@Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
if (dialog == null) return false;
float credits = Global.getSector().getPlayerFleet().getCargo().getCredits().get();
float tribute = (int) Global.getSector().getPlayerFleet().getFleetPoints() * 200;
memoryMap.get(MemKeys.LOCAL).set("$Consortium_tribute", (int)tribute, 0);
int BaseFireChance = 50; // base chance of success before rep cal
CampaignFleetAPI playerFleet;
CampaignFleetAPI otherFleet;
FactionAPI faction;
FactionAPI playerFaction;
playerFleet = Global.getSector().getPlayerFleet();
otherFleet = (CampaignFleetAPI) (dialog.getInteractionTarget());
faction = otherFleet.getFaction();
playerFaction = playerFleet.getFaction();
RepLevel level = faction.getRelationshipLevel(playerFaction);
// get rep level relative to player
if (level.isAtWorst(RepLevel.INHOSPITABLE)); // no chance once hostile.
{
int fireChance = BaseFireChance + (int) (Math.random() * 101);
// generates random number and adds to fireChance
if (level.isAtWorst(RepLevel.COOPERATIVE)) // rep adds or subtracts fireChance
fireChance -= 100;
if (level.isAtWorst(RepLevel.WELCOMING))
fireChance -= 20;
if (level.isAtWorst(RepLevel.FAVORABLE))
fireChance -= 15;
if (level.isAtWorst(RepLevel.FRIENDLY))
fireChance -= 10;
if (level.isAtWorst(RepLevel.NEUTRAL))
fireChance += 5;
if (level.isAtWorst(RepLevel.SUSPICIOUS))
fireChance += 20;
if (level.isAtWorst(RepLevel.INHOSPITABLE))
fireChance += 30;
memoryMap.get(MemKeys.LOCAL).set("$Tribute_fireChance", fireChance, 0);
if (fireChance >= 100 && credits >= tribute) // only fire if enough player credits for tribute request
return true; // and if fireChance over 100 (successful roll)
}
return false;
}
}
settings entry:
Spoiler
"ruleCommandPackages":[
"archeus.rulecmd"
],
Error Message:
Spoiler
5450 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingArcheanTOffNormal
5450 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingArcheanTOffWeaker
5450 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingArcheanFriendly
5450 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingArcheanHostileWeaker
5450 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingArcheanHostileWeakerDefiant
5450 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingArcheanHostileStronger
5450 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingArcheanNeutral
5451 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingAdamantineFriendly
5451 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingAdamantineHostileWeaker
5451 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingAdamantineHostileWeakerDefiant
5451 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingAdamantineHostileStronger
5451 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: greetingAdamantineNeutral
5451 [Thread-4] INFO com.fs.starfarer.campaign.rules.Rules - Loading rule: ConsortiumTributeCheck
5451 [Thread-4] INFO com.fs.starfarer.loading.scripts.OoOO - Loading class: com.fs.starfarer.api.impl.campaign.rulecmd.ConsortiumTributeCalc
5451 [Thread-4] INFO com.fs.starfarer.loading.scripts.OoOO - Loading class: com.fs.starfarer.api.impl.campaign.rulecmd.salvage.ConsortiumTributeCalc
5451 [Thread-4] INFO com.fs.starfarer.loading.scripts.OoOO - Loading class: com.fs.starfarer.api.impl.campaign.rulecmd.newgame.ConsortiumTributeCalc
5451 [Thread-4] INFO com.fs.starfarer.loading.scripts.OoOO - Loading class: archeus.rulecmd.ConsortiumTributeCalc
5725 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain - com.fs.starfarer.api.util.RuleException: java.lang.RuntimeException: Command [ConsortiumTributeCalc] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
archeus.rulecmd
com.fs.starfarer.api.util.RuleException: java.lang.RuntimeException: Command [ConsortiumTributeCalc] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
archeus.rulecmd
at com.fs.starfarer.campaign.rules.A.<init>(Unknown Source)
at com.fs.starfarer.campaign.rules.Rules.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Command [ConsortiumTributeCalc] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
archeus.rulecmd
at com.fs.starfarer.campaign.rules.A.getCommandClass(Unknown Source)
... 8 more
Process finished with exit code 1
Anyone dealt with this?
I'm fairly confident I set up the artifact correctly in the compiler, and in the 'compiled output' folder after the project builds the script shows up as a class file, so its recognized there.
Not really sure where to go from here. ???
Edit: Solved. The dumb thing (intelliJ) renamed the jar to the project name for some reason so I just needed to update the entry in the mod_info file with the correct jar name since I can't get it to call the jar anything else for some reason. >:(