diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 166c402ad..6b65a3a47 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -824,6 +824,8 @@ const memberlabel_t ActorLabels[]= { "ulotag", ACTOR_ULOTAG, 0, 0 }, { "uhitag", ACTOR_UHITAG, 0, 0 }, + { "isvalid", ACTOR_ISVALID, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST }; diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 3a639d868..cca295be3 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -518,6 +518,7 @@ enum ActorLabel_t ACTOR_ALPHA, ACTOR_ULOTAG, ACTOR_UHITAG, + ACTOR_ISVALID, ACTOR_END }; diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index d9e61e6bc..60b8402e2 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -2930,6 +2930,10 @@ static void __fastcall VM_GetSprite(int32_t lVar1, int32_t lLabelID, int32_t lVa Gv_SetVarX(lVar2, (uint8_t)(spriteext[iActor].alpha * 255.0f)); return; + case ACTOR_ISVALID: + Gv_SetVarX(lVar2, sprite[iActor].statnum != MAXSTATUS); + return; + default: return; } @@ -3553,6 +3557,7 @@ static int32_t __fastcall VM_AccessSpriteX(int32_t iActor, int32_t lLabelID, int case ACTOR_YPANNING: return spriteext[iActor].ypanning; case ACTOR_HTFLAGS: return actor[iActor].flags; case ACTOR_ALPHA: return (uint8_t)(spriteext[iActor].alpha*255.0f); + case ACTOR_ISVALID: return (sprite[iActor].statnum != MAXSTATUS); default: return -1; } diff --git a/polymer/eduke32/source/lunatic/con_lang.lua b/polymer/eduke32/source/lunatic/con_lang.lua index c245b8307..e2a30d97c 100644 --- a/polymer/eduke32/source/lunatic/con_lang.lua +++ b/polymer/eduke32/source/lunatic/con_lang.lua @@ -414,6 +414,8 @@ local ActorLabels = { -- Read access differs from write, write not available: alpha = { "_math.floor(spriteext[%s].alpha*255)", "spriteext[%s].alpha=(%%s)/255" }, + + isvalid = { "_con._isvalid(%s)" }, } local function spr2tspr(code) diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index c98eba603..3c438251d 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -1424,11 +1424,20 @@ function _cansee(aci, ps) return can end +function _isvalid(i) + check_sprite_idx(i) + return ffiC.sprite[i].statnum ~= ffiC.MAXSTATUS and 1 or 0 +end + function _canseespr(s1, s2) - local spr1, spr2 = sprite[s1], sprite[s2] + check_sprite_idx(s1) + check_sprite_idx(s2) + + local spr1, spr2 = ffiC.sprite[s1], ffiC.sprite[s2] -- Redundant, but points the error messages to the CON code: check_sector_idx(spr1.sectnum) check_sector_idx(spr2.sectnum) + return cansee(spr1, spr1.sectnum, spr2, spr2.sectnum) and 1 or 0 end