share/hedgewars/Data/Maps/Control/map.lua
changeset 5842 30e374a27269
parent 5806 6778f0a7d896
child 7838 5c2337f8dbb2
equal deleted inserted replaced
5841:ef0a76e154cb 5842:30e374a27269
     1 --------------------------------
     1 --------------------------------
     2 -- CONTROL 0.5
     2 -- CONTROL 0.6
     3 --------------------------------
     3 --------------------------------
     4 
     4 
     5 ---------
     5 ---------
     6 -- 0.2
     6 -- 0.2
     7 ---------
     7 ---------
    33 --------
    33 --------
    34 
    34 
    35 -- removed user branding
    35 -- removed user branding
    36 -- fixed infinite attack time exploit
    36 -- fixed infinite attack time exploit
    37 
    37 
       
    38 --------
       
    39 -- 0.6
       
    40 --------
       
    41 
       
    42 -- timebox fix
       
    43 -- support for more players
       
    44 -- remove version numbers
       
    45 -- enable limited sudden death
       
    46 -- using skip go generates as many points as you would have gotten had you sat and waited
       
    47 
    38 -----------------
    48 -----------------
    39 --script begins
    49 --script begins
    40 -----------------
    50 -----------------
    41 
    51 
    42 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
    52 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
    86 
    96 
    87 --------------------------------
    97 --------------------------------
    88 --zone and teleporter variables
    98 --zone and teleporter variables
    89 --------------------------------
    99 --------------------------------
    90 
   100 
    91 --local redTel
       
    92 --local orangeTel
       
    93 --local areaArr = {} -- no longer used
       
    94 
       
    95 local cPoint = {}
   101 local cPoint = {}
    96 local cOwnerClan = {}
   102 local cOwnerClan = {}
    97 
   103 
    98 local zXMin = {}
   104 local zXMin = {}
    99 local zWidth = {}
   105 local zWidth = {}
   157 
   163 
   158 	for i = 0,(zCount-1) do
   164 	for i = 0,(zCount-1) do
   159 		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], 0xffffffff)
   165 		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], 0xffffffff)
   160 		cOwnerClan[i] = nil
   166 		cOwnerClan[i] = nil
   161 		for k = 0, (numhhs-1) do
   167 		for k = 0, (numhhs-1) do
   162 			if (hhs[k] ~= nil) and (GetGearType(hhs[k]) ~= nil) then
   168 			if (hhs[k] ~= nil) then --and (GetGearType(hhs[k]) ~= nil) then
   163                 if (GearIsInZone(hhs[k],i)) == true then
   169                 if (GearIsInZone(hhs[k],i)) == true then
   164 
   170 
   165                     if cOwnerClan[i] ~= nil then
   171                     if cOwnerClan[i] ~= nil then
   166                         if cOwnerClan[i] ~= GetHogClan(hhs[k]) then 
   172                         if cOwnerClan[i] ~= GetHogClan(hhs[k]) then 
   167                             --if the hog now being compared is different to one that is also here and was previously compared
   173                             --if the hog now being compared is different to one that is also here and was previously compared
   177                         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])))
   183                         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])))
   178         
   184         
   179                     end
   185                     end
   180 
   186 
   181                 end
   187                 end
   182             else hhs[k] = nil
   188            -- else hhs[k] = nil
   183 			end
   189 			end
   184 		end
   190 		end
   185 
   191 
   186 	end
   192 	end
   187 
   193 
   205 
   211 
   206 	-- 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	
   212 	-- 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	
   207 	for i = 0,(zCount-1) do			
   213 	for i = 0,(zCount-1) do			
   208 		if CurrentHedgehog ~= nil then		
   214 		if CurrentHedgehog ~= nil then		
   209 			if cOwnerClan[i] == GetHogClan(CurrentHedgehog) then
   215 			if cOwnerClan[i] == GetHogClan(CurrentHedgehog) then
   210 				g = AddVisualGear(vCircX[i], vCircY[i], vgtHealthTag, 100, False)
   216 				g = AddVisualGear(vCircX[i], vCircY[i]-100, vgtHealthTag, 100, False)
   211                 if g ~= 0 then
   217                 if g ~= 0 then
   212 				    SetVisualGearValues(g, vCircX[i], vCircY[i], 0, 0, 0, 0, 0, teamScore[cOwnerClan[i]], 1500, GetClanColor(cOwnerClan[i]))
   218 				    SetVisualGearValues(g, vCircX[i], vCircY[i]-100, 0, 0, 0, 0, 0, teamScore[cOwnerClan[i]], 1500, GetClanColor(cOwnerClan[i]))
   213                 end
   219                 end
   214 			end
   220 			end
   215 		end
   221 		end
   216 	end
   222 	end
   217 
   223 
   223 
   229 
   224 function RebuildTeamInfo()
   230 function RebuildTeamInfo()
   225 
   231 
   226 
   232 
   227 	-- make a list of individual team names
   233 	-- make a list of individual team names
   228 	for i = 0, 5 do
   234 	for i = 0, (TeamsCount-1) do
   229 		teamNameArr[i] = " " -- = i
   235 		teamNameArr[i] = " " -- = i
   230 		teamSize[i] = 0
   236 		teamSize[i] = 0
   231 		teamIndex[i] = 0
   237 		teamIndex[i] = 0
   232 		teamScore[i] = 0
   238 		teamScore[i] = 0
   233 	end
   239 	end
   280 
   286 
   281 ------------------------
   287 ------------------------
   282 -- game methods
   288 -- game methods
   283 ------------------------
   289 ------------------------
   284 
   290 
       
   291 function onAttack()
       
   292 
       
   293 	if CurrentHedgehog ~= nil then
       
   294 		if GetCurAmmoType() == amSkip then
       
   295 			z = (TurnTimeLeft / 2000) - (TurnTimeLeft / 2000)%2 
       
   296 			--AddCaption("scored: " .. z,GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
       
   297 			for i = 0, z do
       
   298 				AwardPoints()
       
   299 			end
       
   300 		end
       
   301 	end
       
   302 
       
   303 end
       
   304 
   285 function onGameInit()
   305 function onGameInit()
   286 
   306 
   287 	-- Things we don't modify here will use their default values.
   307 	-- Things we don't modify here will use their default values.
   288 	--GameFlags = gfInfAttack + gfSolidLand -- Game settings and rules
   308 	--GameFlags = gfInfAttack + gfSolidLand -- Game settings and rules
   289 	
   309 	
   290 	GameFlags = band(bor(GameFlags, gfInfAttack + gfSolidLand), bnot(gfKing + gfForts))
   310 	GameFlags = band(bor(GameFlags, gfInfAttack + gfSolidLand), bnot(gfKing + gfForts))
   291 		
   311 	WaterRise = 0
   292 	SuddenDeathTurns = 99 -- suddendeath is off, effectively
       
   293 
   312 
   294 end
   313 end
   295 
   314 
   296 
   315 
   297 function onGameStart()
   316 function onGameStart()
   333 	RebuildTeamInfo()
   352 	RebuildTeamInfo()
   334 
   353 
   335 	for i = 0, (numTeams-1) do
   354 	for i = 0, (numTeams-1) do
   336 		pointLimit = pointLimit - 25
   355 		pointLimit = pointLimit - 25
   337 	end
   356 	end
   338 	--SetGearPosition(hhs[0], 631, 82)
   357 	
   339 	--SetGearPosition(hhs[1], 1088, 684)
       
   340 	--SetGearPosition(hhs[2], 381, 1569)
       
   341 
       
   342 	-- reposition hogs if they are on control points until they are not or sanity limit kicks in
   358 	-- reposition hogs if they are on control points until they are not or sanity limit kicks in
   343 	reN = 0
   359 	reN = 0
   344 	--zz = 0
   360 	--zz = 0
   345 	while (reN < 10) do
   361 	while (reN < 10) do
   346 		if ZonesAreEmpty() == false then
   362 		if ZonesAreEmpty() == false then
   351 			reN = 15		
   367 			reN = 15		
   352 		end
   368 		end
   353 		--AddCaption(zz) -- number of times it took to work
   369 		--AddCaption(zz) -- number of times it took to work
   354 	end
   370 	end
   355 
   371 
   356 	ShowMission("CONTROL v0.3", "", loc("Control pillars to score points.") .. "|" .. loc("Goal") .. ": " .. pointLimit .. " " .. loc("points"), 0, 0)
   372 	ShowMission("CONTROL", 
       
   373 	"", 
       
   374 	loc("Control pillars to score points.") .. "|" .. 
       
   375 	loc("Goal") .. ": " .. pointLimit .. " " .. loc("points"), 0, 0)
   357 
   376 
   358 
   377 
   359 end
   378 end
   360 
   379 
   361 
   380 
   387 				end			
   406 				end			
   388 			end
   407 			end
   389 			TurnTimeLeft = 1
   408 			TurnTimeLeft = 1
   390 		end
   409 		end
   391 
   410 
   392 		for i = 0,5 do
   411 		totalComment = ""		
       
   412 		for i = 0,(TeamsCount-1) do
   393 				if teamNameArr[i] ~= " " then				-- i
   413 				if teamNameArr[i] ~= " " then				-- i
   394 					teamComment[i] = teamNameArr[i] .. ": " .. teamScore[teamClan[i]] .. " " .. loc("points") .. "|"
   414 					teamComment[i] = teamNameArr[i] .. ": " .. teamScore[teamClan[i]] .. " " .. loc("points") .. "|"
       
   415 					totalComment = totalComment .. teamComment[i]			
   395 				elseif teamNameArr[i] == " " then
   416 				elseif teamNameArr[i] == " " then
   396 					teamComment[i] = "|"
   417 					teamComment[i] = "|"
   397 				end
   418 				end
   398 			end
   419 			end
   399 			ShowMission("CONTROL", loc("Team Scores") .. ":", teamComment[0] .. teamComment[1] .. teamComment[2] .. teamComment[3] .. teamComment[4] .. teamComment[5], 0, 1600)
   420 			
       
   421 			ShowMission("CONTROL", 
       
   422 			loc("Team Scores") .. ":", 
       
   423 			totalComment, 0, 1600)
   400 	
   424 	
   401 	end
   425 	end
   402 
   426 
   403 end
   427 end
   404 
   428 
   406 
   430 
   407 	vCircCount = vCircCount + 1
   431 	vCircCount = vCircCount + 1
   408 	if (vCircCount >= 500) and (gameWon == false) then
   432 	if (vCircCount >= 500) and (gameWon == false) then
   409 		vCircCount = 0
   433 		vCircCount = 0
   410 		CheckZones()
   434 		CheckZones()
   411 		--AwardPoints()
       
   412 
       
   413 
       
   414 		--[[for i = 0,5 do
       
   415 
       
   416 			if teamNameArr[i] ~= " " then				-- i
       
   417 				teamComment[i] = teamNameArr[i] .. ": " .. teamScore[teamClan[i] ] .. " points|"
       
   418 			elseif teamNameArr[i] == " " then
       
   419 				teamComment[i] = "|"
       
   420 			end
       
   421 		end
       
   422 		
       
   423 		ShowMission("CONTROL", "Team Scores:", teamComment[0] .. teamComment[1] .. teamComment[2] .. teamComment[3] .. teamComment[4] .. teamComment[5], 0, 1600)]]
       
   424 
       
   425 	end	
   435 	end	
   426 
   436 
   427 	-- things we wanna check often
   437 	-- things we wanna check often
   428 	if (CurrentHedgehog ~= nil) then
   438 	if (CurrentHedgehog ~= nil) then
   429 	--	AddCaption(GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog))
   439 	--	AddCaption(GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog))
   459 
   469 
   460 function onGearResurrect(gear)
   470 function onGearResurrect(gear)
   461 	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   471 	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   462 end
   472 end
   463 
   473 
       
   474 function InABetterPlaceNow(gear)
       
   475 	for i = 0, (numhhs-1) do
       
   476 		if gear == hhs[i] then
       
   477 			hhs[i] = nil
       
   478 		end
       
   479 	end
       
   480 end
       
   481 
       
   482 function onHogHide(gear)
       
   483 	 InABetterPlaceNow(gear)
       
   484 end
       
   485 
       
   486 function onHogRestore(gear)
       
   487 	match = false
       
   488 	for i = 0, (numhhs-1) do
       
   489 		if (hhs[i] == nil) and (match == false) then
       
   490 			hhs[i] = gear
       
   491 			--AddCaption(GetHogName(gear) .. " has reappeared it seems!")
       
   492 			--FollowGear(gear)
       
   493 			match = true
       
   494 		end
       
   495 	end
       
   496 end
       
   497 
   464 
   498 
   465 function onGearAdd(gear)
   499 function onGearAdd(gear)
   466 
   500 
   467 	if GetGearType(gear) == gtHedgehog then
   501 	if GetGearType(gear) == gtHedgehog then
   468 
       
   469 		hhs[numhhs] = gear
   502 		hhs[numhhs] = gear
   470 		numhhs = numhhs + 1
   503 		numhhs = numhhs + 1
   471 		SetEffect(gear, heResurrectable, true)
   504 		SetEffect(gear, heResurrectable, true)
   472 
       
   473 	end
   505 	end
   474 
   506 
   475 end
   507 end
   476 
   508 
   477 function onGearDelete(gear)
   509 function onGearDelete(gear)
   478 
   510 
   479 	if GetGearType(gear) == gtHedgehog then
   511 	if GetGearType(gear) == gtHedgehog then
   480 	--AddCaption("gear deleted!")
   512 		InABetterPlaceNow(gear)
   481 		for i = 0, (numhhs-1) do
   513 	end
   482 			if gear == hhs[i] then
   514 
   483 				hhs[i] = nil
   515 end
   484 				--AddCaption("for real")	
       
   485 			end		
       
   486 		end
       
   487 	end
       
   488 
       
   489 end