mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-14 17:14:29 +02:00
#22 add slam (teeth) trap
This commit is contained in:
@@ -311,6 +311,7 @@ namespace TR {
|
|||||||
HIT_BOULDER,
|
HIT_BOULDER,
|
||||||
HIT_SPIKES,
|
HIT_SPIKES,
|
||||||
HIT_FLAME,
|
HIT_FLAME,
|
||||||
|
HIT_SLAM,
|
||||||
HIT_REX,
|
HIT_REX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
28
src/lara.h
28
src/lara.h
@@ -469,6 +469,7 @@ struct Lara : Character {
|
|||||||
//reset(10, vec3(90443, 11264 - 256, 114614), PI, STAND_ONWATER); // villa mortal 2
|
//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(50, vec3(53703, -18688, 13769), PI); // Level 10c (scion holder)
|
||||||
//reset(19, vec3(35364, -512, 40199), PI * 0.5f); // Level 10c (lava flow)
|
//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
|
#endif
|
||||||
chestOffset = animation.getJoints(getMatrix(), 7).pos;
|
chestOffset = animation.getJoints(getMatrix(), 7).pos;
|
||||||
}
|
}
|
||||||
@@ -1300,11 +1301,15 @@ struct Lara : Character {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addBlood(float radius, float height, const vec3 &spriteVelocity) {
|
void addBlood(const vec3 &sprPos, const vec3 &sprVel) {
|
||||||
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(sprPos.x), int(sprPos.y), int(sprPos.z), Sprite::FRAME_ANIMATED);
|
||||||
int index = Sprite::add(game, TR::Entity::BLOOD, getRoomIndex(), int(p.x), int(p.y), int(p.z), Sprite::FRAME_ANIMATED);
|
|
||||||
if (index > -1)
|
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() {
|
void addBloodSpikes() {
|
||||||
@@ -1317,6 +1322,10 @@ struct Lara : Character {
|
|||||||
addBlood(64.0f, 744.0f, vec3(sinf(ang), 0.0f, cosf(ang)) * speed);
|
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) {
|
virtual void hit(float damage, Controller *enemy = NULL, TR::HitType hitType = TR::HIT_DEFAULT) {
|
||||||
if (dozy) return;
|
if (dozy) return;
|
||||||
@@ -1327,11 +1336,12 @@ struct Lara : Character {
|
|||||||
|
|
||||||
Character::hit(damage, enemy, hitType);
|
Character::hit(damage, enemy, hitType);
|
||||||
|
|
||||||
if (hitType == TR::HIT_BLADE)
|
switch (hitType) {
|
||||||
addBloodBlade();
|
case TR::HIT_BLADE : addBloodBlade(); break;
|
||||||
|
case TR::HIT_SPIKES : addBloodSpikes(); break;
|
||||||
if (hitType == TR::HIT_SPIKES)
|
case TR::HIT_SLAM : addBloodSlam(enemy); break;
|
||||||
addBloodSpikes();
|
default : ;
|
||||||
|
}
|
||||||
|
|
||||||
if (health > 0.0f)
|
if (health > 0.0f)
|
||||||
return;
|
return;
|
||||||
|
@@ -413,6 +413,9 @@ struct Level : IGame {
|
|||||||
case TR::Entity::TRAP_CEILING_2 :
|
case TR::Entity::TRAP_CEILING_2 :
|
||||||
entity.controller = new TrapCeiling(this, i);
|
entity.controller = new TrapCeiling(this, i);
|
||||||
break;
|
break;
|
||||||
|
case TR::Entity::TRAP_SLAM :
|
||||||
|
entity.controller = new TrapSlam(this, i);
|
||||||
|
break;
|
||||||
case TR::Entity::TRAP_SWORD :
|
case TR::Entity::TRAP_SWORD :
|
||||||
entity.controller = new TrapSword(this, i);
|
entity.controller = new TrapSword(this, i);
|
||||||
break;
|
break;
|
||||||
|
@@ -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 {
|
struct TrapSword : Controller {
|
||||||
TrapSword(IGame *game, int entity) : Controller(game, entity) {}
|
TrapSword(IGame *game, int entity) : Controller(game, entity) {}
|
||||||
|
Reference in New Issue
Block a user