File: worm01.txt

package info (click to toggle)
colobot 0.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 415,532 kB
  • sloc: cpp: 129,246; ansic: 8,872; python: 2,158; sh: 672; awk: 91; xml: 35; makefile: 31
file content (31 lines) | stat: -rw-r--r-- 677 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
extern void object::Attack( )
{
	int		enemy;
	object	p;
	float	dist, prox;
	point	dest;

	errmode(0);  // ne stoppe pas si erreur
	while ( ismovie() != 0 )  wait(1);

	enemy = WheeledGrabber;

	while ( true )
	{
		p = radar(enemy);  // cherche cible
		if ( p == null )
		{
			wait(2);
		}
		else
		{
			dist = distance(p.position, position);
			prox = dist/2;  // on se rapproche
			if ( prox < 2.5 )  prox = 2.5;  // pas trop tout de même
			dest.x = (position.x-p.position.x)*prox/dist + p.position.x;
			dest.y = (position.y-p.position.y)*prox/dist + p.position.y;
			dest.z = (position.z-p.position.z)*prox/dist + p.position.z;
			goto(dest);  // va sur la cible
		}
	}
}