mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Move a few mobj spawn defaults to its own function
This commit is contained in:
parent
24ba782144
commit
6f9c48a305
3 changed files with 46 additions and 71 deletions
|
@ -279,6 +279,7 @@ 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);
|
||||
void P_SetMobjSpawnDefaults(mobj_t *mobj);
|
||||
|
||||
void P_RecalcPrecipInSector(sector_t *sector);
|
||||
void P_PrecipitationEffects(void);
|
||||
|
|
76
src/p_mobj.c
76
src/p_mobj.c
|
@ -10438,44 +10438,11 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
|||
mobj->x = x;
|
||||
mobj->y = y;
|
||||
|
||||
mobj->radius = info->radius;
|
||||
mobj->height = info->height;
|
||||
mobj->flags = info->flags;
|
||||
|
||||
mobj->health = (info->spawnhealth ? info->spawnhealth : 1);
|
||||
|
||||
mobj->reactiontime = info->reactiontime;
|
||||
|
||||
mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer
|
||||
|
||||
// do not set the state with P_SetMobjState,
|
||||
// because action routines can not be called yet
|
||||
st = &states[info->spawnstate];
|
||||
|
||||
mobj->state = st;
|
||||
mobj->tics = st->tics;
|
||||
mobj->sprite = st->sprite;
|
||||
mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits..
|
||||
P_SetupStateAnimation(mobj, st);
|
||||
|
||||
mobj->friction = ORIG_FRICTION;
|
||||
|
||||
mobj->movefactor = FRACUNIT;
|
||||
|
||||
// All mobjs are created at 100% scale.
|
||||
mobj->scale = FRACUNIT;
|
||||
mobj->destscale = mobj->scale;
|
||||
mobj->scalespeed = FRACUNIT/12;
|
||||
|
||||
// TODO: Make this a special map header
|
||||
if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN))
|
||||
mobj->destscale = FRACUNIT/2;
|
||||
|
||||
// Sprite rendering
|
||||
mobj->blendmode = AST_TRANSLUCENT;
|
||||
mobj->spritexscale = mobj->spriteyscale = mobj->scale;
|
||||
mobj->spritexoffset = mobj->spriteyoffset = 0;
|
||||
mobj->floorspriteslope = NULL;
|
||||
P_SetMobjSpawnDefaults(mobj);
|
||||
|
||||
// set subsector and/or block links
|
||||
P_SetThingPosition(mobj);
|
||||
|
@ -10785,6 +10752,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
|||
mobj->frame &= ~FF_FRAMEMASK;
|
||||
}
|
||||
|
||||
st = &states[info->spawnstate];
|
||||
|
||||
// Call action functions when the state is set
|
||||
if (st->action.acp1 && (mobj->flags & MF_RUNSPAWNFUNC))
|
||||
{
|
||||
|
@ -10815,6 +10784,45 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
|||
return mobj;
|
||||
}
|
||||
|
||||
void P_SetMobjSpawnDefaults(mobj_t *mobj)
|
||||
{
|
||||
const mobjinfo_t *info = mobj->info;
|
||||
state_t *st = &states[info->spawnstate];
|
||||
|
||||
mobj->radius = info->radius;
|
||||
mobj->height = info->height;
|
||||
mobj->flags = info->flags;
|
||||
|
||||
mobj->health = (info->spawnhealth ? info->spawnhealth : 1);
|
||||
|
||||
mobj->reactiontime = info->reactiontime;
|
||||
|
||||
mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer
|
||||
|
||||
// do not set the state with P_SetMobjState,
|
||||
// because action routines can not be called yet
|
||||
mobj->state = st;
|
||||
mobj->tics = st->tics;
|
||||
mobj->sprite = st->sprite;
|
||||
mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits..
|
||||
P_SetupStateAnimation(mobj, st);
|
||||
|
||||
mobj->friction = ORIG_FRICTION;
|
||||
|
||||
mobj->movefactor = FRACUNIT;
|
||||
|
||||
// All mobjs are created at 100% scale.
|
||||
mobj->scale = FRACUNIT;
|
||||
mobj->destscale = mobj->scale;
|
||||
mobj->scalespeed = FRACUNIT/12;
|
||||
|
||||
// Sprite rendering
|
||||
mobj->blendmode = AST_TRANSLUCENT;
|
||||
mobj->spritexscale = mobj->spriteyscale = mobj->scale;
|
||||
mobj->spritexoffset = mobj->spriteyoffset = 0;
|
||||
mobj->floorspriteslope = NULL;
|
||||
}
|
||||
|
||||
static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
||||
{
|
||||
state_t *st;
|
||||
|
|
|
@ -2692,7 +2692,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
|
|||
}
|
||||
mobj->type = i;
|
||||
}
|
||||
|
||||
mobj->info = &mobjinfo[mobj->type];
|
||||
P_SetMobjSpawnDefaults(mobj);
|
||||
|
||||
if (diff & MD_POS)
|
||||
{
|
||||
mobj->x = READFIXED(save_p);
|
||||
|
@ -2718,35 +2721,21 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
|
|||
|
||||
if (diff & MD_RADIUS)
|
||||
mobj->radius = READFIXED(save_p);
|
||||
else
|
||||
mobj->radius = mobj->info->radius;
|
||||
if (diff & MD_HEIGHT)
|
||||
mobj->height = READFIXED(save_p);
|
||||
else
|
||||
mobj->height = mobj->info->height;
|
||||
if (diff & MD_FLAGS)
|
||||
mobj->flags = READUINT32(save_p);
|
||||
else
|
||||
mobj->flags = mobj->info->flags;
|
||||
if (diff & MD_FLAGS2)
|
||||
mobj->flags2 = READUINT32(save_p);
|
||||
if (diff & MD_HEALTH)
|
||||
mobj->health = READINT32(save_p);
|
||||
else
|
||||
mobj->health = mobj->info->spawnhealth;
|
||||
if (diff & MD_RTIME)
|
||||
mobj->reactiontime = READINT32(save_p);
|
||||
else
|
||||
mobj->reactiontime = mobj->info->reactiontime;
|
||||
|
||||
if (diff & MD_STATE)
|
||||
mobj->state = &states[READUINT16(save_p)];
|
||||
else
|
||||
mobj->state = &states[mobj->info->spawnstate];
|
||||
if (diff & MD_TICS)
|
||||
mobj->tics = READINT32(save_p);
|
||||
else
|
||||
mobj->tics = mobj->state->tics;
|
||||
if (diff & MD_SPRITE) {
|
||||
mobj->sprite = READUINT16(save_p);
|
||||
if (mobj->sprite == SPR_PLAY)
|
||||
|
@ -2762,11 +2751,6 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
|
|||
mobj->frame = READUINT32(save_p);
|
||||
mobj->anim_duration = READUINT16(save_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
mobj->frame = mobj->state->frame;
|
||||
mobj->anim_duration = (UINT16)mobj->state->var2;
|
||||
}
|
||||
if (diff & MD_EFLAGS)
|
||||
mobj->eflags = READUINT16(save_p);
|
||||
if (diff & MD_PLAYER)
|
||||
|
@ -2783,20 +2767,14 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
|
|||
mobj->threshold = READINT32(save_p);
|
||||
if (diff & MD_LASTLOOK)
|
||||
mobj->lastlook = READINT32(save_p);
|
||||
else
|
||||
mobj->lastlook = -1;
|
||||
if (diff & MD_TARGET)
|
||||
mobj->target = (mobj_t *)(size_t)READUINT32(save_p);
|
||||
if (diff & MD_TRACER)
|
||||
mobj->tracer = (mobj_t *)(size_t)READUINT32(save_p);
|
||||
if (diff & MD_FRICTION)
|
||||
mobj->friction = READFIXED(save_p);
|
||||
else
|
||||
mobj->friction = ORIG_FRICTION;
|
||||
if (diff & MD_MOVEFACTOR)
|
||||
mobj->movefactor = READFIXED(save_p);
|
||||
else
|
||||
mobj->movefactor = FRACUNIT;
|
||||
if (diff & MD_FUSE)
|
||||
mobj->fuse = READINT32(save_p);
|
||||
if (diff & MD_WATERTOP)
|
||||
|
@ -2805,16 +2783,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
|
|||
mobj->waterbottom = READFIXED(save_p);
|
||||
if (diff & MD_SCALE)
|
||||
mobj->scale = READFIXED(save_p);
|
||||
else
|
||||
mobj->scale = FRACUNIT;
|
||||
if (diff & MD_DSCALE)
|
||||
mobj->destscale = READFIXED(save_p);
|
||||
else
|
||||
mobj->destscale = mobj->scale;
|
||||
if (diff2 & MD2_SCALESPEED)
|
||||
mobj->scalespeed = READFIXED(save_p);
|
||||
else
|
||||
mobj->scalespeed = FRACUNIT/12;
|
||||
if (diff2 & MD2_CUSVAL)
|
||||
mobj->cusval = READINT32(save_p);
|
||||
if (diff2 & MD2_CVMEM)
|
||||
|
@ -2845,16 +2817,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
|
|||
mobj->renderflags = READUINT32(save_p);
|
||||
if (diff2 & MD2_BLENDMODE)
|
||||
mobj->blendmode = READINT32(save_p);
|
||||
else
|
||||
mobj->blendmode = AST_TRANSLUCENT;
|
||||
if (diff2 & MD2_SPRITEXSCALE)
|
||||
mobj->spritexscale = READFIXED(save_p);
|
||||
else
|
||||
mobj->spritexscale = FRACUNIT;
|
||||
if (diff2 & MD2_SPRITEYSCALE)
|
||||
mobj->spriteyscale = READFIXED(save_p);
|
||||
else
|
||||
mobj->spriteyscale = FRACUNIT;
|
||||
if (diff2 & MD2_SPRITEXOFFSET)
|
||||
mobj->spritexoffset = READFIXED(save_p);
|
||||
if (diff2 & MD2_SPRITEYOFFSET)
|
||||
|
|
Loading…
Reference in a new issue