Snippet Building Builder

Prozix

New Member
Reaction score
7
Hi there, it's me again.

This time I'm on the forums because I'd like to save you some time. The next snippet allows you to create buildings very easily and rapidly. It requires:
  • Newgen
which should come with ObjectMerger.

JASS:

//---HEADER---
// This file was made by Prozix. 
// It contain's macros to facilitate building creation with object merger
// Example code is in the Example trigger and a more descriptive copyable example beneath the library code
// Fictional Example is only possible when textmacro's will be able to run other textmacro's, which was not possible at the time of creation of this library
// Couldn't have done this withoud Azlier's tutorial on ObjectMerger
// Enjoy

//---FILE TEXTMACRO'S---
//do not touch this unless you know what you are doing
//please report any bugs or errors you may discover on the thehelper forums

//! textmacro MakeChangeArt takes BTNX, BTNY, GROUND_TEX, ICON, MODEL, SCALE, SELECTION_SCALE, SHADOW_TEX
//! i makechange(current, "ubpx", $BTNX$)
//! i makechange(current, "ubpy", $BTNY$)
//! i makechange(current, "uubs", "$GROUND_TEX$")
//! i makechange(current, "uico", "$ICON$")
//! i makechange(current, "umdl", "$MODEL$")
//! i makechange(current, "usca", $SCALE$)
//! i makechange(current, "ussc", $SELECTION_SCALE$)
//! i makechange(current, "ushb", "$SHADOW_TEX$")
//! endtextmacro

//! textmacro MakeChangeColor takes R, G, B
//! i makechange(current, "uclr", $R$)
//! i makechange(current, "uclg", $G$)
//! i makechange(current, "uclb", $B$)
//! endtextmacro

//! textmacro MakeChangeCombat takes DEATH_TYPE, DEFENSE_BASE, DEFENSE_TYPE
//! i makechange(current, "udea", $DEATH_TYPE$)
//! i makechange(current, "udef", $DEFENSE_BASE$)
//! i makechange(current, "udty", "$DEFENSE_TYPE$")
//! endtextmacro

//! textmacro MakeChangePathing takes COLLISION_SIZE, PATHING_MAP
//! i makechange(current, "ucol", $COLLISION_SIZE$)
//! i makechange(current, "upat", "$PATHING_MAP$")
//! endtextmacro

//! textmacro MakeChangeSound takes CONSTRUCTION_SOUNDSET, UNIT_SOUNDSET
//! i makechange(current, "ubsl", "$CONSTRUCTION_SOUNDSET$")
//! i makechange(current, "usnd", "$UNIT_SOUNDSET$")
//! endtextmacro

//! textmacro MakeChangeFood takes FOOD_PRODUCED, FOOD_COST
//! i makechange(current, "ufoo", $FOOD_COST$)
//! i makechange(current, "ufma", $FOOD_PRODUCED$)
//! endtextmacro

//! textmacro MakeChangeStatsBuild takes BUILD_GOLD, BUILD_LUMBER, BUILD_TIME
//! i makechange(current, "ugol", $BUILD_GOLD$)
//! i makechange(current, "ulum", $BUILD_LUMBER$)
//! i makechange(current, "ubld", $BUILD_TIME$)
//! endtextmacro

//! textmacro MakeChangeStatsRepair takes REPAIR_GOLD, REPAIR_LUMBER, REPAIR_TIME
//! i makechange(current, "ugor", $REPAIR_GOLD$)
//! i makechange(current, "ulur", $REPAIR_LUMBER$)
//! i makechange(current, "urtm", $REPAIR_TIME$)
//! endtextmacro

//! textmacro MakeChangeStats takes HP_BASE, HP_REGEN, HP_REGENTYPE, MP_INITIAL, MP_BASE, MP_REGEN
//! i makechange(current, "uhpm", $HP_BASE$)
//! i makechange(current, "uhpr", $HP_REGEN$)
//! i makechange(current, "uhrt", "$HP_REGENTYPE$")

//! i makechange(current, "umpi", $MP_INITIAL$)
//! i makechange(current, "umpm", $MP_BASE$)
//! i makechange(current, "umpr", $MP_REGEN$)
//! endtextmacro

//! textmacro MakeChangeStatsExtra takes HIDE_DISPLAY, SHOW_ICON, RACE, SIGHT_DAY, SIGHT_NIGHT
//! i makechange(current, "uhom", $HIDE_DISPLAY$)
//! i makechange(current, "unbm", $SHOW_ICON$)
//! i makechange(current, "urac", "$RACE$")
//! i makechange(current, "usid", $SIGHT_DAY$)
//! i makechange(current, "usin", $SIGHT_NIGHT$)
//! endtextmacro 

//! textmacro MakeChangeTechtreeItems takes ITEMS_MADE, ITEMS_SOLD
//! i makechange(current, "umki", "$ITEMS_MADE$")
//! i makechange(current, "usei", "$ITEMS_SOLD$")
//! endtextmacro

//! textmacro MakeChangeTechtreeUnits takes UNITS_SOLD, UNITS_TRAINED
//! i makechange(current, "useu", "$UNITS_SOLD$")
//! i makechange(current, "utra", "$UNITS_TRAINED$")
//! endtextmacro

//! textmacro MakeChangeTechtreeUpgrades takes UPGRADES_TO, UPGRADES_USED
//! i makechange(current, "uupt", "$UPGRADES_TO$")
//! i makechange(current, "upgr", "$UPGRADES_USED$")
//! endtextmacro

//! textmacro MakeChangeTechtree takes TECHTREE_REQ, TECHTREE_LVLS, RESEARCHES_AVAILABLE, REVIVES_HEROES
//! i makechange(current, "ureq", "$TECHTREE_REQ$")
//! i makechange(current, "urqa", "$TECHTREE_LVLS$")
//! i makechange(current, "ures", "$RESEARCHES_AVAILABLE$")
//! i makechange(current, "urev", $REVIVES_HEROES$)
//! endtextmacro

//! textmacro MakeChangeText takes HOTKEY, NAME, EDITOR_SUFFIX, TOOLTIP_BASIC, TOOLTIP_EXTENDED
//! i makechange(current, "uhot", "$HOTKEY$")
//! i makechange(current, "unam", "$NAME$")
//! i makechange(current, "unsf", "$EDITOR_SUFFIX$")
//! i makechange(current, "utip", "$TOOLTIP_BASIC$")
//! i makechange(current, "utub", "$TOOLTIP_EXTENDED$")
//! endtextmacro

//! textmacro MakeChangeTextAuto takes HOTKEY, NAME, EDITOR_SUFFIX, TOOLTIP_EXTENDED, COLOR_HOTKEY
//! i makechange(current, "uhot", "$HOTKEY$")
//! i makechange(current, "unam", "$NAME$")
//! i makechange(current, "unsf", "$EDITOR_SUFFIX$")
//! i makechange(current, "utip", "Build $NAME$ |cff$COLOR_HOTKEY$\($HOTKEY$\)|r")
//! i makechange(current, "utub", "$TOOLTIP_EXTENDED$")
//! endtextmacro

//! textmacro MakeBuilding takes BASEID, NEWID
//! i setobjecttype("units")
//! i createobject("$BASEID$", "$NEWID$")
//! endtextmacro

//---EXAMPLE CODE---
/*
//! externalblock extension=lua ObjectMerger $FILENAME$
///! runtextmacro MakeBuilding("BASE_ID", "NEW_ID")
//! runtextmacro MakeBuilding("hhou", "hH01")

///! runtextmacro MakeChangeArt("BTNX", "BTNY", "GROUND_TEX", "ICON", "MODEL", "SCALE", "SELECTION_SCALE", "SHADOW_TEX") //be sure to use \\ in file paths for \
//! runtextmacro MakeChangeArt("1", "1", "HSMA", "ReplaceableTextures\\CommandButtons\\BTNFireBolt.blp", "buildings\\human\\GryphonAviary\\GryphonAviary.mdl", "0.76", "1.0", "ShadowHouse")

///! runtextmacro MakeChangeColor("RED", "GREEN", "BLUE") //RGB 0-255
//! runtextmacro MakeChangeColor("255", "50", "130")

///! runtextmacro MakeChangeCombat("DEATH_TYPE", "DEFENSE_BASE", "DEFENSE_TYPE") //DEATH_TYPE 0-3, DEFENSE_TYPE normal, small, medium, large, fort, hero, devine, none
//! runtextmacro MakeChangeCombat("0", "50", "hero")

/// runtextmacro MakeChangePathing("COLLISION_SIZE", "PATHING_MAP")
//! runtextmacro MakeChangePathing("64", "PathTextures\\4x4SimpleSolid.tga")

///! runtextmacro MakeChangeSound("CONSTRUCTION_SOUNDSET", "UNIT_SOUNDSET")
//! runtextmacro MakeChangeSound("BuildingConstructionLoop", "Farm")

///! runtextmacro MakeChangeFood("FOOD_PRODUCED", "FOOD_COST")
//! runtextmacro MakeChangeFood("12", "0")

///! runtextmacro MakeChangeStatsBuild("BUILD_GOLD", "BUILD_LUMBER", "BUILD_TIME")
//! runtextmacro MakeChangeStatsBuild("200", "20", "10")

///! runtextmacro MakeChangeStatsRepair("REPAIR_GOLD", "REPAIR_LUMBER", "REPAIR_TIME")
//! runtextmacro MakeChangeStatsRepair("200", "20", "10")

///! runtextmacro MakeChangeStats HP_BASE", "HP_REGEN", "HP_REGENTYPE", "MP_INITIAL", "MP_BASE", "MP_REGEN") REGENTYPE none, always, blight, day, night
//! runtextmacro MakeChangeStats("500", "5", "always", "2000", "20000", "100")

///! runtextmacro MakeChangeStatsExtra("HIDE_DISPLAY", "SHOW_ICON", "RACE", "SIGHT_DAY", "SIGHT_NIGHT")
//! runtextmacro MakeChangeStatsExtra("0", "0", "human", "700", "700")

///! runtextmacro MakeChangeTechtreeItems("ITEMS_MADE", "ITEMS_SOLD")
//! runtextmacro MakeChangeTechtreeItems("modt,ratf", "rde1")

///! runtextmacro MakeChangeTechtreeUnits("UNITS_SOLD", "UNITS_TRAINED")
//! runtextmacro MakeChangeTechtreeUnits("", "")

///! runtextmacro MakeChangeTechtreeUpgrades("UPGRADES_TO", "UPGRADES_USED")
//! runtextmacro MakeChangeTechtreeUpgrades("", "")

///! runtextmacro MakeChangeTechtree("TECHTREE_REQ", "TECHTREE_LVLS", "RESEARCHES_AVAILABLE", "REVIVES_HEROES")
//! runtextmacro MakeChangeTechtree("", "", "", "0")

///! runtextmacro MakeChangeText("HOTKEY", "NAME", "EDITOR_SUFFIX", "TOOLTIP_BASIC", "TOOLTIP_EXTENDED")
//You can use this one, but the next one does the same with some automatic stuff

///! runtextmacro MakeChangeTextAuto("HOTKEY", "NAME", "EDITOR_SUFFIX", "TOOLTIP_EXTENDED", "COLOR_HOTKEY")
//! runtextmacro MakeChangeTextAuto("F", "Heavy Farm", "", "Provides food for heavy peasants. ", "ffcc00")

//! endexternalblock
*/


An example script which creates 4 buildings:
JASS:

//GOAL: we are going to create 4 farm like buildings that can upgrade into each other

//This needs to be added before using the Building textmacro's
//! externalblock extension=lua ObjectMerger $FILENAME$

//base heavy farm
//! runtextmacro MakeBuilding("hhou", "hH01")
//! runtextmacro MakeChangeArt("0", "2", "HSMA", "ReplaceableTextures\\CommandButtons\\BTNFireBolt.blp", "buildings\\human\\GryphonAviary\\GryphonAviary.mdl", "0.76", "1.0", "ShadowHouse")
//! runtextmacro MakeChangeColor("255", "0", "130")
//! runtextmacro MakeChangeCombat("0", "50", "hero")
//! runtextmacro MakeChangePathing("64", "PathTextures\\4x4SimpleSolid.tga")
//! runtextmacro MakeChangeSound("BuildingConstructionLoop", "Farm")
//! runtextmacro MakeChangeFood("6", "0")
//! runtextmacro MakeChangeStatsBuild("200", "20", "1")
//! runtextmacro MakeChangeStatsRepair("200", "20", "1")
//! runtextmacro MakeChangeStats("500", "5", "always", "2000", "20000", "100")
//! runtextmacro MakeChangeStatsExtra("0", "0", "human", "700", "700")
//! runtextmacro MakeChangeTechtreeItems("", "")
//! runtextmacro MakeChangeTechtreeUnits("", "")
//! runtextmacro MakeChangeTechtreeUpgrades("hH02", "")
//! runtextmacro MakeChangeTechtree("", "", "", "0")
//! runtextmacro MakeChangeTextAuto("F", "Heavy Farm lvl 1", "", "Provides food for heavy peasants. ", "ffcc00")

//heavy farm lvl 2
//! runtextmacro MakeBuilding("hH01", "hH02")
//! runtextmacro MakeChangeColor("255", "50", "160")
//! runtextmacro MakeChangeFood("12", "0")
//! runtextmacro MakeChangeTechtreeUpgrades("hH03", "")
//! runtextmacro MakeChangeTextAuto("F", "Heavy Farm lvl 2", "", "Provides food for heavy peasants. ", "ffcc00")

//heavy farm lvl 3
//! runtextmacro MakeBuilding("hH01", "hH03")
//! runtextmacro MakeChangeColor("255", "100", "190")
//! runtextmacro MakeChangeFood("18", "0")
//! runtextmacro MakeChangeTechtreeUpgrades("hH04", "")
//! runtextmacro MakeChangeTextAuto("F", "Heavy Farm lvl 3", "", "Provides food for heavy peasants. ", "ffcc00")

//heavy farm lvl 4
//! runtextmacro MakeBuilding("hH01", "hH04")
//! runtextmacro MakeChangeColor("255", "150", "220")
//! runtextmacro MakeChangeFood("24", "0")
//! runtextmacro MakeChangeTechtreeUpgrades("", "")
//! runtextmacro MakeChangeTextAuto("F", "Heavy Farm lvl 4", "", "Provides food for heavy peasants. ", "ffcc00")

//and this line ends the external block
//! endexternalblock


of course, I have included a demo map.

Beware that I haven't tested everything thoroughly so there might be some minor errors I haven't discovered yet.
Please let me know if you have an idea or if you discovered something that doesn't work correctly.

Greetz, Prozix
 

Attachments

  • TextMacroBuilding.w3x
    17.4 KB · Views: 273

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
It's not a bad idea. But needs better documentation, for starters.
 

Prozix

New Member
Reaction score
7
Should I write that someone who wants to use this should copy this

JASS:

//! externalblock extension=lua ObjectMerger $FILENAME$
///! runtextmacro MakeBuilding("BASE_ID", "NEW_ID")
//! runtextmacro MakeBuilding("hhou", "hH01")

///! runtextmacro MakeChangeArt("BTNX", "BTNY", "GROUND_TEX", "ICON", "MODEL", "SCALE", "SELECTION_SCALE", "SHADOW_TEX") //be sure to use \\ in file paths for \
//! runtextmacro MakeChangeArt("1", "1", "HSMA", "ReplaceableTextures\\CommandButtons\\BTNFireBolt.blp", "buildings\\human\\GryphonAviary\\GryphonAviary.mdl", "0.76", "1.0", "ShadowHouse")

///! runtextmacro MakeChangeColor("RED", "GREEN", "BLUE") //RGB 0-255
//! runtextmacro MakeChangeColor("255", "50", "130")

///! runtextmacro MakeChangeCombat("DEATH_TYPE", "DEFENSE_BASE", "DEFENSE_TYPE") //DEATH_TYPE 0-3, DEFENSE_TYPE normal, small, medium, large, fort, hero, devine, none
//! runtextmacro MakeChangeCombat("0", "50", "hero")

/// runtextmacro MakeChangePathing("COLLISION_SIZE", "PATHING_MAP")
//! runtextmacro MakeChangePathing("64", "PathTextures\\4x4SimpleSolid.tga")

///! runtextmacro MakeChangeSound("CONSTRUCTION_SOUNDSET", "UNIT_SOUNDSET")
//! runtextmacro MakeChangeSound("BuildingConstructionLoop", "Farm")

///! runtextmacro MakeChangeFood("FOOD_PRODUCED", "FOOD_COST")
//! runtextmacro MakeChangeFood("12", "0")

///! runtextmacro MakeChangeStatsBuild("BUILD_GOLD", "BUILD_LUMBER", "BUILD_TIME")
//! runtextmacro MakeChangeStatsBuild("200", "20", "10")

///! runtextmacro MakeChangeStatsRepair("REPAIR_GOLD", "REPAIR_LUMBER", "REPAIR_TIME")
//! runtextmacro MakeChangeStatsRepair("200", "20", "10")

///! runtextmacro MakeChangeStats HP_BASE", "HP_REGEN", "HP_REGENTYPE", "MP_INITIAL", "MP_BASE", "MP_REGEN") REGENTYPE none, always, blight, day, night
//! runtextmacro MakeChangeStats("500", "5", "always", "2000", "20000", "100")

///! runtextmacro MakeChangeStatsExtra("HIDE_DISPLAY", "SHOW_ICON", "RACE", "SIGHT_DAY", "SIGHT_NIGHT")
//! runtextmacro MakeChangeStatsExtra("0", "0", "human", "700", "700")

///! runtextmacro MakeChangeTechtreeItems("ITEMS_MADE", "ITEMS_SOLD")
//! runtextmacro MakeChangeTechtreeItems("modt,ratf", "rde1")

///! runtextmacro MakeChangeTechtreeUnits("UNITS_SOLD", "UNITS_TRAINED")
//! runtextmacro MakeChangeTechtreeUnits("", "")

///! runtextmacro MakeChangeTechtreeUpgrades("UPGRADES_TO", "UPGRADES_USED")
//! runtextmacro MakeChangeTechtreeUpgrades("", "")

///! runtextmacro MakeChangeTechtree("TECHTREE_REQ", "TECHTREE_LVLS", "RESEARCHES_AVAILABLE", "REVIVES_HEROES")
//! runtextmacro MakeChangeTechtree("", "", "", "0")

///! runtextmacro MakeChangeText("HOTKEY", "NAME", "EDITOR_SUFFIX", "TOOLTIP_BASIC", "TOOLTIP_EXTENDED")
//You can use this one, but the next one does the same with some automatic stuff

///! runtextmacro MakeChangeTextAuto("HOTKEY", "NAME", "EDITOR_SUFFIX", "TOOLTIP_EXTENDED", "COLOR_HOTKEY")
//! runtextmacro MakeChangeTextAuto("F", "Heavy Farm", "", "Provides food for heavy peasants. ", "ffcc00")

//! endexternalblock


and then adjust it to his needs in the documentation? I know this doesn't have one of those beautiful headers but it doesn't need it. If you want to know how to use the ObjectMerger and understand it's commands: tuntuntun. I don't know what you would like too see.
 

Laiev

Hey Listen!!
Reaction score
188
I don't like much the [ljass]//! textmacro[/ljass] but if I use some "rmk" mode in my map, of course I'll use it.
 

Kenny

Back for now.
Reaction score
202
> How is this in any way faster than using the object editor?

Indeed. You still have to go and change everything that you would in the object editor. Plus most users will have to reference the editor just to use this.

Seems like it would be a fair bit slower, unless you are willing to memorise the majority of the fields in the object editor for units.
 

tooltiperror

Super Moderator
Reaction score
231
Very good idea in theory.

When I`m going to be making lots of very similar things, like ten pieces of armor, I will use object merger. But for this? No.
 

Prozix

New Member
Reaction score
7
Well, I personally hate searching for values, waiting untill I've got a copy of a unit and doing the same stuff over and over again.
So if I wan't to create a map which has about 500 upgradeable buildings, I'd want to use something like this. For small amounts of buildings that aren't similar at all, I wouldn't use this either ofcourse because you can do it in the object editor.
Aditionally, using the object merger's normal new unit command is a lot slower than using the lua thing. So instead of having to search for the same
//! i makechange(current, "ubpx", $BTNX$)
//! i makechange(current, "ubpy", $BTNY$)
//! i makechange(current, "uubs", "$GROUND_TEX$")
//! i makechange(current, "uico", "$ICON$")
field value codes every single time untill you remember them (or get mad and quit editing), you can use the textmacro's.
 

Azlier

Old World Ghost
Reaction score
461
This would have real uses if textmacros could run other textmacros...

But sadly they can't. Unless you're Jesus4Lyf and spend your time abusing vJass, of course.
 

Prozix

New Member
Reaction score
7
Hahah, if you download the map there is an example trigger: fictional example
It tries to do what you said, I discovered that having textmacro's run other textmacro's wasn't possible at this time.

I solved it by making a base unit that has most stats set correctly, and then base other units on that so that you have to change only a couple of things. That is why I split the textmacro's in several parts, so you can adjust only what you need to. (or a tiny little bit more)
 

tooltiperror

Super Moderator
Reaction score
231
I`m just going to throw this out there, when developing a TD, this could be extremely useful.

Edit: That gives me an idea, you could create a system for creating Towers quickly, and find a way to make it easy to code the towers attacks with a custom event type thing.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top