• 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.

[GUI] Custom Resource Harvest System 1.05

Custom Resource Harvest System

Description
Oil harvesting like in Warcraft 2. Oil Tankers go to Oil Platforms, extract oil, and return it to the closest Oil Refinery.
  • Configure multiple tanker, refinery and platform types.
  • Tankers automatically find the nearest platform/refinery after returning/harvesting.
  • Smart targeting - you can right-click a platform to harvest. Also works for newly trained units to mine from their rally point.
  • Can easily be configured to represent a resource other than oil.
  • Includes Oil Display System (not required) - to display oil resource for all players (multiple resources types coming soon)
  • Includes Oil Usage System (not required) - to manage using oil resource for training units (structures, items and purchased units functionality coming soon)
  • Coming soon: ability to define any number of resource types.

The oil resource is tracked per player by the OHS_OilResource[] integer variable.

Installation
Pre-requisite: Bribe's Unit Indexer (included)

1. Copy the Oil Harvest System trigger categories into your map.
2. Make the necessary units and abilities in the object editor.
Abilities:
Harvest Oil - Ability that can target your oil platform.
Return Oil - Ability that can target your oil refinery.
Units:
Oil Tanker - Unit that will harvest the oil. Give your Harvest Oil ability to this unit.
Oil Refinery - Unit that will act as the drop-off point for tankers.
Oil Platform - Unit that will be the oil deposit.
3. Set these units in the variables in the OHS Config Trigger.

Triggers

  • OHS Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set OHS_CheckHashtable = (Last created hashtable)
      • -------- ----- --------
      • -------- Set the Harvest and Return abilities. --------
      • -------- ----- --------
      • Set OHS_HarvestAbility = Harvest Oil
      • Set OHS_ReturnAbility = Return Oil
      • -------- ----- --------
      • Set OHS_OilHarvestAmount = 10
      • Set OHS_FloatingTextColour = |cff404080
      • -------- ----- --------
      • -------- Set the unit types the system will use --------
      • -------- ----- --------
      • Set OHS_SaveUnitType = Oil Tanker
      • Set OHS_SaveResourceType = oil
      • Set OHS_SaveFunctionType = worker
      • Trigger - Run OHS Save Type <gen> (ignoring conditions)
      • -------- ----- --------
      • Set OHS_SaveUnitType = Oil Refinery
      • Set OHS_SaveResourceType = oil
      • Set OHS_SaveFunctionType = base
      • Trigger - Run OHS Save Type <gen> (ignoring conditions)
      • -------- ----- --------
      • Set OHS_SaveUnitType = Oil Platform
      • Set OHS_SaveResourceType = oil
      • Set OHS_SaveFunctionType = mine
      • Set OHS_SaveOilRemaining = 5000
      • Trigger - Run OHS Save Type <gen> (ignoring conditions)
      • -------- ----- --------
      • -------- ----- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set tempUnit = (Picked unit)
          • Trigger - Run OHS Check Group Register <gen> (ignoring conditions)
  • OHS Save Type
    • Events
    • Conditions
    • Actions
      • Custom script: set udg_tempInt = udg_OHS_SaveUnitType
      • Hashtable - Save OHS_SaveFunctionType as 0 of tempInt in OHS_CheckHashtable
      • Hashtable - Save OHS_SaveResourceType as 1 of tempInt in OHS_CheckHashtable
      • Hashtable - Save OHS_SaveOilRemaining as 3 of tempInt in OHS_CheckHashtable
  • OHS Smart
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(smart))
    • Actions
      • Set tempUnitTrigger = (Triggering unit)
      • Set tempUnitTarget = (Target unit of issued order)
      • -------- Check if ordered unit is a harvester --------
      • Set OHS_LoadUnitType = (Unit-type of tempUnitTrigger)
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load 0 of tempInt from OHS_CheckHashtable) Equal to worker
        • Then - Actions
          • -------- Check if target unit is a base or mine --------
          • Set OHS_LoadUnitType = (Unit-type of tempUnitTarget)
          • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Load 0 of tempInt from OHS_CheckHashtable) Equal to base
                  • (Load 0 of tempInt from OHS_CheckHashtable) Equal to mine
            • Then - Actions
              • Unit - Order tempUnitTrigger to Neutral Dark Ranger - Charm tempUnitTarget
            • Else - Actions
        • Else - Actions
  • OHS Trained Smart
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Set tempUnit = (Trained unit)
      • Set tempUnitTrigger = (Triggering unit)
      • Set tempUnitTarget = (Rally-Point of tempUnitTrigger as a unit)
      • Set OHS_LoadUnitType = (Unit-type of tempUnit)
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load 0 of tempInt from OHS_CheckHashtable) Equal to worker
        • Then - Actions
          • Set OHS_LoadUnitType = (Unit-type of tempUnitTarget)
          • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 0 of tempInt from OHS_CheckHashtable) Equal to mine
            • Then - Actions
              • Unit - Order tempUnit to Right-Click tempUnitTarget
            • Else - Actions
        • Else - Actions
  • OHS Register New Units
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Set tempUnit = UDexUnits[UDex]
      • Trigger - Run OHS Check Group Register <gen> (ignoring conditions)
  • OHS Check Group Register
    • Events
    • Conditions
    • Actions
      • Set tempId = (Custom value of tempUnit)
      • Set OHS_LoadUnitType = (Unit-type of tempUnit)
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Load 0 of tempInt from OHS_CheckHashtable) Equal to base
              • (Load 0 of tempInt from OHS_CheckHashtable) Equal to mine
        • Then - Actions
          • Unit Group - Add tempUnit to OHS_CheckUnitGroup
          • -------- Set starting resource for mines --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 0 of tempInt from OHS_CheckHashtable) Equal to mine
            • Then - Actions
              • Set OHS_OilRemaining[tempId] = (Load 3 of tempInt from OHS_CheckHashtable)
            • Else - Actions
        • Else - Actions
  • OHS Remove Check Group
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in OHS_CheckUnitGroup) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from OHS_CheckUnitGroup
  • OHS Harvest
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to OHS_HarvestAbility
    • Actions
      • Set tempUnitTrigger = (Triggering unit)
      • Set tempUnitTarget = (Target unit of ability being cast)
      • Set tempPlayer = (Owner of tempUnitTrigger)
      • -------- ------ --------
      • Set OHS_LoadUnitType = (Unit-type of tempUnitTrigger)
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • -------- Save the worker's resource type --------
      • Set OHS_CheckResourceType = (Load 1 of tempInt from OHS_CheckHashtable)
      • -------- Compare with the target's resource type --------
      • Set OHS_LoadUnitType = (Unit-type of tempUnitTarget)
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load 1 of tempInt from OHS_CheckHashtable) Equal to OHS_CheckResourceType
        • Then - Actions
          • -------- Remove resource from mine --------
          • Set tempId = (Custom value of tempUnitTarget)
          • Set OHS_OilRemaining[tempId] = (OHS_OilRemaining[tempId] - OHS_OilHarvestAmount)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • OHS_OilRemaining[tempId] Less than or equal to 0
            • Then - Actions
              • Unit - Kill tempUnitTarget
            • Else - Actions
          • -------- Show remaining oil --------
          • Set tempForce = (Player group((Owner of tempUnitTrigger)))
          • Floating Text - Create floating text that reads (OHS_FloatingTextColour + ((String(OHS_OilRemaining[tempId])) + |r)) above tempUnitTarget
  • with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
    • Floating Text - Hide (Last created floating text) for (All players)
    • Floating Text - Show (Last created floating text) for tempForce
    • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
    • Floating Text - Change (Last created floating text): Disable permanence
    • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
    • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
    • Custom script: call DestroyForce(udg_tempForce)
    • -------- Switch harvest/return abilities --------
    • Unit - Remove OHS_HarvestAbility from tempUnitTrigger
    • Unit - Add OHS_ReturnAbility to tempUnitTrigger
    • -------- Now search for base --------
    • Set OHS_SearchResourceType = OHS_CheckResourceType
    • Set OHS_SearchFunctionType = base
    • -------- Find nearest base --------
    • Set tempUnitPicked = No unit
    • Trigger - Run OHS Search <gen> (ignoring conditions)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • tempUnitPicked Not equal to No unit
      • Then - Actions
        • Unit - Order tempUnitTrigger to Neutral Dark Ranger - Charm tempUnitPicked
      • Else - Actions
    • Else - Actions
  • OHS Return
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to OHS_ReturnAbility
    • Actions
      • Set tempUnitTrigger = (Triggering unit)
      • Set tempUnitTarget = (Target unit of ability being cast)
      • Set tempPlayer = (Owner of tempUnitTarget)
      • -------- Determine what resource type the worker is carrying for the next check --------
      • Set OHS_LoadUnitType = (Unit-type of tempUnitTrigger)
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • Set OHS_CheckResourceType = (Load 1 of tempInt from OHS_CheckHashtable)
      • -------- Check if the base matches the resource being returned by the worker --------
      • Set OHS_LoadUnitType = (Unit-type of tempUnitTarget)
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Load 1 of tempInt from OHS_CheckHashtable) Equal to OHS_CheckResourceType
              • (Load 0 of tempInt from OHS_CheckHashtable) Equal to base
        • Then - Actions
          • -------- Add resources --------
          • Set OHS_OilResource[tempId] = (OHS_OilResource[tempId] + OHS_OilHarvestAmount)
          • Set tempForce = (Player group((Owner of tempUnitTrigger)))
          • Floating Text - Create floating text that reads ((OHS_FloatingTextColour + +) + ((String(OHS_OilHarvestAmount)) + oil|r)) above
  • tempUnitTrigger with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
    • Floating Text - Hide (Last created floating text) for (All players)
    • Floating Text - Show (Last created floating text) for tempForce
    • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
    • Floating Text - Change (Last created floating text): Disable permanence
    • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
    • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
    • Custom script: call DestroyForce(udg_tempForce)
    • -------- ------- --------
    • Set OHS_SearchResourceType = OHS_CheckResourceType
    • Set OHS_SearchFunctionType = mine
    • -------- Find nearest mine --------
    • Trigger - Run OHS Search <gen> (ignoring conditions)
    • Unit - Remove OHS_ReturnAbility from tempUnitTrigger
    • Unit - Add OHS_HarvestAbility to tempUnitTrigger
    • Unit - Order tempUnitTrigger to Neutral Dark Ranger - Charm tempUnitPicked
    • Unit Group - Remove all units from tempGroup
    • Else - Actions
  • OHS Search
    • Events
    • Conditions
    • Actions
      • Set tempGroup = (Units owned by tempPlayer matching (((Matching unit) is in OHS_CheckUnitGroup) Equal to True))
      • Set tempLoc = (Position of tempUnitTrigger)
      • Set tempDistance = 90000.00
      • Set tempUnitPicked = No unit
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Set OHS_LoadUnitType = (Unit-type of (Picked unit))
          • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Load 0 of tempInt from OHS_CheckHashtable) Equal to OHS_SearchFunctionType
                  • (Load 1 of tempInt from OHS_CheckHashtable) Equal to OHS_SearchResourceType
            • Then - Actions
              • Set tempLoc2 = (Position of (Picked unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between tempLoc and tempLoc2) Less than or equal to tempDistance
                • Then - Actions
                  • Set tempDistance = (Distance between tempLoc and tempLoc2)
                  • Set tempUnitPicked = (Picked unit)
                • Else - Actions
              • Custom script: call RemoveLocation(udg_tempLoc2)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_tempLoc)


  • OHS Display Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Set Oil icon for multiboard --------
      • Set OHS_DisplayOilIcon = ReplaceableTextures\CommandButtons\BTNPotionOfDivinity.blp
      • -------- ------- --------
      • Wait 0.25 seconds
      • -------- Create board for every player. --------
      • -------- If you want to create for only one player, set tempId = that player's player number and run OHS Display Create Board --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set tempId = (Player number of (Picked player))
          • Trigger - Run OHS Create Board <gen> (ignoring conditions)
  • OHS Create Board
    • Events
    • Conditions
    • Actions
      • Player Group - Add (Player(tempId)) to OHS_PlayersUsingDisplaySystem
      • Multiboard - Create a multiboard with 1 columns and 1 rows, titled Resources
      • Set OHS_Multiboard[tempId] = (Last created multiboard)
      • Multiboard - Set the icon for OHS_Multiboard[tempId] item in column 1, row 1 to OHS_DisplayOilIcon
      • Multiboard - Set the width for OHS_Multiboard[tempId] item in column 1, row 1 to 6.00% of the total screen width
      • Multiboard - Set the text for OHS_Multiboard[tempId] item in column 1, row 1 to 0
      • Multiboard - Hide OHS_Multiboard[tempId]
      • Multiboard - Show OHS_Multiboard[tempId]
  • Events
    • Time - Every 0.10 seconds of game time


  • OHS Usage Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set OHS_UsageHashtable = (Last created hashtable)
      • -------- ----- --------
      • -------- Set costs of unit types --------
      • -------- saveOilCost - the amount of oil the chosen unit type should cost --------
      • -------- To add more unit types, copy the following 4 lines, and change the OHS_SaveUnitType and OHS_SaveOilCost variables for the new unit --------
      • -------- ----- --------
      • Set OHS_SaveUnitType = Oil Tanker
      • Set OHS_SaveOilCost = 50
      • Custom script: set udg_tempInt = udg_OHS_SaveUnitType
      • Hashtable - Save OHS_SaveOilCost as 0 of tempInt in OHS_UsageHashtable
      • -------- ----- --------
  • OHS Unit Train
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • -------- Load values for the trained unit --------
      • Set tempUnit = (Triggering unit)
      • Set tempPlayer = (Owner of tempUnit)
      • Set OHS_LoadUnitType = (Unit-type((String((Issued order)))))
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • Set OHS_LoadOilCost = (Load 0 of tempInt from OHS_UsageHashtable)
      • -------- Check if the trained unit uses oil --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • OHS_LoadOilCost Greater than 0
        • Then - Actions
          • Set tempId = (Player number of tempPlayer)
          • -------- Check if player has enough oil --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • OHS_OilResource[tempId] Greater than or equal to OHS_LoadOilCost
            • Then - Actions
              • -------- Player has enough oil; subtract the cost from them --------
              • Set OHS_OilResource[tempId] = (OHS_OilResource[tempId] - OHS_LoadOilCost)
            • Else - Actions
              • -------- Player doesn't have enough oil, cancel training and display an error message --------
              • Unit Group - Add tempUnit to OHS_CancelTrainingGroup
              • Set tempForce = (Player group(tempPlayer))
              • Game - Display to tempForce the text: |cffff0000Error|r -...
              • Custom script: call DestroyForce(udg_tempForce)
              • Set tempId = (Custom value of tempUnit)
              • Set OHS_CancelTrainingStack[tempId] = (OHS_CancelTrainingStack[tempId] + 1)
        • Else - Actions
  • OHS Cancel Training
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in OHS_CancelTrainingGroup and do (Actions)
        • Loop - Actions
          • Set tempId = (Custom value of (Picked unit))
          • Trigger - Turn off OHS Refund <gen>
          • Custom script: call IssueImmediateOrderById( GetEnumUnit(), 851976 )
          • Trigger - Turn on OHS Refund <gen>
          • Set OHS_CancelTrainingStack[tempId] = (OHS_CancelTrainingStack[tempId] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • OHS_CancelTrainingStack[tempId] Equal to 0
            • Then - Actions
              • Unit Group - Remove (Picked unit) from OHS_CancelTrainingGroup
            • Else - Actions
  • OHS Refund
    • Events
      • Unit - A unit Cancels training a unit
    • Conditions
    • Actions
      • -------- Load values for the cancelled --------
      • Set tempPlayer = (Owner of tempUnit)
      • Set OHS_LoadUnitType = (Trained unit-type)
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • Set OHS_LoadOilCost = (Load 0 of tempInt from OHS_UsageHashtable)
      • -------- Check if the trained unit uses oil --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • OHS_LoadOilCost Greater than 0
        • Then - Actions
          • Set tempId = (Player number of tempPlayer)
          • -------- Check if training isn't being cancelled by triggers --------
          • -------- Refund the player --------
          • Set OHS_OilResource[tempId] = (OHS_OilResource[tempId] + OHS_LoadOilCost)
        • Else - Actions
  • OHS Start Building
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • -------- Load values for the building --------
      • Set tempUnit = (Constructing structure)
      • Set tempPlayer = (Owner of tempUnit)
      • Set OHS_LoadUnitType = (Unit-type of (Constructing structure))
      • Custom script: set udg_tempInt = udg_OHS_LoadUnitType
      • Set OHS_LoadOilCost = (Load 0 of tempInt from OHS_UsageHashtable)
      • -------- Check if the trained unit uses oil --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • OHS_LoadOilCost Greater than 0
        • Then - Actions
          • Set tempId = (Player number of tempPlayer)
          • -------- Check if player has enough oil --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • OHS_OilResource[tempId] Greater than or equal to OHS_LoadOilCost
            • Then - Actions
              • -------- Player has enough oil; subtract the cost from them --------
              • Set OHS_OilResource[tempId] = (OHS_OilResource[tempId] - OHS_LoadOilCost)
            • Else - Actions
              • -------- Player doesn't have enough oil, cancel training and display an error message --------
              • Set tempForce = (Player group(tempPlayer))
              • Game - Display to tempForce the text: |cffff0000Error|r -...
              • Custom script: call DestroyForce(udg_tempForce)
              • Unit - Remove tempUnit from the game
              • -------- Refund --------
              • Player - Add (Load 1 of tempInt from OHS_UsageHashtable) to tempPlayer Current gold
              • Player - Add (Load 2 of tempInt from OHS_UsageHashtable) to tempPlayer Current lumber
        • Else - Actions


Credits
Laercio - Inspiration
Bribe - Unit Indexer.

Changelog
1.04
  • Fixed bases being destroyed when targeted by empty workers
  • Added refunds for cancelled units
  • Changed training cancellation to use a loop and a stack instead of "Begins training" event
1.05
  • Now also works for buildings.

Keywords:
oil, oil harvest, harvest, resource, oil resource, oil system, oil harvest system, warcraft 2, resource harvest,
Contents

Custom Resource Harvest System 1.05 (Map)

Reviews
12:11, 18th Nov 2012 Magtheridon96: Changes made. Approved. This is well coded and deserves a very solid 4/5 :>

Moderator

M

Moderator

12:11, 18th Nov 2012
Magtheridon96: Changes made. Approved.
This is well coded and deserves a very solid 4/5 :>
 
It will be more Useful, If you put a Multiboard as a 3rd Resource Interface and Constants.
Rating System by doomhammer99

Note: 5 points are the highest rating and 1 point is the lowest rating.

Usefulness: 5
Documentation: 3
Triggering: 5
Overall Aspects: 4
Idea: 2

Overall Rating: 3.8

[TD]This Rating System is must[/TD]
 
You can just merge that return and harvest ability into one because you are using some of the functions twice.
Also,i think you should pick the groups instead of using an integer loop,unit groups are integers too.
And also what mag will say,cache some of the uncached function calls so that you wont repeat it all over again :D
Thats all
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
You can just merge that return and harvest ability into one because you are using some of the functions twice.
Also,i think you should pick the groups instead of using an integer loop,unit groups are integers too.
And also what mag will say,cache some of the uncached function calls so that you wont repeat it all over again :D
Thats all

Thanks will do!

I was using a integer loop because the code is from another map I'm making where all this took place inside a pick every unit, so I couldn't use that.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Right clicking a refinery causes it to explode.

Hi, that was a bug with a previous version where the unit indexer would sometimes run before refineries were initialised, and sometimes after. I've added a delay and this no longer happens.

The refinery explodes when it has no more oil in it, and the bug was that the oil wasn't properly set.

The oil is kept in an array using unit custom value as the index. You can manually set it yourself
  • Set OHS_OilRemaining[Custom Value of (MyRefineryUnit)] = 5000
I will soon add better documentation.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
very nice!
is there a way to change the resource type? For example to stone, silver etc?

Yes.

In the current version, you can change the type to anything you wish, along with the icon and floating text colour.

I'm busy working on a version that will allow you to use multiple different resource types.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Attached! It works quite well too, if I may say so. You might just want to decrease the peasants' collision size.

Configurables should be self-explanatory, currently each trip adds lumber. You can change this and the colour in the MPR Return trigger.

Copy both abilities as they are, and make sure to give the peasant the "Get a clue" ability.
 

Attachments

  • LimitAttackersSystem102-SC1StyleMineralHarvesting100.w3x
    32.2 KB · Views: 244
Level 25
Joined
Jul 10, 2006
Messages
3,315
btw might this work with a 3rd custom resource too?

Of course. I'm going to implement this system into my Custom Resource Harvest System, which will soon also allow multiple resource types.

is it possible to add the carry animation (gold or lumber) for the worker?

Easily, I'll add that when I get a chance.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Hey, excelent work. I noticed that when you try to create a ship and you don't have enough oil the ship is still created and the game displays an error message. Can you fix it?

Thanks for pointing that out; will do.

EDIT: Was this for the ships purchased at the oil platform?

The training prevention system currently only works for when you attempt to train units, so I'll have to add functionality for buying units.
 
Level 2
Joined
Jun 5, 2012
Messages
18
Can you make a screen of the variables please: I don't want to take a wrong one and ave to do all again.
 
Level 6
Joined
Nov 12, 2012
Messages
153
Let's see...

I'm working on a map and I have five oil platforms, each one with a different amount of oil (at least that's the idea) How do I do that with your system?

The trigger seems to determine that every unit of the type "oil platform" will have the same amount of oil, but I want to have different amount of oil for each one, just as if they where gold mines.

(If this will help, I have a custom unit I use as an oil patch and it has a custom gold mine ability, and I am planing to build the oil platform on it. and I want the oil platform to have the same amount of oil the oil patch has, and I want the oil patch to disappear when I'm done harvesting. Is that possible?)

Edit: I'm asking this because I wanted to make different quantities of oil as a strategic point in my map.
 
Last edited:
Level 25
Joined
Jul 10, 2006
Messages
3,315
I'm working on a map and I have five oil platforms, each one with a different amount of oil (at least that's the idea) How do I do that with your system?

The trigger seems to determine that every unit of the type "oil platform" will have the same amount of oil, but I want to have different amount of oil for each one, just as if they where gold mines.

(If this will help, I have a custom unit I use as an oil patch and it has a custom gold mine ability, and I am planing to build the oil platform on it. and I want the oil platform to have the same amount of oil the oil patch has, and I want the oil patch to disappear when I'm done harvesting. Is that possible?)

Edit: I'm asking this because I wanted to make different quantities of oil as a strategic point in my map.

Like so:
  • Actions:
    • Set tempId = (Custom value of (your oil platform))
    • Set OHS_OilRemaining[tempId] = how much oil you want
 
Level 6
Joined
Nov 12, 2012
Messages
153
Help me on this one...

I'm using an oil patch and it has a gold mine ability. I'm building my oil platform on it just like you build a haunted gold mine on a gold mine.

Using your last suggestion I could make my platforms to have the same oil amount as the oil patch on witch the platform was constructed. The problem is that the oil remaining in the oil patch (obviously) is not used. So if the platform is destroyed/depleted and you build a new one, the new platform will start again and this way you have infinite oil.

Can you help me make the resources on the oil patch to drop along with the oil remaining on the platform? If you could do this that might work as a display of the oil remaining on each platform and would help me a lot. Thank you...

By the way, I don't recall if I said it before, but your system is amazing, 5/5...

Edit: I think I managed to do that by myself. The oil amount on my map is now displayed above the platform as "gold remaining", and when you are done harvesting the platform, the oil patch desappears, so you can't build the platform there again. Anyway, thank you.
 
Last edited:
Level 6
Joined
Nov 12, 2012
Messages
153
Oil for upgrades

Hey, I was making my maps and I wanted to ask you how do I do to use the oil not only for the buildings and units, but for upgrades (researches) also. This is the only feature in the oil usage that does not has a function for it. It would be nice if you added this feature...(and would help me a lot...)
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
I took this directly from my map. I use the point value of units and buildings to array their resource cost.
  • BuildBasRes
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Set TempPlayer = (Triggering player)
      • Set TempUnit = (Constructing structure)
      • Set TempInt = (Point-value of TempUnit)
      • Set TempInt2 = (Player number of TempPlayer)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • CostMetal[TempInt] Greater than StoredMetal[TempInt2]
              • CostWood[TempInt] Greater than StoredWood[TempInt2]
              • CostCloth[TempInt] Greater than StoredCloth[TempInt2]
              • CostAmmo[TempInt] Greater than StoredAmmo[TempInt2]
        • Then - Actions
          • Unit - Remove TempUnit from the game
        • Else - Actions
          • Set StoredWood[TempInt2] = (StoredWood[TempInt2] - CostWood[TempInt])
          • Set StoredMetal[TempInt2] = (StoredMetal[TempInt2] - CostMetal[TempInt])
          • Set StoredCloth[TempInt2] = (StoredCloth[TempInt2] - CostCloth[TempInt])
          • Set StoredAmmo[TempInt2] = (StoredAmmo[TempInt2] - CostAmmo[TempInt])

  • UpBasRes
    • Events
      • Unit - A unit Begins an upgrade
    • Conditions
    • Actions
      • Set TempPlayer = (Triggering player)
      • Set TempUnit = (Triggering unit)
      • Set TempInt = (Point-value of (Triggering unit))
      • Set TempInt2 = (Player number of TempPlayer)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • CostMetal[TempInt] Greater than StoredMetal[TempInt2]
              • CostWood[TempInt] Greater than StoredWood[TempInt2]
              • CostCloth[TempInt] Greater than StoredCloth[TempInt2]
              • CostAmmo[TempInt] Greater than StoredAmmo[TempInt2]
        • Then - Actions
          • Unit - Order TempUnit to Stop
        • Else - Actions
          • Set StoredWood[TempInt2] = (StoredWood[TempInt2] - CostWood[TempInt])
          • Set StoredMetal[TempInt2] = (StoredMetal[TempInt2] - CostMetal[TempInt])
          • Set StoredCloth[TempInt2] = (StoredCloth[TempInt2] - CostCloth[TempInt])
          • Set StoredAmmo[TempInt2] = (StoredAmmo[TempInt2] - CostAmmo[TempInt])
For researches you'd have to do some more complicated (boring) storing the costs and the researches because they dont have a value which can be detected and used.
 
Level 6
Joined
Nov 12, 2012
Messages
153
The ships block each other returning the oil. Is it possible to remove collision from the ships while harvesting? Similar to gold harvesting.
Btw if i want the ships to return gold and add to the normal gold is that possible?

I've noticed the ships blocking each other too, and, I had no time to do it yet, but I think you can change the collision value in the object editor, so the units harvesting oil will be "smaller" and they won't block each other. After all, they don't need to have a big collision value. The problem is not with the system, but with the ability "harvest oil", that does not have the same effect as the "Harvest Gold Ability".

About returning gold, you can simply make a custom gold mine with any model you want over the water and give the ships the ability "Harvest", like a normal peasant, without using the Oil Harvest System, simply using the existing system of gold collection.

(Please, if I wasn't clear, fell free to tell me that, ok?)

Try it...
 
Level 6
Joined
Nov 12, 2012
Messages
153
I know that i could add return gold, but than normal gold from goldmines can be returned at a harbour too. I dont want that.

Let's see...

I'll think about something...

Edit: Yeah! You're right, its quite a chalenge to do it only in object editor. We'll need some triggers...

Edit (again): I Think I've done it, let's see if you have tried it.

  • -------- Add resources --------
  • Player - Add 10 to Player 1 (Red) Current gold
  • Set OHS_OilResource[tempId] = (OHS_OilResource[tempId] + OHS_OilHarvestAmount)
These functions are on the trigger OHS Return

If you want to have only gold income you can replace the second action using the first one (I've added it so it would work the way you want)

You can also just add the first action, but it will give you gold AND oil.

The oil tanker will add gold and the Peasants will not go to the Shipyard (Because you won't use the "return gold and lumber" ability)

I hope I've helped (if not, tell me)

Editing once again: Forgot to mention it will work for the player you choose (And I've done it right now, so maybe it's not the best way to do it, but will work for single player, maybe with more time we can use a diferent way of doing it)
 
Last edited:
Level 12
Joined
Mar 24, 2011
Messages
1,082
Is people still working on this? How can i set the computer do the same with their own platforms?
Last update in 2012. Also, ruler is not 100% active around, last in Jan. So, answer is not really.
You'd have more luck posting in WeHZ or Triggers & Scripts.

I am not entirely sure if this system supports use by Computer players, or rather the other way around:
Default Warcraft 3 AI would not support many custom systems unless you add/extend/create the appropriate behaviour either inside the AI or externally via triggers.

PS: Why did this appear as message addressed to me?
 
Level 22
Joined
Nov 20, 2005
Messages
1,221
PS: Why did this appear as message addressed to me?
I don't know but i surely do appreciate your reply. I've come really close to develop an oil system on my own, but i'm having some strange logistic bugs happening right now at the end that are sending me in the total craziness. This is why i wanna try this out(looks confusing AF for me though) but i'd need to know more, as i asked above.
 
Top