share/hedgewars/Data/Scripts/Multiplayer/WxW.lua
changeset 14773 a9f32ff53389
parent 14772 f5dcf47dff2c
child 14811 d65e25e211d4
equal deleted inserted replaced
14772:f5dcf47dff2c 14773:a9f32ff53389
   851 	end
   851 	end
   852 
   852 
   853 end
   853 end
   854 
   854 
   855 function onCaseDrop()
   855 function onCaseDrop()
       
   856 	local crates
   856 	if roundN == 100 then
   857 	if roundN == 100 then
   857 		allowCrate = crateGearsInGame < maxCrates
   858 		allowCrate = crateGearsInGame < maxCrates
   858 		CheckCrateConditions()
   859 		crates = CheckCrateConditions()
       
   860 	end
       
   861 	if type(crates) == "table" and #crates > 0 and CurrentHedgehog then
       
   862 		PlaySound(sndReinforce, CurrentHedgehog)
   859 	end
   863 	end
   860 end
   864 end
   861 
   865 
   862 function CheckCrateConditions()
   866 function CheckCrateConditions()
   863 
   867 
   864 	local crateSpawn = AreCratesUnlocked()
   868 	local crateSpawn = AreCratesUnlocked()
       
   869 	local crates = {}
   865 
   870 
   866 	if crateSpawn == true and crateSpawned == false then
   871 	if crateSpawn == true and crateSpawned == false then
   867 		UnfreezeCrates()
   872 		UnfreezeCrates()
   868 		if allowCrate == true then
   873 		if allowCrate == true then
   869 			local cratesInGame = crateGearsInGame
   874 			local cratesInGame = crateGearsInGame
   870 			local toSpawn = cratesPerTurn
   875 			local toSpawn = cratesPerTurn
   871 			if cratesInGame + toSpawn > maxCrates then
   876 			if cratesInGame + toSpawn > maxCrates then
   872 				toSpawn = maxCrates - cratesInGame
   877 				toSpawn = maxCrates - cratesInGame
   873 			end
   878 			end
   874 			for i=1,toSpawn do
   879 			for i=1,toSpawn do
   875 				SpawnSupplyCrate(0, 0, weapons[1+GetRandom(#weapons)] )
   880 				table.insert(crates, SpawnSupplyCrate(0, 0, weapons[1+GetRandom(#weapons)]))
   876 			end
   881 			end
   877 			rPingTimer = 0
   882 			rPingTimer = 0
   878 			rAlpha = 0
   883 			rAlpha = 0
   879 			if toSpawn > 0 then
   884 			if toSpawn > 0 then
   880 				PlaySound(sndWarp)
   885 				PlaySound(sndWarp)
   881 			end
   886 			end
   882 		end
   887 		end
   883 	end
   888 	end
   884 
   889 
       
   890 	return crates
   885 end
   891 end
   886 
   892 
   887 function onGearWaterSkip(gear)
   893 function onGearWaterSkip(gear)
   888 	if gear == CurrentHedgehog then
   894 	if gear == CurrentHedgehog then
   889 		hasSurfed = true
   895 		hasSurfed = true