• 🏆 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 Help - Buying Abilities System

Status
Not open for further replies.
Level 1
Joined
Jun 18, 2012
Messages
4
I'm trying to create a Buying Abilities System. Unique for each hero, but I don't know how. Please, help me. :S

Triggers :
  • learnability
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Powerup
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempItem = (Item being manipulated)
      • For each (Integer A) from 0 to ItemAbilityCount, do (Actions)
        • Loop - Actions
          • Set TempInt = (Integer A)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Items[TempInt] Equal to (Item-type of TempItem)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Abilities[TempInt] for TempUnit) Less than 1
                • Then - Actions
                  • Unit - Add Abilities[TempInt] to TempUnit
                  • Set TempForce = (Player group((Owner of TempUnit)))
                  • Game - Display to TempForce the text: Parabéns, você ap...
                  • Item - Remove TempItem
                  • Custom script: call DestroyForce( udg_TempForce )
                  • Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Items\Alam\AlemTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: exitwhen true
                • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Level[TempInt] Greater than 1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Abilities[TempInt] for TempUnit) Less than Level[TempInt]
                • Then - Actions
                  • Unit - Increase level of Abilities[TempInt] for TempUnit
                  • Set TempForce = (Player group((Owner of TempUnit)))
                  • Game - Display to TempForce for 5.00 seconds the text: Você acaba de evol...
                  • Item - Remove TempItem
                  • Custom script: call DestroyForce( udg_TempForce )
                  • Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Items\Alam\AlemTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: exitwhen true
                • Else - Actions
                  • Set TempForce = (Player group((Owner of TempUnit)))
                  • Game - Display to TempForce for 5.00 seconds the text: Esta habilidade já...
                  • Item - Remove TempItem
                  • Custom script: call DestroyForce( udg_TempForce )
                  • Player - Add Lumber[(Integer A)] to (Owner of TempUnit) Current lumber
              • Skip remaining actions
            • Else - Actions
              • Set TempForce = (Player group((Owner of TempUnit)))
              • Game - Display to TempForce for 5.00 seconds the text: Esta habilidade já...
              • Item - Remove TempItem
              • Custom script: call DestroyForce(udg_TempForce )
              • Player - Add Lumber[TempInt] to (Owner of TempUnit) Current lumber
and

  • setvariables1
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set ItemAbilityCount = -1
      • -------- SpellPunch! --------
      • Set ItemAbilityCount = (ItemAbilityCount + 1)
      • Set Abilities[ItemAbilityCount] = Punch!
      • Set Items[ItemAbilityCount] = Punch!
      • Set Lumber[ItemAbilityCount] = 1
      • Set Level[ItemAbilityCount] = 10
      • -------- --------
Thanks !
 
Set ability max level to 1 then :)
JASS:
set ItemId = 'I000' //FOR ITEM -> 'I000'
call SaveInteger(udg_KSHash, ItemId,  0,    0  ) //Required Agility
call SaveInteger(udg_KSHash, ItemId,  1,   40  ) //Required Intelligence
call SaveInteger(udg_KSHash, ItemId,  2,    0  ) //Required Strength
call SaveInteger(udg_KSHash, ItemId,  3,    0  ) //Required Level
call SaveInteger(udg_KSHash, ItemId,  4,    1  ) //Ability Max Level <- Here
call SaveInteger(udg_KSHash, ItemId,  5,    0  ) //Item Gold Cost
call SaveInteger(udg_KSHash, ItemId,  6,    2  ) //Item Lumber Cost
call SaveInteger(udg_KSHash, ItemId,  7, 'A000') //Ability Id
 
This one should work flawlessly, also I added a lot of API functions.
You can use them in GUI easily just like mckill2009 did in his example :)

JASS:
library ItemFilterLib initializer Init

    globals
        private hashtable hash = InitHashtable()
        private boolean array enable_system
    endglobals
    
    function DisableItemFilter takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen i>12
            set enable_system[i] = false
            set i=i+1
        endloop
    endfunction
    
    function DisableItemFilterForPlayer takes player p returns nothing
        set enable_system[GetPlayerId(p)] = false
    endfunction
    
    function DisableItemFilterForPlayerId takes integer id returns nothing
        set enable_system[id] = false
    endfunction
    
    function EnableItemFilter takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen i>12
            set enable_system[i] = true
            set i=i+1
        endloop
    endfunction
    
    function EnableItemFilterForPlayer takes player p returns nothing
        set enable_system[GetPlayerId(p)] = true
    endfunction
    
    function EnableItemFilterForPlayerId takes integer id returns nothing
        set enable_system[id] = true
    endfunction
    
    function AddItem takes item it returns nothing
        call SaveBoolean(hash, GetHandleId(it), -1, true)
    endfunction
    
    function AddItemForUnit takes item it, unit u returns nothing
        call SaveBoolean(hash, GetHandleId(u), GetHandleId(it), true)
    endfunction

    function FlushItem takes item it returns nothing
        call SaveBoolean(hash, GetHandleId(it), -1, false)
    endfunction
    
    function FlushItemForUnit takes item it, unit u returns nothing
        call SaveBoolean(hash, GetHandleId(u), GetHandleId(it), false)
    endfunction
    
    function Run takes nothing returns nothing
        if enable_system[GetPlayerId(GetTriggerPlayer())] then
        
            if LoadBoolean(hash, GetHandleId(GetTriggerUnit()), GetHandleId(GetManipulatedItem())) then
                call UnitRemoveItem(GetTriggerUnit(), GetManipulatedItem())
                call BJDebugMsg("Can't carry item with ID: " + I2S(GetHandleId(GetManipulatedItem())))
                return
            endif
            
            if LoadBoolean(hash, GetHandleId(GetManipulatedItem()), -1) then
                call UnitRemoveItem(GetTriggerUnit(), GetManipulatedItem())
                call BJDebugMsg("Disabled item with ID: " + I2S(GetHandleId(GetManipulatedItem())))
            endif
            
        endif
    endfunction
    
    private function RegisterItems takes nothing returns nothing
        call AddItem(CreateItem('afac', 0,0))
        call CreateItem('afac', 100,0)
        call CreateItem('afac', 110,0)
        call AddItem(CreateItem('spsh', 0,0))
        
        call AddItemForUnit(gg_item_ajen_0006, gg_unit_Hamg_0002)
        call AddItemForUnit(gg_item_bgst_0007, gg_unit_Hamg_0002)
        
        call EnableItemFilterForPlayer(Player(0))
    endfunction
    
    function Init takes nothing returns nothing
        local integer i = 0
        local trigger system_trig = CreateTrigger()
        loop
            exitwhen i > 12
            call TriggerRegisterPlayerUnitEvent(system_trig, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, null)
            set enable_system[i] = true
            set i = i+1
        endloop
        call TriggerAddAction(system_trig, function Run )
        set system_trig = null
        
        call DisableItemFilter()
        call RegisterItems()
    endfunction
endlibrary
 

Attachments

  • ItemFilter.w3x
    24.8 KB · Views: 50
Status
Not open for further replies.
Top