PDA

View Full Version : Modding Add-ons/ Making Units


BlademasterSlsh
06-11-2008, 10:28 AM
I'm trying to make an add-on that creates different units depending on which building it is attached to. So far, I have been able to get a Barracks to build a Physics Lab add-on and attach to it, so I know I can do that part. My question is, is there a way for the Add-Ons to detect which building they are connected to?

This is not the same as the Siege Tank requiring the Machine Shop to be built.

What I want to happen:
Barracks creates or attaches to an add-on. The add-on then brings up a menu allowing it to build Marines or Firebats. The Barracks lifts off and a Factory attaches. The add-on brings up a menu allowing it to build Vultures and Goliaths. The Factory lifts off and a Starport attaches. The add-on brings up a menu allowing it to build Wraiths, Dropships, and Valkyries.

TheNomad
06-11-2008, 11:15 AM
yes, we follow the sc2 updates :P

if you want to do it properly, as in show diff buttons depending on what building it is attached to, u can't. they can only gray out. i didn't try but i think u can make diff master buildings for the same add-on, it's just that u have a limit of 9 units per add-on, unless u create sub-menus (which is kinda sucky IF u want to respect the sc stuff... if u wanna do it sc2-style, then if 9 buttons aren't enough, say 3 buttons per master building, just create sub menus).

The grafting should be Current Unit is X OR Current Unit is Y where X and Y are Factory/Barracks/etc. but that'd only work to actually build the add-on in theory.

But I didn't try, though it should work. Make sure you set the add-on offsets in DatEdit for the master buildings for proper gfx alignment.

But as for the detection of master buildings - no, only via ASM. And I am not sure even that works since I don't think the add-on can detect the master, I don't remember seeing a CUNIT pointer for that, only masters have a pointer to their add-ons (afaik).

Please keep in mind the SC1 engine is quite "primitive" and wasn't even planned for modding so us being able to do even the things we can now is not something Blizzard actually "wanted". There at least 50% of the things SC2 has which can't be put in SC1. Unless maybe via heavy exe reverse engineering (but even things like worm hole or time bomb wouldn't be do-able even then I think).

BlademasterSlsh
06-11-2008, 12:06 PM
yes, we follow the sc2 updates :P

if you want to do it properly, as in show diff buttons depending on what building it is attached to, u can't. they can only gray out. i didn't try but i think u can make diff master buildings for the same add-on, it's just that u have a limit of 9 units per add-on, unless u create sub-menus (which is kinda sucky IF u want to respect the sc stuff... if u wanna do it sc2-style, then if 9 buttons aren't enough, say 3 buttons per master building, just create sub menus).

Sub-menus will be fine for me, but I guess that leaves the question of how do I lock out certain sub-menus?


The grafting should be Current Unit is X OR Current Unit is Y where X and Y are Factory/Barracks/etc. but that'd only work to actually build the add-on in theory.

But I didn't try, though it should work. Make sure you set the add-on offsets in DatEdit for the master buildings for proper gfx alignment.


Managed to get that before I posted the question. I didn't have to mess around with add-on offsets, just plug in buttons for building add-ons in Firegraft (and the other behind the scenes stuff)


But as for the detection of master buildings - no, only via ASM. And I am not sure even that works since I don't think the add-on can detect the master, I don't remember seeing a CUNIT pointer for that, only masters have a pointer to their add-ons (afaik).

...what are ASM and CUNIT?


Please keep in mind the SC1 engine is quite "primitive" and wasn't even planned for modding so us being able to do even the things we can now is not something Blizzard actually "wanted". There at least 50% of the things SC2 has which can't be put in SC1. Unless maybe via heavy exe reverse engineering (but even things like worm hole or time bomb wouldn't be do-able even then I think).

I'm just getting my toes wet. I won't worry about spells or whatnot until I think I've got a better handle on the basics.

Durandal
06-11-2008, 1:57 PM
masters have a pointer to their add-ons (afaik).
Well... what if you made the "master buildings" into controllable flying addons, and the "Addon" into a regular building? :P

BlademasterSlsh
06-11-2008, 2:27 PM
Well... what if you made the "master buildings" into controllable flying addons, and the "Addon" into a regular building? :P

...I get the strange feeling I don't want to go down that road... ever...

I've managed to build the sub menus (right now I'm scrapping the other add-ons, so if anyone has a better way, tell me), but I still have the question of how to limit which sub-menu can be accessed when attached to what buildings...

[Edit] I also have the annoying little problem that it cant set rally points, but considering everything else is working so far I'm happy. :)

[Edit2] ... I spoke too soon. Although the Barracks, Factory, and Starport can all build and initially connect to Physics Labs and Machine Shops, only the top unit on the "Current unit is..." list can re-attach to the add-on. Any suggestions?

TheNomad
06-11-2008, 3:51 PM
...what are ASM and CUNIT?

If you don't know what asm is, then it's nothing you need to concern yourself about. ASM stends for Assembly Language (or Assembler as most call it for short) and... simply said, it's the language your processor "understands" when it executes any binary (from ocx to dll to exe).
CUNIT is the Unit structure, the Unit Class, if you will, that holds pointers to different objects or values (per short "variables").

A simple example in C++ would be (this is actually the way the class is organized in SC - tnx to DoA for showing me the components):

class CUnit :: CSCBase
{
CUnit *PrevUnit;
CUnit *NextUnit;
int UnitHP;
CSprite *Sprite;

[...]
}

Then it's accessed like this:

CUnit *myUnit;

if (myUnit->UnitHP > 0)
DoWhatever();

But as I said, don't worry about this... I've been thinking, THEORETICALLY there SHOULD (should but the SC code is so erratic, I am even wondering how most stuff manages to work) be a master building pointer, since once a master lands, the add-on becomes function and gains the master's Player ID.

Then again that might just be an event handler so not really sure ...
I'm afraid what you want may not work so the only "hack" you can do is just make different add-ons have the same GRP and same name, just different buttons and masters. It's really the only way... for now.

Perhaps there MIGHT be a very crazy way to do it on UMS maps via EUD triggers, but again, it's way too much trouble and might not be worth it since chances are it might not even work...

BlademasterSlsh
06-11-2008, 6:41 PM
Ok, how about these two.

Is there a way to have a button give minerals/gas to a player? (I'm looking to make a sell back mechanic here without going UMS)

Is it possible to add a button to a building that doesn't normally have any? (Supply depot, Pylon...)

ForTheSwarm
06-11-2008, 9:37 PM
The second part is possible, not sure about the first.

KillerKow
06-11-2008, 10:10 PM
The first part would be possible with a trigger template... I'm not all to familiar with exactly how they work, though.

BlademasterSlsh
06-12-2008, 12:09 AM
The first part would be possible with a trigger template... I'm not all to familiar with exactly how they work, though.

Is that the same idea as the triggers that tell the game to give 50 minerals and sets defeat and victory conditions, even on normal maps? If so, I may have to look into those.

The second part is possible, not sure about the first.

How do you do that, I'm not seeing it in FireGraft?

[Edit] ... I just realized I don't know how to save my buttons and what not made in Firegraft with anything else (such as my units.dat files)... I had been following instructions for saving from Memgraft and wondering why nothing was working... if anyone could help me with this, I would appreciate it.

TheNomad
06-12-2008, 3:49 AM
OK tell you what ... give me 1-2 days cos I got some stuff to do and I'll do another grafting tutorial, this time for FG. OK ?

As for the first thing, yes KillerKow is right, it is possible and I wanted to use it too in a mod idea. The second is also possible. Be patient, you'll get all the answers you need in time...

BlademasterSlsh
06-12-2008, 8:25 AM
I await it eagerly. Thanks for putting up with me.