Esempio n. 1
0
//destroys the asteroid, spawning new ones if necessary
void AsteroidHit(LIST * a, int fromplayershot)
{
   if(a)
   {
      PlaySoundIndex(SND_EXP_ASTEROID);

      SpawnExplosion(NewListNode(&g_explosion_list, sizeof(EXPLOSION)), &(((ASTEROID *)a->d)->pos), (int)(((ASTEROID *)a->d)->scale) * 8);

      if(((ASTEROID *)a->d)->scale > 1.0f)
      {
         if(fromplayershot)
            Score(((ASTEROID *)a->d)->scale > 2.0f ? 20 : 50, &(((ASTEROID *)a->d)->pos));

         SpawnAsteroid(NewListNode(&g_asteroid_list, sizeof(ASTEROID)), &(((ASTEROID *)a->d)->pos), ((ASTEROID *)a->d)->scale * 0.5f);
         SpawnAsteroid(NewListNode(&g_asteroid_list, sizeof(ASTEROID)), &(((ASTEROID *)a->d)->pos), ((ASTEROID *)a->d)->scale * 0.5f);
      }
      else if(fromplayershot)
         Score(100, &(((ASTEROID *)a->d)->pos));

      RemoveNode(a, &g_asteroid_list);

      if(!g_asteroid_list && g_ships)
         g_time_to_reset = RESET_TIME;
   }
}
PyResult Command_roid( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	if( !args.isNumber( 1 ) )
		throw PyException( MakeCustomError( "Argument 1 should be an item type ID" ) );
    const uint32 typeID = atoi( args.arg( 1 ).c_str() );

	if( !args.isNumber( 2 ) )
		throw PyException( MakeCustomError( "Argument 2 should be a radius" ) );
    const double radius = atof( args.arg( 2 ).c_str() );

	if( 0 >= radius )
		throw PyException( MakeCustomError( "Invalid radius." ) );

	if( !who->IsInSpace() )
		throw PyException( MakeCustomError( "You must be in space to spawn things." ) );

    sLog.Log( "Command", "Roid %u of radius %f", typeID, radius );

	GPoint position( who->GetPosition() );
	position.x += radius + 1 + who->GetRadius();	//put it raw enough away to not push us around.
	
	SpawnAsteroid( who->System(), typeID, radius, position );

	return new PyString( "Spawn successsfull." );
}
Esempio n. 3
0
//initializes or resets the state of the game
void NextLevel(void)
{
   int i;

   PlaySoundIndex(SND_NEWLEVEL);

   g_level++;

   InitStarfield(&g_starfield);

   DeleteEntireList(&g_asteroid_list);
   DeleteEntireList(&g_alien_list);
   DeleteEntireList(&g_shot_list);
   DeleteEntireList(&g_explosion_list);
   DeleteEntireList(&g_burst_list);
   DeleteEntireList(&g_powerup_list);

   i = g_player.powerups;
   ResetPlayer(&g_player);
   g_player.powerups = i;

   for(i = 0; i < (int)(log((double)g_level) + 2.5); i++)
      SpawnAsteroid(NewListNode(&g_asteroid_list, sizeof(ASTEROID)), NULL, 4.0f);

   Score((g_level > 100 ? 999 : (g_level - 1) * 10), NULL); //completion bonus

   g_frame = 0;
   g_time_to_reset = 0;
}
Esempio n. 4
0
void GameScreen::Update(const float time_step)
{
	player.Update(time_step);

	bool game_over = false;

	//Update asteroids checking them against player and lasers
	BSphere player_sphere = player.GetBSphere();
	std::list<Asteroid*>::iterator iter = asteroids.begin();
	while(iter != asteroids.end())
	{
		Asteroid* ast = iter._Ptr->_Myval;

		ast->Update(time_step);

		//Check asteroid is in the play region
		//if not reset it
		if(!play_region.Contains(ast->GetBSphere()))
		{
			//Move the asteroid elsewhere
			RepositionAsteroid(ast);
		}
		//check against the player
		if(player_sphere.Contains(ast->GetBSphere()))
		{
			//player.AddScore(ast->GetBSphere().GetRadius());
			game_over = true;
		}

		iter++;
	}

	//Do some laser-asteroid checking
	player.CheckLaserAsteroidCollisions(&asteroids);

	asteroid_spawn_countdown -= time_step;

	if(asteroid_spawn_countdown < 0 && asteroids.size() < MAX_ASTEROIDS)
	{
		asteroid_spawn_countdown = ASTEROID_SPAWN_INTERVAL;

		SpawnAsteroid();
	}

	if(game_over)
	{
		GameOverScreen *gameover_screen = new GameOverScreen();
		gameover_screen->Initialise(player.GetScore());
		RustyLib::Framework::ScreenManagement::ScreenManager::Instance().ChangeScreen(
					gameover_screen);
	}
}
PyResult Command_spawnbelt( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	if( !who->IsInSpace() )
		throw PyException( MakeCustomError( "You must be in space to spawn things." ) );

    const double beltradius = 100000.0;
	const double beltdistance = 25000.0;
	const double roidradius = MakeRandomFloat( 100.0, 1000.0 );
	const double beltangle = M_PI * 2.0 / 3.0;
	const uint32 pcs = 20 + MakeRandomInt( -10, 10 );   // reduced from 160 + MakeRandomInt( -10, 10 )

	const GPoint position( who->GetPosition() );

	const double R = sqrt( position.x * position.x + position.z * position.z );
	const GPoint r = position * ( R + beltdistance - beltradius ) / R;

	double phi = atan( position.x / position.z );
	if( position.z < 0 )
		phi += M_PI;

	SystemManager* sys = who->System();
	std::map<double, uint32> roidDist;
	if( !db->GetRoidDist( sys->GetSystemSecurity(), roidDist ) )
    {
        sLog.Error( "Command", "Couldn't get roid list for system security %s", sys->GetSystemSecurity() );

		throw PyException( MakeCustomError( "Couldn't get roid list for system security %s", sys->GetSystemSecurity() ) );
	}

    //double distanceToMe;
	double alpha;
    GPoint mposition;

	for( uint32 i = 0; i < pcs; ++i )
    {
		alpha = beltangle * MakeRandomFloat( -0.5, 0.5 );

		mposition.x = beltradius * sin( phi + alpha ) + roidradius * MakeRandomFloat( 0, 15 );
		mposition.z = beltradius * cos( phi + alpha ) + roidradius * MakeRandomFloat( 0, 15 );
		mposition.y = position.y - r.y + roidradius * MakeRandomFloat( 0, 15 );
        //distanceToMe = (r + mposition - position).length();
        SpawnAsteroid( who->System(), GetAsteroidType( MakeRandomFloat(), roidDist ), roidradius, r + mposition );
	}

	return new PyString( "Spawn successsfull." );
}
Esempio n. 6
0
void ABxtAsteroidSpawner::Tick(float deltaSeconds)
{
	Super::Tick(deltaSeconds);

	if (_numAsteroidsSpawned >= TotalAsteroidsToSpawn)
	{
		// already spawned all the asteroids we'll ever need
		return;
	}

	float curTime = GetWorld()->GetTimeSeconds();
	if ((-1.0f == _lastSpawnTime) || ((curTime - _lastSpawnTime) > AsteroidSpawnDelay))
	{
		SpawnAsteroid();

		_lastSpawnTime = curTime;
		++_numAsteroidsSpawned;
	}
}
Esempio n. 7
0
PyResult Command_spawnbelt( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
    if( !who->IsInSpace() )
        throw PyException( MakeCustomError( "You must be in space to spawn things." ) );

	bool makeIceBelt = false;
	bool makeRareIce = false;
	uint32 customCount = 0;
    if( args.argCount() >= 2 )
	{
        if( !args.isNumber( 1 ) )
		{
			if( args.arg( 1 ) == "ice" )
				makeIceBelt = true;
		}
		else
		{
			if( atoi(args.arg( 1 ).c_str()) > 15 )
				customCount = atoi(args.arg( 1 ).c_str());
			else
				PyException( MakeCustomError( "Argument 1 should be at least 15!" ) );
		}
	}

	if( args.argCount() >= 3 )
	{
		if( args.isNumber( 2 ) )
		{
			if( atoi(args.arg( 2 ).c_str()) > 15 )
				customCount = atoi(args.arg(2).c_str());
			else
				PyException( MakeCustomError( "Argument 2 should be at least 15!" ) );
		}
		else
			if( args.arg( 2 ) == "ice" )
				makeIceBelt = true;
			if( args.arg( 2 ) == "rareice" )
			{
				makeIceBelt = true;
				makeRareIce = true;
			}
	}

    const double beltradius = 100000.0;
    const double beltdistance = 25000.0;
    double roidradius;
    const double beltangle = M_PI * 2.0 / 3.0;
    uint32 pcs = 0;
	
	if( customCount > 15 )
		pcs = customCount + static_cast<uint32>(MakeRandomInt( -10, 10 ));
	else
		pcs = 30 + static_cast<uint32>(MakeRandomInt( -10, 10 ));

    const GPoint position( who->GetPosition() );

    const double R = sqrt( position.x * position.x + position.z * position.z );
    const GPoint r = position * ( R + beltdistance - beltradius ) / R;

    double phi = atan( position.x / position.z );
    if( position.z < 0 )
        phi += M_PI;

    SystemManager* sys = who->System();
    std::map<double, uint32> roidDist;
	if( makeIceBelt )
	{
		std::string securityStatus = sys->GetSystemSecurity();
		if( !makeRareIce )
		{
			roidDist.insert(std::pair<double,uint32>(0.60,16264));		// Blue Ice
			roidDist.insert(std::pair<double,uint32>(0.45,17975));		// Thick Blue Ice
			roidDist.insert(std::pair<double,uint32>(0.30,28627));		// Azure Ice
			roidDist.insert(std::pair<double,uint32>(0.20,16262));		// Clear Icicle
			roidDist.insert(std::pair<double,uint32>(0.10,16267));		// Dark Glitter
		}
		if( makeRareIce )
		{
			roidDist.insert(std::pair<double,uint32>(0.90,16263));		// Glacial Mass
			roidDist.insert(std::pair<double,uint32>(0.80,16265));		// White Glaze
			roidDist.insert(std::pair<double,uint32>(0.70,16266));		// Glare Crust
			roidDist.insert(std::pair<double,uint32>(0.60,16268));		// Gelidus
			roidDist.insert(std::pair<double,uint32>(0.50,16269));		// Krystallos
			roidDist.insert(std::pair<double,uint32>(0.40,17976));		// Pristine White Glaze
			roidDist.insert(std::pair<double,uint32>(0.30,17977));		// Smooth Glacial Mass
			roidDist.insert(std::pair<double,uint32>(0.20,17978));		// Enriched Clear Icicle
			roidDist.insert(std::pair<double,uint32>(0.10,28628));		// Crystalline Icicle
		}
	}
	else
	{
		if( !db->GetRoidDist( sys->GetSystemSecurity(), roidDist ) )
		{
			sLog.Error( "Command", "Couldn't get roid list for system security %s", sys->GetSystemSecurity() );

			throw PyException( MakeCustomError( "Couldn't get roid list for system security %s", sys->GetSystemSecurity() ) );
		}
	}

    double distanceToMe;
    double alpha;
    GPoint mposition;

	if( makeIceBelt )
		pcs *= 2;

    for( uint32 i = 0; i < pcs; ++i )
    {
        alpha = beltangle * MakeRandomFloat( -0.5, 0.5 );

		if( makeIceBelt )
			roidradius = MakeRandomFloat( 1000.0, 10000.0 );
		else
			roidradius = MakeRandomFloat( 100.0, 1000.0 );
        mposition.x = beltradius * sin( phi + alpha ) + roidradius * MakeRandomFloat( 0, 15 );
        mposition.z = beltradius * cos( phi + alpha ) + roidradius * MakeRandomFloat( 0, 15 );
        mposition.y = position.y - r.y + roidradius * MakeRandomFloat( 0, 15 );
        distanceToMe = (r + mposition - position).length();
        SpawnAsteroid( who->System(), GetAsteroidType( MakeRandomFloat(), roidDist ), roidradius, r + mposition );
    }

    return new PyString( "Spawn successsfull." );
}
Esempio n. 8
0
/*
 * SQL to remove all asteroids from space in ALL systems.
 * Important, run in this order or the attributes will not be deleted!
 * 
DELETE FROM srvEntity_default_attributes WHERE attributeID > 0 and itemID in
(SELECT itemID from srvEntity where ownerID=1 AND typeID in
(SELECT typeID from invTypes where groupID in
(select groupID FROM invGroups where categoryID=25) or groupID=711));
DELETE FROM srvEntity_attributes WHERE attributeID > 0 and itemID in
(SELECT itemID from srvEntity where ownerID=1 AND typeID in
(SELECT typeID from invTypes where groupID in
(select groupID FROM invGroups where categoryID=25) or groupID=711));
DELETE FROM srvEntity WHERE itemID>=140000000 AND ownerID=1 AND typeID in
(SELECT typeID from invTypes where groupID in
(select groupID FROM invGroups where categoryID=25) or groupID=711);
 * 
 */
PyResult Command_spawnbelt( Client* who, const Seperator& args )
{
    if (!who->IsInSpace())
    {
        throw PyException(MakeCustomError("You must be in space to spawn things."));
    }

	bool makeIceBelt = false;
	bool makeRareIce = false;
	uint32 customCount = 0;
    if( args.argCount() >= 2 )
	{
        if( !args.isNumber( 1 ) )
		{
			if( args.arg( 1 ) == "ice" )
				makeIceBelt = true;
		}
		else
		{
			if( atoi(args.arg( 1 ).c_str()) > 15 )
				customCount = atoi(args.arg( 1 ).c_str());
			else
				PyException( MakeCustomError( "Argument 1 should be at least 15!" ) );
		}
	}

	if( args.argCount() >= 3 )
	{
		if( args.isNumber( 2 ) )
		{
			if( atoi(args.arg( 2 ).c_str()) > 15 )
				customCount = atoi(args.arg(2).c_str());
			else
				PyException( MakeCustomError( "Argument 2 should be at least 15!" ) );
		}
		else
			if( args.arg( 2 ) == "ice" )
				makeIceBelt = true;
			if( args.arg( 2 ) == "rareice" )
			{
				makeIceBelt = true;
				makeRareIce = true;
			}
    }

    double beltradius = 25000.0; // 25 KM
    if(makeIceBelt)
    {
        beltradius = 100000.0; // 100 KM
    }
    uint32 pcs = 0;

    if (customCount > 15)
    {
        pcs = customCount + static_cast<uint32> (MakeRandomInt(-10, 10));
    }
    else
    {
        pcs = 200 + static_cast<uint32> (MakeRandomInt(-10, 10));
    }

    SystemManager* sys = who->System();
    std::map<double, uint32> roidDist;
    if (makeIceBelt)
    {
        pcs /= 8;
        std::string securityStatus = sys->GetSystemSecurity();
        if (!makeRareIce)
        {
            roidDist.insert(std::pair<double, uint32>(0.60, 16264)); // Blue Ice
            roidDist.insert(std::pair<double, uint32>(0.45, 17975)); // Thick Blue Ice
            roidDist.insert(std::pair<double, uint32>(0.30, 28627)); // Azure Ice
            roidDist.insert(std::pair<double, uint32>(0.20, 16262)); // Clear Icicle
            roidDist.insert(std::pair<double, uint32>(0.10, 16267)); // Dark Glitter
        }
        if (makeRareIce)
        {
            roidDist.insert(std::pair<double, uint32>(0.90, 16263)); // Glacial Mass
            roidDist.insert(std::pair<double, uint32>(0.80, 16265)); // White Glaze
            roidDist.insert(std::pair<double, uint32>(0.70, 16266)); // Glare Crust
            roidDist.insert(std::pair<double, uint32>(0.60, 16268)); // Gelidus
            roidDist.insert(std::pair<double, uint32>(0.50, 16269)); // Krystallos
            roidDist.insert(std::pair<double, uint32>(0.40, 17976)); // Pristine White Glaze
            roidDist.insert(std::pair<double, uint32>(0.30, 17977)); // Smooth Glacial Mass
            roidDist.insert(std::pair<double, uint32>(0.20, 17978)); // Enriched Clear Icicle
            roidDist.insert(std::pair<double, uint32>(0.10, 28628)); // Crystalline Icicle
        }
    }
    else
    {
        if (!CommandDB::GetRoidDist(sys->GetSystemSecurity(), roidDist))
        {
            SysLog::Error("Command", "Couldn't get roid list for system security %s", sys->GetSystemSecurity());

            throw PyException(MakeCustomError("Couldn't get roid list for system security %s", sys->GetSystemSecurity()));
        }
    }

    const GPoint position(who->GetPosition());
    double phi = atan(position.x / position.z);
    if (position.z == 0)
    {
        phi = M_PI / 2;
    }
    if (position.z < 0)
    {
        phi += M_PI;
    }
    GPoint beltOffset;
    if (makeIceBelt)
    {
        beltOffset.x = (beltradius * 0.75) * sin(phi);
        beltOffset.z = (beltradius * 0.75) * cos(phi);
    }
    double alpha;
    GPoint mposition;
    double beltThickness = 3000;
    double height;
    double roidradius;
    const double beltangle = M_PI * 2.0 / 3.0;
    int triesLeft = pcs * 25;
    int pcsLeft = pcs;
    std::vector<std::pair<GPoint, double>> spawned;
    while (triesLeft-- && pcsLeft)
    {
        uint32 typeID = GetAsteroidType(MakeRandomFloat(), roidDist);
        // Generate asteroid parameters.
		if( makeIceBelt)
        {
            height = MakeRandomFloat(-0.2, 1.8);
            alpha = beltangle * ((M_PI / 8) * height);
            roidradius = MakeRandomFloat(4000.0, 10000.0);
            height *= 8;
        }
        else
        {
            alpha = beltangle * MakeRandomFloat(-M_PI / 4, M_PI / 4);
			roidradius = MakeRandomFloat( 100.0, 1000.0 );
            height = MakeRandomFloat(-1, 1);
            const ItemType *type = ItemFactory::GetType(typeID);
            if (type->groupID() == EVEDB::invGroups::Veldspar)
            {
                roidradius *= 2;
            }
        }
        // Calculate new position.
        mposition.y = beltThickness * height;
        mposition.x = beltradius * sin(phi + alpha) + beltThickness * MakeRandomFloat(-1, 1);
        mposition.z = beltradius * cos(phi + alpha) + beltThickness * MakeRandomFloat(-1, 1);
        // Check for collision.
        bool collision = false;
        for (auto pair : spawned)
        {
            GPoint point = pair.first;
            double dist = (mposition - point).length();
            double radii = (roidradius + pair.second);
            if ((dist - radii) < 0)
            {
                collision = true;
                continue;
            }
        }
        if (collision)
        {
            // There was a collision, try again.
            continue;
        }
        // Were good, add the asteroid.
        pcsLeft--;
        SpawnAsteroid(who->System(), typeID, roidradius, mposition + position - beltOffset);
        // Save the location for collision checks.
        spawned.push_back(std::pair<GPoint, double>(mposition, roidradius));
    }

    return new PyString( "Spawn successsfull." );
}