Hey people, I am trying to make a hero reviving method via banks, basically when a unit takes damage, its position, owner, angle and type are saved into a bank, and if it dies it restores him in those specific locations.
As far as I know, using both [Wait] and [Triggering...] will give you problems. I am not sure if it forgets who was the triggering unit after a while, or if another triggering unit gets overwritten to the memory, and when it tries to call it, it doesn't find the triggering player from the previous. Now, I didn't look through the hole trigger, so this may seem far fetched. But try it out. Remove the wait from the trigger and test it.
Anyways: Always save values you will need more than once in a local variable instead of calling the function dozens of times. No matter if it's an integer, unit,..! Just imagine you would like to change triggering unit to "target of triggering unit" and would need to look through 100 lines of GUI code :D
Or you wouldn't need to use "Owner of triggering unit -1" all the time ;)
But it's strange though: if "Owner of triggering unit" doesn't return the correct value but just the lowest possible value like 0, it should still work in your example. But it could also be possible that the engine shuts down the whole trigger thread if it realizes that the triggering unit is dead and gone after the 15-25 seconds wait.
Try storing the owner in a local variable and see what comes out.
And another note: You wouldn't need to use banks to do a revive system if you don't plan on being able to use the hero progressivly each time the players play your map. A bank is a file on the player's computer in case you don't know.
Some global arrays or a database would also work.
The variables are all global, and if I wouldn't use the [owner of triggering unit -1] i would have to copy and phaste 10 times and change it from 0-9 since there are 10 players and each one has its slot in the array, player one has [0], player 2 has [1] etc...
also the wait has nothing to do with it since the error displayed mentions the problem is located at the action of Restore Unit. so it reaches it nonetheless.
What I dont understand is whats wrong with the restore unit actions? they seem to use all the right data.
Try storing the owner in a local variable and see what comes out.
This could realy solve the problem.
Because a unit will be removed from the game after death (if you don't set the the deathtime in unit stats).
After that Triggering Unit points to nothing and you get an exception because your array index gets -1.
So here are the solutions:
Set Stats- Deathtime to e.g. 30sec so the Hero is not removed when you want to use it for indexes
or save the playernumber in a local variable so you are independet from the hero variable
The variables are all global, and if I wouldn't use the [owner of triggering unit -1] i would have to copy and phaste 10 times and change it from 0-9 since there are 10 players and each one has its slot in the array, player one has [0], player 2 has [1] etc...
Triggering Unit, Last restored Unit etc. are functions that grant access to (local) variables wich are linked with each trigger execution.
The clue with local vars is that u write instead of
This could realy solve the problem.
Because a unit will be removed from the game after death (if you don't set the the deathtime in unit stats). After that Triggering Unit points to nothing and you get an exception because your array index gets -1.
So here are the solutions:
Set Stats- Deathtime to e.g. 30sec so the Hero is not removed when you want to use it for indexes
or save the playernumber in a local variable so you are independet from the hero variable
Thank you very much, local variable did indeed work, also, I learned something new :)
Triggering Unit, Last restored Unit etc. are functions that grant access to (local) variables wich are linked with each trigger execution.
The clue with local vars is that u write instead of
Now you can easly change the all your comparision stc without clicking through all but only changing the definition of hero.
Cheers Then
They array for the unit is used in many different triggers and I prefer having a general one instead of a local one.
What is the actual problem of calling out triggering unit a dozen of times in a long trigger, just curios cuz' I do that a lot. Got some very long ones, calling upon the triggering unit 30-40 times or so in varies ways. What would I benefit from, using a local variable?
@Deeweext: Go
Theres no problem about.
You would have a great benefit using local variables if you sometimes have to change Triggering Unit to a other method like eg. Killing Unit.
What is your intended end result for this? If this is just an intricate way to make the hero not disappear when he dies then just copy the resurrection ability/behavior from the underground level on char or the final mission (2nd to last or last mission). A behavior-based resurrection would be insanely faster than a trigger-based resurrection anyway.
I am making a multiplayer arena type map, each player gets a hero, if he dies, (he needs to die, not stay at 1 health) he will respawn at the exact same spot after a period of time.
I will announce my map in the future.
Also, the behavior raynor, tychus etc used to not die, doesn't kill them, it drops them unconscious. And it would have been a great substitute if all the units i am using had the right animations.
Anyway trigger works fine and with no issues :0 thanks for everyone who helped :)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey people, I am trying to make a hero reviving method via banks, basically when a unit takes damage, its position, owner, angle and type are saved into a bank, and if it dies it restores him in those specific locations.
Trigger #1:
Trigger #2:
I run the game and test it by killing the unit which is variabled as HeroUnits[0]
he dies and 25 seconds later I get an error message. I'm new to banks so where did I go wrong ?
As far as I know, using both [Wait] and [Triggering...] will give you problems. I am not sure if it forgets who was the triggering unit after a while, or if another triggering unit gets overwritten to the memory, and when it tries to call it, it doesn't find the triggering player from the previous. Now, I didn't look through the hole trigger, so this may seem far fetched. But try it out. Remove the wait from the trigger and test it.
Anyways: Always save values you will need more than once in a local variable instead of calling the function dozens of times. No matter if it's an integer, unit,..! Just imagine you would like to change triggering unit to "target of triggering unit" and would need to look through 100 lines of GUI code :D
Or you wouldn't need to use "Owner of triggering unit -1" all the time ;)
But it's strange though: if "Owner of triggering unit" doesn't return the correct value but just the lowest possible value like 0, it should still work in your example. But it could also be possible that the engine shuts down the whole trigger thread if it realizes that the triggering unit is dead and gone after the 15-25 seconds wait.
Try storing the owner in a local variable and see what comes out.
And another note: You wouldn't need to use banks to do a revive system if you don't plan on being able to use the hero progressivly each time the players play your map. A bank is a file on the player's computer in case you don't know.
Some global arrays or a database would also work.
gl
The variables are all global, and if I wouldn't use the [owner of triggering unit -1] i would have to copy and phaste 10 times and change it from 0-9 since there are 10 players and each one has its slot in the array, player one has [0], player 2 has [1] etc...
also the wait has nothing to do with it since the error displayed mentions the problem is located at the action of Restore Unit. so it reaches it nonetheless.
What I dont understand is whats wrong with the restore unit actions? they seem to use all the right data.
This could realy solve the problem.
Because a unit will be removed from the game after death (if you don't set the the deathtime in unit stats). After that Triggering Unit points to nothing and you get an exception because your array index gets -1.
So here are the solutions:
BTW:
Triggering Unit, Last restored Unit etc. are functions that grant access to (local) variables wich are linked with each trigger execution.
The clue with local vars is that u write instead of
something like this:
Now you can easly change the all your comparision stc without clicking through all but only changing the definition of hero.
Cheers Then
Thank you very much, local variable did indeed work, also, I learned something new :)
They array for the unit is used in many different triggers and I prefer having a general one instead of a local one.
@Rushhour: Go
What is the actual problem of calling out triggering unit a dozen of times in a long trigger, just curios cuz' I do that a lot. Got some very long ones, calling upon the triggering unit 30-40 times or so in varies ways. What would I benefit from, using a local variable?
@Deeweext: Go Theres no problem about.
You would have a great benefit using local variables if you sometimes have to change Triggering Unit to a other method like eg. Killing Unit.
Then you have a lot of work ;)
@Thenarden: Go
So basicly, it is only a benefit if I change my mind later and want to change it, else not. Right, no gain there then :(
What is your intended end result for this? If this is just an intricate way to make the hero not disappear when he dies then just copy the resurrection ability/behavior from the underground level on char or the final mission (2nd to last or last mission). A behavior-based resurrection would be insanely faster than a trigger-based resurrection anyway.
@Abion47: Go
I am making a multiplayer arena type map, each player gets a hero, if he dies, (he needs to die, not stay at 1 health) he will respawn at the exact same spot after a period of time.
I will announce my map in the future.
Also, the behavior raynor, tychus etc used to not die, doesn't kill them, it drops them unconscious. And it would have been a great substitute if all the units i am using had the right animations.
Anyway trigger works fine and with no issues :0 thanks for everyone who helped :)