#include <gCycleMovement.h>
Public Member Functions | |
gEnemyInfluence () | |
ePlayerNetID const * | GetEnemy () const |
REAL | GetTime () const |
void | AddSensor (const gSensor &sensor, REAL timePenalty, gCycleMovement *thisCycle) |
void | AddWall (const eWall *wall, eCoord const &point, REAL timePenalty, gCycleMovement *thisCycle) |
void | AddWall (const gPlayerWall *wall, REAL timeBuilt, gCycleMovement *thisCycle) |
Private Attributes | |
nObserverPtr< ePlayerNetID > | lastEnemyInfluence |
REAL | lastTime |
Definition at line 53 of file gCycleMovement.h.
gEnemyInfluence::gEnemyInfluence | ( | ) |
Definition at line 521 of file gCycleMovement.cpp.
References lastTime, and sg_suicideTimeout.
00523 { 00524 lastTime = -sg_suicideTimeout;
const ePlayerNetID * gEnemyInfluence::GetEnemy | ( | ) | const |
Definition at line 511 of file gCycleMovement.cpp.
References nObserverPtr< T >::GetPointer(), and lastEnemyInfluence.
Referenced by gCycle::KillAt().
00513 { 00514 return lastEnemyInfluence.GetPointer();
REAL gEnemyInfluence::GetTime | ( | ) | const |
Definition at line 516 of file gCycleMovement.cpp.
References lastTime.
Referenced by gCycle::KillAt().
00518 { 00519 return lastTime;
void gEnemyInfluence::AddSensor | ( | const gSensor & | sensor, | |
REAL | timePenalty, | |||
gCycleMovement * | thisCycle | |||
) |
Definition at line 527 of file gCycleMovement.cpp.
References AddWall(), eSensor::before_hit, nCLIENT, and sn_GetNetState().
Referenced by gCycleMovement::CalculateAcceleration().
00529 { 00530 // the client has no need for this, it does not execute AI code 00531 if ( sn_GetNetState() == nCLIENT ) 00532 return; 00533 00534 // check if the sensor hit an enemy wall 00535 // if ( sensor.type != gSENSOR_ENEMY ) 00536 // return; 00537 00538 // get the wall 00539 if ( !sensor.ehit ) 00540 return; 00541 00542 eWall* wall = sensor.ehit->GetWall(); 00543 if ( !wall ) 00544 return; 00545 00546 AddWall( wall, sensor.before_hit, timePenalty, thisCycle );
void gEnemyInfluence::AddWall | ( | const eWall * | wall, | |
eCoord const & | point, | |||
REAL | timePenalty, | |||
gCycleMovement * | thisCycle | |||
) |
Definition at line 549 of file gCycleMovement.cpp.
References eWall::Edge(), nCLIENT, eHalfEdge::Ratio(), REAL, sn_GetNetState(), and gPlayerWall::Time().
Referenced by AddSensor(), and gCycle::PassEdge().
00551 { 00552 // the client has no need for this, it does not execute AI code 00553 if ( sn_GetNetState() == nCLIENT ) 00554 return; 00555 00556 // see if it is a player wall 00557 gPlayerWall const * playerWall = dynamic_cast<gPlayerWall const *>( wall ); 00558 if ( !playerWall ) 00559 return; 00560 00561 // get the approximate time the wall was drawn 00562 REAL alpha = .5f; 00563 // try to get a more accurate value 00564 if ( playerWall->Edge() ) 00565 { 00566 // get the position of the collision point 00567 alpha = playerWall->Edge()->Ratio( pos ); 00568 } 00569 REAL timeBuilt = playerWall->Time( 0.5f ); 00570 00571 AddWall( playerWall, timeBuilt - timePenalty, thisCycle );
void gEnemyInfluence::AddWall | ( | const gPlayerWall * | wall, | |
REAL | timeBuilt, | |||
gCycleMovement * | thisCycle | |||
) |
Definition at line 574 of file gCycleMovement.cpp.
References gCycleMovement::Alive(), eGameObject::Alive(), ePlayerNetID::CurrentTeam(), gPlayerWall::Cycle(), ePlayerNetID::Enemies(), gCycleMovement::GetLastTurnTime(), nObserverPtr< T >::GetPointer(), lastEnemyInfluence, lastTime, eGameObject::LastTime(), nCLIENT, ePlayerNetID::Object(), eNetGameObject::Player(), REAL, sg_enemyCurrentTimeInfluence, sg_enemyDeadTimePenalty, sg_enemyFriendTimePenalty, and sn_GetNetState().
00576 { 00577 // the client has no need for this, it does not execute AI code 00578 if ( sn_GetNetState() == nCLIENT ) 00579 return; 00580 00581 if ( !wall ) 00582 return; 00583 00584 // get the cycle 00585 gCycle *cycle = wall->Cycle(); 00586 if ( !cycle ) 00587 return; 00588 00589 // don't count self influence 00590 if ( thisCycle == cycle ) 00591 return; 00592 00593 REAL time = timeBuilt; 00594 if ( thisCycle ) 00595 { 00596 REAL currentTime = thisCycle->LastTime(); 00597 time += ( currentTime - time ) * sg_enemyCurrentTimeInfluence; 00598 } 00599 00600 // get the player 00601 ePlayerNetID* player = cycle->Player(); 00602 if ( !player ) 00603 return; 00604 00605 // don't accept milkers. 00606 if ( thisCycle && !ePlayerNetID::Enemies( thisCycle->Player(), player ) ) 00607 { 00608 return; 00609 } 00610 00611 // if the player is not our enemy, add extra time penalty 00612 if ( thisCycle->Player() && player->CurrentTeam() == thisCycle->Player()->CurrentTeam() ) 00613 { 00614 // the time shall be at most the time of the last turn, it should count as suicide if 00615 // I drive into your three mile long wall 00616 if ( time > cycle->GetLastTurnTime() ) 00617 time = cycle->GetLastTurnTime(); 00618 time -= sg_enemyFriendTimePenalty; 00619 } 00620 const ePlayerNetID* pInfluence = this->lastEnemyInfluence.GetPointer(); 00621 00622 // calculate effective last time. Add malus if the player is dead. 00623 REAL lastEffectiveTime = lastTime; 00624 if ( !pInfluence || !pInfluence->Object() || !pInfluence->Object()->Alive() ) 00625 { 00626 lastEffectiveTime -= sg_enemyDeadTimePenalty; 00627 } 00628 00629 // same for the current influence 00630 REAL effectiveTime = time; 00631 if ( !cycle->Alive() ) 00632 { 00633 effectiveTime -= sg_enemyDeadTimePenalty; 00634 } 00635 00636 // if the new influence is newer, take it. 00637 if ( effectiveTime > lastEffectiveTime || !bool(lastEnemyInfluence) ) 00638 { 00639 lastEnemyInfluence = player; 00640 lastTime = time; 00641 }
nObserverPtr< ePlayerNetID > gEnemyInfluence::lastEnemyInfluence [private] |
REAL gEnemyInfluence::lastTime [private] |
Definition at line 56 of file gCycleMovement.h.
Referenced by AddWall(), gEnemyInfluence(), and GetTime().