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

[Trigger] Mana Cost on Unit Production

Status
Not open for further replies.
Level 3
Joined
Jun 9, 2009
Messages
38
The map Power Towers has inspired me to make a RTS styled map where one has to make Generators to make power (mana) to actively use that building. One also has to retrieve raw materials (wood) and refine those into supplies (gold).

However, I'm not sure how to make units require mana on production. This is what I have so far.

  • Unit Creation
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Unit-type of (Buying unit)) Equal to Infantry
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of (Constructing structure)) Greater than or equal to 10.00
        • Then - Actions
        • Else - Actions
          • Unit - Order (Constructing structure) to Stop
The Unit will require 10 mana (for now) on production. The "Then" and "Else" Actions are iffy.

Thanks in advance.
 
Level 10
Joined
Aug 15, 2008
Messages
720
  • Unit on Mana Cost
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Trained unit-type) Equal to (==) Footman
      • (Unit-type of (Triggering unit)) Equal to (==) Barracks
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of (Triggering unit)) Greater than or equal to (>=) 10.00
        • Then - Actions
        • Else - Actions
          • Unit - Order (Triggering unit) to Stop
This should work I think

EDIT: All other should work, I just can't find action to cancel training of the unit....
 
Level 3
Joined
Jun 9, 2009
Messages
38
Didnt understand what u need.

Sorry, let me explain.

When a unit is going to be trained in my map, I want it to deduct a certain ammount of mana (power) from that constructing structure.

In the trigger, I want to make it so it cancels construction when there is not enough mana.
EDIT:
  • Unit Creation
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Unit-type of (Buying unit)) Equal to Infantry
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of (Constructing structure)) Greater than or equal to 10.00
        • Then - Actions
          • Unit - Set mana of (Constructing structure) to ((Mana of (Constructing structure)) - 10.00)
        • Else - Actions
          • Unit - Order (Constructing structure) to Stop
I change the trigger to that, but it doesn't deduct mana from the barracks.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
  • Unit Creation
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Unit-type of (Buying unit)) Equal to Infantry
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of (Constructing structure)) Greater than or equal to 10.00
        • Then - Actions
          • Unit - Set mana of (Constructing structure) to ((Mana of (Constructing structure)) - 10.00)
        • Else - Actions
          • Unit - Order (Constructing structure) to Stop

May be the (Constructing Unit) refers to a unit that has the ability to build buildings like peasent, I think this is not (constructing) this is (training) so try changing (Construction Structure) to (Triggering Unit)
 
Level 3
Joined
Jun 9, 2009
Messages
38
  • Unit Creation
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Trained unit-type) Equal to Infantry
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of (Triggering unit)) Greater than or equal to 10.00
        • Then - Actions
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) - 10.00)
        • Else - Actions
          • Unit - Order (Triggering unit) to Stop
The stop command doesn't work, otherwise it is working perfectly.
 
Level 3
Joined
Jun 9, 2009
Messages
38
  • Unit Creation
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Trained unit-type) Equal to Infantry
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • Set factory = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of (Triggering unit)) Greater than or equal to 10.00
        • Then - Actions
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) - 10.00)
        • Else - Actions
          • Game - Display to (All players matching ((Owner of (Triggering unit)) Equal to (Matching player))) for 10.00 seconds the text: More Power required...
          • Custom script: call IssueImmediateOrderById( udg_factory, 0x000d0008 )
Got it to stop with a custom command. Had to set up a variable.

And it works fine with them all being triggering unit.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
That is good but you will need more than variable if you have more than one building. i.e if you have N# buildings you will need N# variables. So I suggest Implementing a Stack method if you will have more than building as training a unit will take some time and during this time another building may train units.

Implementing a Stack is a part from making an MUI spell, Click here
 
Level 3
Joined
Jun 9, 2009
Messages
38
Been awhile since I've been in this thread, mostly because that refine materials trigger works fine without have to instance it.

However, another trigger I have needs to be instanced. Now I looked at the stack method, but it didn't really explain it well. (At least it would be better if it was step by step for each function)

Though I want to know if the GetTriggerUnit() would work, and how it is implemented. If someone would also like to tell me how to do the Stack in more detail, I'll be welcome.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
I am not sure but you could train unit normally and the mana(Energy) check for the first unit goes as intended and when it reaches the second unit you make the same mana check if it is greater than or equal to the required mana for training then you let the training go else order the building to cancel training. Try the event
  • Events
    • Unit - A unit Begins training a unit
to initite the mana checking condition. And I hope you could solve it :wink:
 
Level 3
Joined
Jun 9, 2009
Messages
38
Well the mana cost on production for units works perfectly even without an Instanced trigger implemented. I think it is because the trigger only happens when the unit is first made. And therefore the trigger isn't required to be used anymore.

Maybe I should just make another thread for this trigger being instanced.
 
Status
Not open for further replies.
Top