Engine:
authorsmxx
Tue, 16 Mar 2010 21:39:55 +0000
changeset 3004 e9b3613cc3fb
parent 3003 0afdba08a858
child 3005 1ff835e9ce32
Engine: * Updated Ball Gun balls: Now rotate depending on velocity (looks better imo but could revert that change as well) * Allow explosions without spawning gears (visuals) * Added some script additions Maps: * Updated Basketball's CMakeLists.txt * Added experimental Knockball map
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uScript.pas
share/hedgewars/Data/Graphics/Balls.png
share/hedgewars/Data/Maps/Basketball/CMakeLists.txt
share/hedgewars/Data/Maps/Basketball/map.lua
share/hedgewars/Data/Maps/Knockball/CMakeLists.txt
share/hedgewars/Data/Maps/Knockball/map.cfg
share/hedgewars/Data/Maps/Knockball/map.lua
share/hedgewars/Data/Maps/Knockball/map.png
share/hedgewars/Data/Maps/Knockball/preview.png
--- a/hedgewars/GSHandlers.inc	Tue Mar 16 19:28:15 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Tue Mar 16 21:39:55 2010 +0000
@@ -249,6 +249,14 @@
         gtWatermelon: makeHogsWorry(Gear^.X, Gear^.Y, 75);
         gtHellishBomb: makeHogsWorry(Gear^.X, Gear^.Y, 90);
     end;
+
+if (Gear^.Kind = gtBall) and ((Gear^.State and gstTmpFlag) <> 0) then
+    begin
+    CheckCollision(Gear);
+    if (Gear^.State and gstCollision) <> 0 then
+        doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLDontDraw or EXPLNoGfx);
+    end;
+
 if Gear^.Timer = 0 then
     begin
     case Gear^.Kind of
@@ -353,7 +361,7 @@
     exit
     end;
 
-if Gear^.Kind = gtMelonPiece then
+if (Gear^.Kind = gtMelonPiece) or (Gear^.Kind = gtBall) then
     CalcRotationDirAngle(Gear)
 else
     if (GameTicks and $1F) = 0 then
--- a/hedgewars/uConsts.pas	Tue Mar 16 19:28:15 2010 +0000
+++ b/hedgewars/uConsts.pas	Tue Mar 16 21:39:55 2010 +0000
@@ -379,6 +379,7 @@
     EXPLNoDamage          = $00000004;
     EXPLDoNotTouchHH      = $00000008;
     EXPLDontDraw          = $00000010;
+    EXPLNoGfx             = $00000020;
 
     posCaseAmmo    = $00000001;
     posCaseHealth  = $00000002;
--- a/hedgewars/uGears.pas	Tue Mar 16 19:28:15 2010 +0000
+++ b/hedgewars/uGears.pas	Tue Mar 16 21:39:55 2010 +0000
@@ -1573,7 +1573,7 @@
                   if ((TrainingFlags and tfRCPlane) <> 0) and (TrainingTargetGear <> nil) and ((Gear^.State and gstDrowning) = 0) then
                      DrawRotatedf(sprFinger, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, GameTicks div 32 mod 16, 0, DxDy2Angle(Gear^.X - TrainingTargetGear^.X, TrainingTargetGear^.Y - Gear^.Y));
                   end;
-       gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX));
+       gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, Gear^.DirAngle);
 
        gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
 
@@ -1736,7 +1736,7 @@
 begin
 TargetPoint.X:= NoPointX;
 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
-if (Radius > 10) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0);
+if (Radius > 10) and ((Mask and EXPLNoGfx) = 0) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0);
 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion);
 
 if (Mask and EXPLAllDamageInRadius) = 0 then
--- a/hedgewars/uScript.pas	Tue Mar 16 19:28:15 2010 +0000
+++ b/hedgewars/uScript.pas	Tue Mar 16 21:39:55 2010 +0000
@@ -194,6 +194,101 @@
     lc_gethogname:= 1
 end;
 
+function lc_getx(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 1 then
+        begin
+        WriteLnToConsole('LUA: Wrong number of parameters passed to GetX!');
+        lua_pushnil(L); // return value on stack (nil)
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then
+            lua_pushnumber(L, hwRound(gear^.X))
+        else
+            lua_pushnil(L);
+        end;
+    lc_getx:= 1
+end;
+
+function lc_gety(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 1 then
+        begin
+        WriteLnToConsole('LUA: Wrong number of parameters passed to GetY!');
+        lua_pushnil(L); // return value on stack (nil)
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then
+            lua_pushnumber(L, hwRound(gear^.Y))
+        else
+            lua_pushnil(L);
+        end;
+    lc_gety:= 1
+end;
+
+function lc_copypv(L : Plua_State) : LongInt; Cdecl;
+var gears, geard : PGear;
+begin
+    if lua_gettop(L) <> 2 then
+        begin
+        WriteLnToConsole('LUA: Wrong number of parameters passed to CopyPV!');
+        end
+    else
+        begin
+        gears:= GearByUID(lua_tointeger(L, 1));
+        geard:= GearByUID(lua_tointeger(L, 2));
+        if (gears <> nil) and (geard <> nil) then
+            begin
+            geard^.X:= gears^.X;
+            geard^.Y:= gears^.Y;
+            geard^.dX:= gears^.dX;
+            geard^.dY:= gears^.dY;
+            end
+        end;
+    lc_copypv:= 1
+end;
+
+function lc_copypv2(L : Plua_State) : LongInt; Cdecl;
+var gears, geard : PGear;
+begin
+    if lua_gettop(L) <> 2 then
+        begin
+        WriteLnToConsole('LUA: Wrong number of parameters passed to CopyPV2!');
+        end
+    else
+        begin
+        gears:= GearByUID(lua_tointeger(L, 1));
+        geard:= GearByUID(lua_tointeger(L, 2));
+        if (gears <> nil) and (geard <> nil) then
+            begin
+            geard^.X:= gears^.X;
+            geard^.Y:= gears^.Y;
+            geard^.dX:= gears^.dX * 2;
+            geard^.dY:= gears^.dY * 2;
+            end
+        end;
+    lc_copypv2:= 1
+end;
+
+function lc_followgear(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 1 then
+        WriteLnToConsole('LUA: Wrong number of parameters passed to FollowGear!')
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then FollowGear:= gear
+        end;
+    lc_followgear:= 0
+end;
+
 function lc_sethealth(L : Plua_State) : LongInt; Cdecl;
 var gear : PGear;
 begin
@@ -204,11 +299,59 @@
     else
         begin
         gear:= GearByUID(lua_tointeger(L, 1));
-        if (gear <> nil) and (gear^.Kind = gtHedgehog) then gear^.Health:= lua_tointeger(L, 2)
+        if gear <> nil then gear^.Health:= lua_tointeger(L, 2)
         end;
     lc_sethealth:= 0
 end;
 
+function lc_setstate(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 2 then
+        begin
+        WriteLnToConsole('LUA: Wrong number of parameters passed to SetState!');
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then gear^.State:= lua_tointeger(L, 2)
+        end;
+    lc_setstate:= 0
+end;
+
+function lc_getstate(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 1 then
+        begin
+        WriteLnToConsole('LUA: Wrong number of parameters passed to GetState!');
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then
+            lua_pushinteger(L, gear^.State)
+        else
+            lua_pushnil(L)
+        end;
+    lc_getstate:= 1
+end;
+
+function lc_settag(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 2 then
+        begin
+        WriteLnToConsole('LUA: Wrong number of parameters passed to SetTag!');
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then gear^.Tag:= lua_tointeger(L, 2)
+        end;
+    lc_settag:= 0
+end;
+
 function lc_endgame(L : Plua_State) : LongInt; Cdecl;
 begin
     GameState:= gsExit;
@@ -637,6 +780,15 @@
 lua_register(luaState, 'SetHealth', @lc_sethealth);
 lua_register(luaState, 'GetHogClan', @lc_gethogclan);
 lua_register(luaState, 'GetHogName', @lc_gethogname);
+lua_register(luaState, 'GetX', @lc_getx);
+lua_register(luaState, 'GetY', @lc_gety);
+lua_register(luaState, 'CopyPV', @lc_copypv);
+lua_register(luaState, 'CopyPV2', @lc_copypv2);
+lua_register(luaState, 'FollowGear', @lc_followgear);
+lua_register(luaState, 'SetState', @lc_setstate);
+lua_register(luaState, 'GetState', @lc_getstate);
+lua_register(luaState, 'SetTag', @lc_settag);
+
 
 ScriptClearStack; // just to be sure stack is empty
 ScriptLoaded:= false;
Binary file share/hedgewars/Data/Graphics/Balls.png has changed
--- a/share/hedgewars/Data/Maps/Basketball/CMakeLists.txt	Tue Mar 16 19:28:15 2010 +0000
+++ b/share/hedgewars/Data/Maps/Basketball/CMakeLists.txt	Tue Mar 16 21:39:55 2010 +0000
@@ -1,6 +1,7 @@
 install(FILES
 	map.png
 	map.cfg
+	map.lua
 	mask.png
 	preview.png
 	DESTINATION ${SHAREPATH}Data/Maps/Basketball)
--- a/share/hedgewars/Data/Maps/Basketball/map.lua	Tue Mar 16 19:28:15 2010 +0000
+++ b/share/hedgewars/Data/Maps/Basketball/map.lua	Tue Mar 16 21:39:55 2010 +0000
@@ -1,4 +1,4 @@
--- Hedgewars - Basketball for 2 Players
+-- Hedgewars - Basketball for 2+ Players
 
 local caption = {
 	["en"] = "Hedgewars-Basketball",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Maps/Knockball/CMakeLists.txt	Tue Mar 16 21:39:55 2010 +0000
@@ -0,0 +1,6 @@
+install(FILES
+	map.png
+	map.cfg
+	map.lua
+	preview.png
+	DESTINATION ${SHAREPATH}Data/Maps/Knockball)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Maps/Knockball/map.cfg	Tue Mar 16 21:39:55 2010 +0000
@@ -0,0 +1,2 @@
+Bamboo
+48
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Maps/Knockball/map.lua	Tue Mar 16 21:39:55 2010 +0000
@@ -0,0 +1,105 @@
+-- Hedgewars - Knockball for 2+ Players
+
+local caption = {
+	["en"] = "Hedgewars-Knockball",
+	["de"] = "Hedgewars-Knockball"
+	}
+
+local subcaption = {
+	["en"] = "Not So Friendly Match",
+	["de"] = "Kein-so-Freundschaftsspiel"
+	}
+
+local goal = {
+	["en"] = "Bat balls at your enemies and|push them into the sea!",
+	["de"] = "Schlage Bälle auf deine Widersacher|und lass sie ins Meer fallen!"
+	}
+
+local scored = {
+	["en"] = " scored a point!",
+	["de"] = " erhält einen Punkt!"
+	}
+
+local failed = {
+	["en"] = " scored a penalty!",
+	["de"] = " erhält eine Strafe!"
+	}
+
+	local sscore = {
+	["en"] = "Score",
+	["de"] = "Punktestand"
+	}
+
+local team = {
+	["en"] = "Team"
+	}
+
+local drowning = {
+	["en"] = "is out and",
+	["de"] = "ist draußen und"
+	}
+
+local function loc(text)
+	if text == nil then return "**missing**"
+	elseif text[L] == nil then return text["en"]
+	else return text[L]
+	end
+end
+
+---------------------------------------------------------------
+
+local score = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0}
+
+local ball = nil
+
+function onGameInit()
+	GameFlags = gfSolidLand + gfInvulnerable + gfDivideTeams
+	TurnTime = 20000
+	CaseFreq = 0
+	LandAdds = 0
+	Explosives = 0
+	Delay = 500
+end
+
+function onGameStart()
+	ShowMission(loc(caption), loc(subcaption), loc(goal), -amBaseballBat, 0);
+end
+
+function onGameTick()
+	if ball ~= nil then FollowGear(ball) end
+end
+
+function onAmmoStoreInit()
+	SetAmmo(amBaseballBat, 9, 0, 0)
+	SetAmmo(amSkip, 9, 0, 0)
+end
+
+function onGearAdd(gear)
+	if GetGearType(gear) == gtShover then
+		ball = AddGear(GetX(gear), GetY(gear), gtBall, 0, 0, 0, 0)
+		if ball ~= nil then
+			CopyPV2(gear, ball)
+			SetState(ball, 0x200) -- temporary - might change!
+			SetTag(ball, 8) -- baseball skin
+		end
+	end
+end
+
+function onGearDelete(gear)
+	if gear == ball then
+		ball = nil
+	elseif (GetGearType(gear) == gtHedgehog) and CurrentHedgehog ~= nil then
+		local clan = GetHogClan(CurrentHedgehog)
+		local s = GetHogName(gear) .. " " .. loc(drowning) .. "|" .. loc(team) .. " " .. (clan + 1) .. " "
+		if GetHogClan(CurrentHedgehog) ~= GetHogClan(gear) then
+			score[clan] = score[clan] + 1
+			s = s .. loc(scored)
+		else
+			score[clan] = score[clan] - 1
+			s = s .. loc(failed)
+		end
+		s = s .. "| |" .. loc(sscore) .. ": " .. score[0]
+		for i = 1, ClansCount - 1 do s = s .. " - " .. score[i] end
+		ShowMission(loc(caption), loc(subcaption), s, -amBaseballBat, 0)
+	end
+end
Binary file share/hedgewars/Data/Maps/Knockball/map.png has changed
Binary file share/hedgewars/Data/Maps/Knockball/preview.png has changed