Fix speech bubble chat commands also applying to bots
authorWuzzy <Wuzzy2@mail.ru>
Thu, 04 Oct 2018 20:36:41 +0200
changeset 13860 6e4e745f42bb
parent 13859 ff468792298a
child 13861 2b6702777c8c
Fix speech bubble chat commands also applying to bots
ChangeLog.txt
hedgewars/uChat.pas
hedgewars/uGearsRender.pas
--- a/ChangeLog.txt	Thu Oct 04 13:26:48 2018 -0400
+++ b/ChangeLog.txt	Thu Oct 04 20:36:41 2018 +0200
@@ -37,6 +37,7 @@
  * Prevent voices from being spoken directly before a victory voice
  * Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
  * Fix retreat timer appearing after using baseball bat or whip and immediately taking damage
+ * Speech bubble commands no longer apply to computer-controlled hogs
 
 Frontend:
  + Add setting to disable audio dampening when losing window focus
--- a/hedgewars/uChat.pas	Thu Oct 04 13:26:48 2018 -0400
+++ b/hedgewars/uChat.pas	Thu Oct 04 20:36:41 2018 +0200
@@ -361,7 +361,7 @@
             // default to current hedgehog (if own) or first hedgehog
             if SpeechHogNumber = 0 then
                 begin
-                if not CurrentTeam^.ExtDriven then
+                if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) then
                     SpeechHogNumber:= CurrentTeam^.CurrHedgehog + 1
                 else
                     SpeechHogNumber:= 1;
@@ -449,7 +449,7 @@
 else if (s[1] = '-') and (s[Length(s)] = '-') then
     x:= 3;
 
-if (not CurrentTeam^.ExtDriven) and (x <> 0) then
+if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) and (x <> 0) then
     for c:= 0 to Pred(TeamsCount) do
         if (TeamsArray[c] = CurrentTeam) then
             t:= c;
@@ -477,7 +477,7 @@
     // Speech bubble, but on next attack
     if (copy(s, 2, 4) = 'hsa ') then
         begin
-        if CurrentTeam^.ExtDriven then
+        if (CurrentTeam^.ExtDriven or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0)) then
             ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
         else
             SendHogSpeech(#4 + copy(s, 6, Length(s)-5));
@@ -487,7 +487,7 @@
     // Thinking bubble, but on next attack
     if (copy(s, 2, 4) = 'hta ') then
         begin
-        if CurrentTeam^.ExtDriven then
+        if (CurrentTeam^.ExtDriven or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0)) then
             ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
         else
             SendHogSpeech(#5 + copy(s, 6, Length(s)-5));
@@ -497,7 +497,7 @@
     // Yelling bubble, but on next attack
     if (copy(s, 2, 4) = 'hya ') then
         begin
-        if CurrentTeam^.ExtDriven then
+        if (CurrentTeam^.ExtDriven or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0)) then
             ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
         else
             SendHogSpeech(#6 + copy(s, 6, Length(s)-5));
--- a/hedgewars/uGearsRender.pas	Thu Oct 04 13:26:48 2018 -0400
+++ b/hedgewars/uGearsRender.pas	Thu Oct 04 20:36:41 2018 +0200
@@ -225,7 +225,7 @@
 begin
 t:= LocalTeam;
 
-if not CurrentTeam^.ExtDriven then
+if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) then
     for i:= 0 to Pred(TeamsCount) do
         if (TeamsArray[i] = CurrentTeam) then
             t:= i;