Merge branch 'character-nightsattack' into 'next'

Draw Character in NiGHTS Attack

See merge request STJr/SRB2!2175
This commit is contained in:
sphere 2024-01-11 12:11:54 +00:00
commit 4ae2482283
4 changed files with 62 additions and 7 deletions

View file

@ -54,7 +54,8 @@ enum skin {
skin_contspeed,
skin_contangle,
skin_soundsid,
skin_sprites
skin_sprites,
skin_natkcolor
};
static const char *const skin_opt[] = {
@ -94,6 +95,7 @@ static const char *const skin_opt[] = {
"contangle",
"soundsid",
"sprites",
"natkcolor",
NULL};
#define UNIMPLEMENTED luaL_error(L, LUA_QL("skin_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", skin_opt[field])
@ -218,6 +220,9 @@ static int skin_get(lua_State *L)
case skin_sprites:
LUA_PushUserdata(L, skin->sprites, META_SKINSPRITES);
break;
case skin_natkcolor:
lua_pushinteger(L, skin->natkcolor);
break;
}
return 1;
}

View file

@ -5980,14 +5980,14 @@ static void M_DrawNightsAttackBackground(void)
}
// NiGHTS Attack floating Super Sonic.
static patch_t *ntssupersonic[2];
/*static patch_t *ntssupersonic[2];
static void M_DrawNightsAttackSuperSonic(void)
{
const UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_YELLOW, GTC_CACHE);
INT32 timer = FixedInt(ntsatkdrawtimer/4) % 2;
angle_t fa = (FixedAngle((FixedInt(ntsatkdrawtimer * 4) % 360)<<FRACBITS)>>ANGLETOFINESHIFT) & FINEMASK;
V_DrawFixedPatch(235<<FRACBITS, (120<<FRACBITS) - (8*FINESINE(fa)), FRACUNIT, 0, ntssupersonic[timer], colormap);
}
}*/
static void M_DrawLevelPlatterMenu(void)
{
@ -10346,7 +10346,52 @@ void M_DrawNightsAttackMenu(void)
}
// Super Sonic
M_DrawNightsAttackSuperSonic();
//M_DrawNightsAttackSuperSonic();
//Draw selected character's NiGHTS sprite
patch_t *NightsAttackSprite; //The patch for the sprite itself
INT32 spritetimer; //Timer for animating NiGHTS sprite
INT32 flags; //Flag var for checking if the sprite needs to be flipped
INT32 skinnumber; //Number for skin
INT32 color; //natkcolor
const UINT8 *colormap = NULL; //Colormap var for coloring the sprite
if (skins[cv_chooseskin.value-1].sprites[SPR2_NFLY].numframes == 0) //If we don't have NiGHTS sprites
skinnumber = 0; //Default to Sonic
else
skinnumber = (cv_chooseskin.value-1);
spritedef_t *sprdef = &skins[skinnumber].sprites[SPR2_NFLY]; //Make our patch the selected character's NFLY sprite
spritetimer = FixedInt(ntsatkdrawtimer/2) % skins[skinnumber].sprites[SPR2_NFLY].numframes; //Make the sprite timer cycle though all the frames at 2 tics per frame
spriteframe_t *sprframe = &sprdef->spriteframes[spritetimer]; //Our animation frame is equal to the number on the timer
NightsAttackSprite = W_CachePatchNum(sprframe->lumppat[6], PU_PATCH); //Draw the right facing angle
if (skins[skinnumber].natkcolor) //If you set natkcolor use it
color = skins[skinnumber].natkcolor;
else if ((skins[skinnumber].flags & SF_SUPER) && !(skins[skinnumber].flags & SF_NONIGHTSSUPER)) //If you go super in NiGHTS, use supercolor
color = skins[skinnumber].supercolor+4;
else //If you don't go super in NiGHTS or at all, use prefcolor
color = skins[skinnumber].prefcolor;
colormap = R_GetTranslationColormap(TC_BLINK, color, GTC_CACHE); //Make the sprite color be our prefcolor
angle_t fa = (FixedAngle(((FixedInt(ntsatkdrawtimer * 4)) % 360)<<FRACBITS)>>ANGLETOFINESHIFT) & FINEMASK;
if (sprframe->flip & 1<<6) //If our sprite is supposed to be flipped
flags = V_FLIP; //Flip it
else
flags = 0;
V_DrawFixedPatch((270<<FRACBITS), ((186<<FRACBITS) - (8*FINESINE(fa))), FixedDiv(skins[skinnumber].highresscale, skins[skinnumber].shieldscale), flags, NightsAttackSprite, colormap); //Draw the sprite
//End of NiGHTS sprite drawing
//if (P_HasGrades(cv_nextmap.value, 0))
// V_DrawScaledPatch(235 - (((ngradeletters[bestoverall])->width)*3)/2, 135, 0, ngradeletters[bestoverall]);
@ -10438,8 +10483,8 @@ static void M_NightsAttack(INT32 choice)
// This is really just to make sure Sonic is the played character, just in case
M_PatchSkinNameTable();
ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH);
ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH);
//ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH);
//ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH);
G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching
titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please

View file

@ -144,6 +144,8 @@ static void Sk_SetDefaultValue(skin_t *skin)
skin->contspeed = 17;
skin->contangle = 0;
skin->natkcolor = SKINCOLOR_NONE;
for (i = 0; i < sfx_skinsoundslot0; i++)
if (S_sfx[i].skinsound != -1)
skin->soundsid[S_sfx[i].skinsound] = i;
@ -588,7 +590,6 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value)
UINT16 color = R_GetSuperColorByName(value);
skin->supercolor = (color ? color : SKINCOLOR_SUPERGOLD1);
}
#define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value));
GETFLOAT(jumpfactor)
GETFLOAT(highresscale)
@ -629,6 +630,9 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value)
GETFLAG(NOSHIELDABILITY)
#undef GETFLAG
else if (!stricmp(stoken, "natkcolor"))
skin->natkcolor = R_GetColorByName(value); // SKINCOLOR_NONE is allowed here
else // let's check if it's a sound, otherwise error out
{
boolean found = false;

View file

@ -71,6 +71,7 @@ typedef struct
UINT16 prefcolor;
UINT16 supercolor;
UINT16 prefoppositecolor; // if 0 use tables instead
UINT16 natkcolor; //Color for Nights Attack Menu
fixed_t highresscale; // scale of highres, default is 0.5
UINT8 contspeed; // continue screen animation speed