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

[Trigger] Problem tracking the number of trees

Status
Not open for further replies.
Level 3
Joined
Nov 28, 2008
Messages
24
Hi, I'm a newbie. Sorry for my mistakes. Ok, so, my map has 110 trees and requires players to protect the trees from being chopped down by the enemy units. If the number of trees reaches 0, then the players will be defeated. But I'm having problem tracking the number of trees in my map. I tried 2 triggers :

*Note : The amount of lumber indicates the number of trees alive*

  • Decrease Lumber
    • Events
      • Destructible - A destructible within (Playable Map Area) dies
    • Conditions
      • (Destructible-type of (Picked destructible)) Equal to Ashenvale Tree Wall
    • Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Player - Set (Player((Integer A))) Current lumber to (((Player((Integer A))) Current lumber) - 1)
This trigger doesn't work. The amount of lumber is 46 after all the trees are chopped down. The second trigger :

  • Decrease Lumber
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Destructible - Pick every destructible in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Ashenvale Tree Wall
            • Then - Actions
              • Set CountHarvest = (CountHarvest + 1)
              • For each (Integer A) from 1 to 8, do (Actions)
                • Loop - Actions
                  • Player - Set (Player((Integer A))) Current lumber to CountHarvest
This trigger also doesn't work. The amount of lumber is also 46 after all the trees are chopped down. Anyone has any idea on this? Your help will be appreciated :cute:

*P.S - The number of trees are counted correctly (110). It is also shown in the object manager (F11)*
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
"a destructible within playable map area dies" only registers 64 destructibles
but picking all destructibles within the map and creating an event for them should work
the second trigger should work as well
there are a few things which could be the reason for the error:
-trees arent placed on the playable map area (black trees)
-trees arent of type ashenvale tree wall
-the object manager lies and you don't have 110 trees
maybe count the trees with a trigger first and see if you get the same result
or count them yourself
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
The second trigger might not work because it could be enumerating destructibles that are dead.
This should work:
  • TreeCheck
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set TreeCount = 0
      • Destructible - Pick every destructible in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Ashenvale Tree Wall
              • ((Picked destructible) is alive) Equal to True
            • Then - Actions
              • Set TreeCount = (TreeCount + 1)
            • Else - Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Player - Set (Player((Integer A))) Current lumber to TreeCount
Though I prefer doing something similar to the first method:
  • MapInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- The trigger should work correctly if all trees are alive at map initialization. --------
      • Destructible - Pick every destructible in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Ashenvale Tree Wall
            • Then - Actions
              • Set TreeCount = (TreeCount + 1)
              • Trigger - Add to TreeDies <gen> the event (Destructible - (Picked destructible) dies)
            • Else - Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Player - Set (Player((Integer A))) Current lumber to TreeCount
  • TreeDies
    • Events
    • Conditions
    • Actions
      • Set TreeCount = (TreeCount - 1)
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Player - Set (Player((Integer A))) Current lumber to TreeCount
since it looks more smooth. This is basically what D4RK_G4ND4LF was talking about.

TreeCount is an integer and its default value is 0.
 
Level 3
Joined
Nov 28, 2008
Messages
24
Thanks a lot! Now it works properly. Thanks a lot guys! Really appreciate it!
 
Level 3
Joined
Nov 28, 2008
Messages
24
Oh yeah....one more thing.....I was wondering if there's a way to set the range of the action 'Harvest Nearby Lumber' :

  • Unit - Order (Triggering unit) to Harvest Nearby Lumber
Is there anyway to set the maximum range for the tree to be considered as 'nearby' in the trigger above?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
The order string that is issued with that order is "autoharvestlumber". I tried extracting AbilityData.slk and figuring out which ability that refers to, but MS Excel seemed to just crash on opening it (I'm looking for another SLK reader/writer now).

I'm pretty sure all you've got to do is find the ability and adjust the fields to what you want.
 
Level 3
Joined
Nov 28, 2008
Messages
24
The order string that is issued with that order is "autoharvestlumber". I tried extracting AbilityData.slk and figuring out which ability that refers to, but MS Excel seemed to just crash on opening it (I'm looking for another SLK reader/writer now).

I'm pretty sure all you've got to do is find the ability and adjust the fields to what you want.

Okay. But I don't really know how to find the ability since the ability 'Harvest Nearby Lumber' doesn't exist. Do you know the ability by any chance? Anyway, thanks a lot for helping! :grin:
 
Status
Not open for further replies.
Top