Bounce Angle Formula

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
Okey. I tried with this formula but didn't work. I'm trying to make a bounce angle.
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Facing of Unit1[(Integer A)]) Greater than or equal to 180.00
    Then - Actions
        Set RM_Angle[(Integer A)] = (540.00 - (Facing of Unit1[(Integer A)]))
    Else - Actions
        Set RM_Angle[(Integer A)] = (360.00 - (Facing of Unit1[(Integer A)]))


This trigger works great. Except in some cases, it can't check if the wall is either south or north, west or right. Example with this code, let's say the red line is 45 degrees, which means it's reflection should be 315 degrees. And in this case it works great.

bamd1.png

But when I use this formula and try to bounce to the south direction, it went like this.

bacf5.png

The red line is still 45 degrees, but this time it also reflect 315 degrees, right in the wall, the black line. But it should have bounced 135 degrees, the white line.
 

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
so, if you took 45 as the angle
45 - 180 = -135
2x-135 = -270
180+(-270) = -90
-90 = 270 degree reflection (with regards to angles, -90 = 270 you can add 360 if you want)

That doesn't seem right :S
 

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
And I didn't get it. Updated the first post to make it more clear.
 

NaPzt3R

You can change this now in User CP.
Reaction score
38
Code:
Set variable position_x to (Cosine(angle property)*x-Sine(angle property)*y)
Set variable position_y to (Cosine(angle property)*y+Sine(angle property)*x)
Move to coordinates position_x and position_y
Here's a fomular that might help. I can't help more than that. Sorry. :)
(Is there cosine and sine functions in Wc3?)

Off-topic:
@OneBadPsycho
Oh halløj broder.
 
F

FViral

Guest
I might be an idiot but it seems as though your problem lies in that the second bounce is acting exactly like the first. Maybe you need to develop a way to detect the orientation of the cliff.

Also, aren't all angles relative?
So isn't you initial bounce incoming at 135 degrees and bouncing at 225 degrees?
 

THE_X

New Member
Reaction score
49
wc3 does not use a 360% method its a 180 and -180, but it converts it to the same degree so whatever the facing angle of it x2 will be the correct angle
 

Caedin88

New Member
Reaction score
1
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Terrain pathing at ((Position of (UR UNIT)) offset by 25.00 towards RM_Angle[(Integer A)] degrees) of type Walkability is off) Equal to True
    Then - Actions
        Set RM_Angle[(Integer A)] = (RM_Angle[(Integer A)] + 180.00)
    Else - Actions
        Do nothing

Tell me if this works, Im anxious to know if it does... It works in my head lol.
 

Caedin88

New Member
Reaction score
1
If RM_Angle[(Integer A)] is 90, would the output be 270 (90+180), which in that case isn't true?

Yeah if it bounces at 90 degrees and there is a wall there then it becomes 270, I don't see what you are saying.

It basically says calculate your bounce, then if there is a wall in that direction then reverse your bounce... for example, if it comes in like the picture at -45? then his stuff makes it becomes -135, which is right for the first picture, but for the 2nd it doesn't work, but if u add this conditional it will say, wait theres a wall in -135 direction, add 180 and you get -135 + 180 which = 45 which is correct. But it won't alter the value if the wall isn't there, thus still leaving it correct for the first scenario.
 

OneBadPsycho

10100111001
Reaction score
93
Yeah if it bounces at 90 degrees and there is a wall there then it becomes 270, I don't see what you are saying.

It basically says calculate your bounce, then if there is a wall in that direction then reverse your bounce... for example, if it comes in like the picture at -45? then his stuff makes it becomes -135, which is right for the first picture, but for the 2nd it doesn't work, but if u add this conditional it will say, wait theres a wall in -135 direction, add 180 and you get -135 + 180 which = 45 which is correct. But it won't alter the value if the wall isn't there, thus still leaving it correct for the first scenario.

I mean: If you stand and throw a ball into a wall at 90 degrees and the wall is facing like this: |. Would the ball go back then, with your trigger ?

---->|
---->|
---->|

EDIT: Oh, I see your point now. ^^
 

OneBadPsycho

10100111001
Reaction score
93
----> is 0 degrees not 90, so thus


----> | 0 degrees
<---- | 180 degrees

My bad, but I have this trigger:
Code:
Move Spell
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in SpellUg and do (Actions)
            Loop - Actions
                Set LocSU = (Position of (Picked unit))
                Set AngleSU = (Facing of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Terrain pathing at (LocSU offset by 25.00 towards AngleSU degrees) of type Walkability is off) Equal to True
                    Then - Actions
                        Set AngleSU = (AngleSU + 180.00)
                    Else - Actions
                Set MoveLocSU = (LocSU offset by 10.00 towards AngleSU degrees)
                Unit - Move (Picked unit) instantly to MoveLocSU
                Custom script:   call RemoveLocation (udg_LocSU)
                Custom script:   call RemoveLocation (udg_MoveLocSU)
                Custom script:   set udg_AngleSU = 0

and it doesn't work, the units just sticks to the wall.
 

Caedin88

New Member
Reaction score
1
Because your trigger updates ever 0.01 seconds it is saying like this.

X = unit
| = wall


Okay there is a wall 25 units offset in the direction of X( reverse direction )
---> X |

0.01 seconds later (Direction is reversed by the unit has only moved 10 units, so thus 25 units to the right is still a wall, so thus reverse direction again.

My advice, switch it to this and see if it works...

Code:
Move Spell
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in SpellUg and do (Actions)
            Loop - Actions
                Set LocSU = (Position of (Picked unit))
                Set AngleSU = (Facing of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Terrain pathing at (LocSU offset by 25.00 towards AngleSU degrees) of type Walkability is off) Equal to True
[B]and BOOLEANVARIABLE is true[/B]
                    Then - Actions
                        Set AngleSU = (AngleSU + 180.00)
                        [B]BOOLEANVARIABLE = false[/B]
                    Else - Actions
                Set MoveLocSU = (LocSU offset by 10.00 towards AngleSU degrees)
                Unit - Move (Picked unit) instantly to MoveLocSU
                Custom script:   call RemoveLocation (udg_LocSU)
                Custom script:   call RemoveLocation (udg_MoveLocSU)
                Custom script:   set udg_AngleSU = 0

Code:
Untitled Trigger 002
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Set BOOLEANVARIABLE = true

If you want MUI make booleanvariable an array and use custom value to specific.
 

OneBadPsycho

10100111001
Reaction score
93
Because your trigger updates ever 0.01 seconds it is saying like this.

X = unit
| = wall


Okay there is a wall 25 units offset in the direction of X( reverse direction )
---> X |

0.01 seconds later (Direction is reversed by the unit has only moved 10 units, so thus 25 units to the right is still a wall, so thus reverse direction again.

My advice, switch it to this and see if it works...

Code:
Move Spell
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in SpellUg and do (Actions)
            Loop - Actions
                Set LocSU = (Position of (Picked unit))
                Set AngleSU = (Facing of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Terrain pathing at (LocSU offset by 25.00 towards AngleSU degrees) of type Walkability is off) Equal to True
[B]and BOOLEANVARIABLE is true[/B]
                    Then - Actions
                        Set AngleSU = (AngleSU + 180.00)
                        [B]BOOLEANVARIABLE = false[/B]
                    Else - Actions
                Set MoveLocSU = (LocSU offset by 10.00 towards AngleSU degrees)
                Unit - Move (Picked unit) instantly to MoveLocSU
                Custom script:   call RemoveLocation (udg_LocSU)
                Custom script:   call RemoveLocation (udg_MoveLocSU)
                Custom script:   set udg_AngleSU = 0

Code:
Untitled Trigger 002
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Set BOOLEANVARIABLE = true

If you want MUI make booleanvariable an array and use custom value to specific.

It doesn't work, but maybe Draphoelix figured it out in the meantime.
 

Caedin88

New Member
Reaction score
1
It doesn't work, but maybe Draphoelix figured it out in the meantime.

Never mind what i posted before its wrong, but i figured it out.

You set the angle to the units facing every pass so you for example move at 35 degrees until you hit a wall, then u move at 35+180, but the very next time u move again at 35. You cannot declare Set AngleSU = (Facing of (Picked unit)) in your trigger, it must be done elsewhere.

Also units don't turn instantly they take time, so when u do a trigger at 0.01 seconds you get problems if moving in the Facing of the unit, because the unit turn animation is much longer than 0.01.
 

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
Code:
Set AngleSU = (AngleSU + 180.00)

Will not work. What if it's in 45 angle, and you throw it on a wall that is in the south? Then it should bounce back at 135, which is 180-45 and not 45+180 which is 225. My formula is okay, except that it can't check where it hits, south of the wall, or right of the wall. Using +180 is completely wrong.

I'm using a slide trigger, don't worry about the facing. But if you throw at 35, it should bounce back at 145 degrees if thrown at a wall in the south, and 325 degrees if thrown at a right wall. I don't see how you got it to 115.

Edit: Oh you talked to One. But still, 180+ is wrong.
 

Caedin88

New Member
Reaction score
1
Code:
Set AngleSU = (AngleSU + 180.00)

Will not work. What if it's in 45 angle, and you throw it on a wall that is in the south? Then it should bounce back at 135, which is 180-45 and not 45+180 which is 225. My formula is okay, except that it can't check where it hits, south of the wall, or right of the wall. Using +180 is completely wrong.

I'm using a slide trigger, don't worry about the facing. But if you throw at 35, it should bounce back at 145 degrees if thrown at a wall in the south, and 325 degrees if thrown at a right wall. I don't see how you got it to 115.

Edit: Oh you talked to One. But still, 180+ is wrong.

I ment to add my conditional AFTER your system, your system calculates the reflect angle, which is right.

But look at your second picture, if it hits the south wall if you add 180 to the actual reflection line then you get the correct angle.

Also you can't throw at 45 degrees and hit somthing in the south, its not possible... you are going north.

You can throw at -45 and hit the south or aka 315 and hit a wall in the south.

You see you will never get 45 + 180 because a 45 angle is moving northeast, thus you cannot hit a wall on the south side.

Your sense of direction is off.
 

Caedin88

New Member
Reaction score
1
bacf5.png

The red line is still 45 degrees, but this time it also reflect 315 degrees, right in the wall, the black line. But it should have bounced 135 degrees, the white line.

The red line is at 315 not 45, the reflect is at 225 degrees not 315 and the white line, the correct reflection is at 45. Warcrafts directional system starts with 0 being directly East and 180 being directly West of the unit.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top