• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Detect collision

Status
Not open for further replies.

sentrywiz

S

sentrywiz

I have projectiles (dummy units) that are used in many skill shot spells in my map. I want to improve my AI by giving the AI the knowledge to dodge (or try) projectiles.

I want the AI to somehow calculate where there is open space and go towards there (away from any missiles) when it detects there are.


IF THIS IS SOLVABLE THROUGH TRIGGERS
Give me an example.

IF THIS IS SOLVABLE THROUGH MATH
Explain because I'm a dumb-ass and didn't learn math properly.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
IF THIS IS SOLVABLE THROUGH MATH
Explain because I'm a dumb-ass and didn't learn math properly.

Well, that is not really a problem.
When you use this calculation, you can easily understand how to calculate a nice direction to go to in an attempt to avoid any incoming missiles:
I9bNCmv.png


If that is not enough yet, then you can try to design it yourself.

Your AI has to mark locations as big ass trouble... basically there is a missile/projectile flying to this place.
You can give it the weight of the danger (dmg, status effects, etc) and the moment of impact if you want that but for now it doesnt really matter.

Then you simply have to walk away from those locations.
(The weight and stuff are for moments that you will be hit in any case but just to find the spot that would be the best for you to go to... which is a second part of this kind of AI.)
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
If you would apply math the moment the spell was cast, you will just get a rough approximation because your target can move in any direction which was not taken into account. The approximation is better the faster the missile since units will have less time to react/move. If you want to use this, you can compute the time when the missile will hit by time = distance/speed.

What you can do is simulate the missile's movement using periodic triggers. Example, you know that the speed of your missile is 1500, every 0.03 sec, keep track of where the missile should have been using polar offsets since you know that every 0.03 sec, the missile moves by 1500*0.03 distance. The trigger depends whether your missile is homing or just straight line. If it just moves in a straight line, you would just use polar offset at a constant angle, but if it is homing, your polar offset angle should be from current location of missile to the current loc of target.
Then what's left now is, check in the periodic trigger if a nearby enemy unit/AI is within range, if there is, order that AI to dodge it.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Homing missiles are just homing... hard to dodge.
Until you use a real good missile system that allows other objects to block the missile or make the missile have a max rotation per second which will make you be able to dodge it quite nice in order to make it hit another target or make it reach the maximum traveled time or distance.
But then again, I don't assume him to have such a system... unless he wants to use this trigger in real life :D
 

sentrywiz

S

sentrywiz

When you use this calculation, you can easily understand how to calculate a nice direction to go to in an attempt to avoid any incoming missiles:

I love how you say this, and then show me the calculation for life itself. WTF :D How am I to use this? How am I to even comprehend this? Have you used this?

I do love how you enjoy trolling me. Well played

If you would apply math the moment the spell was cast, you will just get a rough approximation because your target can move in any direction which was not taken into account. The approximation is better the faster the missile since units will have less time to react/move. If you want to use this, you can compute the time when the missile will hit by time = distance/speed.

What you can do is simulate the missile's movement using periodic triggers. Example, you know that the speed of your missile is 1500, every 0.03 sec, keep track of where the missile should have been using polar offsets since you know that every 0.03 sec, the missile moves by 1500*0.03 distance. The trigger depends whether your missile is homing or just straight line. If it just moves in a straight line, you would just use polar offset at a constant angle, but if it is homing, your polar offset angle should be from current location of missile to the current loc of target.
Then what's left now is, check in the periodic trigger if a nearby enemy unit/AI is within range, if there is, order that AI to dodge it.

That is my idea as well. My weak side is math so I can utilize loops and unit groups. So yes, I do that. The problem is: I don't understand how to order the unit to move in a direction where there aren't detectable missiles OR hide in the space between missiles.

Assume that I know how to use units groups and loops. Through what method can I calculate the direction and the AI should travel through use of Polar Offset angle?


MISSILE -------------> (AI)
OPEN SPACE [1]
OPEN SPACE [2]
MISSILE ---->
OPEN SPACE [3]


Through the rough example above, say the AI is aware of both missiles because of a periodic loop that detects missiles at 1000 range around it. Here are the two challenges:
- pick a direction towards open space where there are no missiles at that moment that would hit it
- calculate beforehand if a missile direction would hit the AI
 
Why not pick every dummy_projectile and then pick every unit with Dist_range of dummy.
Then if loop every 10 distance points in every direction (angle) for a given distance and check pathability.
You could remove angles for the direction the missile is coming from, that way the unit would not move into the path of the missile.
If the rout is pathable order unit to move there.
You can even cheat and add in the target of order being cast so the AI knows where the missile is coming and use that as the starting temppoint.
So pick all units within 200 of target_point, then check path-ability of escape routs. Then order it to move.

Let's recap

first
  • Unit Group - Pick every unit within 200 of Target_Loc
Set all the proper conditions to get only units that should be dodging.

then
  • For each (integer_A) from 1 to 33 do,
  • Loop - Actions
    • For each (integer_B) from 1 to 10 *(or however far they need to move to dodge/10) do,
      • Loop - Actions
        • Set Loc = (position of (Picked Unit))
        • Set Missile_Angle = Angle between Caster and Target_Loc + 15
        • Set Loc2[integer_A] = Loc offset by 10 x integer_B at angle integer_A x 10
        • If (All consitions are True) then do then (Actions) else (Actions)
          • Conditions -
            • (Terrain pathing at (Loc2[interget_A]) of type Walkability is on) Equal to True
          • Actions -
            • Set EscapePath[integer_A] equal to True
          • Else -
            • Set EscapePath[integer_A] equal to False
          • If (All consitions are True) then do then (Actions) else (Actions)
            • Conditions -
              • integer_A Equal to 10
              • EscapePath[integer_A] equal to True
            • Actions -
              • Unit - order unit to get the fuck out of there
              • Skip remaining actions
Terrain pathing condition is found under booleen and environment.
 
Last edited:

sentrywiz

S

sentrywiz

@Legal Ease - your trigger is not complete. Target_Loc isn't defined here. Also the "Order unit to get the fuck out" < this is the main issue for me. I don't know the direction in which target unit is supposed to go.

Something with calculating missile direction, then telling the unit to go - + (45 90) degrees from it or something like that.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
Something with calculating missile direction, then telling the unit to go - + (45 90) degrees from it or something like that.

set locAngle = Angle from Loc of Missile to Loc of AI
if Absolute Value of (missile's facing angle - locAngle) <= 15 then
if missile's angle > locAngle
set offsetAngle = -90
else
set offsetAngle = 90
endif
set locAngle = missile's facing + offsetAngle
Order AI to move to (AI loc offset by 150 distance by locAngle degrees)

The (15) determines whether the AI will dodge or not depending on how close it is. Setting it to higher will cause AI to dodge even if the missile will not hit. Setting it to lower will cause the AI to not dodge even if the missile is about to hit.

You might wanna check if that new loc is walkable, if it is not, use another polar radius distance.
 
Dude, you want to code an advanced AI with GUI and without math knowledge? I'd say forget about it and make your map multiplayer.

Simple approaches like the one Flux proposed are easily exploitable as soon as a player figures out how the AI reacts and outright break as soon as more than one missile is fired into the same general direction.


In order to truly create an intelligent AI that would dodge missiles like a human would, you would have to track ALL missiles on the map at the same time, then apply a decision algorithm to find the most optimal place to dodge. Which is very similar to the traveling salesman problem, which can not be solved without recursion and high-level calculus.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
@OP the one I proposed will simply move perpendicular to the missile direction to a location farther from where the missile was about to hit (That's why there is an If-else condition finding which is greater). However, players can easily figure out how the AI reacts and if that new location happens to be in another cliff level, it is possible the the AI will find a path around it therefore, it can still be hit by the missile. So if you can't tolerate that, you have to periodically order the AI to move at a polar offset and at the same time, compare if it's current location is the same as where the AI should be (as predicted) which just adds more complexity. I doubt you will accept complex answers so I suggested a simple one. But if you want complexity, feel free to try. Also, the approach I suggested can make the AI go nuts if two missiles is about to hit it at the same time, but it is much less complicated.
 
@OP the one I proposed will simply move perpendicular to the missile direction to a location farther from where the missile was about to hit (That's why there is an If-else condition finding which is greater). However, players can easily figure out how the AI reacts and if that new location happens to be in another cliff level, it is possible the the AI will find a path around it therefore, it can still be hit by the missile.
Unfortunately, there are even worse problems than that:
If the AI always moves perpedicular, it's basicly possible to "control" the movement of the AI with skillshots.
For example, you could exploit it to make the AI move into the range of towers on AoS maps. I kid you not; you can expect players to figure that strategy out (and exploit it) in less than 5 minutes.

AI in MOBA games is just not feasable unless you really get into it hard.
AI is an optimization problem. There are no quick solutions in AI.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
Unfortunately, there are even worse problems than that:
If the AI always moves perpedicular, it's basicly possible to "control" the movement of the AI with skillshots.
For example, you could exploit it to make the AI move into the range of towers on AoS maps. I kid you not; you can expect players to figure that strategy out (and exploit it) in less than 5 minutes.

AI in MOBA games is just not feasable unless you really get into it hard.
AI is an optimization problem. There are no quick solutions in AI.
Yes, in short, its is really exploitable. In my defense, I just answered his question which I quoted in my 2nd previous post.
 

sentrywiz

S

sentrywiz

Dude, you want to code an advanced AI with GUI and without math knowledge? I'd say forget about it and make your map multiplayer.

Simple approaches like the one Flux proposed are easily exploitable as soon as a player figures out how the AI reacts and outright break as soon as more than one missile is fired into the same general direction.


In order to truly create an intelligent AI that would dodge missiles like a human would, you would have to track ALL missiles on the map at the same time, then apply a decision algorithm to find the most optimal place to dodge. Which is very similar to the traveling salesman problem, which can not be solved without recursion and high-level calculus.

I just want to remind you that occam's razor as a principle of problem solving stands everywhere. The most complex of solutions are not better or best and this has been proven too many times to list an example. Also KISS is true to heart here.

Dodging missiles and travelling to cities have little in common, especially since cities remain static while missiles don't. Also the AI doesn't want to "visit" any cities or even care about cities far from its detection range. It only cares to dodge the missiles that wander too close.
 
Last edited by a moderator:
I just want to remind you that occam's razor as a principle of problem solving stands everywhere. The most complex of solutions are not better or best and this has been proven too many times to list an example. Also KISS is true to heart here.
There is no easy solution in AI. There are way too many parameters to track here. You are not done with just knowing where a missile crosses the path of a unit.
You need to account for collision sizes of units (what if a unit is surrounded? You still give it a move order in that case, causing it to do nothing while trying to reach the target?), the maps pathing (what if a cliff or wall of trees blocks the targeted point?) and also other gameplay factors (towers? Other players? You definitely don't want the unit to run into a direction that creates more problems than it solves).

The KISS principle has nothing to do with algorithm complexity. KISS is about usability.

Dodging missiles and travelling to cities have little in common, especially since cities remain static while missiles don't. Also the AI doesn't want to "visit" any cities or even care about cities far from its detection range. It only cares to dodge the missiles that wander too close.
It has very much in common. Creating a dodge AI is an optimization problem based on movement efficiency. But it's not only about finding the closest safe spot - it's also about planning ahead, otherwise your move order will lead this unit into sure death, even if that death isn't caused by another missile. The traveling salesman is very similar in this case in that you can not put a solution to an immediate problem out of context of the bigger scope. You must think ahead.

So, yes, dodging is an optimization problem, otherwise your AI will be predictable and exploitable.
That is why simpler AI systems usually work with weighted randomness in which the weights shift according to external variables, of which the most basic (and easiest to track) would be:
- your health
- the health of enemies
- the position of enemies or friends not directly involved in the battle, but within proximity to assist
- the position of other external threats (creep camps, towers)
- expected damage of the missile
- expected gains you could have when not dodging (killing an enemy vs. him escaping)
- immobilizing factors
- abilities of the enemy

These weighting factors could trigger a number of behaviours, of which the most common would be:
- take the hit
- dodge a missile moving sideways
- dodge a missile with the closest possible secure spot
- fall back (towards the location of nearby friendlies)
- move closer to the target


I recommend starting with this. Actually, I take back what I said: with weighted randomness and all the above parameters and the possible behaviours, it seems very possible to code something like that.


For example, your script could look like this:

- Have all 5 behaviours the same base weight and pick the decision at random
- If your health is significantly higher than that of the enemy, shift the weight towards moving closer and/or taking the hit.
- If the expected damage would be lethal, shift the weight of "closest dodge" higher
- If your health is significantly lower than that of the enemy, increase the weight of falling back
- If you are close to the enemies' base, shift the weight towards falling back
- If more enemies are in proximity than allies, shift weight towards falling back
- If more allies are in proximity than enemies, shift weight towards moving closer

... etc.
 
Last edited:

sentrywiz

S

sentrywiz

There is no easy solution in AI. There are way too many parameters to track here. You are not done with just knowing where a missile crosses the path of a unit.
You need to account for collision sizes of units (what if a unit is surrounded? You still give it a move order in that case, causing it to do nothing while trying to reach the target?), the maps pathing (what if a cliff or wall of trees blocks the targeted point?) and also other gameplay factors (towers? Other players? You definitely don't want the unit to run into a direction that creates more problems than it solves).

The KISS principle has nothing to do with algorithm complexity. KISS is about usability.


It has very much in common. Creating a dodge AI is an optimization problem based on movement efficiency. But it's not only about finding the closest safe spot - it's also about planning ahead, otherwise your move order will lead this unit into sure death, even if that death isn't caused by another missile. The traveling salesman is very similar in this case in that you can not put a solution to an immediate problem out of context of the bigger scope. You must think ahead.

So, yes, dodging is an optimization problem, otherwise your AI will be predictable and exploitable.
That is why simpler AI systems usually work with weighted randomness in which the weights shift according to external variables, of which the most basic (and easiest to track) would be:
- your health
- the health of enemies
- the position of enemies or friends not directly involved in the battle, but within proximity to assist
- the position of other external threats (creep camps, towers)
- expected damage of the missile
- expected gains you could have when not dodging (killing an enemy vs. him escaping)
- immobilizing factors
- abilities of the enemy

These weighting factors could trigger a number of behaviours, of which the most common would be:
- take the hit
- dodge a missile moving sideways
- dodge a missile with the closest possible secure spot
- fall back (towards the location of nearby friendlies)
- move closer to the target


I recommend starting with this. Actually, I take back what I said: with weighted randomness and all the above parameters and the possible behaviours, it seems very possible to code something like that.


For example, your script could look like this:

- Have all 5 behaviours the same base weight and pick the decision at random
- If your health is significantly higher than that of the enemy, shift the weight towards moving closer and/or taking the hit.
- If the expected damage would be lethal, shift the weight of "closest dodge" higher
- If your health is significantly lower than that of the enemy, increase the weight of falling back
- If you are close to the enemies' base, shift the weight towards falling back
- If more enemies are in proximity than allies, shift weight towards falling back
- If more allies are in proximity than enemies, shift weight towards moving closer

... etc.

First of all, I apologize. I was at work when I saw this massive reply and wanted to read it later but I forgot...

There is only one unit, and its collision doesn't matter. Also missiles can fly through anything, so walls, cliffs and trees don't matter.

KISS stands for anything. It and Occam also explain everything - at its core, everything is simple. Trying to make it complicated is a human trait, often by those who want to prove how much they know. But let's not get into that..

This map will also have randomness. But we're not talking about my map mechanics, just how to make the AI dodge missiles. I don't care how predictable and exploitable you say it is, if its simple and I like it, I will use it. And you can go ahead and exploit it, that's your deal.

I like your game states, but you're assuming too much. You completely missed my map genre or the variables you gave me as you thought I'd need them. Nevertheless, I still like your logic and if I am making a map in that genre, I will ask you for optimization advice.

FOR NOW, just give me what I want if you know how it can be done. I want to calculate in which way the AI should turn, so it faces away from the missiles around it. NOTHING ELSE. Please
 
First of all, I apologize. I was at work when I saw this massive reply and wanted to read it later but I forgot...

There is only one unit, and its collision doesn't matter. Also missiles can fly through anything, so walls, cliffs and trees don't matter.
They do matter, unless your unit is a flying unit. I was not talking about the missile, but the dodging unit.

KISS stands for anything. It and Occam also explain everything - at its core, everything is simple. Trying to make it complicated is a human trait, often by those who want to prove how much they know. But let's not get into that..
Dude, this you even read what I wrote? Not everything is simple at it's core. It depends on the scope of things.
A dice is simple. Determining the probability of a certain dice result is simple. Calculating what result a dice will show before throwing it is not.

This map will also have randomness. But we're not talking about my map mechanics, just how to make the AI dodge missiles. I don't care how predictable and exploitable you say it is, if its simple and I like it, I will use it. And you can go ahead and exploit it, that's your deal.
Again, did you read what I wrote? Having the AI dodge missiles by simple mathematics will certainly cause more problems than it solves.

I like your game states, but you're assuming too much. You completely missed my map genre or the variables you gave me as you thought I'd need them. Nevertheless, I still like your logic and if I am making a map in that genre, I will ask you for optimization advice.
... which could be mended if you just gave us more context.

FOR NOW, just give me what I want if you know how it can be done. I want to calculate in which way the AI should turn, so it faces away from the missiles around it. NOTHING ELSE. Please
Eh... fine.
Just disregard completely the advice that people give you.

But, to answer your questions and NOTHING ELSE:

It's simple mathematics:
- For circular missile impact, compare the position of the unit with the impact center. Determine the angle between these points and make the unit move in the same direction by (impact radius - distance between impact center and position of the unit). This will fail as soon as any terrain obstacles that block the pathing for the dodging unit are present. It will also fail as soon as more than one missile aims for the same area.

- for linear moving missiles (like the tauren chieftain shockwave), things get ugly:

7SLdf.png


In this image, point E is the point between B and D.

Code:
sqr(E.x) + sqr(BD.m)*sqr(E.x) + 2*BD.m*E.x*BD.b - 2*E.x*B.x + sqr(B.x) - 2*BD.m*B.y + sqr(B.y) - 2*BD.b*B.y + sqr(B.y) == sqr(B.r)

(1 + sqr(BD.m)) * sqr(E.x)  +  2*(BD.m*BD.b - B.x) * E.x  + sqr(B.x)  +  sqr(B.y) - 2*BD.m*B.y + sqr(B.y) - 2*BD.b*B.y + sqr(B.y) - sqr(B.r) == 0

aa := (1 + sqr(BD.m));
bb := 2*(BD.m*BD.b - B.x);
cc := sqr(B.y) - 2*BD.m*B.y + sqr(B.y) - 2*BD.b*B.y + sqr(B.y) - sqr(B.r);

-> quadratic formula, and then get your two points and choose the one closer to B.
 

sentrywiz

S

sentrywiz

They do matter, unless your unit is a flying unit. I was not talking about the missile, but the dodging unit.

Well, it still doesn't matter. The unit can / will go where it can and it won't where it can't. Missiles will though, cuz its simpler that way.

Dude, this you even read what I wrote? Not everything is simple at it's core. It depends on the scope of things.
A dice is simple. Determining the probability of a certain dice result is simple. Calculating what result a dice will show before throwing it is not.

And I wholeheartedly disagree. Everything is simple at its core. But in its evolution of becoming, it grows up to infinity in complexity.

Dice is simple at its core: its an accessory easy and intuitive randomization. But it can have as many sides as you want, as many symbols as you want, it can even have multiple symbols per side to affect whatever in whatever circumstances. But at its core, it remains simple.


Again, did you read what I wrote? Having the AI dodge missiles by simple mathematics will certainly cause more problems than it solves.

I did. And I replied in the best way I thought.


... which could be mended if you just gave us more context.

Which is why I stick-ed to the point I needed and left everything out. Since skill-shot spells can be used in whatever genre.

Are you just mad that you "wasted" your time explaining a concept that I didn't need? If so, that is your fault not mine. Don't assume things that you cannot predict or currently don't know.


Eh... fine.
Just disregard completely the advice that people give you.

But, to answer your questions and NOTHING ELSE:

It's simple mathematics:
- For circular missile impact, compare the position of the unit with the impact center. Determine the angle between these points and make the unit move in the same direction by (impact radius - distance between impact center and position of the unit). This will fail as soon as any terrain obstacles that block the pathing for the dodging unit are present. It will also fail as soon as more than one missile aims for the same area.

- for linear moving missiles (like the tauren chieftain shockwave), things get ugly:

7SLdf.png


In this image, point E is the point between B and D.

Code:
sqr(E.x) + sqr(BD.m)*sqr(E.x) + 2*BD.m*E.x*BD.b - 2*E.x*B.x + sqr(B.x) - 2*BD.m*B.y + sqr(B.y) - 2*BD.b*B.y + sqr(B.y) == sqr(B.r)

(1 + sqr(BD.m)) * sqr(E.x)  +  2*(BD.m*BD.b - B.x) * E.x  + sqr(B.x)  +  sqr(B.y) - 2*BD.m*B.y + sqr(B.y) - 2*BD.b*B.y + sqr(B.y) - sqr(B.r) == 0

aa := (1 + sqr(BD.m));
bb := 2*(BD.m*BD.b - B.x);
cc := sqr(B.y) - 2*BD.m*B.y + sqr(B.y) - 2*BD.b*B.y + sqr(B.y) - sqr(B.r);

-> quadratic formula, and then get your two points and choose the one closer to B.

Thank you. I will study this until I get it.

+rep (can't rep you though, cuz I rep-ed you recently)

I didn't disregard everything, only those things that I don't care about or know differently in my own personal experience.
 
Well, it still doesn't matter. The unit can / will go where it can and it won't where it can't. Missiles will though, cuz its simpler that way.
And what will the unit do if you order it to move to a point that is blocked by an obstacle? Right: it will move in whatever direction the wc3 pathfinding algorithm orders it to.
And yes, that might even move the unit more towards the impact center.

And I wholeheartedly disagree. Everything is simple at its core. But in its evolution of becoming, it grows up to infinity in complexity.

Dice is simple at its core: its an accessory easy and intuitive randomization. But it can have as many sides as you want, as many symbols as you want, it can even have multiple symbols per side to affect whatever in whatever circumstances. But at its core, it remains simple.
A dice is simple in it's design. A dice result is simple to predict statistically. But it's almost impossible to predict a dice result before rolling it, even if the physics involved are completely deterministic.

There are problems in life that just aren't simple.
 

sentrywiz

S

sentrywiz

And what will the unit do if you order it to move to a point that is blocked by an obstacle? Right: it will move in whatever direction the wc3 pathfinding algorithm orders it to.
And yes, that might even move the unit more towards the impact center.


A dice is simple in it's design. A dice result is simple to predict statistically. But it's almost impossible to predict a dice result before rolling it, even if the physics involved are completely deterministic.

There are problems in life that just aren't simple.

There are no problems in life. Only passable challenges

In the grand design, everything is fundamentally simple at its core, but grows infinitely complex in all directions.
 
There are no problems in life. Only passable challenges
Seriously? -.-
You answer my real-world example with a random quote?
Is that how science works for you?

In the grand design, everything is fundamentally simple at its core, but grows infinitely complex in all directions.
Your point? I know that scope matters. That's what I'm telling you.
Your problem has a scope far larger than it's simple core. You just fail to acknowledge that.
 

sentrywiz

S

sentrywiz

Seriously? -.-
You answer my real-world example with a random quote?
Is that how science works for you?

Its true though, but to each their own.

Depends on what kind of science we're talking about.

Mainstream science is bullshit. It only measures what it can put into a
formula, equation and then rattle the cage like it made something happen.

I like to think of myself as spiritual, though I appreciate some amount
of science as well. Not the mainstream science, that is more like a
religion. That I don't support nor condone. For me, its a level of bullshit
equal to politics, religion, world order, economy, television etc.

Your point? I know that scope matters. That's what I'm telling you.
Your problem has a scope far larger than it's simple core. You just fail to acknowledge that.

I acknowledge that I don't know what you know. Because of that, I can't look at what you did
and go "aha!" and just get it. IMO, its easier to come up with alternate solutions that don't involve
me re-taking math classes just to get this. I want to solve this and be lazy. Its as simple as that :D
 
Do you still need help with this problem? I know a way how to solve your problem without any math knowledge.
How? Abusing the "worker" classification that causes units to move in the opposite direction of the damage source if they take damage, then have a small invisible dummy ability that deals 0 damage to trigger it?
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
you detect where the missile is flying to and if the hero controlled by the AI is in range of that, you order him to move 90° or -90° to the missline line.

You could create dummies between the unit casting and the target point as a detection method.

That's what I told him in the 1st page

@Zwiebelchen, I knew it, it was intentional.
 

sentrywiz

S

sentrywiz

That's what I told him in the 1st page

@Zwiebelchen, I knew it, it was intentional.

you did. but this became a snowball down a hill when Zwie started sharing "great" advice on METHamatics and how complex everything is and there are no easy solutions and yada yada here we are, third page of thread even though good solution was on page 1 :))
 
you did. but this became a snowball down a hill when Zwie started sharing "great" advice on METHamatics and how complex everything is and there are no easy solutions and yada yada here we are, third page of thread even though good solution was on page 1 :))
This is just because you fail to recognize the scope of this problem.

Why don't you just share control with with the enemy player anyway? After all, if you can already control their movement in a predictable way, why not go all the way? Would be like playing chess with yourself... :D

you detect where the missile is flying to and if the hero controlled by the AI is in range of that, you order him to move 90° or -90° to the missline line.

You could create dummies between the unit casting and the target point as a detection method.
Three questions:
1) how do you calculate if the missile is actually *aimed* in the right direction and would hit the unit in the first place without using mathematics?
2) how do you calculate the location that is 90° apart from the travel direction without mathematics?
3) how do you predict if the current movement of the unit intersects the missile travel path without mathematics? Because obviously, you don't want units to move in there accidentally either


Your answer had basicly the same sustenance like answering the question "How do I build a car?" with "well, duh, you just build the car!".
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
Here is simple demo how to predict whether a missile will hit a unit or not. However it will only predict correctly if the target unit is idle. And this is not perfectly precise.

If you want to predict correctly when the unit is moving, you should take unit's move direction, unit's movespeed, and estimated hit time into consideration. I will try this one later.

Note: Math is always required to work on these kind of things.
 

Attachments

  • AI.w3x
    49.8 KB · Views: 56

sentrywiz

S

sentrywiz

This is just because you fail to recognize the scope of this problem.

Yeah yeah. you also failed to recognize the simplicity of it :)

Here is simple demo how to predict whether a missile will hit a unit or not. However it will only predict correctly if the target unit is idle. And this is not perfectly precise.

If you want to predict correctly when the unit is moving, you should take unit's move direction, unit's movespeed, and estimated hit time into consideration. I will try this one later.

Note: Math is always required to work on these kind of things.

Thank you will take a look at it. +rep
 
Level 12
Joined
Jan 13, 2008
Messages
559
This is just because you fail to recognize the scope of this problem.

Why don't you just share control with with the enemy player anyway? After all, if you can already control their movement in a predictable way, why not go all the way? Would be like playing chess with yourself... :D


Three questions:
1) how do you calculate if the missile is actually *aimed* in the right direction and would hit the unit in the first place without using mathematics?
2) how do you calculate the location that is 90° apart from the travel direction without mathematics?
3) how do you predict if the current movement of the unit intersects the missile travel path without mathematics? Because obviously, you don't want units to move in there accidentally either


Your answer had basicly the same sustenance like answering the question "How do I build a car?" with "well, duh, you just build the car!".

of course you are going to need basic math..but math that everyone understands. I think it's quite obvious that math is needed but you make it sound more complicated than it actually is. And well..he asked for advice not to share a complete solution so I gave him an advice.
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
Hey, I have just found that blizzard doesn't halves the collision size in IsUnitInRange which is used by the Missile library I use. So you can change:

set a = Atan((m.collision+8)/dist)

to

set a = Atan((m.collision+16)/dist) // 16 is peasant's actual collision size at Object Editor

Then it should be perfectly precise now.

In case your missile (system) doesn't use IsUnitInRange, then you don't need to add unit's collision size to the calculation:

set a = Atan(m.collision/dist)
 

Attachments

  • AI.w3x
    50 KB · Views: 75

sentrywiz

S

sentrywiz

Hey, I have just found that blizzard doesn't halves the collision size in IsUnitInRange which is used by the Missile library I use. So you can change:

set a = Atan((m.collision+8)/dist)

to

set a = Atan((m.collision+16)/dist) // 16 is peasant's actual collision size at Object Editor

Then it should be perfectly precise now.

In case your missile (system) doesn't use IsUnitInRange, then you don't need to add unit's collision size to the calculation:

set a = Atan(m.collision/dist)

Great, thanks for the fix.
 
Status
Not open for further replies.
Top