Objectplace improvements:

- movement speeds are scaled with player scale
- spawned objects are scaled with player scale
- command accepts argument for thing num to set
This commit is contained in:
lachwright 2020-09-06 17:28:34 +09:30
parent 4959aa5614
commit d7ab41a90b
3 changed files with 75 additions and 59 deletions

View File

@ -1023,8 +1023,8 @@ static void OP_CycleThings(INT32 amt)
states[S_OBJPLACE_DUMMY].frame = states[mobjinfo[op_currentthing].spawnstate].frame;
}
if (players[0].mo->eflags & MFE_VERTICALFLIP) // correct z when flipped
players[0].mo->z += players[0].mo->height - mobjinfo[op_currentthing].height;
players[0].mo->height = mobjinfo[op_currentthing].height;
players[0].mo->z += players[0].mo->height - FixedMul(mobjinfo[op_currentthing].height, players[0].mo->scale);
players[0].mo->height = FixedMul(mobjinfo[op_currentthing].height, players[0].mo->scale);
P_SetPlayerMobjState(players[0].mo, S_OBJPLACE_DUMMY);
op_currentdoomednum = mobjinfo[op_currentthing].doomednum;
@ -1107,6 +1107,7 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c
mt->angle = (INT16)(FixedInt(AngleFixed(player->mo->angle)));
mt->options = (mt->z << ZSHIFT) | (UINT16)cv_opflags.value;
mt->scale = player->mo->scale;
return mt;
}
@ -1305,19 +1306,19 @@ void OP_ObjectplaceMovement(player_t *player)
ticmiss++;
if (cmd->buttons & BT_JUMP)
player->mo->z += FRACUNIT*cv_speed.value;
player->mo->z += player->mo->scale*cv_speed.value;
else if (cmd->buttons & BT_SPIN)
player->mo->z -= FRACUNIT*cv_speed.value;
player->mo->z -= player->mo->scale*cv_speed.value;
if (cmd->forwardmove != 0)
{
P_Thrust(player->mo, player->mo->angle, (cmd->forwardmove*FRACUNIT/MAXPLMOVE)*cv_speed.value);
P_Thrust(player->mo, player->mo->angle, (cmd->forwardmove*player->mo->scale/MAXPLMOVE)*cv_speed.value);
P_TeleportMove(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z);
player->mo->momx = player->mo->momy = 0;
}
if (cmd->sidemove != 0)
{
P_Thrust(player->mo, player->mo->angle-ANGLE_90, (cmd->sidemove*FRACUNIT/MAXPLMOVE)*cv_speed.value);
P_Thrust(player->mo, player->mo->angle-ANGLE_90, (cmd->sidemove*player->mo->scale/MAXPLMOVE)*cv_speed.value);
P_TeleportMove(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z);
player->mo->momx = player->mo->momy = 0;
}
@ -1443,6 +1444,8 @@ void Command_ObjectPlace_f(void)
G_SetGameModified(multiplayer);
// Entering objectplace?
if (!objectplacing || COM_Argc() > 1)
{
if (!objectplacing)
{
objectplacing = true;
@ -1499,6 +1502,17 @@ void Command_ObjectPlace_f(void)
}
else
op_oldstate = (statenum_t)(players[0].mo->state-states);
}
if (COM_Argc() > 1)
{
UINT16 mapthingnum = atoi(COM_Argv(1));
mobjtype_t type = P_GetMobjtype(mapthingnum);
if (type == MT_UNKNOWN)
CONS_Printf(M_GetText("No mobj type delegated to thing type %d.\n"), mapthingnum);
else
op_currentthing = type;
}
// If no thing set, then cycle a little
if (!op_currentthing)
@ -1506,8 +1520,8 @@ void Command_ObjectPlace_f(void)
op_currentthing = 1;
OP_CycleThings(1);
}
else // Cycle things sets this for the former.
players[0].mo->height = mobjinfo[op_currentthing].height;
else
OP_CycleThings(0); // sets all necessary height values without cycling op_currentthing
P_SetPlayerMobjState(players[0].mo, S_OBJPLACE_DUMMY);
}

View File

@ -274,6 +274,8 @@ extern tic_t itemrespawntime[ITEMQUESIZE];
extern size_t iquehead, iquetail;
extern consvar_t cv_gravity, cv_movebob;
mobjtype_t P_GetMobjtype(UINT16 mthingtype);
void P_RespawnSpecials(void);
mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);

View File

@ -11249,7 +11249,7 @@ void P_PrecipitationEffects(void)
* \param mthingtype Mapthing number in question.
* \return Mobj type; MT_UNKNOWN if nothing found.
*/
static mobjtype_t P_GetMobjtype(UINT16 mthingtype)
mobjtype_t P_GetMobjtype(UINT16 mthingtype)
{
mobjtype_t i;
for (i = 0; i < NUMMOBJTYPES; i++)