From: Andy D. <kha...@us...> - 2004-12-27 19:03:10
|
Update of /cvsroot/planeshift/planeshift/src/npcclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5223 Modified Files: npcbehave.cpp Log Message: Added perception for when the npc falls off and dies. Index: npcbehave.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/npcbehave.cpp,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** npcbehave.cpp 27 Dec 2004 18:15:25 -0000 1.65 --- npcbehave.cpp 27 Dec 2004 19:02:57 -0000 1.66 *************** *** 675,679 **** iPcMesh); ! csVector3 oldpos,pos2; float rot; iSector * sector; --- 675,679 ---- iPcMesh); ! csVector3 oldpos,pos2, vel; float rot; iSector * sector; *************** *** 682,686 **** --- 682,693 ---- npc->GetLinMove()->ExtrapolatePosition(timedelta); npc->GetLinMove()->GetLastPosition(pos2,rot,sector); + npc->GetLinMove()->GetVelocity(vel); + if (vel.y < 50) + { + Perception suicide("npcdeath"); + npc->TriggerEvent(&suicide,eventmgr); + return; + } if (fabs(oldpos.x - pos2.x) < EPSILON && fabs(oldpos.y - pos2.y) < EPSILON && *************** *** 831,835 **** // CPrintf(CON_DEBUG, "MoveTo Advance %1.2f\n",timedelta); ! csVector3 pos,pos2; float rot; iSector * sector; --- 838,842 ---- // CPrintf(CON_DEBUG, "MoveTo Advance %1.2f\n",timedelta); ! csVector3 pos,pos2, vel; float rot; iSector * sector; *************** *** 838,841 **** --- 845,856 ---- npc->GetLinMove()->ExtrapolatePosition(timedelta); npc->GetLinMove()->GetLastPosition(pos2,rot,sector); + npc->GetLinMove()->GetVelocity(vel); + + if (vel.y < 50) + { + Perception suicide("npcdeath"); + npc->TriggerEvent(&suicide,eventmgr); + return; + } if (pos == pos2) // then stopped dead, presumably by collision *************** *** 1411,1415 **** void ChaseOperation::Advance(float timedelta,NPC *npc,EventManager *eventmgr) { ! csVector3 pos,pos2; float rot,dummyrot; iSector * sector; --- 1426,1430 ---- void ChaseOperation::Advance(float timedelta,NPC *npc,EventManager *eventmgr) { ! csVector3 pos,pos2,vel; float rot,dummyrot; iSector * sector; *************** *** 1418,1421 **** --- 1433,1444 ---- npc->GetLinMove()->ExtrapolatePosition(timedelta); npc->GetLinMove()->GetLastPosition(pos2,rot,sector); + npc->GetLinMove()->GetVelocity(vel); + + if (vel.y < 50) + { + Perception suicide("npcdeath"); + npc->TriggerEvent(&suicide,eventmgr); + return; + } if (pos == pos2) // then stopped dead, presumably by collision *************** *** 1742,1746 **** --- 1765,1778 ---- void MovePathOperation::Advance(float timedelta,NPC *npc,EventManager *eventmgr) { + csVector3 vel; npc->GetLinMove()->ExtrapolatePosition(timedelta); + npc->GetLinMove()->GetVelocity(vel); + + if (vel.y < 50) + { + Perception suicide("npcdeath"); + npc->TriggerEvent(&suicide,eventmgr); + return; + } csVector3 pos; float rot; iSector *sec; |