Well, here's my first big tutorial, so there's bound to be mistakes It comes from my project source, so if you have any problems let me know and I'll try to fix it. I said flame wall, but really it is just using the rocket, you'll have to add your own flame projectile. Some credit goes to Wolf3DBreaker, as I used a modified portion of his code for player shooting projectiles in the T_Projectile function (so it will kill guards).
It uses an object to spawn rockets at set intervals rather than the actor concept I've already seen on these forums. Hopefully this runs alot faster and takes less memory & data bytes.. Also note that I haven't made the switch to turn it off yet, I'll update the tut when I do. Also, you can have as many as you want, however they all currently shoot EAST.
Okay, here we go. First we'll need to add a new flag, so open up "WL_DEF.H". Look for this code, near the top, and add the red line:
Next, go to the gamestate structure, and add this:
Close that file, and open "WL_PLAY.C". The majority of the code is here. Scroll down to the play loop function (at the very bottom) and add the red lines:
Now, at the very bottom of the file, add this:
FireObject is whatever object you want to spawn the fire. You could modify this to include multible objects for diffrent directions.
Now close that file, and open up "WL_ACT2.C". Go to the T_Projectile function, and add the red lines:
Close that file. Now, I'm assuming you'll want the firewalls to come on every level if you add a switch to turn them off...simple. Open up "WL_INTER.C". In the PreloadGraphics function, add this:
Ta da! Now place object 600 in your favorite map editor (preferably in front of a wall) and watch rockets fly from it! I'll add the code for the switch later. Remeber to give credit, and please report any bugs!
EDIT: Seems red doesn't work in code boxes like on DHW. Well, just add what's between the [color] boxes, don't actually add those
It uses an object to spawn rockets at set intervals rather than the actor concept I've already seen on these forums. Hopefully this runs alot faster and takes less memory & data bytes.. Also note that I haven't made the switch to turn it off yet, I'll update the tut when I do. Also, you can have as many as you want, however they all currently shoot EAST.
Okay, here we go. First we'll need to add a new flag, so open up "WL_DEF.H". Look for this code, near the top, and add the red line:
- Code:
#define FL_SHOOTABLE 1
#define FL_BONUS 2
#define FL_NEVERMARK 4
#define FL_VISABLE 8
#define FL_ATTACKMODE 16
#define FL_FIRSTATTACK 32
#define FL_AMBUSH 64
#define FL_NONMARK 128
[color=red]#define FL_KILLALL 16[/color]
Next, go to the gamestate structure, and add this:
- Code:
int ammo;
int keys;
weapontype bestweapon,weapon,chosenweapon,nextweapon;
[color=red]boolean firewall;[/color]
Close that file, and open "WL_PLAY.C". The majority of the code is here. Scroll down to the play loop function (at the very bottom) and add the red lines:
- Code:
/*
===================
=
= PlayLoop
=
===================
*/
long funnyticount;
[color=red]long fireticount;[/color]
void PlayLoop (void)
{
int give;
int helmetangle;
playstate = TimeCount = lasttimecount = 0;
frameon = 0;
running = false;
anglefrac = 0;
facecount = 0;
funnyticount = 0;
memset (buttonstate,0,sizeof(buttonstate));
ClearPaletteShifts ();
if (MousePresent)
Mouse(MDelta); // Clear accumulated mouse movement
if (demoplayback)
IN_StartAck ();
do
{
if (virtualreality)
{
helmetangle = peek (0x40,0xf0);
player->angle += helmetangle;
if (player->angle >= ANGLES)
player->angle -= ANGLES;
}
PollControls();
//
// actor thinking
//
madenoise = false;
MoveDoors ();
MovePWalls ();
for (obj = player;obj;obj = obj->next)
DoActor (obj);
UpdatePaletteShifts ();
ThreeDRefresh ();
//
// MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE
//
#ifdef SPEAR
funnyticount += tics;
if (funnyticount > 30l*70)
{
funnyticount = 0;
StatusDrawPic (17,4,BJWAITING1PIC+(US_RndT()&1));
facecount = 0;
}
#endif
[color=red]
fireticount+=tics;
if (fireticount>100)
{
FireScan();
fireticount=0;
}
[/color]
rest of function skipped...
Now, at the very bottom of the file, add this:
- Code:
[color=red]
/*
===================
=
= Scan for Firewall
=
===================
*/
#define FireObject 600
extern statetype s_rocket; //For Fire Wall
void FireScan (void)
{
int x,y,tile;
if (gamestate.firewall==true) //No sense scanning if it isn't on
{
for (y=0;y<mapheight;y++)
for (x=0;x<mapwidth;x++)
{
tile=MAPSPOT(x,y,1);
if (tile==FireObject)
{
GetNewActor ();
new->state = &s_rocket;
new->ticcount = 1;
new->tilex = x;
new->tiley = y;
//new->x = ob->x;
//new->y = ob->y;
new->x = ((long)x<<TILESHIFT)+TILEGLOBAL/2;
new->y = ((long)y<<TILESHIFT)+TILEGLOBAL/2;
new->obclass = rocketobj;
new->dir = nodir;
new->angle = 0;
new->speed = 0x2000l;
new->flags = FL_NONMARK | FL_KILLALL;
new->active = true;
}
}
}
}[/color]
FireObject is whatever object you want to spawn the fire. You could modify this to include multible objects for diffrent directions.
Now close that file, and open up "WL_ACT2.C". Go to the T_Projectile function, and add the red lines:
- Code:
// Check if player hit by anything
[color=red]
if (ob->obclass == rocketobj && ob->flags & FL_NONMARK && ob->flags & FL_KILLALL)
{
check = objlist ;
while (check)
{
if (check->flags & FL_SHOOTABLE)
{
deltax = LABS(ob->x - check->x);
deltay = LABS(ob->y - check->y);
if (deltax < PROJECTILESIZE && deltay < PROJECTILESIZE)
{
//if (check->obclass != angelobj)
// PlaySoundLocActor(MISSILEHITSND,ob);
ob->state = &s_boom1;
damage = (US_RndT() >>3) + 30;
DamageActor (check,damage);
}
}
check = check->next ;
}
} [/color]
deltax = LABS(ob->x - player->x);
deltay = LABS(ob->y - player->y);
if (deltax < PROJECTILESIZE && deltay < PROJECTILESIZE)
{ // hit the player
switch (ob->obclass)
{
case needleobj:
damage = (US_RndT() >>3) + 20;
break;
case rocketobj:
case hrocketobj:
// case sparkobj:
damage = (US_RndT() >>3) + 30;
break;
rest of code not included...
Close that file. Now, I'm assuming you'll want the firewalls to come on every level if you add a switch to turn them off...simple. Open up "WL_INTER.C". In the PreloadGraphics function, add this:
- Code:
LatchDrawPic (20-14,80-3*8,GETPSYCHEDPIC);
WindowX = 160-14*8;
WindowY = 80-3*8;
WindowW = 28*8;
WindowH = 48;
VW_UpdateScreen();
VW_FadeIn ();
PM_Preload (PreloadUpdate);
IN_UserInput (70);
VW_FadeOut ();
DrawPlayBorder ();
VW_UpdateScreen ();
[color=red]//Update Variables
gamestate.firewall=true;[/color]
}
Ta da! Now place object 600 in your favorite map editor (preferably in front of a wall) and watch rockets fly from it! I'll add the code for the switch later. Remeber to give credit, and please report any bugs!
EDIT: Seems red doesn't work in code boxes like on DHW. Well, just add what's between the [color] boxes, don't actually add those