• 🏆 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!

custom spell: kill first unit in direction

Status
Not open for further replies.
Level 7
Joined
Jan 30, 2011
Messages
267
i want to create a spell that is cast into a target direction (dummyspell carrion swarm)
the spell INSTANTLY kills the first enemy unit in the target direction
i dont manage to properly detect the unit, that should be killed
 
Level 8
Joined
Aug 21, 2009
Messages
333
Pretty sure Mr Bean didn't read the question...

Anyway. Here is a rough idea of how you could do it:

variables:
Spell_Width:real - width of the angle of the spell (how wide you want the area of effect to be) let's call it 40 degrees
Spell_Angle:real - angle from caster to casting point of spell
Unit_Angle:real - angle from caster to possible closest unit
Unit_Distance:real - distance from caster to possible closest unit
Closest_Distance:real - self-explanatory
Closest_Unit:unit - self-explanatory

When the spell is cast:
- calculate Spell_Angle
- set Closest_Distance to whatever the spell range is (let's say 700)
- set Closest_Unit to No Unit
- Select each unit within a range of the caster (let's say 700):
- - calculate Unit_Angle
- - if (unit is enemy AND Unit_Angle > Spell_Angle - Spell_Width/2 AND Unit_Angle < Spell_Angle + Spell_Width/2)
- - - calculate Unit_Distance
- - - if (Unit_Distance < Closest_Distance)
- - - - set Closest_Distance to Unit_Distance
- - - - set Closest_Unit to Selected Unit
- kill Closest_Unit

Obviously, you can name the variables whatever you want.
Let me know if you need more explanation
 
Level 7
Joined
Jan 30, 2011
Messages
267
i should have been more exact in my description:
my spell will be a lightning that hits the first unit in its way
the problem about ur system is, that the area of possible units is not a narrow and long rect, it is a sector of a circle, close to a triangle
thx for trying to help me but ur suggestion sadly wont work
 
Level 8
Joined
Aug 21, 2009
Messages
333
Okay, I understand. I was under the impression that you wanted a cone AOE since your base-spell is Carrion Swarm.

Anyway, you have 2 options:
  1. Settle for the cone AOE. I don't think there is much added value in having a linear width AOE for this spell.
  2. Don't settle. See the attached picture for way to visualize how to do this.

I think either way, you should make it so if a closest unit is found, it should create a dummy unit at the caster's location and make it cast a chain lightning with a single target and 999999 damage on the found closest unit.
 

Attachments

  • example.png
    example.png
    15 KB · Views: 82
Level 7
Joined
Jan 30, 2011
Messages
267
exactly what i was searching for and thx for the good idea, but i allready decided to do it another mathimatical way: just calculate the point on middle black line that is closest to the possible unit, and if the difference between the unit and the calculated point is smaller than the allowed width, the unit is a possible target
 
Status
Not open for further replies.
Top