# HG changeset patch # User unc0rr # Date 1294430914 -10800 # Node ID efbc8f80acac5f68bdf8b405784afe735729de9c # Parent 8789a8f6c016e344ad926232cc35c94d9a2c2078 Keep track of which hog's weapon does damage diff -r 8789a8f6c016 -r efbc8f80acac hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Fri Jan 07 21:41:12 2011 +0300 +++ b/hedgewars/GSHandlers.inc Fri Jan 07 23:08:34 2011 +0300 @@ -215,7 +215,7 @@ //else // PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack); - ApplyDamage(Gear, dmg, dsFall); + ApplyDamage(Gear, CurrentHedgehog^.Gear, 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, EXPLDontDraw or EXPLNoGfx); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear, 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, EXPLAutoSound); - gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, EXPLAutoSound); + gtBomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound); + gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, Gear, EXPLAutoSound); gtClusterBomb: begin x := hwRound(Gear^.X); y := hwRound(Gear^.Y); - doMakeExplosion(x, y, 20, EXPLAutoSound); + doMakeExplosion(x, y, 20, Gear, 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, EXPLAutoSound); + doMakeExplosion(x, y, 75, Gear, 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, EXPLAutoSound); + doMakeExplosion(x, y, 90, Gear, EXPLAutoSound); for i:= 0 to 127 do begin @@ -432,7 +432,7 @@ end; gtGasBomb: begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear, 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, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, Gear, 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, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, 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, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, 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, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, 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, EXPLDontDraw); + doMakeExplosion(x, y + 7, 6, Gear, 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, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, 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, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, 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, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, Gear, EXPLAutoSound); DeleteGear(Gear); exit end; @@ -1915,13 +1915,13 @@ if k = gtCase then begin - doMakeExplosion(x, y, 25, EXPLAutoSound); + doMakeExplosion(x, y, 25, Gear, 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, EXPLAutoSound); + doMakeExplosion(x, y, 75, Gear, EXPLAutoSound); for i:= 0 to 31 do begin dX := AngleCos(i * 64) * _0_5 * (getrandom + _1); @@ -2106,7 +2106,7 @@ AmmoShove(Gear, 4, 150); Gear^.Radius := 1; end - else if ((GameTicks and $3) = 3) then doMakeExplosion(gX, gY, 6, 0);//, EXPLNoDamage); + else if ((GameTicks and $3) = 3) then doMakeExplosion(gX, gY, 6, Gear, 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 +2347,7 @@ doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound); DeleteGear(Gear); performRumble(); exit @@ -2546,7 +2546,7 @@ doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear, EXPLAutoSound); Gear^.dX.isNegative := not dxn; Gear^.dY.isNegative := not dyn; @@ -2616,7 +2616,7 @@ if Gear^.Health < Gear^.Damage then begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound); AfterAttack; DeleteGear(Gear); DeleteGear(HHGear); @@ -2676,7 +2676,7 @@ inc(Gear^.Tag); if Gear^.Tag < 2250 then exit; - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, Gear, EXPLAutoSound); AfterAttack; DeleteGear(Gear) end; @@ -2969,9 +2969,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, EXPLAutoSound) + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound) else - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound); DeleteGear(Gear); exit end @@ -3021,9 +3021,9 @@ begin //explode right on contact with HH if (Gear^.State and gsttmpFlag) <> 0 then - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound) + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound) else - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear, EXPLAutoSound); DeleteGear(Gear); exit; end; @@ -3170,7 +3170,7 @@ if ((Gear^.State and gstCollision) <> 0) then begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, Gear, EXPLAutoSound); for i:= 0 to 32 do begin dX := AngleCos(i * 64) * _0_5 * (GetRandom + _1); @@ -3545,7 +3545,7 @@ if (Gear^.State and gstCollision) <> 0 then begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, EXPLPoisoned, $C0E0FFE0); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear, EXPLPoisoned, $C0E0FFE0); PlaySound(sndEggBreak); AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEgg); vg := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEgg); @@ -4051,9 +4051,9 @@ begin r0 := GetRandom(21); r1 := GetRandom(21); - doMakeExplosion(hwRound(Gear^.X) - 30 - r0, hwRound(Gear^.Y) + 40, 40 + r1, 0); - doMakeExplosion(hwRound(Gear^.X) + 30 + r1, hwRound(Gear^.Y) + 40, 40 + r0, 0); - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 80 + r0, EXPLAutoSound); + 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); for r0:= 0 to 4 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote); Gear^.dY := odY * -1 + cGravity * 2; @@ -4294,7 +4294,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, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned); AllInactive:= false; end; @@ -4322,7 +4322,7 @@ if (tmp^.Kind = gtHedgehog) then begin //tmp^.State:= tmp^.State or gstFlatened; - ApplyDamage(tmp, tmp^.Health div 3, dsUnknown); + ApplyDamage(tmp, CurrentHedgehog^.Gear, 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 +4545,7 @@ doStepFallingGear(Gear); if (Gear^.Timer > 0) and ((Gear^.State and gstCollision) <> 0) then begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear, EXPLAutoSound); gX := hwRound(Gear^.X); gY := hwRound(Gear^.Y); for i:= 0 to 10 do @@ -4562,7 +4562,7 @@ end; if (Gear^.Timer = 0) then begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear, 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); diff -r 8789a8f6c016 -r efbc8f80acac hedgewars/HHHandlers.inc --- a/hedgewars/HHHandlers.inc Fri Jan 07 21:41:12 2011 +0300 +++ b/hedgewars/HHHandlers.inc Fri Jan 07 23:08:34 2011 +0300 @@ -402,7 +402,7 @@ if Gear^.Timer = 1 then begin Gear^.State:= Gear^.State or gstNoDamage; - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear, EXPLAutoSound); AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; DeleteGear(Gear); SetAllToActive diff -r 8789a8f6c016 -r efbc8f80acac hedgewars/uGears.pas --- a/hedgewars/uGears.pas Fri Jan 07 21:41:12 2011 +0300 +++ b/hedgewars/uGears.pas Fri Jan 07 23:08:34 2011 +0300 @@ -29,7 +29,7 @@ procedure ResurrectHedgehog(gear: PGear); procedure ProcessGears; procedure EndTurnCleanup; -procedure ApplyDamage(Gear: PGear; Damage: Longword; Source: TDamageSource); +procedure ApplyDamage(Gear, Attacker: PGear; Damage: Longword; Source: TDamageSource); procedure SetAllToActive; procedure SetAllHHToActive; procedure DrawGears; @@ -50,8 +50,7 @@ uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture; -procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward; -procedure doMakeExplosion(X, Y, Radius: LongInt; Mask, Tint: LongWord); forward; +procedure doMakeExplosion(X, Y, Radius: LongInt; GearCaused: PGear; 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; @@ -559,7 +558,7 @@ Gear^.Damage:= t; if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cWaterOpacity < $FF))) and (hwRound(Gear^.Y) < cWaterLine + 256) then spawnHealthTagForHH(Gear, t); - uStats.HedgehogDamaged(Gear) + uStats.HedgehogDamaged(Gear, CurrentHedgehog^.Gear) end; team:= Gear^.Hedgehog^.Team; @@ -616,7 +615,7 @@ (not Gear^.Invulnerable) then begin CheckNoDamage:= false; - uStats.HedgehogDamaged(Gear); + dmg:= Gear^.Damage; if Gear^.Health < dmg then begin @@ -986,13 +985,14 @@ RecountTeamHealth(TeamsArray[i]) end; -procedure ApplyDamage(Gear: PGear; Damage: Longword; Source: TDamageSource); +procedure ApplyDamage(Gear, Attacker: PGear; 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); 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)); @@ -1133,12 +1133,7 @@ end end; -procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); -begin -doMakeExplosion(X, Y, Radius, Mask, $FFFFFFFF); -end; - -procedure doMakeExplosion(X, Y, Radius: LongInt; Mask, Tint: LongWord); +procedure doMakeExplosion(X, Y, Radius: LongInt; GearCaused: PGear; Mask: Longword; const Tint: LongWord); var Gear: PGear; dmg, dmgRadius, dmgBase: LongInt; fX, fY: hwFloat; @@ -1192,7 +1187,7 @@ if (Mask and EXPLNoDamage) = 0 then begin if not Gear^.Invulnerable then - ApplyDamage(Gear, dmg, dsExplosion) + ApplyDamage(Gear, GearCaused, dmg, dsExplosion) else Gear^.State:= Gear^.State or gstWinner; end; @@ -1258,7 +1253,7 @@ gtTarget, gtExplosives: begin if (not t^.Invulnerable) then - ApplyDamage(t, dmg, dsBullet) + ApplyDamage(t, Gear, dmg, dsBullet) else Gear^.State:= Gear^.State or gstWinner; @@ -1305,13 +1300,13 @@ tmpDmg:= ModifyDamage(Damage, Gear); if (Gear^.State and gstNoDamage) = 0 then begin - + if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then begin VGear := AddVisualGear(hwround(Ammo^.X), hwround(Ammo^.Y), vgtBulletHit); if VGear <> nil then VGear^.Angle := DxDy2Angle(-Ammo^.dX, Ammo^.dY); end; - + if (Gear^.Kind = gtHedgehog) and (Ammo^.State and gsttmpFlag <> 0) and (Ammo^.Kind = gtShover) then Gear^.FlightTime:= 1; case Gear^.Kind of @@ -1323,10 +1318,10 @@ gtExplosives: begin if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end; if (not Gear^.Invulnerable) then - ApplyDamage(Gear, tmpDmg, dsShove) + ApplyDamage(Gear, Ammo, tmpDmg, dsShove) else Gear^.State:= Gear^.State or gstWinner; - if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then ApplyDamage(Gear, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch + if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then ApplyDamage(Gear, Ammo, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch DeleteCI(Gear); if (Gear^.Kind = gtHedgehog) and Gear^.Hedgehog^.King then @@ -1517,7 +1512,6 @@ gear^.dX := _0; gear^.dY := _0; gear^.State := gstWait; - uStats.HedgehogDamaged(gear); gear^.Damage := 0; gear^.Health := gear^.Hedgehog^.InitialHealth; gear^.Hedgehog^.Effects[hePoisoned] := false; diff -r 8789a8f6c016 -r efbc8f80acac hedgewars/uStats.pas --- a/hedgewars/uStats.pas Fri Jan 07 21:41:12 2011 +0300 +++ b/hedgewars/uStats.pas Fri Jan 07 23:08:34 2011 +0300 @@ -29,7 +29,7 @@ procedure freeModule; procedure AmmoUsed(am: TAmmoType); -procedure HedgehogDamaged(Gear: PGear); +procedure HedgehogDamaged(Gear, Attacker: PGear); procedure Skipped; procedure TurnReaction; procedure SendStats; @@ -50,15 +50,13 @@ vpHurtSameClan: PVoicepack = nil; vpHurtEnemy: PVoicepack = nil; -procedure HedgehogDamaged(Gear: PGear); +procedure HedgehogDamaged(Gear, Attacker: PGear); begin -if CurrentHedgehog^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then +if Attacker^.Hedgehog^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack else vpHurtEnemy:= Gear^.Hedgehog^.Team^.voicepack; -if bBetweenTurns then exit; - ////////////////////////// if Gear <> CurrentHedgehog^.Gear then