• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

harvest detection

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,226
In short, I want to give a player +1 lumber each time a worker attacks/harvests a tree.

I thought of a few ideas but none of them are good.

1. every X seconds check health of every single tree in the game and compare it to the hp when last checked. However I think a destructable group got a limit of 64 and I got a lot of trees in my map. This would also be very inefficient.

2. check when unit is ordered to harvest a tree, store the targeted tree into a variable and then keep track of the hp of that specific tree in a loop. This is what I am rolling with atm but it seems kinda.. bad.. somehow.

3. check when unit attacks and then give +1 lumber. I am not even sure if the event works on destructables and even so it's buggy since you could get lumber by canceling the animation.

4. checking for the current order id in a loop trigger and give player lumber every -animation length- seconds. This would be buggy since the issued order can be given from far away and the player would therefore be getting lumber by running to the tree.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
only the GUI destructable enumeration has 64 trees limit(can be seen in the BJ function that is called), but yes, 1. is very very bad, cause checking every tree is so heavy your map would drop to literally 0 fps.

Second one sounds a lot better.

Im pretty sure third one wont work, cause unit has order Harvest, not Attack when harvesting from trees.

You named the problem in the fourth yourself
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,226
  • get target
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Set order = (Current order of (Triggering unit))
      • Set target_tree = (Target destructible of issued order)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • order Equal to (Order(harvest))
              • order Equal to (Order(attack))
              • order Equal to (Order(smart))
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of (Triggering unit)) + (will go and harvest + (Name of (Target destructible of issued order))))
          • Set tree_last_hp = (Current life of target_tree)
        • Else - Actions
  • Untitled Trigger 001
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set tree_new_hp = (Current life of target_tree)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tree_new_hp Less than tree_last_hp
        • Then - Actions
          • Game - Display to (All players) the text: +1
        • Else - Actions
      • Set tree_last_hp = tree_new_hp
Maybe it's just me who thinks this feels odd. Why couldn't Blizzard just add a Destructable takes damage event -.-
 
Status
Not open for further replies.
Top