• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Damage Unit Group

Status
Not open for further replies.
Level 17
Joined
Jun 28, 2008
Messages
776
Hi, I am very new to Jass and I am creating my first spell, here is what I have so far :

JASS:
function Trig_Earth_Break_JASS_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00Y' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Earth_Break_JASS_Actions takes nothing returns nothing

    local unit caster
    
    local location point1
    local location point2
    
    local real damage
    
    local integer x = 0
    local integer casts
    
    local effect special
    
    set caster = GetTriggerUnit()
    set damage = 50*GetUnitAbilityLevelSwapped('A00Y', caster)
    set casts  = 8
    
    loop
    
        set x = x + 1
        
        exitwhen x == casts
        
            set point1 = GetUnitLoc(caster)
            set point2 = PolarProjectionBJ(point1, GetRandomReal(0, 500.00), GetRandomReal(0, 360.00))
            call AddSpecialEffectLocBJ(point2, "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl")
            set special = GetLastCreatedEffectBJ()
            call TriggerSleepAction(0.06)
            call DestroyEffectBJ(special)
            
            <<>><<>><<>><<>><<<>>><<<>>><<>>

            call RemoveLocation(point1)
            call RemoveLocation(point2)
            
    endloop

endfunction

//===========================================================================
function InitTrig_Earth_Break_JASS takes nothing returns nothing
    set gg_trg_Earth_Break_JASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Earth_Break_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Earth_Break_JASS, Condition( function Trig_Earth_Break_JASS_Conditions ) )
    call TriggerAddAction( gg_trg_Earth_Break_JASS, function Trig_Earth_Break_JASS_Actions )
endfunction

Now the thing I want is that the trigger damages all units in a 250 radius from point2(the random point)

The <><><><><><><><><><> is where I want the code to go. I created a gui trigger and added the converted script, but it gave errors.

SO, my big question is : Is there a easy way to pick units in UnitGroup and then damage them, if the meet the conditions.

Thanks in advance.

++REP
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
JASS:
globals
    group enumGrp = CreateGroup()
endglobals

scope mySpell
private function TheFilter takes nothing returns boolean
    local unit u = GetFilterUnit()
    if ... then
        call UnitDamageTarget(...)
    endif
    set u = null
    return false
endfunction

..

call GroupEnumUnits...(enumGrp,...,Filter(function TheFilter))

..

endscope
 
Level 6
Joined
Aug 19, 2006
Messages
187
Hi, I am very new to Jass and I am creating my first spell, here is what I have so far :

JASS:
function Trig_Earth_Break_JASS_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00Y'
endfunction

function Trig_Earth_Break_JASS_Actions takes nothing returns nothing

    local unit caster = GetTriggerUnit()
    
    local location point1 = GetUnitLoc(caster)
    local location point2
    
    local real damage = 50*GetUnitAbilityLevelSwapped('A00Y', caster)
    
    local integer x = 0
    local integer casts = 8
    
    loop
    
        set x = x + 1
        
        exitwhen x == casts
        
            set point2 = PolarProjectionBJ(point1, GetRandomReal(0, 500.00), GetRandomReal(0, 360.00))
            call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl",point2))
            
            <<>><<>><<>><<>><<<>>><<<>>><<>>


    endloop
            call RemoveLocation(point1)
            set point1 = null
            call RemoveLocation(point2)
            set point2 = null
            set caster = null
endfunction

//===========================================================================
function InitTrig_Earth_Break_JASS takes nothing returns nothing
    local integer i = 0
    set gg_trg_Earth_Break_JASS = CreateTrigger(  )
    loop
        exitwhen i = <INSERTPLAYERNUMBER>
    call TriggerRegisterPlayerUnitEvent( gg_trg_Earth_Break_JASS, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null )
    set i = i+1
    endloop
    call TriggerAddCondition( gg_trg_Earth_Break_JASS, Condition( function Trig_Earth_Break_JASS_Conditions ) )
    call TriggerAddAction( gg_trg_Earth_Break_JASS, function Trig_Earth_Break_JASS_Actions )
endfunction

[...]

i justed added some code optimizations you could also use in the addition to purplepoot's advice
 
Status
Not open for further replies.
Top