OpenXcom Forum
Modding => Help => Topic started by: Nirran on November 16, 2023, 06:36:22 am
-
my script triggers on the hit but soldier dies anyway,looked at script ,donno what to look for
any way to prevent the transformation with scripts?4
-
you need scripthook "damageSpecialUnit"
in which you should modify variable "transform_chance".
-
you need scripthook "damageSpecialUnit"
in which you should modify variable "transform_chance".
Thnx Dude
question: this obviously isnt the entirte hook list,mind dirrecting me to the complete list?
Unit scripts
recolorUnitSprite: Runs for every pixel of a units graphic. Change to any color.
selectUnitSprite: Runs for every part of a units graphic. E.g. Change the graphic used for legs.
selectMoveSoundUnit: Runs for each unit step.
reactionUnitAction: Runs when an unit performs an action that triggers reaction fire.
reactionUnitReaction: Runs when a unit sees another unit perform an action that triggers reaction fire.
hitUnit: When a unit is hit it allows adjusting damage and the part of the body it affects. Runs before damageUnit
damageUnit: Used to alter the final change to stats of a unit when its hit by a weapon. If unit receives a hit with 0 power this script doesnt run.
healUnit: Used to alter effect of medikit on unit. Can alter exp from usage of it.
createUnit: Runs when new unit is created
newTurnUnit: Runs for every unit every turn (this includes alien, civilian and xcom turns)
returnFromMissionUnit: Runs for every unit at the end of a mission.
awardExperience: Runs whenever a unit performs an action that can earn it experience.
visibilityUnit: Runs to check if two units of opposing factions can see each other.
Item scripts
recolorItemSprite: Runs for every pixel of sprite. Change color.
selectItemSprite: Run to change the graphic of an item when its on the floor or in the hands of a soldier
reactionWeaponAction: Runs for the weapon that triggered reaction shots by firing.
createItem: Runs when a new item is created.
newTurnItem: Runs for each item each turn. (this includes alien, civilian and xcom turns)
Stat bonus scripts
For armors: psiDefence, meleeDodge, recovery (time, energy, morale, health, stun, mana)
For items: damageBonus, meleeBonus, accuracyMultiplier, meleeMultiplier, throwMultiplier, closeQuartersMultiplier
For units: applySoldierBonuses: Runs once for each bonus of each soldier on mission start.
seems oxce has alot of variations of get/set
edit: what is the correct synthax to get/set transform_chance?
edit2: typo
-
To create full list of script commands, you need to switch "verboseLogging" in options.cfg to "true", then launch oxce, then quit and open file "openxcom.log". It will contain not only log, but script help. Save it somewhere, and remember to update when upgrade to newer OXCE version.
edit: what is the correct synthax to get/set transform_chance?
Just as any variable,
set temp transform_chance;
...magic...
set transform_chance temp;
Like 0 is no transform at all, 100 - transform by any circumstances.
-
To create full list of script commands, you need to switch "verboseLogging" in options.cfg to "true", then launch oxce, then quit and open file "openxcom.log". It will contain not only log, but script help. Save it somewhere, and remember to update when upgrade to newer OXCE version.
Just as any variable,
set temp transform_chance;
...magic...
set transform_chance temp;
Like 0 is no transform at all, 100 - transform by any circumstances.
I Tried both of those,they both break the script
thnx tho for trying
-
Youmust
I Tried both of those,they both break the script
Show it here.
-
Youmust Show it here.
my script i tried these :
#get transform_chance temp;
#set transform_chance temp;
#set temp transform_chance;
#debug_log "transform " temp;
it is a script to cheat death,originaly copied from Meridian lucky script i found on this forum,this doesnt fire if i uncoment those(one at a time of course)
unit.getHealth Health; # get current health
sub Health to_health; # sub projected hp loss from current hp
debug_log "Unconscious Code Health:" Health;
unit.getStun stunLevel; # set var to unit stun level
add stunLevel to_stun; # add projected stun level to current stun level
debug_log "Unconscious Code Stun:" stunLevel;
#get transform_chance temp;
#set transform_chance temp;
#set temp transform_chance;
#debug_log "transform " temp;
if ge stunLevel Health;
#battle_game.flashLongMessage "STR_TRANSFORM_STRING";
battle_game.flashLongMessage "STR_UNCONSCIOUS_STRING";
#set transform_chance temp;
#debug_log "transform " temp";
unit.getHealthMax temp;
unit.setHealth temp;
mul temp 4;
unit.setStun temp;
set to_health 0;
set to_stun 0;
set to_wound -50;
unit.disableIndicators;
unit.setTag Tag.LRF_IS_DEAD 1;
return;
end;
-
first string is wrong, and you forget about @magic@ in a middle.
If you want make chances equal to 0:
set transform_chance 0;
If you want set chances 15% less:
set temp transform_chance;
muldiv temp 85 100;
set transform_chance temp;
And dont forget to define variable in a beginning of script:
damageSpecialUnit:
- offset: 11 # any number for counting
code: |
var int temp;
-
first string is wrong, and you forget about @magic@ in a middle.
If you want make chances equal to 0:
set transform_chance 0;
If you want set chances 15% less:
set temp transform_chance;
muldiv temp 85 100;
set transform_chance temp;
And dont forget to define variable in a beginning of script:
damageSpecialUnit:
- offset: 11 # any number for counting
code: |
var int temp;
ok thnx for reply,i tried a few variasions of this
scripts:
damageSpecialUnit:
- offset: 99
code: |
var int temp 0;
var int transform 0;
set temp transform_chance;
...magic...
set transform_chance temp;
debug_log "transform " temp;
battle_game.flashLongMessage "STR_TRANSFORM_STRING";
they break the code,and the string dosnt fire
-
:) "...magic..." is not an operator, it is a joke.
Dont write it.
-
:) "...magic..." is not an operator, it is a joke.
Dont write it.
haha wasnt sure,tried this and debug line doesnt fire
extended:
tags:
BattleUnit:
LRF_IS_DEAD: int
scripts:
damageSpecialUnit:
- offset: 99
code: |
var int temp 0;
var int transform 0;
set temp transform_chance;
#...magic...
set transform_chance temp;
debug_log "transform " temp;
battle_game.flashLongMessage "STR_TRANSFORM_STRING";
-
anybody know why that code fails?
-
You should know it, you have all available tools to debug this, look in logs and see what was there.
-
you forget
return;
in the end.
-
You should know it, you have all available tools to debug this, look in logs and see what was there.
its is bit problematic,as the debug doesnt spam anything i try,nothign fires
you forget return;
in the end.
tried that,no dice,thnx for trying
-
Sorry, but I tried your script and the logs clearly indicate what's wrong.
[23-11-2023_07-09-43] [ERROR] Invalid variable name 'transform'
[23-11-2023_07-09-43] [ERROR] Error in matching arguments for operator 'var'
[23-11-2023_07-09-43] [ERROR] Error in parsing script 'damageSpecialUnit' for 'Global Event Script': invalid operation in line: 'var int transform 0;'
It says exactly, which line is wrong ('var int transform 0;').
And it says exactly what's wrong (invalid variable name).
And Nord's answer is also correct.
Once you fix the issue with the variable name, the logs will complain about the missing return too.
Here's a fixed script:
extended:
tags:
BattleUnit:
LRF_IS_DEAD: int
scripts:
damageSpecialUnit:
- offset: 99
code: |
var int temp 0;
var int transformx 0;
set temp transform_chance;
#...magic...
set transform_chance temp;
debug_log "transform " temp;
battle_game.flashLongMessage "STR_TRANSFORM_STRING";
return;
-
Sorry, but I tried your script and the logs clearly indicate what's wrong.
[23-11-2023_07-09-43] [ERROR] Invalid variable name 'transform'
[23-11-2023_07-09-43] [ERROR] Error in matching arguments for operator 'var'
[23-11-2023_07-09-43] [ERROR] Error in parsing script 'damageSpecialUnit' for 'Global Event Script': invalid operation in line: 'var int transform 0;'
It says exactly, which line is wrong ('var int transform 0;').
And it says exactly what's wrong (invalid variable name).
And Nord's answer is also correct.
Once you fix the issue with the variable name, the logs will complain about the missing return too.
Here's a fixed script:
extended:
tags:
BattleUnit:
LRF_IS_DEAD: int
scripts:
damageSpecialUnit:
- offset: 99
code: |
var int temp 0;
var int transformx 0;
set temp transform_chance;
#...magic...
set transform_chance temp;
debug_log "transform " temp;
battle_game.flashLongMessage "STR_TRANSFORM_STRING";
return;
my bad god i was looking for errors at end of the log,thinking that the script would error after the attack and it would be at bottom of the file
thanks once again Meridian
-
is transform_chance always 100 if it isnt modded?
-
no, the default value is this:
const RuleItem *specialDamageTransform = attack.damage_item ? attack.damage_item->getRules() : nullptr;
int specialDamageTransformChance = 0;
if (specialDamageTransform
&& !specialDamageTransform->getZombieUnit(this).empty()
&& getArmor()->getZombiImmune() == false)
{
specialDamageTransformChance = getOriginalFaction() != FACTION_HOSTILE ? specialDamageTransform->getZombieUnitChance() : 0;
}
-
no, the default value is this:
const RuleItem *specialDamageTransform = attack.damage_item ? attack.damage_item->getRules() : nullptr;
int specialDamageTransformChance = 0;
if (specialDamageTransform
&& !specialDamageTransform->getZombieUnit(this).empty()
&& getArmor()->getZombiImmune() == false)
{
specialDamageTransformChance = getOriginalFaction() != FACTION_HOSTILE ? specialDamageTransform->getZombieUnitChance() : 0;
}
thanks again dude