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

[General] One event to many different results

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

Suppose I have a trigger that checks when a unit picks up an item, as I need to make sure I can allow that unit to hold said item.

But say also picking up some items can start a quest for a player.

These are two entirely different results from the same event. Do I just make one set of if statements that iterate over all such possibilities? I suppose I can be clever and assign certain point values to items that start quests, but it still has to look like this:

JASS:
Player picks up some item

If item is an equippable item
  If player is strong enough to use item
    do nothing
  else unequip item, display message "Not ready to use item"
elseif item is a quest starting item
  if item is == QuestItemA
    start QuestA
  if item is == QuestItemB
    start QuestB
...
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
Well I need to control which units pick up what items.

But picking up items is also a way to start a quest, or perhaps advance one. E.g. a character comes across a dusty old tome (think Skyrim where you read a book you start a quest). Or character finds the item their quest needs.

These are all the same event, but different outcomes. It's a bit annoying to have to put it all into a single giant set of conditions...
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You could use a hashtable to initialize data.

For examle

set ht = InitHashtable()
call SaveBoolean(ht, 'Hpal', 0, true) // Hpal = paladin

Unit acquires an item
if LoadBoolean(ht, GetUnitTypeId(GetTriggerUnit()), 0) then
--can equip
else
--can not equip
endif

Likewise, you can initialize if an item is a quest item or not.
 
Status
Not open for further replies.
Top