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

How do i remove a buff when a unit picks up an item?

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,257
Code:
// Note: Use a null unit for "any unit" events

// Inventory changes
const int c_unitInventoryChangeUses             = 0;
const int c_unitInventoryChangeExhausts         = 1;
const int c_unitInventoryChangeGains            = 2;
const int c_unitInventoryChangeLoses            = 3;
const int c_unitInventoryChangePicksUp          = 4;
const int c_unitInventoryChangeDrops            = 5;
const int c_unitInventoryChangeBuys             = 6;
const int c_unitInventoryChangeSells            = 7;
const int c_unitInventoryChangeGives            = 8;
const int c_unitInventoryChangeReceives         = 9;
const int c_unitInventoryChangeMoves            = 10;

native void     TriggerAddEventUnitInventoryChange (trigger t, unitref u, int inChangeType, unitref inItem);

I believe this event is what you are after.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,257
TriggerAddEventUnitInventoryChange function basically adds a trigger (observer) to various item action sockets (observables). This results in the trigger being evaluated every time an item action which it is observing is run. This logically will run your trigger handler code. Be aware that the number of observable sockets is finite as well as the number of trigger threads that can be active at any time so you can not abuse huge scope triggers like you could in WC3.

As you can see, the function allows you to observe specific units using specific items. This can be good for scope reduction (eg if only 1 unique unit using 1 unique item has to run something). You do however have the option to specify any unit or any item by simply providing null for that unitref.

The change type represents which item action to socket the trigger to. The names are all implicit. More than 1 action socket might be be notified at a specific ingame action (as buying an item also makes the unit receive an item etc).

You might be able to avoid the trigger editor alltogether.
1. item gives unit a buff behaviour.
2. the buff behaviour uses a validator to require the unit has the buff you want to remove.
3. active buff behaviour effect is to remove effect you do not want unit to have with item.

If item is used on aquisition, it is even easier as you could simply build a buff removal branch into your effect path.
 
Status
Not open for further replies.
Top