# HG changeset patch # User Wuzzy # Date 1520517942 -3600 # Node ID 64d84011a48e1ce72cc1696f9a324e05f8ed76c2 # Parent c3fc9157f740dc9ababa5e9ef5fe9c2b90f8b29c CTF: Write hog with most captures in stats screen diff -r c3fc9157f740 -r 64d84011a48e share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua Thu Mar 08 14:53:25 2018 +0100 +++ b/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua Thu Mar 08 15:05:42 2018 +0100 @@ -101,6 +101,11 @@ local teamSize = {} -- store how many hogs per team local teamIndex = {} -- at what point in the hhs{} does each team begin +local mostCapturesHogName = nil -- name of hog who holds the record of most flags captured +local mostCapturesHogTeam = nil -- name of team who holds the record of most flags captured +local mostCaptures = 0 -- number of most per-hog captures +local capturesPerHog = {} + ------------------- -- flag variables ------------------- @@ -169,6 +174,10 @@ SendStat(siPointType, loc("point(s)")) SendStat(siPlayerKills, tostring(teamList[i].score), teamList[i].name) end + + if mostCaptures >= 2 then + SendStat(siCustomAchievement, string.format(loc("%s (%s) has captured the flag %d times."), mostCapturesHogName, mostCapturesHogTeam, mostCaptures)) + end end end @@ -198,6 +207,14 @@ PlaySound(sndHomerun) fThief[thiefClan] = nil -- player no longer has the enemy flag fThiefFlag[flagClan] = nil + + capturesPerHog[CurrentHedgehog] = capturesPerHog[CurrentHedgehog] + 1 + if capturesPerHog[CurrentHedgehog] > mostCaptures then + mostCaptures = capturesPerHog[CurrentHedgehog] + mostCapturesHogName = GetHogName(CurrentHedgehog) + mostCapturesHogTeam = GetHogTeamName(CurrentHedgehog) + end + CheckScore(flagClan) --if the player is returning the flag @@ -596,6 +613,7 @@ if GetGearType(gear) == gtHedgehog then hhs[numhhs] = gear + capturesPerHog[gear] = 0 numhhs = numhhs + 1 SetEffect(gear, heResurrectable, 1)