Problem with dummy units

bane25

New Member
Reaction score
1
I am making a skill that deals damage based on current mana, and after you cast it, a dummy unit casts a regeneration skill on the caster.
JASS:
function Trig_ManaCoil_Conditions takes nothing returns boolean
if GetSpellAbilityId() == 'A0H5' then
return true
endif
return false
endfunction

function ManaCoilCheck takes nothing returns boolean
local unit u = GetTriggerUnit()
local unit u2 = GetFilterUnit()
local player p = GetOwningPlayer(u)
if IsUnitAlly(u2, p) == false and IsUnitAliveBJ(u2) == true and IsUnitType(u2, UNIT_TYPE_STRUCTURE) == false then
set u = null
set u2 = null
set p = null
return true
endif
set u = null
set u2 = null
set p = null
return false 
endfunction

function ManaCoil takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit u2 = GetEnumUnit()
local real d = 10 * GetUnitState(u, UNIT_STATE_MANA)
call UnitDamageTargetBJ( u, u2, d, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
call AddSpecialEffectTargetUnitBJ( "origin", u2, "Objects\\Spawnmodels\\NightElf\\NEDeathSmall\\NEDeathSmall.mdl" )
set u = null
set u2 = null
endfunction

function Trig_ManaCoil_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local location l = GetSpellTargetLoc()
local location l2 = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocMatching(120.00, l, Condition(function ManaCoilCheck))
local player p = GetOwningPlayer(u)
call ForGroupBJ(g,function ManaCoil)
call CreateUnitAtLoc( p, 'n027', l2, bj_UNIT_FACING )
call UnitAddAbilityBJ( 'A0H6', GetLastCreatedUnit() )
call IssueTargetOrderBJ( GetLastCreatedUnit(), "rejuvination", u )
call UnitApplyTimedLifeBJ( 5.00, 'BTLF', GetLastCreatedUnit() )
call RemoveLocation(l)
call RemoveLocation(l2)
call DestroyGroup(g)
set u = null
set l = null
set l2 = null
set g = null
set p = null
endfunction

//===========================================================================
function InitTrig_ManaCoil takes nothing returns nothing
    set gg_trg_ManaCoil = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(1), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(2), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(3), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(4), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(5), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(6), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(7), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(8), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_ManaCoil, Player(9), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_ManaCoil, Condition( function Trig_ManaCoil_Conditions ) )
    call TriggerAddAction( gg_trg_ManaCoil, function Trig_ManaCoil_Actions )
endfunction


However, the dummy units are created but do nothing. What could be the problem?
 

bane25

New Member
Reaction score
1
No, it doesn't require a tech upgrade. Afaik, regeneration doesn't require a tech upgrade anyway. Its bear form that does.
 

bane25

New Member
Reaction score
1
In other words you are saying that I need a variable for the dummy unit? I'll try it.
 

Jesus4Lyf

Good Idea™
Reaction score
397
In other words you are saying that I need a variable for the dummy unit? I'll try it.
Actually, I'm saying literally replace that line, exactly as I showed you. The BJ just returns a variable. Every CreateUnitBJ basically sets that variable. So since you are using the native, it does not work.

- Unless you set that variable manually. :)
(That variable is bj_lastCreatedUnit.)
(Of course using a variable will then work the same way.)
 

bane25

New Member
Reaction score
1
Screw the BJ's...

I just used udg and everything worked perfectly.
A lesson on why not to try something new.
The problem was that GetLastCreatedUnit() just doesn't work, so replace it with any variable and it works fine.
 

millz-

New Member
Reaction score
25
Jesus4Lyf clearly explained why it did not work o_O. GetLastCreatedUnit() function returns bj_lastCreatedUnit, which was only set if you used BJ function to create the units as well, unless you manually set it (also shown by Jesus4Lyf).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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