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

Broken Functions?

Status
Not open for further replies.
Level 3
Joined
Sep 10, 2012
Messages
39
:vw_wtf:
Greetings. Over the last couple of weeks I have been attempting to create an inventory system for my campaign. For the most part, I have succeeded. The other day, however, I came across a problem that has me well and truly stumped.

The system works as such: The hero clicks on an item in the inventory, and the item is given to the appropriate inventory unit. When the inventory unit clicks on the item, it is 'equipped' - the item itself is removed while a dummy ability with the icon of the item is given to the inventory unit, and appropriate item abilities are given to the hero.

This actually worked flawlessly for a while. Then, quite suddenly, it didn't. After tinkering with the system I realized that it is no longer detecting when the inventory unit using the item. Even when the trigger has no condition attached. Curiously, when the inventory unit picks up the item on its own, the use of the item is detected. But when it is given an item via trigger, it does not, even if it is the original item that is used.

What so confuses me is that, as I said, it was working perfectly not long before its breakdown. I have uploaded the map, as I don't feel like I can adequately explain things here. If you need additional information, ask and I will post it.

Edit: Based on further testing, the problem occurs when the inventory unit is selected via trigger (interface hero icon is clicked, 'enter inventory' ability is clicked, inventory unit is selected). After that the unit's use of items is no longer detected. Also, if the 'return item to belt' ability is used, the ability button vanishes and the inventory unit's actions are locked and the 'cast' animation is played on loop, as if the unit is channeling something, though I have yet to discern what.
 

Attachments

  • Of Light and Darkness Workshop.w3x
    19.4 MB · Views: 87
Last edited:
It can be a few things.

First the map is huge and anything over 8mb cannot be played in multiplayer.

Your triggers may not be running. Don't set the arrays in the variable editor to more than 1. Only some need to be more than one. Check out my tutorial Things you should know when using triggers / GUI. The section on the variable editor will explain more. Link is in my sig below.

You have a ton of location leaks / unit group leaks / others. Look at the tutorial Things that leak on the triggers and scripts home page.

If you notice in the picture it has some errors those have to be fixed first.
Also when using custom script do not use the BJs. Use the native functions.

After you fix those errors it should work fine.
 

Attachments

  • Capture.PNG
    Capture.PNG
    90.1 KB · Views: 76
Level 3
Joined
Sep 10, 2012
Messages
39
Thank you for your response. Actually, shortly after reading your message, I seemed to have located the problem, at least generally - another trigger that uses the Active Inventory variable appears to cause some sort of conflict. *How* it causes a problem of that sort I have no idea, but replacing the variable used when selecting the inventory unit has so far solved it. It's tentative yet, but my troubles with this may be over.

The trigger errors were functions and triggers that I had disabled/replaced during my debugging process.

I was aware of the leaks ( I am currently planning to fix them at a later time) but I do appreciate the reminder, and I will take a look at your tutorial regarding them and the array variables.

However, I am uncertain of both the difference between BJ's and natives and how one replaces one with the other (my knowledge of JASS is very poor). I would be grateful if you could point me in the direction of something that would explain that.

Regarding the map size, my campaign is intended to be single-player only, unless multiplayer capability is a requirement I was not aware of.
 
BJs are GUI function calls / actions. They call natives. Which are used in Jass thus making GUI slower.

If you have JNGP looking up the natives is rather easy.

This is one of your custom scripts.
call SaveIntegerBJ( 1, 20, 'H009', udg_xxITEMS_xHashtable ) Notice how it has BJ in the name.
This is the native that it calls with the items you use above in the correct order. Note that the order does change for all natives compared to their respective GUI function calls.
call SaveInteger( udg_xxITEMS_xHashtable, 'H009', 20, 1)

For a better understanding of Jass and how it works I suggest you look at my tutorial Converting GUI to efficient JASS
It is meant to teach one how to use Jass through the use of GUI. But it does have how to search for natives in there. ( if using JNGP)

Also no multiplayer capability is not a requirement. I was just informing you in case you did not know about the size limit for multiplayer.
 
Level 3
Joined
Sep 10, 2012
Messages
39
For my purposes, then, it's the same function sans the 'BJ' and with the values in reverse order.

Regarding arrays, assuming there is a point to using arrays besides timer and dialogue for reasons other than neatness, how does one expand them with triggers, if a size greater than 1 does not need to be initialized?
 
arrays are automatically expanded when they need to be. The other arrayed variables that need to be more than one are not for expanding reasons. They are for initialization reasons. Example if you set a unit group variable to 100 it gets initialized at map init. That means that 100 unit groups are created at map init. You can alternatively use Custom script to create the group. Or use Set unit group = to units in region or whatever also initializes that variable.

The reason BJ is not good to use is that it is slower.
It calls the native.
Here is what that BJ does.
JASS:
function SaveIntegerBJ takes integer value, integer key, integer missionKey, hashtable table returns nothing
    call SaveInteger(table, missionKey, key, value)
endfunction
 
Status
Not open for further replies.
Top