mirror of
https://github.com/XProger/OpenLara.git
synced 2025-04-21 11:31:56 +02:00
#183 fix "Getting trough boulders" and "Getting through mutants eggs"
This commit is contained in:
parent
319449970c
commit
18386a1d35
@ -622,7 +622,9 @@ struct Controller {
|
||||
return e.isEnemy() ||
|
||||
e.isVehicle() ||
|
||||
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() {
|
||||
|
17
src/lara.h
17
src/lara.h
@ -64,6 +64,8 @@
|
||||
|
||||
#define LARA_VIBRATE_HIT_TIME 0.2f
|
||||
|
||||
#define COLLIDE_MAX_RANGE (1024.0f * 4.0f)
|
||||
|
||||
struct Lara : Character {
|
||||
|
||||
// http://www.tombraiderforums.com/showthread.php?t=148859
|
||||
@ -3457,24 +3459,29 @@ struct Lara : Character {
|
||||
} else {
|
||||
// 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 (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 p = dir.rotateY(controller->angle.y);
|
||||
|
||||
Box box = controller->getBoundingBoxLocal();
|
||||
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)
|
||||
continue;
|
||||
|
||||
if (!collide(controller, false))
|
||||
continue;
|
||||
|
||||
if (e.isEnemy()) { // enemy collision
|
||||
if (!collide(controller, false))
|
||||
continue;
|
||||
// velocity.x = velocity.y = 0.0f;
|
||||
} else { // door collision
|
||||
} else {
|
||||
p += box.pushOut2D(p);
|
||||
p = (p.rotateY(-controller->angle.y) + controller->pos) - pos;
|
||||
collisionOffset += vec3(p.x, 0.0f, p.z);
|
||||
|
@ -438,12 +438,6 @@ struct TrapBoulder : Controller {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -477,9 +471,12 @@ struct TrapBoulder : Controller {
|
||||
vec3 v = pos + getDir() * 512.0f;
|
||||
sector = level->getSector(roomIdx, v);
|
||||
if (pos.y > level->getFloor(sector, v)) {
|
||||
velocity.y = 0.0f;
|
||||
pos = p;
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user