HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spell that targets friendlys and enemys, does different things

08-15-2009, 03:18 AM#1
T3RMINUS
Hello, the spell i would like to make is a channeled spell that creates a circle area around the caster, to pause all units inside the circle, and several beams of light or dark energy come down in random places. I would like the light beams to heal allied units and the dark beams to damage enemy units. I know it's a lot to ask, but I would really appriciate some help... I don't even know where to start. Here's my code so far:
function Trig_Light_n_Dark_Actions takes nothing returns nothing

Collapse JASS:
function Trig_Light_n_Dark_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function Trig_Light_n_Dark_Actions takes nothing returns nothing
 local integer a = 0
 local boolean b = false
    loop
        exitwhen a == 20
        if (b==false) then
            call AddSpecialEffectLoc("war3mapImported\\Desecrate.mdx", GetRandomPointInDisk(GetUnitX(GetSpellAbilityUnit()), GetUnitY(GetSpellAbilityUnit()), 0, 500))
        else
            call AddSpecialEffectLoc("war3mapImported\\Judgement.mdx", GetRandomPointInDisk(GetUnitX(GetSpellAbilityUnit()), GetUnitY(GetSpellAbilityUnit()), 0, 500))
        endif
        set a = a+1
    endloop
endfunction

//===========================================================================
function InitTrig_Light_n_Dark takes nothing returns nothing
    set gg_trg_Light_n_Dark = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Light_n_Dark, function Trig_Light_n_Dark_Actions )
    call TriggerAddCondition( gg_trg_Light_n_Dark, Condition( function Trig_Light_n_Dark_Conditions ) )
    call Preload("war3mapImported\\Desecrate.mdx")
    call Preload("war3mapImported\\Judgement.mdx")
endfunction
Edit: Well, I found GetRandomPointInDisk by Vex, but i get a weird syntax error when i use it, only on the top one. As far as i can tell, the top one is exactly the same as the bottom one except for the file path. Any help?
08-15-2009, 07:03 PM#2
Anitarf
You're missing a "call" in front. The second syntax error isn't reported because the compiler gives up after the first.

Could you specify more precisely how you want the damage to be done? In a small area around the effect, or in the entire spell area simultaneously?
08-15-2009, 07:05 PM#3
T3RMINUS
In a small area around the effect.

Edit: and, adding a call still comes up with a syntax error.
Edit2: odd, I usually save to check errors, but when i use syntax check it comes up with different errrors. I've highlighed the new errors.
08-15-2009, 07:11 PM#4
Anitarf
You lack an ")" at the end of the line.

If you want your effects to appear in only a circle, not a disk, then you needn't use that function, you can instead inline the code which would save you the use of a location.
08-15-2009, 07:13 PM#5
T3RMINUS
What is the difference between a circle and a disk?
08-15-2009, 07:15 PM#6
Anitarf
Disk has a certain thickness, it's basically an area between two circles. In your case, however, you set the radii for both the inner and the outer circle to the same value, so your disk has no width, it is effectively a circle.
08-15-2009, 07:16 PM#7
T3RMINUS
I see, so like a donut . Give me a second to try to figure this out, if i cant then i will ask you for help.
Edit: Lol I need help... I don't know the maths for a circle.
Edit2: Well, after looking at it some more, i got this so far:
Collapse JASS:
function PickRandomPointInCircle takes real centerX, real centerY, real radius returns location
    return centerX + (GetRandomReal(0, radius)) * Cos(0, 2 * bj_PI), centerY + (GetRandomReal(0, radius)) * Cos(0, 2 * bj_PI)
endfunction
But I get 3 errors: Too many arguments passed to function, syntax error, and missing return all on line 2.
08-15-2009, 07:45 PM#8
chobibo
Maybe this could help. Disk Point Picking
08-15-2009, 07:51 PM#9
T3RMINUS
Quote:
Originally Posted by chobibo
Maybe this could help. Disk Point Picking
Um... could you explain that to me? I just started trig this year so I don't understand any of this...
Edit: I decided to go with GetRandomPointInDisk for now... my code has no errors but it doesnt work atm.
08-15-2009, 08:10 PM#10
chobibo
I'm not sure if I'm right but this is how I understood that:
Collapse JASS:
// cX       :   the x offset of disk's center.
// cY       :   the x offset of disk's center.
// radius   :   the circle's radius.
// width    :   refers to the width of the disk where it picks a random point.

function GetRandomPointInDisk takes real cX, real cY, real width, real radius returns location
    local real x=GetRandomReal(cX+width, radius)
    local real y=GetRandomReal(cY+width, radius)
    local real angle=GetRandomReal(0, bj_PI*2)
    local real radius=SquareRoot(x*x+y*y)
    
    set x=x+radius*Cos(angle)
    set y=y+radius*Sin(angle)
    
    return Location(x,y)
endfunction

Vexorian gave that link to someone asking how to get a random point inside a disk, I just gave it to you also lol. Just wait for corrections, I expect mine to not work as intended.
08-15-2009, 08:28 PM#11
Anitarf
Yeah, yours is totally wrong.
08-15-2009, 09:36 PM#12
T3RMINUS
Ok, so I heared somewhere that if you use a wait function in your spell it won't be mui. Is this true?
08-15-2009, 09:59 PM#13
Anitarf
Quote:
Originally Posted by T3RMINUS
Ok, so I heared somewhere that if you use a wait function in your spell it won't be mui. Is this true?
No. Wait actions suck for a lot of other reasons and you shouldn't be using them, but they don't inherently make a spell non-MUI.
08-15-2009, 10:10 PM#14
T3RMINUS
Quote:
Originally Posted by Anitarf
No. Wait actions suck for a lot of other reasons and you shouldn't be using them, but they don't inherently make a spell non-MUI.
Well, I haven't been using them, so thats good... but how would i get my spell to wait in between the beams (so they don't all come at once) without using a wait?
08-15-2009, 10:31 PM#15
Anitarf
By using timers.