mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-09 14:47:02 +02:00
#183 fix "Getting trough boulders" and "Getting through mutants eggs"
This commit is contained in:
@@ -622,7 +622,9 @@ struct Controller {
|
|||||||
return e.isEnemy() ||
|
return e.isEnemy() ||
|
||||||
e.isVehicle() ||
|
e.isVehicle() ||
|
||||||
e.isDoor() ||
|
e.isDoor() ||
|
||||||
e.type == TR::Entity::SCION_HOLDER;
|
e.type == TR::Entity::SCION_HOLDER ||
|
||||||
|
e.type == TR::Entity::TRAP_BOULDER ||
|
||||||
|
e.type == TR::Entity::MUTANT_EGG_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool activate() {
|
virtual bool activate() {
|
||||||
|
15
src/lara.h
15
src/lara.h
@@ -64,6 +64,8 @@
|
|||||||
|
|
||||||
#define LARA_VIBRATE_HIT_TIME 0.2f
|
#define LARA_VIBRATE_HIT_TIME 0.2f
|
||||||
|
|
||||||
|
#define COLLIDE_MAX_RANGE (1024.0f * 4.0f)
|
||||||
|
|
||||||
struct Lara : Character {
|
struct Lara : Character {
|
||||||
|
|
||||||
// http://www.tombraiderforums.com/showthread.php?t=148859
|
// http://www.tombraiderforums.com/showthread.php?t=148859
|
||||||
@@ -3457,24 +3459,29 @@ struct Lara : Character {
|
|||||||
} else {
|
} else {
|
||||||
// fast distance check for object
|
// fast distance check for object
|
||||||
if (e.type != TR::Entity::HAMMER_HANDLE && e.type != TR::Entity::HAMMER_BLOCK && e.type != TR::Entity::SCION_HOLDER)
|
if (e.type != TR::Entity::HAMMER_HANDLE && e.type != TR::Entity::HAMMER_BLOCK && e.type != TR::Entity::SCION_HOLDER)
|
||||||
if (fabsf(pos.x - controller->pos.x) > 2048 || fabsf(pos.z - controller->pos.z) > 2048 || fabsf(pos.y - controller->pos.y) > 2048) continue;
|
if (fabsf(pos.x - controller->pos.x) > COLLIDE_MAX_RANGE ||
|
||||||
|
fabsf(pos.z - controller->pos.z) > COLLIDE_MAX_RANGE ||
|
||||||
|
fabsf(pos.y - controller->pos.y) > COLLIDE_MAX_RANGE) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.type == TR::Entity::TRAP_BOULDER && !controller->flags.unused) continue; // boulder should stay still
|
||||||
|
|
||||||
vec3 dir = pos - vec3(0.0f, 128.0f, 0.0f) - controller->pos;
|
vec3 dir = pos - vec3(0.0f, 128.0f, 0.0f) - controller->pos;
|
||||||
vec3 p = dir.rotateY(controller->angle.y);
|
vec3 p = dir.rotateY(controller->angle.y);
|
||||||
|
|
||||||
Box box = controller->getBoundingBoxLocal();
|
Box box = controller->getBoundingBoxLocal();
|
||||||
box.expand(vec3(LARA_RADIUS + 50.0f, 0.0f, LARA_RADIUS + 50.0f));
|
box.expand(vec3(LARA_RADIUS + 50.0f, 0.0f, LARA_RADIUS + 50.0f));
|
||||||
box.max.y += 768;
|
box.max.y += LARA_HEIGHT;
|
||||||
|
|
||||||
if (!box.contains(p)) // TODO: Box vs Box or check Lara's head point? (check thor hammer handle)
|
if (!box.contains(p)) // TODO: Box vs Box or check Lara's head point? (check thor hammer handle)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (e.isEnemy()) { // enemy collision
|
|
||||||
if (!collide(controller, false))
|
if (!collide(controller, false))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (e.isEnemy()) { // enemy collision
|
||||||
// velocity.x = velocity.y = 0.0f;
|
// velocity.x = velocity.y = 0.0f;
|
||||||
} else { // door collision
|
} else {
|
||||||
p += box.pushOut2D(p);
|
p += box.pushOut2D(p);
|
||||||
p = (p.rotateY(-controller->angle.y) + controller->pos) - pos;
|
p = (p.rotateY(-controller->angle.y) + controller->pos) - pos;
|
||||||
collisionOffset += vec3(p.x, 0.0f, p.z);
|
collisionOffset += vec3(p.x, 0.0f, p.z);
|
||||||
|
@@ -438,12 +438,6 @@ struct TrapBoulder : Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags.unused) {
|
if (flags.unused) {
|
||||||
Character *lara = (Character*)game->getLara(pos);
|
|
||||||
if (lara->collide(this, true)) {
|
|
||||||
vec3 delta = lara->pos - pos;
|
|
||||||
Box box(delta + vec3(-125, 0, -125), delta + vec3(125, 762, 125));
|
|
||||||
lara->pos += getBoundingBoxLocal().pushOut2D(box);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,9 +471,12 @@ struct TrapBoulder : Controller {
|
|||||||
vec3 v = pos + getDir() * 512.0f;
|
vec3 v = pos + getDir() * 512.0f;
|
||||||
sector = level->getSector(roomIdx, v);
|
sector = level->getSector(roomIdx, v);
|
||||||
if (pos.y > level->getFloor(sector, v)) {
|
if (pos.y > level->getFloor(sector, v)) {
|
||||||
velocity.y = 0.0f;
|
|
||||||
pos = p;
|
|
||||||
flags.unused = true;
|
flags.unused = true;
|
||||||
|
|
||||||
|
pos.x = int(pos.x / 1024.0f) * 1024.0f + 512.0f;
|
||||||
|
pos.z = int(pos.z / 1024.0f) * 1024.0f + 512.0f;
|
||||||
|
sector = level->getSector(roomIndex, pos);
|
||||||
|
pos.y = level->getFloor(sector, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
game->checkTrigger(this, true);
|
game->checkTrigger(this, true);
|
||||||
|
Reference in New Issue
Block a user