fix trophyrace. also tweak it a little
authornemo
Sat, 20 Oct 2012 22:43:25 -0400
changeset 7771 ce6d4dd0c780
parent 7769 1661680c6b59
child 7773 3d460e57d4e6
fix trophyrace. also tweak it a little
QTfrontend/ui/widget/gamecfgwidget.cpp
hedgewars/uScript.pas
share/hedgewars/Data/Maps/TrophyRace/map.lua
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Sat Oct 20 18:54:03 2012 +0400
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Sat Oct 20 22:43:25 2012 -0400
@@ -200,6 +200,10 @@
 {
     QList<QByteArray> bcfg;
     int mapgen = pMapContainer->get_mapgen();
+    if (Scripts->currentIndex() > 0)
+    {
+        bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString()).toUtf8();
+    }
 
     QString currentMap = pMapContainer->getCurrentMap();
     if (currentMap.size() > 0)
@@ -212,11 +216,6 @@
     }
     bcfg << QString("etheme " + pMapContainer->getCurrentTheme()).toUtf8();
 
-    if (Scripts->currentIndex() > 0)
-    {
-        bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString()).toUtf8();
-    }
-
     bcfg << QString("eseed " + pMapContainer->getCurrentSeed()).toUtf8();
     bcfg << QString("e$gmflags %1").arg(getGameFlags()).toUtf8();
     bcfg << QString("e$damagepct %1").arg(schemeData(26).toInt()).toUtf8();
--- a/hedgewars/uScript.pas	Sat Oct 20 18:54:03 2012 +0400
+++ b/hedgewars/uScript.pas	Sat Oct 20 22:43:25 2012 -0400
@@ -1892,7 +1892,8 @@
 cWaterRise       := ScriptGetInteger('WaterRise');
 cHealthDecrease  := ScriptGetInteger('HealthDecrease');
 
-ParseCommand('map ' + ScriptGetString('Map'), true);
+if cMapName <> ScriptGetString('Map') then
+    ParseCommand('map ' + ScriptGetString('Map'), true);
 if ScriptGetString('Theme') <> '' then
     ParseCommand('theme ' + ScriptGetString('Theme'), true);
 LuaGoals:= ScriptGetString('Goals');
--- a/share/hedgewars/Data/Maps/TrophyRace/map.lua	Sat Oct 20 18:54:03 2012 +0400
+++ b/share/hedgewars/Data/Maps/TrophyRace/map.lua	Sat Oct 20 22:43:25 2012 -0400
@@ -70,19 +70,22 @@
 	SetAmmo(amRope, 9, 2, 0)
 end
 
-function onGameTick()
-	if TurnTimeLeft == 1 and CurrentHedgehog ~= nil then
+function onGameTick20()
+	if CurrentHedgehog ~= nil and TurnTimeLeft <= 20 and TurnTimeLeft > 0 then
 		SetHealth(CurrentHedgehog, 0)
 		x, y = GetGearPosition(CurrentHedgehog)
-		AddGear(x, y, gtAmmo_Grenade, 0, 0, 0, 0)
+		AddGear(x, y, gtShell, 0, 0, 0, 0)
 		worsttime = 99999
 		worsthog = nil
-	elseif TurnTimeLeft == maxtime - 1 and CurrentHedgehog ~= nil then
+	elseif TurnTimeLeft > maxtime - 25 and CurrentHedgehog ~= nil then
 		if lasthog ~= nil then 
 		SetGearPosition(lasthog, p , 0)
 		end
 		reached = false
+        SetGearVelocity(CurrentHedgehog, 1, 0)
 		SetGearPosition(CurrentHedgehog, start_area[1] + start_area[3] / 2, start_area[2] + start_area[4] / 2)
+        ParseCommand("setweap " .. string.char(amRope))
+		lasthog = CurrentHedgehog
 	elseif CurrentHedgehog ~= nil then
 		x, y = GetGearPosition(CurrentHedgehog)
 		if not reached and x > goal_area[1] and x < goal_area[1] + goal_area[3] and y > goal_area[2] and y < goal_area[2] + goal_area[4] then -- hog is within goal rectangle
@@ -148,15 +151,14 @@
 		hhs[numhhs] = gear
 		times[numhhs] = 0
 		numhhs = numhhs + 1
-	elseif GetGearType(gear) == gtRope then -- rope is shot
-		
 	end
+--	elseif GetGearType(gear) == gtRope then -- rope is shot
 end
 
-function onGearDelete(gear)
-	if GetGearType(gear) == gtRope then -- rope deletion - hog didn't manage to rerope
-		--TurnTimeLeft = 0 -- end turn or not? hm...
-		lasthog = CurrentHedgehog
-		
-	end
-end
+--function onGearDelete(gear)
+--	if GetGearType(gear) == gtRope then -- rope deletion - hog didn't manage to rerope
+--		--TurnTimeLeft = 0 -- end turn or not? hm...
+--		lasthog = CurrentHedgehog
+--		
+--	end
+--end