1
OXCE Support Y-scripts / Re: Drugs that restore / give time (tu)
« on: June 17, 2022, 01:55:18 am »
I see two issues with the script.
Firstly the scripthook is missing (i.e. the part that determines when the script runs). I presume the script you grabbed used the healUnit: hook, you need to add it one line above code: |. Note that if you're adding it to a file with multiple existing scripts, there might already be a healUnit: hook, in which case you only need to add the script after it (adding the hook again will not work).
Secondly the Tag required by the script most likely isn't defined which means you need to add that too. Here is an example on how it should look like:
One pitfall to avoid is that you need to add tags to an item in the same file as where the tags are defined, otherwise the script may not work.
The easiest way to achieve what you're trying to do would be to just to create a new .rul file and add the new script and item, it should look something like this
Firstly the scripthook is missing (i.e. the part that determines when the script runs). I presume the script you grabbed used the healUnit: hook, you need to add it one line above code: |. Note that if you're adding it to a file with multiple existing scripts, there might already be a healUnit: hook, in which case you only need to add the script after it (adding the hook again will not work).
Secondly the Tag required by the script most likely isn't defined which means you need to add that too. Here is an example on how it should look like:
Code: [Select]
extended:
tags:
RuleItem:
WM_IS_WACKY: int
If the RuleItem section already exists in the file you can just add WM_IS_WACKY: int among the existing tags.One pitfall to avoid is that you need to add tags to an item in the same file as where the tags are defined, otherwise the script may not work.
The easiest way to achieve what you're trying to do would be to just to create a new .rul file and add the new script and item, it should look something like this
Code: [Select]
items:
- type: STR_COMBAT_DRUGS
medikitActionName: STR_INJECT
costUse:
time: 1
health: 1 (We will lost 1 hp for each use)
stun: -50
morale: -50
mana: -50
costThrow:
energy: 6
time: 40
flatRate: true
isConsumable: true
flatUse:
time: true
health: true
recoveryPoints: 1
tags: (The tag is what the script will use)
WM_IS_WACKY: 1
extended:
tags:
RuleItem:
WM_IS_WACKY: int
scripts:
healUnit:
code: |
var int temp;
item.getTag temp Tag.WM_IS_WACKY;
if neq temp 0;
# debug_log "healUnit: applying wacky medikit, skip normal effects completely";
set medikit_action_type 0;
target.getTimeUnits temp;
add temp 55;
target.setTimeUnits temp;
target.getEnergy temp;
add temp 50;
target.setEnergy temp;
return;
end;
# debug_log "healUnit: not wacky...";
return;