1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-12 16:14:25 +02:00

#22 heavy triggers

This commit is contained in:
XProger
2017-09-25 06:21:23 +03:00
parent 67750a0535
commit 9f0d744c97
4 changed files with 17 additions and 5 deletions

View File

@@ -50,6 +50,8 @@ struct IGame {
virtual void renderView(int roomIndex, bool water) {}
virtual void setEffect(TR::Effect effect, float param) {}
virtual void checkTrigger(Controller *controller, bool heavy) {}
virtual bool invUse(TR::Entity::Type type) { return false; }
virtual void invAdd(TR::Entity::Type type, int count = 1) {}
virtual int* invCount(TR::Entity::Type type) { return NULL; }

View File

@@ -1354,13 +1354,14 @@ struct Lara : Character {
switch (hitType) {
case TR::HIT_BOULDER : {
animation.setAnim(ANIM_DEATH_BOULDER);
angle = enemy->angle;
if (enemy)
angle = enemy->angle;
TR::Level::FloorInfo info;
level->getFloorInfo(getRoomIndex(), int(pos.x), int(pos.y), int(pos.z), info);
vec3 d = getDir();
vec3 v = info.getSlant(d);
angle.x = -acos(d.dot(v));
v = ((TrapBoulder*)enemy)->velocity * 2.0f;
v = enemy ? ((TrapBoulder*)enemy)->velocity * 2.0f : vec3(0.0f);
for (int i = 0; i < 15; i++)
addBlood(256.0f, 512.0f, v);
break;
@@ -1564,8 +1565,8 @@ struct Lara : Character {
return false;
}
void checkTrigger() {
TR::Entity &e = getEntity();
void checkTrigger(Controller *controller, bool heavy) {
TR::Entity &e = controller->getEntity();
TR::Level::FloorInfo info;
level->getFloorInfo(e.room, e.x, e.y, e.z, info);
@@ -1653,6 +1654,7 @@ struct Lara : Character {
break;
case TR::Level::Trigger::HEAVY :
if (!heavy) return;
break;
case TR::Level::Trigger::DUMMY :
return;
@@ -2353,7 +2355,7 @@ struct Lara : Character {
return;
if (!(input & DEATH))
checkTrigger();
checkTrigger(this, false);
// get turning angle
float w = (input & LEFT) ? -1.0f : ((input & RIGHT) ? 1.0f : 0.0f);

View File

@@ -213,6 +213,10 @@ struct Level : IGame {
this->effectTimer = 0.0f;
}
virtual void checkTrigger(Controller *controller, bool heavy) {
lara->checkTrigger(controller, heavy);
}
virtual bool invUse(TR::Entity::Type type) {
if (!lara->useItem(type))
return inventory.use(type);

View File

@@ -176,6 +176,8 @@ struct TrapBoulder : Controller {
if (info.roomNext != TR::NO_ROOM)
getEntity().room = info.roomNext;
game->checkTrigger(this, true);
vec3 v = pos + getDir() * 512.0f;
level->getFloorInfo(getRoomIndex(), int(v.x), int(v.y), int(v.z), info);
if (pos.y > info.floor) {
@@ -267,6 +269,7 @@ struct Block : Controller {
updateEntity();
updateFloor(true);
deactivate();
game->checkTrigger(this, true);
}
updateLights();
}
@@ -318,6 +321,7 @@ struct MovingBlock : Controller {
pos.x = int(pos.x / 1024.0f) * 1024.0f + 512.0f;
pos.z = int(pos.z / 1024.0f) * 1024.0f + 512.0f;
updateFloor(true);
game->checkTrigger(this, true);
return;
}