mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Pass RETURN to EVENT_DAMAGEHPLANE in the 'dist' arg to allow chained callbacks.
git-svn-id: https://svn.eduke32.com/eduke32@4208 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
fa6746867c
commit
02e0929ca7
3 changed files with 32 additions and 10 deletions
|
@ -2242,19 +2242,27 @@ cheat give a different ``full'' amount. A negative value is ignored.
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Triggered when a ceiling or a floor (collectively called ``hplane'') is
|
Triggered when a ceiling or a floor (collectively called ``hplane'') is
|
||||||
determined as being damaged. The event receives `RETURN` as a value that can be
|
determined as being damaged. The event receives `RETURN` in the variable
|
||||||
decoded into two parts by passing it to `sector.damagehplane_whatsect`:
|
`gv.RETURN` as well as the third, `dist` argument to the event
|
||||||
|
<<gameactor,callback function>>.footnote:[Passing `RETURN` in the `dist`
|
||||||
|
argument serves the possibility to create chained callbacks for
|
||||||
|
`EVENT_DAMAGEHPLANE`. Otherwise, once `gv.RETURN` were assigned to, there would
|
||||||
|
be no way to obtain its original value in subsequent chained callbacks.] This
|
||||||
|
value can be decoded into two parts by passing it to
|
||||||
|
`sector.damagehplane_whatsect`:
|
||||||
|
|
||||||
[source]
|
[source]
|
||||||
----------
|
----------
|
||||||
local what, sectnum = sector.damagehplane_whatsect(gv.RETURN)
|
function(aci, pli, RETURN)
|
||||||
|
local what, sectnum = sector.damagehplane_whatsect(RETURN)
|
||||||
|
-- (...)
|
||||||
----------
|
----------
|
||||||
Then,
|
Then,
|
||||||
|
|
||||||
* `what` is one of the strings `'ceiling'` or `'floor'` and
|
* `what` is one of the strings `'ceiling'` or `'floor'` and
|
||||||
* `sectnum` is the sector whose hplane is considered to be damaged.
|
* `sectnum` is the sector whose hplane is considered to be damaged.
|
||||||
|
|
||||||
When `EVENT_DAMAGEHPLANE` is left, `RETURN` is examined to determine the
|
When `EVENT_DAMAGEHPLANE` is left, `gv.RETURN` is examined to determine the
|
||||||
further action. It may be one of three values given by `sector.DAMAGEHPLANE`
|
further action. It may be one of three values given by `sector.DAMAGEHPLANE`
|
||||||
(abbreviated `DHP` in the following):
|
(abbreviated `DHP` in the following):
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,10 @@ local DHP = sector.DAMAGEHPLANE
|
||||||
|
|
||||||
gameevent
|
gameevent
|
||||||
{
|
{
|
||||||
gv.EVENT_DAMAGEHPLANE,
|
"DAMAGEHPLANE",
|
||||||
|
|
||||||
function(aci, pli, dist)
|
function(aci, pli, RETURN)
|
||||||
local what, sectnum = sector.damagehplane_whatsect(gv.RETURN)
|
local what, sectnum = sector.damagehplane_whatsect(RETURN)
|
||||||
local sec = sector[sectnum]
|
local sec = sector[sectnum]
|
||||||
|
|
||||||
-- Part I: make various screens breakable when it's a ceiling picnum.
|
-- Part I: make various screens breakable when it's a ceiling picnum.
|
||||||
|
@ -71,10 +71,22 @@ gameevent
|
||||||
if (sec.ceilingpicnum >= 263 and sec.ceilingpicnum <= 275) then
|
if (sec.ceilingpicnum >= 263 and sec.ceilingpicnum <= 275) then
|
||||||
sec:set_ceilingpicnum(D.W_SCREENBREAK + gv.krand()%3)
|
sec:set_ceilingpicnum(D.W_SCREENBREAK + gv.krand()%3)
|
||||||
gv.RETURN = DHP.GLASSBREAK
|
gv.RETURN = DHP.GLASSBREAK
|
||||||
return
|
return con.longjmp()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
gv.RETURN = DHP.DEFAULT
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
gameevent
|
||||||
|
{
|
||||||
|
"DAMAGEHPLANE",
|
||||||
|
|
||||||
|
function(aci, pli, RETURN)
|
||||||
|
local what, sectnum = sector.damagehplane_whatsect(RETURN)
|
||||||
|
local sec = sector[sectnum]
|
||||||
|
|
||||||
-- Part II: breakable TROR hplanes
|
-- Part II: breakable TROR hplanes
|
||||||
local cf = sec[what]
|
local cf = sec[what]
|
||||||
-- printf("damage %s of sector %d (pic %d, bunch %d, hittable: %s)", what, sectnum,
|
-- printf("damage %s of sector %d (pic %d, bunch %d, hittable: %s)", what, sectnum,
|
||||||
|
@ -90,7 +102,7 @@ gameevent
|
||||||
breaker.extra = cf.bunch
|
breaker.extra = cf.bunch
|
||||||
|
|
||||||
gv.RETURN = DHP.SUPPRESS
|
gv.RETURN = DHP.SUPPRESS
|
||||||
return
|
return con.longjmp()
|
||||||
end
|
end
|
||||||
|
|
||||||
gv.RETURN = DHP.DEFAULT
|
gv.RETURN = DHP.DEFAULT
|
||||||
|
|
|
@ -1880,7 +1880,9 @@ int32_t Sect_DamageCeilingOrFloor(int32_t floorp, int32_t sn)
|
||||||
int32_t i, j;
|
int32_t i, j;
|
||||||
|
|
||||||
const int32_t RETURN_in = floorp ? 131072+sn : 65536+sn;
|
const int32_t RETURN_in = floorp ? 131072+sn : 65536+sn;
|
||||||
int32_t ret = VM_OnEvent(EVENT_DAMAGEHPLANE, g_player[screenpeek].ps->i, screenpeek, -1, RETURN_in);
|
// NOTE: pass RETURN in the dist argument, too.
|
||||||
|
int32_t ret = VM_OnEvent(EVENT_DAMAGEHPLANE, g_player[screenpeek].ps->i, screenpeek,
|
||||||
|
RETURN_in, RETURN_in);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue