diff --git a/src/format.h b/src/format.h index 6928fd2..c8a6c5b 100644 --- a/src/format.h +++ b/src/format.h @@ -311,6 +311,7 @@ namespace TR { HIT_BOULDER, HIT_SPIKES, HIT_FLAME, + HIT_SLAM, HIT_REX, }; diff --git a/src/lara.h b/src/lara.h index c4bfd9e..081f728 100644 --- a/src/lara.h +++ b/src/lara.h @@ -469,6 +469,7 @@ struct Lara : Character { //reset(10, vec3(90443, 11264 - 256, 114614), PI, STAND_ONWATER); // villa mortal 2 //reset(50, vec3(53703, -18688, 13769), PI); // Level 10c (scion holder) //reset(19, vec3(35364, -512, 40199), PI * 0.5f); // Level 10c (lava flow) + //reset(9, vec3(69074, -14592, 25192), 0); // Level 10c (trap slam) #endif chestOffset = animation.getJoints(getMatrix(), 7).pos; } @@ -1300,11 +1301,15 @@ struct Lara : Character { } } - void addBlood(float radius, float height, const vec3 &spriteVelocity) { - vec3 p = pos + vec3((randf() * 2.0f - 1.0f) * radius, -randf() * height, (randf() * 2.0f - 1.0f) * radius); - int index = Sprite::add(game, TR::Entity::BLOOD, getRoomIndex(), int(p.x), int(p.y), int(p.z), Sprite::FRAME_ANIMATED); + void addBlood(const vec3 &sprPos, const vec3 &sprVel) { + int index = Sprite::add(game, TR::Entity::BLOOD, getRoomIndex(), int(sprPos.x), int(sprPos.y), int(sprPos.z), Sprite::FRAME_ANIMATED); if (index > -1) - ((Sprite*)level->entities[index].controller)->velocity = spriteVelocity; + ((Sprite*)level->entities[index].controller)->velocity = sprVel; + } + + void addBlood(float radius, float height, const vec3 &sprVel) { + vec3 p = pos + vec3((randf() * 2.0f - 1.0f) * radius, -randf() * height, (randf() * 2.0f - 1.0f) * radius); + addBlood(p, sprVel); } void addBloodSpikes() { @@ -1317,6 +1322,10 @@ struct Lara : Character { addBlood(64.0f, 744.0f, vec3(sinf(ang), 0.0f, cosf(ang)) * speed); } + void addBloodSlam(Controller *trapSlam) { + for (int i = 0; i < 6; i++) + addBloodSpikes(); + } virtual void hit(float damage, Controller *enemy = NULL, TR::HitType hitType = TR::HIT_DEFAULT) { if (dozy) return; @@ -1327,11 +1336,12 @@ struct Lara : Character { Character::hit(damage, enemy, hitType); - if (hitType == TR::HIT_BLADE) - addBloodBlade(); - - if (hitType == TR::HIT_SPIKES) - addBloodSpikes(); + switch (hitType) { + case TR::HIT_BLADE : addBloodBlade(); break; + case TR::HIT_SPIKES : addBloodSpikes(); break; + case TR::HIT_SLAM : addBloodSlam(enemy); break; + default : ; + } if (health > 0.0f) return; diff --git a/src/level.h b/src/level.h index 3f93061..330e54e 100644 --- a/src/level.h +++ b/src/level.h @@ -413,6 +413,9 @@ struct Level : IGame { case TR::Entity::TRAP_CEILING_2 : entity.controller = new TrapCeiling(this, i); break; + case TR::Entity::TRAP_SLAM : + entity.controller = new TrapSlam(this, i); + break; case TR::Entity::TRAP_SWORD : entity.controller = new TrapSword(this, i); break; diff --git a/src/trigger.h b/src/trigger.h index f4202f8..9bc3a88 100644 --- a/src/trigger.h +++ b/src/trigger.h @@ -640,6 +640,38 @@ struct TrapCeiling : Controller { } }; +#define SLAM_DAMAGE 400 + +struct TrapSlam : Controller { + enum { + STATE_OPEN, + STATE_SLAM, + }; + + bool bite; + + TrapSlam(IGame *game, int entity) : Controller(game, entity), bite(false) {} + + virtual void update() { + if (isActive()) { + animation.setState(STATE_SLAM); + + if (animation.frameIndex >= 20) + bite = false; + + Character *lara = (Character*)level->laraController; + if (animation.state == STATE_SLAM && !bite && collide(lara)) { + lara->hit(SLAM_DAMAGE, this, TR::HIT_SLAM); + bite = true; + } + + } else + animation.setState(STATE_OPEN); + + updateAnimation(true); + } +}; + struct TrapSword : Controller { TrapSword(IGame *game, int entity) : Controller(game, entity) {}