• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] GUI to JASS help

Status
Not open for further replies.
Level 3
Joined
Sep 9, 2009
Messages
658
JASS:
function Trig_Death_Blow_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A01C' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Death_Blow_Func005002003001001 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(u)) == true )
endfunction

function Trig_Death_Blow_Func005002003001002 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Death_Blow_Func005002003001 takes nothing returns boolean
    return GetBooleanAnd( Trig_Death_Blow_Func005002003001001(), Trig_Death_Blow_Func005002003001002() )
endfunction

function Trig_Death_Blow_Func005002003002001 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true )
endfunction

function Trig_Death_Blow_Func005002003002002 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false )
endfunction

function Trig_Death_Blow_Func005002003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Death_Blow_Func005002003002001(), Trig_Death_Blow_Func005002003002002() )
endfunction

function Trig_Death_Blow_Func005002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Death_Blow_Func005002003001(), Trig_Death_Blow_Func005002003002() )
endfunction

function Trig_Death_Blow_Func008A takes nothing returns nothing
    call AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", GetEnumUnit(), "origin" )
    call DestroyEffect( GetLastCreatedEffectBJ() )
    call UnitDamageTargetBJ( u1, GetEnumUnit(), d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
endfunction

function Trig_Death_Blow_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit u1 = GetSpellTargetUnit()
    local location p = GetUnitLoc(u1)
    local real d = ( 125.00 + ( 75.00 * I2R(GetUnitAbilityLevelSwapped('A01C', u)) ) )
    local group g = GetUnitsInRangeOfLocMatching(300.00, p, Condition(function Trig_Death_Blow_Func005002003))
    call AddSpecialEffectLoc( "ThunderclapCasterGreen.mdx", p )
    call DestroyEffect( GetLastCreatedEffectBJ() )
    call ForGroup( g, function Trig_Death_Blow_Func008A )
    call RemoveLocation (p)
    call DestroyGroup (g)
    set u = null
    set u1 = null
endfunction

//===========================================================================
function InitTrig_Death_Blow takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Death_Blow_Conditions ) )
    call TriggerAddAction( t, function Trig_Death_Blow_Actions )
    set t = null
endfunction

Okay, so I tried reading the tutorial about converting GUI triggers to efficient JASS but it never dealt with local variables being used in ITE conditions. I think I should change the ITE conditions to be more efficient but since this trigger is a little different from the example in the tutorial, I'm having trouble getting it to work. Can anyone tell me what I need to do?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
JASS:
function Trig_Death_Blow_Func005002003 takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(u)) and IsUnitType(GetFilterUnit()) != UNIT_TYPE_DEAD
endfunction

You could also use a variable for the filtered unit.

Then get rid of the location.

Then you could use FirstOfGroup loop instead of a filter function.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
in that tutorial i showed u how to inline. u didnt inline any of ur functions. u should take a look at that part.

also u should combine all of those condition functions. i showed u that in the tutorial also. Maker showed u this.

local variables get used in the ITE functions. im not sure wat u mean by how they arent dealt with ? u declare a local at the top of the script. then u use them just as if they were global variables.
 
Level 3
Joined
Sep 9, 2009
Messages
658
in that tutorial i showed u how to inline. u didnt inline any of ur functions. u should take a look at that part.

also u should combine all of those condition functions. i showed u that in the tutorial also. Maker showed u this.

local variables get used in the ITE functions. im not sure wat u mean by how they arent dealt with ? u declare a local at the top of the script. then u use them just as if they were global variables.

This sounds stupid but what's inlining? I checked the tutorial again and I still can't figure out what it is.

Yeah, I kinda figured I had to combine them but I didn't know how to do that since it seemed like they were already returning what I wanted to be returned, so thanks to Maker for showing me how to do that.

About local variables...so instead of declaring them at the actions function of my trigger, I should just declare them at the very top just at the bottom of the trigger condition function?

And what's a FirstofGroup loop? Oh and when I copied Maker's new condition and tried to save the map, it said not enough arguements for the IsUnitType. Why is that? It works fine if I delete the last part though, I think.

<b>EDIT: I think I'm starting to get it, I put everything into one function like deathismyfriend says, with the locals first, the conditions below them. For the unit group issue, I can use the FirstofGroup loop so that I don't have to use another function is that correct? But ForGroup needs a callback right? So I still need another function which would make declaring the locals useless since they're only limited to the function they're in right? So how do I fix that?</b>
 
Last edited:
Level 29
Joined
Oct 24, 2012
Messages
6,543
A firstofgroup replaces the for group loop.

Look in one of my spells I use a Firstofgroup loop. I can't show u right now I'm on my phone.

As for inlining. It means to get rid of all the functions that call other functions. All the red text is not inlined. The red text are called BJs. They call the native functions that are used in jass. Easiest way to find out what they call is to use JNGP. That's wat I use in my tutorial. Then when u hold ctrl and click the red text it shows u wat is called. So instead of using the inefficient BJs u change all of them to the functions that are called. Again I would give an example but I'm on my phone.
 
Level 3
Joined
Sep 9, 2009
Messages
658
Thanks for the suggestions. However, I can't try them just yet since I tried modifying the script to make it similar to the one in deathismyfriend's tutorial but when I tried to save it, I got an error saying there's a missing endblock. I think it's somehow affecting the initialization trigger. Anyway, this isn't the complete edit since I can't continue until I solve that problem.

JASS:
function Trig_Death_Blow_Func005002003 takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) and IsUnitType(GetFilterUnit()) != UNIT_TYPE_DEAD
endfunction

function Trig_Death_Blow_Func008A takes nothing returns nothing
    call AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", GetEnumUnit(), "origin" )
    call DestroyEffect( GetLastCreatedEffectBJ() )
    call UnitDamageTargetBJ( u1, GetEnumUnit(), d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
endfunction

function Trig_Death_Blow_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit u1 = GetSpellTargetUnit()
    local location p = GetUnitLoc(u1)
    local real d = ( 125.00 + ( 75.00 * I2R(GetUnitAbilityLevelSwapped('A01C', u)) ) )
    local group g = GetUnitsInRangeOfLocMatching(300.00, p, Condition(function Trig_Death_Blow_Func005002003))
    if GetSpellAbilityId() == 'A01C' then
        call AddSpecialEffectLoc( "ThunderclapCasterGreen.mdx", p )
        call DestroyEffect( GetLastCreatedEffectBJ() )
        call ForGroup( g, function Trig_Death_Blow_Func008A )
        call RemoveLocation (p)
        call DestroyGroup (g)
        set u = null
        set u1 = null
    end if
    return false
endfunction

//===========================================================================
function InitTrig_Death_Blow_Copy_3 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Death_Blow_Actions ) )
    set t = null
endfunction
 
Level 3
Joined
Sep 9, 2009
Messages
658
JASS:
local unit u

set g = someGroup
loop
    set u = FirstOfGroup(g)
    exitwhen u == null
    if u is structure and u is alive and blah blah then
        do something
    endif
    call GroupRemoveUnit(g, u)
endloop

Okay, I finally got some free time. I've started taking Japanese lessons just recently so I couldn't find time to to work on this. Is someGroup supposed to be a global variable?

Oh and how do you write the conditions? Does it go like...

if u = IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) and blah blah?
 
Level 3
Joined
Sep 9, 2009
Messages
658
JASS:
function Trig_Death_Blow_Func008A takes nothing returns nothing
    call AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", GetEnumUnit(), "origin" )
    call DestroyEffect( bj_lastCreatedEffect )
    call UnitDamageTargetBJ( u1, GetEnumUnit(), d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
endfunction

function Trig_Death_Blow_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit u1 = GetSpellTargetUnit()
    local location p = GetUnitLoc(u1)
    local real d = ( 125.00 + ( 75.00 * I2R(GetUnitAbilityLevel(u, 'A016') ) ))
    set g = udg_DB_group
    loop
        set u = FirstOfGroup(g)
        if IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) and GetUnitState(u, UNIT_STATE_LIFE) <= 0
            call AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", GetEnumUnit(), "origin" )
            call DestroyEffect( bj_lastCreatedEffect )
            call UnitDamageTargetBJ( u1, GetEnumUnit(), d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
        exitwhen u == null
    endloop
    call AddSpecialEffectLoc( "ThunderclapCasterGreen.mdx", p )
    call DestroyEffect( bj_lastCreatedEffect )
    call ForGroup( g, function Trig_Death_Blow_Func008A )
    call RemoveLocation (p)
    call DestroyGroup (g)
    set u = null
    set u1 = null
endfunction

function Trig_Death_Blow_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A016' then
        call Trig_Death_Blow_Actions()
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Death_Blow_Copy_3 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Death_Blow_Conditions) )
    set t = null
endfunction

There's no more errors when I save. I think it's almost done. The only thing that bothers me now is that I haven't set the range of the group, have I? How do I do that? Plus, I think I shouldn't have set g to a global variable. Can anyone go over this trigger one more time?

EDIT: My bad, I had the trigger disabled when I saved. That's why no errors popped up when I saved. The only error now is that g is an undefined variable. Should I do something like
JASS:
local group g = GetUnitsinRangeofLoc blah blah
since the conditions are inside the FirstofGroup loop??

Sorry for double posting but...OH MY GOD, FINALLY!!!

JASS:
function Trig_Death_Blow_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit u1 = GetSpellTargetUnit()
    local location p = GetUnitLoc(u1)
    local real d = ( 125.00 + ( 75.00 * I2R(GetUnitAbilityLevel(u, 'A016') ) ))
    local group g = GetUnitsInRangeOfLocAll(300, p)
    loop
        set u = FirstOfGroup(g)
        if IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) and GetUnitState(u, UNIT_STATE_LIFE) <= 0 then
            call AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", GetEnumUnit(), "origin" )
            call DestroyEffect( bj_lastCreatedEffect )
            call UnitDamageTargetBJ( u1, GetEnumUnit(), d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
        exitwhen u == null
        endif
    endloop
    call AddSpecialEffectLoc( "ThunderclapCasterGreen.mdx", p )
    call DestroyEffect( bj_lastCreatedEffect )
    call RemoveLocation (p)
    call DestroyGroup (g)
    set u = null
    set u1 = null
endfunction

function Trig_Death_Blow_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A016' then
        call Trig_Death_Blow_Actions()
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Death_Blow_Copy_3 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Death_Blow_Conditions) )
    set t = null
endfunction

I just have a few questions now, in the FirstofGroup loop do I need to null u?
And is there a better way to make the groups? Since GetUnitsInRangeOfLocAll is a red text.
 
Last edited by a moderator:
Level 23
Joined
Apr 16, 2012
Messages
4,041
its maybe a bit more efficient to do this:

JASS:
local group g = CreateGroup()
call GroupEnumUnitsInRange(g, GetUnitX(u1), GetUnitY(u1), 300, null)
//first argument is the group that we want to put the units in
//second argument is the X coordiante, we take the units X
//third is Y coordiante, again, units Y
//fourth is radius, in your case 300
//fifth argument is boolexpr(conditional function which says if the unit should be added or not), this is most of the time null

//first of group loop
call DestroyGroup(g)
set g = null
This way you dont need the location at all


and I think you dont need to null the unit variable because you are already setting it to null by set u = FirstOfGroup(g)

You are missing one call by the way, this would crash the thread, you need GroupRemoveUnit(g, u) to remove the unit from group after picking it to variable(without this, you will always pick the first unit in the UnitGroup)
 
Level 3
Joined
Sep 9, 2009
Messages
658
JASS:
function Trig_Death_Blow_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit u1 = GetSpellTargetUnit()
    local location p = GetUnitLoc(u1)
    local real d = ( 125.00 + ( 75.00 * I2R(GetUnitAbilityLevel(u, 'A01C') ) ))
    local group g = CreateGroup()
    call GroupEnumUnitsInRange(g, GetUnitX(u1), GetUnitY(u1), 300, null)
    loop
        set u1 = FirstOfGroup(g)
        if IsUnitType(u1, UNIT_TYPE_GROUND) and IsUnitType(u1, UNIT_TYPE_STRUCTURE) and IsUnitEnemy(u1, GetOwningPlayer(u)) and GetUnitState(u1, UNIT_STATE_LIFE) <= 0 then
            call AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", u1, "origin" )
            call DestroyEffect( bj_lastCreatedEffect )
            call UnitDamageTargetBJ( u, u1, d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
        exitwhen u1 == null
        endif
        call GroupRemoveUnit(g,u1)
    endloop
    call AddSpecialEffectLoc( "ThunderclapCasterGreen.mdx", p )
    call DestroyEffect( bj_lastCreatedEffect )
    call RemoveLocation (p)
    call DestroyGroup (g)
    set u = null
    set u1 = null
    set g = null
endfunction

function Trig_Death_Blow_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A01C' then
        call Trig_Death_Blow_Actions()
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Death_Blow_Copy_3 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Death_Blow_Conditions) )
    set t = null
endfunction

Well, I changed it to what you said. There's no errors but when I cast the spell nothing happens. I've made sure the ability ID is the correct one too. So what's wrong now?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
your loop is wrote a little badly:

JASS:
    loop
        set u1 = FirstOfGroup(g)
        if IsUnitType(u1, UNIT_TYPE_GROUND) and IsUnitType(u1, UNIT_TYPE_STRUCTURE) and IsUnitEnemy(u1, GetOwningPlayer(u)) and GetUnitState(u1, UNIT_STATE_LIFE) <= 0 then
            call AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", u1, "origin" )
            call DestroyEffect( bj_lastCreatedEffect )
            call UnitDamageTargetBJ( u, u1, d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
        exitwhen u1 == null
        endif
        call GroupRemoveUnit(g,u1)
    endloop

change it to:

JASS:
    loop
        set u1 = FirstOfGroup(g)
        if IsUnitType(u1, UNIT_TYPE_GROUND) and IsUnitType(u1, UNIT_TYPE_STRUCTURE) and IsUnitEnemy(u1, GetOwningPlayer(u)) and GetUnitState(u1, UNIT_STATE_LIFE) <= 0 then
            call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", u1, "origin" ))
            //you was calling DestroyEffect(bj_lastCreatedEffect), which has no result, because
            //that variable only has last created effect if the BJ is called
            //you can destroy newly created effect tho
            call UnitDamageTargetBJ( u, u1, d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
        endif   //was line after
        exitwhen u1 == null
        call GroupRemoveUnit(g,u1)
    endloop

and you can put some call BJDebugMsg(GetUnitName(u)) into the if block, to see with which unit it runs, when it runs and if it even runs
 
Level 3
Joined
Sep 9, 2009
Messages
658
JASS:
function Trig_Death_Blow_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit u1 = GetSpellTargetUnit()
    local location p = GetUnitLoc(u1)
    local real d = ( 125.00 + ( 75.00 * I2R(GetUnitAbilityLevel(u, 'A01C') ) ))
    local group g = CreateGroup()
    call GroupEnumUnitsInRange(g, GetUnitX(u1), GetUnitY(u1), 300, null)
    loop
        set u1 = FirstOfGroup(g)
        if IsUnitType(u1, UNIT_TYPE_GROUND) and IsUnitType(u1, UNIT_TYPE_STRUCTURE) and IsUnitEnemy(u1, GetOwningPlayer(u)) and GetUnitState(u1, UNIT_STATE_LIFE) <= 0 then
            call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", u1, "origin" ))
            call UnitDamageTargetBJ( u, u1, d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
        endif
        exitwhen u1 == null
        call GroupRemoveUnit(g,u1)
    endloop
    call AddSpecialEffectLoc( "ThunderclapCasterGreen.mdx", p )
    call DestroyEffect( bj_lastCreatedEffect )
    call RemoveLocation (p)
    call DestroyGroup (g)
    set u = null
    set u1 = null
    set g = null
endfunction

function Trig_Death_Blow_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A01C' then
        call Trig_Death_Blow_Actions()
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Death_Blow_Copy_3 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Death_Blow_Conditions) )
    set t = null
endfunction

Well the thunderclapgreen part works now. The FirstofGroup loop still doesn't though even with the changes made.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
u need to change the firstofgroup loop to this.

JASS:
    loop
        set u1 = FirstOfGroup(g)
        if IsUnitType(u1, UNIT_TYPE_GROUND) and IsUnitType(u1, UNIT_TYPE_STRUCTURE) and IsUnitEnemy(u1, GetOwningPlayer(u)) and GetUnitState(u1, UNIT_STATE_LIFE) <= 0 then
            call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", u1, "origin" ))
            call UnitDamageTargetBJ( u, u1, d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
        endif
        exitwhen u1 == null
        call GroupRemoveUnit(g,u1)
    endloop
    
    // It should be like this down below. U were checking if its null at the wrong point
    
    loop
        set u1 = FirstOfGroup(g)
        exitwhen u1 == null
        if IsUnitType(u1, UNIT_TYPE_GROUND) and IsUnitType(u1, UNIT_TYPE_STRUCTURE) and IsUnitEnemy(u1, GetOwningPlayer(u)) and GetUnitState(u1, UNIT_STATE_LIFE) <= 0 then
            call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", u1, "origin" ))
            call UnitDamageTargetBJ( u, u1, d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
        endif
        call GroupRemoveUnit(g,u1)
    endloop

u should also get rid of the BJ that u still use
 
Level 3
Joined
Sep 9, 2009
Messages
658
JASS:
function Trig_Death_Blow_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit u1 = GetSpellTargetUnit()
    local location p = GetUnitLoc(u1)
    local real d = ( 125.00 + ( 75.00 * I2R(GetUnitAbilityLevel(u, 'A01C') ) ))
    local group g = CreateGroup()
    call GroupEnumUnitsInRange(g, GetUnitX(u1), GetUnitY(u1), 300, null)
    loop
        set u1 = FirstOfGroup(g)
        exitwhen u1 == null
        if IsUnitType(u1, UNIT_TYPE_GROUND) and IsUnitType(u1, UNIT_TYPE_STRUCTURE) and IsUnitEnemy(u1, GetOwningPlayer(u)) and GetUnitState(u1, UNIT_STATE_LIFE) <= 0 then
            call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", u1, "origin" ))
            call UnitDamageTargetBJ( u, u1, d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
        endif
        call GroupRemoveUnit(g,u1)
    endloop
    call AddSpecialEffectLoc( "ThunderclapCasterGreen.mdx", p )
    call DestroyEffect( bj_lastCreatedEffect )
    call RemoveLocation (p)
    call DestroyGroup (g)
    set u = null
    set u1 = null
    set g = null
endfunction

function Trig_Death_Blow_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A01C' then
        call Trig_Death_Blow_Actions()
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Death_Blow_Copy_3 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Death_Blow_Conditions) )
    set t = null
endfunction

Well, I tried doing it the way you said. Nothing changed and haha yeah I was planning on getting rid of the BJ after the spell was fixed so I never really got around to doing that.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
and GetUnitState(u1, UNIT_STATE_LIFE) <= 0 then you are checking for units that have lower or equal health to 0, which will not happen most of the time, change it to >= 0.405 if you want to pick units that are alive(this is value at which unit is considered dead)

also checking if unit is ground and structure makes sence? I never saw flying structure in warcraft :D
 
Level 3
Joined
Sep 9, 2009
Messages
658
Thanks you!! It works now! I didn't realize I was picking structures and units with less than 0 life. I'll change the BJ now to UnitDamageTarget. I just have a few more questions. I've read there are times when ForGroup is more preferable than FirstofGroup so if I want to use ForGroup, I have to make more than one action function? One for the core of the spell, one for the group actions and one for the trigger?

The other is for UnitDamageTarget, if it's for a spell, what's the usual values for the attack and range booleans?
 
Status
Not open for further replies.
Top