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

[Solved] Items system related questions

Status
Not open for further replies.
Level 6
Joined
Jul 22, 2009
Messages
214
SOLVED
1. I have a system that drop an item(for example a weapon) if the hero already have an item of this type.(weapon in the example). My problem is when I buy items, I don't want the buyed item to be dropped if the hero already have an item of the same type, I just want to show the alert message that say: ''Can only wear one weapon'' and I want to give back the gold that the item cost.

SOLVED
2. I've search for it but I've found nothing, is there a way to ''clear'' the item that are on the ground, for example an item is dropped, if 30 sec. later no one picked it the item disapear.

+REP for help
 
Last edited:
Last edited:
Yes, you can use these simple triggers:
  • Item
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • Hashtable - Save True as (Key sold) of (Key (Sold Item)) in I_Hash
  • Item2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load (Key sold) of (Key (Item being manipulated)) from I_Hash) Equal to False
        • Then - Actions
          • Game - Display to (All players) the text: This item is picked.
        • Else - Actions
          • Game - Display to (All players) the text: This item was sold.
Test map attached; you can drop the bought/picked items and it will still tell you whether this item was sold or picked up by your unit.
 

Attachments

  • Item Picked or Sold.w3x
    17 KB · Views: 70
Level 6
Joined
Jul 22, 2009
Messages
214
Thanks Pharaoh_ it's looking good, just one thing, when I drop a bought item and I picked it after it's say tht it's a buyed item, is it possible to remove it?
 
Level 6
Joined
Jul 22, 2009
Messages
214
I will try this when I got some time, htanks for help

EDIT: I used what you send me, thanks you two. +REP
Can you help me with the second questions?
 
Last edited:
  • Create a hashtable
  • When an item is dropped, save 30.00seconds as a real on the hashtable using the item's handleId as the parent key, the child key could just be 0
  • Add the item into an array
  • Create a .03 seconds periodic trigger which loops through the array, and reduces the saved real by .03 seconds
  • Now, if the real becomes less than or equal to 0, remove the item
  • Then if an item is picked-up, remove it from the array, recycle the index, and also flush the child hashtable specific to that item
 
Status
Not open for further replies.
Top