diff -r 8d598aa498b0 -r d73317579ae4 share/hedgewars/Data/Scripts/Multiplayer/Racer.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua Mon Oct 31 16:56:48 2011 +0100 +++ b/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua Mon Oct 31 19:40:39 2011 +0200 @@ -1,6 +1,6 @@ ------------------------------------------ --- RACER 0.4 +-- RACER 0.5 -- map-independant racing script -- by mikade ----------------------------------------- @@ -52,6 +52,15 @@ -- update user feedback -- add more sounds +------- +-- 0.5 +------- + +-- fix ghost disappearing if hog falls in water or somehow dies +-- lengthen ghost tracking interval to improve performance on slower machines +-- increase waypoint limit to 8 +-- allow for persistent showmission information + ----------------------------- -- SCRIPT BEGINS ----------------------------- @@ -116,7 +125,11 @@ local wpActive = {} local wpRad = 450 --75 local wpCount = 0 -local wpLimit = 5 +local wpLimit = 8 + +local roundN +local lastRound +local RoundHasChanged ------------------- -- general methods @@ -317,31 +330,50 @@ end +function onNewRound() + + roundNumber = roundNumber + 1 + + totalComment = "" + for i = 0, (TeamsCount-1) do + if teamNameArr[i] ~= " " then -- teamScore[teamClan[i]] + teamComment[i] = teamNameArr[i] .. ": " .. (teamScore[i]/1000) .. loc("s|") + totalComment = totalComment .. teamComment[i] + elseif teamNameArr[i] == " " then + teamComment[i] = "|" + end + end + + ShowMission( loc("RACER"), + loc("STATUS UPDATE"), + loc("Rounds Complete: ") .. roundNumber .. "/" .. roundLimit .. "|" .. " " .. "|" .. + loc("Best Team Times: ") .. "|" .. totalComment, 0, 4000) + + -- end game if its at round limit + if roundNumber == roundLimit then + for i = 0, (numhhs-1) do + if GetHogClan(hhs[i]) ~= bestClan then + SetEffect(hhs[i], heResurrectable, false) + SetHealth(hhs[i],0) + end + end + gameOver = true + TurnTimeLeft = 1 + end + +end + function CheckForNewRound() - if GetHogClan(CurrentHedgehog) == firstClan then - - roundNumber = roundNumber + 1 + ------------- + ------ new + ------------- - totalComment = "" - for i = 0, (TeamsCount-1) do - if teamNameArr[i] ~= " " then -- teamScore[teamClan[i]] - teamComment[i] = teamNameArr[i] .. ": " .. (teamScore[i]/1000) .. loc("s|") - totalComment = totalComment .. teamComment[i] - elseif teamNameArr[i] == " " then - teamComment[i] = "|" - end - end - - ShowMission( loc("RACER"), - loc("STATUS UPDATE"), - loc("Rounds Complete: ") .. roundNumber .. "/" .. roundLimit .. "|" .. " " .. "|" .. - loc("Best Team Times: ") .. "|" .. totalComment, 0, 4000) - - -- end game if its at round limit - if roundNumber == roundLimit then + --[[turnN = turnN + 1 + if gameBegun == false then + if turnN == 2 then for i = 0, (numhhs-1) do - if GetHogClan(hhs[i]) ~= bestClan then + if hhs[i] ~= nil then SetEffect(hhs[i], heResurrectable, false) SetHealth(hhs[i],0) end @@ -349,7 +381,39 @@ gameOver = true TurnTimeLeft = 1 end + else + + end]] + + --[[if roundBegun == true then + + if RoundHasChanged == true then + roundN = roundN + 1 + RoundHasChanged = false + onNewRound() + end + + if lastRound ~= TotalRounds then -- new round, but not really + + if RoundHasChanged == false then + RoundHasChanged = true + end + + end + + AddCaption("RoundN:" .. roundN .. "; " .. "TR: " .. TotalRounds) + + lastRound = TotalRounds + + end]] + + ------------ + ----- old + ------------ + + if GetHogClan(CurrentHedgehog) == firstClan then + onNewRound() end end @@ -402,6 +466,11 @@ function onGameStart() + + roundN = 0 + lastRound = TotalRounds + RoundHasChanged = false -- true + RebuildTeamInfo() ShowMission ( @@ -413,8 +482,6 @@ "", 4, 4000 ) - - end function PlaceWayPoint(x,y) @@ -490,7 +557,7 @@ -- airstrike detected, convert this into a potential waypoint spot if cGear ~= nil then x,y = GetGearTarget(cGear) - + DeleteGear(cGear) if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then @@ -525,7 +592,8 @@ SetGearPosition(CurrentHedgehog, wpX[0], wpY[0]) AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1) FollowGear(CurrentHedgehog) - ShowMission("...", "...", "...", 2, 1) + + HideMission() else -- still in placement mode @@ -546,7 +614,7 @@ --ghost gTimer = gTimer + 1 - if gTimer == 15 then + if gTimer == 40 then gTimer = 0 HandleGhost() end @@ -584,6 +652,10 @@ AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) + if gear == CurrentHedgehog then + DisableTumbler() + end + -- if the player stops and "dies" or flies into water, stop him racing --[[if gear == CurrentHedgehog then DisableTumbler()