Inside3D tutorials.

Inside3D
 • Front Page
 • Articles
 • Downloads
 • Forums
 • Hosting
 • Help Wanted
 • Interviews
 • Reviews
 • Staff

 
Allied Sites
 - AI Cafe
 - Bot Epidemic
 - Dark Places
 - Flat Earth
 - FrikBot
 - Ghoulish Art
 - Kilbert3D
 - Quake Info Pool
 - QSG: Quake Standards
 - Rusted Fork
 - Stroggs Gone Mad
 - More...
 
Quake
 - Getting Started
 - QuakeC Specs v1.0
 - QuakeC Tutorials
 - Quake Mod Index
 
Quake II
 - Getting Started
 - dll Sourcecode
 - Coding Tutorials
 
.dll Central
 - Getting Started
 - Learning
 - dll Primer
 - dll in C
 - dll in Delphi
 - Compilers
 
Jedi Knight
 - Getting Started
 - COG Specs
 - Sound Specs
 - Tutorials
 
Level Editing
 - Tutorials/Tips
 
 
Telefragged!!!
Created By: Mr. Pink
eMail: mrpink@hempseed.com
Difficulty Scale: Easy/Medium


Step 1
In this tutorial we are gonna make a Homing Rocket... cool right?.. well lets get started. First open Weapons.qc scroll down until the W_FireRocket section and write the code in blue:
/*
================
W_FireRocket
================
*/

void()   RockThink;
entity() RockFindTarget;
float(entity targ) visible;
float(entity targ) infront;


void() W_FireRocket =
Step 2
Next what you need its to add or remove the code in blue:
void() W_FireRocket =
{
	local	entity missile, mpuff;
	
	self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
	
	sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);

	self.punchangle_x = -2;

	missile = spawn ();
	missile.owner = self;
	missile.movetype = MOVETYPE_FLYMISSILE;
	missile.solid = SOLID_BBOX;
        missile.classname = "missile";  //delete this line
		
// set missile speed	

	makevectors (self.v_angle);
	missile.velocity = aim(self, 1000);
	missile.velocity = missile.velocity * 300; //Change the velocity of the Rocket to 300 (slower)
	missile.angles = vectoangles(missile.velocity);
	
	missile.touch = T_MissileTouch;
	
// set missile duration
	missile.nextthink = time + 0.2; //Change the nexttime from 5 to 0.2
	missile.think = RockThink;  //Change the nextthink from SUB_remove to RockThink
	missile.enemy = world;

	setmodel (missile, "progs/missile.mdl");
	setsize (missile, '0 0 0', '0 0 0');		
	setorigin (missile, self.origin + v_forward*8 + '0 0 16');
};


Step 3
Third, write this code under the W_FireRocket function:


entity() RockFindTarget = 
{
	local entity head, selected;
	local float dist;
	dist = 100000;
	selected = world;
	head = findradius(self.origin, 100000);
	while(head)
	{
		if( (head.health > 1) && (head != self) && (head != self.owner) )
		{
			traceline(self.origin,head.origin,TRUE,self);
			if ( (trace_fraction >= 1) && (vlen(head.origin - self.origin) < dist) )
			{
				selected = head;
				dist= vlen(head.origin - self.origin);
			}
		}
		head= head.chain;
	}
	if (selected != world)
	{
		sprint (self.owner,homing); //prints that the rocket is homing somebody
		if (selected.classname == "player") //tells you the rocket its homing a player
		{
			sprint (self.owner,selected.netname);
			sprint (selected,self.owner.netname);
			sprint (selected," sended a rocket after you!\n"); //Change what it says.. it sucks
		else
			sprint (self.owner,selected.classname); //if not a player, tell what classname 
		sprint (self.owner,"\n");
	}
	return selected;
};


Step4
Now this is the final step... write this down of the W_RockFindTarget function:


void() RockThink =
{
	local vector dir, vtemp;

	if ( !(self.enemy) || (self.enemy == world) || (self.enemy.health < 1) )
		self.enemy="RockFindTarget();" //find a enemy to kill

	if (self.enemy != world) 
	{
		vtemp = self.enemy.origin + '0 0 10';
		dir = normalize(vtemp - self.origin);
		self.velocity = dir * 250;
		self.angles = vectoangles(self.velocity);
	}

	self.nextthink = time + 0.2;
	self.think=RockThink;
};


Step 5
Hey were done!! compile it ... and go kill something, hope you like this Tutorial... thanks Inside3D for letting me post this, and some feedback will be cool.






The Inside3D content and design is copyrighted by the Inside3D team, and may not be re-produced or copied without proper consent. All rights reserved. Any work credited to any author not part of InsideQC is copyrighted by that author. If you have any feedback, suggestions or flames please send it in to the author. Inside3D is hosted by telefragged and the design was originated by project-9.