HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

math -_-

08-06-2004, 05:36 AM#1
mosarani
how would i find the vertical (on the y axis not in height) distance between 2 points who dont have the same x value? Basically I need a check to know how far unit is from horizontal line.
08-06-2004, 05:52 AM#2
Anitarf
In the trigger editor you have real functions "y of point" and "x of point" (they are right below "arithmetic" in the list). All you must do is a real comparison: for example:

Code:
  If - Then - else multiple functions
    If - conditions:
      And - multiple conditions:
        conditions:
          Real comparison - arithmetic((Y of point (position of unit A))-(Y of point (position of unit B))) is less than or equal to 200
          Real comparison - arithmetic((Y of point (position of unit A))-(Y of point (position of unit B))) is greater than or equal to -200
    Then - actions:
      Game - display message to all players: units are close enough
    Else - actions:
      Game - display message to all players: units are too far away
08-06-2004, 06:00 AM#3
mosarani
Ill definitely update mine, i was doing it a supid way as you'll see. Can anyone tell me why this fails to make the footman unit run down? He only goes up or forwards. Those numbers (5200.06 and 4368.06) are the distance from the center of the map to the edges of the area in which the footman is allowed to go.

Code:
check
    Events
        Time - Every 0.50 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (X of (Position of Footman 0001 <gen>)) Less than (X of (Position of Demon Hunter 0000 <gen>))
            Then - Actions
                Set RandomNumber = (Random integer number between 1 and 3)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        RandomNumber Equal to 1
                    Then - Actions
                        Unit - Order Footman 0001 <gen> to Move To ((Position of Footman 0001 <gen>) offset by (500.00, 0.00))
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        RandomNumber Equal to 2
                    Then - Actions
                        Set Points[1] = ((Center of (Playable map area)) offset by ((X of (Position of Footman 0001 <gen>)), 4368.06))
                        Unit - Order Footman 0001 <gen> to Move To ((Position of Footman 0001 <gen>) offset by (0.00, (Random real number between 1.00 and (Distance between (Position of Footman 0001 <gen>) and Points[1]))))
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        RandomNumber Equal to 3
                    Then - Actions
                        Set Points[2] = ((Center of (Playable map area)) offset by ((X of (Position of Footman 0001 <gen>)), 5200.06))
                        Unit - Order Footman 0001 <gen> to Move To ((Position of Footman 0001 <gen>) offset by (0.00, (Random real number between -1.00 and (-1.00 x (Distance between (Position of Footman 0001 <gen>) and Points[2])))))
                    Else - Actions
            Else - Actions
08-07-2004, 04:12 AM#4
mosarani
Anybody know why that doesnt work?
08-07-2004, 05:49 AM#5
RebelDris
Wow extremely confusing but i got it, i hope.

You are using both positive numbers for your point[1] so it makes your point always in the upper right part of the area so if you use a negative somewhere it will change his direction.

Good Luck!