make use of onGearWaterSkip
authormikade <redgrinner@gmail.com>
Sun, 14 Dec 2014 12:26:16 +0900
changeset 10670 638af9cb922b
parent 10669 4c78eafe76ac
child 10671 17dd6265a08a
make use of onGearWaterSkip
share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
share/hedgewars/Data/Scripts/Multiplayer/WxW.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Sun Dec 14 03:32:11 2014 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Sun Dec 14 12:26:16 2014 +0900
@@ -290,7 +290,6 @@
 local chainLength = 0
 local shotsFired = 0
 local shotsHit = 0
-local SurfTime = 0
 local sniperHits = 0
 local pointBlankHits = 0
 ---------------------
@@ -1105,7 +1104,6 @@
 	pointBlankHits = 0
 	chainLength = 0
 	chainCounter = 0
-	SurfTime = 12
 
 	-------------------------
 	-- gaudy racer
@@ -1160,6 +1158,19 @@
 
 end
 
+function onGearWaterSkip(gear)
+	if gear == CurrentHedgehog then
+
+		for i = 0,(TeamsCount-1) do
+			if teamClan[i] == GetHogClan(CurrentHedgehog) and (teamSurfer[i] == false) then
+				teamSurfer[i] = true
+				AddCaption(loc("Surfer! +15 points!"),0xffba00ff,capgrpVolume)
+				AwardPoints(15)
+			end
+		end
+
+	end
+end
 
 function onGameTick()
 
@@ -1328,30 +1339,6 @@
 				--------------
 				--------------
 
-				------------------------
-				-- surfer achievement
-				------------------------
-
-				if (WaterLine - GetY(CurrentHedgehog)) < 15 then
-					SurfTime = SurfTime -1
-				end
-
-				if SurfTime ~= 12 then
-
-					SurfTime = SurfTime - 1
-					if SurfTime <= 0 then
-						for i = 0,(TeamsCount-1) do
-							if teamClan[i] == GetHogClan(CurrentHedgehog) and (teamSurfer[i] == false) then
-								teamSurfer[i] = true
-								SurfTime = 12
-								AddCaption(loc("Surfer! +15 points!"),0xffba00ff,capgrpVolume)
-								AwardPoints(15)
-							end
-						end
-					end
-				end
-
-
 				dx, dy = GetGearVelocity(CurrentHedgehog)
 
 				--WriteLnToConsole("I just got the velocity of currenthedgehog. It is dx: " .. dx .. "; dy: " .. dy)
--- a/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua	Sun Dec 14 03:32:11 2014 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua	Sun Dec 14 12:26:16 2014 +0900
@@ -77,8 +77,6 @@
 --local margin
 local wallsLeft = 0
 
-local highestY = 0
-local surferTimer = 0
 local hasSurfed = false
 local allWallsHit = false
 
@@ -356,25 +354,14 @@
 
 end
 
-function CheckSurfer()
-
-	if GetY(CurrentHedgehog) > highestY then
-		highestY = GetY(CurrentHedgehog)
+function onGearWaterSkip(gear)
+	if gear == CurrentHedgehog then
+		hasSurfed = true
+		AddCaption(loc("Surfer!"),0xffba00ff,capgrpMessage2)
 	end
-
-	if (highestY == (WaterLine-8)) and (hasSurfed == false)  then
-
-		surferTimer = surferTimer +1
-		if (surferTimer == 40) then
-			hasSurfed = true
-			AddCaption(loc("Surfer!"),0xffba00ff,capgrpMessage2)
-		end
-	end
-
 end
 
 
-
 function WallHit(id, zXMin,zYMin, zWidth, zHeight)
 
 	if wTouched[id] == false then
@@ -588,10 +575,8 @@
 
 	allowCrate = true
 
-	surferTimer = 0
 	hasSurfed = false
 	allWallsHit = false
-	highestY = 0
 
 	crateG = nil
 
@@ -650,8 +635,6 @@
 		--AddCaption(Map)
 		--AddCaption(RightX ..";" .. GetX(CurrentHedgehog))
 
-		CheckSurfer()
-
 		gTimer = gTimer + 1
 		if gTimer == 25 then
 			gTimer = 1