share/hedgewars/Data/Maps/Knockball/map.lua
changeset 3240 e3b52d10b4c2
parent 3238 e99a43a2405b
child 3257 fff80d469185
equal deleted inserted replaced
3239:ac829895edfc 3240:e3b52d10b4c2
    46 
    46 
    47 local score = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0}
    47 local score = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0}
    48 
    48 
    49 local ball = nil
    49 local ball = nil
    50 
    50 
       
    51 local started = false
       
    52 
    51 function onGameInit()
    53 function onGameInit()
    52 	GameFlags = gfSolidLand + gfInvulnerable + gfDivideTeams
    54 	GameFlags = gfSolidLand + gfInvulnerable + gfDivideTeams
    53 	TurnTime = 20000
    55 	TurnTime = 20000
    54 	CaseFreq = 0
    56 	CaseFreq = 0
    55 	LandAdds = 0
    57 	LandAdds = 0
    57 	Delay = 500
    59 	Delay = 500
    58 	SuddenDeathTurns = 99999 -- "disable" sudden death
    60 	SuddenDeathTurns = 99999 -- "disable" sudden death
    59 end
    61 end
    60 
    62 
    61 function onGameStart()
    63 function onGameStart()
    62 	ShowMission(loc(caption), loc(subcaption), loc(goal), -amBaseballBat, 0);
    64 	ShowMission(loc(caption), loc(subcaption), loc(goal), -amBaseballBat, 0)
       
    65 	started = true
    63 end
    66 end
    64 
    67 
    65 function onGameTick()
    68 function onGameTick()
    66 	if ball ~= nil and GetFollowGear() ~= nil then FollowGear(ball) end
    69 	if ball ~= nil and GetFollowGear() ~= nil then FollowGear(ball) end
    67 end
    70 end
    82 		end
    85 		end
    83 	end
    86 	end
    84 end
    87 end
    85 
    88 
    86 function onGearDelete(gear)
    89 function onGearDelete(gear)
       
    90 	if not started then
       
    91 		return
    87 	if gear == ball then
    92 	if gear == ball then
    88 		ball = nil
    93 		ball = nil
    89 	elseif (GetGearType(gear) == gtHedgehog) and CurrentHedgehog ~= nil then
    94 	elseif (GetGearType(gear) == gtHedgehog) and CurrentHedgehog ~= nil then
    90 		local clan = GetHogClan(CurrentHedgehog)
    95 		local clan = GetHogClan(CurrentHedgehog)
    91 		local s
    96 		local s
    92 		if GetHogClan(CurrentHedgehog) ~= GetHogClan(gear) then
    97 		if clan ~= nil then
    93 			score[clan] = score[clan] + 1
    98 			if GetHogClan(CurrentHedgehog) ~= GetHogClan(gear) then
    94 			s = string.format(loc(scored), GetHogName(gear), clan + 1)
    99 				score[clan] = score[clan] + 1
    95 		else
   100 				s = string.format(loc(scored), GetHogName(gear), clan + 1)
    96 			score[clan] = score[clan] - 1
   101 			else
    97 			s = string.format(loc(failed), GetHogName(gear), clan + 1)
   102 				score[clan] = score[clan] - 1
       
   103 				s = string.format(loc(failed), GetHogName(gear), clan + 1)
       
   104 			end
       
   105 			s = s .. " " .. score[0]
       
   106 			for i = 1, ClansCount - 1 do s = s .. " - " .. score[i] end
       
   107 			ShowMission(loc(caption), loc(subcaption), s, -amBaseballBat, 0)
    98 		end
   108 		end
    99 		s = s .. " " .. score[0]
       
   100 		for i = 1, ClansCount - 1 do s = s .. " - " .. score[i] end
       
   101 		ShowMission(loc(caption), loc(subcaption), s, -amBaseballBat, 0)
       
   102 	end
   109 	end
   103 end
   110 end