/usr/share/games/colobot/ai/antattsw.txt is in colobot-common 0.1.6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | extern void object::Attack( )
{
int list[], i; // liste des objets cherchés
object target; // info sur la cible
point lastPos; // dernière position (pr test si bloquée)
float distTar; // distance de la cible
float dirTar; // direction de la cible
float r; // valeur aléatoire
float mp; // puissance moteur
float tangle; // angle d'esquive en cas d'eau
boolean ifmove; // si on avance en tirant ou pas
errmode(0); // ne stoppe pas si erreur
while ( ismovie() != 0 ) wait(1);
i = 0;
list[i++] = WingedGrabber;
list[i++] = TrackedGrabber;
list[i++] = WheeledGrabber;
list[i++] = LeggedGrabber;
list[i++] = WingedShooter;
list[i++] = TrackedShooter;
list[i++] = WheeledShooter;
list[i++] = LeggedShooter;
list[i++] = WingedOrgaShooter;
list[i++] = TrackedOrgaShooter;
list[i++] = WheeledOrgaShooter;
list[i++] = LeggedOrgaShooter;
list[i++] = WingedSniffer;
list[i++] = TrackedSniffer;
list[i++] = WheeledSniffer;
list[i++] = LeggedSniffer;
list[i++] = Thumper;
list[i++] = PhazerShooter;
list[i++] = Recycler;
list[i++] = Shielder;
list[i++] = Subber;
list[i++] = Me;
list[i++] = Derrick;
list[i++] = BotFactory;
list[i++] = PowerStation;
list[i++] = Converter;
list[i++] = RepairCenter;
list[i++] = DefenseTower;
list[i++] = ResearchCenter;
list[i++] = RadarStation;
list[i++] = ExchangePost;
list[i++] = PowerPlant;
list[i++] = AutoLab;
list[i++] = NuclearPlant;
// wait(cmdline(0)); // attend pour entrer en action
lastPos = position; // initialise
ifmove = true;
while ( true ) // répète à l'infini
{
target = radar(list);
dirTar = direction(target.position);
distTar = distance(position, target.position);
if(distTar<40)
{
turn(dirTar);
fire(target.position);
target = radar(list);
turn(direction(target.position));
for(int i=0; i<3; i=i+1)
{
if(topo(position)<2 or distance(position, target.position) < 8 or !ifmove)
{
ifmove = false;
}
else
{
lastPos = position;
motor(1,1);
wait(0.5);
if (distance(position, lastPos) < 0.2) ifmove = false;
}
}
}
else
{
ifmove = true;
if (distance(lastPos, position) < 0.2)
{ //si elle est bloquée par obstacle
lastPos = position;
turn(rand()*360-180);
motor(1,1);
wait(1);
target = radar(list);
turn(direction(target.position));
}
else
{
lastPos = position;
if (topo(position)>1)
{
mp = direction(target.position)/180;
//if (mp>1) mp = 1;
//if (mp<-1) mp = -1;
if (mp>0)
{
motor(1-mp,1);
}
else
{
motor(1,1+mp);
}
wait(1);
}
else
{
motor (-0.5, -0.5);
wait(1.5);
target = radar(list);
turn(direction(target.position));
tangle = 0;
do
{
tangle = tangle + 22.5;
if (tp(tangle) == 0) break;
tangle = -tangle;
if (tp(tangle) == 0) break;
tangle = -tangle;
if (tangle > 180) break;
}
while (true);
turn(tangle);
motor(1,1);
wait(2);
}
}
}
}
}
int object::tp(float angle)
{
point tpoint;
tpoint.x = position.x + cos(orientation + angle)*10;
tpoint.y = position.y + sin(orientation + angle)*10;
tpoint.z = 0;
if (topo(tpoint) < 1.5) return(1); else return(0);
}
|