PianoStrike exploit fix for Capture The Flag.
authormikade
Tue, 21 Jun 2011 20:49:47 +0200
changeset 5277 09beef0752ab
parent 5276 562070d3f978
child 5278 1aadb3312828
PianoStrike exploit fix for Capture The Flag. New Gameplay Mode: The Specialists
hedgewars/uScript.pas
share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
--- a/hedgewars/uScript.pas	Tue Jun 21 22:43:55 2011 +0400
+++ b/hedgewars/uScript.pas	Tue Jun 21 20:49:47 2011 +0200
@@ -851,6 +851,31 @@
     lc_switchhog:= 0
 end;
 
+{function lc_addammo(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+
+    if lua_gettop(L) = 3 then
+    begin
+	gear:= GearByUID(lua_tointeger(L, 1));
+        if (gear <> nil) and (gear^.Hedgehog <> nil) then
+            AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) );
+    end else
+    
+    if lua_gettop(L) = 2 then
+    begin
+	gear:= GearByUID(lua_tointeger(L, 1));
+        if (gear <> nil) and (gear^.Hedgehog <> nil) then
+            AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)));
+    end else
+    begin
+    	LuaError('Lua: Wrong number of parameters passed to AddAmmo!');
+    end;
+
+    lc_addammo:= 0;
+
+end;}
+
 function lc_addammo(L : Plua_State) : LongInt; Cdecl;
 var gear : PGear;
 begin
--- a/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua	Tue Jun 21 22:43:55 2011 +0400
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua	Tue Jun 21 20:49:47 2011 +0200
@@ -1,7 +1,7 @@
---------------------------------
--- CAPTURE_THE_FLAG_CUSTOM 0.3
+---------------------------------------
+-- CAPTURE_THE_FLAG GAMEPLAY MODE 0.4
 -- by mikade
---------------------------------
+---------------------------------------
 
 -- Version History
 ---------
@@ -50,6 +50,17 @@
 -- added a check to make sure the player doesn't kamikaze straight down and make the flag's starting point underwater
 -- added a check to make sure the player drops the flag if he has it and he uses kamikaze
 
+--------
+-- 0.4
+--------
+
+-- remove user-branding and version numbers
+-- removed some stuff that wasn't needed
+-- fix piano strike exploit
+-- changed delay to allow for better portals
+-- changed starting feedback a little
+-- increased the radius around the circle indicating the flag thief so that it doesn't obscure his health
+
 -----------------
 --SCRIPT BEGINS
 -----------------
@@ -188,10 +199,6 @@
 		end
 		AddCaption(loc("Flag captured!"))
 
-	--below line doesnt usually get called
-	--else 
-		-- now gets called if you go over your own flag, presumably		
-		--AddCaption("Hmm... that wasn't supposed to happen...")
 	end
 	
 end
@@ -227,7 +234,7 @@
 			fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
 			fGearX[i] = fSpawnX[i]
 			fGearY[i] = fSpawnY[i]			
-			--fGear[i] = SpawnAmmoCrate(fSpawnX[i],fSpawnY[i],amSkip)
+
 			fNeedsRespawn[i] = false
 			fIsMissing[i] = false -- new, this should solve problems of a respawned flag being "returned" when a player tries to score
 			AddCaption(loc("Flag respawned!"))
@@ -255,12 +262,10 @@
 			fIsMissing[wtf] = true
 			fNeedsRespawn[wtf] = true
 			HandleRespawns()
-			--AddCaption("hah??")
 		else	--normally	
 			fGearX[wtf]  =  fThiefX[wtf]
 			fGearY[wtf]  =  fThiefY[wtf]	
 			fGear[wtf] = AddVisualGear(fGearX[wtf],fGearY[wtf],vgtCircle,0,true)		
-			--fGear[wtf] = AddVisualGear(fThiefX[wtf],fThiefY[wtf],vgtCircle,0,true)
 		end
 
 		AddVisualGear(fThiefX[wtf], fThiefY[wtf], vgtBigExplosion, 0, false)
@@ -290,8 +295,8 @@
 				SetVisualGearValues(fGear[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
 			end
 		elseif (fIsMissing[i] == true) and (fNeedsRespawn[i] == false) then
-			if fThief[i] ~= nil then -- draw circle round flag carrier
-				SetVisualGearValues(fCirc[i], fThiefX[i], fThiefY[i], 20, 200, 0, 0, 100, 33, 3, fCol[i])
+			if fThief[i] ~= nil then -- draw circle round flag carrier			-- 33
+				SetVisualGearValues(fCirc[i], fThiefX[i], fThiefY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i])
 				--AddCaption("circle marking carrier")
 			elseif fThief[i] == nil then -- draw cirle round dropped flag
 				--g1X,g1Y,g4,g5,g6,g7,g8,g9,g10,g11 =  GetVisualGearValues(fGear[i])				
@@ -419,8 +424,6 @@
 		--SetVisualGearValues(zxc, 1000,1000, 20, 100, 0,    10,                     1,         100,        5,      GetClanColor(0))		
 		
 		SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 100, 0, 10, 0, 75, 5, fCol[i])
-		--SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 20, 0, 10, 0, 33, 3, fCol[i])
-
 				
 	end
 
@@ -432,12 +435,9 @@
 
 function onGameInit()
 
-	-- Things we don't modify here will use their default values.
-	
 	GameFlags = band(bor(GameFlags, gfDivideTeams), bnot(gfKing + gfForts))
-	SuddenDeathTurns = 99 -- suddendeath is off, effectively
-	--TurnTime = 30000 -- (was 30) The time the player has to move each round (in ms)
-	--Delay = 10 -- The delay between each round
+	SuddenDeathTurns = 999 -- suddendeath is off, effectively
+	Delay = 10 
 
 end
 
@@ -445,7 +445,7 @@
 function onGameStart()
 
 	--ShowMission(loc(caption), loc(subcaption), loc(goal), 0, 0)
-	ShowMission(loc("CAPTURE THE FLAG"), loc("by mikade"), loc("CUSTOM BUILD 0.2"), 0, 0)
+	ShowMission(loc("CAPTURE THE FLAG"), loc("Flags, and their home base will be placed where each team ends their first turn."), "", 0, 0)
 
 	RebuildTeamInfo()
 	
@@ -484,7 +484,7 @@
 		HandleRespawns()
 	--new method of placing starting flags	
 	elseif gameTurns == 1 then
-		ShowMission(loc("CAPTURE THE FLAG"), loc("Flags will be placed where each team ends their turn."), "", 0, 0)
+		ShowMission(loc("CAPTURE THE FLAG"), loc("Flags, and their home base will be placed where each team ends their first turn."), "", 0, 0)
 	elseif gameTurns == 2 then
 		fPlaced[0] = true
 		ShowMission(loc("CAPTURE THE FLAG"), loc("RULES OF THE GAME [Press ESC to view]"), loc(" - Return the enemy flag to your base to score | - First team to 3 captures wins | - You may only score when your flag is in your base | - Hogs will drop the flag if killed, or drowned | - Dropped flags may be returned or recaptured | - Hogs respawn when killed"), 0, 0)
@@ -562,16 +562,21 @@
 
 end
 
-function onGearDamage(gear, damage)
---
-end
-
 function onGearAdd(gear)
 
 	if GetGearType(gear) == gtHedgehog then
 		hhs[numhhs] = gear
 		numhhs = numhhs + 1
 		SetEffect(gear, heResurrectable, true)
+	
+	elseif GetGearType(gear) == gtPiano then
+
+		for i = 0, 1 do
+			if CurrentHedgehog == fThief[i] then
+				FlagThiefDead(gear)			
+			end
+		end
+
 	end
 
 end
@@ -579,7 +584,6 @@
 function onGearDelete(gear)
 
 	if GetGearType(gear) == gtHedgehog then
-	--AddCaption("gear deleted!")
 		for i = 0, (numhhs-1) do
 			if gear == hhs[i] then
 				
@@ -588,8 +592,7 @@
 						FlagThiefDead(gear)
 					end
 				end				
-				hhs[i] = nil
-				--AddCaption("for real")	
+				hhs[i] = nil	
 			end		
 		end
 	end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua	Tue Jun 21 20:49:47 2011 +0200
@@ -0,0 +1,256 @@
+----------------------------------
+-- THE SPECIALISTS MODE 0.2
+-- by mikade
+----------------------------------
+
+-- version history
+-----------------
+-- version 0.1
+-----------------
+-- concept test
+
+----------------
+-- version 0.2
+----------------
+-- added gfRandomOrder to gameflags
+-- removed some deprecated variables/methods
+-- fixed lack of portal reset
+
+--------------------
+--TO DO
+--------------------
+
+-- add proper gameflag checking, maybe
+-- set crate drops etc.
+-- assuming place hog mode + gfinfattack doesn't get the fix: somehow end turn after teleport
+
+loadfile(GetDataPath() .. "Scripts/Locale.lua")()
+
+local numhhs = 0 
+local hhs = {} 
+
+local currName 
+local lastName
+
+function CreateTeam()
+
+	currTeam = ""
+	lastTeam = ""
+	z = 0
+
+	for i = 0, (numhhs-1) do
+
+		currTeam = GetHogTeamName(hhs[i])
+
+		if currTeam == lastTeam then
+			z = z + 1
+		else
+			z = 1		
+		end
+
+		if z == 1 then
+
+			SetHogName(hhs[i],"Soldier")
+			SetHogHat(hhs[i], "Vega")
+			SetHealth(hhs[i],200)
+
+		elseif z == 2 then
+
+			SetHogHat(hhs[i], "Glasses")
+			SetHogName(hhs[i],"Engineer")
+
+		elseif z == 3 then
+
+			SetHogName(hhs[i],"Ninja")			
+			SetHogHat(hhs[i], "NinjaFull")
+			SetHealth(hhs[i],80)
+
+		elseif z == 4 then
+
+			SetHogName(hhs[i],"Demo")			
+			SetHogHat(hhs[i], "Skull")
+			SetHealth(hhs[i],200)
+
+		elseif z == 5 then
+
+			SetHogName(hhs[i],"Sniper")			
+			SetHogHat(hhs[i], "Sniper")
+			SetHealth(hhs[i],120)
+
+		elseif z == 6 then
+
+			SetHogName(hhs[i],"Saint")			
+			SetHogHat(hhs[i], "angel")
+			SetHealth(hhs[i],300)
+
+		elseif z == 7 then
+
+			SetHogName(hhs[i],"Pyro")			
+			SetHogHat(hhs[i], "Gasmask")
+			SetHealth(hhs[i],150)
+		
+		elseif z == 8 then
+		
+			SetHogName(hhs[i],"Loon")			
+			SetHogHat(hhs[i], "clown")
+			SetHealth(hhs[i],100)
+
+		end
+
+		lastTeam = GetHogTeamName(hhs[i])
+
+	end	
+
+end
+
+function ResetAllAmmo()
+
+	AddAmmo(CurrentHedgehog, amBazooka, 0)
+	AddAmmo(CurrentHedgehog, amGrenade, 0)
+	AddAmmo(CurrentHedgehog, amShotgun, 0)
+	
+	AddAmmo(CurrentHedgehog, amGirder, 0)
+	AddAmmo(CurrentHedgehog, amBlowTorch, 0)
+	AddAmmo(CurrentHedgehog, amPickHammer, 0)
+	AddAmmo(CurrentHedgehog, amSwitch, 0)
+
+	AddAmmo(CurrentHedgehog, amRope, 0)
+	AddAmmo(CurrentHedgehog, amParachute, 0)
+	AddAmmo(CurrentHedgehog, amFirePunch, 0)
+
+	AddAmmo(CurrentHedgehog, amDynamite, 0)
+	AddAmmo(CurrentHedgehog, amDrill, 0)
+	AddAmmo(CurrentHedgehog, amMine, 0)
+
+	AddAmmo(CurrentHedgehog, amSniperRifle, 0)
+	AddAmmo(CurrentHedgehog, amDEagle, 0)
+	AddAmmo(CurrentHedgehog, amPortalGun, 0)
+
+	AddAmmo(CurrentHedgehog, amSeduction, 0)
+	AddAmmo(CurrentHedgehog, amResurrector, 0)
+	AddAmmo(CurrentHedgehog, amInvulnerable, 0)
+	
+	AddAmmo(CurrentHedgehog, amFlamethrower, 0)
+	AddAmmo(CurrentHedgehog, amMolotov, 0)
+	AddAmmo(CurrentHedgehog, amNapalm, 0)
+	
+	AddAmmo(CurrentHedgehog, amBaseballBat, 0)
+	AddAmmo(CurrentHedgehog, amGasBomb, 0)
+	AddAmmo(CurrentHedgehog, amKamikaze, 0)
+
+end
+
+function AssignAmmo()
+
+	ResetAllAmmo()	
+	n = GetHogName(CurrentHedgehog)
+
+	AddAmmo(CurrentHedgehog, amSkip,100)
+
+	if n == "Soldier" then 
+		AddAmmo(CurrentHedgehog, amBazooka,1)
+		AddAmmo(CurrentHedgehog, amGrenade,1)
+		AddAmmo(CurrentHedgehog, amShotgun,1)
+	elseif n == "Engineer" then
+		AddAmmo(CurrentHedgehog, amGirder, 2)
+		AddAmmo(CurrentHedgehog, amBlowTorch, 1)
+		AddAmmo(CurrentHedgehog, amPickHammer, 1)	
+		AddAmmo(CurrentHedgehog, amSwitch, 2)	
+	elseif n == "Ninja" then
+		AddAmmo(CurrentHedgehog, amRope, 100)
+		AddAmmo(CurrentHedgehog, amParachute, 100)
+		AddAmmo(CurrentHedgehog, amFirePunch, 1)
+	elseif n == "Demo" then
+		AddAmmo(CurrentHedgehog, amDynamite, 1)
+		AddAmmo(CurrentHedgehog, amMine, 1)
+		AddAmmo(CurrentHedgehog, amDrill, 1)
+	elseif n == "Sniper" then
+		AddAmmo(CurrentHedgehog, amSniperRifle, 1)
+		AddAmmo(CurrentHedgehog, amDEagle, 1)
+		AddAmmo(CurrentHedgehog, amPortalGun, 2)
+	elseif n == "Saint" then
+		AddAmmo(CurrentHedgehog, amSeduction, 100)
+		AddAmmo(CurrentHedgehog, amResurrector, 1)
+		AddAmmo(CurrentHedgehog, amInvulnerable, 1)
+	elseif n == "Pyro" then
+		AddAmmo(CurrentHedgehog, amFlamethrower, 1)
+		AddAmmo(CurrentHedgehog, amMolotov, 1)
+		AddAmmo(CurrentHedgehog, amNapalm, 1)
+	elseif n == "Loon" then
+		AddAmmo(CurrentHedgehog, amBaseballBat, 1)
+		AddAmmo(CurrentHedgehog, amGasBomb, 1)
+		AddAmmo(CurrentHedgehog, amKamikaze, 1)
+	end
+
+end
+
+function onGameInit()
+	GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog
+	Delay = 10
+end
+
+function onGameStart()
+   	
+	CreateTeam()
+
+	ShowMission	(
+				loc("THE SPECIALISTS"),
+				loc("a Hedgewars mini-game"),
+
+				loc("Eliminate the enemy specialists.") .. "|" ..
+				" " .. "|" ..
+
+				loc("Game Modifiers: ") .. "|" ..
+				loc("Per-Hog Ammo") .. "|" ..				
+				loc("Weapons Reset") .. "|" ..				
+				loc("Unlimited Attacks") .. "|" ..
+
+				"", 4, 4000
+				)
+
+end
+
+
+function onNewTurn()
+	currName = GetHogName(CurrentHedgehog)
+	lastName = GetHogName(CurrentHedgehog)
+	AssignAmmo()
+	AddAmmo(CurrentHedgehog, amSwitch, 1)
+end
+
+function onGameTick()
+
+	if (CurrentHedgehog ~= nil) then
+
+		currName = GetHogName(CurrentHedgehog)
+		
+		if currName ~= lastName then
+			AddCaption(loc("Switched to ") .. currName .. "!")
+			AssignAmmo()		
+		end
+
+		lastName = currName
+
+	end
+
+end
+
+function onGearAdd(gear)
+    
+	if GetGearType(gear) == gtHedgehog then
+		hhs[numhhs] = gear
+		numhhs = numhhs + 1
+	end
+
+end
+
+function onGearDelete(gear)
+--
+end
+
+function onAmmoStoreInit()
+
+end
+
+
+