(Old code tutorial) Adding a Projectile from Wolf Planet forum

View previous topic View next topic Go down

(Old code tutorial) Adding a Projectile from Wolf Planet forum

Post by Officer-M. John (Admin) on Sat Mar 26, 2016 8:40 pm

This is one of my earlier tutorials I wrote up and tested:

Add energyobj under needleobj in GLOBALTYPES in WL_DEF.H

Define sprites in WL_DEF.H, under Chaingun Sprites

Code:

SPR_EGY1, SPR_EGY2, SPREGY3,

Define Statetypes in WL_ACT2.C

Code:

//
// energy blast
//

extern   statetype s_energy1;
extern   statetype s_energy2;
extern   statetype s_energy3;

statetype s_energy1    = {false,SPR_EGY1,6,T_Projectile,NULL,&s_energy2};
statetype s_energy2    = {false,SPR_EGY2,6,T_Projectile,NULL,&s_energy3};
statetype s_energy3    = {false,SPR_EGY3,6,T_Projectile,NULL,&s_energy1};

And add to WL_ACT2.C, above T_GiftThrow Function:

Code:

/*
=================
=
= T_Energy
=
=================
*/

void T_Energy (objtype *ob)
{
   long   deltax,deltay;
   float   angle;
   int      iangle;

   deltax = player->x - ob->x;
   deltay = ob->y - player->y;
   angle = atan2 (deltay,deltax);
   if (angle<0)
      angle = M_PI*2+angle;
   iangle = angle/(M_PI*2)*ANGLES;

   GetNewActor ();
   new->state = &s_energy1;
   new->ticcount = 1;

   new->tilex = ob->tilex;
   new->tiley = ob->tiley;
   new->x = ob->x;
   new->y = ob->y;
   new->obclass = energyobj;
   new->dir = nodir;
   new->angle = iangle;
   new->speed = 0x2000l;

   new->flags = FL_NONMARK;
   new->active = true;

   PlaySoundLocActor (SCHABBSTHROWSND,new);
}

Add under case needleobj: damage = (US_RndT() >>3) + 20; break; in WL_ACT2.C:

Code:

case energyobj:
         damage = (US_RndT() >>4) + 10;
         break

Then choose which enemy you want to use it, edit the statetypes, and your done.
You can even make a rocket type projectile, where it is 'directional'.

There you go
-Deathshead

Writte by Deathshead on Thu Apr 07, 2005 9:05 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