Stargun

1996-06-22 InsideQC tutorials kleskby 0 394
Author: [SL1CK]-=MERL1N=-
Source: https://www.insideqc.com/qctut/qctut-39.shtml



Step 1
What is a star gun I hear ya ask ? Well... Its a gun (der!) that shoots out a star really slow and when the star touches something... well errr... you'll find out :) Open up weapons qc and find that whole "player weapon use" thing (3/4 of the way down).


Step 2
Just before all this is where we are gunna put the star gun in. As usual in QC code (or any code for that matter) everything is backwards, so the first bit we will put in is the touch function (touch wall and boom).

Add this...

void() Star_Touch = // touch function

{

local float damg;

 

if (other == self.owner)

return; // don't explode on owner (seen this before?)

 

if (pointcontents(self.origin) == CONTENT_SKY) // if its hits tha sky

{

remove(self); // get rid of it (crap aim :)

return;

}

 

damg = 500 + random()*3; // do massive amounts of damage

T_RadiusDamage (self, self.owner, 2500, other); // to everything

 

// sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);

self.origin = self.origin - 8*normalize(self.velocity);

 

WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);

WriteByte (MSG_BROADCAST, TE_EXPLOSION);

WriteCoord (MSG_BROADCAST, self.origin_x);

WriteCoord (MSG_BROADCAST, self.origin_y);

WriteCoord (MSG_BROADCAST, self.origin_z);

 

BecomeExplosion (); // play explosion animation

 

};

You can put your own big boom sound in there, I advise that U do too :) and dont forget to precache all of the sounds!


Step 3

Now that it can hit a wall we want to shoot it so paste this under what we just did...

void() W_FireStar =

{

local entity missile, mpuff;

self.currentammo = self.ammo_rockets = self.ammo_rockets - 25; // take away 25 rockets

sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM); // precache!!

 

self.punchangle_x = -3;

 

missile = spawn (); // make it

missile.owner = self; // own it

missile.movetype = MOVETYPE_FLYMISSILE;

missile.solid = SOLID_BBOX;

missile.classname = "missile";

// set missile speed

 

makevectors (self.v_angle);

missile.velocity = aim(self, 100); // move slow

missile.velocity = missile.velocity * 75; // real slow

missile.angles = vectoangles(missile.velocity);

missile.touch = Star_Touch; // hit sumthin, call the func

// set missile duration

missile.nextthink = time + 10; // if still going after 10 secs

missile.think = Star_Touch; // blow it up anyway

 

setmodel (missile, "progs/teleport.mdl"); // dont forget to precache this!

setsize (missile, '0 0 0', '0 0 0');

setorigin (missile, self.origin + v_forward*3 + '0 0 16');

};

 

 

Step 4

If you know how to add a gun to quake, (and by this stage u should) go ahead, the fire func is... obvious :)

Otherwise we will swap the rocket launcher with the stargun...

 Step 5

OK, simply find the IT_ROCKET_LAUNCHER bit under W_attack and swap the W_FireRocket with W_FireStar. Bingo! Stargun mania!!!

Tutorial html coding by Achilles.



Tags: tutorial, quakec, qc, insideqc, weapon
Owned by kleskby#1837
Telegram
Close

You have no new notifications.


You have no new messages.