Skip to content

Commit

Permalink
#368 GBA fix shotgun
Browse files Browse the repository at this point in the history
  • Loading branch information
XProger committed Jul 31, 2021
1 parent b5e52c8 commit 78e5947
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/platform/gba/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ void drawLaraNodes(const Item* lara, const AnimFrame* frameA)
node++;
if (arm->useBasis) { // hands are rotated relative to the basis
matrixSetBasis(matrixGet(), basis);
matrixRotateYXZ(arm->angle.x, arm->angle.y, arm->angle.z);
}
matrixRotateYXZ(arm->angle.x, arm->angle.y, arm->angle.z);
matrixFrame(vec3s(0, 0, 0), anglesArm[i]++);
drawMesh(*mesh++);

Expand Down Expand Up @@ -495,8 +495,8 @@ void drawLaraNodesLerp(const Item* lara, const AnimFrame* frameA, const AnimFram
node++;
if (arm->useBasis) { // hands are rotated relative to the basis
matrixSetBasis(matrixGet(), basis);
matrixRotateYXZ(arm->angle.x, arm->angle.y, arm->angle.z);
}
matrixRotateYXZ(arm->angle.x, arm->angle.y, arm->angle.z);

bool useLerp = frameRateArm[i] > 1; // armed hands always use frameRate == 1 (i.e. useLerp == false)

Expand Down
44 changes: 25 additions & 19 deletions src/platform/gba/lara.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ const WeaponParams weaponParams[WEAPON_MAX] = {
0, // flashOffset
0, // flashTimer
0, // flashIntensity
ANGLE(60), // aimX
ANGLE(55), // aimX
ANGLE(60), // aimY
ANGLE(80), // armX
ANGLE(-60), // armMinY
ANGLE(170), // armMaxY
ANGLE(65), // armX
ANGLE(-80), // armMinY
ANGLE(80), // armMaxY
},
};

Expand Down Expand Up @@ -3397,15 +3397,17 @@ struct Lara : Item
void weaponUpdateShotgun()
{
ExtraInfoLara::Arm &R = extraL->armR;
ExtraInfoLara::Arm &L = extraL->armL;

vec3s &H = extraL->head.angle;
vec3s &T = extraL->torso.angle;

weaponAim(R);

if (R.aim)
{
T.x = R.angle.x >> 1;
T.y = R.angle.y >> 1;
T.x = R.angle.x;
T.y = R.angle.y;
H.x = H.y = 0;
}

Expand Down Expand Up @@ -3439,28 +3441,32 @@ struct Lara : Item
}
case ANIM_SHOTGUN_DRAW:
{
if ((input & IN_ACTION) || arm->aim) {
if (((input & IN_ACTION) && !arm->target) || arm->aim)
{
anim = ANIM_SHOTGUN_AIM;
frame = 1;
}
break;
}
case ANIM_SHOTGUN_AIM:
{
if ((input & IN_ACTION) || arm->aim)
if (((input & IN_ACTION) && !arm->target) || arm->aim)
{
if (frame == animLength)
{
frame = 1;
anim = ANIM_SHOTGUN_FIRE;

for (int32 i = 0; i < 6; i++)
if (input & IN_ACTION)
{
if (!weaponShoot(arm))
break;
frame = 1;
anim = ANIM_SHOTGUN_FIRE;

if (i == 5) {
soundPlay(params.soundId, pos);
for (int32 i = 0; i < 6; i++)
{
if (!weaponShoot(arm))
break;

if (i == 5) {
soundPlay(params.soundId, pos);
}
}
}
} else {
Expand All @@ -3480,9 +3486,9 @@ struct Lara : Item
}
}

extraL->armR.angle = extraL->armL.angle = vec3s(0, 0, 0);
extraL->armR.animIndex = extraL->armL.animIndex = anim + models[params.animType].animIndex;
extraL->armR.frameIndex = extraL->armL.frameIndex = frame;
R.useBasis = L.useBasis = false;
R.animIndex = L.animIndex = anim + models[params.animType].animIndex;
R.frameIndex = L.frameIndex = frame;
}

void weaponUpdateState()
Expand Down

0 comments on commit 78e5947

Please sign in to comment.