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

How to make researches cost a 3rd resource

Status
Not open for further replies.
Level 10
Joined
Sep 25, 2013
Messages
521
I'm using this system by rulerofiron99 to add an additional resource into my game. How can i use this system to make researches cost this new resource type?

http://www.hiveworkshop.com/threads/gui-custom-resource-harvest-system-1-05.225610/

Here is what i tried to do, but it doesn't work:

  • Second Age
    • Events
      • Unit - A unit Begins research
    • Conditions
      • (Researched tech-type) Equal to Second Age (Elves)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • OHS_OilResource[(Player number of (Owner of (Researching unit)))] Greater than or equal to 200
        • Then - Actions
          • Set OHS_OilResource[(Player number of (Owner of (Researching unit)))] = (OHS_OilResource[(Player number of (Owner of (Researching unit)))] - 200)
        • Else - Actions
          • Game - Display to tempForce the text: |cffff0000Error|r -...
          • Unit - Order (Researching unit) to Stop
What happens is the research still continues, none of the resource cost is subtracted, and i don't get an error message saying i need more of the resource. Thank you!
 
Level 10
Joined
Sep 25, 2013
Messages
521
Google is your friend.

Ordering a Unit to Stop doesn't interrupt research/training commands.

Your solution to that is here: http://www.hiveworkshop.com/threads/cancel-research-by-trigger.180949/

IF your If, Then, Else is failing to fire at all (i.e. you're not getting the message AND not the subtraction) then it's likely that the trigger isn't executing it's actions.

Thanks, i figured ordering the structure to stop wouldn't cancel the research. The problem has to do with detecting the resource amount. This is the trigger this system uses for units that cost this resource.
  • 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
the oil cost of the unit is saved in the trigger configuration. Other than that, what i have is the same thing, just with a number (200) instead of loading a cost from hashtable and what not.
 
Level 13
Joined
Jul 15, 2007
Messages
763
  • Second Age
    • Events
      • Unit - A unit Begins research
    • Conditions
      • (Researched tech-type) Equal to Second Age (Elves)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • OHS_OilResource[(Player number of (Owner of (Researching unit)))] Greater than or equal to 200
        • Then - Actions
          • Set OHS_OilResource[(Player number of (Owner of (Researching unit)))] = (OHS_OilResource[(Player number of (Owner of (Researching unit)))] - 200)
        • Else - Actions
          • Game - Display to tempForce the text: |cffff0000Error|r -...
            • Unit - Order (Researching unit) to Stop

For the text message, does tempForce exist elsewhere? It's not set during this trigger which can be why you're not seeing a text at all. What i would recommend is to add game text messages at each point of the trigger (before IF, THEN ELSE, and then at THEN and then at ELSE so you can see what's firing and what isn't.
 
Level 10
Joined
Sep 25, 2013
Messages
521
For the text message, does tempForce exist elsewhere? It's not set during this trigger which can be why you're not seeing a text at all. What i would recommend is to add game text messages at each point of the trigger (before IF, THEN ELSE, and then at THEN and then at ELSE so you can see what's firing and what isn't.

Yeah you're right, i should add messages at each section, i'll test that out now. And yeah there was no temp force in that trigger. I just went with all players for now. I'll update this post in a minute once i test this

EDIT:

You were right, i just needed to see where the trigger was failing with the messages. It was working all along, i just needed to add that custom script to cancel the research. Thank you for your help +rep, google is my friend lol
 
Last edited:
Status
Not open for further replies.
Top