Why doesn't it make a dummy unit?

Evan1993

Ultra Cool Member
Reaction score
30
Here's my code..
Code:
function Trig_Spell_Mirror_Conditions takes nothing returns boolean
    return GetUnitAbilityLevelSwapped('A007', GetSpellTargetUnit()) > 0
endfunction

function Trig_Spell_Mirror_Actions takes nothing returns nothing
    local unit Target = GetSpellTargetUnit()
    local unit Caster = GetSpellAbilityUnit()
    local unit Dummy = GetLastCreatedUnit()
    local integer ID =  GetSpellAbilityId()
    
    if GetRandomInt(1, 100) <= ( 10 * GetUnitAbilityLevelSwapped('A007', Target) ) then
        call UnitAddAbilityBJ( 'A008', Target )
        call CreateNUnitsAtLoc( 1, 'hpb1', GetOwningPlayer(Target), GetUnitLoc(Target), bj_UNIT_FACING )//make dummyunit
        set Dummy = GetLastCreatedUnit()
        call UnitAddAbilityBJ(ID, Dummy )
        call SetUnitAbilityLevelSwapped(  ID, Dummy, GetUnitAbilityLevelSwapped(ID, Caster) )
        call IssueTargetOrderById(Dummy, ID, Caster)
        call UnitApplyTimedLifeBJ( 2.00, 'BTLF', Dummy )
        call DisplayTextToForce( GetPlayersAll(), I2S(ID) )
        call DisplayTextToForce( GetPlayersAll(), GetUnitName(GetLastCreatedUnit()) )
    endif
endfunction

//===========================================================================
function InitTrig_Spell_Mirror takes nothing returns nothing
    set gg_trg_Spell_Mirror = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Spell_Mirror, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Spell_Mirror, Condition( function Trig_Spell_Mirror_Conditions ) )
    call TriggerAddAction( gg_trg_Spell_Mirror, function Trig_Spell_Mirror_Actions )
endfunction
 

Joker(Div)

Always Here..
Reaction score
86
JASS:
function Trig_Spell_Mirror_Conditions takes nothing returns boolean
    return GetUnitAbilityLevelSwapped(&#039;A007&#039;, GetSpellTargetUnit()) &gt; 0
endfunction

function Trig_Spell_Mirror_Actions takes nothing returns nothing
    local unit Target = GetSpellTargetUnit()
    local unit Caster = GetSpellAbilityUnit()
    local unit Dummy
    local integer ID =  GetSpellAbilityId()
    
    if GetRandomInt(1, 100) &lt;= 10 * GetUnitAbilityLevel(Target, &#039;A007&#039;) then
        call UnitAddAbility( Target, &#039;A008&#039; )
        set Dummy = CreateUnit( GetOwningPlayer(Target),&#039;hpb1&#039;, GetUnitX(Target), GetUnitY(Target), bj_UNIT_FACING )//make dummyunit
        call UnitAddAbility(Dummy, ID)
        call SetUnitAbilityLevel(Dummy, ID, GetUnitAbilityLevel(Caster, ID) )
        call IssueTargetOrderById(Dummy, ID, Caster)
        call UnitApplyTimedLifeBJ( Dummy, &#039;BTLF&#039;, 2 )
        call DisplayTextToForce( GetPlayersAll(), I2S(ID) )
        call DisplayTextToForce( GetPlayersAll(), GetUnitName(Dummy) )
    endif
    
    set Target = null
    set Caster = null
    set Dummy = null
endfunction

//===========================================================================
function InitTrig_Spell_Mirror takes nothing returns nothing
    set gg_trg_Spell_Mirror = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Spell_Mirror, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Spell_Mirror, Condition( function Trig_Spell_Mirror_Conditions ) )
    call TriggerAddAction( gg_trg_Spell_Mirror, function Trig_Spell_Mirror_Actions )
endfunction

Try this. I got rid of a few leaks and BJ's. Are you wanting to create a dummy unit for the target unit and order it to target the caster? Also, are you aware that you only have a 10/20/30...% of creating a dummy?
 

Arkan

Nobody rides for free
Reaction score
92
Instead, use set dummy = CreateUnit(Player(p),'hfoo',x,y,0)
 

substance

New Member
Reaction score
34
Make sure the dummy unit has mana.

Are you trying to make the dummy unit cast the same spell thta is being cast? that doesnt make sense. And whats up with this:
JASS:
    return GetUnitAbilityLevelSwapped(&#039;A007&#039;, GetSpellTargetUnit()) &gt; 0
your checking if the level of the casted ability is greater than one? if he didnt have the ability then how would it be cast?

You've still got some BJ function in there too. You should tell us what exactly is supposed to happen when this spell is cast.
 

Evan1993

Ultra Cool Member
Reaction score
30
Any unit with the ability 'A007' is supposed to have a % chance to have a spell not hurt him, and bounce back at an enemy. Right now, the spell doesn’t hurt, and the dummy gets the ability (at the right level too) but just doesn’t cast it.

JASS:
function Trig_Spell_Mirror_Conditions takes nothing returns boolean
    return GetUnitAbilityLevelSwapped(&#039;A007&#039;, GetSpellTargetUnit()) &gt; 0 //make sure the unit has the repel ability  
endfunction

function Trig_Spell_Mirror_Actions takes nothing returns nothing
    local unit Target = GetSpellTargetUnit()
    local unit Caster = GetSpellAbilityUnit()
    local unit Dummy
    local integer ID =  GetSpellAbilityId()
    
    if GetRandomInt(1, 100) &lt;= 10 * GetUnitAbilityLevel(Target, &#039;A007&#039;) then// 10% chance per level
        call UnitAddAbility( Target, &#039;A008&#039; )	// add spell shield to block spell(it gets removed by another trigger) 
        set Dummy = CreateUnit( GetOwningPlayer(Target),&#039;hsor&#039;, GetUnitX(Target), GetUnitY(Target), bj_UNIT_FACING )//make dummyunit
        call UnitAddAbility(Dummy, ID) // add whatever spell was cast on the unit with repel
        call SetUnitAbilityLevel(Dummy, ID, GetUnitAbilityLevel(Caster, ID) ) //set it to the same level
        call IssueTargetOrderById(Dummy, ID, Caster)// cast it..
        call UnitApplyTimedLife( Dummy, &#039;BTLF&#039;, 2 ) // get rid of dummy
        call DisplayTextToForce( GetPlayersAll(), I2S(ID) )
        call DisplayTextToForce( GetPlayersAll(), GetUnitName(Dummy) )
    endif
    
    set Target = null//cleanup
    set Caster = null
    set Dummy = null
endfunction

//===========================================================================
function InitTrig_Spell_Mirror takes nothing returns nothing
    set gg_trg_Spell_Mirror = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Spell_Mirror, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Spell_Mirror, Condition( function Trig_Spell_Mirror_Conditions ) )
    call TriggerAddAction( gg_trg_Spell_Mirror, function Trig_Spell_Mirror_Actions )
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top