aliens

Author Topic: code snip help please  (Read 2389 times)

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
code snip help please
« on: February 08, 2021, 02:20:46 pm »
why doesnt this work?ive tried many variations,none do anything

im trying to remove the engine added stats and use my own

this is available commands i read(is this wrong?)

Code: [Select]
          #statPrevious - original stats before mission (read only)
          #statChange - stats change from exp (read only)
          #soldier.Stats - current stats of geoscape soldier, if you change it it will permanently change stats of soldier
          #unit.Stats - stats of battle soldier, changed by armor. Only affect current battle.
          #unit.Exp - exp grain during battle (read only)

and this is what i have so far

Code: [Select]
          #arbitrary value
          #unit.Exp.getTimeUnits changeTimeUnits;
          #statChange.getTimeUnits changeTimeUnits;
          statPrevious.getTimeUnits prevTimeUnits;  
          soldier.Stats.getTimeUnits origTimeUnits;
          sub origTimeUnits prevTimeUnits;
          soldier.Stats.getTimeUnits currTimeUnits;
          #battle_game.randomRange value valueMin valueMax;
          sub currTimeUnits origTimeUnits; #remove engine added  
          #add origTimeUnits value; #add 1-3 to old stat
          soldier.Stats.setTimeUnits currTimeUnits; #overwrite stat +1-3

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: code snip help please
« Reply #1 on: February 08, 2021, 03:02:36 pm »
What you mean by "why doesnt this work"? what you tried exactly and what exact result was.

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: code snip help please
« Reply #2 on: February 08, 2021, 03:11:08 pm »
it seems these arent valid,got them off a forum post here,all 4 produce errors  in .log

Code: [Select]
          #statPrevious - original stats before mission (read only)
          #statChange - stats change from exp (read only)
          #soldier.Stats - current stats of geoscape soldier, if you change it it will permanently change stats of soldier
          #unit.Stats - stats of battle soldier, changed by armor. Only affect current battle.
          #unit.Exp - exp grain during battle (read only)

does a list of scripting commands exist?

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: code snip help please
« Reply #3 on: February 08, 2021, 05:38:08 pm »
This is not commands, this is hints where here find data you need.
Operation would look like `soldier.Stats.getTimeUnits tu;`.

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.

beside when you get error in any program you should post it in your question, because it is critical to understand what go wrong.

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: code snip help please
« Reply #4 on: February 08, 2021, 08:22:42 pm »
thank you,i got the list of synthax,how are these declared?

Code: [Select]
#Name: soldier                                 ptre      GeoscapeSoldier
#Name: statChange                              ptr       StatAdjustment
#Name: statPrevious                            ptr       StatAdjustment
#Name: unit                                    ptre      BattleUnit

this way errors in .log
Code: [Select]
          var ptr StatAdjTime statChange;
          var ptr StatPrev statPrevious;

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: code snip help please
« Reply #5 on: February 08, 2021, 10:25:45 pm »
ok did some testing these throw errors :

code is
Code: [Select]
statChange.getTimeUnits incTimeUnits;error is
Code: [Select]
[ERROR] Error in parsing script 'returnFromMissionUnit' for 'Global Event Script': invalid operation name 'statChange.getTimeUnits'
code is
Code: [Select]
statPrevious.getTimeUnits origTimeUnits;error is
Code: [Select]
[ERROR] Error in parsing script 'returnFromMissionUnit' for 'Global Event Script': invalid operation name 'statPrevious.getTimeUnits'
code is
Code: [Select]
unit.Exp.getTimeUnits changeTimeUnits;error is
Code: [Select]
[ERROR] Error in parsing script 'returnFromMissionUnit' for 'Global Event Script': invalid operation name 'unit.Exp.getTimeUnits'
however this is in the 'verboseLogging' dump

Code: [Select]
Name: rules                                   ptr       RuleMod 
Name: soldier                                 ptre      GeoscapeSoldier
Name: statChange                              ptr       StatAdjustment
Name: statPrevious                            ptr       StatAdjustment
Name: unit                                    ptre      BattleUnit
« Last Edit: February 08, 2021, 10:47:54 pm by Nirran »

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: code snip help please
« Reply #6 on: February 09, 2021, 12:19:55 am »
`getTimeUnits` do not exists for this types. This is because game handle them differently in exp grains (this is this stas you can see on main battle scape screen).
if you use `getBravery`(or other similar) this should work.

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: code snip help please
« Reply #7 on: February 09, 2021, 12:29:05 am »
ok :( thnx

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: code snip help please
« Reply #8 on: February 09, 2021, 01:12:48 am »
any way of coding or using rule settings for all stats for override ?

i want to make each gain small while having a large stat cap,and engine increases individual gains with higher stat caps

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: code snip help please
« Reply #9 on: February 09, 2021, 12:19:48 pm »
Ok, after digging to code I saw that I make mistake, I handled `statChange` same as `unit.Exp`,
but at end of mission there is special code that update base stats too (like TU) if you have any exp (and this is different to other stats that each have own exp).
This mean I block access info how this stats changed.

Beside that, you still have access to `soldier.Stats.setTimeUnits` etc. (previously I was referring only to types that give you errors).
If you want to know what what limits there are you can use e.g.
Code: [Select]
var ptr RuleSoldier rule;

soldier.getRuleSoldier rule;

rule.StatsCap.getTimeUnits temp;

rule.StatsMin.getTimeUnits temp;

rule.StatsMax.getTimeUnits temp;