Math Problem for my triggered spell

FarAwaY

TH.net Regular
Reaction score
9
Well Im making a triggered spell that looks like a beam blasting from the caster to all units in front of him.

My problem is, how do I pick all the units thats in front of him and put them into a unit group? I know you have to calculate the distance between the caster and whatnot but can someone help by being more specific?

This is much like the "cone problem", except that this is dealt in a line, rather than in a cone fashion, much like the shockwave skill rather than the breath of frost skill.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
function GroupEnumUnitsInLine takes group g, real x1, real y1, real x2, real y2, real width returns nothing
    local real angle = Atan2(y2-y1,x2-x1)
    local real dist = SquareRoot( (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1) )
    local real cdist = 0
    local group temp
    loop
        exitwhen (cdist > dist)
        set temp = CreateGroup()
        call GroupEnumUnitsInRange(temp,x1,y1,width/2,null)
        set bj_wantDestroyGroup = true
        call GroupAddGroup(temp,g)
        set x1 = x1+((width/4)*Cos(angle))
        set y1 = y1+((width/4)*Sin(angle))
        set cdist = cdist + (width/4)
    endloop
    set temp = null
endfunction


P/S : I live at Malaysia, beside you. :p
 

FarAwaY

TH.net Regular
Reaction score
9
Erm king, thanks alot but could you explain what it does? Furthermore, can I have it in GUI so I can modify it to my liking. Im not that proficient in JASS.

P.S.
Im half malaysian too lol.
 

kingkwong92

Well-Known Member
Reaction score
25
unit starts the effect of an ability
ability being cast equal to blast beam
Set radius = A x level of blast beam for triggering unit
Set range = B x level of blast beam for triggering unit
Set target_loc = target point of ability being cast
Set Caster_loc = position of triggering unit
Set angle = angle from caster_loc to target_loc
Set target_loc = caster_loc offset by radius towards angle
For integer A 1 to range do
Loop
Set target_group = all units within radius of target_loc matching <Your conditions>
Set target_loc = target_loc offset by (radius/4) towards angle
unit group pick every unit in target_group and
loop
add unit to blast_group
Custom script: call RemoveLocation(udg_caster_loc)
Custom script: call RemoveLocation(udg_target_loc)
Custom script: call DestroyGroup(udg_target_group)

Sorry this is freehand.
Set radius to how wide you want your blast
The range is The radius divided by 4.
So if you want it to have a 1200 range with 200 radius on level 1
radius = 200
range = 24
 

FarAwaY

TH.net Regular
Reaction score
9
> For integer A 1 to range do
Loop
Set target_group = all units within radius of target_loc matching <Your conditions>
Set target_loc = target_loc offset by (radius/4) towards angle

Is the "For Each Integer A 1 to Range" loop really necessary ? And yeah its a little confusing.
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top