Posted By: jigalypuff
a query about c_scan - 08/11/07 16:46
i am trying to write a targeting code, i figured c_scan would be the best thing for this as c_trace only goes in a straight line and this is for a spaceship, which should be able to scan all around itself. i want it to run all the time, but i`m a bit stumped on how this actually works, all the tuts seem to require a button being pressed, but i want it to scan automaticly then if it finds a target i want it to lock on to that target untill it is destroyed. i have a bit of test code and would dearly love some pointers on which way to work this, thanks.
Code:
Code:
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 (key_1 == on)
{
c_scan(player.x, temp, vector(360, 60, 1000), ignore_me);
}
wait(1);
}
}
function f_ship
{
enemy = my;
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;
}
function event_scn()
{
if (event_type == event_scan)
{
ent_create(lockon, my.x, got_target);
}
}
function got_target
{
my.scale_x = 0.1;
my.scale_y = my.scale_x;////scale the sprite so it`s no huge
}