Allow using localskins for any kind of mobj from lua

This commit is contained in:
indev committed 2023-11-28 01:46:28 +03:00
1 parent 3610096c35
commit c2ddac2c1e
3 files changed
+36 -9

No files matched your search

+1 -1
View File
@@ -5558,7 +5558,7 @@ void HWR_ProjectSprite(mobj_t *thing)
rot = thing->frame&FF_FRAMEMASK;
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
if (thing->skin && thing->sprite == SPR_PLAY)
if ((thing->skin || thing->localskin) && thing->sprite == SPR_PLAY)
{
sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef;
#ifdef ROTSPRITE
+34 -7
View File
@@ -217,7 +217,7 @@ UNIMPLEMENTED(mobjnum)
// For some dumb reason it is valid to set sloperoll, even though it is read
// only
int mobj_sloperoll_noop(lua_State *L) { return 0; }
int mobj_sloperoll_noop(lua_State *L) { (void)L; return 0; }
// Now other getters/setters with arbitary logic
@@ -415,13 +415,40 @@ int mobj_localskin_setter(lua_State *L)
{
mobj_t *mo = GETMO();
// TODO - add ability to set localskin to non-player mobjs
// Will probably just need to reimplement SetLocalPlayerSkin as something
// like SetLocalObjectSkin
if (!mo->player)
return luaL_error(L, "mobj.localskin can't be set for non-player mobjs!");
if (mo->player)
{
SetLocalPlayerSkin(mo->player - players, luaL_checkstring(L, 2), NULL);
}
else
{
INT32 i;
char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
strlcpy(skin, luaL_checkstring(L, 2), sizeof skin);
strlwr(skin); // all skin names are lowercase
// Try localskins
for (i = 0; i < numlocalskins; i++)
{
if (stricmp(localskins[i].name, skin) == 0)
{
mo->localskin = &localskins[i];
mo->skinlocal = true;
return 0;
}
}
// Try other skins
for (i = 0; i < numskins; i++)
{
if (fastcmp(skins[i].name, skin))
{
mo->localskin = &skins[i];
mo->skinlocal = false;
return 0;
}
}
}
SetLocalPlayerSkin(mo->player - players, luaL_checkstring(L, 2), NULL);
return 0;
}
+1 -1
View File
@@ -1399,7 +1399,7 @@ static void R_ProjectSprite(mobj_t *thing)
rot = thing->frame&FF_FRAMEMASK;
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
if (thing->skin && thing->sprite == SPR_PLAY)
if ((thing->skin || thing->localskin) && thing->sprite == SPR_PLAY)
{
sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef;
#ifdef ROTSPRITE