HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Best Way To Measure Distance Of Angle (GUI)

02-21-2007, 04:43 AM#1
Brash
I've been having difficulties with something that should be simple but i'm just not seeming to grasp what i'm doing wrong. I have a spell that lines up several created dummy units in front of a caster and i want that line to oscillate back and forth at.. i'm guessing i want it to move towards about 45 degrees one way.. stop.. then move back to mirror that the other way.. stop.. then back again.. and just keep repeating.

i have a trigger that detects when a unit casts a spell that targets a point and sets that point to the "thrasher_targetposi" variable. I also set the casters position and it creates dummy units from there to the target point every 80 distance... then i have it turn on another trigger that runs periodically every .03 seconds and runs a bunch of events but here is the section that i am having trouble with. i've copied the code below:


Code:
Set Thrasher_Caster_Posi = (Position of Thrasher_Caster)
        For each (Integer A) from 1 to Thrasher_Dummy_Int, do (Actions)
            Loop - Actions
                Set Thrasher_Dummy_Posi[(Integer A)] = (Position of Thrasher_DummyU[(Integer A)])
        -------------------- Change Angle ---------------------
        Set Thrasher_real_Width = ((Distance between Thrasher_Caster_Posi and Thrasher_TargetPosi) + ((Distance between Thrasher_Caster_Posi and Thrasher_TargetPosi) - (Distance between Thrasher_Dummy_Posi[1] and Thrasher_TargetPosi)))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Thrasher_Direction_Lock_Int Equal to 1
                Thrasher_real_Width Greater than ((Distance between Thrasher_Caster_Posi and Thrasher_TargetPosi) + 150.00)
            Then - Actions
                Set Thrasher_Direction_Lock_Int = 2
                Set Thrasher_RevChanger = (Thrasher_RevChanger x -1.00)
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Thrasher_Direction_Lock_Int Equal to 2
                        Thrasher_real_Width Greater than or equal to ((Distance between Thrasher_Caster_Posi and Thrasher_TargetPosi) + 0.00)
                        Thrasher_real_Width Less than or equal to ((Distance between Thrasher_Caster_Posi and Thrasher_TargetPosi) + 50.00)
                    Then - Actions
                        Set Thrasher_Direction_Lock_Int = 1
                    Else - Actions
                        Do nothing
        Set Thrasher_Angle = (Thrasher_Angle + Thrasher_RevChanger)
       

As you can see, i am trying to tell it to check the distance.. when the one distance is greater than the other it should turn around.. but it just keeps going around in a full circle never checking.

the direction_lock_int is just to guard against it checking more than once at being greater.. just in case. when i disable the conditions and events for that thrasher_direction_lock_int and not use it at all it still does complete circles but the "else" condition goes off at what seems to be the correct places but not exactly sure.. but it still does complete circles no matter. the "Then" never goes off. or i have yet to notice it.

i know the "else" goes off because i have a text message display to me when it works but i have removed it from the code above to make it cleaner for you to read.

Oh and another thing i'm concerned about is the target point.. i'm thinking that if i cast it close to the caster or target far away it might screw the accuracy up of the distance measure.

any ideas?
02-21-2007, 07:09 AM#2
NmdSnprEnigma
I'm a bit too tired to follow exactly what's going on, but it might be that WC considers angles as the exact same as any reals, so if you look for a difference in the greater than sense, it'll only give you higher ones, so I'll willing to bet that when it only goes one way, it goes CCW. Vex has some angle funcs in his caster systenm cehck 'em out.
02-21-2007, 12:55 PM#3
Brash
i'm not quite sure i follow.

oh yeah. i failed to mention the RevChanger had a default value of -2 then when it multiples by -1 each time it will change it to positive.. then back to negative.. and that will determine the direction flow.

and i also failed to say that after that code i have it do a move unit instantly function in reference to those angles.
02-21-2007, 05:03 PM#4
grim001
I won't even try to read anything like this in GUI...

honestly if you are starting to get into 'complicated' abilities you should be working on learning JASS.
02-22-2007, 12:48 PM#5
Brash
thx for the tip but i'm reluctant to learn jass because i hate programming. i'm gui now for 2 years. i have a hard enough time keeping this straight... but i do understand gui farily well.


anyhow. i figured it out. and it is smooth! i revised that code to not measure anything.. but instead i have a variable plus itself the exact same angle degrees i have been successfully moving it around in a circle by.. this way it just counts from 0 from something fresh rather than comparing distance or actual angle of the direction from point a to point b within the 0-360 range.

anyhow.. it mearly adds to itself and counts.. and i have a condition that just checks if that variable has reached a certain number.. then if it does i set another lock integer "Thrasher_Direction_Lock_Int = 2".. and have another condition that checks for that being equal to 2 and then it starts - the other counting variable til that reaches the negative of itself.. condition checks and set the "Thrasher_Direction_Lock_Int = 2" to 1 again.. then it starts adding back to itself

it oscilates beautifully at any angle i cast it at. picture pudges hook sticking out like your pointer finger and you wave it back and forth saying no no no.


smoother than i thought it would be too.

Now onto my next goal.. changing the flying height as it oscilates. this one has me stomped at present. i want the flying height to be at default flying height or somewhere around 200 as it finishes oscilating either one direction left/right.. and gradually climb up at an arc as it aproaches the 0 mark.. (middle of oscilation).. and should be around 400 height then when it does have it arc down to reach 200 by the time it hits other side.. then climb down til it reaches that 0 mark and it will then be at 0 flying height.

in other words i want it to oscilate now up and down with flying height.. and combining the two, it should look like he is swinging them around in a circle.. not around himself but in front of himself.. like a mixer... a tornado
02-22-2007, 03:51 PM#6
grim001
you have been programming for 2 years, you're only making it harder on yourself by using a cumbersome wrapper for the actual programming