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

how can i make a unit use mana to build

Status
Not open for further replies.
Level 20
Joined
Apr 14, 2012
Messages
2,901
I don't know how this is possible through the object editor but you can do it via triggers:

You can store the mana you want in a real variable and subtract that variable to the worker unit using an If-Then-Else to check what building the unit is currently building.

I think the condition to use it two: One is to check the current order of the unit and to check the unit-type of the building being built.

Then just subtract from the mana of the builder unit the value you stored in a variable.

It doesn't sound complicated at all does it?
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
Easy.

Make a periodic trigger that is turned on by another trigger when a worker decides to build a structure.

So make an initially off trigger with the event : Event - Every 1.00 seconds of Game Time

and the actions will be: Unit - Set Mana of (your_worker unit) to (Current Mana of (your_worker unit) - 1.00)

See? Now I think you know how to find the value of the variable of your_worker unit, so I won't bother explaining it anymore.
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
dont forget to make this completely MUI otherwise it will bug up at times and not subtract mana from the unit when wanted. u should use indexing for this. hashtables should be ok if u really want to use them tho.

Of course! How could I have forgotten to mention that...

Anyways andreasaspenberg you should check out deathismyfriend's GUI tutorial... might help you too =)
 
Level 14
Joined
Oct 6, 2008
Messages
759
Erm...you can make them be summoned like undead buildings using mana by this way :
Use spellbook with no cooldown and inside put :
(for example) 8 spells that create a diffrent ward with summoned duration (the ward is our building being constructed timer, make it look like a construction in progress model). Each ward costs different mana as it is a different building.
Then use a simple trigger:
A unit dies
triggering unit equal to (ward type)
create unit - the actual building.
play sound - construction complete message for humans.

(Or even make it with no trigger - make each ward spawn a permanent unit uphon the ward's death - the unit being the building. base it off spawn hydra hatchlings)

So in total you need :
8 spells in a spellbook
8 wards for construction purposes - duration = construction time
8 buildings that spawn when each ward dies
8 triggers to spawn them (or no triggers if used spawn-spell)


That's a workaround that has its limitations but it is the easiest way.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Erm...you can make them be summoned like undead buildings using mana by this way :
Use spellbook with no cooldown and inside put :
(for example) 8 spells that create a diffrent ward with summoned duration (the ward is our building being constructed timer, make it look like a construction in progress model). Each ward costs different mana as it is a different building.
Then use a simple trigger:
A unit dies
triggering unit equal to (ward type)
create unit - the actual building.
play sound - construction complete message for humans.

(Or even make it with no trigger - make each ward spawn a permanent unit uphon the ward's death - the unit being the building. base it off spawn hydra hatchlings)

So in total you need :
8 spells in a spellbook
8 wards for construction purposes - duration = construction time
8 buildings that spawn when each ward dies
8 triggers to spawn them (or no triggers if used spawn-spell)


That's a workaround that has its limitations but it is the easiest way.

hmm thats a cool workaround i never knew u could do that.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Here's a test map.

Here's the list of fields that needs to be edited;
Data - Unit Created (per player race): Must be filled 4 times like what I did in the test map
Stats - Duration - Normal: Time taken for the building to be constructed
Stats - Mana Cost: Self-explanatory

All of these fields can be found in Object Editor -> Abilities Tab -> Build Cannon Tower
 

Attachments

  • Building Spell.w3x
    15.8 KB · Views: 66
Level 13
Joined
Mar 24, 2013
Messages
1,105
Assuming you mean you just want ALL the human buildings to cost mana to be built and you want the click "B" to open another menu and then blah blah--

This IS what you want, but you'll have to be a little innovative to make it seem as if it's the thing you actually want.
You'll need to make a spellbook with all the various buildings (What both me and defskull posted) inside of this spellbook and give this spellbook to the unit you'd like to build with.

I'll see if I can mend my test map to show you.

EDIT:
Hmm..Strange..even when basing off of different item abilities they all seem to build the first building in the spellbook... So I guess I'm incorrect, or not thinking properly atm. Hm I'll try to think about it more and come up with another solution.
 
Last edited:
Level 21
Joined
Mar 2, 2010
Messages
3,069
that is because they share the same base order ID. i made a trigger that you could take a look at. perhaps you can get it to work. /trigger blood elf
Events
Unit - A unit Begins construction
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Constructing structure)) Equal to Dragonhawk breader
Then - Actions
Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) - 200.00)
Else - Actions
Unit - Order (Triggering unit) to Stop
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
use trigger tags... http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/

  • blood elf
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructing structure)) Equal to Dragonhawk breader
        • Then - Actions
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) - 200.00)
        • Else - Actions
          • Unit - Order (Triggering unit) to Stop
heres a map of what u want it has a bug with the repair thing of the unit. dont have time to find a workaround atm.
 

Attachments

  • System Build buildings w mana.w3x
    13.1 KB · Views: 59
Level 21
Joined
Mar 2, 2010
Messages
3,069
i tried to use a trigger tag but i guess i did something wrong. that system you posted seems to work perfectly so it should work for the regular worker.(good system though. seems that you forgot to remove the lumber cost of one building.) the arcane worker on the other hand uses a different build system. that unit will use the undead build system.(other races have units that build as undead as well so not giving it to the blood elves will give them a disadvantage.) one of 2 problems are solved. i just found a problem: i cant copy variables from one map to another so that prevents me from copying your system from your map to mine. please add your system to my map for me.
 

Attachments

  • all races2.w3x
    1.5 MB · Views: 67
Last edited:
Level 29
Joined
Oct 24, 2012
Messages
6,543
the bug in that system is when u stop the unit from building. if u just right click on the building it doesnt register. but if u click the repair action then click the building it does register.
the other thing i didnt do is when a building is destroyed / removed in ur game u need to make a trigger so it unregisters that unit from the unit group.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
im not sure i didnt have enough time to find a workaround. u could tryq making ur own repair ability. If u trigger it and order unit to repair it might work but im not sure. like i said its only when a unit moves away and right clicks the building. if the unit moves away and then clicks the ability repair. then clicks the building it works fine.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
try this
  • Untitled Trigger 006
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Trigger - Turn Off ( this trigger)
      • Unit - Order (Ordered unit) to Human Peasant - Repair (Target unit of issued order)
      • Trigger - Turn On ( this trigger)
also u should limit this somehow. otherwise when a hero targets an enemy it will issue this to him.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
i dont understand why but that actually worked. the limits will be added later. that trigger is just a test to see if it works and now that it works i will add conditions. i have added condition but despite all buildings being a part of those some of them doesnt drain mana. what could cause that.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
  • Register Buildings
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Constructing structure)) Equal to Blood elf town hall
          • (Unit-type of (Constructing structure)) Equal to Altar of elven Kings (blood elf)
          • (Unit-type of (Constructing structure)) Equal to Lumber Mill (blood elf)
          • (Unit-type of (Constructing structure)) Equal to Blacksmith (Blood elf)
          • (Unit-type of (Constructing structure)) Equal to Arcane Sanctum (blood elf)
          • (Unit-type of (Constructing structure)) Equal to Blood Elf Farm
          • (Unit-type of (Constructing structure)) Equal to Dragonhawk breader
          • (Unit-type of (Constructing structure)) Equal to Blood Elf Barracks
    • Actions
      • Game - Display to (All players) the text: Registered.
      • Unit Group - Add (Constructing structure) to buildingGroup
      • Set buildingUnitCount = (buildingUnitCount + 1)
      • Trigger - Turn on Reduce Mana <gen>
  • Untitled Trigger 006
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Targeted unit)) Equal to Blood elf town hall
          • (Unit-type of (Targeted unit)) Equal to Altar of elven Kings (blood elf)
          • (Unit-type of (Targeted unit)) Equal to Dragonhawk breader
          • (Unit-type of (Targeted unit)) Equal to Arcane Sanctum (blood elf)
          • (Unit-type of (Targeted unit)) Equal to Blacksmith (Blood elf)
          • (Unit-type of (Targeted unit)) Equal to Lumber Mill (blood elf)
          • (Unit-type of (Targeted unit)) Equal to Blood Elf Farm
          • (Unit-type of (Targeted unit)) Equal to Blood Elf Barracks
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Order (Ordered unit) to Human Peasant - Repair (Target unit of issued order)
      • Trigger - Turn on (This trigger)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
im taking a look at it now. u have a lot to improve in ur map btw. never use dying unit. always use triggering unit.
get rid of all the do nothings also.

You should take a look at my tutorial it will help u to make ur map more efficient. http://www.hiveworkshop.com/forums/tutorial-submission-283/things-gui-user-should-know-233242/

The problem was that u never fixed the mistake u made that i told u about earlier...........

Edit: heres the map back and i put in a thing to stop the units if they have 0 mana. So they wont build anymore. you may have to adjust the time tho. 0.50 might not be fast enough to counter if someone keeps clicking on repair a building. Heres the map back.

You should really work on optimizing the triggers u already have. if u need help with that just post the triggers on here and ill help u optimize them.
 

Attachments

  • all races2.w3x
    1.5 MB · Views: 35
Level 21
Joined
Mar 2, 2010
Messages
3,069
i just want the bugs in the build system fixed so that i can finish the blood elves and perhaps add the gnolls if there is space for the models. please try to find out what is wrong. you are welcome to ask other users to help out though if you cant figure it out yourself.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
i doubt ill have the time to try to fix it. U just need to find out how to stop the unit from repairing when the units mana is empty. U can ask other to help. Like i said the system isnt complete and im not sure y the unit isnt stopping when he is ordered to stop. You might have to make ur own repair ability to do this.
 
Status
Not open for further replies.
Top