summaryrefslogtreecommitdiffstats
path: root/src/CBot/tests/scenarios/a1.txt
blob: 165bc95b0f7b1af4e1d2edc8288ffc70cbdcb849 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
object radarGuepe(point orig, float dist)
{
	int i;
	object pr, r;
	float mindist;
	
	i = 0;
	mindist = 1000;
	while (i<30)
	{
		pr = radar(i);
		if (pr != null)
		{
			
			if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
			{
				mindist = distance(orig, pr.position);
				r = pr;
			}
		}
		i = i+1;
	}
	if (mindist < dist) return(r); else return(null);
}


class Guepe
{
	
	point pos;
	
	
	void cherche(point orig, float dist)
	{
		object p;
		point o;
		
		p = radarGuepe(orig, dist);
		while (p == null)
		{
			wait(0.1);
			p = radarGuepe(orig, dist);
		}
		
		pos.x = p.position.x;
		pos.y = p.position.y;
		pos.z = p.position.z;
		
		//o = p.position;
		//wait(0.1);
		
		//vitessex = (p.position.x - o.x)/0.1;
		//vitessey = (p.position.y - o.y)/0.1;
		//vitessez = (p.position.z - o.z)/0.1;
		
	}
	
	
	void tire(point orig, float orient)
	{
		//float t = 3;          //temps d'anticipation
		float angle;
		point cible;
		
		cible.x = pos.x;// + t*vitessex;
		cible.y = pos.y;// + t*vitessey;
		cible.z = pos.z;// + t*vitessez;
		
		if (cible.x == 0) angle = 90; else
		  angle = atan(cible.y / cible.x);
		if (cible.x < 0) angle = angle + 180;
		angle = angle - orient;
		if (angle > 180) angle = angle - 360;
		if (angle < -180) angle = angle + 360;
		turn(angle);
		
		angle = atan((cible.z-orig.z) / distance2d(orig, cible));
		aim(angle);
		
		fire(0.1);
		
	}
}

extern void object::Fourmi6()
{
	//fps(1000);
	Guepe guepe = new Guepe();
	
	while (true)
	{
		guepe.cherche(position, 50);
		
		guepe.tire(position, orientation);
	}
}