mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-13 08:34:32 +02:00
#368 GBA fix aiming
This commit is contained in:
@@ -2757,37 +2757,70 @@ struct Lara : Item
|
|||||||
|
|
||||||
void updateLook()
|
void updateLook()
|
||||||
{
|
{
|
||||||
|
ExtraInfoLara::Arm &R = extraL->armR;
|
||||||
|
ExtraInfoLara::Arm &L = extraL->armL;
|
||||||
|
vec3s &H = extraL->head.angle;
|
||||||
|
vec3s &T = extraL->torso.angle;
|
||||||
|
|
||||||
if (health <= 0) {
|
if (health <= 0) {
|
||||||
extraL->head.angle = vec3s(0, 0, 0);
|
H = T = vec3s(0, 0, 0);
|
||||||
} else if ((input & IN_LOOK) && gCamera->mode != CAMERA_MODE_FIXED) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (R.target || L.target)
|
||||||
|
{
|
||||||
|
if (extraL->weapon < WEAPON_SHOTGUN)
|
||||||
|
{
|
||||||
|
int32 aX = R.angle.x + L.angle.x;
|
||||||
|
int32 aY = R.angle.y + L.angle.y;
|
||||||
|
|
||||||
|
if (R.aim && L.aim) {
|
||||||
|
H.x = T.x = aX >> 2;
|
||||||
|
H.y = T.y = aY >> 2;
|
||||||
|
} else if (R.aim ^ L.aim) {
|
||||||
|
H.x = T.x = aX >> 1;
|
||||||
|
H.y = T.y = aY >> 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
T.x = R.angle.x;
|
||||||
|
T.y = R.angle.y;
|
||||||
|
H.x = H.y = 0;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((input & IN_LOOK) && gCamera->mode != CAMERA_MODE_FIXED)
|
||||||
|
{
|
||||||
gCamera->lookAtItem = NULL;
|
gCamera->lookAtItem = NULL;
|
||||||
|
|
||||||
if (input & IN_UP) {
|
if (input & IN_UP) {
|
||||||
extraL->head.angle.x -= LARA_LOOK_TURN_SPEED;
|
H.x -= LARA_LOOK_TURN_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input & IN_DOWN) {
|
if (input & IN_DOWN) {
|
||||||
extraL->head.angle.x += LARA_LOOK_TURN_SPEED;
|
H.x += LARA_LOOK_TURN_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input & IN_LEFT) {
|
if (input & IN_LEFT) {
|
||||||
extraL->head.angle.y -= LARA_LOOK_TURN_SPEED;
|
H.y -= LARA_LOOK_TURN_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input & IN_RIGHT) {
|
if (input & IN_RIGHT) {
|
||||||
extraL->head.angle.y += LARA_LOOK_TURN_SPEED;
|
H.y += LARA_LOOK_TURN_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
extraL->head.angle.x = X_CLAMP(extraL->head.angle.x, LARA_LOOK_ANGLE_MIN, LARA_LOOK_ANGLE_MAX);
|
H.x = T.x = X_CLAMP(H.x, LARA_LOOK_ANGLE_MIN, LARA_LOOK_ANGLE_MAX);
|
||||||
extraL->head.angle.y = X_CLAMP(extraL->head.angle.y, -LARA_LOOK_ANGLE_Y, LARA_LOOK_ANGLE_Y);
|
H.y = T.y = X_CLAMP(H.y, -LARA_LOOK_ANGLE_Y, LARA_LOOK_ANGLE_Y);
|
||||||
|
|
||||||
input &= ~(IN_RIGHT | IN_LEFT | IN_UP | IN_DOWN);
|
input &= ~(IN_RIGHT | IN_LEFT | IN_UP | IN_DOWN);
|
||||||
} else if (gCamera->lastItem == NULL) {
|
return;
|
||||||
extraL->head.angle.x = angleDec(extraL->head.angle.x, abs(extraL->head.angle.x) >> 3);
|
|
||||||
extraL->head.angle.y = angleDec(extraL->head.angle.y, abs(extraL->head.angle.y) >> 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extraL->torso.angle = extraL->head.angle;
|
if (gCamera->lastItem != NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
H.x = T.x = angleDec(H.x, abs(H.x) >> 3);
|
||||||
|
H.y = T.y = angleDec(H.y, abs(H.y) >> 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateWaterState()
|
void updateWaterState()
|
||||||
@@ -3100,19 +3133,27 @@ struct Lara : Item
|
|||||||
return;
|
return;
|
||||||
extraL->weaponState = weaponState;
|
extraL->weaponState = weaponState;
|
||||||
|
|
||||||
|
ExtraInfoLara::Arm &R = extraL->armR;
|
||||||
|
ExtraInfoLara::Arm &L = extraL->armL;
|
||||||
|
|
||||||
if (weaponState == WEAPON_STATE_DRAW)
|
if (weaponState == WEAPON_STATE_DRAW)
|
||||||
{
|
{
|
||||||
const WeaponParams ¶ms = weaponParams[extraL->weapon];
|
const WeaponParams ¶ms = weaponParams[extraL->weapon];
|
||||||
int32 anim = (extraL->weapon == WEAPON_SHOTGUN) ? ANIM_SHOTGUN_DRAW : ANIM_PISTOLS_PICK;
|
int32 anim = (extraL->weapon == WEAPON_SHOTGUN) ? ANIM_SHOTGUN_DRAW : ANIM_PISTOLS_PICK;
|
||||||
extraL->armR.animIndex = extraL->armL.animIndex = models[params.animType].animIndex + anim;
|
R.animIndex = L.animIndex = models[params.animType].animIndex + anim;
|
||||||
extraL->armR.frameIndex = extraL->armL.frameIndex = 0;
|
R.frameIndex = L.frameIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weaponState == WEAPON_STATE_HOLSTER)
|
||||||
|
{
|
||||||
|
R.target = L.target = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (weaponState == WEAPON_STATE_FREE)
|
if (weaponState == WEAPON_STATE_FREE)
|
||||||
{
|
{
|
||||||
extraL->armR.useBasis = extraL->armL.useBasis = false;
|
R.useBasis = L.useBasis = false;
|
||||||
extraL->armR.animIndex = extraL->armL.animIndex = 0;
|
R.animIndex = L.animIndex = 0;
|
||||||
extraL->armR.frameIndex = extraL->armL.frameIndex = 0;
|
R.frameIndex = L.frameIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3321,23 +3362,10 @@ struct Lara : Item
|
|||||||
{
|
{
|
||||||
ExtraInfoLara::Arm &R = extraL->armR;
|
ExtraInfoLara::Arm &R = extraL->armR;
|
||||||
ExtraInfoLara::Arm &L = extraL->armL;
|
ExtraInfoLara::Arm &L = extraL->armL;
|
||||||
vec3s &H = extraL->head.angle;
|
|
||||||
vec3s &T = extraL->torso.angle;
|
|
||||||
|
|
||||||
weaponAim(R);
|
weaponAim(R);
|
||||||
weaponAim(L);
|
weaponAim(L);
|
||||||
|
|
||||||
int32 aX = R.angle.x + L.angle.x;
|
|
||||||
int32 aY = R.angle.y + L.angle.y;
|
|
||||||
|
|
||||||
if (R.aim && L.aim) {
|
|
||||||
H.x = T.x = aX >> 2;
|
|
||||||
H.y = T.y = aY >> 2;
|
|
||||||
} else if (R.aim ^ L.aim) {
|
|
||||||
H.x = T.x = aX >> 1;
|
|
||||||
H.y = T.y = aY >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const WeaponParams ¶ms = weaponParams[extraL->weapon];
|
const WeaponParams ¶ms = weaponParams[extraL->weapon];
|
||||||
|
|
||||||
for (int32 i = 0; i < LARA_ARM_MAX; i++)
|
for (int32 i = 0; i < LARA_ARM_MAX; i++)
|
||||||
@@ -3399,18 +3427,8 @@ struct Lara : Item
|
|||||||
ExtraInfoLara::Arm &R = extraL->armR;
|
ExtraInfoLara::Arm &R = extraL->armR;
|
||||||
ExtraInfoLara::Arm &L = extraL->armL;
|
ExtraInfoLara::Arm &L = extraL->armL;
|
||||||
|
|
||||||
vec3s &H = extraL->head.angle;
|
|
||||||
vec3s &T = extraL->torso.angle;
|
|
||||||
|
|
||||||
weaponAim(R);
|
weaponAim(R);
|
||||||
|
|
||||||
if (R.aim)
|
|
||||||
{
|
|
||||||
T.x = R.angle.x;
|
|
||||||
T.y = R.angle.y;
|
|
||||||
H.x = H.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const WeaponParams ¶ms = weaponParams[extraL->weapon];
|
const WeaponParams ¶ms = weaponParams[extraL->weapon];
|
||||||
|
|
||||||
ExtraInfoLara::Arm* arm = &extraL->armR;
|
ExtraInfoLara::Arm* arm = &extraL->armR;
|
||||||
@@ -3420,6 +3438,8 @@ struct Lara : Item
|
|||||||
int32 frame = arm->frameIndex;
|
int32 frame = arm->frameIndex;
|
||||||
int32 anim = arm->animIndex - models[params.animType].animIndex;
|
int32 anim = arm->animIndex - models[params.animType].animIndex;
|
||||||
|
|
||||||
|
bool aim = ((input & IN_ACTION) && !arm->target) || arm->aim;
|
||||||
|
|
||||||
switch (anim)
|
switch (anim)
|
||||||
{
|
{
|
||||||
case ANIM_SHOTGUN_FIRE:
|
case ANIM_SHOTGUN_FIRE:
|
||||||
@@ -3431,7 +3451,7 @@ struct Lara : Item
|
|||||||
anim = ANIM_SHOTGUN_AIM;
|
anim = ANIM_SHOTGUN_AIM;
|
||||||
animPtr = level.anims + models[params.animType].animIndex + anim;
|
animPtr = level.anims + models[params.animType].animIndex + anim;
|
||||||
frame = animPtr->frameEnd - animPtr->frameBegin;
|
frame = animPtr->frameEnd - animPtr->frameBegin;
|
||||||
} else if ((animLength - frame < 10) && !(input & IN_ACTION)) {
|
} else if ((animLength - frame < 10) && !aim) {
|
||||||
anim = ANIM_SHOTGUN_AIM;
|
anim = ANIM_SHOTGUN_AIM;
|
||||||
frame = animLength - frame; // how many frames left for fire animation
|
frame = animLength - frame; // how many frames left for fire animation
|
||||||
animPtr = level.anims + models[params.animType].animIndex + anim;
|
animPtr = level.anims + models[params.animType].animIndex + anim;
|
||||||
@@ -3441,7 +3461,7 @@ struct Lara : Item
|
|||||||
}
|
}
|
||||||
case ANIM_SHOTGUN_DRAW:
|
case ANIM_SHOTGUN_DRAW:
|
||||||
{
|
{
|
||||||
if (((input & IN_ACTION) && !arm->target) || arm->aim)
|
if (aim)
|
||||||
{
|
{
|
||||||
anim = ANIM_SHOTGUN_AIM;
|
anim = ANIM_SHOTGUN_AIM;
|
||||||
frame = 1;
|
frame = 1;
|
||||||
@@ -3450,7 +3470,7 @@ struct Lara : Item
|
|||||||
}
|
}
|
||||||
case ANIM_SHOTGUN_AIM:
|
case ANIM_SHOTGUN_AIM:
|
||||||
{
|
{
|
||||||
if (((input & IN_ACTION) && !arm->target) || arm->aim)
|
if (aim)
|
||||||
{
|
{
|
||||||
if (frame == animLength)
|
if (frame == animLength)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user