1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. The results are out! Check them out.
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Oh god! Just cast it!

Discussion in 'Triggers & Scripts' started by Saishy, Feb 5, 2009.

  1. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    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:

    Code (vJASS):

                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)
     


    Code (vJASS):
            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.
     
  2. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    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.
     
  3. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    Code (vJASS):
    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
     


    Code (vJASS):
    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.
     
  4. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    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...
     
  5. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    In the first trigger the spell is instant cast...

    Edit: Oh damn... was missing:

    Code (vJASS):
            set x = GetUnitX(caster)
            set y = GetUnitY(caster)

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


    :blush:
     
  6. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    In the first trigger, x and y aren't even initialized.

    I guess that's the problem?
     
  7. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    but... I told you that this was the problem...

    ???
     
  8. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    I was only confirming...