I need help making a spell that spawns a creep when unit was killed by the spell.

Ostrze

New Member
Reaction score
0
I have most of my spell done, and now i am stuck at point, where after the creep is damaged by the spell, and if it is killed by the spell, there is a new creep spawned for the owner of the casting unit.

Here is what i have done in the spell:
JASS:
function Cond takes nothing returns boolean
    return GetSpellAbilityId() = 'A002'
    endfunction
    
function TurnToDead takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local unit targ = GetSpellTargetUnit()
    local unit dumb
    
    if IsUnitEnemy(targ, GetOwningPlayer(cast)) == true then
        set dumb = CreateUnitAtLoc(GetOwningPlayer(cast), 'h001', GetUnitLoc(targ), 0.00)
        call IssueTargetOrder(dumb, "TurnToDead", targ)
        call UnitApplyTimedLife(dumb, 'BTLF', 0.01)
        call SetUnitState(targ, UNIT_STATE_LIFE, ( GetUnitState(targ, UNIT_STATE_LIFE) - 300))
        set dumb = null
        endif
    set cast = null
    set targ = null
    endfunction
    
function InitTrig_TurnToDead takes nothing returns nothing
    local trigger t
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Cond))
    call TriggerAddAction(t, function TurnToDead)
    endfunction

Can any1 help me with this spell?
 
Q

Quicksho14

Guest
Heyaz i'm still lerning jass as well and i'm defintly not an experet but I do belive this line is incorrect, there should be two = not just one, as with all comparsions when checking to see there equal (you see the same thing in your if statment when checking to see if its equal to true the same applies here just were comparing to see if its the same spell.

JASS:
function Cond takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
    endfunction



As for the rest of the spell i'm sure theres other quick picks but this is the one that stands out the most to me and the major culprute why your trigger isnt doing anything at all. Its a small start but i hope it helps.
 

Romek

Super Moderator
Reaction score
964
JASS:
call IssueTargetOrder(dumb, "TurnToDead", targ)

I doubt that works.

JASS:
set dumb = null

Should be outside the If block.

JASS:
call UnitApplyTimedLife(dumb, 'BTLF', 0.01)

Nothing can cast a spell in 0.01 seconds.. Make that at least 3 seconds.. :p

JASS:
function Cond takes nothing returns boolean
    return GetSpellAbilityId() = 'A002'
endfunction


Should be:

JASS:
function Cond takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction


as Quicksho14 mentioned.
 

Ostrze

New Member
Reaction score
0
Thanks for teling me the leaks, but I still don't know how to make the spell spawn a creep if the target of spell is killed by that spell.
 

Cheesy

some fucker
Reaction score
95
Those aren't leaks, those are fixing your code. :rolleyes:

Do you want to spawn one specific creep, like a skeleton? Or do you want to spawn different units?

EDIT: I can't add the spawning part right now, but this should fix the rest of your code:

JASS:
function Cond takes nothing returns boolean
    return GetSpellAbilityId() == 'A002' //changed '=' to '=='
    endfunction
    
function TurnToDead takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local unit targ = GetSpellTargetUnit()
    local location targpos = GetUnitLoc(targ)
    local unit dumb
    
    if IsUnitEnemy(targ, GetOwningPlayer(cast)) == true then
        set dumb = CreateUnitAtLoc(GetOwningPlayer(cast), 'h001', targpos, 0.00)
        call IssueTargetOrder(dumb, "TurnToDead", targ) //I don't think this will work, what ability did you base "Turn to Dead" off of?
        call UnitApplyTimedLife(dumb, 'BTLF', 3) //No one can cast a spell in 0.01
        call SetUnitState(targ, UNIT_STATE_LIFE, ( GetUnitState(targ, UNIT_STATE_LIFE) - 300))
        endif

    set dumb = null //moved out of the if statement
    set cast = null
    set targ = null

    call RemoveLocation(targpos) //clear the location leak

    endfunction
    
function InitTrig_TurnToDead takes nothing returns nothing
    local trigger t
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Cond))
    call TriggerAddAction(t, function TurnToDead)
    endfunction
 

Ostrze

New Member
Reaction score
0
Hmmm...
I want the creep to be a skeleton (melee) and i want it to have half the life, damage and armor of the killed creep.
About the TurnToDead...after a little thought, i don't realy need it cast the spell, so i can delete this line;
JASS:
call IssueTargetOrder(dumb, "TurnToDead", targ)

The damage is in the code itself:
JASS:

I am using the dummy, cuz i dont know how to call a special effect on unit. I would like it to be the Death Coil spell effect. I am just making the dummy's model the spell effect, so the model of spell appears and then it disappears.

If you can tell me how to call a special effect, i would use it instead of dummy ;]
 
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