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

Unit Autocreating building

Status
Not open for further replies.
Level 4
Joined
Dec 2, 2011
Messages
76
I think I have put a this thread finally in the right spot.
I have made these two but I need help figuring out how to stop making the units completely or pick a different unit to make.
212827-albums5272-picture53750.png

212827-albums5272-picture53749.png

I need help making a building that has units and when you select one it will
create one every second or two and automatically subtracts gold every second
or two from your amount

Sorry about my many threads on this
 
Last edited:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Trigger - Add to One <gen> the event (Player - (Player((Integer A))) Selects a unit)
  • One
    • Events
    • Conditions
      • (Owner of (Triggering unit)) Equal to (Triggering player)
      • ((Triggering unit) is in Group) Equal to False
    • Actions
      • Unit Group - Add (Triggering unit) to Group
  • Two
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ((Triggering unit) is in Group) Equal to True
    • Actions
      • Unit - Order (Triggering unit) to train/upgrade to a (Unit-type of (Trained unit))
It's up to you to let the engine know when you want this to stop. Just remove the unit from the "Group" unit group.

Subtract the gold required. There is a GetUnitCostById() function somewhere in plain Jass; move it to the header of the map and then subtract that value, like:
  • Custom script: set udg_Cost = GetUnitCostById (GetUnitTypeId(GetTrainedUnit()))
  • Player - Add (-1 x Cost) to (Triggering player) Current gold
"Cost" is an Integer variable.
 
Level 4
Joined
Dec 2, 2011
Messages
76
I'll look into that, thank you.
how would I make it stop if you clicked the cancel button?
Just if cancel button clicked take unit out of group?
Where do I find GetUnitCostById()?
I have searched the forum and can't find it.

sorry, I'm new at this and I don't know much about how this stuff works
 
unit types are just integers so instead of arrays and if you dont want random, then save a
unit type into a hashtable, then load it in the creation...
  • Custom script: call SaveInteger(udg_Hash, udg_ID, 9, 'hpea')
  • Custom script: set udg_UType = LoadInteger(udg_Hash, udg_ID, 9)
  • Unit - Create 1 UType for (Owner of U) at Loc facing Default building facing degrees
 
Status
Not open for further replies.
Top