- Convert small damage tag to visual gears
- Fixes weird fire behavior leading to queue error
--- a/hedgewars/GSHandlers.inc Thu Nov 20 15:48:50 2008 +0000
+++ b/hedgewars/GSHandlers.inc Fri Nov 21 15:58:36 2008 +0000
@@ -49,7 +49,7 @@
dmg:= 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70);
inc(Gear^.Damage, dmg);
- AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, Gear);
+ AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color);
end
end;
@@ -219,9 +219,11 @@
procedure doStepHealthTagWork(Gear: PGear);
begin
if Gear^.Kind = gtHealthTag then
- AllInactive:= false;
+ AllInactive:= false;
+
dec(Gear^.Timer);
Gear^.Y:= Gear^.Y + Gear^.dY;
+
if Gear^.Timer = 0 then
begin
if Gear^.Kind = gtHealthTag then
@@ -232,34 +234,28 @@
procedure doStepHealthTagWorkUnderWater(Gear: PGear);
begin
-if Gear^.Kind = gtHealthTag then
- AllInactive:= false;
+AllInactive:= false;
Gear^.Y:= Gear^.Y - _0_08;
if hwRound(Gear^.Y) < cWaterLine + 10 then
- DeleteGear(Gear)
+ DeleteGear(Gear)
end;
procedure doStepHealthTag(Gear: PGear);
var s: shortstring;
- font: THWFont;
begin
-if Gear^.Kind = gtHealthTag then
- begin
- AllInactive:= false;
- font:= fnt16;
- Gear^.dY:= -_0_08
- end else
- begin
- font:= fntSmall;
- Gear^.dY:= -_0_02
- end;
+AllInactive:= false;
+Gear^.dY:= -_0_08;
str(Gear^.State, s);
-Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, font);
-if hwRound(Gear^.Y) < cWaterLine then Gear^.doStep:= @doStepHealthTagWork
- else Gear^.doStep:= @doStepHealthTagWorkUnderWater;
+Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16);
+
+if hwRound(Gear^.Y) < cWaterLine then
+ Gear^.doStep:= @doStepHealthTagWork
+else
+ Gear^.doStep:= @doStepHealthTagWorkUnderWater;
+
Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h)
end;
@@ -280,6 +276,7 @@
exit
end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false)
end;
+
Gear^.Y:= Gear^.Y + Gear^.dY;
CheckGearDrowning(Gear);
Gear^.dY:= Gear^.dY + cGravity
--- a/hedgewars/HHHandlers.inc Thu Nov 20 15:48:50 2008 +0000
+++ b/hedgewars/HHHandlers.inc Fri Nov 21 15:58:36 2008 +0000
@@ -647,10 +647,14 @@
procedure doStepHedgehog(Gear: PGear);
begin
if (Gear^.Message and gm_Destroy) <> 0 then
- begin
- DeleteGear(Gear);
- exit
- end;
+ begin
+ DeleteGear(Gear);
+ exit
+ end;
+
+//if Gear^.uid = 7 then
+//with Gear^ do AddFileLog('State: (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ')');
+
if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear)
else doStepHedgehogDriven(Gear)
end;
--- a/hedgewars/uConsts.pas Thu Nov 20 15:48:50 2008 +0000
+++ b/hedgewars/uConsts.pas Fri Nov 21 15:58:36 2008 +0000
@@ -51,17 +51,18 @@
sprEvilTrace, sprHellishBomb, sprSeduction, sprDress,
sprCensored);
- TGearType = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
- gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope,
- gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite,
- gtTeamHealthSorter, gtClusterBomb, gtCluster, gtShover, gtFlame,
- gtFirePunch, gtATStartGame, gtATSmoothWindCh, gtATFinishGame,
- gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder,
- gtTeleport, gtSmallDamage, gtSwitcher, gtTarget, gtMortar,
- gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece,
+ TGearType = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag, // 3
+ gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope, // 8
+ gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite, // 14
+ gtTeamHealthSorter, gtClusterBomb, gtCluster, gtShover, gtFlame, // 19
+ gtFirePunch, gtATStartGame, gtATSmoothWindCh, gtATFinishGame, // 23
+ gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder, // 28
+ gtTeleport, gtSwitcher, gtTarget, gtMortar, // 32
+ gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece, // 38
gtHellishBomb, gtEvilTrace, gtWaterUp);
- TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire);
+ TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire,
+ vgtSmallDamageTag);
TGearsType = set of TGearType;
--- a/hedgewars/uGears.pas Thu Nov 20 15:48:50 2008 +0000
+++ b/hedgewars/uGears.pas Fri Nov 21 15:58:36 2008 +0000
@@ -97,7 +97,6 @@
procedure HedgehogStep(Gear: PGear); forward;
procedure HedgehogChAngle(Gear: PGear); forward;
procedure ShotgunShot(Gear: PGear); forward;
-procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); forward;
{$INCLUDE GSHandlers.inc}
{$INCLUDE HHHandlers.inc}
@@ -133,7 +132,6 @@
@doStepBlowTorch,
@doStepGirder,
@doStepTeleport,
- @doStepHealthTag,
@doStepSwitcher,
@doStepCase,
@doStepMortar,
@@ -152,32 +150,34 @@
var tmp, ptmp: PGear;
begin
if GearsList = nil then
- GearsList:= Gear
- else begin
- tmp:= GearsList;
- ptmp:= GearsList;
- while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do
- begin
- ptmp:= tmp;
- tmp:= tmp^.NextGear
- end;
+ GearsList:= Gear
+ else begin
+ tmp:= GearsList;
+ ptmp:= GearsList;
+ while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do
+ begin
+ ptmp:= tmp;
+ tmp:= tmp^.NextGear
+ end;
- if ptmp <> nil then
- begin
- Gear^.NextGear:= ptmp^.NextGear;
- Gear^.PrevGear:= ptmp;
- if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear;
- ptmp^.NextGear:= Gear
- end
- else GearsList:= Gear
- end
+ if ptmp <> nil then
+ begin
+ Gear^.NextGear:= ptmp^.NextGear;
+ Gear^.PrevGear:= ptmp;
+ if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear;
+ ptmp^.NextGear:= Gear
+ end
+ else GearsList:= Gear
+ end
end;
procedure RemoveGearFromList(Gear: PGear);
begin
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
-if Gear^.PrevGear <> nil then Gear^.PrevGear^.NextGear:= Gear^.NextGear
- else GearsList:= Gear^.NextGear
+if Gear^.PrevGear <> nil then
+ Gear^.PrevGear^.NextGear:= Gear^.NextGear
+else
+ GearsList:= Gear^.NextGear
end;
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
@@ -205,10 +205,10 @@
Result^.uid:= Counter;
if CurrentTeam <> nil then
- begin
- Result^.Hedgehog:= CurrentHedgehog;
- Result^.IntersectGear:= CurrentHedgehog^.Gear
- end;
+ begin
+ Result^.Hedgehog:= CurrentHedgehog;
+ Result^.IntersectGear:= CurrentHedgehog^.Gear
+ end;
case Kind of
gtAmmo_Bomb,
@@ -310,10 +310,6 @@
Result^.Radius:= cHHRadius + cBlowTorchC;
Result^.Timer:= 7500;
end;
- gtSmallDamage: begin
- Result^.Timer:= 1100;
- Result^.Z:= 2000;
- end;
gtSwitcher: begin
Result^.Z:= cCurrHHZ
end;
@@ -417,6 +413,7 @@
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
gtHealthTag, Gear^.Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
+
RenderHealth(PHedgehog(Gear^.Hedgehog)^);
RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
@@ -440,12 +437,6 @@
end;
end;
-procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear);
-begin
-if cAltDamage then
- AddGear(X, Y, gtSmallDamage, Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
-end;
-
procedure ProcessGears;
const delay: LongWord = 0;
step: (stDelay, stChDmg, stTurnReact,
@@ -574,10 +565,10 @@
AllInactive:= false;
t:= GearsList;
while t <> nil do
- begin
- t^.Active:= true;
- t:= t^.NextGear
- end
+ begin
+ t^.Active:= true;
+ t:= t^.NextGear
+ end
end;
procedure SetAllHHToActive;
@@ -586,10 +577,10 @@
AllInactive:= false;
t:= GearsList;
while t <> nil do
- begin
- if t^.Kind = gtHedgehog then t^.Active:= true;
- t:= t^.NextGear
- end
+ begin
+ if t^.Kind = gtHedgehog then t^.Active:= true;
+ t:= t^.NextGear
+ end
end;
procedure DrawHH(Gear: PGear);
@@ -1041,8 +1032,7 @@
gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
gtHedgehog: DrawHH(Gear);
gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
- gtHealthTag,
- gtSmallDamage: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
+ gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex);
gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4);
gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0);
@@ -1117,12 +1107,12 @@
begin
tt:= GearsList;
GearsList:= nil;
-while tt<>nil do
- begin
- t:= tt;
- tt:= tt^.NextGear;
- Dispose(t)
- end;
+while tt <> nil do
+ begin
+ t:= tt;
+ tt:= tt^.NextGear;
+ Dispose(t)
+ end;
end;
procedure AddMiscGears;
@@ -1168,7 +1158,7 @@
begin
inc(Gear^.Damage, dmg);
if Gear^.Kind = gtHedgehog then
- AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, Gear)
+ AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color)
end;
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
begin
@@ -1213,7 +1203,7 @@
inc(t^.Damage, dmg);
if t^.Kind = gtHedgehog then
- AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, t);
+ AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(t^.Hedgehog)^.Team^.Clan^.Color);
DeleteCI(t);
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX);
@@ -1250,7 +1240,7 @@
inc(t^.ar[i]^.Damage, Damage);
if (t^.ar[i]^.Kind = gtHedgehog) and (Damage > 0) then
- AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, t^.ar[i]);
+ AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, PHedgehog(t^.ar[i]^.Hedgehog)^.Team^.Clan^.Color);
DeleteCI(t^.ar[i]);
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01;
--- a/hedgewars/uVisualGears.pas Thu Nov 20 15:48:50 2008 +0000
+++ b/hedgewars/uVisualGears.pas Fri Nov 21 15:58:36 2008 +0000
@@ -23,48 +23,62 @@
const AllInactive: boolean = false;
type PVisualGear = ^TVisualGear;
- TVGearStepProcedure = procedure (Gear: PVisualGear; Steps: Longword);
- TVisualGear = record
- NextGear, PrevGear: PVisualGear;
- Frame,
- FrameTicks: Longword;
- X : hwFloat;
- Y : hwFloat;
- dX: hwFloat;
- dY: hwFloat;
- mdY: QWord;
- Angle, dAngle: real;
- Kind: TVisualGearType;
- doStep: TVGearStepProcedure;
- end;
+ TVGearStepProcedure = procedure (Gear: PVisualGear; Steps: Longword);
+ TVisualGear = record
+ NextGear, PrevGear: PVisualGear;
+ Frame,
+ FrameTicks: Longword;
+ X : hwFloat;
+ Y : hwFloat;
+ dX: hwFloat;
+ dY: hwFloat;
+ mdY: QWord;
+ Angle, dAngle: real;
+ Kind: TVisualGearType;
+ doStep: TVGearStepProcedure;
+ Tex: PTexture;
+ end;
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
procedure ProcessVisualGears(Steps: Longword);
procedure DrawVisualGears(Layer: LongWord);
procedure DeleteVisualGear(Gear: PVisualGear);
procedure AddClouds;
+procedure AddDamageTag(X, Y, Damage, Color: LongWord);
var VisualGearsList: PVisualGear = nil;
- vobFrameTicks, vobFramesCount: Longword;
- vobVelocity, vobFallSpeed: LongInt;
+ vobFrameTicks, vobFramesCount: Longword;
+ vobVelocity, vobFallSpeed: LongInt;
implementation
uses uWorld, uMisc, uStore;
const cExplFrameTicks = 110;
+procedure AddDamageTag(X, Y, Damage, Color: LongWord);
+var s: shortstring;
+begin
+if cAltDamage then
+ with AddVisualGear(X, Y, vgtSmallDamageTag)^ do
+ begin
+ str(Damage, s);
+ Tex:= RenderStringTex(s, Color, fntSmall);
+ end;
+end;
+
+
// ==================================================================
procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
begin
with Gear^ do
- begin
- inc(FrameTicks, Steps);
- if FrameTicks > vobFrameTicks then
- begin
- dec(FrameTicks, vobFrameTicks);
- inc(Frame);
- if Frame = vobFramesCount then Frame:= 0
- end
- end;
+ begin
+ inc(FrameTicks, Steps);
+ if FrameTicks > vobFrameTicks then
+ begin
+ dec(FrameTicks, vobFrameTicks);
+ inc(Frame);
+ if Frame = vobFramesCount then Frame:= 0
+ end
+ end;
Gear^.X:= Gear^.X + (cWindSpeed * 200 + Gear^.dX) * Steps;
Gear^.Y:= Gear^.Y + (Gear^.dY + cGravity * vobFallSpeed) * Steps;
@@ -124,15 +138,26 @@
dec(Gear^.FrameTicks, Steps)
end;
+procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword);
+begin
+Gear^.Y:= Gear^.Y - _0_02 * Steps;
+
+if Gear^.FrameTicks <= Steps then
+ DeleteVisualGear(Gear)
+else
+ dec(Gear^.FrameTicks, Steps)
+end;
+
// ==================================================================
const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure =
- (
- @doStepFlake,
- @doStepCloud,
- @doStepExpl,
- @doStepExpl,
- @doStepFire
- );
+ (
+ @doStepFlake,
+ @doStepCloud,
+ @doStepExpl,
+ @doStepExpl,
+ @doStepFire,
+ @doStepSmallDamage
+ );
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
var Result: PVisualGear;
@@ -146,57 +171,57 @@
Result^.Kind := Kind;
Result^.doStep:= doStepHandlers[Kind];
-case Kind of
- vgtFlake: with Result^ do
- begin
- FrameTicks:= random(vobFrameTicks);
- Frame:= random(vobFramesCount);
- Angle:= random * 360;
- dx.isNegative:= random(2) = 0;
- dx.QWordValue:= random(100000000);
- dy.isNegative:= false;
- dy.QWordValue:= random(70000000);
- dAngle:= (random(2) * 2 - 1) * (1 + random) * vobVelocity / 1000
- end;
- vgtCloud: with Result^ do
- begin
- Frame:= random(4);
- dx.isNegative:= random(2) = 0;
- dx.QWordValue:= random(214748364);
- dy.isNegative:= random(2) = 0;
- dy.QWordValue:= 21474836 + random(64424509);
- mdY:= dy.QWordValue
- end;
- vgtExplPart,
- vgtExplPart2: with Result^ do
- begin
- t:= random(1024);
- sp:= _0_001 * (random(95) + 70);
- dx:= AngleSin(t) * sp;
- dx.isNegative:= random(2) = 0;
- dy:= AngleCos(t) * sp;
- dy.isNegative:= random(2) = 0;
- Frame:= 7 - random(3);
- FrameTicks:= cExplFrameTicks
- end;
- vgtFire: with Result^ do
- begin
- t:= random(1024);
- sp:= _0_001 * (random(85) + 95);
- dx:= AngleSin(t) * sp;
- dx.isNegative:= random(2) = 0;
- dy:= AngleCos(t) * sp;
- dy.isNegative:= random(2) = 0;
- FrameTicks:= 650 + random(250);
- Frame:= random(8)
- end;
- end;
+with Result^ do
+ case Kind of
+ vgtFlake: begin
+ FrameTicks:= random(vobFrameTicks);
+ Frame:= random(vobFramesCount);
+ Angle:= random * 360;
+ dx.isNegative:= random(2) = 0;
+ dx.QWordValue:= random(100000000);
+ dy.isNegative:= false;
+ dy.QWordValue:= random(70000000);
+ dAngle:= (random(2) * 2 - 1) * (1 + random) * vobVelocity / 1000
+ end;
+ vgtCloud: begin
+ Frame:= random(4);
+ dx.isNegative:= random(2) = 0;
+ dx.QWordValue:= random(214748364);
+ dy.isNegative:= random(2) = 0;
+ dy.QWordValue:= 21474836 + random(64424509);
+ mdY:= dy.QWordValue
+ end;
+ vgtExplPart,
+ vgtExplPart2: begin
+ t:= random(1024);
+ sp:= _0_001 * (random(95) + 70);
+ dx:= AngleSin(t) * sp;
+ dx.isNegative:= random(2) = 0;
+ dy:= AngleCos(t) * sp;
+ dy.isNegative:= random(2) = 0;
+ Frame:= 7 - random(3);
+ FrameTicks:= cExplFrameTicks
+ end;
+ vgtFire: begin
+ t:= random(1024);
+ sp:= _0_001 * (random(85) + 95);
+ dx:= AngleSin(t) * sp;
+ dx.isNegative:= random(2) = 0;
+ dy:= AngleCos(t) * sp;
+ dy.isNegative:= random(2) = 0;
+ FrameTicks:= 650 + random(250);
+ Frame:= random(8)
+ end;
+ vgtSmallDamageTag: begin
+ Result^.FrameTicks:= 1100
+ end;
+ end;
if VisualGearsList <> nil then
- begin
- VisualGearsList^.PrevGear:= Result;
- Result^.NextGear:= VisualGearsList
- end;
+ begin
+ VisualGearsList^.PrevGear:= Result;
+ Result^.NextGear:= VisualGearsList
+ end;
VisualGearsList:= Result;
AddVisualGear:= Result
@@ -204,6 +229,9 @@
procedure DeleteVisualGear(Gear: PVisualGear);
begin
+if Gear^.Tex <> nil then
+ FreeTexture(Gear^.Tex);
+
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
if Gear^.PrevGear <> nil then Gear^.PrevGear^.NextGear:= Gear^.NextGear
else VisualGearsList:= Gear^.NextGear;
@@ -247,6 +275,7 @@
vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
vgtExplPart2: DrawSprite(sprExplPart2, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
+ vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
end;
Gear:= Gear^.NextGear
end