In sotis there once was an ability that could reset a unit in time, by recovering the position, cooldowns, energy/health levels, buffs etc. it had X seconds before - how would you create such an ability?
I think that would require more triggers than data. The easiest solution I can think of is to create struct/record and fill it with variables to save whatever you want to save. Then have it update every second or less and when the ability is used restore the data that was saved earlier.
In order to save the data of the unit you'll need variables and the reason why it is better to store them in a record is because you'll a better overview and you can create a array of it instead of each individual variable. It's basically a variable(or more) in a variable. The main data that you'll want to store are its position(point), hp(real) and energy(real), but you can add anything you like.
Now you'll need is a variable to define the record, the type will be record. Next thing you need is action definition, under options check create thread and under parameters create a variable of the type unit Add the action repeat forever, under this repeat create a set variable action and set the variable to the variable of the record and it's member to the hp variable. It's value will then be Unit Property, the unit parameter of this function should link to the unit parameter created earlier, also add one for it's position, energy and anything you want store. At the and of this repeat add a wait action of 3 seconds.
Now create a new trigger with a Unit Uses Ability and link it to an (dummy) ability(you'll have to create this). Under actions add a Move Unit Instantly action and a Set Unit Property action, their value parameter should link to the ones in the record.
And the last thing is to add a Map Initalization trigger and add the action created earlier.
Oh wow okay slowly. I never even opened the trigger window before okay? Well, only to remove the melee-stuff.
Would be great if you could explain it again a bit more thoroughly and with more steps. If it's hard to explain you can always make a few screenshots to show it to me.
Also getting a terrible headache trying to decipher what you are saying in the middle part.
I got the last part, but you need to explain how I let the trigger know the right variables again, because I really didn't understand anything there.
Oh wow okay slowly. I never even opened the trigger window before okay? Well, only to remove the melee-stuff.
Would be great if you could explain it again a bit more thoroughly and with more steps. If it's hard to explain you can always make a few screenshots to show it to me.
Also getting a terrible headache trying to decipher what you are saying.
His guide already has every single step as far as I can tell, if you don't know what he wants you to do then read beginner tutorials for the Triggereditor before you go into making this ability or ask specific questions about the step that you have problems with (or even better, use the search function of the forum first and only ask here if you can't find anything via search).
I searched for similar things first of course. While I was trying to understand what he is saying I read a beginner guide for the trigger editor, but nevertheless I need the steps for the variables more in-depth. I understand the last part just fine, it's really easy, but how I setup the variables so they are 5 seconds in the past and how I create that in the trigger editor is just not clear to me.
Some more " " around options and checkboxes etc. in the trigger editor would help me not getting a headache reading it.
I got the last part, but you need to explain how I let the trigger know the right variables again, because I really didn't understand anything there.
What he basically wants you to do is to create an action that saves all the variables that you want to reset with your ability every 3 seconds. As in the HP, Energy, Position, Facing, Ability Cooldowns and stuff like that. You can use separate variables for each of these attributes of the unit if you want, but it gets really messy very fast if you do that (especially if multiple players can have a unit with that ability, so you have to save multiple states for multiple units frequently). So he recommends that you use a Record for that, which is basically a list of different variables, and you put everything that you want to reset with the ability into that record as a variable with the correct type (as in Real for HP/Energy, Point for the Position etc.).
Then you have to create an action that periodically saves the state, and you do that by creating a new "Action Definition", check the box which says "Create as Thread" and then add an Action "Repeat Forever" in which you include all the Set Variables for your unit variables (HP, Energy etc.) and a Wait Action with 3 Seconds. That means every 3 seconds the state gets saved, and then you can use these variables to teleport your unit / set the HP to the right amount etc.
Note that this way will really only save the state every 3 seconds, so it won't work completely as intended because it would teleport the unit back for a random time between 0 and 3 seconds (whatever the last saved state was). The correct way to do this would be to use a more frequent loop (set the wait to a time like 0.25 or 0.5 seconds), then count the correct amount of cycles that you want to go back in time and save the state from that time ago into the variables that you want to use in your "Ability Used" Event.
I took the time and made a raw version of the ability that you can check out for reference. Note that it has a couple of problems, for example if you have multiple units with this ability on the field you have to use an array of States/Loop variables, I would also use a smaller wait time and therefore larger arrays (for the variables in the record) to make it appear smoother/in less varying intervals.
Edit:
Also note that I wouldnt use a "Repeat Forever" if I actually wanted to implement this in a map but a "While (ParamUnit is Alive == true)" or some similar condition that doesn't make the loop repeat forever even if the unit with the ability already died.
I understood the theoretical part, what I need is the practical one. Aka how I build the trigger.
To make my problem more clear. I don't know how to make the trigger out of the theoretical part. Do I make a variable, call it for example "HP" and then make an action "Set Variable". Then there is "Variable" and "Value" that I have to set. Variable is clear - it's the one I want to set, which would be "HP" in this case. But what do I have to put into "Value" so it takes the Unit HP?
Also as a side note: This ability will only used by one unit and that unit is unique in the game, so we don't need to make it super clean.
Just read your second post: It would be good to have that parameter. Imagine there are about 11 heros and only ever one gets picked (total), so the chance this trigger is needed is rather low. Also the ability is somewhat hard to reach.
I understood the theoretical part, what I need is the practical one. Aka how I build the trigger.
To make my problem more clear. I don't know how to make the trigger out of the theoretical part. Do I make a variable, call it for example "HP" and then make an action "Set Variable". Then there is "Variable" and "Value" that I have to set. Variable is clear - it's the one I want to set, which would be "HP" in this case. But what do I have to put into "Value" so it takes the Unit HP?
Also as a side note: This ability will only used by one unit and that unit is unique in the game, so we don't need to make it super clean.
Just read your second post: It would be good to have that parameter. Imagine there are about 11 heros and only ever one gets picked (total), so the chance this trigger is needed is rather low. Also the ability is somewhat hard to reach.
Look into the map, the loops only get used if you the hero is in the map because you have to reference the hero to even make it work, otherwise there would be no Position, HP or something like this to save.
Just try to understand what I did in the map that I uploaded and ask your questions related to that if possible.
Okay - let's say, I understood most of what you did, but I can not say I would be able to recreate that, as I don't know how to manage things yet.
So I think I can edit that trigger to what I need (I added energy successfully) - only question is, does it work like you said or not? You said I should reduce the wait-time to make it run smoother.
Other thing is... what do I need to change to change the time the unit gets set back? For example if I want the ability to set the unit 4 seconds back in time instead of 3.
You have to assign the loop to a unit, because the actions have to know what unit they are running for/for what Unit they set the HP/Position etc. Variables. That's what the Unit Parameter (ParamUnit) is for and you can do that at either MapInit or if the Unit is not preplaced when the unit is created / chosen by a player / whatever. As soon as you use the action definition that we created ("State Save" or whatever I called it) with the Unit that has the ability as the Parameter your ability starts to work.
Your way of increasing the length and choosing smaller wait time intervals is correct, you just have to increase the size of the arrays for the variables in the record ("State") accordingly (right now it's set to 6, you probably want something like 20).
edit:
Also make sure the conditions (i==6) or (i==5) in the if statements are adjusted accordingly so they fit with the Size of the Array or (Size of Array-1).
Copied the Trigger to my map, of course all the variables broke =P but I fixed everything and it resets you 5 seconds back in time now. Didn't test lost energy/health but it should work, position works too, so why wouldn't it?
I think I can add ability cooldowns if I want to add them, but currently I scraped those plans for ability balancing reasons.
Thanks there, this will definitely make a nice ultimate.
Can anyone explain me how I can make it so this trigger is working in every case? Let's imagine the unit that should be set back in time is a standard-army unit and can be produced a lot.
I would need to make the trigger run the function that saves the state at the event "Unit created" or "Unit enters region". As far as I know I need a global variable "unit type" that I can use, otherwise I can use this trigger only for preplaced units.
So could anyone explain me step-by-step how I can do this?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
In sotis there once was an ability that could reset a unit in time, by recovering the position, cooldowns, energy/health levels, buffs etc. it had X seconds before - how would you create such an ability?
I think that would require more triggers than data. The easiest solution I can think of is to create struct/record and fill it with variables to save whatever you want to save. Then have it update every second or less and when the ability is used restore the data that was saved earlier.
Hm, okay I guess then I have to start messing with triggers - I have quite some knowledge in data by now, but I never messed with triggers.
Would be nice if someone could explain me - in a way for a trigger beginner (with common sense though) - what I need to do exactly.
I'll also let someone move this to triggers then. ^^
In order to save the data of the unit you'll need variables and the reason why it is better to store them in a record is because you'll a better overview and you can create a array of it instead of each individual variable. It's basically a variable(or more) in a variable. The main data that you'll want to store are its position(point), hp(real) and energy(real), but you can add anything you like.
Now you'll need is a variable to define the record, the type will be record. Next thing you need is action definition, under options check create thread and under parameters create a variable of the type unit Add the action repeat forever, under this repeat create a set variable action and set the variable to the variable of the record and it's member to the hp variable. It's value will then be Unit Property, the unit parameter of this function should link to the unit parameter created earlier, also add one for it's position, energy and anything you want store. At the and of this repeat add a wait action of 3 seconds.
Now create a new trigger with a Unit Uses Ability and link it to an (dummy) ability(you'll have to create this). Under actions add a Move Unit Instantly action and a Set Unit Property action, their value parameter should link to the ones in the record.
And the last thing is to add a Map Initalization trigger and add the action created earlier.
Oh wow okay slowly. I never even opened the trigger window before okay? Well, only to remove the melee-stuff.
Would be great if you could explain it again a bit more thoroughly and with more steps. If it's hard to explain you can always make a few screenshots to show it to me.
Also getting a terrible headache trying to decipher what you are saying in the middle part.
I got the last part, but you need to explain how I let the trigger know the right variables again, because I really didn't understand anything there.
His guide already has every single step as far as I can tell, if you don't know what he wants you to do then read beginner tutorials for the Triggereditor before you go into making this ability or ask specific questions about the step that you have problems with (or even better, use the search function of the forum first and only ask here if you can't find anything via search).
I searched for similar things first of course. While I was trying to understand what he is saying I read a beginner guide for the trigger editor, but nevertheless I need the steps for the variables more in-depth. I understand the last part just fine, it's really easy, but how I setup the variables so they are 5 seconds in the past and how I create that in the trigger editor is just not clear to me.
Some more " " around options and checkboxes etc. in the trigger editor would help me not getting a headache reading it.
What he basically wants you to do is to create an action that saves all the variables that you want to reset with your ability every 3 seconds. As in the HP, Energy, Position, Facing, Ability Cooldowns and stuff like that. You can use separate variables for each of these attributes of the unit if you want, but it gets really messy very fast if you do that (especially if multiple players can have a unit with that ability, so you have to save multiple states for multiple units frequently). So he recommends that you use a Record for that, which is basically a list of different variables, and you put everything that you want to reset with the ability into that record as a variable with the correct type (as in Real for HP/Energy, Point for the Position etc.).
Then you have to create an action that periodically saves the state, and you do that by creating a new "Action Definition", check the box which says "Create as Thread" and then add an Action "Repeat Forever" in which you include all the Set Variables for your unit variables (HP, Energy etc.) and a Wait Action with 3 Seconds. That means every 3 seconds the state gets saved, and then you can use these variables to teleport your unit / set the HP to the right amount etc.
Note that this way will really only save the state every 3 seconds, so it won't work completely as intended because it would teleport the unit back for a random time between 0 and 3 seconds (whatever the last saved state was). The correct way to do this would be to use a more frequent loop (set the wait to a time like 0.25 or 0.5 seconds), then count the correct amount of cycles that you want to go back in time and save the state from that time ago into the variables that you want to use in your "Ability Used" Event.
I took the time and made a raw version of the ability that you can check out for reference. Note that it has a couple of problems, for example if you have multiple units with this ability on the field you have to use an array of States/Loop variables, I would also use a smaller wait time and therefore larger arrays (for the variables in the record) to make it appear smoother/in less varying intervals.
Edit:
Also note that I wouldnt use a "Repeat Forever" if I actually wanted to implement this in a map but a "While (ParamUnit is Alive == true)" or some similar condition that doesn't make the loop repeat forever even if the unit with the ability already died.
I understood the theoretical part, what I need is the practical one. Aka how I build the trigger.
To make my problem more clear. I don't know how to make the trigger out of the theoretical part. Do I make a variable, call it for example "HP" and then make an action "Set Variable". Then there is "Variable" and "Value" that I have to set. Variable is clear - it's the one I want to set, which would be "HP" in this case. But what do I have to put into "Value" so it takes the Unit HP?
Also as a side note: This ability will only used by one unit and that unit is unique in the game, so we don't need to make it super clean.
Just read your second post: It would be good to have that parameter. Imagine there are about 11 heros and only ever one gets picked (total), so the chance this trigger is needed is rather low. Also the ability is somewhat hard to reach.
Look into the map, the loops only get used if you the hero is in the map because you have to reference the hero to even make it work, otherwise there would be no Position, HP or something like this to save.
Just try to understand what I did in the map that I uploaded and ask your questions related to that if possible.
Okay - let's say, I understood most of what you did, but I can not say I would be able to recreate that, as I don't know how to manage things yet.
So I think I can edit that trigger to what I need (I added energy successfully) - only question is, does it work like you said or not? You said I should reduce the wait-time to make it run smoother.
Other thing is... what do I need to change to change the time the unit gets set back? For example if I want the ability to set the unit 4 seconds back in time instead of 3.
I figured it out. If I set the waittime to 0.25 instead and make i reset at 20 instead of 6 it is 5 seconds (because 20x0.25=5).
Now I get an error though (despite the ability working fine): Error in gt_MapInit_Func: Trying to access an element past the array.
What is the MapInit Trigger for anyway? That's not quite clear to me.
You have to assign the loop to a unit, because the actions have to know what unit they are running for/for what Unit they set the HP/Position etc. Variables. That's what the Unit Parameter (ParamUnit) is for and you can do that at either MapInit or if the Unit is not preplaced when the unit is created / chosen by a player / whatever. As soon as you use the action definition that we created ("State Save" or whatever I called it) with the Unit that has the ability as the Parameter your ability starts to work.
Your way of increasing the length and choosing smaller wait time intervals is correct, you just have to increase the size of the arrays for the variables in the record ("State") accordingly (right now it's set to 6, you probably want something like 20).
edit:
Also make sure the conditions (i==6) or (i==5) in the if statements are adjusted accordingly so they fit with the Size of the Array or (Size of Array-1).
Copied the Trigger to my map, of course all the variables broke =P but I fixed everything and it resets you 5 seconds back in time now. Didn't test lost energy/health but it should work, position works too, so why wouldn't it?
I think I can add ability cooldowns if I want to add them, but currently I scraped those plans for ability balancing reasons.
Thanks there, this will definitely make a nice ultimate.
Can anyone explain me how I can make it so this trigger is working in every case? Let's imagine the unit that should be set back in time is a standard-army unit and can be produced a lot.
I would need to make the trigger run the function that saves the state at the event "Unit created" or "Unit enters region". As far as I know I need a global variable "unit type" that I can use, otherwise I can use this trigger only for preplaced units.
So could anyone explain me step-by-step how I can do this?