I created a thread before because I was having trouble coding in galaxy and then importing the script, but I've now converted into only using Custom Script triggers directly in the editor. So I created a new thread even if this is about the same code, it's a new problem.
So I created some code for a spell I'm doing which shouldn't be too difficult but there's some weird bug with it XD
It's a blink spell which will move the caster behind the target and then there should happen some more stuff but I haven't gotten to it yet and it's already bugging. So the bug I've encountered is that for some weird reason whenever I target a unit with my spell, the "target" unit actually becomes the caster :S BUT, this only happens with one unit. I used to have the same spell with two of the same units in the test map before, and the spell only worked for one of them. They are both identical units, but for some reason one of them only targeted itself and not the actual target of the spell.
I would very much appreciate if someone could just test the spell and see if this happens when they test it.
You use the wrong unit function, you use EventUnitTarget, you need to use EventUnitTargetUnit.
Also, I guess, you are used to making WC3 spells with putting all affected units for a knockback in a global group and periodically move all of them with a periodic trigger or a timer? In SC2, it is much easier to just use local variables and a wait instead. Unlike in WC3, waits are just as accurate as timers now; in fact, they can even run at double the speed (however any impact on the actual game has yet to be proven). This will also trigger a lot less events, which might help in testing with the debug window.
Also keep in mind, that timers and waits in SC2 cannot run faster than 16 fps, or a 0.0625 interval; which is also the maximum precision (with the exception of a 0 wait, wich runs at 32 fps)
The static keyword is pretty much useless in its current state. It acts somewhat like a private; you cannot use the variable in another file. However, it still prevents declarations of variables of the same name in other files, so you might want to use prefixes.
The first thing I did when getting my hands on galaxy script was a function like this:
Well yeah, I was planning to make the knockback using a timer and such, but I should just use a loop then? With a wait in it?
And yeah, I changed the Caster to burnCaster XD Weird that static doesn't work as you would expect :S
So thank you so much! Now I just have to figure out why my new spell moves to the target's "behind", but also moves the target double the range forward.
Meaning that when I target the unit, he moves some range forward, and I move to him in that new position.
Well yeah, I was planning to make the knockback using a timer and such, but I should just use a loop then? With a wait in it?
You may still use a timer, but unlike in WC3, you cannot start a timer without a trigger anymore (well, you can, but you need a trigger to react to it, not like in WC3, where the TimerStart function would call a function directly without the need of a trigger). Also, it is much more convenient to be able to use local variables and a simple loop. Performance wise, there should be hardly any difference anyway, and the one and only reason you basically had to use a timer in WC3, the non-precise waits, is not valid anymore.
So yes, I would use loop + wait, if I would do it with triggers.
You also have the option of using the data editor; it is much more advanced than WC3's object editor, and chances are, that you can realize your entire ability without the need of a single trigger.
Quote:
And yeah, I changed the Caster to burnCaster XD Weird that static doesn't work as you would expect :S So thank you so much! Now I just have to figure out why my new spell moves to the target's "behind", but also moves the target double the range forward. Meaning that when I target the unit, he moves some range forward, and I move to him in that new position
Don't just print the coordinates, print all important intermediary results as well. I am pretty sure, it is just a calculation error.
Also, I noticed, you use Pi for something; didn't look into it. All SC2 angle functions take degrees instead of radians, unlike WC3, which was almost all radians.
Ok, so I'm not entirely sure I'm using the "PointWithOffsetPolar" correctly, and that's why i'm trying to do those calculations myself XD
But since I'm used to WC3 and converting to radians and such I can't seem to figure out how to do it wich just degrees :S
The one which work best is the top one, but that one gave the result in the last post -_-
And the data editor seems like a lost cause for me XD It's impossible to understand all the elements you need to create stuff with it, for me at least :P
If anyone have a great tutorial for it that might work, but I don't feel like trying to understand it by myself when I feel more comfortable using triggers ;)
You commented out the first setting of your targetPoint, so it is null, when you try to calculate a polar offset of it, resulting in the error message.
Well, that helped the error message, but now I still have the same old bug with them both being teleported :S
But I'll just have to try untill it works -_-
Yeah XD
That was the problem -_-
I created a new map and took some time with making the testing unit and the spell so I understand actors a better now :D
So what happened, just to clarify, is that I used the Blink spell as the "parent spell" but I also made the effect based on that one and that makes the caster teleport to the unit first, before the trigger also makes him teleport...
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hi!
I created a thread before because I was having trouble coding in galaxy and then importing the script, but I've now converted into only using Custom Script triggers directly in the editor. So I created a new thread even if this is about the same code, it's a new problem.
So I created some code for a spell I'm doing which shouldn't be too difficult but there's some weird bug with it XD It's a blink spell which will move the caster behind the target and then there should happen some more stuff but I haven't gotten to it yet and it's already bugging. So the bug I've encountered is that for some weird reason whenever I target a unit with my spell, the "target" unit actually becomes the caster :S BUT, this only happens with one unit. I used to have the same spell with two of the same units in the test map before, and the spell only worked for one of them. They are both identical units, but for some reason one of them only targeted itself and not the actual target of the spell.
I would very much appreciate if someone could just test the spell and see if this happens when they test it.
You use the wrong unit function, you use EventUnitTarget, you need to use EventUnitTargetUnit.
Also, I guess, you are used to making WC3 spells with putting all affected units for a knockback in a global group and periodically move all of them with a periodic trigger or a timer? In SC2, it is much easier to just use local variables and a wait instead. Unlike in WC3, waits are just as accurate as timers now; in fact, they can even run at double the speed (however any impact on the actual game has yet to be proven). This will also trigger a lot less events, which might help in testing with the debug window.
Also keep in mind, that timers and waits in SC2 cannot run faster than 16 fps, or a 0.0625 interval; which is also the maximum precision (with the exception of a 0 wait, wich runs at 32 fps)
The static keyword is pretty much useless in its current state. It acts somewhat like a private; you cannot use the variable in another file. However, it still prevents declarations of variables of the same name in other files, so you might want to use prefixes.
The first thing I did when getting my hands on galaxy script was a function like this:
so I can just use Print("Hello World"); instead of the whole mumbo jumbo with text conversion and stuff every time I want to show some debug text.
Well yeah, I was planning to make the knockback using a timer and such, but I should just use a loop then? With a wait in it?
And yeah, I changed the Caster to burnCaster XD Weird that static doesn't work as you would expect :S So thank you so much! Now I just have to figure out why my new spell moves to the target's "behind", but also moves the target double the range forward. Meaning that when I target the unit, he moves some range forward, and I move to him in that new position.
You may still use a timer, but unlike in WC3, you cannot start a timer without a trigger anymore (well, you can, but you need a trigger to react to it, not like in WC3, where the TimerStart function would call a function directly without the need of a trigger). Also, it is much more convenient to be able to use local variables and a simple loop. Performance wise, there should be hardly any difference anyway, and the one and only reason you basically had to use a timer in WC3, the non-precise waits, is not valid anymore.
So yes, I would use loop + wait, if I would do it with triggers.
You also have the option of using the data editor; it is much more advanced than WC3's object editor, and chances are, that you can realize your entire ability without the need of a single trigger.
Don't just print the coordinates, print all important intermediary results as well. I am pretty sure, it is just a calculation error.
Also, I noticed, you use Pi for something; didn't look into it. All SC2 angle functions take degrees instead of radians, unlike WC3, which was almost all radians.
Ok, so I'm not entirely sure I'm using the "PointWithOffsetPolar" correctly, and that's why i'm trying to do those calculations myself XD But since I'm used to WC3 and converting to radians and such I can't seem to figure out how to do it wich just degrees :S
I've tried these three: targetPoint = PointWithOffsetPolar( targetPoint, 0.8, targetFacing + 180 ); targetPoint = Point( targX + .45 * 180/PI * Cos( ( UnitGetFacing( spellTarget ) + 180 ) * ( PI/180 ) ), targY + .45 * 180/PI * Sin( ( UnitGetFacing( spellTarget ) + 180 ) * ( PI/180 ) ) ); targetPoint = Point( targX + .45 * UnitGetFacing( spellTarget ) + 180, targY + .45 * UnitGetFacing( spellTarget ) + 180 );
But none work...
The one which work best is the top one, but that one gave the result in the last post -_-
And the data editor seems like a lost cause for me XD It's impossible to understand all the elements you need to create stuff with it, for me at least :P
If anyone have a great tutorial for it that might work, but I don't feel like trying to understand it by myself when I feel more comfortable using triggers ;)
Well, in data, teleporting behind a target could be done in 2 effects, without any huge calculation.
However, I am not even sure, what your spell should do in the final version, so I cannot tell you how complicated it would be all together.
If you just need a point behind your enemy, this should work. Not sure, why your target gets teleported as well.
If anyone would like to try out the weird bug, here's the map...
But now I also get an in-game error with red text :S
Says this:
'PointWithOffsetPolar' [value: 0] Trigger error in 'BurningStep_Main': Could not get 'point' from parameter in UnitSetPosition [value: 65535]
Weird error if you ask me :S
Here's the method it's pointing to:
You commented out the first setting of your targetPoint, so it is null, when you try to calculate a polar offset of it, resulting in the error message.
Yeah XD
Well, that helped the error message, but now I still have the same old bug with them both being teleported :S But I'll just have to try untill it works -_-
If you use "dummy" effects, make sure, they don't do anything. You are using a teleport effect, which teleports the target.
Yeah XD That was the problem -_- I created a new map and took some time with making the testing unit and the spell so I understand actors a better now :D
So what happened, just to clarify, is that I used the Blink spell as the "parent spell" but I also made the effect based on that one and that makes the caster teleport to the unit first, before the trigger also makes him teleport...