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

Item Events

Status
Not open for further replies.
Level 11
Joined
Mar 18, 2009
Messages
788
So;

I need an event (or similar) to notice if an item is removed or destroyed, in GUI.

I found the pawns an item to shop event but I still need the other two for my trigger to function.

Rep guaranteed to helpful replies that solves the problem :)
 
Level 11
Joined
Jul 9, 2009
Messages
927
I can help you, what do you mean?
Is it >> A unit has an item then he dropped it and destroyed it and then a text message will come out of the screen with the player's name destroyed the name of the item example
"EloTheMan destroyed boots of speed"
 
Level 11
Joined
Jul 9, 2009
Messages
927
Can you give a situation so that I can see if I can make it :)
Edit :
Do you add effects on the item by Trigger or by Object Editor ? and what do you mean by clear all item data attached to it ?
 
Level 11
Joined
Mar 18, 2009
Messages
788
Can you give a situation so that I can see if I can make it :)

Event:
An item is destroyed/removed

Actions:
Clear all parent and child hashtables in EXAMPLE'HASHTABLE for triggering Item


I was going to use a trigger copy for the action from WE but i forgot were i could find that function xD

but anyway its the event that is the main problem.
 
Level 11
Joined
Jul 9, 2009
Messages
927
it can still work though, but you have to trigger it so that it wont be abused
  • Destroy Item
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Item-type of (Target item of issued order)) Equal to Tome of Experience
    • Actions
      • Item - Remove (Target item of issued order)
      • Game - Display to (All players) the text: EloTheMan Destroyed...
then just put special effects for it not to look like triggered.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You want to clear hashtable saved data for that item when it is removed/destroyed ?

It seems like you have 2 different Events; one is Remove, another is Destroy

Now I understand removing item a unit...
What I do not understand is, what do you mean by "destroy" an item ?
Is it like, you attack the item until it disappears ?
Or, what ?
 
Level 11
Joined
Mar 18, 2009
Messages
788
As far as I know an item can disappear from the map in 3 ways; 1 when its sold to a shop 2 when it is removed by an trigger and 3 when it is destroyed (by a unit thru attack or spells)

There is already an event for selling it to a shop (pawned) but I still need the other two especially since removed is pretty common.

By destroyed I mean by a Unit who for example attacks it.
 
You can set given items to item array variables.
Add a loop trigger which enumerates through indexes and checks if:
  • Custom script: if GetWidgetLife(udg_item[udg_indexHere]) < 0.401 or udg_item[udg_indexhere] == null then
  • // clear data/whatever
  • Custom script: endif
You can also use some index recycling; so the trigger won't enumerate empty indexes.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Make a custom event.

Whenever you call to remove the item you run the trigger (custom remove item call).

Be aware that killing an item by attacking it just sets its dead flag and does not actually remove the item (it stays there all game until a trigger removes it).

Thus you have 3 real systems needed.
1. A custom remove item function for removing items and running cleanup code.
2. A trigger that responds to item pawning.
3. A trigger that responds to item deathsby removing the item (using system 1).
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
So why GUI? In Jass, there is
native TriggerRegisterDeathEvent takes trigger whichTrigger, widget whichWidget returns event
When applied on an item, it triggers both when it is killed or removed (second only in case the item is alive).

constant native GetTriggerWidget takes nothing returns widget
returns the widget in question. If you need it as an item, you would have to save the item under its handle id like
call SaveItemHandle(<hashtable>, GetHandleId(<item>), 0, <item>)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Yes and I am asking why TC wants it in GUI. Sometimes, people see an obstacle others know a solution for and can convince him/her to take it (with further instructions). The standard reason is that they have never used Jass and are therefore inexperienced/unsure. I just shew that this special case requires little of the unknown. More can be described.

"I am in need of a calculator." "What do you need it for?" "To solve this exercise." "But you could easily do it with written simplification this way..."

Btw, you did include some jass lines yourself.
 
Level 11
Joined
Mar 18, 2009
Messages
788
You can set given items to item array variables.
Add a loop trigger which enumerates through indexes and checks if:
  • Custom script: if GetWidgetLife(udg_item[udg_indexHere]) < 0.401 or udg_item[udg_indexhere] == null then
  • // clear data/whatever
  • Custom script: endif
You can also use some index recycling; so the trigger won't enumerate empty indexes.

Ok... so il basically add all the specific items to a arrayed variabel, then i create a new trigger that is looping and contains these actions.

My scripting is sorta bad, which parts in the first action am I going to change?


So why GUI? In Jass, there is
native TriggerRegisterDeathEvent takes trigger whichTrigger, widget whichWidget returns event
When applied on an item, it triggers both when it is killed or removed (second only in case the item is alive).

constant native GetTriggerWidget takes nothing returns widget
returns the widget in question. If you need it as an item, you would have to save the item under its handle id like
call SaveItemHandle(<hashtable>, GetHandleId(<item>), 0, <item>)

As I wrote above, my scripting knowledge is like 0.1 on a scale of 50 so if this was to be made in JASS, then you would have to create all of it and configure it to fit in as well as write a manual in case I would need to change anything.

But il keep your reply in mind if I would start to learn JASS someday, and then remake the trigger.

EDIT: I know GUI has some limits which are hard to break and all but I don't simply have time to learn JASS right now, GUI is more of a way to keep this community alive and open for new users.
 
Last edited:
Status
Not open for further replies.
Top