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." );
}
示例#2
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." );
}
示例#3
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." );
}