• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Aura isn't creating Skeletons on Death

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
I have an aura that when the unit dies, he will create a skeleton. Using BonusMod the Skeletons become scaled to the strength of the dying unit, which is helped determined by SpellStat,GetUnitBounty which I created. (They both work flawlessly)

Anyways, the problem is when the unit dies it refuses to recognize the buffs on them. I've tried making the buff target dead units too and make the buffs scale for level. No luck though.

Any help? Here's the buff rawcodes:

BLP1
BLP2
BLP3
BLP4
BLP5

And here's the aura targeting options:

air,alive,dead,friend,ground,invulnerable,self,vulnerable

The Aura is based off of Unholy Aura, and so are the buffs.

JASS:
scope PresenceOfBL initializer Init

globals
    private integer lvl
endglobals

private function Buff takes unit c returns boolean
    if GetUnitAbilityLevel(c, 'BLP1') > 0 then
        set lvl = 1
        return true
    elseif GetUnitAbilityLevel(c, 'BLP2') > 0 then
        set lvl = 2
        return true
    elseif GetUnitAbilityLevel(c, 'BLP3') > 0 then
        set lvl = 3
        return true
    elseif GetUnitAbilityLevel(c, 'BLP4') > 0 then
        set lvl = 4
        return true
    elseif GetUnitAbilityLevel(c, 'BLP5') > 0 then
        set lvl = 5
        return true
    endif
 return false
endfunction

private function Actions takes unit c, unit d returns nothing
    local real HPBonus = lvl*SpellStat(c,true) + GetUnitState(c, UNIT_STATE_MAX_LIFE)/4
    local real DamageBonus = SpellStat(c, false)/8 + lvl*4
    local real ArmorBonus = GetUnitBonus(c, BONUS_ARMOR)/7 + SpellStat(c,true)/10*lvl
    set d = CreateUnit(GetOwningPlayer(c), 'uske', GetUnitX(c), GetUnitY(c), GetUnitFacing(c))
    call UnitApplyTimedLife(d, 'BLP1', 60)
    call AddUnitBonus(d, BONUS_LIFE, R2I(HPBonus))
    call AddUnitBonus(d, BONUS_DAMAGE, R2I(DamageBonus))
    call AddUnitBonus(d, BONUS_ARMOR, R2I(ArmorBonus))
    call UnitAddType(d, UNIT_TYPE_SUMMONED)
    if GetUnitBounty(c) > 30 then
        call UnitAddAbility(d, 'Cr12')
    endif
    if GetUnitBounty(c) > 90 then
        call AddUnitBonus(d, BONUS_MANA, 150)
        call UnitAddAbility(d, 'SmDo')
    endif
    if GetUnitBounty(c) > 180 then
        call AddUnitBonus(d, BONUS_MANA, 220)
        call UnitAddAbility(d, 'DBol')
    endif
    call AddUnitBonus(GetEnumUnit(), BONUS_MANA_REGEN, 4)
endfunction

private function Conditions takes nothing returns boolean
    if Buff(GetDyingUnit()) then
        call Actions(GetDyingUnit(), null)
    endif
 return true
endfunction

//===========================================================================
public function Init takes nothing returns nothing
 local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, function Conditions )
 set t = null
endfunction

endscope
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Dead units don't have any buffs, Adiktuz is correct. It is too bad that they didn't make the death event run before the unit actually died, like how the damage event detects damage just before it is actually dealt.

From the looks of it this spell has more problems than that; the skeleton is created for the dying unit rather than the bestower of the aura. Is this how it is supposed to be? I would think that the skeletons are created for the source of the aura.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
It really isn't that complicated; what you can do is set up a death event trigger but filter units that are not in a specific, predefined group. This means that you will be able to control which units are aura-"active", and which are not. From there you can easily determine which nearby unit is bestowing the aura, and determine the level of the aura ability on that unit.
 
Level 12
Joined
Aug 22, 2008
Messages
911
2 solutions, I offer:
1. Play with unit groups, add and remove units every now and then from the units under the effect of the aura, and when the unit dies check if it is in the unit group.
2. Add a condition or something that checks if an allied unit with the aura is in range with the dying unit, then create the skeleton.
 
Status
Not open for further replies.
Top