• 🏆 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!

Simple Trigger Problem

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,601
Hello.

How to make a system that when a hero picks a specific item an integer increases with one point. But does not increase if this item is already picked once before. There are many same types of items and totally in the map there are about 20 to 40 items that increases this integer. There are some other items too but they won't increase this integer.

Rep for the one who helps.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
This is where hashtables come in handy once again.

When a unit acquires an item, you check the item type. Then you check whether there's some valuen , a boolean perhaps, saved for the item in a hashtable. If it is there, then the item has been picked up before. If it isn't save the value and increase the integer by one.

I can throw you a test map soon.
 
  • Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer A) from 1 to I_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to I_ItemType[(Integer A)]
            • Then - Actions
            • Else - Actions
              • Set I_Index = (I_Index + 1)
              • Set I_ItemType[I_Index] = (Item-type of (Item being manipulated))
Stores an item type variable and re-checks that same variable. Place all your actions in the 'Else' column, that is when the item you pick up is not registered already.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
This system keys the boolean for the item picked. You can add more item types to the condition, just use OR.

  • Acquire Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
    • Actions
      • Custom script: if LoadBoolean(udg_Item_Hash , GetHandleId(GetManipulatedItem() ) , StringHash("isPicked") ) != true then
      • Custom script: call SaveInteger(udg_Item_Hash , GetHandleId(GetTriggerUnit() ) , StringHash("IntegerBonus") , LoadInteger(udg_Item_Hash , GetHandleId(GetTriggerUnit() ) , StringHash("IntegerBonus") ) +1 )
      • Custom script: call SaveBoolean(udg_Item_Hash , GetHandleId(GetManipulatedItem() ) , StringHash("isPicked") , true )
      • Custom script: endif
      • Custom script: call BJDebugMsg(I2S(LoadInteger(udg_Item_Hash , GetHandleId(GetTriggerUnit() ) , StringHash("IntegerBonus") ) ) )
 

Attachments

  • Integer_Test.w3x
    16.7 KB · Views: 33
Level 37
Joined
Aug 14, 2006
Messages
7,601
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing 1 as An exact match
    • Conditions
    • Actions
      • Custom script: Custom script: set integer = LoadInteger(udg_Item_Hash , GetHandleId(udg_Hero) , StringHash("IntegerBonus") )
      • Game - Display to (All players) the text: (String(integer))
Hmm, gives me an error.

ERROR: "Custom script: set integer = LoadInteger(udg_Item_Hash , GetHandleId(udg_Hero) , StringHash("IntegerBonus") )"

Why we have to do with jass? :D
Why can't we go to old sexy classic GUI that always works and everyone knows how things run?
 
Level 37
Joined
Aug 14, 2006
Messages
7,601
Oh yea, oh yea. I just copied it and didn't see that one coming. Just wait a moment and I'll fix it. As you can see, I'm not very much used to make JASS things(or any "high level triggers"). :p

Oh noes, things don't go forward. Still bugs!

  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing 1 as An exact match
    • Conditions
    • Actions
      • Custom script: set integer = LoadInteger(udg_Item_Hash , GetHandleId(udg_Hero) , StringHash("IntegerBonus") )
      • Game - Display to (All players) the text: (String(integer))
ERROR: set integer = LoadInteger(udg_Item_Hash , GetHandleId(udg_Hero) , StringHash("IntegerBonus") )
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Yes, it works for any amount of heroes. Once an item is picked up, it will no longer give integer bonus if it is picked up again.

But what do you mean by "boxes that can pick up items"?

That doesn't really matter since the items are not tied to certain units. It does not matter who/what picks them up.

Let me load normal WE and I'll give you a GUI (MUI) test map.
 
Status
Not open for further replies.
Top