diff --git a/bin/OpenLara.exe b/bin/OpenLara.exe index 3fb7f56..a5bcd74 100644 Binary files a/bin/OpenLara.exe and b/bin/OpenLara.exe differ diff --git a/src/controller.h b/src/controller.h index ab9ee1e..1721c6b 100644 --- a/src/controller.h +++ b/src/controller.h @@ -44,11 +44,12 @@ struct Controller { struct Action { TR::Action action; int value; + float timer; - Action(TR::Action action, int value) : action(action), value(value) {} + Action(TR::Action action, int value, float timer) : action(action), value(value), timer(timer) {} } nextAction; - Controller(TR::Level *level, int entity) : level(level), entity(entity), velocity(0.0f), animTime(0.0f), animPrevFrame(0), health(100), turnTime(0.0f), nextAction(TR::Action::NONE, 0) { + Controller(TR::Level *level, int entity) : level(level), entity(entity), velocity(0.0f), animTime(0.0f), animPrevFrame(0), health(100), turnTime(0.0f), nextAction(TR::Action::NONE, 0, 0.0f) { TR::Entity &e = getEntity(); pos = vec3((float)e.x, (float)e.y, (float)e.z); angle = vec3(0.0f, e.rotation / 16384.0f * PI * 0.5f, 0.0f); @@ -168,6 +169,7 @@ struct Controller { // LOG("play sound %d\n", id); int16 a = level->soundsMap[id]; + if (a == -1) return; TR::SoundInfo &b = level->soundsInfo[a]; if (b.chance == 0 || (rand() & 0x7fff) <= b.chance) { uint32 c = level->soundOffsets[b.offset + rand() % ((b.flags & 0xFF) >> 2)]; @@ -238,11 +240,11 @@ struct Controller { Controller *controller = (Controller*)level->entities[nextAction.value].controller; nextAction.action = TR::Action::NONE; if (controller) - controller->activate(); + controller->activate(nextAction.timer); } - virtual void activate() {} - virtual void updateVelocity() {} + virtual bool activate(float timer) { return false; } + virtual void updateVelocity() {} virtual void move() {} virtual Stand getStand() { return STAND_AIR; } virtual int getHeight() { return 0; } diff --git a/src/format.h b/src/format.h index ec415ad..fc00b5e 100644 --- a/src/format.h +++ b/src/format.h @@ -103,17 +103,18 @@ namespace TR { #define ENTITY_ENEMY_MUMMY 24 #define ENTITY_ENEMY_LARSON 27 - #define ENTITY_BLADE 36 + #define ENTITY_TRAP_FLOOR 35 + #define ENTITY_TRAP_BLADE 36 + #define ENTITY_TRAP_SPIKES 37 + #define ENTITY_TRAP_STONE 38 + #define ENTITY_TRAP_DART 39 + #define ENTITY_TRAP_DARTGUN 40 #define ENTITY_CRYSTAL 83 #define ENTITY_MEDIKIT_SMALL 93 #define ENTITY_MEDIKIT_BIG 94 - #define ENTITY_TRAP_FLOOR 35 - #define ENTITY_TRAP_SPIKES 37 - #define ENTITY_TRAP_STONE 38 - #define ENTITY_TRAP_DART 40 #define ENTITY_SWITCH 55 #define ENTITY_SWITCH_WATER 56 @@ -859,7 +860,7 @@ namespace TR { case 7 : break; // end level case 8 : break; // play soundtrack case 9 : break; // special hadrdcode trigger - case 10 : break; // secret found + case 10 : break; // secret found (playSound(175)) case 11 : break; // clear bodies case 12 : break; // flyby camera sequence case 13 : break; // play cutscene diff --git a/src/lara.h b/src/lara.h index f87403f..39ba0bc 100644 --- a/src/lara.h +++ b/src/lara.h @@ -127,6 +127,7 @@ struct Lara : Controller { } bool waterOut(int &outState) { + // TODO: playSound 36 vec3 dst = pos + getDir() * 32.0f; TR::Level::FloorInfo infoCur, infoDst; @@ -209,7 +210,7 @@ struct Lara : Controller { playSound(2); return; } else - controller->nextAction = (i < info.trigCmdCount - 1) ? Action(TR::Action::ACTIVATE, info.trigCmd[i + 1].args) : Action(TR::Action::NONE, 0); + controller->nextAction = (i < info.trigCmdCount - 1) ? Action(TR::Action::ACTIVATE, info.trigCmd[i + 1].args, 0.0f) : Action(TR::Action::NONE, 0, 0.0f); } if (info.trigCmd[0].func != TR::Action::ACTIVATE) return; // see above TODO @@ -220,7 +221,7 @@ struct Lara : Controller { nextAction = controller->nextAction; controller->nextAction.action = TR::Action::NONE; } else - controller->activate(); + controller->activate((float)info.trigInfo.timer); } virtual Stand getStand() { @@ -399,7 +400,7 @@ struct Lara : Controller { playSound(snd_id); // setAnimation(snd_id); LOG("sound: %d\n", snd_id++); - + /* LOG("state: %d\n", anim->state); for (int i = 0; i < anim->scCount; i++) { auto &sc = level->states[anim->scOffset + i]; @@ -410,7 +411,7 @@ struct Lara : Controller { } LOG("\n"); } - + */ } } else diff --git a/src/level.h b/src/level.h index 68236ad..675101b 100644 --- a/src/level.h +++ b/src/level.h @@ -83,9 +83,16 @@ struct Level { case ENTITY_DOOR_BIG_2 : case ENTITY_DOOR_FLOOR_1 : case ENTITY_DOOR_FLOOR_2 : - case ENTITY_BLADE : + case ENTITY_TRAP_FLOOR : + case ENTITY_TRAP_BLADE : + case ENTITY_TRAP_SPIKES : + case ENTITY_TRAP_STONE : + //case ENTITY_TRAP_DART : entity.controller = new Trigger(&level, i, true); break; + case ENTITY_TRAP_DARTGUN : + entity.controller = new Dart(&level, i); + break; case ENTITY_SWITCH : case ENTITY_SWITCH_WATER : case ENTITY_HOLE_PUZZLE :