#include <acknex.h>
#include <default.c>
#define STATE skill
#define ELEVATION skill2
#define COOLDOWN skill4
ENTITY* PLAYER;
var camera_distance = -200;
// used to check the value on the c_move;
var debugSkill3;
var debugHitx;
var debugHity;
var debugHitz;
var debugMyX;
var onbekend;
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 ){
VECTOR trace_target;
vec_set(trace_target,vector(2000,0,0)); // the weapon has a firing range of 2000 quants
vec_rotate(trace_target, camera.pan);
vec_add(trace_target, my.x);
c_move( my,vector( -10 * time_step , 0 , 0 ),NULL,IGNORE_YOU );
debugMyX = my.x;
// if the missile misses, it has a 2000 quant livespan
if ( my.x > 2000 ){
ent_remove(me);
return;
}
if ( HIT_TARGET ){
ent_remove(me);
//your.vmask |= 1<<hit.subset;
onbekend = hit.subset;
//draw a square where the entity got hit.
draw_point3d(hit.x,vector(0,0,0),0,25);
//your.vmask |= 1<<hit.subset; // make mesh group invisible
//without the return, the script crashes and burns when my missile hits the other capship.
//unsure why that happens.
return;
}
wait(1);
}
}
// collision_event when 2 capitalships fysically run into eachother.
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;
debugHitx = hit.x;
debugHity = hit.y;
debugHitz = hit.z;
}
}
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 (PLAYER.x - 500, PLAYER.y , PLAYER.z) );
// capitalship capship3_mdl_000 is already placed in spacetest2.wmb
}