//**********************WEAPON MASTER*********************//
//***
//**************************END***************************//
//************************INCLUDES************************//
//**************************END***************************//
//**************************NOTES*************************//
//***No Notes.
//**************************END***************************//
//**************************TODO**************************//
//***No Todo
//**************************END***************************//
//********************GLOBAL VARIABLES********************//
//***Any global variables go here. This is NOT the place
//***for entities or other such declarations.
VECTOR gunLeft;
VECTOR gunRight;
var laserActive;
VECTOR mouseTemp;
VECTOR laserDir; //Direction the space dust blows
VECTOR pPos;
//**************************END***************************//
//************************ENTITIES************************//
//***All entity declarations go here. (Unless local only!)
ENTITY* bullet;
ENTITY* tracer;
//**************************END***************************//
//************************FUNCTIONS***********************//
//***All function declarations go here.
function weapon_fire(); //Fires the weapons
function weapon_laser(PARTICLE* p); //Fires the laser
function laser_fade(PARTICLE* p); //Turns off the laser
//**************************END***************************//
//********************OTHER DECLARATIONS******************//
//***All other declarations like panels, sprites, etc
//***get thrown in here. Keep them organized in sections!
BMAP* laser = "laser_blue.tga";
//**************************END***************************//
//**********************FUNCTION CODE*********************//
//***All function code goes here. Try to keep this neat and
//***write your functions in groups in seperate files if
//***possible.
//Fires the weapons
function weapon_fire() {
vec_for_vertex (gunLeft, player, 679);
vec_for_vertex (gunRight, player, 737);
if (mouse_left) {
if (laserActive != 1) {
tracer = ent_create("bullet.mdl",nullvector,NULL);
effect (weapon_laser, 1, gunLeft, nullvector);
}
laserActive = 1;
}
}
//Laser weapon
function weapon_laser(PARTICLE* p) {
p.flags |= (BRIGHT | BEAM | TRANSLUCENT);
p.event = laser_fade; //Move to faster function
p.size = 0.6;
p.bmap = laser; //the effect bitmap
}
function laser_fade(PARTICLE* p) {
if (mouse_left == 0) {
p.lifespan = 0;
laserActive = 0;
}else{
p.lifespan = 100;
vec_set(p.x,gunLeft);
vec_set(mouseTemp,vector(mouse_pos.x,mouse_pos.y,2000));
vec_for_screen(mouseTemp,camera);
vec_set(pPos,mouseTemp); //Sets the position to the camera
temp.x = cos(camera.pan); //Computes for pan & tilt
temp.y = sin(camera.pan);
temp.z = 600*cos(camera.tilt);
pPos.x = pPos.x + temp.z*temp.x; //Sets the final positions
pPos.y = pPos.y + temp.z*temp.y;
pPos.z = pPos.z + 600*sin(camera.tilt);
vec_set(laserDir,camera.x); //Sets the vector to camera pos
vec_sub(laserDir,pPos.x); //Subtracts the position of the emitter
//vec_scale(laserDir,0.05); //Scales the vector, so things don't go too fast.
vec_inverse(laserDir);
vec_set(p.vel_x,laserDir);
vec_set(tracer.x,laserDir);
}
}
//**************************END***************************//