mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Lunatic: swap con.insetsprite's 4th and 5th positional arguments.
git-svn-id: https://svn.eduke32.com/eduke32@4218 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3cef7cccc0
commit
2900144e22
5 changed files with 63 additions and 37 deletions
|
@ -266,22 +266,20 @@ end
|
|||
-- the engine "insertsprite".
|
||||
--
|
||||
-- Forms:
|
||||
-- 1. table-call: insertsprite{tilenum, pos, sectnum [, owner [, statnum]] [, key=val...]}
|
||||
-- 1. table-call: insertsprite{tilenum, pos, sectnum [, statnum [, owner]] [, key=val...]}
|
||||
-- valid keys are: owner, statnum, shade, xrepeat, yrepeat, xvel, zvel
|
||||
-- 2. position-call: insertsprite(tilenum, pos, sectnum [, owner [, statnum]])
|
||||
-- 2. position-call: insertsprite(tilenum, pos, sectnum [, statnum [, owner]])
|
||||
function insertsprite(tab_or_tilenum, ...)
|
||||
local tilenum, pos, sectnum -- mandatory
|
||||
-- optional with defaults:
|
||||
-- TODO: swap order of owner and statnum?
|
||||
-- XXX: owner -1 valid???
|
||||
local owner, statnum
|
||||
local shade, xrepeat, yrepeat, ang, xvel, zvel = 0, 48, 48, 0, 0, 0
|
||||
|
||||
if (type(tab_or_tilenum)=="table") then
|
||||
local tab = tab_or_tilenum
|
||||
tilenum, pos, sectnum = unpack(tab, 1, 3)
|
||||
owner = tab[4] or tab.owner or -1
|
||||
statnum = tab[5] or tab.statnum or 0
|
||||
statnum = tab[4] or tab.statnum or 0
|
||||
owner = tab[5] or tab.owner or -1
|
||||
shade = tab.shade or shade
|
||||
xrepeat = tab.xrepeat or xrepeat
|
||||
yrepeat = tab.yrepeat or yrepeat
|
||||
|
@ -292,8 +290,8 @@ function insertsprite(tab_or_tilenum, ...)
|
|||
tilenum = tab_or_tilenum
|
||||
local args = {...}
|
||||
pos, sectnum = unpack(args, 1, 2)
|
||||
owner = args[3] or -1
|
||||
statnum = args[4] or 0
|
||||
statnum = args[3] or 0
|
||||
owner = args[4] or -1
|
||||
end
|
||||
|
||||
if (type(sectnum)~="number" or type(tilenum) ~= "number") then
|
||||
|
@ -303,6 +301,9 @@ function insertsprite(tab_or_tilenum, ...)
|
|||
check_tile_idx(tilenum)
|
||||
check_sector_idx(sectnum)
|
||||
check_allnumbers(shade, xrepeat, yrepeat, ang, xvel, zvel, owner)
|
||||
if (owner ~= -1) then
|
||||
check_sprite_idx(owner)
|
||||
end
|
||||
|
||||
if (not (statnum >= 0 and statnum < ffiC.MAXSTATUS)) then
|
||||
error("invalid 'statnum' argument to insertsprite: must be a status number [0 .. MAXSTATUS-1]", 2)
|
||||
|
@ -310,9 +311,13 @@ function insertsprite(tab_or_tilenum, ...)
|
|||
|
||||
A_ResetVarsNextIns()
|
||||
|
||||
return CF.A_InsertSprite(sectnum, pos.x, pos.y, pos.z, tilenum,
|
||||
shade, xrepeat, yrepeat, ang, xvel, zvel,
|
||||
owner, statnum)
|
||||
local i = CF.A_InsertSprite(sectnum, pos.x, pos.y, pos.z, tilenum,
|
||||
shade, xrepeat, yrepeat, ang, xvel, zvel,
|
||||
owner, statnum)
|
||||
if (owner == -1) then
|
||||
ffiC.sprite[i]:_set_owner(i)
|
||||
end
|
||||
return i
|
||||
end
|
||||
|
||||
-- INTERNAL USE ONLY.
|
||||
|
@ -353,7 +358,7 @@ function _spawnmany(ow, label, n)
|
|||
local spr = sprite[ow]
|
||||
|
||||
for i=n,1, -1 do
|
||||
local j = insertsprite{ tilenum, spr^(ffiC.krand()%(47*256)), spr.sectnum, ow, 5,
|
||||
local j = insertsprite{ tilenum, spr^(ffiC.krand()%(47*256)), spr.sectnum, 5, ow,
|
||||
shade=-32, xrepeat=8, yrepeat=8, ang=krandand(2047) }
|
||||
_spawnexisting(j)
|
||||
sprite[j].cstat = krandand(8+4)
|
||||
|
@ -1025,7 +1030,7 @@ function _A_DoGuts(i, gutstile, n)
|
|||
|
||||
for i=n,1, -1 do
|
||||
local pos = vec3(spr.x+krandand(255)-128, spr.y+krandand(255)-128, z-krandand(8191))
|
||||
local j = insertsprite{ gutstile, pos, spr.sectnum, i, 5, shade=-32, xrepeat=xsz, yrepeat=ysz,
|
||||
local j = insertsprite{ gutstile, pos, spr.sectnum, 5, i, shade=-32, xrepeat=xsz, yrepeat=ysz,
|
||||
ang=krandand(2047), xvel=48+krandand(31), zvel=-512-krandand(2047) }
|
||||
local newspr = sprite[j]
|
||||
if (ispic(newspr.picnum, "JIBS2")) then
|
||||
|
@ -1048,7 +1053,7 @@ function _debris(i, dtile, n)
|
|||
local isblimpscrap = (ispic(spr.picnum, "BLIMP") and ispic(dtile, "SCRAP1"))
|
||||
local picofs = isblimpscrap and 0 or krandand(3)
|
||||
local pos = spr + vec3(krandand(255)-128, krandand(255)-128, -(8*256)-krandand(8191))
|
||||
local jj = insertsprite{ dtile+picofs, pos, spr.sectnum, i, 5,
|
||||
local jj = insertsprite{ dtile+picofs, pos, spr.sectnum, 5, i,
|
||||
shade=spr.shade, xrepeat=32+krandand(15), yrepeat=32+krandand(15),
|
||||
ang=krandand(2047), xvel=32+krandand(127), zvel=-krandand(2047) }
|
||||
-- NOTE: BlimpSpawnSprites[14] (its array size is 15) will never be chosen
|
||||
|
@ -1062,7 +1067,7 @@ function _A_SpawnGlass(i, n)
|
|||
local spr = sprite[i]
|
||||
|
||||
for j=n,1, -1 do
|
||||
local k = insertsprite{ D.GLASSPIECES+n%3, spr^(256*krandand(16)), spr.sectnum, i, 5,
|
||||
local k = insertsprite{ D.GLASSPIECES+n%3, spr^(256*krandand(16)), spr.sectnum, 5, i,
|
||||
shade=krandand(15), xrepeat=36, yrepeat=36, ang=krandand(2047),
|
||||
xvel=32+krandand(63), zvel=-512-krandand(2047) }
|
||||
sprite[k].pal = spr.pal
|
||||
|
|
|
@ -1946,7 +1946,7 @@ In Lunatic, there are two functions that insert a sprite into the game world.
|
|||
They mainly differ in how they are used, and to which extent they imply
|
||||
``hard-coded'' behavior.
|
||||
|
||||
===== The function `con.insertsprite{tilenum, pos, sectnum [, owner [, statnum]] [key=val...]}`
|
||||
===== The function `con.insertsprite{tilenum, pos, sectnum [, statnum [, owner]] [key=val...]}`
|
||||
|
||||
Inserts a new sprite into the game with the properties given as input
|
||||
arguments. If the world already contains the maximum number of sprites
|
||||
|
@ -1957,11 +1957,26 @@ cleared. No additional ``hard-wired'' C code is run.
|
|||
|
||||
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`,
|
||||
are passed positionally. All other input arguments are passed as key-value
|
||||
pairs, but `owner` and `statnum` may be provided in both forms (but only one
|
||||
form in one call).
|
||||
The function `con.insertsprite` can be used in one of two forms:
|
||||
|
||||
* In the `table-call` form specified above, a single table is passed whose
|
||||
values are taken as the actual arguments. The first three, `tilenum`, `pos` and
|
||||
`sectnum`, are passed positionally. All other input arguments are passed as
|
||||
key-value pairs, but `owner` and `statnum` may be provided either positionally
|
||||
or as key/value pair.
|
||||
|
||||
* Passing only the three to five positional arguments is also directly
|
||||
possible. For example, all of the following calls are equivalent:
|
||||
+
|
||||
[source]
|
||||
----------
|
||||
local i = con.insertsprite(tile, pos, sect, stat, ow) -- direct-call
|
||||
local i = con.insertsprite{tile, pos, sect, stat, ow} -- table-call
|
||||
local i = con.insertsprite{tile, pos, sect, statnum=stat, owner=ow} -- table-call with 2 k/v args
|
||||
local i = con.insertsprite{tile, pos, sect, stat, owner=ow} -- table-call with one k/v arg
|
||||
----------
|
||||
|
||||
The five main arguments are as follows:
|
||||
|
||||
`[1]` (`tilenum`)::
|
||||
The tile number of the sprite to insert.
|
||||
|
@ -1972,18 +1987,18 @@ The position at which to insert the sprite (anything indexable with `x`, `y` and
|
|||
`[3]` (`sectnum`)::
|
||||
The index of the sector in which to insert the sprite.
|
||||
|
||||
`[4] owner` (default: --1)::
|
||||
The index of the sprite that is in some sense the ``parent'' of the newly
|
||||
created one.
|
||||
|
||||
`[5] statnum` (default: `actor.STAT.DEFAULT`)::
|
||||
`[4] statnum` (default: `actor.STAT.DEFAULT`)::
|
||||
The initial status number of the inserted sprite.
|
||||
|
||||
The following additional keys are permissible as input arguments, corresponding
|
||||
to the same-named <<sprite,`sprite`>> members:
|
||||
`shade`, `xrepeat` (default: 48), `yrepeat` (default: 48), `ang`, `xvel`,
|
||||
`zvel`. All optional arguments passed this way except for `xrepeat` and
|
||||
`yrepeat` default to 0.
|
||||
`[5] owner` (default: see below)::
|
||||
The index of the sprite that is in some sense the ``parent'' of the newly
|
||||
created one. If omitted, it is set to the index of the newly spawned sprite.
|
||||
|
||||
These keys are permissible as optional input arguments in the table-call form,
|
||||
corresponding to the same-named <<sprite,`sprite`>> members:
|
||||
|
||||
* `shade`, `ang`, `xvel`, `zvel` (default: 0)
|
||||
* `xrepeat` and `yrepeat` (default: 48)
|
||||
|
||||
===== The function `con.spawn(tilenum, parentspritenum)`
|
||||
|
||||
|
|
|
@ -92,10 +92,16 @@ gameevent
|
|||
end
|
||||
---[[
|
||||
if (vol==1 and lev==8) then
|
||||
print('tweaking bunch 1');
|
||||
-- trueror1.map
|
||||
for i, what in sectorsofbunch(1, gv.BOTH_CF) do
|
||||
sector[i][what].z = sector[i][what].z - 3*1024;
|
||||
local havebunch = false
|
||||
for i=0,gv.numsectors-1 do
|
||||
havebunch = havebunch or (sector[i].ceilingbunch >= 0)
|
||||
end
|
||||
if (havebunch) then
|
||||
print('tweaking bunch 1');
|
||||
-- trueror1.map
|
||||
for i, what in sectorsofbunch(1, gv.BOTH_CF) do
|
||||
sector[i][what].z = sector[i][what].z - 3*1024;
|
||||
end
|
||||
end
|
||||
end
|
||||
--]]
|
||||
|
|
|
@ -94,7 +94,7 @@ gameevent
|
|||
|
||||
if (cf.bunch >= 0 and (cf.picnum==198 or cf.picnum==D.GLASS2) and
|
||||
cf.statbits:test(sector.STAT.HITSCAN)) then
|
||||
local bi = con.insertsprite(TROR_GLASSBREAKER, wall[sec.wallptr], sectnum, aci, actor.STAT.ACTOR)
|
||||
local bi = con.insertsprite(TROR_GLASSBREAKER, wall[sec.wallptr], sectnum, actor.STAT.ACTOR)
|
||||
local breaker = sprite[bi]
|
||||
|
||||
breaker.cstat = sprite.CSTAT.INVISIBLE
|
||||
|
|
|
@ -130,7 +130,7 @@ gameactor
|
|||
local circvec = xmath.vec3(0, v.x, 16*v.y):rotate(spr.ang)
|
||||
local pos = spr^(zofs + radius) + 256*bangvec(spr.ang) + circvec
|
||||
|
||||
con.insertsprite{D.TRANSPORTERSTAR+4, pos, spr.sectnum, aci, actor.STAT.ACTOR,
|
||||
con.insertsprite{D.TRANSPORTERSTAR+4, pos, spr.sectnum, actor.STAT.ACTOR, aci,
|
||||
xrepeat=3, yrepeat=3, ang=spr.ang}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue