branch | webgl |
changeset 8330 | aaefa587e277 |
parent 8096 | 453917e94e55 |
parent 8228 | 8cc5dc7f7ef9 |
child 8444 | 75db7bb8dce8 |
8116:d24257910f8d | 8330:aaefa587e277 |
---|---|
78 uCollisions, |
78 uCollisions, |
79 uRenderUtils, |
79 uRenderUtils, |
80 uTextures, |
80 uTextures, |
81 uLandGraphics, |
81 uLandGraphics, |
82 SDLh, |
82 SDLh, |
83 SysUtils, |
83 SysUtils, |
84 uIO, |
84 uIO, |
85 uPhysFSLayer |
85 uPhysFSLayer |
86 ; |
86 ; |
87 |
87 |
88 var luaState : Plua_State; |
88 var luaState : Plua_State; |
109 // where L contains the state, returns the number of return values on the stack |
109 // where L contains the state, returns the number of return values on the stack |
110 // call lua_gettop(L) to receive number of parameters passed |
110 // call lua_gettop(L) to receive number of parameters passed |
111 |
111 |
112 function lc_band(L: PLua_State): LongInt; Cdecl; |
112 function lc_band(L: PLua_State): LongInt; Cdecl; |
113 begin |
113 begin |
114 if lua_gettop(L) <> 2 then |
114 if lua_gettop(L) <> 2 then |
115 begin |
115 begin |
116 LuaError('Lua: Wrong number of parameters passed to band!'); |
116 LuaError('Lua: Wrong number of parameters passed to band!'); |
117 lua_pushnil(L); |
117 lua_pushnil(L); |
118 end |
118 end |
119 else |
119 else |
121 lc_band := 1; |
121 lc_band := 1; |
122 end; |
122 end; |
123 |
123 |
124 function lc_bor(L: PLua_State): LongInt; Cdecl; |
124 function lc_bor(L: PLua_State): LongInt; Cdecl; |
125 begin |
125 begin |
126 if lua_gettop(L) <> 2 then |
126 if lua_gettop(L) <> 2 then |
127 begin |
127 begin |
128 LuaError('Lua: Wrong number of parameters passed to bor!'); |
128 LuaError('Lua: Wrong number of parameters passed to bor!'); |
129 lua_pushnil(L); |
129 lua_pushnil(L); |
130 end |
130 end |
131 else |
131 else |
133 lc_bor := 1; |
133 lc_bor := 1; |
134 end; |
134 end; |
135 |
135 |
136 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
136 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
137 begin |
137 begin |
138 if lua_gettop(L) <> 1 then |
138 if lua_gettop(L) <> 1 then |
139 begin |
139 begin |
140 LuaError('Lua: Wrong number of parameters passed to bnot!'); |
140 LuaError('Lua: Wrong number of parameters passed to bnot!'); |
141 lua_pushnil(L); |
141 lua_pushnil(L); |
142 end |
142 end |
143 else |
143 else |
145 lc_bnot := 1; |
145 lc_bnot := 1; |
146 end; |
146 end; |
147 |
147 |
148 function lc_div(L: PLua_State): LongInt; Cdecl; |
148 function lc_div(L: PLua_State): LongInt; Cdecl; |
149 begin |
149 begin |
150 if lua_gettop(L) <> 2 then |
150 if lua_gettop(L) <> 2 then |
151 begin |
151 begin |
152 LuaError('Lua: Wrong number of parameters passed to div!'); |
152 LuaError('Lua: Wrong number of parameters passed to div!'); |
153 lua_pushnil(L); |
153 lua_pushnil(L); |
154 end |
154 end |
155 else |
155 else |
271 begin |
271 begin |
272 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
272 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
273 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
273 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
274 lua_pushinteger(L, gear^.uid); |
274 lua_pushinteger(L, gear^.uid); |
275 end; |
275 end; |
276 lc_spawnfakehealthcrate := 1; |
276 lc_spawnfakehealthcrate := 1; |
277 end; |
277 end; |
278 |
278 |
279 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
279 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
280 var gear: PGear; |
280 var gear: PGear; |
281 begin |
281 begin |
300 begin |
300 begin |
301 LuaError('Lua: Wrong number of parameters passed to SpawnFakeUtilityCrate!'); |
301 LuaError('Lua: Wrong number of parameters passed to SpawnFakeUtilityCrate!'); |
302 lua_pushnil(L); |
302 lua_pushnil(L); |
303 end |
303 end |
304 else |
304 else |
305 begin |
305 begin |
306 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
306 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
307 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
307 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
308 lua_pushinteger(L, gear^.uid); |
308 lua_pushinteger(L, gear^.uid); |
309 end; |
309 end; |
310 lc_spawnfakeutilitycrate := 1; |
310 lc_spawnfakeutilitycrate := 1; |
329 if gear <> nil then |
329 if gear <> nil then |
330 lua_pushinteger(L, gear^.uid) |
330 lua_pushinteger(L, gear^.uid) |
331 else |
331 else |
332 lua_pushnil(L); |
332 lua_pushnil(L); |
333 end; |
333 end; |
334 lc_spawnhealthcrate := 1; |
334 lc_spawnhealthcrate := 1; |
335 end; |
335 end; |
336 |
336 |
337 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl; |
337 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl; |
338 var gear: PGear; |
338 var gear: PGear; |
339 begin |
339 begin |
342 LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!'); |
342 LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!'); |
343 lua_pushnil(L); |
343 lua_pushnil(L); |
344 end |
344 end |
345 else |
345 else |
346 begin |
346 begin |
347 if (lua_gettop(L) = 3) then |
347 if (lua_gettop(L) = 3) then |
348 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0) |
348 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0) |
349 else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
349 else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
350 if gear <> nil then |
350 if gear <> nil then |
351 lua_pushinteger(L, gear^.uid) |
351 lua_pushinteger(L, gear^.uid) |
352 else |
352 else |
438 vgt:= TVisualGearType(lua_tointeger(L, 3)); |
438 vgt:= TVisualGearType(lua_tointeger(L, 3)); |
439 s:= lua_tointeger(L, 4); |
439 s:= lua_tointeger(L, 4); |
440 c:= lua_toboolean(L, 5); |
440 c:= lua_toboolean(L, 5); |
441 |
441 |
442 vg:= AddVisualGear(x, y, vgt, s, c); |
442 vg:= AddVisualGear(x, y, vgt, s, c); |
443 if vg <> nil then |
443 if vg <> nil then |
444 begin |
444 begin |
445 lastVisualGearByUID:= vg; |
445 lastVisualGearByUID:= vg; |
446 lua_pushinteger(L, vg^.uid) |
446 lua_pushinteger(L, vg^.uid) |
447 end |
447 end |
448 else |
448 else |
688 if lua_gettop(L) <> 1 then |
688 if lua_gettop(L) <> 1 then |
689 LuaError('Lua: Wrong number of parameters passed to GetHogLevel!') |
689 LuaError('Lua: Wrong number of parameters passed to GetHogLevel!') |
690 else |
690 else |
691 begin |
691 begin |
692 gear := GearByUID(lua_tointeger(L, 1)); |
692 gear := GearByUID(lua_tointeger(L, 1)); |
693 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
693 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
694 lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
694 lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
695 else |
695 else |
696 lua_pushnil(L); |
696 lua_pushnil(L); |
697 end; |
697 end; |
698 lc_gethoglevel := 1; |
698 lc_gethoglevel := 1; |
721 lua_pushnil(L); // return value on stack (nil) |
721 lua_pushnil(L); // return value on stack (nil) |
722 end |
722 end |
723 else |
723 else |
724 begin |
724 begin |
725 gear:= GearByUID(lua_tointeger(L, 1)); |
725 gear:= GearByUID(lua_tointeger(L, 1)); |
726 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
726 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
727 begin |
727 begin |
728 lua_pushinteger(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
728 lua_pushinteger(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
729 end |
729 end |
730 else |
730 else |
731 lua_pushnil(L); |
731 lua_pushnil(L); |
762 begin |
762 begin |
763 team:= clan^.Teams[i]; |
763 team:= clan^.Teams[i]; |
764 for j:= 0 to 7 do |
764 for j:= 0 to 7 do |
765 begin |
765 begin |
766 hh:= team^.Hedgehogs[j]; |
766 hh:= team^.Hedgehogs[j]; |
767 if (hh.Gear <> nil) or (hh.GearHidden <> nil) then |
767 if (hh.Gear <> nil) or (hh.GearHidden <> nil) then |
768 begin |
768 begin |
769 FreeTexture(hh.NameTagTex); |
769 FreeTexture(hh.NameTagTex); |
770 hh.NameTagTex:= RenderStringTex(hh.Name, clan^.Color, fnt16); |
770 hh.NameTagTex:= RenderStringTex(hh.Name, clan^.Color, fnt16); |
771 RenderHealth(hh); |
771 RenderHealth(hh); |
772 end; |
772 end; |
803 lua_pushnil(L); // return value on stack (nil) |
803 lua_pushnil(L); // return value on stack (nil) |
804 end |
804 end |
805 else |
805 else |
806 begin |
806 begin |
807 gear:= GearByUID(lua_tointeger(L, 1)); |
807 gear:= GearByUID(lua_tointeger(L, 1)); |
808 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
808 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
809 begin |
809 begin |
810 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
810 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
811 end |
811 end |
812 else |
812 else |
813 lua_pushnil(L); |
813 lua_pushnil(L); |
824 lua_pushnil(L); // return value on stack (nil) |
824 lua_pushnil(L); // return value on stack (nil) |
825 end |
825 end |
826 else |
826 else |
827 begin |
827 begin |
828 gear:= GearByUID(lua_tointeger(L, 1)); |
828 gear:= GearByUID(lua_tointeger(L, 1)); |
829 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
829 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
830 begin |
830 begin |
831 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Name)) |
831 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Name)) |
832 end |
832 end |
833 else |
833 else |
834 lua_pushnil(L); |
834 lua_pushnil(L); |
1021 prevgear^.Active := false; |
1021 prevgear^.Active := false; |
1022 prevgear^.State:= prevgear^.State and (not gstHHDriven); |
1022 prevgear^.State:= prevgear^.State and (not gstHHDriven); |
1023 prevgear^.Z := cHHZ; |
1023 prevgear^.Z := cHHZ; |
1024 prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; |
1024 prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; |
1025 end; |
1025 end; |
1026 |
1026 |
1027 SwitchCurrentHedgehog(gear^.Hedgehog); |
1027 SwitchCurrentHedgehog(gear^.Hedgehog); |
1028 CurrentTeam:= CurrentHedgehog^.Team; |
1028 CurrentTeam:= CurrentHedgehog^.Team; |
1029 |
1029 |
1030 gear^.State:= gear^.State or gstHHDriven; |
1030 gear^.State:= gear^.State or gstHHDriven; |
1031 gear^.Active := true; |
1031 gear^.Active := true; |
1044 begin |
1044 begin |
1045 gear:= GearByUID(lua_tointeger(L, 1)); |
1045 gear:= GearByUID(lua_tointeger(L, 1)); |
1046 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1046 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1047 AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) ); |
1047 AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) ); |
1048 end else |
1048 end else |
1049 |
1049 |
1050 if lua_gettop(L) = 2 then |
1050 if lua_gettop(L) = 2 then |
1051 begin |
1051 begin |
1052 gear:= GearByUID(lua_tointeger(L, 1)); |
1052 gear:= GearByUID(lua_tointeger(L, 1)); |
1053 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1053 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1054 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
1054 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
1082 ammo : PAmmo; |
1082 ammo : PAmmo; |
1083 begin |
1083 begin |
1084 if (lua_gettop(L) = 2) then |
1084 if (lua_gettop(L) = 2) then |
1085 begin |
1085 begin |
1086 gear:= GearByUID(lua_tointeger(L, 1)); |
1086 gear:= GearByUID(lua_tointeger(L, 1)); |
1087 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1087 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1088 begin |
1088 begin |
1089 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
1089 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
1090 if ammo^.AmmoType = amNothing then |
1090 if ammo^.AmmoType = amNothing then |
1091 lua_pushinteger(L, 0) |
1091 lua_pushinteger(L, 0) |
1092 else |
1092 else |
1093 lua_pushinteger(L, ammo^.Count) |
1093 lua_pushinteger(L, ammo^.Count) |
1094 end |
1094 end |
1095 else lua_pushinteger(L, 0) |
1095 else lua_pushinteger(L, 0) |
1096 end |
1096 end |
1097 else |
1097 else |
1098 begin |
1098 begin |
1099 LuaError('Lua: Wrong number of parameters passed to GetAmmoCount!'); |
1099 LuaError('Lua: Wrong number of parameters passed to GetAmmoCount!'); |
1100 lua_pushnil(L) |
1100 lua_pushnil(L) |
1101 end; |
1101 end; |
1102 lc_getammocount:= 1 |
1102 lc_getammocount:= 1 |
1115 if gear <> nil then |
1115 if gear <> nil then |
1116 begin |
1116 begin |
1117 gear^.Health:= lua_tointeger(L, 2); |
1117 gear^.Health:= lua_tointeger(L, 2); |
1118 |
1118 |
1119 if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1119 if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1120 begin |
1120 begin |
1121 RenderHealth(gear^.Hedgehog^); |
1121 RenderHealth(gear^.Hedgehog^); |
1122 RecountTeamHealth(gear^.Hedgehog^.Team) |
1122 RecountTeamHealth(gear^.Hedgehog^.Team) |
1123 end; |
1123 end; |
1124 |
1124 |
1125 SetAllToActive; |
1125 SetAllToActive; |
1648 begin |
1648 begin |
1649 if lua_gettop(L) <> 1 then |
1649 if lua_gettop(L) <> 1 then |
1650 LuaError('Lua: Wrong number of parameters passed to GetHogHat!') |
1650 LuaError('Lua: Wrong number of parameters passed to GetHogHat!') |
1651 else begin |
1651 else begin |
1652 gear := GearByUID(lua_tointeger(L, 1)); |
1652 gear := GearByUID(lua_tointeger(L, 1)); |
1653 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1653 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1654 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
1654 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
1655 else |
1655 else |
1656 lua_pushnil(L); |
1656 lua_pushnil(L); |
1657 end; |
1657 end; |
1658 lc_gethoghat := 1; |
1658 lc_gethoghat := 1; |
1940 begin |
1940 begin |
1941 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
1941 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
1942 if StoreCnt-1 < k then AddAmmoStore; |
1942 if StoreCnt-1 < k then AddAmmoStore; |
1943 inc(k) |
1943 inc(k) |
1944 end |
1944 end |
1945 else |
1945 else |
1946 for i:= 0 to Pred(TeamsCount) do |
1946 for i:= 0 to Pred(TeamsCount) do |
1947 begin |
1947 begin |
1948 for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
1948 for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
1949 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
1949 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
1950 if StoreCnt-1 < k then AddAmmoStore; |
1950 if StoreCnt-1 < k then AddAmmoStore; |
1992 s:= cPathz[ptData] + name; |
1992 s:= cPathz[ptData] + name; |
1993 if not pfsExists(s) then |
1993 if not pfsExists(s) then |
1994 exit; |
1994 exit; |
1995 |
1995 |
1996 f:= pfsOpenRead(s); |
1996 f:= pfsOpenRead(s); |
1997 if f = nil then |
1997 if f = nil then |
1998 exit; |
1998 exit; |
1999 |
1999 |
2000 physfsReaderSetBuffer(@buf); |
2000 physfsReaderSetBuffer(@buf); |
2001 ret:= lua_load(luaState, @physfsReader, f, Str2PChar(s)); |
2001 ret:= lua_load(luaState, @physfsReader, f, Str2PChar(s)); |
2002 pfsClose(f); |
2002 pfsClose(f); |
2189 SetAmmoReinforcement(ScriptAmmoReinforcement) |
2189 SetAmmoReinforcement(ScriptAmmoReinforcement) |
2190 end; |
2190 end; |
2191 AddAmmoStore; |
2191 AddAmmoStore; |
2192 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 |
2192 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 |
2193 end |
2193 end |
2194 else |
2194 else |
2195 for i:= 0 to Pred(TeamsCount) do |
2195 for i:= 0 to Pred(TeamsCount) do |
2196 begin |
2196 begin |
2197 if ScriptExists('onNewAmmoStore') then |
2197 if ScriptExists('onNewAmmoStore') then |
2198 begin |
2198 begin |
2199 ScriptPrepareAmmoStore; |
2199 ScriptPrepareAmmoStore; |
2319 ScriptSetInteger('gstNotKickable' ,$00040000); |
2319 ScriptSetInteger('gstNotKickable' ,$00040000); |
2320 ScriptSetInteger('gstLoser' ,$00080000); |
2320 ScriptSetInteger('gstLoser' ,$00080000); |
2321 ScriptSetInteger('gstHHGone' ,$00100000); |
2321 ScriptSetInteger('gstHHGone' ,$00100000); |
2322 ScriptSetInteger('gstInvisible' ,$00200000); |
2322 ScriptSetInteger('gstInvisible' ,$00200000); |
2323 |
2323 |
2324 // ai hints |
|
2324 ScriptSetInteger('aihUsualProcessing' ,$00000000); |
2325 ScriptSetInteger('aihUsualProcessing' ,$00000000); |
2325 ScriptSetInteger('aihDoesntMatter' ,$00000001); |
2326 ScriptSetInteger('aihDoesntMatter' ,$00000001); |
2326 |
2327 |
2327 // register functions |
2328 // register functions |
2328 lua_register(luaState, _P'HideHog', @lc_hidehog); |
2329 lua_register(luaState, _P'HideHog', @lc_hidehog); |