mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-08 06:06:51 +02:00
#13 trigger timer & dartgun logic
This commit is contained in:
BIN
bin/OpenLara.exe
BIN
bin/OpenLara.exe
Binary file not shown.
@@ -44,11 +44,12 @@ struct Controller {
|
|||||||
struct Action {
|
struct Action {
|
||||||
TR::Action action;
|
TR::Action action;
|
||||||
int value;
|
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;
|
} 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();
|
TR::Entity &e = getEntity();
|
||||||
pos = vec3((float)e.x, (float)e.y, (float)e.z);
|
pos = vec3((float)e.x, (float)e.y, (float)e.z);
|
||||||
angle = vec3(0.0f, e.rotation / 16384.0f * PI * 0.5f, 0.0f);
|
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);
|
// LOG("play sound %d\n", id);
|
||||||
|
|
||||||
int16 a = level->soundsMap[id];
|
int16 a = level->soundsMap[id];
|
||||||
|
if (a == -1) return;
|
||||||
TR::SoundInfo &b = level->soundsInfo[a];
|
TR::SoundInfo &b = level->soundsInfo[a];
|
||||||
if (b.chance == 0 || (rand() & 0x7fff) <= b.chance) {
|
if (b.chance == 0 || (rand() & 0x7fff) <= b.chance) {
|
||||||
uint32 c = level->soundOffsets[b.offset + rand() % ((b.flags & 0xFF) >> 2)];
|
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;
|
Controller *controller = (Controller*)level->entities[nextAction.value].controller;
|
||||||
nextAction.action = TR::Action::NONE;
|
nextAction.action = TR::Action::NONE;
|
||||||
if (controller)
|
if (controller)
|
||||||
controller->activate();
|
controller->activate(nextAction.timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void activate() {}
|
virtual bool activate(float timer) { return false; }
|
||||||
virtual void updateVelocity() {}
|
virtual void updateVelocity() {}
|
||||||
virtual void move() {}
|
virtual void move() {}
|
||||||
virtual Stand getStand() { return STAND_AIR; }
|
virtual Stand getStand() { return STAND_AIR; }
|
||||||
|
13
src/format.h
13
src/format.h
@@ -103,17 +103,18 @@ namespace TR {
|
|||||||
#define ENTITY_ENEMY_MUMMY 24
|
#define ENTITY_ENEMY_MUMMY 24
|
||||||
#define ENTITY_ENEMY_LARSON 27
|
#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_CRYSTAL 83
|
||||||
|
|
||||||
#define ENTITY_MEDIKIT_SMALL 93
|
#define ENTITY_MEDIKIT_SMALL 93
|
||||||
#define ENTITY_MEDIKIT_BIG 94
|
#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 55
|
||||||
#define ENTITY_SWITCH_WATER 56
|
#define ENTITY_SWITCH_WATER 56
|
||||||
@@ -859,7 +860,7 @@ namespace TR {
|
|||||||
case 7 : break; // end level
|
case 7 : break; // end level
|
||||||
case 8 : break; // play soundtrack
|
case 8 : break; // play soundtrack
|
||||||
case 9 : break; // special hadrdcode trigger
|
case 9 : break; // special hadrdcode trigger
|
||||||
case 10 : break; // secret found
|
case 10 : break; // secret found (playSound(175))
|
||||||
case 11 : break; // clear bodies
|
case 11 : break; // clear bodies
|
||||||
case 12 : break; // flyby camera sequence
|
case 12 : break; // flyby camera sequence
|
||||||
case 13 : break; // play cutscene
|
case 13 : break; // play cutscene
|
||||||
|
@@ -127,6 +127,7 @@ struct Lara : Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool waterOut(int &outState) {
|
bool waterOut(int &outState) {
|
||||||
|
// TODO: playSound 36
|
||||||
vec3 dst = pos + getDir() * 32.0f;
|
vec3 dst = pos + getDir() * 32.0f;
|
||||||
|
|
||||||
TR::Level::FloorInfo infoCur, infoDst;
|
TR::Level::FloorInfo infoCur, infoDst;
|
||||||
@@ -209,7 +210,7 @@ struct Lara : Controller {
|
|||||||
playSound(2);
|
playSound(2);
|
||||||
return;
|
return;
|
||||||
} else
|
} 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
|
if (info.trigCmd[0].func != TR::Action::ACTIVATE) return; // see above TODO
|
||||||
@@ -220,7 +221,7 @@ struct Lara : Controller {
|
|||||||
nextAction = controller->nextAction;
|
nextAction = controller->nextAction;
|
||||||
controller->nextAction.action = TR::Action::NONE;
|
controller->nextAction.action = TR::Action::NONE;
|
||||||
} else
|
} else
|
||||||
controller->activate();
|
controller->activate((float)info.trigInfo.timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Stand getStand() {
|
virtual Stand getStand() {
|
||||||
@@ -399,7 +400,7 @@ struct Lara : Controller {
|
|||||||
playSound(snd_id);
|
playSound(snd_id);
|
||||||
// setAnimation(snd_id);
|
// setAnimation(snd_id);
|
||||||
LOG("sound: %d\n", snd_id++);
|
LOG("sound: %d\n", snd_id++);
|
||||||
|
/*
|
||||||
LOG("state: %d\n", anim->state);
|
LOG("state: %d\n", anim->state);
|
||||||
for (int i = 0; i < anim->scCount; i++) {
|
for (int i = 0; i < anim->scCount; i++) {
|
||||||
auto &sc = level->states[anim->scOffset + i];
|
auto &sc = level->states[anim->scOffset + i];
|
||||||
@@ -410,7 +411,7 @@ struct Lara : Controller {
|
|||||||
}
|
}
|
||||||
LOG("\n");
|
LOG("\n");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
@@ -83,9 +83,16 @@ struct Level {
|
|||||||
case ENTITY_DOOR_BIG_2 :
|
case ENTITY_DOOR_BIG_2 :
|
||||||
case ENTITY_DOOR_FLOOR_1 :
|
case ENTITY_DOOR_FLOOR_1 :
|
||||||
case ENTITY_DOOR_FLOOR_2 :
|
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);
|
entity.controller = new Trigger(&level, i, true);
|
||||||
break;
|
break;
|
||||||
|
case ENTITY_TRAP_DARTGUN :
|
||||||
|
entity.controller = new Dart(&level, i);
|
||||||
|
break;
|
||||||
case ENTITY_SWITCH :
|
case ENTITY_SWITCH :
|
||||||
case ENTITY_SWITCH_WATER :
|
case ENTITY_SWITCH_WATER :
|
||||||
case ENTITY_HOLE_PUZZLE :
|
case ENTITY_HOLE_PUZZLE :
|
||||||
|
Reference in New Issue
Block a user