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

Go down

(Old code tutorial) Adding a Projectile from Wolf Planet forum Empty (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



Define Statetypes in WL_ACT2.C


// 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:


= 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:


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

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

Writte by Deathshead on Thu Apr 07, 2005 9:05 am
Officer-M. John (Admin)
Officer-M. John (Admin)

Posts : 422
Join date : 2015-10-02
Age : 21

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

Back to top Go down

Back to top

- Similar topics

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