OpenXcom Forum
Modding => Help => Topic started by: Nirran on October 29, 2023, 10:47:58 am
-
hello
im trying to limit stam tu and hp gains,unfortunatly this script snip doesnt work,and way of doing this with scripting some other way or with a rul file?
#limit TimeUnits
statChange.getTimeUnits changeTimeUnits; #how much TimeUnits was incresed by exp
soldier.Stats.getTimeUnits origTimeUnits; #current TimeUnits (alredy with bonsu value from exp)
battle_game.randomRange value valueMin valueMax;
add currTimeUnits value; #effective 1-2 points
soldier.Stats.setTimeUnits currTimeUnits;
#limit Stamina
statChange.getStamina changeStamina; #how much Stamina was incresed by exp
soldier.Stats.getStamina origStamina; #current Stamina (alredy with bonsu value from exp)
battle_game.randomRange value valueMin valueMax;
add currStamina value; #effective 1-2 points
soldier.Stats.setStamina currStamina;
#limit Health
statChange.getHealth changeHealth; #how much Health was incresed by exp
soldier.Stats.getHealth origHealth; #current Health (alredy with bonsu value from exp)
battle_game.randomRange value valueMin valueMax;
add currHealth value; #effective 1-2 points
soldier.Stats.setHealth currHealth;
-
Here's a simple example to set your custom TU increase after a mission:
extended:
scripts:
returnFromMissionUnit:
- offset: 10
code: |
var int statFromGame;
var int statFromGameDiff;
var int statByModder;
soldier.Stats.getTimeUnits statFromGame; # new soldier TU
statChange.getTimeUnits statFromGameDiff; # how much TU was gained this mission
set statByModder statFromGame; # let's take the new soldier TU
sub statByModder statFromGameDiff; # and remove the gain to get the old soldier TU
add statByModder 42; # add whatever custom amount you want
soldier.Stats.setTimeUnits statByModder; # set the newly calculated amount
return;
This is just for illustration, in a real script, you will need to consider stat caps, whether any experience was gained or not, etc.
-
Here's a simple example to set your custom TU increase after a mission:
extended:
scripts:
returnFromMissionUnit:
- offset: 10
code: |
var int statFromGame;
var int statFromGameDiff;
var int statByModder;
soldier.Stats.getTimeUnits statFromGame; # new soldier TU
statChange.getTimeUnits statFromGameDiff; # how much TU was gained this mission
set statByModder statFromGame; # let's take the new soldier TU
sub statByModder statFromGameDiff; # and remove the gain to get the old soldier TU
add statByModder 42; # add whatever custom amount you want
soldier.Stats.setTimeUnits statByModder; # set the newly calculated amount
return;
This is just for illustration, in a real script, you will need to consider stat caps, whether any experience was gained or not, etc.
tyvm Meridian,got it working!
-
This is just for illustration, in a real script, you will need to consider stat caps, whether any experience was gained or not, etc.
alright,does a method exist to return the .rul stat caps with a script?
and thnx for ur help again dude
-
alright,does a method exist to return the .rul stat caps with a script?
yes
-
yes
thnx again
can point me to scripting .rul file docs?
-
If you want to know full list of operations in script you need enable verbose logging in config, with this script will dump all meta information about every script hook to logs.
-
im friggin blind sometimes,sorry if i annoyed