1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-01-17 21:09:00 +01:00

#3 fix high jump to hang; #22 fix activation by trigger;

This commit is contained in:
XProger 2017-01-02 03:05:56 +03:00
parent acb31d366e
commit 3c1bbcf53a
5 changed files with 42 additions and 27 deletions

Binary file not shown.

View File

@ -326,6 +326,8 @@ struct Controller {
return;
case TR::Action::FLOW :
applyFlow(level->cameras[next->value]);
actionCommand = next;
activateNext();
break;
case TR::Action::FLIP_MAP :
case TR::Action::FLIP_ON :

View File

@ -339,7 +339,7 @@ namespace Debug {
TR::Entity &e = level.entities[i];
sprintf(buf, "%d", (int)e.type);
Debug::Draw::text(vec3(e.x, e.y, e.z), vec4(0.8, 0, 0, 1), buf);
Debug::Draw::text(vec3(e.x, e.y, e.z), e.flags.active ? vec4(0, 0, 0.8, 1) : vec4(0.8, 0, 0, 1), buf);
}
for (int i = 0; i < level.camerasCount; i++) {
@ -405,23 +405,19 @@ namespace Debug {
for (int i = 0; i < level.entitiesCount; i++) {
TR::Entity &e = level.entities[i];
Controller *controller = (Controller*)e.controller;
if (!controller) continue;
mat4 matrix;
matrix.identity();
matrix.translate(vec3(e.x, e.y, e.z));
if (controller) {
matrix.rotateY(controller->angle.y);
matrix.rotateX(controller->angle.x);
matrix.rotateZ(controller->angle.z);
} else
matrix.rotateY(e.rotation);
mat4 matrix = controller->getMatrix();
Box box = controller->animation.getBoundingBox(vec3(0.0f), 0);
Debug::Draw::box(matrix, box.min, box.max, vec4(1.0));
/*
for (int j = 0; j < level.modelsCount; j++) {
TR::Model &m = level.models[j];
TR::Node *node = m.node < level.nodesDataSize ? (TR::Node*)&level.nodesData[m.node] : NULL;
if (!node) continue; // ???
/*
if (e.type == m.type) {
ASSERT(m.animation < 0xFFFF);
@ -479,9 +475,9 @@ namespace Debug {
break;
}
*/
}
*/
}
}

View File

@ -21,7 +21,7 @@
#define GLIDE_SPEED 35.0f
#define SWIM_SPEED 45.0f
#define LARA_HANG_OFFSET 735.0f
#define LARA_HANG_OFFSET 724.0f
#define LARA_WET_SPECULAR 0.5f
#define LARA_WET_TIMER (LARA_WET_SPECULAR / 16.0f) // 4 sec
@ -252,11 +252,16 @@ struct Lara : Character {
angle = vec3(0.0f, -PI * 0.25f, 0.0f);
getEntity().room = 13;
// level 2 (room 1)
// level 2 (room 43)
pos = vec3(31400, -2560, 25200);
angle = vec3(0.0f, PI, 0.0f);
getEntity().room = 43;
// level 2 (room 16)
pos = vec3(60907, 0, 39642);
angle = vec3(0.0f, PI * 3 / 2, 0.0f);
getEntity().room = 16;
// level 2 (medikit)
pos = vec3(30800, -7936, 22131);
angle = vec3(0.0f, 0.0f, 0.0f);
@ -417,6 +422,8 @@ struct Lara : Character {
bool canDrawWeapon() {
return wpnCurrent != Weapon::EMPTY
&& emptyHands()
&& animation.index != ANIM_CLIMB_3
&& animation.index != ANIM_CLIMB_2
&& state != STATE_DEATH
&& state != STATE_HANG
&& state != STATE_REACH
@ -984,7 +991,15 @@ struct Lara : Character {
level->getFloorInfo(e.room, e.x, e.y, e.z, info);
if (!info.trigCmdCount) return; // has no trigger
bool isActive = level->entities[info.trigCmd[0].args].flags.active != 0;
TR::FloorData::TriggerCommand &cmd = info.trigCmd[0];
bool isActive = false;
switch (cmd.action) {
case TR::Action::SECRET : isActive = level->secrets[cmd.args]; break;
case TR::Action::ACTIVATE : isActive = level->entities[cmd.args].flags.active != 0; break;
default : isActive = false;
}
if (info.trigInfo.once == 1 && isActive) return; // once trigger is already activated
int actionState = state;
@ -1156,6 +1171,8 @@ struct Lara : Character {
if (state == STATE_REACH && velocity.y < 0.0f)
return state;
Box bounds = animation.getBoundingBox(pos, 0);
vec3 p = pos + getDir() * 128.0f;
TR::Level::FloorInfo info;
// TODO: use brain
@ -1166,12 +1183,11 @@ struct Lara : Character {
do {
level->getFloorInfo(info.roomAbove, (int)p.x, (int)p.y, (int)p.z, info);
} while (info.ceiling > p.y - LARA_HANG_OFFSET && info.roomAbove != 0xFF);
if (abs(int(info.floor - (p.y - LARA_HANG_OFFSET))) < 32) {
alignToWall();
pos = pos - getDir() * 96.0f; // TODO: collision wall offset
pos.y = info.floor + LARA_HANG_OFFSET;
} while (info.ceiling > bounds.min.y && info.roomAbove != 0xFF);
if (abs(info.floor - int(bounds.min.y)) < 16) { // reach fall
alignToWall(96.0f);
pos.y = info.floor + 724.0f;
updateEntity();
stand = STAND_HANG;
@ -1244,7 +1260,7 @@ struct Lara : Character {
aIndex = ANIM_CLIMB_JUMP;
if (aIndex != animation.index) {
alignToWall();
alignToWall(96.0f);
return animation.setAnim(aIndex);
}
}

View File

@ -613,6 +613,7 @@ struct Level {
for (int i = 0; i < r.lightsCount; i++) {
TR::Room::Light &light = r.lights[i];
if (light.intensity > 0x1FFF) continue;
float att = max(0.0f, 1.0f - (pos - vec3(float(light.x), float(light.y), float(light.z))).length2() / ((float)light.radius * (float)light.radius));
if (att > maxAtt) {
maxAtt = att;
@ -924,15 +925,15 @@ struct Level {
case 4 : glRotatef( 0, 0, 1, 0); break;
case 5 : glRotatef(180, 0, 1, 0); break;
}
glTranslatef(0, 0, 256);
glTranslatef(0, 0, 128);
ambientCache->textures[j * 4 + dbg_ambient]->bind(sDiffuse);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(-256, 256, 0);
glTexCoord2f(1, 0); glVertex3f( 256, 256, 0);
glTexCoord2f(1, 1); glVertex3f( 256, -256, 0);
glTexCoord2f(0, 1); glVertex3f(-256, -256, 0);
glTexCoord2f(0, 0); glVertex3f(-128, 128, 0);
glTexCoord2f(1, 0); glVertex3f( 128, 128, 0);
glTexCoord2f(1, 1); glVertex3f( 128, -128, 0);
glTexCoord2f(0, 1); glVertex3f(-128, -128, 0);
glEnd();
glPopMatrix();