• 🏆 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!

[Trigger] Pestilence

Status
Not open for further replies.
Level 1
Joined
Sep 8, 2008
Messages
12
JASS:
function P_ValidTarget takes unit t returns boolean
    if IsUnitEnemy(t, GetOwningPlayer(GetSpellAbilityUnit())) == true then
        return true
    endif
    if GetOwningPlayer(t) == Player(PLAYER_NEUTRAL_AGGRESSIVE) then
        return true
    elseif GetOwningPlayer(t) == Player(bj_PLAYER_NEUTRAL_VICTIM) then
        return true
    elseif GetOwningPlayer(t) == Player(bj_PLAYER_NEUTRAL_EXTRA) then
        return true
    elseif GetOwningPlayer(t) == Player(PLAYER_NEUTRAL_PASSIVE) then
        return true
    endif
    return false
endfunction

function P_Actions takes nothing returns nothing
    local unit target = GetSpellTargetUnit()
    local unit u
    local unit FrostCaster
    local unit BloodCaster
    local player p = GetOwningPlayer(GetSpellAbilityUnit())
    local boolean HasFrost = (GetUnitAbilityLevel(target, 'B003') > 0)
    local boolean HasBlood = (GetUnitAbilityLevel(target, 'B005') > 0)
    local group g = CreateGroup()
    call GroupEnumUnitsInRangeOfLoc(g, GetUnitLoc(target), 150.0, null)
    if HasFrost or HasBlood then
        loop
            set u = FirstOfGroup(g)
            exitwhen u == null
            if P_ValidTarget(u) then
                if HasFrost then
                    set FrostCaster = CreateUnitAtLoc(p, 'n002', GetUnitLoc(u), 270.0)
                    call ShowUnit(FrostCaster, false)
                    call IssueTargetOrder(FrostCaster, "frostnova", u)
                    call UnitApplyTimedLife(FrostCaster, 'BTLF', 3.0)
                endif
                if HasBlood then
                    set BloodCaster = CreateUnitAtLoc(p, 'n002', GetUnitLoc(u), 270.0)
                    call ShowUnit(BloodCaster, false)
                    call IssueTargetOrder(BloodCaster, "acidbomb", u)
                    call UnitApplyTimedLife(BloodCaster, 'BTLF', 3.0)
                endif
            endif
            call GroupRemoveUnit(g, u)
        endloop
    endif
endfunction

function P_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00L'
endfunction

//===========================================================================
function InitTrig_Pestilence takes nothing returns nothing
    local trigger P = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( P, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( P, Condition(function P_Conditions) )
    call TriggerAddAction( P, function P_Actions )
    set P = null
endfunction

I'm trying to emulate the Pestilence ability of Death Knight from WoW. 'B003' is Frost Fever buff, 'B005' is Blood Plague buff - those two we need to spread in a 150 AoE of the target of the spell.

'A00L' is the ability Pestilence, and 'n002' is a dummy caster unit that has 0 cost 0 cooldown abilities that will place the buffs needed.

Now for some reason, the expiration timer applies to the caster of Pestilence, not to the dummy. What am I doing wrong?
 
Level 1
Joined
Sep 8, 2008
Messages
12
Okay, tried to simplify and fix it myself and I seem to have ran into a wall.

Although dummy caster has the proper abilities, and their order id are 'frostnova' or 'acidbomb', IssueTargetOrder doesn't do anything (that said, everything else is working - dummies are created, hidden and expire properly).

Any thoughts on why would not IssueTargetOrder work?
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
Try creating the dummy with a model for the owner of casting unit, and see if you (as a player) can select the dummy and cast the order manually.

That should prove to you whether or not your target types are configured properly in the object editor.

One other thing. You should use CreateUnit(), GetUnitX(), and GetUnitY(). Locations are bad.
 
Level 1
Joined
Sep 8, 2008
Messages
12
Went and try to cast manually - everything is working, dummies are even created in the correct position.

Changed a bit - removed the abilities from dummy's default roster and made them appear only if conditions are met. Again, manually they are added and can be cast, but IssueTargetOrder is not working.
 
Level 1
Joined
Sep 8, 2008
Messages
12
Tried ordering the Dummies using the default OrderId for the dummy abilities leaving custom-specified OrderIds in the abilities data.

For some reason, it worked. Does that mean that IssueTargetOrder does not recognize custom-specified OrderId, then?
 
Level 1
Joined
Sep 8, 2008
Messages
12
Cripple and Slow.

Now I have uncovered yet another problem - the spell would only spread one buff at a time, but not both.

JASS:
function P_Actions takes nothing returns nothing
    local unit target = GetSpellTargetUnit()
    local unit u
    local unit FrostCaster
    local unit BloodCaster
    local real x
    local real y
    local player p = GetOwningPlayer(GetSpellAbilityUnit())
    local boolean HasFrost = (GetUnitAbilityLevel(target, 'B003') > 0)
    local boolean HasBlood = (GetUnitAbilityLevel(target, 'B005') > 0)
    local group g = CreateGroup()
    call GroupEnumUnitsInRangeOfLoc(g, GetUnitLoc(target), 600.0, null)
    call GroupRemoveUnit(g, target)
    if HasFrost or HasBlood then
        loop
            set u = FirstOfGroup(g)
            exitwhen u == null
            if IsUnitEnemy(u, p) or GetOwningPlayer(u) == Player(15) then
                if HasFrost then
                    set x = GetUnitX(u)
                    set y = GetUnitY(u)
                    set FrostCaster = CreateUnit(p, 'n002', x, y, 270.0)
                    call UnitAddAbility(FrostCaster, 'S002')
                    call ShowUnit(FrostCaster, false)
                    call IssueTargetOrder(FrostCaster, "cripple", u)
                    call UnitApplyTimedLife(FrostCaster, 'BTLF', 3.0)
                    set FrostCaster = null
                    call FrostFever(GetSpellAbilityUnit(), u)
                endif
                if HasBlood then
                    set x = GetUnitX(u)
                    set y = GetUnitY(u)
                    set BloodCaster = CreateUnit(p, 'n002', x, y, 270.0)
                    call UnitAddAbility(BloodCaster, 'A00Q')
                    call ShowUnit(BloodCaster, false)
                    call IssueTargetOrder(BloodCaster, "slow", u)
                    call UnitApplyTimedLife(BloodCaster, 'BTLF', 3.0)
                    set BloodCaster = null
                    call BloodPlague(GetSpellAbilityUnit(), u)
                endif                
            endif
            call GroupRemoveUnit(g, u)
        endloop
    endif
endfunction

function P_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00L'
endfunction

//===========================================================================
function InitTrig_Pestilence takes nothing returns nothing
    local trigger P = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( P, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( P, Condition(function P_Conditions) )
    call TriggerAddAction( P, function P_Actions )
    set P = null
endfunction
 
Status
Not open for further replies.
Top