File src/fdungeon.cpp changed (mode: 100644) (index 5e03c4b..882795b) |
... |
... |
Agent *Dungeon::addAgent( btVector3 position, btScalar mass, btScalar restitutio |
1869 |
1869 |
a->angle = { 0.0, 0.0, 0.0 }; |
a->angle = { 0.0, 0.0, 0.0 }; |
1870 |
1870 |
a->scale = scale; |
a->scale = scale; |
1871 |
1871 |
a->offsetYaw = 0.0; |
a->offsetYaw = 0.0; |
1872 |
|
a->health = 100.0; // A good enough default as any. |
|
|
1872 |
|
// Static agents are invincible unless health and maxHealth are set. |
|
1873 |
|
a->health = isStatic ? 0.0 : 100.0; |
1873 |
1874 |
a->maxHealth = a->health; |
a->maxHealth = a->health; |
1874 |
1875 |
a->waterHealthRate = 0.0; |
a->waterHealthRate = 0.0; |
1875 |
1876 |
a->mass = mass; |
a->mass = mass; |
|
... |
... |
Agent *Dungeon::rayImpact( Agent *a, std::pair<linalg::vec<double,3>,linalg::vec |
3205 |
3206 |
if( atype == "agent" || atype == "spawn" ){ |
if( atype == "agent" || atype == "spawn" ){ |
3206 |
3207 |
// Ray hit an agent. |
// Ray hit an agent. |
3207 |
3208 |
// TODO: Headshots, special damage zones, blood vertices, destroying static objects, etc. |
// TODO: Headshots, special damage zones, blood vertices, destroying static objects, etc. |
3208 |
|
if( hitAgent != &defaultAgent |
|
3209 |
|
&& (hitAgent->type == TYPE_AGENT || hitAgent->type == TYPE_VEHICLE || hitAgent->type == TYPE_DYNAMIC) ){ |
|
|
3209 |
|
if( hitAgent != &defaultAgent ){ |
3210 |
3210 |
if( defenseSkill.length() > 0 && hitAgent->skills.size() > 0 ){ |
if( defenseSkill.length() > 0 && hitAgent->skills.size() > 0 ){ |
3211 |
3211 |
auto defense_skill_it = hitAgent->skills.find( defenseSkill ); |
auto defense_skill_it = hitAgent->skills.find( defenseSkill ); |
3212 |
3212 |
if( defense_skill_it != hitAgent->skills.end() ){ |
if( defense_skill_it != hitAgent->skills.end() ){ |
|
... |
... |
void Dungeon::simulate( double maxDraw, double d, std::string defenseSkill ){ |
3901 |
3901 |
}else{ |
}else{ |
3902 |
3902 |
// Run AI. Remove agent if aiFrameCallback returns true. |
// Run AI. Remove agent if aiFrameCallback returns true. |
3903 |
3903 |
if( (*aiFrameCallback)( agent_ptr, d ) ){ |
if( (*aiFrameCallback)( agent_ptr, d ) ){ |
3904 |
|
// Run the agent's death callback. |
|
3905 |
|
if(portalCallback && agent_ptr->onDeath.length() > 0) |
|
3906 |
|
(*portalCallback)( agent_ptr->onDeath ); |
|
3907 |
3904 |
// Flag the agent for removal and skip to the next agent. |
// Flag the agent for removal and skip to the next agent. |
3908 |
3905 |
agent_ptr->health = 0.0; |
agent_ptr->health = 0.0; |
3909 |
3906 |
agent_ptr = agent_ptr->next; |
agent_ptr = agent_ptr->next; |
|
... |
... |
void Dungeon::simulate( double maxDraw, double d, std::string defenseSkill ){ |
3934 |
3931 |
agent_ptr->rigidBody ? agent_ptr->rigidBody->getLinearVelocity() : btVector3(0,0,0); |
agent_ptr->rigidBody ? agent_ptr->rigidBody->getLinearVelocity() : btVector3(0,0,0); |
3935 |
3932 |
double velHoriz = linalg::length(linalg::vec<double,2>(velVec.x(), velVec.z())); |
double velHoriz = linalg::length(linalg::vec<double,2>(velVec.x(), velVec.z())); |
3936 |
3933 |
bool jumping = agent_ptr->type == TYPE_AGENT && agent_ptr->standing == 0.0; |
bool jumping = agent_ptr->type == TYPE_AGENT && agent_ptr->standing == 0.0; |
3937 |
|
if( agent_ptr->health > 0.0 || agent_ptr->maxHealth <= 0.0 ){ |
|
|
3934 |
|
if( agent_ptr->health > 0.0 ){ |
3938 |
3935 |
auto fire_it = agent_ptr->avatar.bodyAnimations.find("stand_fire"); |
auto fire_it = agent_ptr->avatar.bodyAnimations.find("stand_fire"); |
3939 |
3936 |
if( fire_it != agent_ptr->avatar.bodyAnimations.end() |
if( fire_it != agent_ptr->avatar.bodyAnimations.end() |
3940 |
3937 |
&& agent_ptr->avatar.bodyFrame >= fire_it->second.x |
&& agent_ptr->avatar.bodyFrame >= fire_it->second.x |
|
... |
... |
void Dungeon::simulate( double maxDraw, double d, std::string defenseSkill ){ |
3995 |
3992 |
Agent *a = agent_ptr->next; |
Agent *a = agent_ptr->next; |
3996 |
3993 |
if(agent_ptr && agent_ptr != playerAgent |
if(agent_ptr && agent_ptr != playerAgent |
3997 |
3994 |
&& agent_ptr->health <= 0.0 && agent_ptr->maxHealth > 0.0){ |
&& agent_ptr->health <= 0.0 && agent_ptr->maxHealth > 0.0){ |
|
3995 |
|
// Prevent this from triggering again by setting maxHealth negative. |
|
3996 |
|
agent_ptr->maxHealth = -1.0; |
|
3997 |
|
// Run the agent's death callback. |
|
3998 |
|
if(portalCallback && agent_ptr->onDeath.length() > 0) |
|
3999 |
|
(*portalCallback)( agent_ptr->onDeath ); |
|
4000 |
|
// Remove the agent from the world (though probably not completely from memory until next level load). |
3998 |
4001 |
removeAgent( agent_ptr, true ); |
removeAgent( agent_ptr, true ); |
3999 |
4002 |
} |
} |
4000 |
4003 |
agent_ptr = a; |
agent_ptr = a; |