Distance between points ?

Status
Not open for further replies.
Level 2
Joined
Apr 17, 2012
Messages
14
Hi

The situation is, I want my character to do something when I "do an order" (Attack order) on a hostile unit, the problem is, he does the order but even if he's like a mile away. I want to create a condition that obligate him to draw near the unit of issued order before doing his action.

So I found the condition : Math - Distance between points.
I set the points correctly, but I dont know the value of the distance. Is 100 close or far? 1000 ? Well I tried both of these values and my character just walk close his victim and do nothing else.

Here's the trigger:

Trigger problem.png
 
100 is melee range between units. You can see how far it can be in world editor.
Just open new map and press "G" key - a yellow grid appears. If you press it second time, a white grid appears; for the third time - a gray grid appears. These grids create squares

Yellow grid square is 512 x 512 range
White => 128
Gray => 32

So you can place 2 units in WE on the grid and just check and see how far they are from one another.


Edit: Also going by the pic: you don't need the "And" in the conditions, because you don't use "Or" condition.
 
Ok thanks, but even when I put 100, my character draw near the target but do nothing else :/
 
It may be a bit tricky to get things set up correctly - the location "position of unit" is at the center of that unit and it does not take collision size into consideration, so if you have 2 big units, the closest they can get to each other may in fact still be greater than 100 range
 
  • Attaque Chevalier
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is A Hero) Equal to True
          • (Unit-type of (Triggering unit)) Equal to Knight
          • (Owner of (Target unit of issued order)) Equal to Neutral Hostile
          • Stats_EnergyReal_Player1 Greater than or equal to 30
          • (Issued order) Equal to (Order(attack))
          • (Distance between (Position of (Triggering unit)) and (Position of (Target unit of issued order))) Greater than or equal to 100.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 10) Greater than or equal to 5
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Animation - Play (Triggering unit)'s Attack - 1 animation
          • Wait 0.30 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Less than or equal to Stats_Dexterity_Player1
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of issued order), dealing (Stats_Strike_Player1 x Stats_Strenght_Player1) damage of attack type Spells and damage type Normal
              • Set Stats_EnergyReal_Player1 = (Stats_EnergyReal_Player1 - 30)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 2) Equal to 1
                • Then - Actions
                  • Sound - Play MetalLightChopFlesh1 <gen> at 100.00% volume, located at (Position of (Triggering unit)) with Z offset 0.00
                  • Trigger - Turn on (This trigger)
                • Else - Actions
                  • Sound - Play MetalLightChopFlesh2 <gen> at 100.00% volume, located at (Position of (Triggering unit)) with Z offset 0.00
                  • Trigger - Turn on (This trigger)
            • Else - Actions
              • Set Stats_EnergyReal_Player1 = (Stats_EnergyReal_Player1 - 30)
              • Unit - Cause (Triggering unit) to damage (Target unit of issued order), dealing Stats_Strike_Player1 damage of attack type Spells and damage type Normal
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 2) Equal to 1
                • Then - Actions
                  • Sound - Play MetalLightChopFlesh1 <gen> at 100.00% volume, located at (Position of (Triggering unit)) with Z offset 0.00
                  • Trigger - Turn on (This trigger)
                • Else - Actions
                  • Sound - Play MetalLightChopFlesh2 <gen> at 100.00% volume, located at (Position of (Triggering unit)) with Z offset 0.00
                  • Trigger - Turn on (This trigger)
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Animation - Play (Triggering unit)'s Attack - 2 animation
          • Wait 0.30 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Less than or equal to Stats_Dexterity_Player1
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of issued order), dealing (Stats_Strike_Player1 x Stats_Strenght_Player1) damage of attack type Spells and damage type Normal
              • Set Stats_EnergyReal_Player1 = (Stats_EnergyReal_Player1 - 30)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 2) Equal to 1
                • Then - Actions
                  • Sound - Play MetalLightChopFlesh1 <gen> at 100.00% volume, located at (Position of (Triggering unit)) with Z offset 0.00
                  • Trigger - Turn on (This trigger)
                • Else - Actions
                  • Sound - Play MetalLightChopFlesh2 <gen> at 100.00% volume, located at (Position of (Triggering unit)) with Z offset 0.00
                  • Trigger - Turn on (This trigger)
            • Else - Actions
              • Set Stats_EnergyReal_Player1 = (Stats_EnergyReal_Player1 - 30)
              • Unit - Cause (Triggering unit) to damage (Target unit of issued order), dealing Stats_Strike_Player1 damage of attack type Spells and damage type Normal
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 2) Equal to 1
                • Then - Actions
                  • Sound - Play MetalLightChopFlesh1 <gen> at 100.00% volume, located at (Position of (Triggering unit)) with Z offset 0.00
                  • Trigger - Turn on (This trigger)
                • Else - Actions
                  • Sound - Play MetalLightChopFlesh2 <gen> at 100.00% volume, located at (Position of (Triggering unit)) with Z offset 0.00
                  • Trigger - Turn on (This trigger)
This is a really big trigger haha. And no the units are not to big. I tried like 150 or 200 just for fun and it didnt work either. I guess the problem is somewhere else then :/

PS Yes I can have some little mistakes in the trigger I'm not the best coder in the world :P
 
Well I found the problem! It was because I added a wierd condition about the order.. Anyways, you guys was right. Thanks a lot to you :) +Honor
 
Status
Not open for further replies.
Back
Top