Esempio n. 1
0
// find the best gSpawnPoint
gSpawnPoint * gArena::LeastDangerousSpawnPoint()
{
    REAL mindanger=1E+30;
    gSpawnPoint *ret=NULL;

    for(int i=0;i<spawnPoints.Len();i++)
    {
        REAL newDanger = spawnPoints(i)->Danger();
        if (newDanger < mindanger - EPS )
        {
            ret = spawnPoints(i);
            mindanger = newDanger;
        }
    }

    if (!ret)
    {
        throw tGenericException( "No spawnpoint available." );
    }

#ifdef DEBUG
    //	std::cout << "Spawn at " << ret->location << "\n";
#endif

    return ret;
}
Esempio n. 2
0
void gArena::RemoveAllSpawn() {
    while (spawnPoints.Len()){
        gSpawnPoint *s=spawnPoints(0);
        spawnPoints.Remove(s,s->id);
        delete s;
    }
}
std::auto_ptr<Actor> CtfSoldierSpawnSystem::Spawn( ::core::ClientData& clientData, Team::Type team )
{
    map::SpawnPoints_t spawnPoints( map::ctf::CtfSoldierSpawnPointMapElementSystem::Get()->GetActiveSpawnPoints( team ) );
    map::SpawnPoint spawnPoint( spawnPoints[rand() % spawnPoints.size()] );
    std::auto_ptr<Actor> player( mActorFactory( mPlayerAutoId ) );
    Opt<ITeamComponent> teamC( player->Get<ITeamComponent>() );
    if ( teamC.IsValid() )
    {
        teamC->SetTeam( team );
    }
    return SoldierSpawnSystem::Get()->Spawn( clientData, spawnPoint, player );
}
Esempio n. 4
0
gArena::~gArena()
{
    // usually, we would write this:
    // RemoveAllSpawn();

    // but because of a bug in GCC version 3.3.5 to 3.4.x (4.0 is unaffected),
    // we have to dublicate the code of the function.
    while (spawnPoints.Len())
    {
        gSpawnPoint *s=spawnPoints(0);
        spawnPoints.Remove(s,s->id);
        delete s;
    }
}
Esempio n. 5
0
void gArena::PrepareGrid(eGrid *grid, gParser *aParser)
{
    RemoveAllSpawn();

    init_grid_in_process=true;
    grid->Create();
    grid->SetWinding(axes);

    aParser->setSizeMultiplier(sizeMultiplier);
    aParser->Parse();

    init_grid_in_process=false;

    int i;
    for(i=0;i<spawnPoints.Len();i++)
        spawnPoints(i)->Clear();

    // update arena bounds
    eWallRim::UpdateBounds();
}
Esempio n. 6
0
std::auto_ptr<Actor> SoldierSpawnSystem::Spawn( core::ClientData& clientData )
{
    map::SpawnPoints_t spawnPoints( map::SoldierSpawnPointMapElementSystem::Get()->GetActiveSpawnPoints() );
    map::SpawnPoint spawnPoint( spawnPoints[RandomGenerator::global()() % spawnPoints.size()] );
    return Spawn( clientData, spawnPoint );
}