New S_SKIN attributes.

* radius - sets the player's radius for that skin.
* height - sets the player's normal height for that skin.
* spinheight - sets the player's spinheight for that skin.
* shieldscale - see http://i.imgur.com/BQ5DhKC.png for justification
This commit is contained in:
toasterbabe 2016-07-13 15:15:45 +01:00
parent 8087cde5db
commit c2aba46298
6 changed files with 61 additions and 10 deletions

View File

@ -44,6 +44,10 @@ enum skin {
skin_accelstart,
skin_acceleration,
skin_jumpfactor,
skin_radius,
skin_height,
skin_spinheight,
skin_shieldscale,
skin_starttranscolor,
skin_prefcolor,
skin_highresscale,
@ -74,6 +78,10 @@ static const char *const skin_opt[] = {
"accelstart",
"acceleration",
"jumpfactor",
"radius",
"height",
"spinheight",
"shieldscale",
"starttranscolor",
"prefcolor",
"highresscale",
@ -173,6 +181,18 @@ static int skin_get(lua_State *L)
case skin_jumpfactor:
lua_pushfixed(L, skin->jumpfactor);
break;
case skin_radius:
lua_pushfixed(L, skin->radius);
break;
case skin_height:
lua_pushfixed(L, skin->height);
break;
case skin_spinheight:
lua_pushfixed(L, skin->spinheight);
break;
case skin_shieldscale:
lua_pushfixed(L, skin->shieldscale);
break;
case skin_starttranscolor:
lua_pushinteger(L, skin->starttranscolor);
break;

View File

@ -119,6 +119,7 @@ extern consvar_t cv_cam2_speed, cv_cam2_rotate, cv_cam2_rotspeed;
extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate;
extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate;
fixed_t P_GetPlayerRadius(player_t *player);
fixed_t P_GetPlayerHeight(player_t *player);
fixed_t P_GetPlayerSpinHeight(player_t *player);
INT32 P_GetPlayerControlDirection(player_t *player);

View File

@ -6097,7 +6097,7 @@ static boolean P_ShieldLook(mobj_t *thing, shieldtype_t shield)
thing->flags |= MF_NOCLIPHEIGHT;
thing->eflags = (thing->eflags & ~MFE_VERTICALFLIP)|(thing->target->eflags & MFE_VERTICALFLIP);
P_SetScale(thing, thing->target->scale);
P_SetScale(thing, FixedMul(thing->target->scale, skins[thing->target->player->skin].shieldscale));
P_UnsetThingPosition(thing);
thing->x = thing->target->x;
thing->y = thing->target->y;

View File

@ -1296,6 +1296,17 @@ void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative)
mo->momz = value;
}
//
// P_GetPlayerRadius
//
// Returns the radius
// of the player.
//
fixed_t P_GetPlayerRadius(player_t *player)
{
return FixedMul(skins[player->skin].radius, player->mo->scale);
}
//
// P_GetPlayerHeight
//
@ -1304,7 +1315,7 @@ void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative)
//
fixed_t P_GetPlayerHeight(player_t *player)
{
return FixedMul(player->mo->info->height, player->mo->scale);
return FixedMul(skins[player->skin].height, player->mo->scale);
}
//
@ -1315,7 +1326,7 @@ fixed_t P_GetPlayerHeight(player_t *player)
//
fixed_t P_GetPlayerSpinHeight(player_t *player)
{
return FixedMul(FixedMul(player->mo->info->height, player->mo->scale),2*FRACUNIT/3);
return FixedMul(skins[player->skin].spinheight, player->mo->scale);
}
//
@ -6536,8 +6547,8 @@ static void P_MovePlayer(player_t *player)
|| ((((player->charflags & SF_NOJUMPSPIN) && (player->pflags & PF_JUMPED) && player->panim == PA_JUMP))
&& (P_MobjFlip(player->mo)*player->mo->momz < 0 || player->pflags & PF_THOKKED)))
P_SetPlayerMobjState(player->mo, S_PLAY_FALL);
// If Springing but on the ground, change back!
else if (onground && (player->panim == PA_SPRING || player->panim == PA_FALL || player->panim == PA_RIDE) && !player->mo->momz)
// If doing an air animation but on the ground, change back!
else if (onground && (player->panim == PA_SPRING || player->panim == PA_FALL || player->panim == PA_RIDE || player->panim == PA_JUMP) && !player->mo->momz)
P_SetPlayerMobjState(player->mo, S_PLAY_STND);
// If you are stopped and are still walking, stand still!
@ -6996,6 +7007,7 @@ static void P_MovePlayer(player_t *player)
player->mo->height = P_GetPlayerSpinHeight(player);
else
player->mo->height = P_GetPlayerHeight(player);
player->mo->radius = P_GetPlayerRadius(player);
if (player->mo->eflags & MFE_VERTICALFLIP && player->mo->height != oldheight) // adjust z height for reverse gravity, similar to how it's done for scaling
player->mo->z -= player->mo->height - oldheight;

View File

@ -2300,6 +2300,12 @@ static void Sk_SetDefaultValue(skin_t *skin)
skin->mindash = 15<<FRACBITS;
skin->maxdash = 90<<FRACBITS;
skin->radius = mobjinfo[MT_PLAYER].radius;
skin->height = mobjinfo[MT_PLAYER].height;
skin->spinheight = FixedMul(skin->height, 2*FRACUNIT/3);
skin->shieldscale = FRACUNIT;
skin->thokitem = -1;
skin->spinitem = -1;
skin->revitem = -1;
@ -2545,7 +2551,7 @@ void R_AddSkins(UINT16 wadnum)
value2[stringspace - 1] = '\0';
if (R_SkinAvailable(value2) == -1)
// I'm lazy so if NEW name is already used I leave the 'skin x'
- // default skin name set in Sk_SetDefaultValue
// default skin name set in Sk_SetDefaultValue
STRBUFCPY(skin->name, value2);
Z_Free(value2);
}
@ -2620,6 +2626,9 @@ void R_AddSkins(UINT16 wadnum)
GETSPEED(mindash)
GETSPEED(maxdash)
GETSPEED(actionspd)
GETSPEED(radius)
GETSPEED(height)
GETSPEED(spinheight)
#undef GETSPEED
#define GETINT(field) else if (!stricmp(stoken, #field)) skin->field = atoi(value);
@ -2652,10 +2661,13 @@ void R_AddSkins(UINT16 wadnum)
else if (!stricmp(stoken, "prefcolor"))
skin->prefcolor = R_GetColorByName(value);
else if (!stricmp(stoken, "jumpfactor"))
skin->jumpfactor = FLOAT_TO_FIXED(atof(value));
else if (!stricmp(stoken, "highresscale"))
skin->highresscale = FLOAT_TO_FIXED(atof(value));
#define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value));
GETFLOAT(jumpfactor)
GETFLOAT(highresscale)
GETFLOAT(shieldscale)
#undef GETFLOAT
else // let's check if it's a sound, otherwise error out
{
boolean found = false;

View File

@ -93,6 +93,12 @@ typedef struct
fixed_t jumpfactor; // multiple of standard jump height
fixed_t radius; // Bounding box changes.
fixed_t height;
fixed_t spinheight;
fixed_t shieldscale; // no change to bounding box, but helps set the shield's sprite size
// Definable color translation table
UINT8 starttranscolor;
UINT8 prefcolor;