Posted: Mon Jun 08, 2020 1:11 pm Post subject:
RA New unit
Subject description: RA New unit
So I am struggling to add a new unit to RA, I have followed the excellent guide for adding a nuke tank into TD however there appears to be subtle differences in each games code. Currently I have updated define_h with the new tanks id, updated udata copying the mammoth tank but changing it to the new tanks id and also adding its stats to rules.ini. The problem I am having is the icon for it in the build queue is that of the fake construction yard and it doesn't build. Reading the TD guide they added code in to give it the mammoth tanks image but adjusting the same code for use in RA does not appear to work. I am at a loss does anyone have any idea whats missing?
I have attached the files in case anyone wants to take a look its ID is Unit_SUTANK and UNITSUTANK.
Any help would be awesome or an example of a new unit added to RA I can work with
I tried doing this as well And encountered the same issue but with a new aircraft. I searched every file for the name of the unit I was copying and created a new one off of that, then added it to the rules.ini and rabuildables xml file that shows the path for the build icon but same issue with the fake construction yard icon. It would have been nice if they gave an example unit mod for RA as well. I tried copying the mig and it did work if I defined the unit ini name the same but all that did was add another mig to the build list. I even tried making the badger buildable, it shows up as buildable but when I change selectable to true in the source code file it doesn’t make it selectable. QUICK_EDIT
I guess I have the same problem as you. I can't really find the icons in the MEG files therefore I can't really replicate the unit on the sidebar.
Quote:
I even tried making the badger buildable, it shows up as buildable but when I change selectable to true in the source code file it doesn’t make it selectable.
This is were I come in. The Badger Bomber is being defined as a "Loaner" plane, it's just a units that gets summoned by the map for the player and then exits without landing anywhere and it is impossible to select.
To fix this in the Aircraft.cpp file in line 283 you will find the following statement:
As you can see, this if statement just says that if the plane has a Camera Primary Weapon (Spyplane) or if it is a Badger plane, it's a Loaner and therefore it can't be selected.
To make the Badger playable you need to remove the loaner, in that case you can just refactor the code this way.
Code:
if (Class->PrimaryWeapon != NULL && Class->PrimaryWeapon->IsCamera) {
IsALoaner = true;
}
if (*this == AIRCRAFT_BADGER) {
IsALoaner = false;
}
This way, any Badger plane called by the player or in the same faction as the player will be able to be selected and used.
It will still crash into the ground after you order it to do something, to fix this you need to add "Struct_airstrip" into the preferred landing building in AADATA.cpp
It can't load passengers as it can't land on the ground (I'm working on some logic just for that)
Still, I advise you into making the Badger plane into a completely different plane as the last change in this post will cause it to land in Soviet Airstrips during missions. I mean, it could break things in the campaign or custom missions, not sure what it could. QUICK_EDIT
Ill have to try that tonight, the Badger was kind of an experiment to see if I could get something to work, I feel like the changes I'm making are not being compiled into the DLL as I can get the same result with the fake icon if I just edit the ini file. If this doesn't work i'm going to try and break something on purpose to see if red alert is at least picking up my dll file as a mod.
I also tried to add a new unit as an Aftermath unit as they seem to be added as an if statement under FIXIT_CSII (the only reason i could see them adding it this way was to have the option to turn Aftermath units off) but when I try to make a new aircraft called AIRCRAFT_BOMBER it says it needs a constructor which I tried to follow the same logic as the chrono tank except as an aircraft but its till giving me an error with the constructor. Oddly enough if I don't add it under FIXIT_CSII it doesn't give me the missing constructor error. Again just experimenting with stuff for now. QUICK_EDIT
This is what I don’t understand about the nuke tank. It has its own unique icon and turret image. Going over the guide I am failing to see where these are set. I have run a search for nuke and example_mod which they have put around each section they have changed and cannot find any reference to this info. What’s annoying me the most is it’s one thing not being able to build it but I cannot even spawn it in using the map editor or any other means to be able to see if it even works. QUICK_EDIT
I found this code in the AADATA that appears to initialize the graphics for the unit it’s also found in the building and unit code to. It looks similar to the nuke tank example but they are probably doing something to run the same code over and over for different units. You can even see it references .shp which is the graphic file type and cameo for the side bar icons. I’m not a programmer so my knowledge is limited in case I’m wrong here.
*/
char buffer[_MAX_FNAME];
sprintf(buffer, "%sICON", uclass.Graphic_Name());
_makepath(fullname, NULL, NULL, buffer, ".SHP");
((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname); QUICK_EDIT
I found this code in the AADATA that appears to initialize the graphics for the unit it’s also found in the building and unit code to. It looks similar to the nuke tank example but they are probably doing something to run the same code over and over for different units. You can even see it references .shp which is the graphic file type and cameo for the side bar icons. I’m not a programmer so my knowledge is limited in case I’m wrong here.
*/
char buffer[_MAX_FNAME];
sprintf(buffer, "%sICON", uclass.Graphic_Name());
_makepath(fullname, NULL, NULL, buffer, ".SHP");
((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname);
Progress. I managed to fetch the old data in the mix files as a workaround similar to the one applied in the Nuclear Tank tutorial you can find in the tutorial section.
Code:
if (index == AIRCRAFT_CAS) {
_makepath(fullname, NULL, NULL, "MIG", ".SHP");
//ptr = MixFileClass::Retrieve(fullname); //This is the TD Equivalent made by Petroglyph
((void const*&)uclass.CameoData) = MFCD::Retrieve(fullname);
((void const*&)uclass.ImageData) = MFCD::Retrieve(fullname);
}
Inside any One_time for loop, at the end, apply this if statement by changing the Unit Type (In my case, I'm adding a A10 by calling it AIRCRAFT_CAS) and changing the MIX file subsistute in
Code:
_makepath(fullname, NULL, NULL, "MIG", ".SHP");
In this case, I'm changing it with a MIG SHP.
For some reason the cameo is still not loading, but I'm confident I will be able to load that as well tomorrow.
PS. I too am not a programmer, so I don't know if this is the most correct way to do this. So far, it's working. QUICK_EDIT
Well I did finally get the badger to fly but it can't do much, I assume this is because of the other code for the unit. Also will crash wherever you send it, probably something to do with it looking for an available airfield.
As far as adding a new unit I was able to add your code in but i'm still not getting anywhere. I defined my own mod like the nuke tank example and followed the format of FIXIT_CSII and still nothing. Not getting any constructor errors now though. I exported the art and renamed it, placed it in a directory just like the nuke tank example. QUICK_EDIT
I took another look at the nuke tank mod and you also need to define the graphics in RA_BUILDABLES.XML AND RA_UNITS.XML, did this and still no luck, think I'm done for today going to try again tomorrow. QUICK_EDIT
Well I did finally get the badger to fly but it can't do much, I assume this is because of the other code for the unit. Also will crash wherever you send it, probably something to do with it looking for an available airfield.
In the AAData.cpp you need to change the "STRUCT_NONE" to "STRUCT_AIRSTRIP" in the Badger Class.
Code:
static AircraftTypeClass const BadgerPlane(
AIRCRAFT_BADGER, // What kind of aircraft is this.
TXT_BADGER, // Translated text number for aircraft.
"BADR", // INI name of aircraft.
0x0000, // Vertical offset.
0x0000, // Primary weapon offset along turret centerline.
0x0000, // Primary weapon lateral offset along turret centerline.
true, // Fixed wing aircraft?
false, // Equipped with a rotor?
false, // Custom rotor sets for each facing?
false, // Can this aircraft land on clear terrain?
true, // Is it invisible on radar?
false, // Can the player select it so as to give it orders?
true, // Can it be assigned as a target for attack.
false, // Is it insignificant (won't be announced)?
false, // Is it immune to normal combat damage?
STRUCT_NONE, // Preferred landing building. <----------------------//This is the one you need to change to STRUCT_AIRSTRIP
0xFF, // Landing speed
16, // Number of rotation stages.
MISSION_HUNT // Default mission for aircraft.
);
After this it will find an Airstrip after each command, if it doesn't (if there is no Airstrip), it will crash like any aircraft in the game.
Skyfighter24 wrote:
As far as adding a new unit I was able to add your code in but i'm still not getting anywhere. I defined my own mod like the nuke tank example and followed the format of FIXIT_CSII and still nothing. Not getting any constructor errors now though. I exported the art and renamed it, placed it in a directory just like the nuke tank example.
Feel free to post that part of the code so I can help you fix it.
Skyfighter24 wrote:
I took another look at the nuke tank mod and you also need to define the graphics in RA_BUILDABLES.XML AND RA_UNITS.XML, did this and still no luck, think I'm done for today going to try again tomorrow.
I'm trying to understand that as well. I managed to get the A10 Cameo by simply calling it like its being called in the CNCBULDABLES but so far I can't get it to get the sprites I put inside the mod.
To check if I was doing everything correctly, I switched the turrets of the light tank with the mammoth tank and it worked perfectly.
I also added the correct sprites in the RA_UNITS.XML but so far, it's only a grey box. Everything else works though.
In the RA_BUILDABLES.XML I have to call the A10 as RA_A10 otherwise it will not call the correct cameo. There's something else that needs to be changed, maybe there's some relationship with the extended class I showed you prior but then I think that if it's calling the MIG SHP from the Mix files I stated above and nothing from the HD version, then there must be a problem with the XMLs. QUICK_EDIT
Well I did finally get the badger to fly but it can't do much, I assume this is because of the other code for the unit. Also will crash wherever you send it, probably something to do with it looking for an available airfield.
In the AAData.cpp you need to change the "STRUCT_NONE" to "STRUCT_AIRSTRIP" in the Badger Class.
Code:
static AircraftTypeClass const BadgerPlane(
AIRCRAFT_BADGER, // What kind of aircraft is this.
TXT_BADGER, // Translated text number for aircraft.
"BADR", // INI name of aircraft.
0x0000, // Vertical offset.
0x0000, // Primary weapon offset along turret centerline.
0x0000, // Primary weapon lateral offset along turret centerline.
true, // Fixed wing aircraft?
false, // Equipped with a rotor?
false, // Custom rotor sets for each facing?
false, // Can this aircraft land on clear terrain?
true, // Is it invisible on radar?
false, // Can the player select it so as to give it orders?
true, // Can it be assigned as a target for attack.
false, // Is it insignificant (won't be announced)?
false, // Is it immune to normal combat damage?
STRUCT_NONE, // Preferred landing building. <----------------------//This is the one you need to change to STRUCT_AIRSTRIP
0xFF, // Landing speed
16, // Number of rotation stages.
MISSION_HUNT // Default mission for aircraft.
);
After this it will find an Airstrip after each command, if it doesn't (if there is no Airstrip), it will crash like any aircraft in the game.
Skyfighter24 wrote:
As far as adding a new unit I was able to add your code in but i'm still not getting anywhere. I defined my own mod like the nuke tank example and followed the format of FIXIT_CSII and still nothing. Not getting any constructor errors now though. I exported the art and renamed it, placed it in a directory just like the nuke tank example.
Feel free to post that part of the code so I can help you fix it.
Skyfighter24 wrote:
I took another look at the nuke tank mod and you also need to define the graphics in RA_BUILDABLES.XML AND RA_UNITS.XML, did this and still no luck, think I'm done for today going to try again tomorrow.
I'm trying to understand that as well. I managed to get the A10 Cameo by simply calling it like its being called in the CNCBULDABLES but so far I can't get it to get the sprites I put inside the mod.
To check if I was doing everything correctly, I switched the turrets of the light tank with the mammoth tank and it worked perfectly.
I also added the correct sprites in the RA_UNITS.XML but so far, it's only a grey box. Everything else works though.
In the RA_BUILDABLES.XML I have to call the A10 as RA_A10 otherwise it will not call the correct cameo. There's something else that needs to be changed, maybe there's some relationship with the extended class I showed you prior but then I think that if it's calling the MIG SHP from the Mix files I stated above and nothing from the HD version, then there must be a problem with the XMLs.
Sorry where are the two xml files I have been unable to locate them QUICK_EDIT
They are located in one of the .MEG files I forget which one but I’ll check when I get to my pc later. You will need to download the .BIG editor from
PPM to extract them.
I emailed Petroglyph for some advice, it’s probably a long shot that they get back to me but if they do I’ll be sure to let everyone know what they said. QUICK_EDIT
Sorry where are the two xml files I have been unable to locate them
You need to extract them from Config.meg using the OSBig Editor you find on this site.
Now, I really feel like an idiot. All this time I put Ra_units.xml in the wrong file path, it was not being found by the game and this is why it wasn't loading the sprites.
It's still showing problems but I will fix them.
I'm not sure about the size, but the actual direction must be due to the fact that the A10 folder shows up 32 sprites instead of the expected 15 for the air units of RA.
I need to do some cleaning.
After this is over, I will write a guide on everything I did along releasing the unit here and on the steam workshop.
Edit:
Changing the rotation stages does fix the issue but the size is still an unknown for me.
Sorry where are the two xml files I have been unable to locate them
You need to extract them from Config.meg using the OSBig Editor you find on this site.
Now, I really feel like an idiot. All this time I put Ra_units.xml in the wrong file path, it was not being found by the game and this is why it wasn't loading the sprites.
It's still showing problems but I will fix them.
I'm not sure about the size, but the actual direction must be due to the fact that the A10 folder shows up 32 sprites instead of the expected 15 for the air units of RA.
I need to do some cleaning.
After this is over, I will write a guide on everything I did along releasing the unit here and on the steam workshop.
Thanks very much, what path do you need to put them in? QUICK_EDIT
Thanks very much, what path do you need to put them in?
This is the correct file path to follow if you're making a mod in your documents folder.
[MODFOLDER]\Data\XML\Tilesets\Ra_units.xml ---> Graphics
[MODFOLDER]\Data\XML\Objects\Units\RABuildables.xml ---> Unit Definition
[MODFOLDER]\Data\XML\CNCModGameCommands.xml ---> not available on the config.meg
Remember to have a CNCModGameCommands.xml that lists the unit\s that you're trying to add in. This is what I have so you don't have to take it from the nuke mod.
Remember to specify this "GAME_COMMAND_RA_MOD_CUSTOM_BUILD1" and the command name, in this case is the Ini name of the unit, it needs to be the exact same as name you put in the RABuildables.xml QUICK_EDIT
I totally missed that file too, I didn't think about it since TD doesn't use INI files. Started from scratch with the source code but now my game is crashing so I have to reinstall it. Hopefully this will make it work.
Found out its actually the cncmodgamecommands file that's causing the crash so I have to do a little more work to find out what change i'm making that's causing this. QUICK_EDIT
I totally missed that file too, I didn't think about it since TD doesn't use INI files. Started from scratch with the source code but now my game is crashing so I have to reinstall it. Hopefully this will make it work.
Found out its actually the cncmodgamecommands file that's causing the crash so I have to do a little more work to find out what change i'm making that's causing this.
You can post it here if you need help, I'll reply when I can.
btw I'm still struggling with the size of the A10 sprite. I tried to change the sprite to the YAK but apparently it's due to the unit itself since the Yak Sprite appears huge when applied to my port so it's the way it's drawn by the engine.
I also checked the shp size that is specified in case the plane is a badger plane but that only changes the old shp size and not the new one.
I really really wish Petro provided an actual guide for adding units to RA. Dealing with the source code is pretty fun, but when it comes to XML files and the new graphics things it gets a little big frustrating as there are files that are pretty much unknown to us. QUICK_EDIT
Yeah I’ll posts some stuff later, are you trying to replace the Yak graphics or add a completely new one? I called my TGA files BOMR-0000.tga etc. basically just exported and renamed the badger files. So I have an aircraft in the source code called BOMBER_AIRCRAFT referencing the ini unit BOMR. I’m not getting any errors flagging in visual studio. QUICK_EDIT
Yeah I’ll posts some stuff later, are you trying to replace the Yak graphics or add a completely new one? I called my TGA files BOMR-0000.tga etc. basically just exported and renamed the badger files. So I have an aircraft in the source code called BOMBER_AIRCRAFT referencing the ini unit BOMR. I’m not getting any errors flagging in visual studio.
I wanted to see if I was doing anything wrong with the A10 sprites so I took the Yak Sprites and put them as the A10 sprites that I was trying to add. The sprites still look huge in comparison to the actual Yak present in-game.
This of course doesn't happen if I change the Aircraft type back to a known one like the MIG, so there's something else causing my problem.
Are you getting any distortion with the HD sprites using the badger? QUICK_EDIT
Problem is my hame crashes at launch when using the mod so I can’t test it.
I actually did hear back from Petroglyph, they didn’t have an example to show me but they did speak to the engineer who made the nuke tank mod, they said the reason they choose to do a TD example is because it’s actually harder to implement a new unit in TD than RA but the process should be similar.
I did see this in the AADATA regarding dimensions
Code:
AircraftTypeClass::Dimensions -- Fetches the graphic dimensions of the aircraft type
Problem is my hame crashes at launch when using the mod so I can’t test it.
I actually did hear back from Petroglyph, they didn’t have an example to show me but they did speak to the engineer who made the nuke tank mod, they said the reason they choose to do a TD example is because it’s actually harder to implement a new unit in TD than RA but the process should be similar.
I did see this in the AADATA regarding dimensions
Code:
AircraftTypeClass::Dimensions -- Fetches the graphic dimensions of the aircraft type
[/code]
Yeah that just draws the generic shape of the unit or else, it doesn't affect the sprite size.
Anyway, I think I got it fixed but it's a little bit complicated.
I'm not sure what the relationship is but my theory is that the classes that form the various units are hardcoded in the Petroglyph side of the code, the closed one
if you watch the nuke tank sprites you will notice that they're all squares instead of being drawn from visible edge to another like the ones inside the meg files (look for the Yak for example)
I think the Glyph engine just doesn't know what to do with those and just draws boxes.
That also means that the actual scale of the unit is handled in the dimensions of the file like 256 x 256 or more
the picture above is the sprite being resized at 500 x 500.
the official sprites all come with a Meta file which contains a resolution to draw the file as instead of the actual resolution of the file but those are not actually being used, for some reason. Not even the official ones extracted from the MEG files.
You can resize any sprite with software like XnConvert, just keep the source image centered and everything will be fine.
Anyway, did you fix the crashes? I can give you my steam handle or any chat if you need to.
EDIT:
I'm currently writing a guide to add a full unit to RA along with other fixed things people will probably be interested in like this one:
https://imgur.com/a/wIFFmCy
The fix for the Destroyer turret that had been bugging me since I was 10.
These damn turrets don't belong on the center of the damn ship. QUICK_EDIT
I’m going to take another look at it tonight, just going to start over so I can try and pinpoint what’s causing the crash. Are you keeping your code in a separate #define like the nuke tank was done or just adding the code in as is? I have a feeling I messed up one of the xml files somewhere and it’s just a typo causing issues.
Did finally get the badger working though I just want to get it working as a separate unit. Then I’m going to hop into 3ds max and make a B-52 (Probably double the bomb load as the badger but make it more expensive to balance) for the Allies but I’ll have to give them a new Airstrip too. QUICK_EDIT
Alright I'm officially stumped as to why my game keeps crashing here is a list of the following changes I have made in my attempt to add a new aircraft using the badger bomber graphics that I exported.
#ifdef BOMBER_MOD
// Bomber aircraft.
static AircraftTypeClass const AircraftBomber(
AIRCRAFT_BOMBER, // What kind of aircraft is this.
TXT_MIG, // Translated text number for aircraft.
"BOMR", // INI name of aircraft.
0x0000, // Vertical offset.
0x0020, // Primary weapon offset along turret centerline.
0x0020, // Primary weapon lateral offset along turret centerline.
true, // Fixed wing aircraft?
false, // Equipped with a rotor?
false, // Custom rotor sets for each facing?
false, // Can this aircraft land on clear terrain?
true, // Is it invisible on radar?
true, // Can the player select it so as to give it orders?
true, // Can it be assigned as a target for attack.
false, // Is it insignificant (won't be announced)?
false, // Is it immune to normal combat damage?
STRUCT_AIRSTRIP, // Preferred landing building.
0xC0, // Landing speed
16, // Number of rotation stages.
MISSION_HUNT // Default mission for aircraft.
);
#endif
#ifdef BOMBER_MOD
new AircraftTypeClass(AircraftBomber);
#endif
#ifdef BOMBER_MOD
if (index == AIRCRAFT_BOMBER) {
_makepath(fullname, NULL, NULL, "BOMR", ".SHP");
//ptr = MixFileClass::Retrieve(fullname); //This is the TD Equivalent made by Petroglyph
((void const*&)uclass.CameoData) = MFCD::Retrieve(fullname);
((void const*&)uclass.ImageData) = MFCD::Retrieve(fullname);
}
#endif
Ok progress, I completely rewrote my cncmodgamecommands xml file and the game no longer crashes, loads the build icon but new problem my unit is invisible, no graphics load but it is selectable.
Update, still no luck getting the unit graphics to load, I have my ra_units.xml in the correct folder, I tried changing the yak file to something different and it works so its a working file but my unit is still invisible. I checked the file names and they match the ones in the xml file so I'm still not sure why everything else is working even has the correct weapons and it moves around but its just invisible.
Furthermore I replaced the Yak with the bomr-000.tga files and that worked too, so its probably pointing to something wrong with the code. QUICK_EDIT
Ok progress, I completely rewrote my cncmodgamecommands xml file and the game no longer crashes, loads the build icon but new problem my unit is invisible, no graphics load but it is selectable.
Update, still no luck getting the unit graphics to load, I have my ra_units.xml in the correct folder, I tried changing the yak file to something different and it works so its a working file but my unit is still invisible. I checked the file names and they match the ones in the xml file so I'm still not sure why everything else is working even has the correct weapons and it moves around but its just invisible.
Furthermore I replaced the Yak with the bomr-000.tga files and that worked too, so its probably pointing to something wrong with the code.
By the way have you had any luck in adding weapons to the game? I added a new weapon in the Defines.h but it's not picking up the weapon from the INI. Last edited by Reinforcementshavearrived on Fri Jun 12, 2020 2:45 pm; edited 1 time in total QUICK_EDIT
I haven’t played around with weapons yet figured one step at a time. I believe the path is correct but I’ll check again as I can point the yak at my graphics and the yak will turn into the badger so the game sees the path but when I define my BOMR with my graphic path it doesn’t see it.
Also I purposely broke the yak path and it replaced the yak graphic with a placeholder Petroglyph icon. It’s not doing this with the BOMR it’s just invisible.
That one is correct, sorry, I left data out.
I'll edit the original post.
Anyway.
The code is correct, but you left the # Symbol before ifdef.
After that, did you define "Bomber_mod" in Defines.h? you can add it with the rest on line 113 like this
Yeah that was just an error in my copy and paste my code has the # in visual studio. I have been finding it won’t even let you compile it if some syntax is off and I did put the #define for bonber_mod too. My only thought is that there’s an error in the RA_units I copied the badger and replaced it with the BOMR path so my thought is maybe there’s an extra tile tag that’s breaking it. I thought the other xml file was fine and it wasn’t.
Do you know if it matters where in the ra_units.xml you add the extra code for your new unit? QUICK_EDIT
Yeah that was just an error in my copy and paste my code has the # in visual studio. I have been finding it won’t even let you compile it if some syntax is off and I did put the #define for bonber_mod too. My only thought is that there’s an error in the RA_units I copied the badger and replaced it with the BOMR path so my thought is maybe there’s an extra tile tag that’s breaking it. I thought the other xml file was fine and it wasn’t.
Do you know if it matters where in the ra_units.xml you add the extra code for your new unit?
Yes, it has to be inside the Tiles tag which is inside other tags.
Code:
<Tilesets>
<TilesetTypeClass name="RA_Units">
<RootTexturePath>Red_Alert\Units</RootTexturePath>
<Tiles>
<Tile>
<Key>
<Name>EXAMPLE</Name>
<Shape>0</Shape>
</Key>
<Value>
<Frames>
<Frame>EXAMPLE\EXAMPLE-0000.tga</Frame>
</Frames>
</Value>
</Tile> ----------------> make sure that each tag gets closed.
</Tiles>
</TilesetTypeClass>
</Tilesets>
It doesn't matter if you put it up or down, just don't delete the other units and follow the tag guides. QUICK_EDIT
going back to the code again as if I disable all the other units it replaces them with white squares so if i couldn't read the graphics it shouldn't be invisible it should be a white square. Ive been over the XML a million times and nothing is out of place.
But what doesn't make sense is its displaying the cameo icon fine. QUICK_EDIT
going back to the code again as if I disable all the other units it replaces them with white squares so if i couldn't read the graphics it shouldn't be invisible it should be a white square. Ive been over the XML a million times and nothing is out of place.
But what doesn't make sense is its displaying the cameo icon fine.
I think you just deleted the whole tileset of the game. All the sprite data inside that ra_tileset.xml needed to stay there, you just need to add your unit to the bunch.
Do you have a backup? QUICK_EDIT
Yeah for the code I posted I only copied what I added I still have the other units in there and I can switch the yak to my custom graphic files so the art is in the right place and the xml is in the right place. The RA_buildables file is working as it’s showing the correct cameo icon.
So going by process of elimination, changing an existing unit works, changing the art path to something that doesn’t exist produces a gray box but my unit is invisible, the ini is working since it had the right weapons and cost, only thing that’s left is something out of place in the source code related to calling the graphics. QUICK_EDIT
Yeah for the code I posted I only copied what I added I still have the other units in there and I can switch the yak to my custom graphic files so the art is in the right place and the xml is in the right place. The RA_buildables file is working as it’s showing the correct cameo icon.
So going by process of elimination, changing an existing unit works, changing the art path to something that doesn’t exist produces a gray box but my unit is invisible, the ini is working since it had the right weapons and cost, only thing that’s left is something out of place in the source code related to calling the graphics.
If you want, you can send me the whole source code so I can check it out and see whats wrong. QUICK_EDIT
I finally got it to work!!!
It was this code as I suspected:
Code:
#ifdef BOMBER_MOD
if (index == AIRCRAFT_BOMBER) {
_makepath(fullname, NULL, NULL, "MIG", ".SHP");
//ptr = MixFileClass::Retrieve(fullname); //This is the TD Equivalent made by Petroglyph
((void const*&)uclass.CameoData) = MFCD::Retrieve(fullname);
((void const*&)uclass.ImageData) = MFCD::Retrieve(fullname);
}
#endif
I kept changing MIG to BOMR, I don't understand why this works and the MIG still acts like a MIG but BOMR now works with the correct graphics. QUICK_EDIT
I finally got it to work!!!
It was this code as I suspected:
Code:
#ifdef BOMBER_MOD
if (index == AIRCRAFT_BOMBER) {
_makepath(fullname, NULL, NULL, "MIG", ".SHP");
//ptr = MixFileClass::Retrieve(fullname); //This is the TD Equivalent made by Petroglyph
((void const*&)uclass.CameoData) = MFCD::Retrieve(fullname);
((void const*&)uclass.ImageData) = MFCD::Retrieve(fullname);
}
#endif
I kept changing MIG to BOMR, I don't understand why this works and the MIG still acts like a MIG but BOMR now works with the correct graphics.
I didn't notice that so I guess Sorry.
I'll explain the code a bit. That part of the code handles how the game retrieves the SHP sprite from the old Mix archives. The original Nuke Tank example code was a bit more complicated so I adapted it using the classes added in RA.
The following code just says that, if the Unit is a certain unit, you need to use another SHP instead of searching for the name stated in the INI file (in this case it was looking for BOMR.shp, which doesn't exist) to give it a game shape, allowing it to be selected.
This will be necessary for every unit you add in the game, give it a generic shape for the classic version.
You could technically use the BADR shp and that will cross between classic mode as well. QUICK_EDIT
Thanks for all your help, now I'm trying to add 2 units, funny thing is they both work individually but when you have them both enabled only one is buildable but they both show up on the side bar. QUICK_EDIT
Ok progress, I completely rewrote my cncmodgamecommands xml file and the game no longer crashes, loads the build icon but new problem my unit is invisible, no graphics load but it is selectable.
Same problem and i need three days to fix it.
Thx goes to Skyfighter24 and Reinforcementshavearrived.
This is my Code and it works perfectly well.
Code:
if (index == UNIT_MTANKX) {
_makepath(fullname, NULL, NULL, "3tnk", ".SHP");
}
The whole codesection in the UDATA.CPP
Code:
/*
** Fetch a pointer to the unit's shape data.
*/
_makepath(fullname, NULL, NULL, uclass.Graphic_Name(), ".SHP");
if (index == UNIT_MTANKX) {
Joined: 24 May 2004 Location: Flanders (Be) Posts:300000001
Posted: Mon Jan 04, 2021 10:50 pm Post subject:
Isn't the problem here simply that the original SHP file is not found, and that marks the graphics as "not found" causing the remaster graphics not to load either? I mean it literally says it tries to load a file with .shp extension, and it only seems to work when you put it on a unit name that is already in the game.
I mean, consider this: the Red Alert terrain graphics files contain more than just graphics: they also contain the terrain type of each cell in the file. So, they are more than just graphics. The game doesn't just need to load these files to get the non-remastered graphics; it needs vital game data from them which determines what tiles are passable for which unit types, and what speeds they get on that (as defined per terrain type in rules.ini). In other words, it needs the classic graphics files to function even if you never switch to the classic graphics in-game. So it's not a stretch to extrapolate that things can go wrong when those original non-remastered files are missing.
So simply add a .shp file for your unit, and you can probably keep using the original unit string ID in that code you showed there. _________________ QUICK_EDIT
Bounding boxes are calculated from the original graphics to handle some logic IIRC, so you can't really get away with just making graphics for the remaster, you need to do the work and provide at least something for the classic graphics as well. QUICK_EDIT
Is it possible to add support code to logically add new custom units to RA? Example: I've added the capability for new weapons via the rules.ini:
rules.cpp snippet line 653 during heap init:
Code:
Weapons.Set_Heap(WeaponMax);
if (ini.Is_Present("Weapons")) {
for (int x = 0; x < ini.Entry_Count("Weapons"); x++) {
new WeaponTypeClass(ini.Get_Entry("Weapons", x));
}
}
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum