mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
Lunatic: various tweaks and fixes.
- fix getv movflags handling in VM_Move() - add actor.fall() - LunaCON: sanity-check some action members git-svn-id: https://svn.eduke32.com/eduke32@3924 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
cb2edcf45e
commit
253a13ed29
5 changed files with 45 additions and 28 deletions
|
@ -656,7 +656,7 @@ dead:
|
|||
if (movflags&getv) vm.g_sp->zvel += ((*(moveptr+1)<<4)-vm.g_sp->zvel)>>1;
|
||||
#else
|
||||
if (movflags&geth) vm.g_sp->xvel += (actor[vm.g_i].mv.hvel - vm.g_sp->xvel)>>1;
|
||||
if (movflags&getv) vm.g_sp->zvel += (actor[vm.g_i].mv.vvel - vm.g_sp->zvel)>>1;
|
||||
if (movflags&getv) vm.g_sp->zvel += (16*actor[vm.g_i].mv.vvel - vm.g_sp->zvel)>>1;
|
||||
#endif
|
||||
|
||||
if (movflags&dodgebullet && !deadflag)
|
||||
|
|
|
@ -174,6 +174,7 @@ local check_tile_idx = bcheck.tile_idx
|
|||
local check_sprite_idx = bcheck.sprite_idx
|
||||
local check_player_idx = bcheck.player_idx
|
||||
local check_sound_idx = bcheck.sound_idx
|
||||
local check_number = bcheck.number
|
||||
local check_type = bcheck.type
|
||||
|
||||
-- Will contain [<label>]=number mappings after CON translation.
|
||||
|
@ -184,7 +185,7 @@ local function krandand(mask)
|
|||
return bit.band(ffiC.krand(), mask)
|
||||
end
|
||||
|
||||
local function check_isnumber(...)
|
||||
local function check_allnumbers(...)
|
||||
local vals = {...}
|
||||
for i=1,#vals do
|
||||
assert(type(vals[i])=="number")
|
||||
|
@ -261,7 +262,7 @@ function insertsprite(tab_or_tilenum, ...)
|
|||
|
||||
check_tile_idx(tilenum)
|
||||
check_sector_idx(sectnum)
|
||||
check_isnumber(shade, xrepeat, yrepeat, ang, xvel, zvel, owner)
|
||||
check_allnumbers(shade, xrepeat, yrepeat, ang, xvel, zvel, owner)
|
||||
|
||||
if (statnum >= ffiC.MAXSTATUS+0ULL) then
|
||||
error("invalid 'statnum' argument to insertsprite: must be a status number (0 .. MAXSTATUS-1)", 2)
|
||||
|
@ -999,11 +1000,6 @@ function _A_IncurDamage(sn)
|
|||
return ffiC.A_IncurDamage(sn)
|
||||
end
|
||||
|
||||
function _VM_FallSprite(i)
|
||||
check_sprite_idx(i)
|
||||
CF.VM_FallSprite(i)
|
||||
end
|
||||
|
||||
function _sizeto(i, xr, yr)
|
||||
local spr = sprite[i]
|
||||
local dr = (xr-spr.xrepeat)
|
||||
|
@ -1895,16 +1891,9 @@ end
|
|||
|
||||
-- Common serialization function for gamearray and actorvar.
|
||||
local function serialize_array(ar, strtab, maxnum)
|
||||
-- if (ffiC._DEBUG_LUNATIC ~= 0) then
|
||||
-- Iterate in numeric order. XXX: also for non-debug?
|
||||
for i=0,maxnum-1 do
|
||||
serialize_value(strtab, i, rawget(ar, i))
|
||||
end
|
||||
-- else
|
||||
-- for i,v in pairs(ar) do
|
||||
-- serialize_value(strtab, i, v)
|
||||
-- end
|
||||
-- end
|
||||
for i=0,maxnum-1 do
|
||||
serialize_value(strtab, i, rawget(ar, i))
|
||||
end
|
||||
|
||||
strtab[#strtab+1] = "})"
|
||||
|
||||
|
@ -2076,8 +2065,8 @@ local gamearray_methods = {
|
|||
_get_require = our_get_require,
|
||||
|
||||
_serialize = function(gar)
|
||||
local strtab = { "_ga(", tostring(gar._size), ",{" }
|
||||
gar:_cleanup()
|
||||
local strtab = { "_ga(", tostring(gar._size), ",{" }
|
||||
return serialize_array(gar, strtab, gar._size)
|
||||
end,
|
||||
}
|
||||
|
@ -2137,7 +2126,7 @@ end
|
|||
local actorvar_methods = {
|
||||
--- Internal routines ---
|
||||
|
||||
-- * All values for sprite not in the game world are cleared.
|
||||
-- * All values for sprites not in the game world are cleared.
|
||||
-- * All values equal to the default one are cleared.
|
||||
_cleanup = function(acv)
|
||||
for i=0,ffiC.MAXSPRITES-1 do
|
||||
|
@ -2156,10 +2145,10 @@ local actorvar_methods = {
|
|||
_get_require = our_get_require,
|
||||
|
||||
_serialize = function(acv)
|
||||
local strtab = { "_av(", tostring(acv._defval), ",{" }
|
||||
-- NOTE: We also clean up when spawning a sprite, too. (See
|
||||
-- A_ResetVars() and related functions above.)
|
||||
acv:_cleanup()
|
||||
local strtab = { "_av(", tostring(acv._defval), ",{" }
|
||||
return serialize_array(acv, strtab, ffiC.MAXSPRITES)
|
||||
end,
|
||||
}
|
||||
|
@ -2177,6 +2166,7 @@ local actorvar_mt = {
|
|||
|
||||
__newindex = function(acv, idx, val)
|
||||
check_sprite_idx(idx)
|
||||
check_number(val)
|
||||
rawset(acv, idx, val)
|
||||
end,
|
||||
|
||||
|
@ -2216,6 +2206,7 @@ local playervar_mt = {
|
|||
|
||||
__newindex = function(plv, idx, val)
|
||||
check_player_idx(idx)
|
||||
check_number(val)
|
||||
rawset(plv, idx, val)
|
||||
end,
|
||||
|
||||
|
|
|
@ -850,6 +850,11 @@ do
|
|||
}
|
||||
end
|
||||
|
||||
function actor_static_members.fall(i)
|
||||
check_sprite_idx(i)
|
||||
CF.VM_FallSprite(i)
|
||||
end
|
||||
|
||||
-- Delete sprite with index <i>.
|
||||
function actor_static_members.delete(i)
|
||||
check_sprite_idx(i)
|
||||
|
@ -1052,7 +1057,8 @@ local actor_mt = {
|
|||
oa:set_action(ai.act)
|
||||
oa:set_move(ai.mov, ai.movflags)
|
||||
|
||||
a.t_data[0] = 0
|
||||
-- Already reset with set_move():
|
||||
-- a.t_data[0] = 0
|
||||
end,
|
||||
|
||||
has_ai = function(a, ai)
|
||||
|
@ -1215,8 +1221,7 @@ local player_mt = {
|
|||
end
|
||||
end,
|
||||
|
||||
-- XXX: is the correct spelling "whack"?
|
||||
wack = function(p, no_return_to_center)
|
||||
whack = function(p, no_return_to_center)
|
||||
p.horiz = p.horiz + 64
|
||||
if (not no_return_to_center) then
|
||||
p.return_to_center = 9
|
||||
|
|
|
@ -783,6 +783,8 @@ local function check_reserved_bits(flags, allowedbits, suffix)
|
|||
end
|
||||
end
|
||||
|
||||
Define.ALLOWED_VIEWTYPE = truetab { 0, 1, 3,4, 5, 7, 8, -5, -7 }
|
||||
|
||||
function Define.composite(labeltype, identifier, ...)
|
||||
local oldtype = g_labeltype[identifier]
|
||||
local oldval = g_labeldef[identifier]
|
||||
|
@ -821,6 +823,20 @@ function Define.composite(labeltype, identifier, ...)
|
|||
check_reserved_bits(args[LABEL.AI], 4096+2047, "for ai's movflags")
|
||||
end
|
||||
|
||||
if (labeltype == LABEL.ACTION) then
|
||||
-- Sanity-check action members.
|
||||
-- TODO: con.action(), too.
|
||||
if (not (args[2] >= 0)) then
|
||||
errprintf("action \"%s\" has negative number of frames", identifier)
|
||||
end
|
||||
if (Define.ALLOWED_VIEWTYPE[args[3]] == nil) then
|
||||
errprintf("action \"%s\" has disallowed viewtype %d", identifier, args[3])
|
||||
end
|
||||
if (not (args[4] >= -1 and args[4] <= 1)) then
|
||||
warnprintf("action \"%s\" has incval different from -1, 0 or 1", identifier)
|
||||
end
|
||||
end
|
||||
|
||||
-- Make a string out of that.
|
||||
for i=1+(isai and 2 or 0),#args do
|
||||
args[i] = format("%d", args[i])
|
||||
|
@ -2247,7 +2263,7 @@ local Cinner = {
|
|||
/ "_con._shoot(_aci,%2,%1)",
|
||||
|
||||
fall = cmd()
|
||||
/ "_con._VM_FallSprite(_aci)",
|
||||
/ "actor.fall(_aci)",
|
||||
flash = cmd()
|
||||
/ format("_con._flash(%s,%s)", SPS"", PLS""),
|
||||
getlastpal = cmd()
|
||||
|
@ -2275,7 +2291,7 @@ local Cinner = {
|
|||
tossweapon = cmd()
|
||||
/ "", -- TODO_MP
|
||||
wackplayer = cmd()
|
||||
/ PLS":wack()",
|
||||
/ PLS":whack()",
|
||||
|
||||
-- player/sprite searching
|
||||
findplayer = cmd(W)
|
||||
|
|
|
@ -473,8 +473,13 @@ gameactor
|
|||
local a = actor[aci]
|
||||
local delay = math.sin(0.1 * 2*math.pi*gv.totalclock/120)
|
||||
a:set_action_delay(20 + 10*delay)
|
||||
a:set_hvel(50*delay)
|
||||
a.movflags = actor.MOVFLAGS.geth
|
||||
if (sprite[aci].pal ~= 0) then
|
||||
a:set_hvel(1024/30)
|
||||
a:set_vvel(-1024/30)
|
||||
else
|
||||
a:set_hvel(50*delay)
|
||||
end
|
||||
a.movflags = actor.MOVFLAGS.geth + actor.MOVFLAGS.getv
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue