Tweak WxW wall spark count according to wall size
authorWuzzy <almikes@aol.com>
Thu, 24 Nov 2016 17:18:16 +0100
changeset 12070 03ba438dd597
parent 12069 b2f2ac53cbab
child 12071 ecad5b4e56d9
Tweak WxW wall spark count according to wall size
share/hedgewars/Data/Scripts/Multiplayer/WxW.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua	Thu Nov 24 17:05:26 2016 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua	Thu Nov 24 17:18:16 2016 +0100
@@ -926,13 +926,18 @@
 
 function BorderSpark(zXMin,zYMin, zWidth, zHeight, bCol)
 
-	eX = zXMin + GetRandom(zWidth+10)
-	eY = zYMin + GetRandom(zHeight+10)
+	local size = zWidth * zHeight
+	-- Add multiple sparks for very large walls
+	sparkRuns = math.min(10, math.max(1, div(size, 10240)))
+	for i=1, sparkRuns do
+		local eX = zXMin + GetRandom(zWidth+10)
+		local eY = zYMin + GetRandom(zHeight+10)
 
-	tempE = AddVisualGear(eX, eY, vgtDust, 0, false)
-	if tempE ~= 0 then
-		g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
-		SetVisualGearValues(tempE, eX, eY, g3, g4, g5, g6, g7, 1, g9, bCol )
+		local tempE = AddVisualGear(eX, eY, vgtDust, 0, false)
+		if tempE ~= 0 then
+			local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
+			SetVisualGearValues(tempE, eX, eY, g3, g4, g5, g6, g7, 1, g9, bCol )
+		end
 	end
 
 end