home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revista CD Expert 51
/
PCGamer51_17Demos.iso
/
games
/
colobotdemo
/
colobotdemo10e.exe
/
script
/
shield03.txt
< prev
next >
Wrap
Text File
|
2001-06-17
|
1KB
|
34 lines
extern void object::FollowPhazer()
{
object item; // info. about phazer
point dest; // position where to go
float dist; // distance to phazer
item = radar(PhazerShooter);
if ( item == null )
{
message("No phazer found");
return; // stops the program
}
shield(1, 25); // activates the shield
while ( true ) // always repeats:
{
item = radar(PhazerShooter);// looks for phazer
if ( item == null ) break;
dist = distance(item.position, position);
if ( dist < 5 )
{ // if closer than 5 m:
wait(1); // waits
}
else // otherwise:
{ // Calculates a position 5 m before the phazer
dest.x = (item.position.x-position.x)*((dist-5)/dist)+position.x;
dest.y = (item.position.y-position.y)*((dist-5)/dist)+position.y;
dest.z = (item.position.z-position.z)*((dist-5)/dist)+position.z;
goto(dest, 0, 1, 1); // and goes there
}
}
}