• 🏆 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!

[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