share/hedgewars/Data/Maps/Control/map.lua
changeset 14983 89f6a1154f67
parent 14982 980a948a5dff
child 14984 6e17abf7b8ef
equal deleted inserted replaced
14982:980a948a5dff 14983:89f6a1154f67
   110 function ZonesAreEmpty()
   110 function ZonesAreEmpty()
   111 
   111 
   112 	okay = true
   112 	okay = true
   113 
   113 
   114 	for i = 0,(zCount-1) do
   114 	for i = 0,(zCount-1) do
   115 				
   115 
   116 		for k = 0, (numhhs-1) do
   116 		for k = 0, (numhhs-1) do
   117 			if (hhs[k] ~= nil) then
   117 			if (hhs[k] ~= nil) then
   118 			if (GearIsInZone(hhs[k],i)) == true then
   118 				if (GearIsInZone(hhs[k],i)) == true then
   119 				FindPlace(hhs[k], false, 0, LAND_WIDTH, true)
   119 					FindPlace(hhs[k], false, 0, LAND_WIDTH, true)
   120 				okay = false
   120 					okay = false
   121 			end
   121 				end
   122 			end
   122 			end
   123 		end
   123 		end
   124 	end
   124 	end
   125 
   125 
   126 	return(okay)
   126 	return(okay)
   132 	for i = 0,(zCount-1) do
   132 	for i = 0,(zCount-1) do
   133 		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], 0xffffffff)
   133 		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], 0xffffffff)
   134 		cOwnerClan[i] = nil
   134 		cOwnerClan[i] = nil
   135 		for k = 0, (numhhs-1) do
   135 		for k = 0, (numhhs-1) do
   136 			if (hhs[k] ~= nil) then
   136 			if (hhs[k] ~= nil) then
   137                 if (GearIsInZone(hhs[k],i)) == true then
   137 				if (GearIsInZone(hhs[k],i)) == true then
   138 
   138 					if cOwnerClan[i] ~= nil then
   139                     if cOwnerClan[i] ~= nil then
   139 						if cOwnerClan[i] ~= GetHogClan(hhs[k]) then
   140                         if cOwnerClan[i] ~= GetHogClan(hhs[k]) then 
   140 							--if the hog now being compared is different to one that is also here and was previously compared
   141                             --if the hog now being compared is different to one that is also here and was previously compared
   141 							SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], 0xffffffff)
   142                             
   142 
   143                             SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], 0xffffffff)						
   143 							cOwnerClan[i] = 10 -- this means conflicted
   144         
   144 						end
   145                             cOwnerClan[i] = 10 -- this means conflicted
   145 					elseif cOwnerClan[i] == nil then
   146                         end
   146 						cOwnerClan[i] = GetHogClan(hhs[k])
   147                     elseif cOwnerClan[i] == nil then
   147 						SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], GetClanColor( GetHogClan(hhs[k])))
   148                         cOwnerClan[i] = GetHogClan(hhs[k])
   148 					end
   149                         SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], GetClanColor( GetHogClan(hhs[k])))
   149 
   150         
   150 				end
   151                     end
   151 			end
   152 
   152 		end
   153                 end
       
   154 			end
       
   155 		end
       
   156 
       
   157 	end
   153 	end
   158 
   154 
   159 end
   155 end
   160 
   156 
   161 function AwardPoints()
   157 function AwardPoints()
   162 		
   158 
   163 	for i = 0,(zCount-1) do
   159 	for i = 0,(zCount-1) do
   164 		-- give score to all players controlling points		
   160 		-- give score to all players controlling points
   165 		
   161 
   166 		-- only give score to the player currently in control		
   162 		-- only give score to the player currently in control
   167 		if CurrentHedgehog ~= nil then		
   163 		if CurrentHedgehog ~= nil then
   168 			if cOwnerClan[i] == GetHogClan(CurrentHedgehog) then
   164 			if cOwnerClan[i] == GetHogClan(CurrentHedgehog) then
   169 				teamScore[cOwnerClan[i]] = teamScore[cOwnerClan[i]] + 1
   165 				teamScore[cOwnerClan[i]] = teamScore[cOwnerClan[i]] + 1
   170 			end
   166 			end
   171 		end
   167 		end
   172 	end
   168 	end
   173 
   169 
   174 	-- i want to show all the tags at once as having the SAME score not 1,2,3,4 so alas, repeating the loop seems needed	
   170 	-- i want to show all the tags at once as having the SAME score not 1,2,3,4 so alas, repeating the loop seems needed
   175 	for i = 0,(zCount-1) do			
   171 	for i = 0,(zCount-1) do
   176 		if CurrentHedgehog ~= nil then		
   172 		if CurrentHedgehog ~= nil then
   177 			if cOwnerClan[i] == GetHogClan(CurrentHedgehog) then
   173 			if cOwnerClan[i] == GetHogClan(CurrentHedgehog) then
   178 				local g = AddVisualGear(vCircX[i], vCircY[i]-100, vgtHealthTag, 100, false)
   174 				local g = AddVisualGear(vCircX[i], vCircY[i]-100, vgtHealthTag, 100, false)
   179 				SetVisualGearValues(g, vCircX[i], vCircY[i]-100, 0, 0, 0, 0, 0, teamScore[cOwnerClan[i]], 1500, GetClanColor(cOwnerClan[i]))
   175 				SetVisualGearValues(g, vCircX[i], vCircY[i]-100, 0, 0, 0, 0, 0, teamScore[cOwnerClan[i]], 1500, GetClanColor(cOwnerClan[i]))
   180 			end
   176 			end
   181 		end
   177 		end
   237 	-- find out how many hogs per team, and the index of the first hog in hhs
   233 	-- find out how many hogs per team, and the index of the first hog in hhs
   238 	for i = 0, (numTeams-1) do
   234 	for i = 0, (numTeams-1) do
   239 		SetTeamLabel(GetTeamName(i), "0")
   235 		SetTeamLabel(GetTeamName(i), "0")
   240 		for z = 0, (numhhs-1) do
   236 		for z = 0, (numhhs-1) do
   241 			if GetHogTeamName(hhs[z]) == teamNameArr[i] then
   237 			if GetHogTeamName(hhs[z]) == teamNameArr[i] then
   242 				teamClan[i] = GetHogClan(hhs[z])				
   238 				teamClan[i] = GetHogClan(hhs[z])
   243 				if teamSize[i] == 0 then
   239 				if teamSize[i] == 0 then
   244 					teamIndex[i] = z -- should give starting index
   240 					teamIndex[i] = z -- should give starting index
   245 				end
   241 				end
   246 				teamSize[i] = teamSize[i] + 1
   242 				teamSize[i] = teamSize[i] + 1
   247 				--add a pointer so this hog appears at i in hhs
   243 				--add a pointer so this hog appears at i in hhs
   258 
   254 
   259 function onAttack()
   255 function onAttack()
   260 
   256 
   261 	if CurrentHedgehog ~= nil then
   257 	if CurrentHedgehog ~= nil then
   262 		if GetCurAmmoType() == amSkip then
   258 		if GetCurAmmoType() == amSkip then
   263 			z = (TurnTimeLeft / 2000) - (TurnTimeLeft / 2000)%2 
   259 			z = (TurnTimeLeft / 2000) - (TurnTimeLeft / 2000)%2
   264 			for i = 0, z do
   260 			for i = 0, z do
   265 				AwardPoints()
   261 				AwardPoints()
   266 			end
   262 			end
   267 		end
   263 		end
   268 	end
   264 	end
   270 end
   266 end
   271 
   267 
   272 function onGameInit()
   268 function onGameInit()
   273 
   269 
   274 	-- Things we don't modify here will use their default values.
   270 	-- Things we don't modify here will use their default values.
   275 	
   271 
   276 	EnableGameFlags(gfInfAttack, gfSolidLand)
   272 	EnableGameFlags(gfInfAttack, gfSolidLand)
   277 	DisableGameFlags(gfKing, gfAISurvival)
   273 	DisableGameFlags(gfKing, gfAISurvival)
   278 	WaterRise = 0
   274 	WaterRise = 0
   279 	HealthDecrease = 0
   275 	HealthDecrease = 0
   280 
   276 
   295 	vCircX[1], vCircY[1] = 1088, 684
   291 	vCircX[1], vCircY[1] = 1088, 684
   296 	vCircX[2], vCircY[2] = 381, 1569
   292 	vCircX[2], vCircY[2] = 381, 1569
   297 	vCircX[3], vCircY[3] = 1942, 77
   293 	vCircX[3], vCircY[3] = 1942, 77
   298 	vCircX[4], vCircY[4] = 3883, 89
   294 	vCircX[4], vCircY[4] = 3883, 89
   299 	vCircX[5], vCircY[5] = 2739, 1378
   295 	vCircX[5], vCircY[5] = 2739, 1378
   300 	
   296 
   301 	for i = 0, 5 do	
   297 	for i = 0, 5 do
   302 		vCirc[i] = AddVisualGear(0,0,vgtCircle,0,true)
   298 		vCirc[i] = AddVisualGear(0,0,vgtCircle,0,true)
   303 		vCircMinA[i] = 20
   299 		vCircMinA[i] = 20
   304 		vCircMaxA[i] = 255
   300 		vCircMaxA[i] = 255
   305 		vCircType[i] = 1
   301 		vCircType[i] = 1
   306 		vCircPulse[i] = 10
   302 		vCircPulse[i] = 10
   319 		pointLimit = pointLimit - 25
   315 		pointLimit = pointLimit - 25
   320 	end
   316 	end
   321 
   317 
   322 	missionHelp = loc("Control pillars to score points.") .. "|" ..
   318 	missionHelp = loc("Control pillars to score points.") .. "|" ..
   323 		string.format(loc("Score goal: %d"), pointLimit)
   319 		string.format(loc("Score goal: %d"), pointLimit)
   324 	
   320 
   325 	-- reposition hogs if they are on control points until they are not or sanity limit kicks in
   321 	-- reposition hogs if they are on control points until they are not or sanity limit kicks in
   326 	reN = 0
   322 	reN = 0
   327 	while (reN < 10) do
   323 	while (reN < 10) do
   328 		if ZonesAreEmpty() == false then
   324 		if ZonesAreEmpty() == false then
   329 			reN = reN + 1	
   325 			reN = reN + 1
   330 		else
   326 		else
   331 			reN = 15		
   327 			reN = 15
   332 		end
   328 		end
   333 	end
   329 	end
   334 
   330 
   335 	for h=1, numhhs do
   331 	for h=1, numhhs do
   336 		-- Tardis screws up the game too much, teams might not get killed correctly after victory
   332 		-- Tardis screws up the game too much, teams might not get killed correctly after victory
   346 end
   342 end
   347 
   343 
   348 
   344 
   349 function onNewTurn()
   345 function onNewTurn()
   350 
   346 
   351 	-- reset the time counter so that it will get set to TurnTimeLeft in onGameTick	
   347 	-- reset the time counter so that it will get set to TurnTimeLeft in onGameTick
   352 	TimeCounter = 0
   348 	TimeCounter = 0
   353 		
   349 
   354 	if lastTeam ~= GetHogTeamName(CurrentHedgehog) then
   350 	if lastTeam ~= GetHogTeamName(CurrentHedgehog) then
   355 		lastTeam = GetHogTeamName(CurrentHedgehog)
   351 		lastTeam = GetHogTeamName(CurrentHedgehog)
   356 	end
   352 	end
   357 
   353 
   358 	if gameWon == false then
   354 	if gameWon == false then
   359 	
   355 
   360 		for i = 0, (numTeams-1) do
   356 		for i = 0, (numTeams-1) do
   361 			if teamScore[i] >= pointLimit then --150
   357 			if teamScore[i] >= pointLimit then --150
   362 				gameWon = true
   358 				gameWon = true
   363 				winnerClan = i			
   359 				winnerClan = i
   364 			end
   360 			end
   365 		end
   361 		end
   366 
   362 
   367 		if gameWon == true then
   363 		if gameWon == true then
   368 			for i = 0, (numhhs-1) do
   364 			for i = 0, (numhhs-1) do
   369 				if hhs[i] ~= nil then				
   365 				if hhs[i] ~= nil then
   370 					if GetHogClan(hhs[i]) ~= winnerClan then
   366 					if GetHogClan(hhs[i]) ~= winnerClan then
   371 						SetEffect(hhs[i], heResurrectable, 0)
   367 						SetEffect(hhs[i], heResurrectable, 0)
   372 						SetHealth(hhs[i],0)
   368 						SetHealth(hhs[i],0)
   373 					end
   369 					end
   374 				end			
   370 				end
   375 			end
   371 			end
   376 			SetTurnTimeLeft(1)
   372 			SetTurnTimeLeft(1)
   377 		end
   373 		end
   378 
   374 
   379 	end
   375 	end
   384 
   380 
   385 	vCircCount = vCircCount + 1
   381 	vCircCount = vCircCount + 1
   386 	if (vCircCount >= 500) and (gameWon == false) then
   382 	if (vCircCount >= 500) and (gameWon == false) then
   387 		vCircCount = 0
   383 		vCircCount = 0
   388 		CheckZones()
   384 		CheckZones()
   389 	end	
   385 	end
   390 
   386 
   391 	-- set TimeCounter to starting time if it is uninitialised (from onNewTurn)	
   387 	-- set TimeCounter to starting time if it is uninitialised (from onNewTurn)
   392 	if (TimeCounter == 0) and (TurnTimeLeft > 0) then
   388 	if (TimeCounter == 0) and (TurnTimeLeft > 0) then
   393 		TimeCounter = TurnTimeLeft	
   389 		TimeCounter = TurnTimeLeft
   394 	end	
   390 	end
   395 	
   391 
   396 	-- has it ACTUALLY been 2 seconds since we last did this?	
   392 	-- has it ACTUALLY been 2 seconds since we last did this?
   397 	if (TimeCounter - TurnTimeLeft) >= 2000 then
   393 	if (TimeCounter - TurnTimeLeft) >= 2000 then
   398 		TimeCounter = TurnTimeLeft
   394 		TimeCounter = TurnTimeLeft
   399 		
   395 
   400 		if (gameWon == false) then
   396 		if (gameWon == false) then
   401 			AwardPoints()		
   397 			AwardPoints()
   402 		end	
   398 		end
   403 	end	
   399 	end
   404 	
   400 
   405 end
   401 end
   406 
   402 
   407 function InABetterPlaceNow(gear)
   403 function InABetterPlaceNow(gear)
   408 	for i = 0, (numhhs-1) do
   404 	for i = 0, (numhhs-1) do
   409 		if gear == hhs[i] then
   405 		if gear == hhs[i] then