From 25108494d11ccdc8bbbd27dd02b2120839832d4e Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 20 Dec 2013 18:31:20 +0000 Subject: [PATCH] Lunatic: expose "con.shoot(tilenum, i [, zvel])". Document and add example. git-svn-id: https://svn.eduke32.com/eduke32@4201 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/control.lua | 8 +------- polymer/eduke32/source/lunatic/doc/lunatic.txt | 11 ++++++++++- polymer/eduke32/source/lunatic/lunacon.lua | 16 ++++++++-------- polymer/eduke32/source/lunatic/test.lua | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index b49e9a758..6f8648def 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -365,7 +365,7 @@ local int16_st = ffi.typeof "struct { int16_t s; }" -- out of the range for an int32_t and thus undefined behavior! local SHOOT_HARDCODED_ZVEL = tobit(0x80000000) -function _shoot(i, tilenum, zvel) +function shoot(tilenum, i, zvel) check_sprite_idx(i) check_sector_idx(ffiC.sprite[i].sectnum) -- accessed in A_ShootWithZvel check_tile_idx(tilenum) @@ -1068,12 +1068,6 @@ function _A_SpawnGlass(i, n) end end -function _A_Shoot(i, atwith) - check_sprite_idx(i) - check_tile_idx(atwith) - return CF.A_ShootWithZvel(i, atwith, SHOOT_HARDCODED_ZVEL) -end - function _A_IncurDamage(sn) check_sprite_idx(sn) return ffiC.A_IncurDamage(sn) diff --git a/polymer/eduke32/source/lunatic/doc/lunatic.txt b/polymer/eduke32/source/lunatic/doc/lunatic.txt index 27e0ee76b..87bf29737 100644 --- a/polymer/eduke32/source/lunatic/doc/lunatic.txt +++ b/polymer/eduke32/source/lunatic/doc/lunatic.txt @@ -1924,7 +1924,7 @@ exits.footnote:[This is subject to change and must not be relied on.] Otherwise, relevant per-sprite data for the newly inserted sprite is cleared. No additional ``hard-wired'' C code is run. -The return value is the index of the inserted sprite. +Returns the index of the inserted sprite. The function `con.insertsprite` is called with a single table whose values are taken as the actual arguments. The first three, `tilenum`, `pos` and `sectnum`, @@ -1964,6 +1964,15 @@ run afterwards, possibly modifying the sprite. Returns the index of the spawned sprite on success. +===== The function `con.shoot(tilenum, parentspritenum [, zvel])` + +Attempts to shoot a projectile with tile number `tilenum` from the sprite with +index `parentspritenum`. The z velocity can be overridden by passing `zvel`. + +// TODO: document how zvel is interpreted + +Returns the index of the spawned sprite on success, or -1 otherwise. + The `fs` module -- virtual file system facilities ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 19fccf203..cf8b79d64 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -2507,21 +2507,21 @@ local Cinner = { / ACS".timetosleep=%1", eshoot = cmd(D) - / "_gv.RETURN=_con._shoot(_aci,%1)", + / "_gv.RETURN=_con.shoot(%1,_aci)", eshootvar = cmd(R) - / "_gv.RETURN=_con._shoot(_aci,%1)", + / "_gv.RETURN=_con.shoot(%1,_aci)", ezshoot = cmd(R,D) - / "_gv.RETURN=_con._shoot(_aci,%2,%1)", + / "_gv.RETURN=_con.shoot(%2,_aci,%1)", ezshootvar = cmd(R,R) - / "_gv.RETURN=_con._shoot(_aci,%2,%1)", + / "_gv.RETURN=_con.shoot(%2,_aci,%1)", shoot = cmd(D) - / "_con._shoot(_aci,%1)", + / "_con.shoot(%1,_aci)", shootvar = cmd(R) - / "_con._shoot(_aci,%1)", + / "_con.shoot(%1,_aci)", zshoot = cmd(R,D) - / "_con._shoot(_aci,%2,%1)", + / "_con.shoot(%2,_aci,%1)", zshootvar = cmd(R,R) - / "_con._shoot(_aci,%2,%1)", + / "_con.shoot(%2,_aci,%1)", fall = cmd() / "actor.fall(_aci)", diff --git a/polymer/eduke32/source/lunatic/test.lua b/polymer/eduke32/source/lunatic/test.lua index 266606b44..237cbe486 100644 --- a/polymer/eduke32/source/lunatic/test.lua +++ b/polymer/eduke32/source/lunatic/test.lua @@ -650,6 +650,23 @@ gameactor end } +gameactor +{ + -- Innocent sign, similar to test/weaponvars.con actor 909 (tree trunk) + 1211, actor.FLAGS.replace_hard, + + function(aci, pli) + local a = actor[aci] + + if (a:get_count() >= 120) then + local i = con.spawn(D.TRANSPORTERSTAR, aci) + sprite[i].z = sprite[i].z - 1024*16 + con.shoot(D.MORTER, aci, -4096) + a:set_count(0) + end + end +} + local function testbit(num, b) return bit.band(num,b)~=0 and 1 or 0 end