• 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] Sacred Wave

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2008
Messages
253
I am making a spell that makes a beam, heals all allies and damages enemies every 0.5 seconds for 10 seconds. But it doesn't work at all

This is what i have:

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

function Trig_Sacred_Wave_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location loc = GetSpellTargetLoc()
    local group g = CreateGroup()
    local player p = GetOwningPlayer(caster)
    local unit u
    local unit beam
    local real duration = 0.00
        loop
        exitwhen duration > 10.00
        call CreateUnitAtLoc( p, 'h00A', loc, bj_UNIT_FACING )
        set beam = GetLastCreatedUnit()  
        set g = GetUnitsInRangeOfLocAll (250, loc )
            loop
            set u = FirstOfGroup ( g )
            exitwhen u == null
            call GroupRemoveUnit (g , u )
            if IsUnitEnemy(u, p) then
                call UnitDamageTargetBJ(caster, u, ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, caster, true)) * 0.25 ), ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL )
            else
                call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + I2R(GetHeroStatBJ(bj_HEROSTAT_INT, caster, true)) ) )
            endif            
            set p = null
            set u = null
            endloop
        call RemoveUnit(beam)
        call TriggerSleepAction(0.50)
        set duration = (duration + 1.00)
        endloop
    call RemoveLocation(loc)
    set caster = null
    call DestroyGroup(g)
    set duration = 0.00
endfunction

//===========================================================================
function InitTrig_Sacred_Wave takes nothing returns nothing
    set gg_trg_Sacred_Wave = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Sacred_Wave, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Sacred_Wave, Condition( function Trig_Sacred_Wave_Conditions ) )
    call TriggerAddAction( gg_trg_Sacred_Wave, function Trig_Sacred_Wave_Actions )
endfunction

Could anyone help me?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Here is how the trigger should look like:
JASS:
function Trig_Sacred_Wave_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00P' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Sacred_Wave_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location loc = GetSpellTargetLoc()
    local group g = CreateGroup()
    local player p = GetOwningPlayer(caster)
    local unit u
    local unit beam
    local real duration = 0.00
    loop
        exitwhen duration > 10.00 
        set beam = CreateUnitAtLoc( p, 'h00A', loc, bj_UNIT_FACING )
        call GroupEnumUnitsInRangeOfLoc(g, loc, 250, null )
        loop
            set u = FirstOfGroup ( g )
            exitwhen u == null
            call GroupRemoveUnit (g , u )
            if IsUnitEnemy(u, p) then
                call UnitDamageTarget(caster, u, GetHeroInt( caster, true) * 0.25 ,true,false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS )
            else
                if GetUnitState(u,UNIT_STATE_LIFE)>0.405 then
                    call SetUnitState( u,UNIT_STATE_LIFE,  GetUnitState(u, UNIT_STATE_LIFE) + I2R(GetHeroInt( caster, true)))
                endif
            endif
            set u = null
        endloop
        call RemoveUnit(beam)
        call TriggerSleepAction(0.50)
        set duration = duration + 1.00
        endloop
    call RemoveLocation(loc)
    call DestroyGroup(g)
    set caster = null
    set p=null
    set beam=null
    set g=null
    set loc=null
endfunction

//===========================================================================
function InitTrig_Sacred_Wave takes nothing returns nothing
    set gg_trg_Sacred_Wave = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Sacred_Wave, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Sacred_Wave, Condition( function Trig_Sacred_Wave_Conditions ) )
    call TriggerAddAction( gg_trg_Sacred_Wave, function Trig_Sacred_Wave_Actions )
You do not need to null reals. You need to null loc and g after destroying them.
You do not null p where you did.
And btw:
Would be way more easier if you use a dummy unit. Just create it on the spell target location. Add an immolation based spell with appropriate effects and some AOE heal aura. Set their level to the appropriate level. Than add a expiration timer to the unit. Done.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
And by "evil errors" you mean?
Kinda can't fix them if I do not know what they are...
P.s. There are no syntax errors on my side.
And ffs, I told you how to do it easily.
 
Level 7
Joined
Jul 9, 2008
Messages
253
First of all, my "evil error" is when i press test/save or enable trigger then my editor shuts off?

And second i dont do it your "easy way" because i need the wave to do damage in Int and since u cant do that with a dummy it would be useless...

Clear enough for you?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
This is getting retarded ...
You asked for jass, so you should be able to figure your "evil error".
But here is a hint for this so hard problem: there is something missing.
Here is another hint: it is missing from the end.
Final hint: it has to do something with functions
P.s. JNGP
 
Level 7
Joined
Jul 9, 2008
Messages
253
The only thing i asked was if someone could help me with a spell, i'm to JASS and this is what i get. Someone calling it retarded that someone asks for help. If u dont want to help then bother someone else...
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
No, I call the last several posts retarded.
But, yes you should have been able to figure the error.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Last hint:
You have it in your post.
P.s. It was left out during the copy-paste process(from WE to here).
 
Status
Not open for further replies.
Top