Code:
// example
define _distMoved, skill22;
define _hit, flag7;
function projectileEvent() {
if (event_type == event_entity
|| event_type == event_impact
|| event_type == event_push) {
my._hit = ON;
my.event = NULL;
if (you != NULL) { //shouldn't be
//you._hit = ON;
//you._hullIntegrity = max(you._hullIntegrity - my._hitPower, 0);
}
}
}
function move_projectile() {
var maximum_distance = 1000;
var projectile_speed = 50;
var effect_speed = 0;
wait(1);
c_setminmax(me);
my.invisible = on;
//enable events
my.enable_entity = on;
my.enable_impact = on;
my.enable_push = on;
if (player != NULL) {
my.pan = player.pan;
my.tilt = player.tilt;
}
my.event = projectileEvent;
while (me != NULL) {
if (my._distMoved > maximum_distance
|| my._hit == ON) {
break;
}
my._distMoved += c_move (me, vector(projectile_speed, 0, 0), nullvector, ignore_passable);
vec_set (temp.x, my.x);
effect (photon_effect, 1, temp, effect_speed);
wait (1);
}
//removal of entity
if (me != NULL) {
if (my._hit == ON) {
//create hit flash
//play sound using hit flash
} else {
if (my._distMoved >= maximum_distance) {
//fade out?
}
}
ent_remove(me);
}
}