(Old code tutorial) Merging Boss Spawn Routines from Wolf Planet forum

View previous topic View next topic Go down

(Old code tutorial) Merging Boss Spawn Routines from Wolf Planet forum

Post by Officer-M. John (Admin) on Tue Nov 29, 2016 9:22 am

Merging Boss Spawn Routines

BrotherTank has been mentioning here and there about how he merged the Boss Spawning Routines into one, so I decided to give it a go. It's not actually that hard.

THIS TUTORIAL NOW WORKS FOR SPEAR OF DESTINY

Open WL_DEF.H and search for 'SpawnBoss':

Code:

void SpawnDeadGuard (int tilex, int tiley);
void SpawnBoss (int tilex, int tiley);
void SpawnGretel (int tilex, int tiley);
void SpawnTrans (int tilex, int tiley);
void SpawnUber (int tilex, int tiley);
void SpawnWill (int tilex, int tiley);
void SpawnDeath (int tilex, int tiley);
void SpawnAngel (int tilex, int tiley);
void SpawnSpectre (int tilex, int tiley);
void SpawnGhosts (int which, int tilex, int tiley);
void SpawnSchabbs (int tilex, int tiley);
void SpawnGift (int tilex, int tiley);
void SpawnFat (int tilex, int tiley);
void SpawnFakeHitler (int tilex, int tiley);
void SpawnHitler (int tilex, int tiley);

Change that to look like:

Code:

void SpawnSuperGuard (int tilex, int tiley, int boss);   //the new routine
void SpawnDeadGuard (int tilex, int tiley);
void SpawnGhosts (int which, int tilex, int tiley);

Now, open WL_ACT2.C and delete the SpawnBoss, SpawnGretel, SpawnSchabbs, SpawnGift, SpawnFat, SpawnFakeHitler and SpawnHitler routines.

Lets take a step back before putting in the main routine, just to see why we're doing this:

This is the SpawnBoss routine, used to Spawn Hans Grosse on the map:

Code:

/*
===============
=
= SpawnBoss
=
===============
*/

void SpawnBoss (int tilex, int tiley)
{
   unsigned   far *map,tile;

   SpawnNewObj (tilex,tiley,&s_bossstand);
   new->speed = SPDPATROL;

   new->obclass = bossobj;
   new->hitpoints = starthitpoints[gamestate.difficulty][en_boss];
   new->dir = south;
   new->flags |= FL_SHOOTABLE|FL_AMBUSH;
   if (!loadedgame)
     gamestate.killtotal++;
}

And the SpawnGretel Routine, which Spawns Gretel Grosse on the map:

Code:

/*
===============
=
= SpawnGretel
=
===============
*/

void SpawnGretel (int tilex, int tiley)
{
   unsigned   far *map,tile;

   SpawnNewObj (tilex,tiley,&s_gretelstand);
   new->speed = SPDPATROL;

   new->obclass = gretelobj;
   new->hitpoints = starthitpoints[gamestate.difficulty][en_gretel];
   new->dir = north;
   new->flags |= FL_SHOOTABLE|FL_AMBUSH;
   if (!loadedgame)
     gamestate.killtotal++;
}

Notice that both share the same statements, except for the 'new->obclass', 'new->obspeed' and 'SpawnNewObj'. So, infact, there is only three lines difference in each routine. What the next routine does, is make those common lines universal, and depending on what boss you call will determine the enemy spawned.

Put this code at the bottom of the WL_ACT2.C file:

Code:

/*==
==== SpawnSuperGuard
==== By Deathshead
====
==== Spawns a Boss in the
==== Specified spot
==*/

void SpawnSuperGuard (int tilex, int tiley, int boss)
{
    unsigned   far *map,tile;

    switch (boss)
    {
#ifndef SPEAR
        case en_boss:
                SpawnNewObj (tilex,tiley,&s_bossstand);
                new->obclass = bossobj;
                break;

        case en_gretel:
                SpawnNewObj (tilex,tiley,&s_gretelstand);
                new->obclass = gretelobj;
                break;

        case en_fat:
                if (DigiMode != sds_Off)
                    s_fatdie2.tictime = 140;
                else
                    s_fatdie2.tictime = 5;
                SpawnNewObj (tilex,tiley,&s_fatstand);
                new->obclass = fatobj;
                break;

        case en_schabbs:
                if (DigiMode != sds_Off)
                    s_schabbdie2.tictime = 140;
                else
                    s_schabbdie2.tictime = 5;
                SpawnNewObj (tilex,tiley,&s_schabbstand);
                new->obclass = schabbobj;
                break;

        case en_gift:
                if (DigiMode != sds_Off)
                    s_schabbdie2.tictime = 140;
                else
                    s_schabbdie2.tictime = 5;
                SpawnNewObj (tilex,tiley,&s_giftstand);
                new->obclass = giftobj;
                break;

        case en_fake:
                SpawnNewObj (tilex,tiley,&s_fakestand);
                new->obclass = fakeobj;
                break;

        case en_hitler:
                if (DigiMode != sds_Off)
                    s_hitlerdie2.tictime = 140;
                else
                    s_hitlerdie2.tictime = 5;
                SpawnNewObj (tilex,tiley,&s_mechastand);
                new->obclass = mechahitlerobj;
                break;
#else
   case en_spectre:
      SpawnNewObj (tilex,tiley,&s_spectrewait1);
      new->obclass = spectreobj;
      break;

   case en_angel:
      if (SoundBlasterPresent && DigiMode != sds_Off)
         s_angeldie11.tictime = 105;

      SpawnNewObj (tilex,tiley,&s_angelstand);
      new->obclass = angelobj;
      break;

   case en_death:
      if (SoundBlasterPresent && DigiMode != sds_Off)
         s_deathdie2.tictime = 105;

      SpawnNewObj (tilex,tiley,&s_deathstand);
      new->obclass = deathobj;
      break;

   case en_will:
      if (SoundBlasterPresent && DigiMode != sds_Off)
         s_willdie2.tictime = 70;

      SpawnNewObj (tilex,tiley,&s_willstand);
      new->obclass = willobj;
      break;

   case en_uber:
      if (SoundBlasterPresent && DigiMode != sds_Off)
         s_uberdie01.tictime = 70;

      SpawnNewObj (tilex,tiley,&s_uberstand);
      new->obclass = uberobj;
      break;

   case en_trans:
      if (SoundBlasterPresent && DigiMode != sds_Off)
         s_transdie01.tictime = 105;

      SpawnNewObj (tilex,tiley,&s_transstand);
      new->obclass = transobj;
      break;
#endif
    }
    new->hitpoints = starthitpoints[gamestate.difficulty][boss];
    new->dir = nodir;
    new->speed = SPDPATROL;
    new->flags |= FL_SHOOTABLE|FL_AMBUSH;
    if (!loadedgame)
    gamestate.killtotal++;
}

That's the main routine for Spawning Bosses. Now, open WL_GAME.C and search for "SpawnBoss". You should get:

Code:

#ifndef SPEAR
         case 214:
            SpawnBoss (x,y);
            break;
         case 197:
            SpawnGretel (x,y);
            break;
         case 215:
            SpawnGift (x,y);
            break;
         case 179:
            SpawnFat (x,y);
            break;
         case 196:
            SpawnSchabbs (x,y);
            break;
         case 160:
            SpawnFakeHitler (x,y);
            break;
         case 178:
            SpawnHitler (x,y);
            break;

These all use the old routines we deleted earlier. Change them to look like:

Code:

#ifndef SPEAR
         case 214:
            SpawnSuperGuard (x,y,en_boss);
            break;
         case 197:
            SpawnSuperGuard (x,y,en_gretel);
            break;
         case 215:
            SpawnSuperGuard (x,y,en_gift);
            break;
         case 179:
            SpawnSuperGuard (x,y,en_fat);
            break;
         case 196:
            SpawnSuperGuard (x,y,en_schabbs);
            break;
         case 160:
            SpawnSuperGuard (x,y,en_fake);
            break;
         case 178:
            SpawnSuperGuard (x,y,en_hitler);
            break;

You'd also have to do this with all the Spear bosses and Spectre.

That concludes my tutorial. Should you use this, please include me in the credits, and send me an email at deathshead.frozenfire@gmail.com , I would like to see your project!

NB: This routine could probably be editted to save even more memory.

There you go
-Deathshead

Writte by Deathshead on Wed Apr 06, 2005 11:41 am
avatar
Officer-M. John (Admin)
Admin

Posts : 323
Join date : 2015-10-02
Age : 19

View user profile http://wolf3dfanboys.usersboard.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum