Wolf Planet Forum Index Wolf Planet
We want you here!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Tutorial] Adding a Projectile

 
Post new topic   Reply to topic    Wolf Planet Forum Index -> Coding Alliance
View previous topic :: View next topic  
Author Message
Deathshead
Corporal


Joined: 18 Feb 2005
Posts: 87

PostPosted: Thu Apr 07, 2005 9:05 am    Post subject: [Tutorial] Adding a Projectile Reply with quote

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
_________________
Myspace
VampireFreaks
Music4Life
Wolfing Time
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Wolf Planet Forum Index -> Coding Alliance All times are GMT
Page 1 of 1

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Chronicles phpBB2 theme by Jakob Persson (http://www.eddingschronicles.com). Stone textures by Patty Herford.