--- a/hedgewars/GSHandlers.inc Wed Jan 12 20:32:44 2011 +0100
+++ b/hedgewars/GSHandlers.inc Thu Jan 13 21:52:48 2011 +0300
@@ -215,7 +215,7 @@
//else
// PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack);
- ApplyDamage(Gear, CurrentHedgehog^.Gear, dmg, dsFall);
+ ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall);
end
end;
@@ -375,7 +375,7 @@
begin
CheckCollision(Gear);
if (Gear^.State and gstCollision) <> 0 then
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear, EXPLDontDraw or EXPLNoGfx);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLDontDraw or EXPLNoGfx);
end;
if (Gear^.Kind = gtGasBomb) and ((GameTicks mod 200) = 0) then
@@ -388,13 +388,13 @@
if Gear^.Timer = 0 then
begin
case Gear^.Kind of
- gtBomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound);
- gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, Gear, EXPLAutoSound);
+ gtBomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
+ gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, Gear^.Hedgehog, EXPLAutoSound);
gtClusterBomb:
begin
x := hwRound(Gear^.X);
y := hwRound(Gear^.Y);
- doMakeExplosion(x, y, 20, Gear, EXPLAutoSound);
+ doMakeExplosion(x, y, 20, Gear^.Hedgehog, EXPLAutoSound);
for i:= 0 to 4 do
begin
dX := rndSign(GetRandom * _0_1) + Gear^.dX / 5;
@@ -406,7 +406,7 @@
begin
x := hwRound(Gear^.X);
y := hwRound(Gear^.Y);
- doMakeExplosion(x, y, 75, Gear, EXPLAutoSound);
+ doMakeExplosion(x, y, 75, Gear^.Hedgehog, EXPLAutoSound);
for i:= 0 to 5 do
begin
dX := rndSign(GetRandom * _0_1) + Gear^.dX / 5;
@@ -418,7 +418,7 @@
begin
x := hwRound(Gear^.X);
y := hwRound(Gear^.Y);
- doMakeExplosion(x, y, 90, Gear, EXPLAutoSound);
+ doMakeExplosion(x, y, 90, Gear^.Hedgehog, EXPLAutoSound);
for i:= 0 to 127 do
begin
@@ -432,7 +432,7 @@
end;
gtGasBomb:
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound);
for i:= 0 to 2 do
begin
x:= GetRandom(60);
@@ -509,7 +509,7 @@
doStepFallingGear(Gear);
if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
@@ -528,7 +528,7 @@
doStepFallingGear(Gear);
if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
@@ -766,7 +766,7 @@
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then
begin
StopSound(Gear^.SoundChannel);
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear);
end;
end;
@@ -780,7 +780,7 @@
CheckCollision(Gear);
if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
@@ -1083,7 +1083,7 @@
if (Gear^.Timer mod 33) = 0 then
begin
HHGear^.State := HHGear^.State or gstNoDamage;
- doMakeExplosion(x, y + 7, 6, Gear, EXPLDontDraw);
+ doMakeExplosion(x, y + 7, 6, Gear^.Hedgehog, EXPLDontDraw);
HHGear^.State := HHGear^.State and not gstNoDamage
end;
@@ -1710,7 +1710,7 @@
(cMineDudPercent = 0) or
(getRandom(100) > cMineDudPercent) then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear)
end
else
@@ -1761,7 +1761,7 @@
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick);
if Gear^.Timer = 0 then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
@@ -1781,7 +1781,7 @@
makeHogsWorry(Gear^.X, Gear^.Y, 75);
if Gear^.Timer = 0 then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
@@ -1874,6 +1874,7 @@
k: TGearType;
exBoom: boolean;
dX, dY: HWFloat;
+ hog: PHedgehog;
begin
k := Gear^.Kind;
exBoom := false;
@@ -1910,18 +1911,20 @@
begin
x := hwRound(Gear^.X);
y := hwRound(Gear^.Y);
+ hog:= Gear^.Hedgehog;
+
DeleteGear(Gear);
// <-- delete gear!
if k = gtCase then
begin
- doMakeExplosion(x, y, 25, Gear, EXPLAutoSound);
+ doMakeExplosion(x, y, 25, hog, EXPLAutoSound);
for i:= 0 to 63 do
AddGear(x, y, gtFlame, 0, _0, _0, 0);
end
else if k = gtExplosives then
begin
- doMakeExplosion(x, y, 75, Gear, EXPLAutoSound);
+ doMakeExplosion(x, y, 75, hog, EXPLAutoSound);
for i:= 0 to 31 do
begin
dX := AngleCos(i * 64) * _0_5 * (getrandom + _1);
@@ -2106,7 +2109,7 @@
AmmoShove(Gear, 4, 150);
Gear^.Radius := 1;
end
- else if ((GameTicks and $3) = 3) then doMakeExplosion(gX, gY, 6, Gear, 0);//, EXPLNoDamage);
+ else if ((GameTicks and $3) = 3) then doMakeExplosion(gX, gY, 6, Gear^.Hedgehog, 0);//, EXPLNoDamage);
//DrawExplosion(gX, gY, 4);
if ((GameTicks and $7) = 0) and (Random(2) = 0) then
for i:= 1 to Random(2)+1 do
@@ -2347,7 +2350,7 @@
doStepFallingGear(Gear);
if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear);
performRumble();
exit
@@ -2546,7 +2549,7 @@
doStepFallingGear(Gear);
if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound);
Gear^.dX.isNegative := not dxn;
Gear^.dY.isNegative := not dyn;
@@ -2616,7 +2619,7 @@
if Gear^.Health < Gear^.Damage then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound);
AfterAttack;
DeleteGear(Gear);
DeleteGear(HHGear);
@@ -2676,7 +2679,7 @@
inc(Gear^.Tag);
if Gear^.Tag < 2250 then exit;
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, Gear^.Hedgehog, EXPLAutoSound);
AfterAttack;
DeleteGear(Gear)
end;
@@ -2969,9 +2972,9 @@
//out of time or exited ground
StopSound(Gear^.SoundChannel);
if (Gear^.State and gsttmpFlag) <> 0 then
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound)
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound)
else
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear);
exit
end
@@ -3021,9 +3024,9 @@
begin
//explode right on contact with HH
if (Gear^.State and gsttmpFlag) <> 0 then
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound)
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound)
else
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
DeleteGear(Gear);
exit;
end;
@@ -3170,7 +3173,7 @@
if ((Gear^.State and gstCollision) <> 0) then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, Gear^.Hedgehog, EXPLAutoSound);
for i:= 0 to 32 do
begin
dX := AngleCos(i * 64) * _0_5 * (GetRandom + _1);
@@ -3545,7 +3548,7 @@
if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear, EXPLPoisoned, $C0E0FFE0);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear^.Hedgehog, EXPLPoisoned, $C0E0FFE0);
PlaySound(sndEggBreak);
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEgg);
vg := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEgg);
@@ -4051,9 +4054,9 @@
begin
r0 := GetRandom(21);
r1 := GetRandom(21);
- doMakeExplosion(hwRound(Gear^.X) - 30 - r0, hwRound(Gear^.Y) + 40, 40 + r1, Gear, 0);
- doMakeExplosion(hwRound(Gear^.X) + 30 + r1, hwRound(Gear^.Y) + 40, 40 + r0, Gear, 0);
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 80 + r0, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X) - 30 - r0, hwRound(Gear^.Y) + 40, 40 + r1, Gear^.Hedgehog, 0);
+ doMakeExplosion(hwRound(Gear^.X) + 30 + r1, hwRound(Gear^.Y) + 40, 40 + r0, Gear^.Hedgehog, 0);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 80 + r0, Gear^.Hedgehog, EXPLAutoSound);
for r0:= 0 to 4 do
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote);
Gear^.dY := odY * -1 + cGravity * 2;
@@ -4294,7 +4297,7 @@
Gear^.dX := Gear^.dX + cWindSpeed / 4;
Gear^.dY := Gear^.dY + cGravity / 100;
if (GameTicks mod 250) = 0 then
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned);
AllInactive:= false;
end;
@@ -4322,7 +4325,7 @@
if (tmp^.Kind = gtHedgehog) then
begin
//tmp^.State:= tmp^.State or gstFlatened;
- ApplyDamage(tmp, CurrentHedgehog^.Gear, tmp^.Health div 3, dsUnknown);
+ ApplyDamage(tmp, CurrentHedgehog, tmp^.Health div 3, dsUnknown);
//DrawTunnel(tmp^.X, tmp^.Y - _1, _0, _0_5, cHHRadius * 6, cHHRadius * 3);
tmp2:= AddGear(hwRound(tmp^.X), hwRound(tmp^.Y), gtHammerHit, 0, _0, _0, 0);
tmp2^.Hedgehog:= tmp^.Hedgehog;
@@ -4545,7 +4548,7 @@
doStepFallingGear(Gear);
if (Gear^.Timer > 0) and ((Gear^.State and gstCollision) <> 0) then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear^.Hedgehog, EXPLAutoSound);
gX := hwRound(Gear^.X);
gY := hwRound(Gear^.Y);
for i:= 0 to 10 do
@@ -4562,7 +4565,7 @@
end;
if (Gear^.Timer = 0) then
begin
- doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear^.Hedgehog, EXPLAutoSound);
for i:= -19 to 19 do
FollowGear := AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0);
DeleteGear(Gear);
--- a/hedgewars/uGears.pas Wed Jan 12 20:32:44 2011 +0100
+++ b/hedgewars/uGears.pas Thu Jan 13 21:52:48 2011 +0300
@@ -29,7 +29,7 @@
procedure ResurrectHedgehog(gear: PGear);
procedure ProcessGears;
procedure EndTurnCleanup;
-procedure ApplyDamage(Gear, Attacker: PGear; Damage: Longword; Source: TDamageSource);
+procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
procedure SetAllToActive;
procedure SetAllHHToActive;
procedure DrawGears;
@@ -50,7 +50,7 @@
uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture;
-procedure doMakeExplosion(X, Y, Radius: LongInt; GearCaused: PGear; Mask: Longword; const Tint: LongWord = $FFFFFFFF); forward;
+procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord = $FFFFFFFF); forward;
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward;
//procedure AmmoFlameWork(Ammo: PGear); forward;
function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray; forward;
@@ -204,7 +204,7 @@
gear^.ImpactSound:= sndNone;
gear^.nImpactSounds:= 0;
-if CurrentTeam <> nil then
+if CurrentHedgehog <> nil then
begin
gear^.Hedgehog:= CurrentHedgehog;
gear^.IntersectGear:= CurrentHedgehog^.Gear
@@ -559,8 +559,9 @@
if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cWaterOpacity < $FF))) and (hwRound(Gear^.Y) < cWaterLine + 256) then
spawnHealthTagForHH(Gear, t);
- // should be CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
- uStats.HedgehogDamaged(Gear, CurrentHedgehog^.Gear)
+ // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
+ // same stand for CheckHHDamage
+ uStats.HedgehogDamaged(Gear, CurrentHedgehog)
end;
team:= Gear^.Hedgehog^.Team;
@@ -988,14 +989,14 @@
RecountTeamHealth(TeamsArray[i])
end;
-procedure ApplyDamage(Gear, Attacker: PGear; Damage: Longword; Source: TDamageSource);
+procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
var s: shortstring;
vampDmg, tmpDmg, i: Longword;
vg: PVisualGear;
begin
if (Gear^.Kind = gtHedgehog) and (Damage>=1) then
begin
- uStats.HedgehogDamaged(Gear, Attacker);
+ uStats.HedgehogDamaged(Gear, AttackerHog);
HHHurt(Gear^.Hedgehog, Source);
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, Gear^.Hedgehog^.Team^.Clan^.Color);
tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage));
@@ -1032,7 +1033,10 @@
end;
end;
end else // not gtHedgehog
- Gear^.Hedgehog:= Attacker^.Hedgehog;
+ begin
+ AddFileLog('Assigning hedgehog ' + inttostr(LongInt(AttackerHog)) + ' to gear ' + inttostr(Gear^.uid));
+ Gear^.Hedgehog:= AttackerHog;
+ end;
inc(Gear^.Damage, Damage);
ScriptCall('onGearDamage', Gear^.UID, Damage);
end;
@@ -1144,7 +1148,7 @@
end
end;
-procedure doMakeExplosion(X, Y, Radius: LongInt; GearCaused: PGear; Mask: Longword; const Tint: LongWord);
+procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord);
var Gear: PGear;
dmg, dmgRadius, dmgBase: LongInt;
fX, fY: hwFloat;
@@ -1198,7 +1202,7 @@
if (Mask and EXPLNoDamage) = 0 then
begin
if not Gear^.Invulnerable then
- ApplyDamage(Gear, GearCaused, dmg, dsExplosion)
+ ApplyDamage(Gear, AttackingHog, dmg, dsExplosion)
else
Gear^.State:= Gear^.State or gstWinner;
end;
@@ -1264,7 +1268,7 @@
gtTarget,
gtExplosives: begin
if (not t^.Invulnerable) then
- ApplyDamage(t, Gear, dmg, dsBullet)
+ ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet)
else
Gear^.State:= Gear^.State or gstWinner;
@@ -1329,10 +1333,10 @@
gtExplosives: begin
if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
if (not Gear^.Invulnerable) then
- ApplyDamage(Gear, Ammo, tmpDmg, dsShove)
+ ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove)
else
Gear^.State:= Gear^.State or gstWinner;
- if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then ApplyDamage(Gear, Ammo, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch
+ if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch
DeleteCI(Gear);
if (Gear^.Kind = gtHedgehog) and Gear^.Hedgehog^.King then