diff -r 6766b900ab13 -r a297e06d1607 share/hedgewars/Data/Scripts/TargetPractice.lua --- a/share/hedgewars/Data/Scripts/TargetPractice.lua Fri Feb 23 22:43:34 2018 +0100 +++ b/share/hedgewars/Data/Scripts/TargetPractice.lua Sat Feb 24 14:59:35 2018 +0100 @@ -103,6 +103,12 @@ - shootText: A string which says how many times the player shot, ā€œ%dā€ is replaced by the number of shots. (default: "You have shot %d times.") ]] + + +local getTargetsScore = function() + return scored * math.ceil(6000/#targets) +end + function TargetPracticeMission(params) if params.hogHat == nil then params.hogHat = "NoHat" end if params.hogName == nil then params.hogName = loc("Trainee") end @@ -151,6 +157,7 @@ _G.onGameStart = function() SendHealthStatsOff() ShowMission(params.missionTitle, loc("Aiming practice"), params.goalText, -params.ammoType, 5000) + SetTeamLabel(params.teamName, "0") spawnTarget() end @@ -205,6 +212,7 @@ _G.onGearDamage = function(gear, damage) if GetGearType(gear) == gtTarget then scored = scored + 1 + SetTeamLabel(params.teamName, tostring(getTargetsScore())) if scored < total_targets then AddCaption(string.format(loc("Targets left: %d"), (total_targets-scored)), 0xFFFFFFFF, capgrpMessage) spawnTarget() @@ -249,12 +257,13 @@ _G.generateStats = function() local accuracy = (scored/shots)*100 - local end_score_targets = scored * math.ceil(6000/#targets) + local end_score_targets = getTargetsScore() local end_score_overall if not game_lost then local end_score_time = math.ceil(time_goal/(params.time/6000)) local end_score_accuracy = math.ceil(accuracy * 60) end_score_overall = end_score_time + end_score_targets + end_score_accuracy + SetTeamLabel(params.teamName, tostring(end_score_overall)) SendStat(siGameResult, loc("You have finished the target practice!"))