mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-28 18:00:40 +00:00
Lunatic: retire gv.*_WEAPON and gv.GET_* for gv.WEAPON.* and gv.GET.*.
git-svn-id: https://svn.eduke32.com/eduke32@4030 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
0a06ca29f2
commit
55a3cda9e1
4 changed files with 53 additions and 42 deletions
|
@ -54,6 +54,9 @@ local check_sound_idx = bcheck.sound_idx
|
||||||
local check_number = bcheck.number
|
local check_number = bcheck.number
|
||||||
local check_type = bcheck.type
|
local check_type = bcheck.type
|
||||||
|
|
||||||
|
local lprivate = require("lprivate")
|
||||||
|
local GET, WEAPON = lprivate.GET, lprivate.WEAPON
|
||||||
|
|
||||||
local OUR_REQUIRE_STRING = [[
|
local OUR_REQUIRE_STRING = [[
|
||||||
local _con=require'con'
|
local _con=require'con'
|
||||||
local _ga,_av,_pv=_con._gamearray,_con.actorvar,_con.playervar
|
local _ga,_av,_pv=_con._gamearray,_con.actorvar,_con.playervar
|
||||||
|
@ -587,7 +590,7 @@ function _tossweapon(pli) -- P_DropWeapon replacement
|
||||||
|
|
||||||
if (krandand(1) ~= 0) then
|
if (krandand(1) ~= 0) then
|
||||||
spawn(ffiC.WeaponPickupSprites[cw], ps.i)
|
spawn(ffiC.WeaponPickupSprites[cw], ps.i)
|
||||||
elseif (cw==ffiC.RPG_WEAPON or cw==ffiC.HANDBOMB_WEAPON) then
|
elseif (cw==WEAPON.RPG or cw==WEAPON.HANDBOMB) then
|
||||||
if (D.EXPLOSION2 ~= nil) then
|
if (D.EXPLOSION2 ~= nil) then
|
||||||
spawn(D.EXPLOSION2, ps.i)
|
spawn(D.EXPLOSION2, ps.i)
|
||||||
end
|
end
|
||||||
|
@ -606,7 +609,7 @@ end
|
||||||
local function P_AddWeaponAmmoCommon(ps, weap, amount)
|
local function P_AddWeaponAmmoCommon(ps, weap, amount)
|
||||||
P_AddAmmo(ps, weap, amount)
|
P_AddAmmo(ps, weap, amount)
|
||||||
|
|
||||||
if (ps.curr_weapon==ffiC.KNEE_WEAPON and ps:has_weapon(weap)) then
|
if (ps.curr_weapon==WEAPON.KNEE and ps:has_weapon(weap)) then
|
||||||
CF.P_AddWeaponMaybeSwitchI(ps.weapon._p, weap);
|
CF.P_AddWeaponMaybeSwitchI(ps.weapon._p, weap);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1112,17 +1115,17 @@ end
|
||||||
|
|
||||||
local PALBITS = { [0]=1, [21]=2, [23]=4 }
|
local PALBITS = { [0]=1, [21]=2, [23]=4 }
|
||||||
local ICONS = {
|
local ICONS = {
|
||||||
[ffiC.GET_FIRSTAID] = 1, -- ICON_FIRSTAID
|
[GET.FIRSTAID] = 1, -- ICON_FIRSTAID
|
||||||
[ffiC.GET_STEROIDS] = 2,
|
[GET.STEROIDS] = 2,
|
||||||
[ffiC.GET_HOLODUKE] = 3,
|
[GET.HOLODUKE] = 3,
|
||||||
[ffiC.GET_JETPACK] = 4,
|
[GET.JETPACK] = 4,
|
||||||
[ffiC.GET_HEATS] = 5,
|
[GET.HEATS] = 5,
|
||||||
[ffiC.GET_SCUBA] = 6,
|
[GET.SCUBA] = 6,
|
||||||
[ffiC.GET_BOOTS] = 7,
|
[GET.BOOTS] = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
function _addinventory(ps, inv, amount, i)
|
function _addinventory(ps, inv, amount, i)
|
||||||
if (inv == ffiC.GET_ACCESS) then
|
if (inv == GET.ACCESS) then
|
||||||
local pal = sprite[i].pal
|
local pal = sprite[i].pal
|
||||||
if (PALBITS[pal]) then
|
if (PALBITS[pal]) then
|
||||||
ps.got_access = bor(ps.got_access, PALBITS[pal])
|
ps.got_access = bor(ps.got_access, PALBITS[pal])
|
||||||
|
@ -1132,7 +1135,7 @@ function _addinventory(ps, inv, amount, i)
|
||||||
ps.inven_icon = ICONS[inv]
|
ps.inven_icon = ICONS[inv]
|
||||||
end
|
end
|
||||||
|
|
||||||
if (inv == ffiC.GET_SHIELD) then
|
if (inv == GET.SHIELD) then
|
||||||
amount = math.min(ps.max_shield_amount, amount)
|
amount = math.min(ps.max_shield_amount, amount)
|
||||||
end
|
end
|
||||||
-- NOTE: this is more permissive than CON, e.g. allows
|
-- NOTE: this is more permissive than CON, e.g. allows
|
||||||
|
@ -1142,9 +1145,9 @@ function _addinventory(ps, inv, amount, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _checkpinventory(ps, inv, amount, i)
|
function _checkpinventory(ps, inv, amount, i)
|
||||||
if (inv==ffiC.GET_SHIELD) then
|
if (inv==GET.SHIELD) then
|
||||||
return ps.inv_amount[inv] ~= ps.max_shield_amount
|
return ps.inv_amount[inv] ~= ps.max_shield_amount
|
||||||
elseif (inv==ffiC.GET_ACCESS) then
|
elseif (inv==GET.ACCESS) then
|
||||||
local palbit = PALBITS[sprite[i].pal]
|
local palbit = PALBITS[sprite[i].pal]
|
||||||
return palbit and (band(ps.got_access, palbit)~=0)
|
return palbit and (band(ps.got_access, palbit)~=0)
|
||||||
else
|
else
|
||||||
|
@ -1153,13 +1156,13 @@ function _checkpinventory(ps, inv, amount, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
local INV_SELECTION_ORDER = {
|
local INV_SELECTION_ORDER = {
|
||||||
ffiC.GET_FIRSTAID,
|
GET.FIRSTAID,
|
||||||
ffiC.GET_STEROIDS,
|
GET.STEROIDS,
|
||||||
ffiC.GET_JETPACK,
|
GET.JETPACK,
|
||||||
ffiC.GET_HOLODUKE,
|
GET.HOLODUKE,
|
||||||
ffiC.GET_HEATS,
|
GET.HEATS,
|
||||||
ffiC.GET_SCUBA,
|
GET.SCUBA,
|
||||||
ffiC.GET_BOOTS,
|
GET.BOOTS,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- checkavailinven CON command
|
-- checkavailinven CON command
|
||||||
|
@ -1618,7 +1621,7 @@ function _ifp(flags, pli, aci)
|
||||||
return true
|
return true
|
||||||
elseif (band(l,256)~=0 and vel <= -8 and holdskey(pli, "RUN")) then
|
elseif (band(l,256)~=0 and vel <= -8 and holdskey(pli, "RUN")) then
|
||||||
return true
|
return true
|
||||||
elseif (band(l,512)~=0 and (ps.quick_kick > 0 or (ps.curr_weapon == ffiC.KNEE_WEAPON and ps.kickback_pic > 0))) then
|
elseif (band(l,512)~=0 and (ps.quick_kick > 0 or (ps.curr_weapon == 0 and ps.kickback_pic > 0))) then
|
||||||
return true
|
return true
|
||||||
elseif (band(l,1024)~=0 and sprite[ps.i].xrepeat < 32) then
|
elseif (band(l,1024)~=0 and sprite[ps.i].xrepeat < 32) then
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -106,18 +106,14 @@ local WEAPON_NAMES = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---- game structs ----
|
---- game structs ----
|
||||||
|
|
||||||
|
lprivate.GET = defs_c.conststruct(INV_NAMES)
|
||||||
|
lprivate.WEAPON = defs_c.conststruct(WEAPON_NAMES)
|
||||||
|
|
||||||
ffi.cdef([[
|
ffi.cdef([[
|
||||||
enum dukeinv_t {
|
|
||||||
]].. "GET_"..table.concat(INV_NAMES, ",GET_") ..[[,
|
|
||||||
GET_MAX
|
|
||||||
};
|
|
||||||
|
|
||||||
enum dukeweapon_t {
|
|
||||||
]].. table.concat(WEAPON_NAMES, "_WEAPON,").."_WEAPON," ..[[
|
|
||||||
MAX_WEAPONS
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
GET_MAX = 11,
|
||||||
|
MAX_WEAPONS = 12,
|
||||||
MAXPLAYERS = 16,
|
MAXPLAYERS = 16,
|
||||||
GTICSPERSEC = 30, // The real number of movement updates per second
|
GTICSPERSEC = 30, // The real number of movement updates per second
|
||||||
};
|
};
|
||||||
|
@ -585,7 +581,7 @@ ffi.cdef[[
|
||||||
const int32_t screenpeek;
|
const int32_t screenpeek;
|
||||||
hudweapon_t hudweap;
|
hudweapon_t hudweap;
|
||||||
int32_t g_logoFlags;
|
int32_t g_logoFlags;
|
||||||
int32_t g_RETURN; // deprecated from Lua
|
int32_t g_RETURN;
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- INTERNAL VARIABLES/FUNCTIONS
|
-- INTERNAL VARIABLES/FUNCTIONS
|
||||||
|
@ -1492,6 +1488,9 @@ gv_access.REND = defs_c.conststruct
|
||||||
POLYMER = 4,
|
POLYMER = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gv_access.WEAPON = lprivate.WEAPON
|
||||||
|
gv_access.GET = lprivate.GET
|
||||||
|
|
||||||
function gv_access._get_yxaspect()
|
function gv_access._get_yxaspect()
|
||||||
return ffiC.yxaspect
|
return ffiC.yxaspect
|
||||||
end
|
end
|
||||||
|
@ -2364,7 +2363,7 @@ local tmpmt = {
|
||||||
|
|
||||||
__newindex = function(_, key, val)
|
__newindex = function(_, key, val)
|
||||||
if (gv_access[key] == nil) then
|
if (gv_access[key] == nil) then
|
||||||
-- Read-only vars handled by LuaJIT.
|
-- Variables declared 'const' are handled by LuaJIT.
|
||||||
ffiC[key] = val
|
ffiC[key] = val
|
||||||
else
|
else
|
||||||
error("write access forbidden", 2)
|
error("write access forbidden", 2)
|
||||||
|
|
|
@ -803,8 +803,16 @@ end
|
||||||
function conststruct(tab)
|
function conststruct(tab)
|
||||||
local strtab = { "struct {" }
|
local strtab = { "struct {" }
|
||||||
|
|
||||||
for member, val in pairs(tab) do
|
if (tab[1] ~= nil) then
|
||||||
strtab[#strtab+1] = "static const int "..member.."="..val..";"
|
-- e.g. { "KNEE", "PISTOL", ... } provided
|
||||||
|
for i=1,#tab do
|
||||||
|
strtab[#strtab+1] = "static const int "..tab[i].."="..(i-1)..";"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- e.g. { KNEE=0, PISTOL=1, ... } provided
|
||||||
|
for member, val in pairs(tab) do
|
||||||
|
strtab[#strtab+1] = "static const int "..member.."="..val..";"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
strtab[#strtab+1] = "}"
|
strtab[#strtab+1] = "}"
|
||||||
|
|
||||||
|
|
|
@ -246,6 +246,7 @@ gameevent
|
||||||
}
|
}
|
||||||
|
|
||||||
local D = require("CON.DEFS")
|
local D = require("CON.DEFS")
|
||||||
|
local WEAPON = gv.WEAPON
|
||||||
|
|
||||||
-- test event chaining
|
-- test event chaining
|
||||||
gameevent
|
gameevent
|
||||||
|
@ -264,7 +265,7 @@ gameevent
|
||||||
else
|
else
|
||||||
pistol.shoots = D.SHOTSPARK1
|
pistol.shoots = D.SHOTSPARK1
|
||||||
end
|
end
|
||||||
ps.weapon[gv.PISTOL_WEAPON].firesound = D.LIGHTNING_SLAP
|
ps.weapon[WEAPON.PISTOL].firesound = D.LIGHTNING_SLAP
|
||||||
|
|
||||||
-- This succeeds, because sound2time is a time, not a sound.
|
-- This succeeds, because sound2time is a time, not a sound.
|
||||||
ps.weapon.SHOTGUN.sound2time = 5000
|
ps.weapon.SHOTGUN.sound2time = 5000
|
||||||
|
@ -336,11 +337,11 @@ gameevent
|
||||||
|
|
||||||
local pl = player[0]
|
local pl = player[0]
|
||||||
-- MAX < current is "allowed"
|
-- MAX < current is "allowed"
|
||||||
pl.max_ammo_amount[gv.RPG_WEAPON] = 17
|
pl.max_ammo_amount[WEAPON.RPG] = 17
|
||||||
pl:give_weapon(gv.RPG_WEAPON)
|
pl:give_weapon(WEAPON.RPG)
|
||||||
pl.ammo_amount[gv.RPG_WEAPON] = 54
|
pl.ammo_amount[WEAPON.RPG] = 54
|
||||||
|
|
||||||
pl:give_weapon(gv.SHRINKER_WEAPON)
|
pl:give_weapon(WEAPON.SHRINKER)
|
||||||
-- This looks much prettier:
|
-- This looks much prettier:
|
||||||
pl.ammo_amount.SHRINKER = 2
|
pl.ammo_amount.SHRINKER = 2
|
||||||
|
|
||||||
|
@ -605,7 +606,7 @@ local function testbit(num, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
local FADE_SPEED = {
|
local FADE_SPEED = {
|
||||||
[gv.KNEE_WEAPON] = 1/2.5,
|
[WEAPON.KNEE] = 1/2.5,
|
||||||
|
|
||||||
1/128,
|
1/128,
|
||||||
1/5,
|
1/5,
|
||||||
|
@ -617,7 +618,7 @@ local FADE_SPEED = {
|
||||||
5,
|
5,
|
||||||
127, -- freezer; such a fast fade is not visible, but it clears any
|
127, -- freezer; such a fast fade is not visible, but it clears any
|
||||||
-- existing one (if of higher priority)
|
-- existing one (if of higher priority)
|
||||||
[gv.GROW_WEAPON] = 9.9, -- test banker's rouding -- should be like 10
|
[WEAPON.GROW] = 9.9, -- test banker's rouding -- should be like 10
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Test player[]:fadecol(), a better palfrom.
|
-- Test player[]:fadecol(), a better palfrom.
|
||||||
|
|
Loading…
Reference in a new issue