Demo Map Auto Harvesting

Hellohihi

New Member
Reaction score
42
AutoHarvest
v1.1

What is Auto Harvest?

Auto Harvest simply means that whenever you train a harvesting unit, it will automatically harvest nearby lumber.

AutoHarvest can often be seen in maps like Vampirism Fire and Speed.


Can it be turned Off and On?

Yes, it can be turned off and on by clicking on the item/ability.


Variables used:


AutoHarvest Boolean Array of Size 12
HarvestG Empty Player Group


Code:
Trigger:
  • Toggle ON and OFF
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to AutoHarvest Turn On/Off
    • Actions
      • Player Group - Add (Owner of (Triggering unit)) to HarvestG
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AutoHarvest[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Set AutoHarvest[(Player number of (Owner of (Triggering unit)))] = False
          • Game - Display to HarvestG for 5.00 seconds the text: -------AutoHarvest ...
        • Else - Actions
          • Set AutoHarvest[(Player number of (Owner of (Triggering unit)))] = True
          • Game - Display to HarvestG for 5.00 seconds the text: -------AutoHarvest ...
      • Player Group - Remove (Owner of (Triggering Unit)) from HarvestG


Trigger:
  • AutoHarvest
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • AutoHarvest[(Player number of (Owner of (Trained unit)))] Equal to True
      • (Level of Harvest (Gold and Lumber) for (Trained unit)) Greater than or equal to 1
    • Actions
      • Unit - Order (Trained unit) to Harvest Nearby Lumber

version 1.1 Changelog:
1. Autoharvest on and off text is only displayed to the owner of the trained unit
2. Unit type Condition of AutoHarvest trigger changed to a Harvest Ability level Condition.
 

Attachments

  • DemoAutoHarvest_SaMv1.1.w3x
    24.8 KB · Views: 381

Azlier

Old World Ghost
Reaction score
461
...Why release something that can be done in a minute?
 

Jesus4Lyf

Good Idea™
Reaction score
397
Pretty cool. I still think I'd be inclined to just let players waypoint buildings.
Trigger:
  • Or - Any (Conditions) are true
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Peasant
      • (Unit-type of (Trained unit)) Equal to Peon
This condition could be based on "Unit has Ability (Harvest)" and the variations of that ability? A lot more dynamic. ^_^

>Game - Display to (All players) for 5.00 seconds the text: -------AutoHarvest ...
Err. Let's not give players the ability to spam text to all players, huh? Make it just display to the triggering player, would be great. :)
 

Azlier

Old World Ghost
Reaction score
461
But it leaks, Wolfie. :banghead:
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Ah crap.
Brb.

Fixed.
Trigger:
  • Toggle ON and OFF
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to AutoHarvest Turn On/Off
    • Actions
      • Set tempGroup = (Player group((Owner of (Triggering unit))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AutoHarvest[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Set AutoHarvest[(Player number of (Owner of (Triggering unit)))] = False
          • Game - Display to tempGroup for 5.00 seconds the text: -------AutoHarvest ...
        • Else - Actions
          • Set AutoHarvest[(Player number of (Owner of (Triggering unit)))] = True
          • Game - Display to tempGroup for 5.00 seconds the text: -------AutoHarvest ...
      • Custom script: call DestroyForce(udg_tempGroup)

Trigger:
  • AutoHarvest
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • AutoHarvest[(Player number of (Owner of (Trained unit)))] Equal to True
      • (Level of AutoHarvest Turn On/Off for (Trained unit)) Greater than or equal to 1
    • Actions
      • Unit - Order (Trained unit) to Harvest Nearby Lumber
 

RedSword

New Member
Reaction score
4
What's the point in the second trigger of that line (of your last reply) :

"(Level of AutoHarvest Turn On/Off for (Trained unit)) Greater than or equal to 1"

Because your peon and your peasant doesn't have "AutoHarvest Turn On/Off" but "Harvest (Gold and Lumber)"... so they don't automaticly harvest unless a waypoint is set...
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I don't think that'll ever make a noticeable difference though :eek: ?


EDIT: Change it to "Harvest (Gold and Lumber)" then.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
By request of Jesus4Lyf ( :p ) :
Trigger:
  • Toggle ON and OFF
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) AutoHarvest Turn On/Off
    • Actions
      • Custom script: local force f = CreateForce()
      • Custom script: call ForceAddPlayer(f, GetOwningPlayer(GetTriggerUnit()))
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • AutoHarvest[(Player number of (Owner of (Triggering unit)))] Equal to (==) True
          • Then - Actions
            • Set AutoHarvest[(Player number of (Owner of (Triggering unit)))] = False
            • Custom script: if (IsPlayerInForce(GetLocalPlayer(), f)) then
            • Custom script: call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "-------AutoHarvest turned OFF")
            • Custom script: endif
          • Else - Actions
            • Custom script: if (IsPlayerInForce(GetLocalPlayer(), f)) then
            • Custom script: call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "-------AutoHarvest turned ON")
            • Custom script: endif
            • Set AutoHarvest[(Player number of (Owner of (Triggering unit)))] = True
      • Custom script: call DestroyForce(f)
      • Custom script: set f = null
Hopefully it's right :eek: !
 

Azlier

Old World Ghost
Reaction score
461
Soon, you will have Romek's ability to code vJass in the "happy, readable, colorful" GUI.

Oh, and you never null f! You have accomplished nothing!
 

Jesus4Lyf

Good Idea™
Reaction score
397
Geez, if you were gonna take it that far you didn't need forces to begin with.

I thought you'd just use a global force variable. You could even just add the player to it, display the text, then remove it again at the end...

>Oh, and you never null f! You have accomplished nothing!
Rofl. >_<

>snippet
Yea.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top