2
2
* Hedgewars, a free turn based strategy game
3
* Copyright (c) 2005-2010 Andrey Korotaev <unC0Rr@gmail.com>
3
* Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com>
5
5
* This program is free software; you can redistribute it and/or modify
6
6
* it under the terms of the GNU General Public License as published by
56
56
function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
57
57
function RateShove(Me: PGear; x, y, r, power: LongInt): LongInt;
58
58
function RateShotgun(Me: PGear; x, y: LongInt): LongInt;
59
function RateHammer(Me: PGear): LongInt;
59
60
function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
60
61
function AIrndSign(num: LongInt): LongInt;
113
114
if e > f then friendlyfactor:= 300 + (e - f) * 30
114
else friendlyfactor:= max(30, 300 - f * 80 div e)
115
else friendlyfactor:= max(30, 300 - f * 80 div max(1,e))
117
118
procedure FillBonuses(isAfterAttack: boolean; filter: TGearsType);
134
135
Gear:= GearsList;
135
136
while Gear <> nil do
137
if (filter = []) or (Gear^.Kind in filter) then
138
if (filter = []) or (Gear^.Kind in filter) then
138
139
case Gear^.Kind of
139
140
gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25);
140
141
gtFlame: if (Gear^.State and gsttmpFlag) <> 0 then
141
142
AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 20, -50);
142
gtMine: if (Gear^.State and gstAttacking) = 0 then
143
AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50)
145
AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on
143
// avoid mines unless they are very likely to be duds, or are duds. also avoid if they are about to blow
144
gtMine: if ((Gear^.State and gstAttacking) = 0) and
145
(((cMineDudPercent < 90) and (Gear^.Health <> 0)) or
146
((Gear^.Health = 0) and (Gear^.Damage > 30))) then
147
AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50)
148
else if (Gear^.State and gstAttacking) <> 0 then
149
AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on
150
gtSMine: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -30);
146
151
gtDynamite: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75);
147
152
gtHedgehog: begin
148
153
if Gear^.Damage >= Gear^.Health then
149
154
AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25)
151
156
if isAfterAttack and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog) then
152
if (MyClan = Gear^.Hedgehog^.Team^.Clan) then
157
if (ClansCount > 2) or (MyClan = Gear^.Hedgehog^.Team^.Clan) then
153
158
AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -3) // hedgehog-friend
155
160
AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3)
227
232
for i:= 0 to Targets.Count do
228
233
with Targets.ar[i] do
230
dmg:= r + cHHRadius div 2 - hwRound(DistanceI(Point.x - x, Point.y - y));
235
dmg:= hwRound(_0_01 * cDamageModifier
236
* min((r + cHHRadius div 2 - DistanceI(Point.x - x, Point.y - y).Round) div 2, r) * cDamagePercent);
233
dmg:= min(dmg div 2, r);
234
240
if dmg >= abs(Score) then
235
241
if Score > 0 then inc(rate, KillScore)
236
242
else dec(rate, KillScore * friendlyfactor div 100)
281
286
for i:= 0 to Targets.Count do
282
287
with Targets.ar[i] do
284
dmg:= min(cHHRadius + cShotgunRadius - hwRound(DistanceI(Point.x - x, Point.y - y)), 25);
285
dmg := round(dmg * REUSE_BONUS);
289
dmg:= min(cHHRadius + cShotgunRadius + 4 - hwRound(DistanceI(Point.x - x, Point.y - y)), 25);
290
dmg:= hwRound(_0_01 * cDamageModifier * dmg * cDamagePercent);
288
293
if dmg >= abs(Score) then dmg := KillScore;
289
294
if Score > 0 then inc(rate, dmg)
290
295
else dec(rate, dmg * friendlyfactor div 100);
293
298
RateShotgun:= rate * 1024;
301
function RateHammer(Me: PGear): LongInt;
302
var x, y, i, r, rate: LongInt;
304
// hammer hit shift against attecker hog is 10
305
x:= hwRound(Me^.X) + hwSign(Me^.dX) * 10;
309
for i:= 0 to Pred(Targets.Count) do
310
with Targets.ar[i] do
312
// hammer hit radius is 8, shift is 10
313
r:= hwRound(DistanceI(Point.x - x, Point.y - y));
317
inc(rate, Score div 3)
319
inc(rate, Score div 3 * friendlyfactor div 100)
321
RateHammer:= rate * 1024;
296
324
function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;
297
325
var bX, bY: LongInt;
301
329
GoInfo.Ticks:= 0;
303
330
GoInfo.JumpType:= jmpNone;
304
331
bX:= hwRound(Gear^.X);
305
332
bY:= hwRound(Gear^.Y);
397
422
inc(GoInfo.Ticks, 410);
398
423
Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping);
401
425
HHJump(AltGear, jmpLJump, GoInfo); // try ljump instead of fall
406
430
if (Gear^.Message and gmLeft )<>0 then Gear^.dX:= -cLittle else
407
if (Gear^.Message and gmRight )<>0 then Gear^.dX:= cLittle else exit(bRes);
431
if (Gear^.Message and gmRight )<>0 then Gear^.dX:= cLittle else exit(false);
408
432
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
410
434
if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))