• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] 60 Degree cone damage spell, how?

Status
Not open for further replies.
I'm trying to make a spell that damages units within a range of 500 in a 60 degree cone towards teh target of the spell. The only problem is; how do I add units within a triangle of "500*500*500" with degrees of 60* to a group so that I can damage them?
Like this (if anybody understands :p):
untitled.JPG
 
Level 7
Joined
Jul 20, 2008
Messages
377
A triangle is extremely difficult to do, but you can do a cone very easily (think of a sector of a circle). How, you ask?

First, pick every unit within the radius.
Next, remove any unit from that group such that the angle from the caster to the unit is NOT less than or equal to ((angle from caster to target point)+60) and is NOT greater or equal to ((angle from caster to target point)-60).

And there you have it. That group now holds all units within that cone.


EDIT: Alternatively and probably more efficient:

Pick every unit within the radius such that the angle from the caster to the unit is less than or equal to ((angle from caster to target point)+60) and is greater or equal to ((angle from caster to target point)-60).
 
Level 7
Joined
Jul 20, 2008
Messages
377
See the attached image.

Note that the angle from the origin to each of the red squares (the affected enemies) is LESS OR EQUAL TO than the angle X+60 and GREATER OR EQUAL TO the angle X-60. Thus, the enemy is in-between the two boundary angles. Get it now? The first part is to check if the unit is even within the radius of the circle. Hence the blue enemies being inside the circle. These are enemies that do pass the test of being within distance, but the blue enemies fail the test of being BETWEEN the two boundary angles.

EDIT: Oh, my bad. X is the angle from the caster to the target point.
 

Attachments

  • helpful.GIF
    helpful.GIF
    3.5 KB · Views: 565
That much I understand. But how do I put it in a trigger? I know how to implement Jass, and how to do minor adjustments, put I still use GUI the most. Like this:
dalle.jpg
I set the max radius from caster to 500 and use a "For each..." trigger(loop) to add units within the circles to a group which I will later damage.

But I suspect your way is more efficient if I get it to work..
 
Level 7
Joined
Jul 20, 2008
Messages
377
It should look something like this (leak-free):

  • FindTargets
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Breath of Fire
    • Actions
      • Set locOfCaster = (Position of (Triggering unit))
      • Set targetPoint = (Target point of ability being cast)
      • Set tempGroup = (Units within 500.00 of locOfCaster matching (((Owner of (Matching unit)) is an enemy of (Owner of (Triggering unit))) Equal to True))
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Set tempLoc = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Angle from locOfCaster to tempLoc) Greater than or equal to ((Angle from locOfCaster to targetPoint) - 30.00)
              • (Angle from locOfCaster to tempLoc) Less than or equal to ((Angle from locOfCaster to targetPoint) + 30.00)
            • Then - Actions
              • -------- The picked unit got hit, so do your effects here --------
            • Else - Actions
              • -------- Otherwise, it's NOT within the cone --------
          • Custom script: call RemoveLocation(udg_tempLoc)
      • Unit Group - Remove all units from tempGroup
      • Custom script: call RemoveLocation(udg_targetPoint)
      • Custom script: call RemoveLocation(udg_locOfCaster)
Let's do a bit of analysis here:

When we first form the group, note that it takes all units within a circle of the casting unit that is an enemy of the caster.

Now, we do some in-depth comparisons to make it so the spell only affects units within a cone whose "sides" are defined by subtracting 30 from the angle from your caster to the target point of the ability and adding 30 to that same angle for the other side. Then we check if the angle from the caster to one of the enemies in the group is BETWEEN the angles making up the "sides" of the cone. If both conditions are true, then the enemy unit is within the cone, and you can apply your effects to that enemy unit.

EDIT: Corrected the trigger to account for what UreDe4D said in the following post.
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
To check if a point is inside a triangle you'll need to use vectors.

Vector OA which is one of the vertices at the end of the triangle.
Vector OB which is the other vertex at the end of the triangle.
Vector OP which is a vector from O to the point in question.

Here's an example how it will look:
Code:
  A-------B
   \  P  /
    \ | /
     \|/
      O

And then use this quotation which I have no idea how to use since I never ever used or learned vectors.

OP = aOA + bOB (big letters are the vectors)

And must meet the conditions

0 < b
0 < a
a+b < 1

If you know how to use vectors, you'll already know what to do, because I don't :p
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Another way: Pick all units within a radius of 600 matching the condition: "Cos(Angle between you and target point - angle between you and matching unit) < Cos(degrees / 2)" (I think). Degrees is 60 here.
 
Level 7
Joined
Jul 20, 2008
Messages
377
you could also base it on channel and have dummy do BoF the level u want it to be.

But he wants the damage to be slightly randomized, hence "1d3" in post #3.

EDIT: Also, if the OP gets this, I updated the trigger to correct a leak. Move RemoveLocation(udg_tempPoint) to inside the unit group loop, at the end.
 
Last edited:
Status
Not open for further replies.
Top