• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[General] One event to many different results

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
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,337
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,240
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