1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-07 13:46:45 +02:00

#13 trigger timer & dartgun logic

This commit is contained in:
XProger
2016-09-21 01:41:25 +03:00
parent 31cea8ea89
commit 8e9b17cfdc
5 changed files with 27 additions and 16 deletions

Binary file not shown.

View File

@@ -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,10 +240,10 @@ 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 bool activate(float timer) { return false; }
virtual void updateVelocity() {}
virtual void move() {}
virtual Stand getStand() { return STAND_AIR; }

View File

@@ -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

View File

@@ -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

View File

@@ -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 :