Created
July 5, 2017 17:13
-
-
Save Trylobot/e742b7afb70e17f49f859399070cd510 to your computer and use it in GitHub Desktop.
Re: ExperienceToLevel (erikem) progression http://fractalsoftworks.com/forum/index.php?topic=12755.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "XP Mod", | |
"description": "Get more XP", | |
"author": "<your name here>", | |
"id": "xp_mod", | |
"version": "0.0.1", | |
"gameVersion": "0.8.1a", | |
"modPlugin": "data.scripts.XPModPlugin" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package data.scripts; | |
// Java version: 7 | |
import com.fs.starfarer.api.BaseModPlugin; | |
import com.fs.starfarer.api.EveryFrameScript; | |
import com.fs.starfarer.api.Global; | |
import com.fs.starfarer.api.campaign.SectorAPI; | |
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI; | |
public class XPModPlugin extends BaseModPlugin | |
{ | |
@Override | |
public void onApplicationLoad() { } | |
@Override | |
public void onNewGame() | |
{ | |
// | |
Global.getSector().addScript(new EveryFrameScript() | |
{ | |
private long last_xp = 0L; | |
@Override | |
public void advance(float amount) | |
{ | |
MutableCharacterStatsAPI p_stats = Global.getSector().getPlayerPerson().getStats(); | |
long xp = p_stats.getXP(); | |
int level = p_stats.getLevel(); | |
double bonus_factor = 0d; | |
long delta = 0L; | |
// | |
if (xp > last_xp) { | |
delta = xp - last_xp; | |
if (level >= 0 && level <= 40) { | |
bonus_factor = 0d; // unchanged | |
} else if (level > 40 && level <= 60) { | |
bonus_factor = 1d; // 2x | |
} else if (level > 60) { | |
bonus_factor = 9d; // 10x | |
} | |
} | |
// | |
long bonus_xp = (long)Math.floor(bonus_factor * (double)delta); | |
p_stats.addXP( bonus_xp ); | |
// | |
last_xp = p_stats.getXP(); | |
} | |
@Override public boolean isDone() { return false; } | |
@Override public boolean runWhilePaused() { return false; } | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Manifest:
{Starsector}/mods/xp_mod/mod_info.json
{Starsector}/mods/xp_mod/data/scripts/XPModPlugin.java