Example #1
0
// ACTUAL RESPAWN OF ACTOR
void CRespawnQueueActor::Respawn( CRespawnPoint* point )
{
    CActor* a = 0;
    a = FACTORY->Actors.Create( actorName.c_str(), actorConfigFile.c_str() );
    if ( !a )
    {
      CONSOLE.addx( "Incorrect actor name on respawn: %s", actorName.c_str() );
      return;
    }
    if ( point )
    {
      a->setPosition( point->vPosition );
      a->setDirection( point->fDirection );
    }

    if ( player )
    {
      a->setOwnersPlayerID( player->playerID );
      a->setControls( player->getControls() );
      a->setDebugText( player->className );
    }
    else
    {
      a->setDebugText( a->getFactoryName() );
    }

    bool sent = false;
    // load parent attachment
    if ( point )
    {
      if ( ( point->parentActorName.size() > 1 ) && ( point->parentActorScriptName.size() > 1 ) )
      {
        CActor* pa = 0;
        pa = FACTORY->Actors.Create( point->parentActorName.c_str(), point->parentActorScriptName.c_str() );
        pa->setPosition( point->vPosition );
        pa->setDirection( point->fDirection ); 
        pa->setRespawnable( false );
        a->attachToParentNode( pa, a->getControls() );

        pa->Broadcast();
        sent = true;
      }
    }

    // send the actor to all players
    if ( !sent )
    {
      CGameServer::BroadcastActor( a );
    }


    WORLD.GetRules()->OnActorRespawn( a, point );
}