mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-14 08:30:58 +00:00
Lunatic: add actor methods allowing overriding action delay and move hvel/vvel.
Add testing code for an example actor 1275 (newspaper) to test.elua. git-svn-id: https://svn.eduke32.com/eduke32@3918 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
67db095bd3
commit
ebe0ecaded
5 changed files with 43 additions and 2 deletions
|
@ -7661,6 +7661,7 @@ PALONLY:
|
||||||
#else
|
#else
|
||||||
t->picnum += k + startframe + l*t_data3;
|
t->picnum += k + startframe + l*t_data3;
|
||||||
#endif
|
#endif
|
||||||
|
// XXX: t->picnum can be out-of-bounds by bad user code.
|
||||||
|
|
||||||
if (l > 0)
|
if (l > 0)
|
||||||
while (tilesizx[t->picnum] == 0 && t->picnum > 0)
|
while (tilesizx[t->picnum] == 0 && t->picnum > 0)
|
||||||
|
|
|
@ -598,6 +598,7 @@ GAMEEXEC_STATIC void VM_Move(void)
|
||||||
|
|
||||||
vm.g_t[0]++;
|
vm.g_t[0]++;
|
||||||
|
|
||||||
|
// If the move ID is zero, or the movflags are 0
|
||||||
if (vm.g_t[1] == 0 || a == 0)
|
if (vm.g_t[1] == 0 || a == 0)
|
||||||
{
|
{
|
||||||
if (deadflag || (actor[vm.g_i].bpos.x != vm.g_sp->x) || (actor[vm.g_i].bpos.y != vm.g_sp->y))
|
if (deadflag || (actor[vm.g_i].bpos.x != vm.g_sp->x) || (actor[vm.g_i].bpos.y != vm.g_sp->y))
|
||||||
|
|
|
@ -85,7 +85,7 @@ local function def_action_or_move(what, tab)
|
||||||
lastid[what] = lastid[what]-1
|
lastid[what] = lastid[what]-1
|
||||||
|
|
||||||
-- Pass args table to ffi.new, which can take either: a table with numeric
|
-- Pass args table to ffi.new, which can take either: a table with numeric
|
||||||
-- indices, or a table with key-value pairs.
|
-- indices, or a table with key-value pairs, *but not in combination*.
|
||||||
-- See http://luajit.org/ext_ffi_semantics.html#init_table
|
-- See http://luajit.org/ext_ffi_semantics.html#init_table
|
||||||
return am_ctype[what](lastid[what], tab)
|
return am_ctype[what](lastid[what], tab)
|
||||||
end
|
end
|
||||||
|
|
|
@ -982,6 +982,11 @@ local actor_mt = {
|
||||||
return ffi.cast(actor_ptr_ct, a).t_data[2]
|
return ffi.cast(actor_ptr_ct, a).t_data[2]
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
-- Override action delay. The action ID is kept.
|
||||||
|
set_action_delay = function(a, delay)
|
||||||
|
ffi.cast(actor_ptr_ct, a).ac.delay = delay
|
||||||
|
end,
|
||||||
|
|
||||||
-- move
|
-- move
|
||||||
set_move = function(a, mov, movflags)
|
set_move = function(a, mov, movflags)
|
||||||
a = ffi.cast(actor_ptr_ct, a)
|
a = ffi.cast(actor_ptr_ct, a)
|
||||||
|
@ -1017,6 +1022,15 @@ local actor_mt = {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
-- Override velocity, keeping move ID.
|
||||||
|
set_hvel = function(a, hvel)
|
||||||
|
ffi.cast(actor_ptr_ct, a).mv.hvel = hvel
|
||||||
|
end,
|
||||||
|
|
||||||
|
set_vvel = function(a, vvel)
|
||||||
|
ffi.cast(actor_ptr_ct, a).mv.vvel = vvel
|
||||||
|
end,
|
||||||
|
|
||||||
-- ai
|
-- ai
|
||||||
set_ai = function(a, ai)
|
set_ai = function(a, ai)
|
||||||
local oa = a
|
local oa = a
|
||||||
|
|
|
@ -395,9 +395,12 @@ local hs = stat.new()
|
||||||
local con = require("con")
|
local con = require("con")
|
||||||
local AC, MV = con.AC, con.MV
|
local AC, MV = con.AC, con.MV
|
||||||
|
|
||||||
|
local CAC, CMV, CAI = require("CON.ACTION"), require("CON.MOVE"), require("CON.AI")
|
||||||
|
assert(CAC); assert(CMV); assert(CAI)
|
||||||
|
|
||||||
local AC, MV = {}, {}
|
local AC, MV = {}, {}
|
||||||
|
|
||||||
AC.TROOPSTAND = con.action{0,1,5,1,1}
|
AC.TROOPSTAND = assert(CAC.ATROOPSTAND) -- or con.action{0,1,5,1,1}
|
||||||
AC.TROOPFLINTCH = con.action{50, 1, 1, 1, 6}
|
AC.TROOPFLINTCH = con.action{50, 1, 1, 1, 6}
|
||||||
MV.SHRUNKVELS = con.move{hvel=32}
|
MV.SHRUNKVELS = con.move{hvel=32}
|
||||||
con.ai(AC.TROOPFLINTCH, MV.SHRUNKVELS, 0) -- unused; TODO: test
|
con.ai(AC.TROOPFLINTCH, MV.SHRUNKVELS, 0) -- unused; TODO: test
|
||||||
|
@ -450,7 +453,29 @@ gameactor
|
||||||
con.killit()
|
con.killit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (actr:has_action(CAC.ATROOPWALKING)) then
|
||||||
|
if (actr:get_count() % 50 == 0) then
|
||||||
|
spr.hitag = bit.bxor(spr.hitag, actor.MOVFLAGS.spin)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
gameactor
|
||||||
|
{
|
||||||
|
1275, -- newspaper, E4L6 sprite #513
|
||||||
|
|
||||||
|
-- XXX: I want to write "{0, 4, delay=20}"
|
||||||
|
action = con.action{0, 4, 1, 1, 20},
|
||||||
|
move = con.move{}, -- so that the ID is nonzero
|
||||||
|
|
||||||
|
func = function(aci)
|
||||||
|
local delay = math.sin(0.1 * 2*math.pi*gv.totalclock/120)
|
||||||
|
actor[aci]:set_action_delay(20 + 10*delay)
|
||||||
|
actor[aci]:set_hvel(50*delay)
|
||||||
|
sprite[aci].hitag = actor.MOVFLAGS.geth
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
gameevent
|
gameevent
|
||||||
|
|
Loading…
Reference in a new issue