Topic: NPC Race problem creating ships.  (Read 3609 times)

0 Members and 1 Guest are viewing this topic.

Tombstone

  • Guest
NPC Race problem creating ships.
« on: September 11, 2003, 07:21:05 pm »
I have written a mission script that worked perfectly before.  Then I added some Cardassian ships in the DefaultLoadOut.txt and DefaultCore.txt, and added them to the map.  When the game starts, the server is able to create quite a few ships for AI population of the map with no errors.  I can even attack the AI's that were created with no problems.   When I try to create a Cardassian ship in the mission script, I get a "Debug Assertion Failed" message for line 421 of Teaminfo.cpp.  I don't think it's the way I'm creating the ships because it works fine for Fed/Rom/Borg/Klink races.  Anyone have any idea what could cause this?  Do I need to modify something else to get the game to recognize the Cardassians?  Please help!!!!

Thanks,

Tombstone
 

The_Pelican

  • Guest
Re: NPC Race problem creating ships.
« Reply #1 on: September 15, 2003, 01:10:34 am »
Can you post the code? It'll be easier to see where you are going wrong then.

Tombstone

  • Guest
Re: NPC Race problem creating ships.
« Reply #2 on: September 15, 2003, 07:42:50 am »
Code snippet is below.  In addition to this problem, the server does not create any AI defenders or weapons platforms in Planet and starbase assult missions (stock missions).  This code works perfectly as long as "surprisedRace" is not Cardassian.  Any help you can provide would be greatly appreciated.

   tTeamInfo* playerTeam = fMissionInfo->mGetTeamHandle( static_cast< eTeamID >( kDefendTeam1 ) );

   tMetaLocationSpec currentHex( 0, kAnyRaceHex, kAnyTerrainHex );
   fMissionInfo->mGetHexType( currentHex );
   
   
   eRaceName  surprisedRace = mTranslateHexIntoRace( currentHex );

   int32 shipDice = fMissionInfo->mRandomInt32( 1, 100 );

   if( surprisedRace == kNeutralRace || surprisedRace == playerTeam->mGetRace())
   {
      do
      {
         int32 RaceDice = fMissionInfo->mRandomInt32( 1, 100 );
         if( RaceDice > 100 )
         {
            surprisedRace = kBorg;
         }
         if( RaceDice > 80 )
         {
            surprisedRace = kRomulan;
         }
         if( RaceDice > 60 )
         {
            surprisedRace = kFederation;
         }
         if( RaceDice < 40 )
         {
            surprisedRace = kKlingon;
         }
         if( RaceDice <= 20 )
         {
            surprisedRace = kCardassian;
         }
      } while( surprisedRace == playerTeam->mGetRace() );
   }

   eClassTypes SuprisedWingmanClass = ( static_cast<eClassTypes>(int32(gWC.fPlayerShipClass) - 1 ));

   mCreateFleet( typeid( tSuprisedTeamShip ), 1, kMaxBPV, gWC.fPlayerShipClass, gWC.fPlayerShipClass, 100, kStartPosition_P, kSuprisedShipOne, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kDefaultShipOptions ), surprisedRace );

   mCreateFleet( typeid( tSuprisedTeamShip ), 1, kMaxBPV, SuprisedWingmanClass, SuprisedWingmanClass,  100, kStartPosition_Q, kSuprisedShipTwo, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kDefaultShipOptions ), surprisedRace );

 

The_Pelican

  • Guest
Re: NPC Race problem creating ships.
« Reply #3 on: September 15, 2003, 11:16:52 am »
Don't know why you have the "do" section there, elseif would be much easier to manage.

From what I can tell, your only problem could be that you don't have a full set of Cardassian Ship Models. As the class of the Enemy Ships are defined by the Player's Class. You'd need one for each class that a Player Ship can fly (which presumably is all 7)

Planet & Base Defence would suffer from the same problem, as you need a full set, one for each class for every race.

Also, you need to add a "SurprisedTeam->" before your mCreateFleet (presuming the enemy team variable is "SurprisedTeam"), or the script will be less reliable.

I've got all 9 races to work perfectly, as long as there is a ship for each class, then it should load them up. Of course, you need to make sure the ships themselves load up!!!

Tombstone

  • Guest
Re: NPC Race problem creating ships.
« Reply #4 on: September 15, 2003, 06:13:21 pm »
I confirmed that I do have at least 1 ship defined for each hull class in DefaultCore.txt and DefaultLoadOut.txt (actually I have several of each).  I tried your suggestion and set each ship as my startup ship and logged onto the server, and they all load fine and work properly on the map and in refit.  Grasping at straws, I tried hardcoding the hull class and race as below and commented out all the other code from the previous snippet, and I still get the same error.

SuprisedTeam->mCreateFleet( typeid( tSuprisedTeamShip ), 1, kMaxBPV, kClassFrigate, kClassFrigate, 100, kStartPosition_P, kSuprisedShipOne, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kDefaultShipOptions ), kCardassian );

Is there anything else I can try?  Is the DefaultCore.txt and DefaultLoadOut.txt the only places I have to adjust to include the Cardassians?

I REALLY appreciate you taking the time to help me out.

Tombstone
 

The_Pelican

  • Guest
Re: NPC Race problem creating ships.
« Reply #5 on: September 17, 2003, 11:57:26 am »
By rights, that should work.... I don't know why it isn't.

There has to be something that we are overlooking, something that doesn't involve the creating of the ships.

What is the team definition in Meta_MissionName? That could be the cause.

Tombstone

  • Guest
Re: NPC Race problem creating ships.
« Reply #6 on: September 19, 2003, 01:01:40 pm »
The following is the code for the TeamSpecs from the mScriptSpecs method:

Specs->fMissionTitle = Messages[kMissionTitle_msg];
Specs->fMissionDescription = Messages[kShortBriefing_msg];
Specs->fMissionType = kCampaignMission;
Specs->fMetaLocationSpec = tMetaLocationSpec( 1, kAnyRaceHex, kAnyTerrainHex );
Specs->fMinDate = kMinDate;
Specs->fMaxDate = kMaxDate;
Specs->fWait= 5;
Specs->fMinBPV= kMinBPV;
Specs->fBandwidthPart = static_cast<eBandwidthPart>( k4Band | k2Client );
Specs->fGenericFlags = kNoGenericFlags;
Specs->fMissionBriefingSoundFile = -1;   

const tTeamSpec& team1 = mCreateTeamSpec( "Defend Team1", static_cast< eTeamID>( kDefendTeam1 ), MaxChance, kTrue, kPrimaryTeam, kMinChance, kSpecPlayableRace, kAnyRace, typeid( tDefendTeam ), kNoTeamTag, Messages[kPlayerTeamDefender_msg] );
   
const tTeamSpec& team2 = mCreateTeamSpec( "Suprised Team", static_cast< eTeamID>( kSuprisedTeam ), kMaxChance, kTrue, kNPCTeam, kMaxChance, kSpecAnyRace, kAnyEnemyOf | kDefendTeam1, typeid( tSuprisedTeam ) );

Specs->mSetupTeam( team1 );
Specs->mSetupTeam( team2 );

I fixed the missing weapons platforms (directory name didn't match the model name) and some of the stock missions use the actual UI ship/shipyard/platform names in mCreateShip instead of the kClass<hulltype> ranges (ie: Meta_Hail_Shipyard has "Hideki" hardcoded for defenders).  Using the ship names method creates the ships with no problems.  It seems to be a problem with using the hull class ranges.  If I use the mCreateFleet method, specifying kClassDestroyer for both smallest and largest hull class, it crashes.  If I use the mCreateShip and specify the actual Ship name of a Destroyer, it works fine.  Could this be a bug in the API for hull class ranges for the Cardassian race?  Do you use mCreateFleet or mCreateShip using hull class ranges for the Cardassians?

Thanks again for all your help.

Tombstone
 

The_Pelican

  • Guest
Re: NPC Race problem creating ships.
« Reply #7 on: September 20, 2003, 11:59:36 am »
I create all of my ships using Hull Classes. This is the code I use

for( int32 l = 0; l < numberOfEnemies; ++l )
            {
               switch( PlayerClass )
               {
               case kClassFrigate:
                  enemyTeam->mCreateFleet( typeid( tShipInfo ), 1, playerBPV, kClassFrigate, kClassFrigate, 7500, kStartPosition_V + l,
                                    NULL, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kStartPositionCanBeOffset ), raceOfEnemies );   
               break;
               case kClassDestroyer:
                  enemyTeam->mCreateFleet( typeid( tShipInfo ), 1, playerBPV, kClassFrigate, kClassDestroyer, 7500, kStartPosition_V + l,
                                    NULL, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kStartPositionCanBeOffset ), raceOfEnemies );   
               break;
               case kClassLightCruiser:
                  enemyTeam->mCreateFleet( typeid( tShipInfo ), 1, playerBPV, kClassDestroyer, kClassLightCruiser, 7500, kStartPosition_V + l,
                                    NULL, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kStartPositionCanBeOffset ), raceOfEnemies );   
               break;
               case kClassHeavyCruiser:
                  enemyTeam->mCreateFleet( typeid( tShipInfo ), 1, playerBPV, kClassLightCruiser, kClassHeavyBattlecruiser, 7500, kStartPosition_V + l,
                                    NULL, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kStartPositionCanBeOffset ), raceOfEnemies );   
               break;
               case kClassHeavyBattlecruiser:
                  enemyTeam->mCreateFleet( typeid( tShipInfo ), 1, playerBPV, kClassHeavyCruiser, kClassDreadnought, 7500, kStartPosition_V + l,
                                    NULL, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kStartPositionCanBeOffset ), raceOfEnemies );   
               break;
               case kClassDreadnought:
                  enemyTeam->mCreateFleet( typeid( tShipInfo ), 1, playerBPV, kClassHeavyBattlecruiser, kClassDreadnought, 7500, kStartPosition_V + l,
                                    NULL, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kStartPositionCanBeOffset ), raceOfEnemies );   
               break;
               case kClassBattleship:
                  enemyTeam->mCreateFleet( typeid( tShipInfo ), 1, playerBPV, kClassHeavyBattlecruiser, kClassBattleship, 7500, kStartPosition_V + l,
                                    NULL, 0, 0, -1, -1, NULL, static_cast<eShipOptions>( kStartPositionCanBeOffset ), raceOfEnemies );   
               break;
               }
            }

It's not as "efficient" as yours, but it's never failed yet, so I am loathe to change it.

I can't actually see a reason why your script isn't working, especially when you are specifying the hull class. Only thing I can think of is BPV, I always use the Player's BPV as the base level, because of my class definition, it's always pretty close to the Classes of ships I want to create. Outside of that, I can't think of anything else, it all looks fine to me.

There is one thing I forgot to ask - you didn't alter the RaceNames.gf file did you?
« Last Edit: September 20, 2003, 12:00:21 pm by The_Pelican »

Tombstone

  • Guest
Re: NPC Race problem creating ships.
« Reply #8 on: September 20, 2003, 05:02:16 pm »
No sir, never touched the RaceNames.gf file.  It still says "Cardassian Union".  If you don't mind, I'd like to copy/paste your creation routine into one of my scripts and see if it makes my problem go away.  At least then, I'll have a reference and be able to compare to find the problem.

Thanks yet again.

Tombstone
 

The_Pelican

  • Guest
Re: NPC Race problem creating ships.
« Reply #9 on: September 20, 2003, 07:37:31 pm »
Feel free to use my code, I'm hoping to find time to make the code for all of my scripts available, once I've added a few notes (I rarely make any while coding)

If the problem persists, the best solution would be to zip up the code (remember to delete the Debug/Release files first) and send it to me. They're only a few k, you should be able to e-mail it. (thepelican001@btopenworld.com)

I'll then build it, and try it out with my settings, I at least know that all my Cardassian Ships will load up, so I can tell you whether it's the code, or something in the core/loadout files.