• 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.

[vJASS] Inventory System (Kricz) Modification

Status
Not open for further replies.
Level 3
Joined
Feb 24, 2007
Messages
23
Hello guys,

I'm using this Inventory System and I was wondering if it would be possible to open the Equipment Windows by casting an Ability. The only problem is that I'm not an expert in vJass, so I could need some help.
I found two parts in the script that might be relevant to my problem:

JASS:
private static method onInit takes nothing returns nothing
        call TriggerAddCondition(.Use, Condition(function Inventory.useItem))
        call TriggerAddCondition(.Pickup, Condition(function Inventory.pickupItem))

I thought that it might be necessary to add another condition, something like .Cast maybe? (But I'm not sure).

To open the Inventory when the right ability is cast, I copied and modified the useItem-Code:

JASS:
private static method castAbility takes nothing returns boolean   
        local Inventory this = .table[GetTriggerUnit()]
        if (GetSpellAbilityId() == 'MyAbility') then
            return .openInventory(GetTriggerUnit())
        endif
        return false
    endmethod

So how can I include this code in the system or is the code even right?
 
Level 4
Joined
Mar 27, 2008
Messages
112
Well you could do something like this:
JASS:
scope openInventory initializer init
private function actions takes nothing returns boolean
local Inventory i = Inventory.table[GetTriggerUnit()]
  if GetSpellAbilityId() == 'A000' then //change A000 to your ability rawcode
     call i.openInventory(GetTriggerUnit())
  endif
return false
endfunction

private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function actions))
endfunction
endscope
Note this is hand written so there might be some small errors
 
Status
Not open for further replies.
Top