PDA

View Full Version : Advanced Coding: New Buildings & the Advanced Build Menu



Octopus Rex
22nd Oct 07, 5:24 PM
Rating: Rookie to Competent

Warning - I won't be going as slow as the AE basics in this.

A common question asked is "how do I add new buildings? I've created a new EBPS for them but I can't get it to show in the build list". Well, here's where I will answer that.

Powers of Observation

The build list is populated by all the buildings in a race's structures folder (yes, all, even the single player ones, you'll see). You don't have to do anything, the build list will populate itself automatically from the structures folder. "But my building still doesn't appear!" - where most people fail with this is simple observation and maths (use your brains please guys! :)). Take space marines for example, they have 11 buildable structures. When you click on the build button those 11 building icons appear, and the 12th slot is filled with the 'back' arrow.

http://mods.octopusrex.co.uk/content/buildings/buildings1.jpg
Fig 1. - a full menu

When you make your new, 12th building there is, of course, no room for it to appear. Where exactly were you expecting it to magic itself to? Somewhere else on the user interface? The reinforcement box? Squeezed inbetween some other build icons? :) Try it with Orks and it'll work out for you as they have a couple of spaces left.

A Problem of Space

So the problem now is one of space. The solution to this is that there is already a second build menu coded, the advanced build menu. Take a look in the structure_buildable_ext on the entity files for the buildings and you will see that there is an 'advanced_build_option' tick box. If that is ticked then the building will not appear in the basic build menu, but it will appear in the advanced build menu. This is where all the single player buildings that you see in the AE have gone, check them, they'll all have the advanced_build_option ticked. Buildings will appear on either the advanced menu or the basic one, but they will not appear on both.

Right, well now we know that there is extra space, we just have to get access to it. To do this we need a file from the archives (go here (http://forums.relicnews.com/showthread.php?t=155067) for how to extract them). Extract DXP2data.sga (you may have done this already for another mod as it's a very useful archive). Inside the extraction open up 'game' folder. There's a file in there called taskbar.lua, copy and paste that file into yourmod/data/game i.e. a replica position within your own mod folder, you'll need to create the game folder yourself. Now open it up with a text editor and we can get working. (More on folder trees here)

The advanced build menu appears as another button next to the normal build one that you click on to bring up a different menu. There's two things you need to change to get this working:

First - there's a command that tells the UI where this button should go. Currently it's commented out and is having no effect, all we need to do is remove the comments for it to kick in. You need to find this line:

-- build_adv = list_commands[6], Best to search for it with CTRL + F as the text document is quite big. Then change that line to:

build_adv = list_commands[9], (Please note that tabs don't work on these forums - the code will appear differently in the lua) All we've done is remove those two dashes at the beginning and changed the number from 6 to 9. The reasons we've changed the number is because that number dictates which slot out of the 12 icon slots it goes in. 6 is actually already taken up with the repair button, so if we want it to be seen we should move it to an empty slot. Slot 9 is empty on all the builders and is next to the normal build button, so that will do nicely.

Second - we need to UNcomment one more line.

--{ bind = "build_structures_menu", hk = "buildadv", ui = commandsmall_buttons.build_adv, texture = "command_icons/build_structure_advanced", submenu = submenu_structures_advanced, tt = tooltip_simple_template, tt_title = "$40910", tt_desc = "$40911" },Simply remove the comments only this time.

{ bind = "build_structures_menu", hk = "buildadv", ui = commandsmall_buttons.build_adv, texture = "command_icons/build_structure_advanced", submenu = submenu_structures_advanced, tt = tooltip_simple_template, tt_title = "$40910", tt_desc = "$40911" },.

Okay, now save it and fire up the game. All your builders will now have that extra build menu with a dull grey icon.

http://mods.octopusrex.co.uk/content/buildings/buildings4.gif
Fig 2. - Yuk!

Open it up and you may see one or two building in there that look familiar, these will be the single player buildings, this is where they have gone (aaaahhh! I see!). So, now you can tick some other building's advanced_build_option in the AE and see how they move across to the new menu (remember you'll need to save binary for this to take effect). We'll sort those random buildings out in a moment.

http://mods.octopusrex.co.uk/content//buildings/buildings2.jpg
Fig 3. - the mythical Tau Turrets ready to be built

Race Specific

AH YES, BUT: - you only need/want the advanced build menu on ONE race right? Not a problem. If we look at some other parts of the taskbar.lua then we see that some bits of code are race specific. This is acheived by using this line
{ bind = "selector_player_race",
}and then listing a race like this:
tau = {
},Any races not listed are dealt with using this coverall stuck at the end
other = {
},The code that you want to apply to a race, i.e. that bit about advanced build menu, goes in between those curly brackets and all of that goes in between the race selector code brackets.

So to make it work for say only Eldar the full code would be:

{ bind = "selector_player_race",
eldar = {
{ bind = "build_structures_menu", hk = "buildadv", ui = commandsmall_buttons.build_adv, texture = "command_icons/build_structure_advanced", submenu = submenu_structures_advanced, tt = tooltip_simple_template, tt_title = "$40910", tt_desc = "$40911" },
},
other = {
},
},If you want it to work for more than one then just list them as well like the eldar (i.e. copy and paste and just change the race name). The race names are the same as those on the EBPS or SBPS folders (attrib/SBSP/races). Save it.

So we still have one problem - unwanted single player buildings that are weird duplicates. Easy to fix, pick one you want to get rid of and simply set all the requirements in the building's requirement_ext to none, then change one requirement to required_structure and choose a structure from another race, then do the same again in a second requirement field, but this time tick the display_requirement box also. EG - set the Tau turret to require the Chaos HQ. This way you will never be able to build it as you will never have a building from another race, and it will never display either for the same reason. Repeat this for any other offending buildings you still have.

If you want to change the tooltips for it then you can just edit them in that long line of code we messed with, there's one for the name and one for the description.

And there you have it really. Here's a little build icon (http://mods.octopusrex.co.uk/content/buildings/snazzy_build_icon.tga) that I whipped up for no real reason. Use it if you like. The location and name for it is contained in the long line of code we UNcommented, I'll leave you to sort that out (icons tutorial here (http://forums.relicnews.com/showthread.php?t=161043) - the icon will go in yourmod/data/art/ui/ingame/command_icons).

http://mods.octopusrex.co.uk/content/buildings/buildings3.jpg
Fig 4. - my little icon, use and abuse people

Thanks to - Compiler for figuring this out long before I even began modding, I only know how to do this through dissecting his work.

edvin76
22nd Oct 07, 6:22 PM
hey Rex, your tutorials are fantastic, i love you! :hug:
can you make one how to make new units appear on a building's build list? i think im just clumsy, but i didnt find a tutorial about this
(i know its havent actually, but this is part of my campaign to simplify English language haha :science: )

Gorb
23rd Oct 07, 2:38 AM
Once again you amaze me Octo, keep up the superb work!

And that icon looks great, much better than the dull grey default :)

edvin76
26th Oct 07, 6:39 AM
ok, ive found on one of the Skins@HiveWorldTerra Tutorials (http://skins.hiveworldterra.co.uk/Article/view_AddingModelsToDawnOfWar_pg4.html) how to add he unit to the build list in the building:


Assuming your making a new marine as stated in this tutorial go to "Dawn of War\mymod\data\attrib\ebps\races\space_marines\structures\space_marine_barracks.lua" (what you dont have that file? go and get it from your extracted sga-s then!)

Look for the lines look like this:
GameData["spawner_ext"]["squad_table"]["squad_01"] = "space_marine_squad_force_commander"
GameData["spawner_ext"]["squad_table"]["squad_02"] = "space_marine_squad_tactical"
GameData["spawner_ext"]["squad_table"]["squad_03"] = "space_marine_squad_assault"
GameData["spawner_ext"]["squad_table"]["squad_04"] = "space_marine_squad_devastator"
GameData["spawner_ext"]["squad_table"]["squad_05"] = "space_marine_squad_terminator"
GameData["spawner_ext"]["squad_table"]["squad_06"] = "space_marine_squad_terminator_assault"
Add you unit to that list. You may have noticed my devastators have been added and its the SQUAD file name used here from the "Dawn of War\mymod\data\attrib\sbps\races\space_marines" folder.

this should be added to the end of your hypa-dypa squad making tut, hmm? :) Thank you for all your help Octo!!!!
:awesome:

Octopus Rex
26th Oct 07, 9:27 AM
....ummmm, yeah, maybe you should post it the squad tutorial then? :)

And no, I won't be adding it to the squads tutorial. 1. that information is already part of a tutorial on buildings that I'm working on, which is where it more rightly belongs. 2. Copy pasting other people's tutorial's is unnecesary, I should just link people to that tutorial instead.

Thanks anyway :)

horusheretic
26th Oct 07, 10:01 AM
another usefull tutorial worthy for immortalisation (hopefully:err: )

Unregistered
21st Dec 07, 10:19 AM
i try it out and it do not work :( y?

Octopus Rex
21st Dec 07, 10:31 AM
Um, you might have to give me a little bit more information than that, dude! :) If you want an answer right now I would guess that it's because you didn't follow the tutorial properly, or misinterpreted one of the steps.

Unregistered
21st Dec 07, 11:52 AM
soz i for to remove the comments my bad lol

fuggles
5th Feb 08, 12:47 AM
Sort of related to this - I have moved the eldar support platform into the ork ebps folder in my mod, and also deleted the mek_shop.lua with the intended result being that the mek shop was swapped for a scatter laser on the ork build menu. However... nothing has happened. In AE, the orks still have the mek shop listed and not the scatter laser.

Any advice?

Octopus Rex
5th Feb 08, 5:16 AM
The mekshop will still be listed because deleting won't do anything, it will still inherit from DXP2 or wherever, it won't burn a lack of lua in the data folder, this gap will just be overriden by the dxp2 archive.

As for the scatter laser, you will need to edit the inheritance path by hand, as it will stil be inheriting form eldar_building.nil at this point.

fuggles
5th Feb 08, 11:34 AM
That makes sense. I suppose I can untick it as buildable.

I've changed the eldar_support_platform_scatterlaser.lua to read
GameData = Inherit([[ebps\races\ork\structures\ork_building.nil]])
MetaData = InheritMeta([[ebps\races\ork\structures\ork_building.nil]])

Is that on the right lines?

Octopus Rex
5th Feb 08, 11:59 AM
ebps\races\orks\structures\ork_building.nil

fuggles
6th Feb 08, 5:03 AM
damn inflected languages - of course I read Eldar and took it to be singular.

Have changed it to plural and it's not working still. Strangely I have added new C2C units in before, buildings are obviously harder. Will it make a difference that I haven't renamed the eldarplatform? Shouldn't imagine so. It will have to wait until the weekend now anyway I guess :S

*goes off to search through other tuts for clues*

Daeval
18th Jul 08, 12:28 PM
I'm using advanced_build_option to make buildings unbuildable, but the skirmish mode AI seems to build them anyway if I wait long enough (the delay might just be it saving up resources, as I have them coming in really slow, I just thought of that).

Is there a better way to make them unbuildable for the AI? I guess I could set the cost prohibitively high, but there's got to be something more sensible?

Octopus Rex
18th Jul 08, 2:43 PM
Ai doesn't need to see the buildings to be able to build them.


Easy to fix, pick one you want to get rid of and simply set all the requirements in the building's requirement_ext to none, then change one requirement to required_structure and choose a structure from another race

fuggles
19th Jul 08, 12:42 AM
You could set the prerequisite to be impossible - orks need a mars pattern command to build a hut.

Octopus Rex
19th Jul 08, 1:30 AM
Dude, what did I just say? :)

Daeval
19th Jul 08, 1:51 AM
You got me, I must have skimmed that part. Now I'm one of those posters. :p

Thanks!

I have a wincondition that spawns a building that shouldn't otherwise be built, and was worried that a requirement would stop that from happening, but can confirm that it works fine, for any curious lurkers from the future.

fuggles
19th Jul 08, 2:18 AM
^^ rofl, sorry Octo.

Octopus Rex
19th Jul 08, 2:50 AM
He he, :)

Daevel - yeah, I can see why you'd think that'd be a problem. So basically does SCAR not pay attention to building requirements at all?

Another alternative would have been to edit the AI and remove the building from the build strategies.

fuggles
19th Jul 08, 3:09 AM
No - SCAR just does what you tell it.

"SCAR - give me 20 bloodthirster on this spot in about 12.3 seconds"

"As you wish master"

GROWL!!! FLAP FLAP FLAP.

CMC SoCygnus
10th Aug 08, 12:16 AM
awesome tutorial!:science:

asdarta
5th Feb 09, 7:10 PM
:lurk:

Can I do this in Corsix Mod Studio?

I been trying lots of stuffs now just to get the extra building menu... which all now fails...

Newb in need of help

Thanks in advance....

ChiefScout
26th Apr 09, 1:43 PM
hey octco,
great tutorial as usual, the've been a great help to me
question: is it possible to have one unit able to build only from the basic build menue and another build only from the adanced one?
e.g. working on the wolf lords mod and doing iron priest, who (in theory) can only built turetts while the thrall (sevitor) deals with all the other buildings. i need the thall to only have acsess to the basic menu and the iron priest to only have acsess to the advanced menu. is this even possible? any clue how it could be done? i have had a wee look and am guessing it would be an extension of the race specific section but exaccly how to do it is beyond me
thanks
Chief

Gorb
26th Apr 09, 1:55 PM
You can't do that. Either you have access to both build menus, or none at all (if you have the advanced menu enabled). You can't pick and choose, I'm afraid.

ChiefScout
27th Apr 09, 12:04 PM
damn, another plan is needed then
thanks anyway

neilmarines
24th Jul 09, 2:40 PM
Hi.

I have used the build advanced structures for the defensive structures for my mod "Dawn of War: Unlimited" for Dark Crusade, But is it possible to have three build menus, as i have managed to create a third structure menu by copying the advanced structure info in the taskbar.lua file and changed it to 'build_def' instead of 'build_adv' and changed the UI number to 10, although don`t know how the set the buildings that to be built in this menu, because there is only a "advanced build option = true" on the structures RGD files i added a new child "defensive build option = true" though nothing happened. :Question:

Neilmarines.

Gorb
24th Jul 09, 4:17 PM
You can't add a new child parameter and hope the game accepts it. There is no way to create a third menu and populate it with additional buildings because the hardcode (the code that makes the game work in the way it works) doesn't allow for that kind of flexibility.

neilmarines
25th Jul 09, 5:10 AM
Ok, thanks.

Juntao
12th Feb 13, 8:05 AM
Hi there, sorry to post in such an old thread, but I'm currently trying to add a second machine cult to the space marines, in order to add more vehicles eventually - the problem i'm having is i've followed the guide to the letter as far as i can tell but the sp buildings still appear... I have about half a dozen orbital relays and a stronghold that i just can't seem to get rid of, i changed 2 requirement fields in each building, set them to an unavailable building (chaos armory) and on the second ticked the display requirement box but no luck... can anyone help please? My mod has ground to a halt after a week of massive progress for such a noob modder!

Thanks very much for any suggestions/solutions guys!

jONES1979
12th Feb 13, 8:53 AM
but the sp buildings still appear... I have about half a dozen orbital relays and a stronghold that i just can't seem to get rid of, i changed 2 requirement fields in each building, set them to an unavailable building (chaos armory) and on the second ticked the display requirement box but no luck...

Yeah, you are on the right way, just need to set all requirements properly. Check, for example, how does it done in the Titanuim Wars Mod (http://www.moddb.com/mods/titanium-wars-mod).

Gorb
12th Feb 13, 9:52 AM
Juntao, you need to remove the requirement(s) that are checked as "is_display_requirement" - including any requirements Relic already had in the file(s). This causes the icon to be displayed if the requirement is not met.

Juntao
12th Feb 13, 10:32 AM
Sorry, but i've still had no luck, im looking in entity blueprints in AE, everything in requirements_ext is set to required_none except for requirements 1 and 2, both are set to require chaos armory, all requirement fields have the display_requirement box unchecked, but still they appear... I'm completely bamboozled... I'm clearly doing something wrong, any ideas? :)

Thanks again!

Juntao
12th Feb 13, 11:10 AM
I believe I've spotted the problem, for some reason AE opens DXP2, not my mod! *facepalm* will re-install modtools and try that...

Gorb
12th Feb 13, 11:12 AM
Also, you are burning these files from LUA to RGD, right? Or you're editing the RGDs directly? The RGD has to be affected for the change to make it ingame.

Juntao
12th Feb 13, 11:16 AM
Umm, I'm saving to binary, is that burning? Sorry but my knowledge peaked the second I opened AE :)
Again, thanks for all the help!

Gorb
12th Feb 13, 11:26 AM
Saving to binary should be doing it; check if your mod folder has RGD files in it. If it doesn't, do Save 1 to Binary or whatever the second option is.

Juntao
12th Feb 13, 12:02 PM
Yup, my has RGD's, just to check - is AE supposed to be opening the DXP2 files in the modtools folder? Pretty sure its not, as ive already used AE to add terminator sergeants to my mods data folder somewhere... Any idea whats causing this?
Sorry for the incessant questioning, but its hard to find someone to talk to and learn from!

Silly question, I think it should do now lol

Much appreciated!!

Juntao
12th Feb 13, 2:10 PM
Ok, finally cracked it!!!
I gave up entirely on AE and began fiddling with Corsix's mod tools, was able to set the requirements etc that way... Thanks so very much to you both for all your help, I would not have been able to progress without you! :)