Quick and simple implementation of afk mode (toggled by /pause)
authorunc0rr
Sun, 03 Nov 2013 22:39:00 +0400
changeset 9670 1954f692e8c6
parent 9669 9fa0f67ff628
child 9671 6e95617988c9
child 9672 8663d299ba62
Quick and simple implementation of afk mode (toggled by /pause)
hedgewars/uCommandHandlers.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uScript.pas
hedgewars/uStore.pas
hedgewars/uTypes.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Locale/en.txt
share/hedgewars/Data/Locale/ru.txt
--- a/hedgewars/uCommandHandlers.pas	Sun Nov 03 22:37:41 2013 +0400
+++ b/hedgewars/uCommandHandlers.pas	Sun Nov 03 22:39:00 2013 +0400
@@ -641,9 +641,11 @@
 begin
 s:= s; // avoid compiler hint
 if gameType <> gmtNet then
-    isPaused:= not isPaused;
+    isPaused:= not isPaused
+    else
+    isAFK:= not isAFK;
 
-if isPaused then
+if isPaused or isAFK then
     SDL_ShowCursor(1)
     else
     SDL_ShowCursor(ord(GameState = gsConfirm))
--- a/hedgewars/uGearsHedgehog.pas	Sun Nov 03 22:37:41 2013 +0400
+++ b/hedgewars/uGearsHedgehog.pas	Sun Nov 03 22:39:00 2013 +0400
@@ -35,10 +35,22 @@
 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions,
     uCommands, uLocale, uUtils, uStats, uIO, uScript,
     uGearsList, uCollisions, uRandom, uStore, uTeams,
-    uGearsUtils, uVisualGearsList;
+    uGearsUtils, uVisualGearsList, uChat;
 
 var GHStepTicks: LongWord = 0;
 
+procedure AFKSkip;
+var
+    t: byte;
+begin
+    t:= 0;
+    while (TeamsArray[t] <> CurrentTeam) do inc(t);
+
+    SendHogSpeech(#1 + char(t) + 'AFK');
+
+    ParseCommand('/skip', true)
+end;
+
 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
 function ChangeAmmo(HHGear: PGear): boolean;
 var slot, i: Longword;
@@ -1056,6 +1068,12 @@
     exit
     end;
 
+if isAFK and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
+    begin
+    AFKSkip;
+    exit
+    end;
+
 if (HHGear^.State and gstAnimation) <> 0 then
     begin
     HHGear^.Message:= 0;
@@ -1296,7 +1314,7 @@
     DeleteGear(Gear);
     exit
     end;
-if GameTicks mod 100 = 0 then CheckIce(Gear);
+if GameTicks mod 128 = 0 then CheckIce(Gear);
 (*
 if Gear^.Hedgehog^.Effects[heFrozen] > 0 then
     begin
--- a/hedgewars/uScript.pas	Sun Nov 03 22:37:41 2013 +0400
+++ b/hedgewars/uScript.pas	Sun Nov 03 22:39:00 2013 +0400
@@ -80,7 +80,6 @@
     uRenderUtils,
     uTextures,
     uLandGraphics,
-    SDLh,
     SysUtils, 
     uIO,
     uVisualGearsList,
--- a/hedgewars/uStore.pas	Sun Nov 03 22:37:41 2013 +0400
+++ b/hedgewars/uStore.pas	Sun Nov 03 22:39:00 2013 +0400
@@ -403,6 +403,7 @@
 InitHealth;
 
 PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
+AFKTexture:= RenderStringTex(trmsg[sidAFK], cYellowColor, fntBig);
 ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
 SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
 
@@ -483,6 +484,7 @@
 FreeAndNilTexture(CrosshairTexture);
 FreeAndNilTexture(WeaponTooltipTex);
 FreeAndNilTexture(PauseTexture);
+FreeAndNilTexture(AFKTexture);
 FreeAndNilTexture(SyncTexture);
 FreeAndNilTexture(ConfirmTexture);
 FreeAndNilTexture(ropeIconTex);
--- a/hedgewars/uTypes.pas	Sun Nov 03 22:37:41 2013 +0400
+++ b/hedgewars/uTypes.pas	Sun Nov 03 22:39:00 2013 +0400
@@ -440,7 +440,7 @@
             sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync,
             sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD, sidReady,
             sidBounce1, sidBounce2, sidBounce3, sidBounce4, sidBounce5, sidBounce,
-            sidMute);
+            sidMute, sidAFK);
 
     // Events that are important for the course of the game or at least interesting for other reasons
     TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw,
--- a/hedgewars/uVariables.pas	Sun Nov 03 22:37:41 2013 +0400
+++ b/hedgewars/uVariables.pas	Sun Nov 03 22:39:00 2013 +0400
@@ -69,6 +69,7 @@
     isPaused        : boolean;
     isInMultiShoot  : boolean;
     isSpeed         : boolean;
+    isAFK           : boolean;
     SpeedStart      : LongWord;
 
     fastUntilLag    : boolean;
@@ -2296,6 +2297,7 @@
 
 
     PauseTexture,
+    AFKTexture,
     SyncTexture,
     ConfirmTexture: PTexture;
     cScaleFactor: GLfloat;
@@ -2499,6 +2501,7 @@
     isPaused        := false;
     isInMultiShoot  := false;
     isSpeed         := false;
+    isAFK           := false;
     SpeedStart      := 0;
     fastUntilLag    := false;
     fastScrolling   := false;
--- a/hedgewars/uWorld.pas	Sun Nov 03 22:37:41 2013 +0400
+++ b/hedgewars/uWorld.pas	Sun Nov 03 22:39:00 2013 +0400
@@ -979,7 +979,7 @@
     //glPushMatrix;
     //glScalef(1.0, 1.0, 1.0);
 
-    if (not isPaused) and (GameType <> gmtRecord) then
+    if (not isPaused) and (not isAFK) and (GameType <> gmtRecord) then
         MoveCamera;
 
     if cStereoMode = smNone then
@@ -1555,6 +1555,8 @@
     DrawTextureCentered(0, (cScreenHeight shr 1), SyncTexture);
 if isPaused then
     DrawTextureCentered(0, (cScreenHeight shr 1), PauseTexture);
+if isAFK then
+    DrawTextureCentered(0, (cScreenHeight shr 1), AFKTexture);
 if not isFirstFrame and (missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm) then
     begin
     if (ReadyTimeLeft = 0) and (missionTimer > 0) then
--- a/share/hedgewars/Data/Locale/en.txt	Sun Nov 03 22:37:41 2013 +0400
+++ b/share/hedgewars/Data/Locale/en.txt	Sun Nov 03 22:39:00 2013 +0400
@@ -81,6 +81,7 @@
 01:19=Extreme
 01:20=%1 Bounce
 01:21=Audio Muted
+01:22=AFK mode
 
 ; Event messages
 ; Hog (%1) died
--- a/share/hedgewars/Data/Locale/ru.txt	Sun Nov 03 22:37:41 2013 +0400
+++ b/share/hedgewars/Data/Locale/ru.txt	Sun Nov 03 22:39:00 2013 +0400
@@ -80,6 +80,8 @@
 01:18=Высокий
 01:19=Экстремальный
 01:20=%1 отскок
+01:21=Звук отключен
+01:22=Режим отсутствия
 
 ; Event messages
 ; Hog (%1) died