By request. Allow lua to make random things "talk". I'm not sure if this is a good idea, buuuut.
--- a/hedgewars/uTeams.pas Tue Mar 11 22:49:01 2014 -0400
+++ b/hedgewars/uTeams.pas Wed Mar 12 22:40:49 2014 -0400
@@ -156,7 +156,7 @@
if c > cMaxHHIndex then
c:= 0
end
- until (c = CurrHedgehog) or (Hedgehogs[c].Gear <> nil);
+ until (c = CurrHedgehog) or (Hedgehogs[c].Gear <> nil) and (Hedgehogs[c].Effects[heFrozen] < 50255);
LocalAmmo:= Hedgehogs[c].AmmoStore
end;
--- a/hedgewars/uVisualGears.pas Tue Mar 11 22:49:01 2014 -0400
+++ b/hedgewars/uVisualGears.pas Wed Mar 12 22:40:49 2014 -0400
@@ -250,13 +250,13 @@
else
DrawSpriteRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);*)
vgtSpeechBubble: begin
- if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team <> CurrentTeam)) or (Gear^.State = 1)) then
+ if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Team <> CurrentTeam)) or (Gear^.State = 1)) then
begin
tinted:= true;
Tint($FF, $FF, $FF, $66);
DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
end
- else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team = CurrentTeam)) or (Gear^.State = 2)) then
+ else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and ((Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.Team = CurrentTeam))) or (Gear^.State = 2)) then
DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
end;
vgtSmallDamageTag: DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
--- a/hedgewars/uVisualGearsHandlers.pas Tue Mar 11 22:49:01 2014 -0400
+++ b/hedgewars/uVisualGearsHandlers.pas Wed Mar 12 22:40:49 2014 -0400
@@ -30,7 +30,7 @@
unit uVisualGearsHandlers;
interface
-uses uTypes;
+uses uTypes, uGears;
var doStepVGHandlers: array[TVisualGearType] of TVGearStepProcedure;
@@ -587,47 +587,61 @@
////////////////////////////////////////////////////////////////////////////////
procedure doStepSpeechBubbleWork(Gear: PVisualGear; Steps: Longword);
+var realgear: PGear;
begin
if Gear^.Timer > Steps then dec(Gear^.Timer, Steps) else Gear^.Timer:= 0;
-
-if (Gear^.Hedgehog^.Gear <> nil) then
+realgear:= nil;
+if Gear^.Frame <> 0 then // use a non-hedgehog gear - a lua trick that hopefully won't be overused
+ begin
+ realgear:= GearByUID(Gear^.Frame);
+ if realgear <> nil then
+ begin
+ Gear^.X:= hwFloat2Float(realgear^.X) + (Gear^.Tex^.w div 2 - Gear^.Tag);
+ Gear^.Y:= hwFloat2Float(realgear^.Y) - (realgear^.Radius + Gear^.Tex^.h);
+ end
+ end
+else if Gear^.Hedgehog^.Gear <> nil then
begin
Gear^.X:= hwFloat2Float(Gear^.Hedgehog^.Gear^.X) + (Gear^.Tex^.w div 2 - Gear^.Tag);
- Gear^.Y:= hwFloat2Float(Gear^.Hedgehog^.Gear^.Y) - (16 + Gear^.Tex^.h);
+ Gear^.Y:= hwFloat2Float(Gear^.Hedgehog^.Gear^.Y) - (cHHRadius + Gear^.Tex^.h);
end;
-if Gear^.Timer = 0 then
+if (Gear^.Timer = 0) or ((realgear = nil) and (Gear^.Frame <> 0)) then
begin
- if Gear^.Hedgehog^.SpeechGear = Gear then
+ if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.SpeechGear = Gear) then
Gear^.Hedgehog^.SpeechGear:= nil;
DeleteVisualGear(Gear)
end;
end;
procedure doStepSpeechBubble(Gear: PVisualGear; Steps: Longword);
+var realgear: PGear;
begin
{$IFNDEF PAS2C}
Steps:= Steps; // avoid compiler hint
{$ENDIF}
+if Gear^.Frame <> 0 then
+ realgear:= GearByUID(Gear^.FrameTicks)
+else
+ begin
+ with Gear^.Hedgehog^ do
+ if SpeechGear <> nil then
+ SpeechGear^.Timer:= 0;
+ realgear:= Gear^.Hedgehog^.Gear;
+ Gear^.Hedgehog^.SpeechGear:= Gear;
+ end;
-with Gear^.Hedgehog^ do
- if SpeechGear <> nil then
- SpeechGear^.Timer:= 0;
-
-Gear^.Hedgehog^.SpeechGear:= Gear;
+if realgear <> nil then
+ case Gear^.FrameTicks of
+ 1: Gear^.Tag:= SpritesData[sprSpeechTail].Width-37+realgear^.Radius;
+ 2: Gear^.Tag:= SpritesData[sprThoughtTail].Width-29+realgear^.Radius;
+ 3: Gear^.Tag:= SpritesData[sprShoutTail].Width-19+realgear^.Radius;
+ end;
Gear^.Timer:= max(LongInt(Length(Gear^.Text)) * 150, 3000);
-
Gear^.Tex:= RenderSpeechBubbleTex(ansistring(Gear^.Text), Gear^.FrameTicks, fnt16);
-// FrameTicks cannot hold negative values
-case Gear^.FrameTicks of
- 1: Gear^.Tag:= SpritesData[sprSpeechTail].Width-28;
- 2: Gear^.Tag:= SpritesData[sprThoughtTail].Width-20;
- 3: Gear^.Tag:= SpritesData[sprShoutTail].Width-10;
- end;
-
Gear^.doStep:= @doStepSpeechBubbleWork;
Gear^.Y:= Gear^.Y - Gear^.Tex^.h
--- a/hedgewars/uVisualGearsList.pas Tue Mar 11 22:49:01 2014 -0400
+++ b/hedgewars/uVisualGearsList.pas Wed Mar 12 22:40:49 2014 -0400
@@ -85,10 +85,8 @@
gear^.Y:= real(Y);
gear^.Kind := Kind;
gear^.doStep:= doStepVGHandlers[Kind];
-gear^.State:= 0;
gear^.Tint:= $FFFFFFFF;
gear^.uid:= VGCounter;
-gear^.Layer:= 0;
with gear^ do
case Kind of