• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Spell] Linking two abilities

Status
Not open for further replies.
Level 10
Joined
May 28, 2011
Messages
455
I want to link 2 abilities.
i have first ability that target point. while the second ability cast instantly.
the second ability depend on the first ability point. how can i store the x and y. using hashtable? i dont get the idea how to implement though. Please help me :) Thank you in advance.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
At map initialization, create the hashtable.
Then

  • Custom script: call SaveStr(udg_*hashName*, 'code1', 0, "*order*")
Replace code1 with the raw code of the target point abil, *order* with the instant ability's order string. Press Ctrl + D in object editor to view raw codes.

For example link Blizzard and Divine Shield:
  • Custom script: call SaveStr(udg_*hashName*, 'AHbz', 0, "divineshield")
->
  • Untitled Trigger 006
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blizzard
    • Actions
      • Custom script: call IssueImmediateOrder(GetTriggerUnit(), LoadStr(*hashtable*, GetSpellAbilityId(), 0))
Slightly better than using string would be using integers. You can find out order ids with
  • OrderID
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Custom script: set udg_i = GetIssuedOrderId()
      • Game - Display to Player Group - Player 1 (Red) the text: (String(i))
      • Custom script: call BJDebugMsg(OrderId2String(udg_i))
If you decide to use integers, replace SaveStr with SaveInteger, LoadStr with LoadInteger, and IssueImmediateOrder with IssueImmediateOrderById.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
It is not 100% clear to me what you're trying to do, but here's a very basic script.

JASS:
library Abil initializer InitAbil

    globals
        private constant integer    AID     = 'AHbz'
        private constant string     EFFECT  = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
        private constant real       AOE     =  300
        private constant real       DMG     =  100
        
        private unit U
        private real R
    endglobals
    
    private function Filt takes nothing returns boolean
        local unit u = GetFilterUnit()
        if IsUnitEnemy(u, GetOwningPlayer(U)) then
            call UnitDamageTarget(U, u, DMG, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
        endif
        set u = null
        return false
    endfunction

    private function Cond takes nothing returns boolean
        local real x
        local real y
        if GetSpellAbilityId() == 'AHbz' then
            set U = GetTriggerUnit()
            set x = GetSpellTargetX()
            set y = GetSpellTargetY()
            call DestroyEffect(AddSpecialEffect(EFFECT, x ,y))
            call GroupEnumUnitsInRange(bj_lastCreatedGroup, x ,y, AOE, function Filt)
        endif
        return false
    endfunction

    private function InitAbil takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, function Cond)
        set t = null
    endfunction
    
endlibrary

It doesn't filter dead unit, has no level supports etc.
 
Level 10
Joined
May 28, 2011
Messages
455
ok. i explain the problem.
i have 2 abilities.
1st ability cast target point (like farsight or shockwave)
2nd ability cast instantly. (like warstomp)
Here what i want the trigger do.
after the caster cast the 1st ability. the target point is stored (i dont know how to do this)
then, if the caster cast the 2nd ability, there will be an effect (damage unit in range) of the stored point. if no point is stored. nothing happen. btw, thank you for the basic script. i really appreciate ur help :)
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Well then, store the x and y with SaveReal.

In globals -> private hashtable ht

You can store the x an y using the caster's handle id as parent key.

JASS:
library Abil initializer InitAbil

    globals
        private constant integer    AID1     = 'AHbz' // Blizzard
        private constant integer    AID2     = 'AHds' // Divine Shield
        private constant string     EFFECT  = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
        
        private hashtable ht = InitHashtable()
    endglobals

    private function Cond takes nothing returns boolean
        local integer ID
        local real x
        local real y
        if GetSpellAbilityId() == AID1 then
            set ID = GetHandleId(GetTriggerUnit())
            call SaveReal(ht, ID, 0, GetSpellTargetX())
            call SaveReal(ht, ID, 1, GetSpellTargetY())
        elseif GetSpellAbilityId() == AID2 then
            set ID = GetHandleId(GetTriggerUnit())
            if HaveSavedReal(ht, ID, 0) then
                set x = LoadReal(ht, ID, 0)
                set y = LoadReal(ht, ID, 1)
                call DestroyEffect(AddSpecialEffect(EFFECT, x ,y))
                call FlushChildHashtable(ht, ID)
            endif
        endif
        return false
    endfunction

    private function InitAbil takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, function Cond)
        set t = null
    endfunction
    
endlibrary
 
Level 10
Joined
May 28, 2011
Messages
455
there is another problem now. when i declare my hashtable. the font color remain black unlike all other data type as in it is not recognized. besides, i checked at the function list. no HaveSavedReal >< what should i do? btw, i admire ur script. simple n understandable.
 
Status
Not open for further replies.
Top