# HG changeset patch # User smaxx # Date 1282831329 -7200 # Node ID af0e68ca273ebef0dc84b86156e3dfe1686d007a # Parent f552c7b439fa98321d5bb23d50afbe9a7eedb1a0 Engine: * Added a 5 seconds ready time to every (player controlled) hog's start of the round. Use [attack] to skip it (untested in multiplayer). Frontend: * Fixed training missions failing to start. diff -r f552c7b439fa -r af0e68ca273e QTfrontend/game.cpp --- a/QTfrontend/game.cpp Thu Aug 26 14:46:30 2010 +0100 +++ b/QTfrontend/game.cpp Thu Aug 26 16:02:09 2010 +0200 @@ -357,7 +357,7 @@ void HWGame::StartTraining(const QString & file) { gameType = gtTraining; - training = datadir->absolutePath() + "/Missions/Tutorial/" + file + ".lua"; + training = datadir->absolutePath() + "/Missions/Training/" + file + ".lua"; demo.clear(); Start(); SetGameState(gsStarted); diff -r f552c7b439fa -r af0e68ca273e hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Thu Aug 26 14:46:30 2010 +0100 +++ b/hedgewars/CCHandlers.inc Thu Aug 26 16:02:09 2010 +0200 @@ -289,7 +289,7 @@ procedure chLeft_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; bShowFinger:= false; if not CurrentTeam^.ExtDriven then SendIPC('L'); with CurrentHedgehog^.Gear^ do @@ -308,7 +308,7 @@ procedure chRight_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; bShowFinger:= false; if not CurrentTeam^.ExtDriven then SendIPC('R'); with CurrentHedgehog^.Gear^ do @@ -327,7 +327,7 @@ procedure chUp_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; bShowFinger:= false; if not CurrentTeam^.ExtDriven then SendIPC('U'); with CurrentHedgehog^.Gear^ do @@ -346,7 +346,7 @@ procedure chDown_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; bShowFinger:= false; if not CurrentTeam^.ExtDriven then SendIPC('D'); with CurrentHedgehog^.Gear^ do @@ -365,7 +365,7 @@ procedure chPrecise_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; bShowFinger:= false; if not CurrentTeam^.ExtDriven then SendIPC('Z'); with CurrentHedgehog^.Gear^ do @@ -384,7 +384,7 @@ procedure chLJump(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; bShowFinger:= false; if not CurrentTeam^.ExtDriven then SendIPC('j'); with CurrentHedgehog^.Gear^ do @@ -394,7 +394,7 @@ procedure chHJump(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; bShowFinger:= false; if not CurrentTeam^.ExtDriven then SendIPC('J'); with CurrentHedgehog^.Gear^ do @@ -405,6 +405,12 @@ begin s:= s; // avoid compiler hint if CheckNoTeamOrHH or isPaused then exit; +if ReadyTimeLeft > 1 then + begin + ReadyTimeLeft:= 1; // set to 1 millisecond so we still play the sound file + if not CurrentTeam^.ExtDriven then SendIPC('A'); + exit + end; bShowFinger:= false; with CurrentHedgehog^.Gear^ do begin @@ -433,7 +439,7 @@ procedure chSwitch(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; if not CurrentTeam^.ExtDriven then SendIPC('S'); with CurrentHedgehog^.Gear^ do Message:= Message or gm_Switch @@ -566,7 +572,7 @@ procedure chNewGrave; begin -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; if not CurrentTeam^.ExtDriven then SendIPC('g'); @@ -575,7 +581,7 @@ procedure doPut(putX, putY: LongInt; fromAI: boolean); begin -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused or (ReadyTimeLeft > 0) then exit; if not CurrentTeam^.ExtDriven and bShowAmmoMenu then begin bSelected:= true; diff -r f552c7b439fa -r af0e68ca273e hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Thu Aug 26 14:46:30 2010 +0100 +++ b/hedgewars/hwengine.pas Thu Aug 26 16:02:09 2010 +0200 @@ -85,7 +85,7 @@ ProcessKbd; if not isPaused then begin - DoGameTick(Lag); + if ReadyTimeLeft = 0 then DoGameTick(Lag); ProcessVisualGears(Lag); end; end; @@ -93,7 +93,7 @@ DrawWorld(Lag); if not isPaused then begin - DoGameTick(Lag); + if ReadyTimeLeft = 0 then DoGameTick(Lag); ProcessVisualGears(Lag); end; end; diff -r f552c7b439fa -r af0e68ca273e hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Thu Aug 26 14:46:30 2010 +0100 +++ b/hedgewars/uConsts.pas Thu Aug 26 16:02:09 2010 +0200 @@ -122,7 +122,8 @@ sndMelonImpact, sndDroplet1, sndDroplet2, sndDroplet3, sndEggBreak, sndDrillRocket, sndPoisonCough, sndPoisonMoan, sndBirdyLay, sndWhistle, sndBeeWater, sndPiano0, sndPiano1, sndPiano2, sndPiano3, sndPiano4, sndPiano5, sndPiano6, sndPiano7, sndPiano8, - sndSkip, sndSineGun, sndOoff1, sndOoff2, sndOoff3, sndWhack); + sndSkip, sndSineGun, sndOoff1, sndOoff2, sndOoff3, sndWhack, + sndComeonthen); TAmmoType = (amNothing, amGrenade, amClusterBomb, amBazooka, amBee, amShotgun, amPickHammer, amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip, @@ -937,7 +938,8 @@ (FileName: 'Ooff1.ogg'; Path: ptVoices),// sndOoff1 (FileName: 'Ooff2.ogg'; Path: ptVoices),// sndOoff2 (FileName: 'Ooff3.ogg'; Path: ptVoices),// sndOoff3 - (FileName: 'whipcrack.ogg'; Path: ptSounds) // sndWhack + (FileName: 'whipcrack.ogg'; Path: ptSounds),// sndWhack + (FileName: 'Comeonthen.ogg'; Path: ptVoices) // sndComeonthen ); Ammoz: array [TAmmoType] of record diff -r f552c7b439fa -r af0e68ca273e hedgewars/uLocale.pas --- a/hedgewars/uLocale.pas Thu Aug 26 14:46:30 2010 +0100 +++ b/hedgewars/uLocale.pas Thu Aug 26 16:02:09 2010 +0200 @@ -34,7 +34,7 @@ TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused, sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync, - sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD); + sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD, sidReady); TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw, eidNewHealthPack, eidNewAmmoPack, eidNewUtilityPack, eidTurnSkipped, eidHurtSelf, diff -r f552c7b439fa -r af0e68ca273e hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Thu Aug 26 14:46:30 2010 +0100 +++ b/hedgewars/uMisc.pas Thu Aug 26 16:02:09 2010 +0200 @@ -42,6 +42,7 @@ GameFlags : Longword; TrainingFlags : Longword; TurnTimeLeft : Longword; + ReadyTimeLeft : Longword; cSuddenDTurns : LongInt; cDamagePercent : LongInt; cMineDudPercent : LongWord; @@ -110,6 +111,7 @@ cVolumeDelta : LongInt; cHasFocus : boolean; cInactDelay : Longword; + cReadyDelay : Longword; bBetweenTurns : boolean; cHealthDecrease : LongWord; @@ -783,6 +785,8 @@ cVolumeDelta := 0; cHasFocus := true; cInactDelay := 1250; + cReadyDelay := 5000; + ReadyTimeLeft := 0; ScreenFade := sfNone; diff -r f552c7b439fa -r af0e68ca273e hedgewars/uScript.pas --- a/hedgewars/uScript.pas Thu Aug 26 14:46:30 2010 +0100 +++ b/hedgewars/uScript.pas Thu Aug 26 16:02:09 2010 +0200 @@ -780,6 +780,7 @@ ScriptSetInteger('LandAdds', cLandAdditions); ScriptSetInteger('Explosives', cExplosives); ScriptSetInteger('Delay', cInactDelay); +ScriptSetInteger('Ready', cReadyDelay); ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); ScriptSetString('Map', ''); ScriptSetString('Theme', ''); @@ -805,6 +806,7 @@ ParseCommand('map ' + ScriptGetString('Map'), true); if ScriptGetString('Theme') <> '' then ParseCommand('theme ' + ScriptGetString('Theme'), true); +cReadyDelay:= ScriptGetInteger('Ready'); if ScriptExists('onAmmoStoreInit') then begin @@ -821,7 +823,10 @@ begin ret:= luaL_loadfile(luaState, Str2PChar(name)); if ret <> 0 then - LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')') + begin + LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); + LuaError('Lua: ' + lua_tostring(luaState, -1)); + end else begin WriteLnToConsole('Lua: ' + name + ' loaded'); diff -r f552c7b439fa -r af0e68ca273e hedgewars/uStore.pas --- a/hedgewars/uStore.pas Thu Aug 26 14:46:30 2010 +0100 +++ b/hedgewars/uStore.pas Thu Aug 26 16:02:09 2010 +0200 @@ -26,6 +26,7 @@ var PixelFormat: PSDL_PixelFormat; SDLPrimSurface: PSDL_Surface; PauseTexture, + ReadyTexture, SyncTexture, ConfirmTexture: PTexture; cScaleFactor: GLfloat; @@ -444,7 +445,9 @@ InitHealth; +// TODO: are those textures ever freed? PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig); +ReadyTexture:= RenderStringTex(trmsg[sidReady], cYellowColor, fntBig); ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig); SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig); diff -r f552c7b439fa -r af0e68ca273e hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Thu Aug 26 14:46:30 2010 +0100 +++ b/hedgewars/uTeams.pas Thu Aug 26 16:02:09 2010 +0200 @@ -137,6 +137,7 @@ CheckForWin:= true; TurnTimeLeft:= 0; +ReadyTimeLeft:= 0; if AliveCount = 0 then begin // draw AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); @@ -274,17 +275,19 @@ bShowFinger:= true; -if (CurrentTeam^.ExtDriven or (CurrentHedgehog^.BotLevel > 0)) then - PlaySound(sndIllGetYou, CurrentTeam^.voicepack) -else - PlaySound(sndYesSir, CurrentTeam^.voicepack); - if PlacingHogs then begin if CurrentHedgehog^.Unplaced then TurnTimeLeft:= 15000 else TurnTimeLeft:= 0 end -else TurnTimeLeft:= cHedgehogTurnTime +else TurnTimeLeft:= cHedgehogTurnTime; +if (TurnTimeLeft > 0) and (CurrentHedgehog^.BotLevel = 0) then + begin + PlaySound(sndComeonthen, CurrentTeam^.voicepack); + ReadyTimeLeft:= cReadyDelay + end +else + ReadyTimeLeft:= 0; end; function AddTeam(TeamColor: Longword): PTeam; diff -r f552c7b439fa -r af0e68ca273e hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Thu Aug 26 14:46:30 2010 +0100 +++ b/hedgewars/uWorld.pas Thu Aug 26 16:02:09 2010 +0200 @@ -537,7 +537,7 @@ offset, offsetX, offsetY, ScreenBottom: LongInt; VertexBuffer: array [0..3] of TVertex2f; begin - if not isPaused then + if not isPaused and (ReadyTimeLeft = 0) then begin if ZoomValue < zoom then begin @@ -545,7 +545,7 @@ if ZoomValue > zoom then zoom:= ZoomValue end - else + else if ZoomValue > zoom then begin zoom:= zoom + 0.002 * Lag; @@ -668,9 +668,13 @@ offsetX:= 48; {$ENDIF} offsetY:= cOffsetY; -if TurnTimeLeft <> 0 then - begin - i:= Succ(Pred(TurnTimeLeft) div 1000); +if (TurnTimeLeft <> 0) or (ReadyTimeLeft <> 0) then + begin + if ReadyTimeLeft <> 0 then + i:= Succ(Pred(ReadyTimeLeft) div 1000) + else + i:= Succ(Pred(TurnTimeLeft) div 1000); + if i>99 then t:= 112 else if i>9 then t:= 96 else t:= 80; @@ -853,10 +857,24 @@ if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture); if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture); +if ReadyTimeLeft > 0 then + begin + // TODO: move outside drawing code or do a spearate step in ugears? + if (ReadyTimeLeft = 1) or (ReadyTimeLeft < Lag) then + if (CurrentTeam^.ExtDriven or (CurrentHedgehog^.BotLevel > 0)) then + PlaySound(sndIllGetYou, CurrentTeam^.voicepack) + else + PlaySound(sndYesSir, CurrentTeam^.voicepack); -if not isFirstFrame and ((missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm)) then + if ReadyTimeLeft > Lag then + dec(ReadyTimeLeft, Lag) + else + ReadyTimeLeft:= 0; + DrawCentered(0, (cScreenHeight shr 1), ReadyTexture); + end; +if not isFirstFrame and (missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm) then begin - if missionTimer > 0 then dec(missionTimer, Lag); + if (ReadyTimeLeft = 0) and (missionTimer > 0) then dec(missionTimer, Lag); if missionTimer < 0 then missionTimer:= 0; // avoid subtracting below 0 if missionTex <> nil then DrawCentered(0, min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex); diff -r f552c7b439fa -r af0e68ca273e share/hedgewars/Data/Locale/en.txt --- a/share/hedgewars/Data/Locale/en.txt Thu Aug 26 14:46:30 2010 +0100 +++ b/share/hedgewars/Data/Locale/en.txt Thu Aug 26 16:02:09 2010 +0200 @@ -64,6 +64,7 @@ 01:11=This weapon or utility is not yet available! 01:12=Last round till Sudden Death! 01:13=%1 rounds till Sudden Death! +01:14=Get ready! ; Event messages ; Hog (%1) died