OpenXcom Forum
Modding => OXCE Support => OpenXcom Extended => OXCE Support Y-scripts => Topic started by: Finnik on November 23, 2018, 01:00:49 pm
-
I decided to try to learn how to write Yankes scripts, at least at basic level, so here is my trial release (many thanks to ohartenstein23 for his invaluable help in understanding). This script allows you to set the weapon property (tag) to change the characteristics of the target, which hit the weapon. Stats will be changed to the end of the battle. For example, you can make a blinding gun, lowering Firing, or stim enjector, increasing TUs and, say, Bravery =)
all you need is to define tags in your item, like that:
items:
- type: STR_BUFFER
#categories: [STR_EQUIPMENT]
size: 0.2
costBuy: 10
costSell: 8925
weight: 9
bigSprite: 8585
floorSprite: 8586
bulletSprite: 31
fireSound: 15
power: 5 #there must be a hit event to act the script
damageType: 3
damageAlter:
ToHealth: 0.0
clipSize: -1
accuracyAimed: 110
tuAimed: 15
battleType: 1
twoHanded: false
invWidth: 1
invHeight: 2
recoveryPoints: 2
armor: 10
attraction: 4
listOrder: 39101
tags: #here buff values can be set
FTAG_BUFF_VALUE_TIMEUNITS: 20 #remember add renewable resources to damage alter if positive. this will only affect maximum value, not current
FTAG_BUFF_VALUE_STAMINA: 20
FTAG_BUFF_VALUE_HEALTH: 0
FTAG_BUFF_VALUE_BRAVERY: -20 #negative means debuff
FTAG_BUFF_VALUE_REACTIONS: 20
FTAG_BUFF_VALUE_FIRING: 20
FTAG_BUFF_VALUE_THROWING: 20
FTAG_BUFF_VALUE_MELEE: 20
FTAG_BUFF_VALUE_STRENGTH: 20
FTAG_BUFF_VALUE_PSISTRENGTH: 20
FTAG_BUFF_VALUE_PSISKILL: 20
I will be glad to know what do you think about it. Also any advice is very welcome :D
-
It is fantastic!
But how about stat overflow?
-
I have not faced any problems with it yet. I tried on testing with TUs to be set above 200, everything was fine. also, stats cant be lower 1, so if calculations leads to it, 1 is set instead. But more expirience opinion required for full overview
-
As i remember, in vanilla was a bug, when unit stats increases over 256, they become 1.
-
As i remember, in vanilla was a bug, when unit stats increases over 256, they become 1.
This is in no way related to OXC code, which allows stats of pretty much any value (up to millions).
-
Then we have pretty good stimpacks and magic spells now. :)
-
I decided to try to learn how to write Yankes scripts, at least at basic level, so here is my trial release (many thanks to ohartenstein23 for his invaluable help in understanding). This script allows you to set the weapon property (tag) to change the characteristics of the target, which hit the weapon. Stats will be changed to the end of the battle. For example, you can make a blinding gun, lowering Firing, or stim enjector, increasing TUs and, say, Bravery =)
all you need is to define tags in your item, like that:
I will be glad to know what do you think about it. Also any advice is very welcome :D
Wonderful, Finnik! This is what I looked for! I have planned to make a Combat Whistle, and a Combat Bagpipes so you could encourage your troops to not die and this could be very useful to get the desired effect.
Thank you for making this.
Enviado desde mi iPhone utilizando Tapatalk
-
This is in no way related to OXC code, which allows stats of pretty much any value (up to millions).
But not scripts :> I made deliberate decision to cap stats, upper limit is 1000 (I expects that mods use 100-200 value range, and I multiply it by 5).
Another thing is that is I reduce size of variable that store stats from `int32` to `int16`, this mean right now value is 32*1024. I did that because even you have more that 4GiB free memory, processor memory cache have only couple of MiB and if something not fit it then code is 1000 time slower.
And another thing is low limit, any stat can't have value less than 1, if you did that lot of game logic could go haywire.
-
also ive made script for temporal buff/debuff (it will be off in a set ammount of turns) :D so i can design any buff effect if needed. some example:
i wonder, if i can set any visual effect to a unit with my debuff tag? without making something really huge for recolorUnitSprite
-
also ive made script for temporal buff/debuff (it will be off in a set ammount of turns) :D so i can design any buff effect if needed. some example:
Thank you! I was about to suggest you something like this, actually.
Do you updated the download link?
Enviado desde mi iPhone utilizando Tapatalk
-
not yet, as it will be different script. the one above is specially designed to work with any stat, and now im working on specific daze buff. fading mecanic is much more complicated, so i will be desigh buffs/debuffs separetly if desired, and buff mecanic will be hardcoded. so for now Daze debuff work lowering reactions, but now im setting it to lowering TU by half of original, Reactions buy -30, Firing and trowing -25 and Melee by -15. this is subject of balance talking, but im not feeling ill let modders to change values via tag sets with numbers.
but the code for effect, that was in video is attached here (note, that mod itself is not standalone, its submod for XCF, but i can use script from it in way you like)
-
In my particular opinion, it would be good if you gave modders flexibility to adapt this new temporary script, even if it did not have the different animation.
In case you decide that this temporary buff will be fixed, I present what I have in mind with your script:
Medikit: heals wounds and contains analgesics and stimulants (the same as the vanilla medikit)
Campaign surgery kit: the same as the Medikit, but much better. (Extra +5 Health, +2 Stamina)
Trench Whistle: encourages the troops, raises the reactions and courage. (+7 TU, +10 Bravery, +5 reactions)
Combat Bagpipe: increases bravery, slightly strength, melee damage and stamina (+3 TU, +15 Bravery, +3 Strength, +4 Melee, +4 Stamina)
Bandages: for bleeding and recover a little health. (Stops bleeding, +3 health)
Combat drugs: it increases the precision, the reactions, the force, but reduces the health. (+5 Firing, +10 Reactions, +7 Strength, -8 Health)
Flamethrower: well... is a flamethrower, but reduces enemy reactions and bravery to emule the fear of being roared alive (-10 Reactions, -5 Bravery)
Most of them for three turns, except the medikits and surgery lit, these are more like vanilla medikit.
As you can see, I have many plans for your script, Finnik. :)
Enviado desde mi iPhone utilizando Tapatalk
-
In my particular opinion, it would be good if you gave modders flexibility to adapt this new temporary script, even if it did not have the different animation.
In case you decide that this temporary buff will be fixed, I present what I have in mind with your script:
Medikit: heals wounds and contains analgesics and stimulants (the same as the vanilla medikit)
Campaign surgery kit: the same as the Medikit, but much better. (Extra +5 Health, +2 Stamina)
we cant set Yankes script for medcit use.
Trench Whistle: encourages the troops, raises the reactions and courage. (+7 TU, +10 Bravery, +5 reactions)
Combat Bagpipe: increases bravery, slightly strength, melee damage and stamina (+3 TU, +15 Bravery, +3 Strength, +4 Melee, +4 Stamina)
can be done with first script
Bandages: for bleeding and recover a little health. (Stops bleeding, +3 health)
can be done without scripting with OXCE
Flamethrower: well... is a flamethrower, but reduces enemy reactions and bravery to emule the fear of being roared alive (-10 Reactions, -5 Bravery)
there are mecanics for it already
Most of them for three turns, except the medikits and surgery lit, these are more like vanilla medikit.
can be done without scripting with OXCE
you know, tracking debuff end restore stut to its original value is pretty comlycated thing, so if you can satisfy with permanent buff from first script - just mod and item like i describe above
if you want to make trackable debuff - ill better teach you how to script it =) i dont think trackable debuff made verstile with tags will be unreosanable comlicated both to wright and use for modders
--- posts merged ---
what do you think, guys? this script makes daze on a target, hitted with proper item and fade out in set ammount of turns
extended:
tags:
RuleItem:
FTAG_DAZE_VALUE: int
FTAG_DAZE_TIME: int
BattleUnit:
FTAG_ISDAZED: int #not shure about it
FTAG_DAZE_ENDTURN: int
FTAG_DAZE_ORIGINAL_TIMEUNITS: int
FTAG_DAZE_ORIGINAL_REACTIONS: int
FTAG_DAZE_ORIGINAL_FIRING: int
FTAG_DAZE_ORIGINAL_THROWING: int
FTAG_DAZE_ORIGINAL_MELEE: int
scripts:
hitUnit:
- offset: 1
code: |
var ptr RuleItem itemRuleset;
var int dazeTag;
var int dazeValue;
var int statValue;
var int debuffValue;
var int dazeTime;
var int endTurn;
unit.getTag dazeTag Tag.FTAG_ISDAZED;
if eq dazeTag 69; # Make sure unit already have daze debuff
return power part side;
end;
set dazeTag 69; #set dazed tag
unit.setTag Tag.FTAG_ISDAZED dazeTag;
damaging_item.getRuleItem itemRuleset; #get debuff stats from item
itemRuleset.getTag dazeValue Tag.FTAG_DAZE_VALUE;
itemRuleset.getTag dazeTime Tag.FTAG_DAZE_TIME;
if neq dazeValue 0;
unit.Stats.getTimeUnits statValue; #remember original TimeUnits stat
unit.setTag Tag.FTAG_DAZE_ORIGINAL_TIMEUNITS statValue;
div statValue 2; #calculate TimeUnits debuff, deviding it by 2
unit.Stats.setTimeUnits statValue; #apply debuff
clear statValue;
unit.Stats.getReactions statValue; #remember original Reactions stat
unit.setTag Tag.FTAG_DAZE_ORIGINAL_REACTIONS statValue;
battle_game.randomRange debuffValue 25 35; #calculate random, 25-35 for Reactions
mul debuffValue dazeValue; #calculate debuff
sub statValue debuffValue;
unit.Stats.setReactions statValue; #apply Reactions debuff
clear statValue;
clear debuffValue;
unit.Stats.getFiring statValue; #remember original Firing stat
unit.setTag Tag.FTAG_DAZE_ORIGINAL_FIRING statValue;
battle_game.randomRange debuffValue 20 30; #calculate random, 20-30 for Firing
mul debuffValue dazeValue; #calculate debuff
sub statValue debuffValue;
unit.Stats.setFiring statValue; #apply debuff
clear statValue;
clear debuffValue;
unit.Stats.getThrowing statValue; #remember original Throwing stat
unit.setTag Tag.FTAG_DAZE_ORIGINAL_THROWING statValue;
battle_game.randomRange debuffValue 20 30; #calculate random, 20-30 for Throwing
mul debuffValue dazeValue; #calculate debuff
sub statValue debuffValue;
unit.Stats.setThrowing statValue; #apply debuff
clear statValue;
clear debuffValue;
unit.Stats.getMelee statValue; #remember original Melee stat
unit.setTag Tag.FTAG_DAZE_ORIGINAL_MELEE statValue;
battle_game.randomRange debuffValue 10 20; #calculate random, 10-20 for Melee
mul debuffValue dazeValue; #calculate debuff
sub statValue debuffValue;
unit.Stats.setMelee statValue; #apply debuff
clear statValue;
clear debuffValue;
battle_game.getTurn endTurn;
add endTurn dazeTime; #define end turn for debuff
unit.setTag Tag.FTAG_DAZE_ENDTURN endTurn;
end;
return power part side;
newTurnUnit:
- offset: 2
code: |
var int currTurn;
var int endTurn;
var int dazeTag;
var int originalTimeUnits;
var int originalReactions;
var int originalFiring;
var int originalThrowing;
var int originalMelee;
# Make sure this doesn't run an extra time when civilians have a turn
if eq side 2;
return;
end;
unit.getTag dazeTag Tag.FTAG_ISDAZED;
unit.getTag endTurn Tag.FTAG_DAZE_ENDTURN;
unit.getTag originalTimeUnits Tag.FTAG_DAZE_ORIGINAL_TIMEUNITS;
unit.getTag originalReactions Tag.FTAG_DAZE_ORIGINAL_REACTIONS;
unit.getTag originalFiring Tag.FTAG_DAZE_ORIGINAL_FIRING;
unit.getTag originalThrowing Tag.FTAG_DAZE_ORIGINAL_THROWING;
unit.getTag originalMelee Tag.FTAG_DAZE_ORIGINAL_MELEE;
battle_game.getTurn currTurn;
if eq dazeTag 69;
if eq currTurn endTurn;
unit.Stats.setTimeUnits originalTimeUnits; #revent debuff
unit.Stats.setReactions originalReactions;
unit.Stats.setFiring originalFiring;
unit.Stats.setThrowing originalThrowing;
unit.Stats.setMelee originalMelee;
unit.setTag Tag.FTAG_ISDAZED 0; #cancel tag
end;
end;
return;
im hardcoded parameters of daze debuff, it halfs TUs, decrease reactions by 25-35, firing and throwing by 20-30, and melee by 10-20. numbers are subject of balance talking.
you still can adjust values. place this in your item.rul
tags:
FTAG_DAZE_VALUE: 1 #this is multiplyer to numbers above. if lower than 1, debuff will be weaker, if higher - stronger
FTAG_DAZE_TIME: 2 #number of turns before fading
here is example mod. note, its is submod for XCF, which, btw, i strongly recommend to check out https://openxcom.mod.io/the-x-com-files
-
you know, tracking debuff end restore stut to its original value is pretty comlycated thing, so if you can satisfy with permanent buff from first script - just mod and item like i describe above
if you want to make trackable debuff - ill better teach you how to script it =) i dont think trackable debuff made verstile with tags will be unreosanable comlicated both to wright and use for modders
As you indicate, seems that medical stuff could use codes mostly based on OXCE existent stuff, I'll give them a check:)
If you think my ideas could be done using the first script, it's OK, then. I'll use it. :) Thank you for making this! I'll keep an eye on your project.
-
TY! problem is im using hitUnit hook in Yankes script to set up debuff(buff) effect from item, so you actually need to hit with that item. it can be done with firing, melee, grenede or thing like my flashbang above, but you need a hit. as far as i know, medkit is not a hit event.
-
Can this be applied to recovery/regeneration methods?
Like health recovery, stamina recovery or any kind of stat recovery like a regeneration buff/debuff i would like (if armor stats can be regenerated or recoverable)
no, but there is script for that already (i think, Otto maid it)
(man i wish future OXCE (along new codes and others) should have cloaking, concealment(s) and cloaked units, aliens and enemies)
there are, at least in XCOM files, stealth feature. Easy to make with OXCE. dont know how to make temporal stealth and if its needed. i think its bad game design, if its not rare in game
-
Right... :-\
Let these my 2 OXCE suggestions (regeneration/restoration buffs/debuffs, and cloaking and cloaked units) be rejected then. VʌV'
Finnik is not rejecting you. Ask Otto if he has written some code like the ones you need. :)
Enviado desde mi iPhone utilizando Tapatalk