HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Problem with Spelltrigger that moves unit (math - angle between points)

09-06-2003, 11:31 AM#1
Bloodlust
Hello

Ok... its the following:

I created a spell that that "kicks a unit back". So the hero is casting it and the target is moved away from him.

Now everything seemed to work, i could kick an abom around on my map, like a football^^

Then I changed the move-away distance from 400 down to 200 and made several steps of it, so that it is moved slowly back
- the problem is.. after i did it, the unit is always moved in the same angle. No matter where my hero is, the unit is always moved up North-East-East...

Here is the trigger:
Code:
HeroMoveMS
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Mind Strike 
    Actions
        Wait 0.25 game-time seconds
        Unit - Move MindStrikeTarget instantly to ((Position of MindStrikeTarget) offset by 150.00 towards (180.00 + (Angle from (Position of MindStrikeTarget) to (Position of (Casting unit)))) degrees)
        Animation - Play MindStrikeTarget's death animation
        Wait 0.25 game-time seconds
        Unit - Move MindStrikeTarget instantly to ((Position of MindStrikeTarget) offset by 150.00 towards (180.00 + (Angle from (Position of MindStrikeTarget) to (Position of (Casting unit)))) degrees)
        Wait 0.25 game-time seconds
        Unit - Move MindStrikeTarget instantly to ((Position of MindStrikeTarget) offset by 150.00 towards (180.00 + (Angle from (Position of MindStrikeTarget) to (Position of (Casting unit)))) degrees)
        Wait 0.25 game-time seconds
        Unit - Move MindStrikeTarget instantly to ((Position of MindStrikeTarget) offset by 150.00 towards (180.00 + (Angle from (Position of MindStrikeTarget) to (Position of (Casting unit)))) degrees)
        Animation - Play MindStrikeTarget's stand animation

well it was working before.. and i got really no idea what to do or what could be wrong, help me pls
09-06-2003, 11:38 AM#2
Bloodlust
ok.... im awake for 27 hours now and did map like 17 of them.. so im kinda tired.... sorry:


After a little test i know the problem, the "wait 0.25" kills the trigger. if you know any way to work around this pls tell meh^^ i will try looping the trigger with a variable +1 at the end.. hmmm
09-06-2003, 11:52 AM#3
Bloodlust
"do it yourself"

i should really get some sleep.... i wonder why i even wasted ur time with a silly problem like that, lol :-/



Set MindstrikeAngle = (Integer((Angle from (Position of MindStrikeTarget) to (Position of (Casting unit)))))

Wait 0.25 game-time seconds

Unit - Move MindStrikeTarget instantly to ((Position of MindStrikeTarget) offset by 150.00 towards (180.00 + (Real(MindstrikeAngle))) degrees)



someone close or even better delete it^^
09-06-2003, 12:08 PM#4
cideh
Angle between points doesn't work like "normal".

Its degrees isn't calculated the normal way.

Normal way
90
0 180
360

Angle between points
90
0 180
0 -180
-90

So. Add this: "If (Substring(Real(AngleBetweenPoints), 1, 1)) Equal to - Then do: Set AngleBetweenPoints = (360 + AngleBetweenPoints)"

This solves the problem with negative values and the degrees are always calculated correctly.

This might not be the solution to your problem, as I never really understood your problem, but this should at least help you.
09-06-2003, 12:41 PM#5
Bloodlust
yea i was confused on my own, my problem was:


my trigger did:
it moved the target AWAY from the caster <----

then i added WAIT actions
then the target moved always in the same direction, no matter where the caster was standing...

cuz blizzard sucks
09-06-2003, 01:56 PM#6
Shvegait
Yes, there is a bug that causes the game to forget who the "Casting Unit" is after a wait action. Yes, it's annoying, but there is a workaround. If you want to learn about JASS, you can use local variables and store the Casting Unit in one, referring to that variable instead of "Casting Unit". You could always just set it to a normal global variable, but that might cause some major conflicts. It's up to you, but I recommend using local variables here.