man i`m a dunce, i forgot to write function, however the target sprite still is not appearing, here is all the code from the test level
Code:
string stars_mdl = "stars.mdl";
string galor_mdl = "galor.mdl";
string excelsior_mdl = "excelsior.mdl";
entity* enemy;
string lockon = "lockon+3.tga";
string cphaser_mdl = "cphaser.mdl";
bmap hempire_tga = "hempire.tga";
function stars();
function c_ship();
function f_ship();
function event_scn();
function got_target();
//function beam_weapons();
function main
{
///init_radar();
mouse_map = hempire_tga;
mouse_mode = 1;
level_load ("new_beginings.wmb");
wait(1);
ent_create (stars_mdl, nullvector, stars);
ent_create (galor_mdl, vector(0, 0, 0), c_ship);
ent_create (excelsior_mdl, vector(100,0,0), f_ship);
///ent_create (excelsior_mdl, vector(200,40,0), f_ship);
///ent_create (jungle_mdl, vector(1500, 10000, 0), planets);
///ent_create (clouds_mdl, vector(1500, 10000, 0), clouds);
///ent_create (jungle_mdl, vector(25000, 10000, 0), planets);
/// ent_create (clouds_mdl, vector(25000, 10000, 0), clouds);
while (1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
wait (5);
}
}
function c_ship
{
player = my;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
while(1)
{
if(you == null)
{
c_scan(player.x, temp, vector(360, 60, 1000),ignore_me+ignore_you);
}
wait(-0.25);
}
}
function f_ship
{
my.scale_x = 2.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
my.enable_scan = on;
my.event = event_scn;
}
var enemy_handle; // a global handle we can use for transferring pointersfunction
function event_scn()
{
if (event_type == event_scan)
{
enemy_handle = handle(me);
ent_create(lockon, my.x, got_target);
}
}
function got_target
{
my.scale_x = 0.1;
my.scale_y = my.scale_x;
my.oriented = on;
my.facing = off;
you = ptr_for_handle(enemy_handle); // now YOU is the enemy
while(you != null)
{
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // turn the target toward the player
vec_set(temp,nullvector);
temp.x = 20; // change this if you need to - the distance in front of the enemy
vec_rotate(temp,my.pan);
vec_add(temp,your.x);
vec_set(my.x,temp);
wait(1);
}
ent_remove(me);
}