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

Referring to the unit constructing the construction

Status
Not open for further replies.
Level 9
Joined
Jul 30, 2018
Messages
445
Hey!

I have a stupid problem. When a unit starts constructing a building, I should then check, if the unit constructing the building (i.e. the peon / peasant / etc) has enough mana.

Problem is, if I use trigger "A unit begins construction" and then constructing unit or triggering unit, they both actually refer to the unit being built (like a tower, for example), not to the one building the building.

So, is there some other unit variable or event, that I could use to "catch" the unit building the building, or is there perhaps some other way to add mana cost for building?
 
Level 9
Joined
Jul 30, 2018
Messages
445
Thanks a lot! I'll look into those.

Edit:
On a quick look, that all looks awfully more complicated than I thought.. :D Maybe I'll just fake it by making everyone use the human building system, since humans basically build by repairing and simply adding mana cost to Repair ability does the trick. Thanks for your help anyway! :)
 
Last edited:
Level 7
Joined
Apr 17, 2017
Messages
316
Or you can fake your building system.
If you dont want complicated things there are 2 ways.
1- Create a SpellBook ability and Create town hall ability change them to unit abilities. Add your town hall ability to your spellbook. Set it's manacost. But this way, your worker can't repair it while under construction.
2- You can use these triggers but you need some kind of unit indexing system because if more than 1 worker builds a structure at the same time it won't work. Anyways :

to find the order of a building use your worker to build a structure there will be numbers appearing on your screen with these triggers:

  • Finding the order ID
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Custom script: call BJDebugMsg(I2S(GetIssuedOrderId()))



  • Finding the worker
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Custom script: set udg_issueidfortownhall = GetIssuedOrderId()
      • Custom script: if udg_issueidfortownhall == 1747988528 then
      • Custom script: set udg_worker = GetTriggerUnit()
      • Trigger - Turn on Manacost <gen>
      • Custom script: endif
To those who wonder why did I use custom if statement, simply because building order ids have 9 digits or more, when you use integer if statement in gui your numbers get messed up after 7 digits don't know why.

  • Manacost
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Constructing structure)) Equal to Town Hall
    • Actions
      • Set townhall = (Triggering unit)
      • Unit - Set mana of worker to ((Mana of worker) - 100.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of worker) Less than 100.00
        • Then - Actions
          • Unit - Kill townhall
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Level 9
Joined
Jul 30, 2018
Messages
445
Or you can fake your building system.
If you dont want complicated things there are 2 ways.
1- Create a SpellBook ability and Create town hall ability change them to unit abilities. Add your town hall ability to your spellbook. Set it's manacost. But this way, your worker can't repair it while under construction.
2- You can use these triggers but you need some kind of unit indexing system because if more than 1 worker builds a structure at the same time it won't work. Anyways :

to find the order of a building use your worker to build a structure there will be numbers appearing on your screen with these triggers:

  • Finding the order ID
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Custom script: call BJDebugMsg(I2S(GetIssuedOrderId()))



  • Finding the worker
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Custom script: set udg_issueidfortownhall = GetIssuedOrderId()
      • Custom script: if udg_issueidfortownhall == 1747988528 then
      • Custom script: set udg_worker = GetTriggerUnit()
      • Trigger - Turn on Manacost <gen>
      • Custom script: endif
To those who wonder why did I use custom if statement, simply because building order ids have 9 digits or more, when you use integer if statement in gui your numbers get messed up after 7 digits don't know why.

  • Manacost
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Constructing structure)) Equal to Town Hall
    • Actions
      • Set townhall = (Triggering unit)
      • Unit - Set mana of worker to ((Mana of worker) - 100.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of worker) Less than 100.00
        • Then - Actions
          • Unit - Kill townhall
          • Trigger - Turn off (This trigger)
        • Else - Actions

Great! Thanks! :)
 
Status
Not open for further replies.
Top