Detecting Units in a Cone Area

Jinxx

New Member
Reaction score
4
Okay, since my last excursion into conal damage detection via custom buff placers failed miserably, I've decided to hell with it, I'll just trigger the whole thing! Now it's working as intended, there's no lag or anything, but I'm wondering if it's possible to do this in a more elegant way (I hate nesting countless "ifs" :mad:).

The spell is a modified Carrion Swarm that deals no damage; the trigger detects enemies in a frontal cone and damages them as well as having a dummy pop in and cast a modified Curse on them. The width of the cone detection is 90 degrees from the caster's facing angle, hence the two +/- 45 degree checks.

After banging my head in frustration for over an hour I finally figured out, through debug messages, that unit facing ranges from [0, 360] degrees while angle between points ranges from [-180, 180] degrees! Thank you Blizzard, for being so consistent!! :banghead: :banghead: :banghead: :banghead: :banghead: :(


Trigger:
  • Mystra's Kiss New
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Carrion Swarm CONE TEST
    • Actions
      • Unit Group - Pick every unit in (Units within 500.00 of (Position of (Casting unit)) matching (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True)) and do (Actions)
        • Loop - Actions
          • Game - Display to (Player group((Owner of (Casting unit)))) for 5.00 seconds the text: (DEBUG: Angle from position of caster to position of picked unit in degrees: + (String((Angle from (Position of (Casting unit)) to (Position of (Picked unit))))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Angle from (Position of (Casting unit)) to (Position of (Picked unit))) Greater than or equal to 0.00
                      • (Angle from (Position of (Casting unit)) to (Position of (Picked unit))) Greater than or equal to ((Facing of (Casting unit)) - 45.00)
                      • (Angle from (Position of (Casting unit)) to (Position of (Picked unit))) Less than or equal to ((Facing of (Casting unit)) + 45.00)
                  • And - All (Conditions) are true
                    • Conditions
                      • (Angle from (Position of (Casting unit)) to (Position of (Picked unit))) Less than 0.00
                      • (Angle from (Position of (Casting unit)) to (Position of (Picked unit))) Greater than or equal to (((Facing of (Casting unit)) - 45.00) - 360.00)
                      • (Angle from (Position of (Casting unit)) to (Position of (Picked unit))) Less than or equal to (((Facing of (Casting unit)) + 45.00) - 360.00)
            • Then - Actions
              • --- damage the picked unit since it passed the angle checks ---
              • Unit - Cause (Casting unit) to damage (Picked unit), dealing 100.00 damage of attack type Chaos and damage type Divine
              • --- create a dummy at the picked unit's location and order it to Curse the unit ---
              • Unit - Create 1 Dummy Caster (Jinxx Dummy) for (Owner of (Casting unit)) at (Position of (Picked unit)) facing (Position of (Picked unit))
              • Unit - Add (Dummy Spell) (Mystra's Kiss) (Flare) to (Last created unit)
              • Unit - Set level of (Dummy Spell) (Mystra's Kiss) (Flare) for (Last created unit) to (Level of Carrion Swarm CONE TEST for (Casting unit))
              • Unit - Order (Last created unit) to Undead Banshee - Curse (Picked unit)
              • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
            • Else - Actions
      • Game - Display to (Player group((Owner of (Casting unit)))) for 5.00 seconds the text: (DEBUG: The caster's facing angle in degrees is: + (String((Facing of (Casting unit)))))


Another thing is I'd like to hear your suggestions as to the width of the cone based on the Carrion Swarm animation. I have the spell's speed set to 1250 and range to 500, so what would be the best AoE and cone width to set with this? Also, what the heck does "Final Area" mean (300 by default)?

Finally, please ignore leaks - I fix those once I'm satisfied with the finished trigger.

Anyway, cookies to you if you've managed to read though all this! :thup:
 

Jinxx

New Member
Reaction score
4
Breath of Frost places a buff. You can try detect it.

Nah, I've given up on that - there's a whole thread I posted two days ago in which you can see just why. Right now I just want to optimize this trigger as much as possible.
 

Bogrim

y hello thar
Reaction score
154
Breath of Frost is bugged when you remove the buff, as the damage event will fire several times for some reason. However, there is a work-around to avoid this problem. In addition to removing the buff, add the unit to a unit group and check whether the unit is in the group already in your trigger's conditions. That will prevent the trigger from running more than once despite the bug. Here's an example of a Carrion Swarm spell I made using GDD and Breath of Frost:
Trigger:
  • Ability Carrion Swarm
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • ((Triggering unit) has buff Breath of Frost (Carrion Swarm)) Equal to True
      • ((Triggering unit) is in group_CarrionSwarm) Equal to False
    • Actions
      • Unit - Remove Breath of Frost (Carrion Swarm) buff from (Triggering unit)
      • Unit Group - Add (Triggering unit) to group_CarrionSwarm
      • [...]
Trigger:
  • Ability Carrion Swarm clear
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Carrion Swarm (Dreadlord)
    • Actions
      • Unit Group - Remove all units from group_CarrionSwarm

If you need it to be MPI, make the group an array and use the player's index. If you need it to be MUI, either use an indexer with an array or save the group's handle to the casting unit in a hashtable.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Breath of Frost is bugged when you remove the buff, as the damage event will fire several times for some reason.
Huh, interesting. You're right. Also interesting is that Breath of Fire seems to place its buff for a fraction of a second as far as triggers are concerned, but it won't show up in-game unless cast on a unit with Drunken Haze (and, by the way, it also glitches on buff removal like Breath of Frost).

Actually, you know, I think I ran into this before and assumed it was because the buff is how the game keeps track of which units have been hit by the spell already; removing the buff makes it fair game to be hit by the wave additional time. Supporting evidence: a slower-moving Breath of Fire with a trigger removing the buff will do more damage than a fast-moving Breath of Fire, although even a fast-moving BoF will hit twice if the buff is removed.
 

mapguy

New Member
Reaction score
46
I'll post a tutorial about this today.
but I'll write something for you now:

set Point_A = position of caster
set point_C = target point of ability beeing cast
Pick all units around the Point_A
set Point_B = position of every unit picked
set Point_D = Point_A offset by (distance between Point_A and Point_B) and (angle between Point_A and Point_C)
set Hipotenuse = (distance between Point_A and Point_D) x 2
set Cateto = Distance between Point_D and Point_B)
set Sine = (Cateto / Hipotenuse)
----then you convert sine to an angle and check if this sine is in the interval of sines you want.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top