# HG changeset patch # User smxx # Date 1268607346 0 # Node ID dfc7507a21a09a48b9cf86866699a43ab8b809ac # Parent b90745d873321ec21791b951820509922cb7de50 Engine: * Added explosives count to scripting variables * Fixed adding multiple teams using Lua (AmmoStore problem; temporary) * Added another example mission: Basketball with score table diff -r b90745d87332 -r dfc7507a21a0 hedgewars/HHHandlers.inc --- a/hedgewars/HHHandlers.inc Sun Mar 14 20:48:13 2010 +0000 +++ b/hedgewars/HHHandlers.inc Sun Mar 14 22:55:46 2010 +0000 @@ -166,7 +166,7 @@ end; amBaseballBat: begin CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0); - PlaySound(sndBaseballBat) + PlaySound(sndBaseballBat) // TODO: Only play if something is hit? end; amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0); amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0); diff -r b90745d87332 -r dfc7507a21a0 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Sun Mar 14 20:48:13 2010 +0000 +++ b/hedgewars/uScript.pas Sun Mar 14 22:55:46 2010 +0000 @@ -57,7 +57,7 @@ procedure ScriptPrepareAmmoStore; forward; procedure ScriptApplyAmmoStore; forward; -procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte); forward; +procedure ScriptSetAmmo(ammo : TAmmoType; count, propability, delay: Byte); forward; // wrapped calls // @@ -211,7 +211,7 @@ ParseCommand('grave ' + lua_tostring(L, 3), true); ParseCommand('fort ' + lua_tostring(L, 4), true); ParseCommand('voicepack ' + lua_tostring(L, 5), true); - CurrentTeam^.Binds:= DefaultBinds; + CurrentTeam^.Binds:= DefaultBinds // fails on x64 //lua_pushinteger(L, LongInt(CurrentTeam)); end; @@ -277,11 +277,11 @@ function lc_setammo(L : Plua_State) : LongInt; Cdecl; begin - if lua_gettop(L) <> 3 then + if lua_gettop(L) <> 4 then WriteLnToConsole('LUA: Wrong number of parameters passed to SetAmmo!') else begin - ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3)); + ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4)); end; lc_setammo:= 0 end; @@ -345,6 +345,7 @@ ScriptSetInteger('TurnTime', cHedgehogTurnTime); ScriptSetInteger('CaseFreq', cCaseFactor); ScriptSetInteger('LandAdds', cLandAdditions); +ScriptSetInteger('Explosives', cExplosives); ScriptSetInteger('Delay', cInactDelay); ScriptSetString('Map', ''); ScriptSetString('Theme', ''); @@ -362,6 +363,7 @@ ParseCommand('$turntime ' + ScriptGetString('TurnTime'), true); ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true); ParseCommand('$landadds ' + ScriptGetString('LandAdds'), true); +ParseCommand('$explosives ' + ScriptGetString('Explosives'), true); ParseCommand('$delay ' + ScriptGetString('Delay'), true); if ScriptGetString('Map') <> '' then ParseCommand('map ' + ScriptGetString('Map'), true); @@ -370,6 +372,11 @@ ScriptPrepareAmmoStore; ScriptCall('onAmmoStoreInit'); +ScriptApplyAmmoStore; // doing 6 times - this is just temporary for now +ScriptApplyAmmoStore; +ScriptApplyAmmoStore; +ScriptApplyAmmoStore; +ScriptApplyAmmoStore; ScriptApplyAmmoStore; end; @@ -459,12 +466,13 @@ ScriptAmmoStore:= ScriptAmmoStore + '0000'; end; -procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte); +procedure ScriptSetAmmo(ammo : TAmmoType; count, propability, delay: Byte); begin -if (ord(ammo) < 1) or (count > 9) or (count < 0) or (propability < 0) or (propability > 8) then +if (ord(ammo) < 1) or (count > 9) or (count < 0) or (propability < 0) or (propability > 8) or (delay < 0) or (delay > 9)then exit; ScriptAmmoStore[ord(ammo)]:= inttostr(count)[1]; ScriptAmmoStore[ord(ammo) + ord(high(TAmmoType))]:= inttostr(propability)[1]; +ScriptAmmoStore[ord(ammo) + 2 * ord(high(TAmmoType))]:= inttostr(delay)[1]; end; procedure ScriptApplyAmmoStore; diff -r b90745d87332 -r dfc7507a21a0 share/hedgewars/Data/Missions/Basketball - 2 Players.hwt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Missions/Basketball - 2 Players.hwt Sun Mar 14 22:55:46 2010 +0000 @@ -0,0 +1,103 @@ +-- Hedgewars - Basketball for 2 Players + +local caption = { + ["en"] = "Hedgewars-Basketball", + ["de"] = "Hedgewars-Basketball" + } + +local subcaption = { + ["en"] = "2 Player Match", + ["de"] = "2-Spieler-Turnier" + } + +local goal = { + ["en"] = "Bat your opponents through the|baskets and out of the map!", + ["de"] = "Schlage deine Widersacher durch|die Körbe und aus der Karte hinaus!" + } + +local scored = { + ["en"] = " scored a point!", + ["de"] = " haben gepunktet!" + } + +local sscore = { + ["en"] = "Score", + ["de"] = "Punktestand" + } + + local teams = {} +teams[0] = { + ["en"] = "The Hogville Wizards", + ["de"] = "Die Igeldorf-Zauberer" + } +teams[1] = { + ["en"] = "The Hogmore Ravens", + ["de"] = "Die Igelmoor-Raben" + } + +local hognames = {} +hognames[0] = {"Michael", "Jason", "Mike", "Tom"} +hognames[1] = {"Diego", "Sam", "Jay", "Hank"} + +-- To handle missing texts we define a small wrapper function that +-- we'll use to retrieve text. +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 hogs = {} +hogs[0] = {nil, nil, nil, nil} +hogs[1] = {nil, nil, nil, nil} + +function onGameInit() + Seed = 0 + GameFlags = gfSolidLand + gfBorder + gfInvulnerable + gfRandomOrder + gfLowGravity + TurnTime = 15000 + CaseFreq = 0 + LandAdds = 0 + Explosives = 0 + Delay = 0 + Map = "basketball" + Theme = "Freeway" + + AddTeam(loc(teams[0]), 0xff0000, "Simple", "Island", "Default") + hogs[0][1] = AddHog(hognames[0][1], 0, 1, "NoHat") + hogs[0][2] = AddHog(hognames[0][2], 0, 1, "NoHat") + hogs[0][3] = AddHog(hognames[0][3], 0, 1, "NoHat") + hogs[0][4] = AddHog(hognames[0][4], 0, 1, "NoHat") + AddTeam(loc(teams[1]), 0x0000ff, "Simple", "Island", "Default") + hogs[1][1] = AddHog(hognames[1][1], 0, 1, "NoHat") + hogs[1][2] = AddHog(hognames[1][2], 0, 1, "NoHat") + hogs[1][3] = AddHog(hognames[1][3], 0, 1, "NoHat") + hogs[1][4] = AddHog(hognames[1][4], 0, 1, "NoHat") +end + +function onGameStart() + ShowMission(loc(caption), loc(subcaption), loc(goal), -amBaseballBat, 0); +end + +function onGameTick() +end + +function onAmmoStoreInit() + SetAmmo(amBaseballBat, 9, 0, 0) +end + +function onGearAdd(gear) +end + +local score = {0, 0} +function onGearDelete(gear) + if gear == hogs[0][1] or gear == hogs[0][2] or gear == hogs[0][3] or gear == hogs[0][4] then + score[2] = score[2] + 1 + ShowMission(loc(caption), loc(subcaption), loc(teams[1]) .. " " .. loc(scored) .. "|" .. loc(sscore) .. ": " .. score[1] .. " - " .. score[2], -amBaseballBat, 0); + elseif gear == hogs[1][1] or gear == hogs[1][2] or gear == hogs[1][3] or gear == hogs[1][4] then + score[1] = score[1] + 1 + ShowMission(loc(caption), loc(subcaption), loc(teams[0]) .. " " .. loc(scored) .. "|" .. loc(sscore) .. ": " .. score[1] .. " - " .. score[2], -amBaseballBat, 0); + end +end \ No newline at end of file diff -r b90745d87332 -r dfc7507a21a0 share/hedgewars/Data/Missions/Bazooka Training.hwt --- a/share/hedgewars/Data/Missions/Bazooka Training.hwt Sun Mar 14 20:48:13 2010 +0000 +++ b/share/hedgewars/Data/Missions/Bazooka Training.hwt Sun Mar 14 22:55:46 2010 +0000 @@ -117,8 +117,10 @@ TurnTime = 60000 -- The frequency of crate drops CaseFreq = 0 - -- The number of land objects being placed + -- The number of mines being placed LandAdds = 0 + -- The number of explosives being placed + Explosives = 0 -- The delay between each round Delay = 0 -- The map to be played diff -r b90745d87332 -r dfc7507a21a0 share/hedgewars/Data/Missions/Shotgun Training.hwt --- a/share/hedgewars/Data/Missions/Shotgun Training.hwt Sun Mar 14 20:48:13 2010 +0000 +++ b/share/hedgewars/Data/Missions/Shotgun Training.hwt Sun Mar 14 22:55:46 2010 +0000 @@ -117,8 +117,10 @@ TurnTime = 25000 -- The frequency of crate drops CaseFreq = 0 - -- The number of land objects being placed + -- The number of mines being placed LandAdds = 0 + -- The number of explosives being placed + Explosives = 0 -- The delay between each round Delay = 0 -- The map to be played