Actor ST1 handling: cleanup part 2. DONT_BUILD.

Factor out condition for whether a z offset is added or not
("fix for flying/jumping monsters getting stuck in water", etc.) into
a function A_GetWaterZOffset() (and a helper A_GetVerticalVel()).

git-svn-id: https://svn.eduke32.com/eduke32@4954 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2015-02-05 16:30:12 +00:00
parent 36c3fd9216
commit c0d45ef1ec

View file

@ -920,6 +920,46 @@ static int32_t VM_AddWeapon(int32_t weap, int32_t amount, DukePlayer_t *ps)
}
#endif
static int32_t A_GetVerticalVel(const actor_t *ac)
{
#ifdef LUNATIC
return ac->mv.vvel;
#else
int32_t moveScriptOfs = AC_MOVE_ID(ac->t_data);
if ((unsigned)moveScriptOfs < (unsigned)g_scriptSize-1)
return script[moveScriptOfs + 1];
else
return 0;
#endif
}
static int32_t A_GetWaterZOffset(int spritenum)
{
const spritetype *const sp = &sprite[spritenum];
const actor_t *const ac = &actor[spritenum];
if (sector[sp->sectnum].lotag == ST_1_ABOVE_WATER)
{
switch (DYNAMICTILEMAP(sp->picnum))
{
case OCTABRAIN__STATIC:
case COMMANDER__STATIC:
case DRONE__STATIC:
return 0;
}
// fix for flying/jumping monsters getting stuck in water
if ((AC_MOVFLAGS(sp, ac) & jumptoplayer_only) ||
(G_HaveActor(sp->picnum) && A_GetVerticalVel(ac) != 0))
return 0;
return ACTOR_ONWATER_ADDZ;
}
return 0;
}
static void VM_Fall(int32_t g_i, spritetype *g_sp)
{
int32_t grav = g_spriteGravity;
@ -990,38 +1030,7 @@ static void VM_Fall(int32_t g_i, spritetype *g_sp)
if (sector[g_sp->sectnum].lotag == ST_1_ABOVE_WATER)
{
switch (DYNAMICTILEMAP(g_sp->picnum))
{
case OCTABRAIN__STATIC:
case COMMANDER__STATIC:
case DRONE__STATIC:
break;
default:
{
#if !defined LUNATIC
int32_t moveScriptOfs = AC_MOVE_ID(vm.g_t);
#endif
// fix for flying/jumping monsters getting stuck in water
if ((AC_MOVFLAGS(g_sp, &actor[vm.g_i]) & jumptoplayer_only) ||
(G_HaveActor(g_sp->picnum) &&
#if !defined LUNATIC
(unsigned)moveScriptOfs < (unsigned)g_scriptSize-1 && script[moveScriptOfs + 1] != 0
#else
actor[g_i].mv.vvel != 0
#endif
))
{
break;
}
z += ACTOR_ONWATER_ADDZ;
break;
}
}
g_sp->z = z;
g_sp->z = z + A_GetWaterZOffset(g_i);
return;
}