1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-09 06:36:59 +02:00

add/remove second player; fix dozy reset

This commit is contained in:
XProger
2018-07-21 03:20:44 +03:00
parent 6969f5f904
commit 15f0a0d220
5 changed files with 28 additions and 18 deletions

View File

@@ -166,8 +166,8 @@ namespace Game {
} }
*/ */
if (!level->level.isTitle()) { if (!level->level.isTitle()) {
if (Input::state[0][cStart]) level->addPlayer(0); if (Input::lastState[0] == cStart) level->addPlayer(0);
if (Input::state[1][cStart]) level->addPlayer(1); if (Input::lastState[1] == cStart) level->addPlayer(1);
} }
if (!level->level.isCutsceneLevel()) if (!level->level.isCutsceneLevel())

View File

@@ -5,11 +5,13 @@
#include "utils.h" #include "utils.h"
#define INPUT_JOY_COUNT 4 #define INPUT_JOY_COUNT 4
#define MAX_PLAYERS COUNT(Core::settings.controls)
namespace Input { namespace Input {
InputKey lastKey; InputKey lastKey;
bool down[ikMAX]; bool down[ikMAX];
bool state[2][cMAX]; bool state[MAX_PLAYERS][cMAX];
ControlKey lastState[MAX_PLAYERS];
struct Mouse { struct Mouse {
vec2 pos; vec2 pos;
@@ -195,10 +197,15 @@ namespace Input {
void update() { void update() {
for (int j = 0; j < COUNT(Core::settings.controls); j++) { for (int j = 0; j < COUNT(Core::settings.controls); j++) {
lastState[j] = cMAX;
Core::Settings::Controls &ctrl = Core::settings.controls[j]; Core::Settings::Controls &ctrl = Core::settings.controls[j];
for (int i = 0; i < cMAX; i++) { for (int i = 0; i < cMAX; i++) {
KeySet &c = ctrl.keys[i]; KeySet &c = ctrl.keys[i];
state[j][i] = (c.key != ikNone && down[c.key]) || (c.joy != jkNone && joy[ctrl.joyIndex].down[c.joy]); bool active = (c.key != ikNone && down[c.key]) || (c.joy != jkNone && joy[ctrl.joyIndex].down[c.joy]);
if (active && !state[j][i])
lastState[j] = ControlKey(i);
state[j][i] = active;
} }
} }

View File

@@ -960,16 +960,14 @@ struct Inventory {
} }
void update() { void update() {
if (titleTimer > 1.0f && ( if (Input::lastState[0] == cInventory || Input::lastState[0] == cAction ||
Input::state[0][cInventory] || Input::state[0][cAction] || Input::lastState[1] == cInventory || Input::lastState[1] == cAction)
Input::state[1][cInventory] || Input::state[1][cAction] ||
Input::down[ikCtrl]))
{ {
if (video) { if (video) {
if (video->time > 0.75f) skipVideo();
skipVideo(); } else if (titleTimer > 1.0f && titleTimer < 2.5f) {
} else if (titleTimer > 1.0f && titleTimer < 2.5f)
titleTimer = 1.0f; titleTimer = 1.0f;
}
} }
if (video) { if (video) {
@@ -1018,9 +1016,9 @@ struct Inventory {
Input::Joystick &joy = Input::joy[Core::settings.controls[playerIndex].joyIndex]; Input::Joystick &joy = Input::joy[Core::settings.controls[playerIndex].joyIndex];
ControlKey key = cMAX; ControlKey key = cMAX;
if (Input::down[ikCtrl] || Input::down[ikEnter] || Input::state[playerIndex][cAction] || joy.down[jkA]) if (Input::down[ikCtrl] || Input::down[ikEnter] || Input::lastState[playerIndex] == cAction || joy.down[jkA])
key = cAction; key = cAction;
else if (Input::down[ikAlt] || joy.down[jkB] || Input::state[playerIndex][cInventory]) else if (Input::down[ikAlt] || joy.down[jkB] || Input::lastState[playerIndex] == cInventory)
key = cInventory; key = cInventory;
else if (Input::down[ikLeft] || joy.down[jkLeft] || joy.L.x < -0.5f) else if (Input::down[ikLeft] || joy.down[jkLeft] || joy.L.x < -0.5f)
key = cLeft; key = cLeft;

View File

@@ -614,6 +614,7 @@ struct Lara : Character {
visibleMask = 0xFFFFFFFF; visibleMask = 0xFFFFFFFF;
health = LARA_MAX_HEALTH; health = LARA_MAX_HEALTH;
oxygen = LARA_MAX_OXYGEN; oxygen = LARA_MAX_OXYGEN;
dozy = false;
keyHole = NULL; keyHole = NULL;
keyItem = NULL; keyItem = NULL;
@@ -2583,8 +2584,8 @@ struct Lara : Character {
int pid = camera->cameraIndex; int pid = camera->cameraIndex;
if (!dozy && ((Input::state[pid][cAction] && Input::state[pid][cJump] && Input::state[pid][cLook] && Input::state[pid][cDash]) || Input::down[ikO])) { if (!dozy && ((Input::state[pid][cAction] && Input::state[pid][cJump] && Input::state[pid][cLook] && Input::state[pid][cDash]) || Input::down[ikO])) {
dozy = true;
reset(getRoomIndex(), pos - vec3(0, 512, 0), angle.y, STAND_UNDERWATER); reset(getRoomIndex(), pos - vec3(0, 512, 0), angle.y, STAND_UNDERWATER);
dozy = true;
return input; return input;
} }

View File

@@ -770,6 +770,11 @@ struct Level : IGame {
players[index] = (Lara*)addEntity(TR::Entity::LARA, 0, vec3(0.0f), 0.0f); players[index] = (Lara*)addEntity(TR::Entity::LARA, 0, vec3(0.0f), 0.0f);
players[index]->camera->cameraIndex = index; players[index]->camera->cameraIndex = index;
Sound::listenersCount = 2; Sound::listenersCount = 2;
} else if (index == 1) {
removeEntity(players[index]);
players[index] = NULL;
Sound::listenersCount = 1;
return;
} }
Lara *lead = players[index ^ 1]; Lara *lead = players[index ^ 1];
@@ -783,7 +788,6 @@ struct Level : IGame {
c = next; c = next;
} }
players[index]->dozy = false;
players[index]->reset(lead->getRoomIndex(), lead->pos, lead->angle.y, lead->stand); players[index]->reset(lead->getRoomIndex(), lead->pos, lead->angle.y, lead->stand);
} }
@@ -1535,8 +1539,8 @@ struct Level : IGame {
} }
} }
if ((Input::state[0][cInventory] || Input::state[1][cInventory]) && !level.isTitle() && inventory->titleTimer < 1.0f && !inventory->active && inventory->lastKey == cMAX) { if ((Input::lastState[0] == cInventory || Input::lastState[1] == cInventory) && !level.isTitle() && inventory->titleTimer < 1.0f && !inventory->active) {
int playerIndex = Input::state[0][cInventory] ? 0 : 1; int playerIndex = (Input::lastState[0] == cInventory) ? 0 : 1;
if (level.isCutsceneLevel()) { if (level.isCutsceneLevel()) {
loadNextLevel(); loadNextLevel();