hedgewars/uAIAmmoTests.pas
changeset 15688 10bcec19045c
parent 15661 afeffdb4a712
child 15697 c9a7ee0e3265
equal deleted inserted replaced
15687:63e2b7b2ec47 15688:10bcec19045c
   491             (((ap.Angle < 0) and (windSpeed > 0)) or ((ap.Angle > 0) and (windSpeed < 0))) then
   491             (((ap.Angle < 0) and (windSpeed > 0)) or ((ap.Angle > 0) and (windSpeed < 0))) then
   492             exit(BadTurn);
   492             exit(BadTurn);
   493 
   493 
   494         // Apply inaccuracy
   494         // Apply inaccuracy
   495         if (not aiLaserSighting) then
   495         if (not aiLaserSighting) then
   496             inc(ap.Angle, + AIrndSign(random((Level - 1) * 9)));
   496             inc(ap.Angle, AIrndSign(random((Level - 1) * 9)));
   497 
   497 
   498         if (valueResult <= 0) then
   498         if (valueResult <= 0) then
   499             valueResult:= BadTurn;
   499             valueResult:= BadTurn;
   500         exit(valueResult)
   500         exit(valueResult)
   501         end
   501         end
   980 Vx:= (Targ.Point.X - x) * 1 / 1024;
   980 Vx:= (Targ.Point.X - x) * 1 / 1024;
   981 Vy:= (Targ.Point.Y - y) * 1 / 1024;
   981 Vy:= (Targ.Point.Y - y) * 1 / 1024;
   982 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
   982 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
   983 // Apply inaccuracy
   983 // Apply inaccuracy
   984 if (not aiLaserSighting) then
   984 if (not aiLaserSighting) then
   985     inc(ap.Angle, + AIrndSign(random((Level - 1) * 10)));
   985     inc(ap.Angle, AIrndSign(random((Level - 1) * 10)));
   986 repeat
   986 repeat
   987     x:= x + vX;
   987     x:= x + vX;
   988     y:= y + vY;
   988     y:= y + vY;
   989     rx:= trunc(x);
   989     rx:= trunc(x);
   990     ry:= trunc(y);
   990     ry:= trunc(y);
  1037 Vx:= (Targ.Point.X - x) * t;
  1037 Vx:= (Targ.Point.X - x) * t;
  1038 Vy:= (Targ.Point.Y - y) * t;
  1038 Vy:= (Targ.Point.Y - y) * t;
  1039 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
  1039 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
  1040 // Apply inaccuracy
  1040 // Apply inaccuracy
  1041 if (not aiLaserSighting) then
  1041 if (not aiLaserSighting) then
  1042     inc(ap.Angle, + AIrndSign(random((Level - 1) * 10)));
  1042     inc(ap.Angle, AIrndSign(random((Level - 1) * 10)));
  1043 d:= 0;
  1043 d:= 0;
  1044 
  1044 
  1045 ix:= trunc(x);
  1045 ix:= trunc(x);
  1046 iy:= trunc(y);
  1046 iy:= trunc(y);
  1047 
  1047 
  1093 dmg:= dmg * 0.025; // div 40
  1093 dmg:= dmg * 0.025; // div 40
  1094 Vx:= (Targ.Point.X - x) * t;
  1094 Vx:= (Targ.Point.X - x) * t;
  1095 Vy:= (Targ.Point.Y - y) * t;
  1095 Vy:= (Targ.Point.Y - y) * t;
  1096 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
  1096 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
  1097 // Apply inaccuracy
  1097 // Apply inaccuracy
  1098 inc(ap.Angle, + AIrndSign(random((Level - 1) * 5)));
  1098 inc(ap.Angle, AIrndSign(random((Level - 1) * 5)));
  1099 
  1099 
  1100 d:= 0;
  1100 d:= 0;
  1101 
  1101 
  1102 repeat
  1102 repeat
  1103     x:= x + vX;
  1103     x:= x + vX;
  1323         dy:= (Targ.Point.Y - y) * t;
  1323         dy:= (Targ.Point.Y - y) * t;
  1324 
  1324 
  1325         ap.Angle:= DxDy2AttackAnglef(dx, -dy);
  1325         ap.Angle:= DxDy2AttackAnglef(dx, -dy);
  1326         // Apply inaccuracy
  1326         // Apply inaccuracy
  1327         if (not aiLaserSighting) then
  1327         if (not aiLaserSighting) then
  1328             inc(ap.Angle, + AIrndSign(random((Level - 1) * 10)));
  1328             inc(ap.Angle, AIrndSign(random((Level - 1) * 10)));
  1329         end;
  1329         end;
  1330 
  1330 
  1331     if dx >= 0 then cx:= 0.45 else cx:= -0.45;
  1331     if dx >= 0 then cx:= 0.45 else cx:= -0.45;
  1332 
  1332 
  1333     for i:= 1 to 512 div step - 2 do
  1333     for i:= 1 to 512 div step - 2 do
  2218         ap.Power:= ((range + cHHRadius*2) * cMaxPower) div MAX_RANGE;
  2218         ap.Power:= ((range + cHHRadius*2) * cMaxPower) div MAX_RANGE;
  2219 
  2219 
  2220         // Apply inaccuracy
  2220         // Apply inaccuracy
  2221         inc(ap.Power, (random(93*(Level-1)) - 31*(Level-1))); // Level 1 spread: -124 .. 248
  2221         inc(ap.Power, (random(93*(Level-1)) - 31*(Level-1))); // Level 1 spread: -124 .. 248
  2222         if (not aiLaserSighting) then
  2222         if (not aiLaserSighting) then
  2223             inc(ap.Angle, + AIrndSign(random((Level - 1) * 10)));
  2223             inc(ap.Angle, AIrndSign(random((Level - 1) * 10)));
  2224 
  2224 
  2225         if (valueResult <= 0) then
  2225         if (valueResult <= 0) then
  2226             valueResult:= BadTurn;
  2226             valueResult:= BadTurn;
  2227         exit(valueResult)
  2227         exit(valueResult)
  2228         end
  2228         end
  2265 if (ap.Angle < Ammoz[amMinigun].minAngle) or (ap.Angle > Ammoz[amMinigun].maxAngle) then
  2265 if (ap.Angle < Ammoz[amMinigun].minAngle) or (ap.Angle > Ammoz[amMinigun].maxAngle) then
  2266     exit(BadTurn);
  2266     exit(BadTurn);
  2267 
  2267 
  2268 // Apply inaccuracy
  2268 // Apply inaccuracy
  2269 if (not aiLaserSighting) then
  2269 if (not aiLaserSighting) then
  2270     inc(ap.Angle, + AIrndSign(random((Level - 1) * 10)));
  2270     inc(ap.Angle, AIrndSign(random((Level - 1) * 10)));
  2271 repeat
  2271 repeat
  2272     x:= x + vX;
  2272     x:= x + vX;
  2273     y:= y + vY;
  2273     y:= y + vY;
  2274     rx:= trunc(x);
  2274     rx:= trunc(x);
  2275     ry:= trunc(y);
  2275     ry:= trunc(y);