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

[Solved] Item Un/Equip event with The_Witcher's Equipment System

Status
Not open for further replies.
Level 6
Joined
Jan 8, 2009
Messages
140
I'm not really familiar with jass/vjass events and just in general, what' i'm trying to do is when an item is equipped with The_Witcher's equipment system it then triggers a bag system by IcemanBo to add a bag. It then works in reverse with unequipping. The code is all very simple really I just don't know exactly how to combine the two (mostly the event from the equipment system).

Instructions per The_Witcher

Code:
--------- 4)    Trigger Events    (4 ---------

        function RegisterItemEquipEvent takes code func returns nothing 
        function RegisterItemUnequipEvent takes code func returns nothing
        //use GetTriggeringItemId and GetEquippingUnit to get the involved units

Add code from the bag system (conveniently almost jass anyway i guess haha) I don't actually need the text display, seems like only the AddBag line is needed if there will only ever be a max of 1 bag?

Code:
        Custom script:   local integer i = GetBags(udg_u)
        Custom script:   call AddBag(udg_u, 1)
        Custom script:   if GetBags(udg_u) == i then
        Custom script:   call DisplayTextToForce( GetPlayersAll(), ( "max bags: " + I2S(GetBags(udg_u)) ) )
        Custom script:   else
        Custom script:   call DisplayTextToForce( GetPlayersAll(), ( "bags: " + I2S(GetBags(udg_u)) ) )
        Custom script:   endif

the itemID i'm using for the trigger is the bag I think so: I000
the unit will be: udg_Survivors[player number of triggering player]

so what I need help with is the trigger event in jass for when itemid I000 is equipped as per functionRegisterItemEquipEvent to also run the code from IcemanBo. I could probably do the unequip myself as I figure it's almost identical.

Thanks in advance for any guidance!
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
JASS:
library EquipBag initializer init requires //the libraries
    private function onEquip takes nothing returns nothing
        if GetTriggeringItemId == 'I000' then
            call AddBag(GetEquippingUnit, 1)
        endif
    endfunction

    private function onUnequip takes nothing returns nothing
        if GetTriggeringItemId == 'I000' then
            call AddBag(GetEquippingUnit, 0)
        endif
    endfunction

    private function init takes nothing returns nothing
        call RegisterItemEquipEvent(function onEquip)
        call RegisterItemUnequipEvent(function onUnequip)
    endfunction
endlibrary
 
Level 6
Joined
Jan 8, 2009
Messages
140
I've created a trigger with that code, adding only requires Bag, and i'm getting this error, killing the jasshelper process frees up world edit. any ideas?
GojLrRf.png
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
I have the same problem with the syntax checker in my install. You can close the process and then choose JASSHelper > Show previous errors from the main editor window to show what the syntax error is.

My guess is that you didn't flesh out the requires part. if no requirements, delete the word there, otherwise add the names of the libraries after it separated by commas.
 
Last edited:
Level 6
Joined
Jan 8, 2009
Messages
140
switched to vexorians jasshelper, still same problem in regards to telling me what went wrong, just locks up at found errors. I didn't realise i could find the error report that way so that's helpful, the error is actually on the AddBag() function

GetEquippingUnit seems to input '1' as the value in AddBag(GetEquippingUnit, 1) and the error is cannot convert integer to unit, at least as I understand it...

upload_2016-12-29_18-5-0.png
 
Level 6
Joined
Jan 8, 2009
Messages
140
thanks pyro that fixed that problem but gave rise to one more at the bottom...

these two calls give the error:
Functions passed to Filter or Condition must return boolean

code from the error
Code:
    function EquipBag___init takes nothing returns nothing
        call TriggerAddCondition(AdvancedEquipmentSystem___OnEquip, Filter((function EquipBag___onEquip))) // INLINED!!
        call TriggerAddCondition(AdvancedEquipmentSystem___OnUnequip, Filter((function EquipBag___onUnequip))) // INLINED!!
    endfunction

full code
Code:
library EquipBag initializer init requires Bag
    private function onEquip takes nothing returns nothing
        if GetTriggeringItemId() == 'I000' then
            call AddBag(GetEquippingUnit(), 1)
        endif
    endfunction

    private function onUnequip takes nothing returns nothing
        if GetTriggeringItemId() == 'I000' then
            call AddBag(GetEquippingUnit(), -1)
        endif
    endfunction

    private function init takes nothing returns nothing
        call RegisterItemEquipEvent(function onEquip)
        call RegisterItemUnequipEvent(function onUnequip)
    endfunction
endlibrary
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
You can use JASS tags for syntax highlighting rather than generic CODE tags. Documentation also fails to note that any functions registered for equip events are added as trigger conditions rather than actions and thus must return booleans. I don't know if returning true/false changes how the system works in any way but from a cursory look it just calls TriggerEvaluate(...) but doesn't actually use its return value for anything.
JASS:
library EquipBag initializer init requires Bag
    private function onEquip takes nothing returns boolean
        if GetTriggeringItemId() == 'I000' then
            call AddBag(GetEquippingUnit(), 1)
        endif
        return false
    endfunction

    private function onUnequip takes nothing returns boolean
        if GetTriggeringItemId() == 'I000' then
            call AddBag(GetEquippingUnit(), -1)
        endif
        return false
    endfunction

    private function init takes nothing returns nothing
        call RegisterItemEquipEvent(function onEquip)
        call RegisterItemUnequipEvent(function onUnequip)
    endfunction
endlibrary

You sure it should be -1 in the AddBag call to remove the bag, not 0?
 
Level 6
Joined
Jan 8, 2009
Messages
140
ahh i thought I went mad I haven't really used the forums since before the update, [gui] didn't work and i couldn't find anywhere for it so i figured code tags replaced everything.

yep, definitely -1 as per Iceman's demo triggers, and it works!! thankyou so much for guiding me through this pyro.
 
Status
Not open for further replies.
Top