Merge pull request #183 from MontyTRC89/CrouchRoll

Enable the crouch roll animation
This commit is contained in:
Wuups 2020-05-06 00:07:22 -05:00 committed by GitHub
commit 8a478d0157
2 changed files with 71 additions and 2 deletions

View file

@ -121,7 +121,7 @@ void(*lara_control_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* co
lara_void_func,
lara_as_deathslide,
lara_as_duck,
lara_as_duck,
lara_as_crouch_roll,
lara_as_dash,
lara_as_dashdive,
lara_as_hang2,
@ -5130,7 +5130,7 @@ void lara_as_duck(ITEM_INFO* item, COLL_INFO* coll)//14688, 14738 (F)
&& !(Rooms[roomNum].flags & ENV_FLAG_WATER))
{
if ((item->animNumber == ANIMATION_LARA_CROUCH_IDLE
if ((item->animNumber == ANIMATION_LARA_CROUCH_IDLE
|| item->animNumber == ANIMATION_LARA_CROUCH_PREPARE)
&& !(TrInput & IN_FLARE || TrInput & IN_DRAW)
&& (Lara.gunType != WEAPON_FLARE || Lara.flareAge < 900 && Lara.flareAge != 0))
@ -5140,9 +5140,76 @@ void lara_as_duck(ITEM_INFO* item, COLL_INFO* coll)//14688, 14738 (F)
item->goalAnimState = STATE_LARA_CRAWL_IDLE;
}
}
else
/*crouch roll*/
if ((TrInput & IN_SPRINT) //maybe change this roll? or jump?
&& (TrInput & IN_DUCK || Lara.keepDucked)
&& Lara.gunStatus == LG_NO_ARMS
&& Lara.waterStatus != LW_WADE
&& !(Rooms[roomNum].flags & ENV_FLAG_WATER)) //is this necessary?
{
lara_as_crouch_roll(item, coll);
}
}
void lara_as_crouch_roll(ITEM_INFO* item, COLL_INFO* coll)
{
/*stop Lara from doing it in these conditions to avoid trouble*/
if (LaraFloorFront(item, item->pos.yRot, 1024) >= 512 || //4 clicks away from holes in the floor
TestWall(item, 1024, 0, -640)) //4 clicks away from walls
{
return;
}
/*do actual anim*/
if ((item->animNumber == ANIMATION_LARA_CROUCH_IDLE //)
|| item->animNumber == ANIMATION_LARA_CROUCH_PREPARE) // not exactly necessary but makes gameplay much faster, make optional in the future.
&& !(TrInput & IN_FLARE || TrInput & IN_DRAW) //avoids some flare spawning/wep stuff
&& (Lara.gunType != WEAPON_FLARE || Lara.flareAge < 900 && Lara.flareAge != 0))
{
Lara.torsoYrot = 0;
Lara.torsoXrot = 0;
lara_col_crouch_roll(item, coll);
item->currentAnimState = STATE_LARA_CROUCH_ROLL;
item->goalAnimState = STATE_LARA_CROUCH_IDLE;
item->animNumber = ANIMATION_LARA_CROUCH_ROLL_FORWARD_BEGIN;
item->frameNumber = Anims[ANIMATION_LARA_CROUCH_ROLL_FORWARD_BEGIN].frameBase; //fix it being slow
}
}
void lara_col_crouch_roll(ITEM_INFO* item, COLL_INFO* coll)
{
if (item->hitPoints <= 0)
{
item->goalAnimState = STATE_LARA_CROUCH_IDLE;
return;
}
Lara.isDucked = true;
item->gravityStatus = false;
item->fallspeed = 0;
Lara.moveAngle = item->pos.yRot;
coll->facing = item->pos.yRot;
coll->badPos = STEPUP_HEIGHT;
coll->badNeg = -STEPUP_HEIGHT;
coll->badCeiling = 0;
coll->slopesAreWalls = true;
GetLaraCollisionInfo(item, coll);
ShiftItem(item, coll);
item->pos.yPos += coll->midFloor;
}
void lara_col_ducklr(ITEM_INFO* item, COLL_INFO* coll)//14534, 145E4 (F)
{
// FIXED

View file

@ -283,6 +283,8 @@ void lara_col_all4s(ITEM_INFO* item, COLL_INFO* coll);
void lara_as_all4s(ITEM_INFO* item, COLL_INFO* coll);
void lara_col_duck(ITEM_INFO* item, COLL_INFO* coll);
void lara_as_duck(ITEM_INFO* item, COLL_INFO* coll);
void lara_as_crouch_roll(ITEM_INFO* item, COLL_INFO* coll);
void lara_col_crouch_roll(ITEM_INFO* item, COLL_INFO* coll);
void lara_col_ducklr(ITEM_INFO* item, COLL_INFO* coll);
void lara_as_duckr(ITEM_INFO* item, COLL_INFO* coll);
void lara_as_duckl(ITEM_INFO* item, COLL_INFO* coll);