• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Item Condition

Status
Not open for further replies.
Level 7
Joined
Dec 6, 2010
Messages
153
I am making a bounty system.
So a neutral hostile has a chance to drop an item called bounty.
There are 5 bounty items.
Bounty level 1
Bounty level 2
...
Bounty level 5

Neutral Hostile doesn't give you gold when killed right away, instead they drop one of these items based on the level of the creep.
Then, you transfer those bounty items to a unit called "Bounty Table".
The Bounty Table now has the bounty item on his inventory.
and when the Bounty Table is targeted with the "interact" ability

Events - A unit starts the effects of an ability

The Bounty Table should destroy the Bounty Item and give the casting unit gold based on
(Bounty Level x multiplied by 25) + Intelligence of Triggering Unit.

The Question is, what condition do i use to check if the bounty table has a bounty item.
 
Level 5
Joined
Jun 12, 2018
Messages
146
If your Bounty Table is a unit this should do the trick :

  • Give Item
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by Bounty Table <gen> in slot (Integer A)) Not equal to (Load 0 of 0 in (Last created hashtable))
            • Then - Actions
              • Hero - Give (Item carried by Bounty Table <gen> in slot (Integer A)) to MyUnit <gen>
            • Else - Actions
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
Not sure what Swatosj is on about, that won’t do anything.

Easiest solution is to store the different bounty item types in an array, then loop over the item slots checking if any slot has a matching item, then award gold if it does.

  • Set BountyItem[1] = Bounty level 1
  • Etc.
  • Set BountyLevels = 5
  • ———— ————
  • For each (Integer A) from 1 to 6 do (actions)
    • Loop - Actions
      • For each (Integer B) from 1 to BountyLevels do (Actions)
        • Loop - Actions
          • If...
            • If - Conditions
              • (Item type of (Item carried by BountyTable in slot (Integer A)) equal to BountyItem[Integer B])
            • Then - Actions
              • ———— grant gold, destroy item, etc ————
 
Level 5
Joined
Jun 12, 2018
Messages
146
@Pyrogasm Yes he could use an array but I've understood the Bounty Table is a unit so if this one carries the items in his inventory my solution is working as OP was asking for a condition :)
 
Level 7
Joined
Dec 6, 2010
Messages
153
Not sure what Swatosj is on about, that won’t do anything.

Easiest solution is to store the different bounty item types in an array, then loop over the item slots checking if any slot has a matching item, then award gold if it does.

  • Set BountyItem[1] = Bounty level 1
  • Etc.
  • Set BountyLevels = 5
  • ———— ————
  • For each (Integer A) from 1 to 6 do (actions)
    • Loop - Actions
      • For each (Integer B) from 1 to BountyLevels do (Actions)
        • Loop - Actions
          • If...
            • If - Conditions
              • (Item type of (Item carried by BountyTable in slot (Integer A)) equal to BountyItem[Integer B])
            • Then - Actions
              • ———— grant gold, destroy item, etc ————
i wil try this when i get home, is there a function to drop every item from bounty table's that is not bounty?
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
No, you will have to check the item vs. all possibly bounty items and drop it if it doesn't match any of the items in the array.
  • Set BountyItem[1] = Bounty level 1
  • Etc.
  • Set BountyLevels = 5
  • -------- --------
  • For each (Integer A) from 1 to 6 do (actions)
    • Loop - Actions
      • Set IsBountyItem = False //boolean variable
      • For each (Integer B) from 1 to BountyLevels do (Actions)
        • Loop - Actions
          • If (All conditions are true) then do (Then actions) else do (Else actions)
            • If - Conditions
              • (Item type of (Item carried by BountyTable in slot (Integer A)) equal to BountyItem[Integer B])
            • Then - Actions
              • Set IsBountyItem = True
              • -------- grant gold, destroy item, etc --------
            • Else - Actions
      • If (All conditions are true) then do (Then actions) else do (Else actions)
        • If - Conditions
          • IsBountyItem equal to false //it didn't match any if its still false
        • Then - Actions
          • Unit - Cause BountyTable to drop Item in Slot (Integer A)
        • Else - Actions
 
Status
Not open for further replies.
Top