:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Privacy Policy :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::

Do you want to advertise at Project Perfect Mod. Find out how to do it HERE.

The time now is Wed Jul 08, 2020 6:34 am
All times are UTC + 0
 Forum index » Modding Central » C&C: Remastered Collection Editing Forums
RA New unit
Moderators: Global Moderators
Post new topic   Reply to topic Page 1 of 1 [39 Posts] View previous topic :: View next topic
Author Message
munkle555
Civilian


Joined: 07 Jun 2020

PostPosted: Mon Jun 08, 2020 1:11 pm    Post subject:  RA New unit
Subject description: RA New unit
Reply with quote

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


DEFINES.H
 Description:

Download
 Filename:  DEFINES.H
 Filesize:  108.22 KB
 Downloaded:  3 Time(s)


UDATA.CPP
 Description:

Download
 Filename:  UDATA.CPP
 Filesize:  70.97 KB
 Downloaded:  3 Time(s)


Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Mon Jun 08, 2020 3:50 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Tue Jun 09, 2020 4:03 pm    Post subject: Reply with quote

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:

Code:

if (*this == AIRCRAFT_BADGER || (Class->PrimaryWeapon != NULL && Class->PrimaryWeapon->IsCamera)) {
         IsALoaner = true;

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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Tue Jun 09, 2020 5:31 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
munkle555
Civilian


Joined: 07 Jun 2020

PostPosted: Tue Jun 09, 2020 6:31 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Tue Jun 09, 2020 6:56 pm    Post subject: Reply with quote

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);

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Tue Jun 09, 2020 9:05 pm    Post subject: Reply with quote

Skyfighter24 wrote:
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);


https://imgur.com/a/bnPAPSR

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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Tue Jun 09, 2020 11:25 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Wed Jun 10, 2020 1:10 am    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Wed Jun 10, 2020 8:14 am    Post subject: Reply with quote

Skyfighter24 wrote:
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.

Back to top
View user's profile Send private message
munkle555
Civilian


Joined: 07 Jun 2020

PostPosted: Wed Jun 10, 2020 9:07 am    Post subject: Reply with quote

Reinforcementshavearrived wrote:
Skyfighter24 wrote:
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

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Wed Jun 10, 2020 1:03 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Wed Jun 10, 2020 9:43 pm    Post subject: Reply with quote

munkle555 wrote:

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.

https://imgur.com/a/AtpqgU4

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.

https://imgur.com/uZL5qEQ

This is a quick size comparison.

Last edited by Reinforcementshavearrived on Wed Jun 10, 2020 9:51 pm; edited 1 time in total

Back to top
View user's profile Send private message
munkle555
Civilian


Joined: 07 Jun 2020

PostPosted: Wed Jun 10, 2020 9:47 pm    Post subject: Reply with quote

Reinforcementshavearrived wrote:
munkle555 wrote:

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.

https://imgur.com/a/AtpqgU4

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?

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Wed Jun 10, 2020 9:56 pm    Post subject: Reply with quote

munkle555 wrote:

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.

Code:

<?xml version="1.0"?>

<ModGameCommands>
   <CNCModGameCommandManager>
      <CNCModGameCommands>
         <Command Name="A10">
            <GameCommand>GAME_COMMAND_RA_MOD_CUSTOM_BUILD1</GameCommand>
         </Command>
      </CNCModGameCommands>
   </CNCModGameCommandManager>
</ModGameCommands>

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

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Wed Jun 10, 2020 11:45 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Thu Jun 11, 2020 8:57 am    Post subject: Reply with quote

Skyfighter24 wrote:
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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Thu Jun 11, 2020 11:38 am    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Thu Jun 11, 2020 11:59 am    Post subject: Reply with quote

Skyfighter24 wrote:
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?

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Thu Jun 11, 2020 12:10 pm    Post subject: Reply with quote

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]
Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Thu Jun 11, 2020 4:51 pm    Post subject: Reply with quote

Skyfighter24 wrote:
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.

https://imgur.com/a/bZyxJMC

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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Thu Jun 11, 2020 8:31 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Fri Jun 12, 2020 12:29 am    Post subject: Reply with quote

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.

Code:


Code from DEFINES.H:

#define BOMBER_MOD

#ifdef BOMBER_MOD
   AIRCRAFT_BOMBER,            // Bomber Aircraft
#endif


(Don't know if the below part is needed as its not in the nuke tank mod however the game crashes with or without it added in)

#ifdef BOMBER_MOD
#define AIRCRAFTF_BOMBER        (1L << AIRCRAFT_BOMBER)
#endif


Code from AADATA.CPP:

#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


Code from CNCModGameCommands.xml:

<?xml version="1.0"?>

<ModGameCommands>
   <CNCModGameCommandManager>
      <CNCModGameCommands>
         <Command Name="BOMR">
            <GameCommand>GAME_COMMAND_RA_MOD_CUSTOM_BUILD1</GameCommand>
         </Command>
      </CNCModGameCommands>
   </CNCModGameCommandManager>
</ModGameCommands>


Code from RABuildables.xml:

<ObjectTypeClass Name="RA_BOMR" Classification="CNCBuildableObject" CanInstantiate="False">
      <CNCEncyclopediaComponent>
         <ObjectNameTextID>TEXT_UNIT_RA_HIND</ObjectNameTextID>
         <ObjectDescriptionTextID>TEXT_UNIT_RA_HIND_DESC</ObjectDescriptionTextID>
         <BuildIcon>BuildIcon_RA_Aircraft_Bomber</BuildIcon>
      </CNCEncyclopediaComponent>
   </ObjectTypeClass>

Code from RA_Units.xml:

         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>0</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0000.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>1</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0001.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>2</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0002.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>3</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0003.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>4</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0004.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>5</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0005.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>6</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0006.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>7</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0007.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>8</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0008.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>9</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0009.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>10</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0010.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>11</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0011.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>12</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0012.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>13</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0013.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>14</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0014.tga</Frame>
               </Frames>
            </Value>
         </Tile>
         <Tile>
            <Key>
               <Name>BOMR</Name>
               <Shape>15</Shape>
            </Key>
            <Value>
               <Frames>
                  <Frame>BOMR\BOMR-0015.tga</Frame>
               </Frames>
            </Value>
         </Tile>

Code Added to Rules.ini:

; Bomber Aircraft
[BOMR]
Prerequisite=afld
Primary=Maverick
Secondary=Maverick
Strength=50
Armor=light
TechLevel=10
Sight=0
Speed=20
Owner=soviet
Cost=1200
Points=50
ROT=5
Ammo=3
GuardRange=30


Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Fri Jun 12, 2020 1:01 am    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Fri Jun 12, 2020 12:25 pm    Post subject: Reply with quote

Skyfighter24 wrote:
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.


Check the Art file path again.

It needs to be like this

Code:
[MOD FOLDER]\Data\Art\textures\red_alert\units\BOMR



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

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Fri Jun 12, 2020 12:38 pm    Post subject: Reply with quote

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.

Do I have this part right?

Code:
ifdef BOMBER_MOD
      if (index == AIRCRAFT_BOMBER) {
         _makepath(fullname, NULL, NULL, "BOMR", ".SHP");
         ((void const*&)uclass.CameoData) = MFCD::Retrieve(fullname);
         ((void const*&)uclass.ImageData) = MFCD::Retrieve(fullname);
      }
#endif




I think my art path is:
Code:

[MOD FOLDER]\Data\Art\textures\red_alert\units\BOMR


Not
Code:

[MOD FOLDER]\Art\textures\red_alert\units\BOMR

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Fri Jun 12, 2020 2:36 pm    Post subject: Reply with quote

Skyfighter24 wrote:

I think my art path is:
Code:

[MOD FOLDER]\Data\Art\textures\red_alert\units\BOMR



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
Code:
#define BOMBER_MOD

Add a comment for good measure.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Fri Jun 12, 2020 2:48 pm    Post subject: Reply with quote

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?

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Fri Jun 12, 2020 3:23 pm    Post subject: Reply with quote

Skyfighter24 wrote:
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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Fri Jun 12, 2020 5:34 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Fri Jun 12, 2020 6:38 pm    Post subject: Reply with quote

Skyfighter24 wrote:
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?

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Fri Jun 12, 2020 6:54 pm    Post subject: Reply with quote

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.  

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Fri Jun 12, 2020 10:24 pm    Post subject: Reply with quote

Skyfighter24 wrote:
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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Fri Jun 12, 2020 11:37 pm    Post subject: Reply with quote

I sent you a copy of my deifne and aadata files I think that's everything for the source code that changed.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Sat Jun 13, 2020 12:50 am    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Reinforcementshavearrived
Vehicle Driver


Joined: 09 Jun 2020

PostPosted: Sat Jun 13, 2020 8:47 am    Post subject: Reply with quote

Skyfighter24 wrote:
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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Sat Jun 13, 2020 5:18 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Skyfighter24
Vehicle Driver


Joined: 08 Jun 2020

PostPosted: Sat Jun 13, 2020 11:15 pm    Post subject: Reply with quote

Actually figured that out as well for each new unit in modgamecommands you need to change the number in
Code:

GAME_COMMAND_RA_MOD_CUSTOM_BUILD1


for each consecutive unit so unit 2 would read
Code:

GAME_COMMAND_RA_MOD_CUSTOM_BUILD2

Back to top
View user's profile Send private message
Guest





PostPosted: Sun Jun 21, 2020 6:15 am    Post subject: Reply with quote

Skyfighter24 wrote:
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) {

         _makepath(fullname, NULL, NULL, "3tnk", ".SHP");

      }
      #ifndef NDEBUG
         RawFileClass shpfile(fullname);
         if (shpfile.Is_Available()) {
            ptr = Load_Alloc_Data(shpfile);
         } else {
            ptr = MFCD::Retrieve(fullname);
         }
      #else
         ptr = MFCD::Retrieve(fullname);
      #endif


MTANKX is my new unit.
Simply a Heavy Tank.

This are the importen part, the rest will be ignored.

Code:

_makepath(fullname, NULL, NULL, uclass.Graphic_Name(), ".SHP");
      if (index == UNIT_MTANKX) {

         _makepath(fullname, NULL, NULL, "3tnk", ".SHP");

      }
ptr = MFCD::Retrieve(fullname);

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [39 Posts] View previous topic :: View next topic
 Forum index » Modding Central » C&C: Remastered Collection Editing Forums
Jump to:  
Share on TwitterShare on FacebookShare on Google+Share on DiggShare on RedditShare on PInterestShare on Del.icio.usShare on Stumble Upon
Quick Reply
Username:


If you are visually impaired or cannot otherwise answer the challenges below please contact the Administrator for help.


Write only two of the following words separated by a sharp: Brotherhood, unity, peace! 

 
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


Powered by phpBB © phpBB Group

[ Time: 0.8506s ][ Queries: 12 (0.0226s) ][ Debug on ]