• 🏆 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] Oh god! Just cast it!

Status
Not open for further replies.
Level 12
Joined
Mar 23, 2008
Messages
942
I gave my unit a stormbolt based spell, but it don't cast it! I'm trying to use it on two spells of mine:

JASS:
            set dummy = CreateUnit(GetOwningPlayer(i.caster), 'h00E', i.x, i.y, 0)
            call UnitAddAbility(dummy, 'A048')
            call SetUnitAbilityLevel(dummy, 'A048', 4 + GetUnitAbilityLevel(i.caster, 'A04K'))
            call IssueTargetOrderById(dummy, 852095, i.utarget)
            call UnitApplyTimedLife(dummy, 'BTLF', 1.00)

JASS:
        set caster = GetTriggerUnit()
        set dummy = CreateUnit(GetOwningPlayer(caster), 'h00E', x, y, 0)
        call UnitAddAbility(dummy, 'A048')
        call SetUnitAbilityLevel(dummy, 'A048', GetUnitAbilityLevel(caster, 'A04D'))
        call IssueTargetOrderById(dummy, 852095, GetSpellTargetUnit())
        call UnitApplyTimedLife(dummy, 'BTLF', 1.00)

I tried adding the spell to my hero and manually casting it, its working.
 
Level 12
Joined
Mar 23, 2008
Messages
942
Not enough information. What's "i" (i.caster, ...) ? What events are you using? Perhaps there is no SpellTargetUnit, is the order id correct (double checked?)? etc.

JASS:
function Trig_Shakkahou_Conditions takes nothing returns boolean
    local unit dummy
    local unit caster
    local real x
    local real y
    local location target
    
    if ( GetSpellAbilityId() == 'A04B' ) then
        set caster = GetTriggerUnit()
        set target = GetSpellTargetLoc()
        set x = GetUnitX(caster)
        set y = GetUnitY(caster)
        set dummy = CreateUnit(GetOwningPlayer(caster), 'h00E', x, y, 0)
        call UnitAddAbility(dummy, 'A04G')
        call SetUnitAbilityLevel(dummy, 'A04G', GetUnitAbilityLevel(caster, 'A04B'))
        call IssuePointOrderLoc(dummy, "carrionswarm", target)
        call UnitApplyTimedLife(dummy, 'BTLF', 1.00)
        set dummy = null
        set caster = null
        call RemoveLocation(target)
        set target = null
    elseif ( GetSpellAbilityId() == 'A04C' ) then
        set caster = GetTriggerUnit()
        set target = GetSpellTargetLoc()
        set x = GetUnitX(caster)
        set y = GetUnitY(caster)
        set dummy = CreateUnit(GetOwningPlayer(caster), 'h00E', x, y, 0)
        call UnitAddAbility(dummy, 'A046')
        call SetUnitAbilityLevel(dummy, 'A046', GetUnitAbilityLevel(caster, 'A04C'))
        call IssuePointOrderLoc(dummy, "breathoffire", target)
        call UnitApplyTimedLife(dummy, 'BTLF', 1.00)
        set dummy = null
        set caster = null
        call RemoveLocation(target)
        set target = null
    elseif ( GetSpellAbilityId() == 'A04D' ) then
        set caster = GetTriggerUnit()
        set dummy = CreateUnit(GetOwningPlayer(caster), 'h00E', x, y, 0)
        call UnitAddAbility(dummy, 'A048')
        call SetUnitAbilityLevel(dummy, 'A048', GetUnitAbilityLevel(caster, 'A04D'))
        call IssueTargetOrderById(dummy, 852095, GetSpellTargetUnit())
        call UnitApplyTimedLife(dummy, 'BTLF', 1.00)
        set dummy = null
        set caster = null
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Spells_No_Incantation takes nothing returns nothing
    set gg_trg_Spells_No_Incantation = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Spells_No_Incantation, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Spells_No_Incantation, Condition( function Trig_Shakkahou_Conditions ) )
endfunction

JASS:
scope IncantationSpells initializer In_Incantation

globals
    private string array messages[6]
endglobals

private struct INC
    unit caster
    unit utarget
    real x
    real y
    location target
    integer count
endstruct

private function Spells_Inc_Phrases takes nothing returns nothing
    local INC i = GetTimerData(GetExpiredTimer())
    local unit dummy
    
    if (GetUnitCurrentOrder(i.caster) == 852125) or (GetUnitCurrentOrder(i.caster) == 852580) or (GetUnitCurrentOrder(i.caster) == 852095) then
        if i.count == 5 then
            call CreateTextTagUnitBJ(messages[i.count], i.caster, 0, 10, 100, 100, 100, 0 )
            call SetTextTagPermanent( bj_lastCreatedTextTag, false )
            call SetTextTagLifespan( bj_lastCreatedTextTag, 2.00 )
            set dummy = CreateUnit(GetOwningPlayer(i.caster), 'h00E', i.x, i.y, 0)
            call UnitAddAbility(dummy, 'A048')
            call SetUnitAbilityLevel(dummy, 'A048', 4 + GetUnitAbilityLevel(i.caster, 'A04K'))
            call IssueTargetOrderById(dummy, 852095, i.utarget)
            call UnitApplyTimedLife(dummy, 'BTLF', 1.00)
            call ReleaseTimer(GetExpiredTimer())
            call i.destroy()
        elseif i.count == 3 then
            call CreateTextTagUnitBJ(messages[i.count], i.caster, 0, 10, 100, 100, 100, 0 )
            call SetTextTagPermanent( bj_lastCreatedTextTag, false )
            call SetTextTagLifespan( bj_lastCreatedTextTag, 2.00 )
            set dummy = CreateUnit(GetOwningPlayer(i.caster), 'h00E', i.x, i.y, 0)
            call UnitAddAbility(dummy, 'A046')
            call SetUnitAbilityLevel(dummy, 'A046', 5 + GetUnitAbilityLevel(i.caster, 'A04J'))
            call IssuePointOrderLoc(dummy, "breathoffire", i.target)
            call UnitApplyTimedLife(dummy, 'BTLF', 1.00)
            call ReleaseTimer(GetExpiredTimer())
            call i.destroy()
        elseif i.count == 1 then
            call CreateTextTagUnitBJ(messages[i.count], i.caster, 0, 10, 100, 100, 100, 0 )
            call SetTextTagPermanent( bj_lastCreatedTextTag, false )
            call SetTextTagLifespan( bj_lastCreatedTextTag, 2.00 )
            set dummy = CreateUnit(GetOwningPlayer(i.caster), 'h00E', i.x, i.y, 0)
            call UnitAddAbility(dummy, 'A04G')
            call SetUnitAbilityLevel(dummy, 'A04G', 5 + GetUnitAbilityLevel(i.caster, 'A04I'))
            call IssuePointOrderLoc(dummy, "carrionswarm", i.target)
            call UnitApplyTimedLife(dummy, 'BTLF', 1.00)
            call ReleaseTimer(GetExpiredTimer())
            call i.destroy()
        endif
    else
        call CreateTextTagUnitBJ( "fail", i.caster, 0, 10, 100, 100, 100, 0 )
        call SetTextTagPermanent( bj_lastCreatedTextTag, false )
        call SetTextTagLifespan( bj_lastCreatedTextTag, 2.00 )
        call ReleaseTimer(GetExpiredTimer())
        call i.destroy()
    endif
endfunction

private function Spells_Inc_Actions takes nothing returns boolean
    local INC i
    local timer t
    
    if ( GetSpellAbilityId() == 'A04I' ) then
        set i = INC.create()
        set i.caster = GetTriggerUnit()
        set i.target = GetSpellTargetLoc()
        set i.x = GetUnitX(i.caster)
        set i.y = GetUnitY(i.caster)
        call CreateTextTagUnitBJ(messages[0], i.caster, 0, 10, 100, 100, 100, 0 )
        call SetTextTagPermanent( bj_lastCreatedTextTag, false )
        call SetTextTagLifespan( bj_lastCreatedTextTag, 2.00 )
        set i.count = 1
        set t = NewTimer()
        call SetTimerData(t,i)
        call TimerStart(t, 2, false, function Spells_Inc_Phrases)
    elseif ( GetSpellAbilityId() == 'A04J' ) then
        set i = INC.create()
        set i.caster = GetTriggerUnit()
        set i.target = GetSpellTargetLoc()
        set i.x = GetUnitX(i.caster)
        set i.y = GetUnitY(i.caster)
        call CreateTextTagUnitBJ(messages[2], i.caster, 0, 10, 100, 100, 100, 0 )
        call SetTextTagPermanent( bj_lastCreatedTextTag, false )
        call SetTextTagLifespan( bj_lastCreatedTextTag, 2.00 )
        set i.count = 3
        set t = NewTimer()
        call SetTimerData(t,i)
        call TimerStart(t, 2, false, function Spells_Inc_Phrases)
    elseif ( GetSpellAbilityId() == 'A04K' ) then
        set i = INC.create()
        set i.caster = GetTriggerUnit()
        call CreateTextTagUnitBJ(messages[4], i.caster, 0, 10, 100, 100, 100, 0 )
        call SetTextTagPermanent( bj_lastCreatedTextTag, false )
        call SetTextTagLifespan( bj_lastCreatedTextTag, 2.00 )
        set i.count = 5
        set i.utarget = GetSpellTargetUnit()
        set t = NewTimer()
        call SetTimerData(t,i)
        call TimerStart(t, 2, false, function Spells_Inc_Phrases)
    endif
    return false
endfunction

//===========================================================================
private function In_Incantation takes nothing returns nothing
    local trigger t_Spells_Inc = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t_Spells_Inc, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t_Spells_Inc, Condition( function Spells_Inc_Actions ) )
    set t_Spells_Inc = null
    set messages[0] = "Ye lord! Mask of blood and flesh, all creation, flutter of wings, ye who bears the name of Man!"
    set messages[1] = "Inferno and pandemonium, the sea barrier surges, march on to the south!"
    set messages[2] = "Ye lord! Mask of flesh and bone, flutter of wings, ye who bears the name of Man!"
    set messages[3] = "Truth and temperance, upon this sinless wall of dreams unleash but slightly the wrath of your claws"
    set messages[4] = "Carriage of Thunder. Bridge of a spinning wheel"
    set messages[5] = "With light, divide this into six!"
endfunction

endscope

walloftext lolz

The orderid ir correct, the manacost is 0, casttime 0, the dummy cast all the others spell correctly.
 
Level 12
Joined
Mar 23, 2008
Messages
942
Ok, triggers seem to be all right, so what might be happening is that

- target is not in line of sight for dummy
- range is too far

Both seem possible as the dummy is created at i.x and i.y, which is different from the caster position in 2 seconds...

In the first trigger the spell is instant cast...

Edit: Oh damn... was missing:

JASS:
        set x = GetUnitX(caster)
        set y = GetUnitY(caster)
and
JASS:
        set i.x = GetUnitX(i.caster)
        set i.y = GetUnitY(i.caster)

:blush:
 
Status
Not open for further replies.
Top