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

I need help - Bonus when gathering resources

Status
Not open for further replies.
Level 9
Joined
Apr 19, 2011
Messages
447
Hi everyone.

I need some help to make an upgrade for a custom race I'm working on. Basicly, if this upgrade has been researched, when a worker leaves wood in a lumberyard, the player receives a 20% additional amount of wood. As far as I know, there's no default upgrade with this effect, so this has to be triggered.
I have two main questions:

- How can I detect when a worker leaves wood in a lumberyard? This is really important, because the upgrade only works if the wood is gathered in lumberyards (it's one the race's buildings), not in the main buildings. I think I know how to check when a worker leaves wood, but I don't know how to check what's the type of the building where's being left.

- How can I detect the amount of wood that's being left in the lumberyard? This is also important, because the race has upgrades that increase the amount of wood the workers can gather.

Maybe this is easier than I think, but right now I can't think of a way of doing it...
Thanks for your attention.

Kind Regards
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
When lumber increases check distance between lumberjard and workers around. If there's one wich current order is "harvest" or something like that, then it's most probable it comes from the wood.
 
Level 9
Joined
Apr 19, 2011
Messages
447
There's an event for when a player's resources change, in this case when it becomes greater than or equal to 0. This will fire whenever the player uses/gains resources. Then compare resources before the event to resources after the event to see if it was gained, and if the player has the tech, add 20% of that difference.
As long no spells modify lumbers, it should be easy, just check if the player lumber increase then add by percent.

Damn, you're right. :)
Okay, that was easier than I thought. I guess that part is done, thanks!

When lumber increases check distance between lumberjard and workers around. If there's one wich current order is "harvest" or something like that, then it's most probable it comes from the wood.

I didn't think of doing it that way... However, I gave it a try, with no results. :(

I made a quick test map, to play around with these ideas and see if I could get the results I want before including them in the custom race itself. This is what I have for now:

This first trigger is quite evident, it just puts the current lumber of the player in a real variable.
  • Player Lumber
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set TempReal01 = (Real((Player1 (red) Current lumber)))
The second trigger is the one that should add the bonus.
  • Lumber Bonus
    • Events
      • Player - Player 1 (red)'s Current lumber becomes Higher than of Equal to 0.00
    • Conditions
    • Actions
      • -------- I put the new lumber value on another real variable --------
      • Set TempReal02 = (Real((Player 1 (rojo) Madera actual)))
      • -------- Now I check if the player gained or lost lumber --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TempReal02 - TempReal01) Higher than 0.00
        • Then - Actions
          • -------- Now I loop through all the Lumberyards under the player's control --------
          • Unit Group - Pick every unit in (Units owned by Player 1 (red) of type Lumberyard) and do (Actions)
            • Loop - Actions
              • Set TempLoc = (Position of (Picked unit))
              • -------- I pick all the workers in a short range around the Lumberyard and add them to a unit group --------
              • Unit Group - Pick every unit in (Units within 400.00 of TempLoc matching ((Unit-type of (Matching unit)) Equal to Peasant)) and do (Actions)
                • Then - Actions
                  • Unit Group - Add (Picked unit) to TempGroup
              • -------- I search for the nearest worker to the Lumberyard --------
              • Set TempUnit = (Random unit from TempGroup)
              • Set TempLoc02 = (Position of TempUnit)
              • Set TempReal01 = (Distance between TempLoc and TempLoc02)
              • Custom script: call RemoveLocation(udg_TempLoc02)
              • Unit Group - Pick every unit in TempGroup and do (Actions)
                • Loop - Actions
                  • Set TempLoc02 = (Position of (Picked unit))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between TempLoc and TempLoc02) Lesser than TempReal01
                    • Then - Actions
                      • Set TempReal01 = (Distance between TempLoc and TempLoc02)
                      • Set TempUnit = (Picked unit)
                    • Other - Actions
                  • Custom script: call RemoveLocation(udg_TempLoc02)
              • -------- If the nearest worker (the one which most likely caused the lumber to increase) is currently harvesting, I add a bonus --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current order of TempUnit) Equal to (Order(harvest))
                • Then - Actions
                  • Player - Add 2 to Player 1 (red) Current lumber
                  • Set TempLoc02 = (Position of TempUnit)
                  • Floating Text - Create floating text that reads +2 at TempLoc02 with Z offset 50.00, using font size 10.00, color (25.00%, 100.00%, 25.00%), and 0.00% transparency
                  • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
                  • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
                  • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                  • Custom script: call RemoveLocation(udg_TempLoc02)
                • Other - Actions
              • Custom script: call RemoveLocation(udg_TempLoc)
        • Other - Actions


OK, the bonus never gets added. The detection of the lumber increase works fine (I tested myself), so that's not the problem. The problem is in the part where I try to check if the worker left the lumber in the Lumberyard. Does someone know what am I doing wrong? Maybe an easier way to do this? I attached my test map, if that helps.
Thank you for your attention.

Kind Regards
 

Attachments

  • Lumber Bonus.w3x
    19.3 KB · Views: 32
Status
Not open for further replies.
Top