#include <acknex.h>
#include <default.c>
#define STATE skill
#define ELEVATION skill2
#define COOLDOWN skill4
ENTITY* PLAYER;
// used to check the value on the c_move;
var debugSkill3;
function fire_missile(){
// the local vars
var temp;
my.ambient = 50; // medium bright
my.lightrange = 300; // activate dynamic light
vec_set( my.blue,vector(255,50,50)); // bluish light color
set(me,BRIGHT); // additive blending
vec_scale(my.scale_x, 0.5); // small size
vec_for_bone(temp, you ,"main_missile_tube");
vec_set(my.x,temp) ;
vec_set(my.pan,you.pan);
me.pan = me.pan + 90;
my.tilt = you.ELEVATION;
while( 1 ){
c_move( my,vector( -10 * time_step , 0 , 0 ),NULL,IGNORE_YOU );
if ( HIT_TARGET ){
my.lightrange *= 1+0.5*time_step;
vec_scale(my.scale_x , 1+0.5*time_step); // inflate size of the missile
if (my.scale_x > 3) {
ent_remove(me); // remove the missile after it has inflated to the max
return;
}
}
wait(1);
}
}
function collision_event()
{
// Oops i hit, in this case, another capitalship ( capship3_mdl_000 ).
if(event_type == EVENT_ENTITY)
{
// bring my entity to a halt.
my.skill3 = 0;
debugSkill3 = my.skill3;
}
}
function move(){
my.emask |= ENABLE_ENTITY; //setting sensitive for collision
my.event = collision_event; //assign the event-function
my.skill4 = 1;
while(1){
// assign the key combo's
if(key_w)
my.skill3 -= 0.1;
wait(1);
if(key_s)
my.skill3 += 0.1;
wait(1);
if ( key_d )
//me.pan -= 2 *time_step;
me.pan -= 5 *time_step;
wait(1);
if ( key_a ){
//me.pan += 2 *time_step;
me.pan += 5 *time_step;
wait(1);
}
if ( key_q ){
me.roll += 2 * time_step;
my.ELEVATION = me.roll;
wait(1);
}
if ( key_z ){
me.roll -= 2 * time_step;
my.ELEVATION = me.roll;
wait(1);
}
if ( key_space ){
if ( my.skill4 == 1 )
ent_create("missile.mdl",vector(me.x,me.y , me.z), fire_missile );
wait(1);
my.skill4 = 2;
}
// after releasing the spacebutton, you will be able to fire the weapon again.
// its not a gatlaingun.
// TO DO: some kind of a delay() function for a 'cooldown' period.
if ( !key_space )
if ( my.skill4 == 2 ){
my.skill4 = 1;
}
c_move (me, vector( 0, my.skill3 * time_step, 0), nullvector, GLIDE);
debugSkill3 = my.skill3;
wait(1);
}
}
function main(){
//load the level
level_load("spacetest2.wmb");
wait(2);
// create the capitalship entity
PLAYER = ent_create ( "capship2.mdl", vector( 500,3000,400), move );
// fixed camera position
vec_set(camera.x, vector (-100, 3000, 450));
// capitalship capship3_mdl_000 is already placed in spacetest2.wmb
}