示例#1
0
ShipRef Ship::Spawn(ItemFactory &factory, ItemData &data) {
    uint32 shipID = Ship::_Spawn( factory, data );
    if( shipID == 0 )
        return ShipRef();

    ShipRef sShipRef = Ship::Load( factory, shipID );

    // Create default dynamic attributes in the AttributeMap:
    sShipRef->SetAttribute(AttrIsOnline,            1);                                             // Is Online
    sShipRef->SetAttribute(AttrShieldCharge,        sShipRef->GetAttribute(AttrShieldCapacity));    // Shield Charge
    sShipRef->SetAttribute(AttrArmorDamage,         0.0);                                           // Armor Damage
    sShipRef->SetAttribute(AttrMass,                sShipRef->type().attributes.mass());            // Mass
    sShipRef->SetAttribute(AttrRadius,              sShipRef->type().attributes.radius());          // Radius
    sShipRef->SetAttribute(AttrVolume,              sShipRef->type().attributes.volume());          // Volume
    sShipRef->SetAttribute(AttrCapacity,            sShipRef->type().attributes.capacity());        // Capacity
    sShipRef->SetAttribute(AttrInertia,             1);                                             // Inertia
    sShipRef->SetAttribute(AttrCharge,              sShipRef->GetAttribute(AttrCapacitorCapacity)); // Set Capacitor Charge to the Capacitor Capacity

    // Check for existence of some attributes that may or may not have already been loaded and set them
    // to default values:
    // Maximum Range Capacitor
    if( !(sShipRef->HasAttribute(AttrMaximumRangeCap)) )
        sShipRef->SetAttribute(AttrMaximumRangeCap, 249999.0 );
    // Maximum Armor Damage Resonance
    if( !(sShipRef->HasAttribute(AttrArmorMaxDamageResonance)) )
        sShipRef->SetAttribute(AttrArmorMaxDamageResonance, 1.0f);
    // Maximum Shield Damage Resonance
    if( !(sShipRef->HasAttribute(AttrShieldMaxDamageResonance)) )
        sShipRef->SetAttribute(AttrShieldMaxDamageResonance, 1.0f);
    // Warp Speed Multiplier
    if( !(sShipRef.get()->HasAttribute(AttrWarpSpeedMultiplier)) )
        sShipRef.get()->SetAttribute(AttrWarpSpeedMultiplier, 1.0f);
    // CPU Load of the ship (new ships have zero load with no modules fitted, of course):
    if( !(sShipRef.get()->HasAttribute(AttrCpuLoad)) )
        sShipRef.get()->SetAttribute(AttrCpuLoad, 0);
    // Power Load of the ship (new ships have zero load with no modules fitted, of course):
    if( !(sShipRef.get()->HasAttribute(AttrPowerLoad)) )
        sShipRef.get()->SetAttribute(AttrPowerLoad, 0);

    return sShipRef;
}
示例#2
0
uint32 TargetManager::TimeToLock(ShipRef ship, SystemEntity *target) const {

    EvilNumber scanRes = ship->GetAttribute(AttrScanResolution);
    EvilNumber sigRad(500);

	if( target->Item().get() != NULL )
		if( target->Item()->HasAttribute(AttrSignatureRadius) )
			sigRad = target->Item()->GetAttribute(AttrSignatureRadius);

    EvilNumber time = ( EvilNumber(40000) / ( scanRes ) ) /( EvilNumber::pow( e_log( sigRad + e_sqrt( sigRad * sigRad + 1) ), 2) );

	return static_cast<uint32>(time.get_float() * 1000); // Timer uses ms instead of seconds
}
示例#3
0
bool TargetManager::StartTargeting(SystemEntity *who, ShipRef ship) {   // needs another argument: "ShipRef ship" to access ship attributes
    //first make sure they are not already in the list
    std::map<SystemEntity *, TargetEntry *>::iterator res;
    res = m_targets.find(who);
    if(res != m_targets.end()) {
        //what to do?
        _log(TARGET__TRACE, "Told to start targeting %u, but we are already processing them. Ignoring request.", who->GetID());
        return false;
    }

    //Check that they aren't targeting themselves
    if(who == m_self)
        return false;

	// Calculate Time to Lock target:
	uint32 lockTime = TimeToLock( ship, who );

    // Check against max locked target count
	uint32 maxLockedTargets = ship->GetAttribute(AttrMaxLockedTargets).get_int();
    if( m_targets.size() >= maxLockedTargets )
        return false;

    // Check against max locked target range
	double maxTargetLockRange = ship->GetAttribute(AttrMaxTargetRange).get_float();
    GVector rangeToTarget( who->GetPosition(), m_self->GetPosition() );
    if( rangeToTarget.length() > maxTargetLockRange )
        return false;

    TargetEntry *te = new TargetEntry(who);
    te->state = TargetEntry::Locking;
    te->timer.Start(lockTime);
	m_targets[who] = te;

    _log(TARGET__TRACE, "%u started targeting %u (%u ms lock time)", m_self->GetID(), who->GetID(), lockTime);
    return true;
}
示例#4
0
bool Ship::ValidateBoardShip(ShipRef ship, CharacterRef character)
{

	SkillRef requiredSkill;
    uint32 skillTypeID = 0;
	
    if( (skillTypeID = static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill1).get_int())) != 0)
        if( !(character->HasSkillTrainedToLevel( skillTypeID, static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill1Level).get_int()) )) )
            return false;

    if( (skillTypeID = static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill2).get_int())) != 0)
        if( !(character->HasSkillTrainedToLevel( skillTypeID, static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill2Level).get_int() ))) )
            return false;

    if( (skillTypeID = static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill3).get_int())) != 0)
        if( !(character->HasSkillTrainedToLevel( skillTypeID, static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill3Level).get_int() ))) )
            return false;

    if( (skillTypeID = static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill4).get_int())) != 0)
        if( !(character->HasSkillTrainedToLevel( skillTypeID, static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill4Level).get_int() ))) )
            return false;

    if( (skillTypeID = static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill5).get_int())) != 0)
        if( !(character->HasSkillTrainedToLevel( skillTypeID, static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill5Level).get_int() )) ))
            return false;

    if( (skillTypeID = static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill6).get_int())) != 0)
        if( !(character->HasSkillTrainedToLevel( skillTypeID, static_cast<uint32>(ship->GetAttribute(AttrRequiredSkill6Level).get_int() )) ))
            return false;

    return true;
/*
    //Primary Skill
	if(ship->GetAttribute(AttrRequiredSkill1).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill1).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill1Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}

	//Secondary Skill
	if(ship->GetAttribute(AttrRequiredSkill2).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill2).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill2Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}
	
	//Tertiary Skill
	if(ship->GetAttribute(AttrRequiredSkill3).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill3).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill3Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}
	
	//Quarternary Skill
	if(ship->GetAttribute(AttrRequiredSkill4).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill4).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill4Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}
	
	//Quinary Skill
	if(ship->GetAttribute(AttrRequiredSkill5).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill5).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill5Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}
	
	//Senary Skill
	if(ship->GetAttribute(AttrRequiredSkill6).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill6).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill6Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}

	return true;
*/
}
示例#5
0
ShipRef Ship::Spawn(ItemFactory &factory, ItemData &data) {
    uint32 shipID = Ship::_Spawn( factory, data );
    if( shipID == 0 )
        return ShipRef();

    ShipRef sShipRef = Ship::Load( factory, shipID );

    // Create default dynamic attributes in the AttributeMap:
    sShipRef->SetAttribute(AttrIsOnline,            1, true);												// Is Online
    sShipRef->SetAttribute(AttrShieldCharge,        sShipRef->GetAttribute(AttrShieldCapacity), true);		// Shield Charge
    sShipRef->SetAttribute(AttrArmorDamage,         0.0, true);												// Armor Damage
    sShipRef->SetAttribute(AttrMass,                sShipRef->type().attributes.mass(), true);				// Mass
    sShipRef->SetAttribute(AttrRadius,              sShipRef->type().attributes.radius(), true);			// Radius
    sShipRef->SetAttribute(AttrVolume,              sShipRef->type().attributes.volume(), true);			// Volume
    sShipRef->SetAttribute(AttrCapacity,            sShipRef->type().attributes.capacity(), true);			// Capacity
    sShipRef->SetAttribute(AttrInertia,             1, true);												// Inertia
    sShipRef->SetAttribute(AttrCharge,              sShipRef->GetAttribute(AttrCapacitorCapacity), true);	// Set Capacitor Charge to the Capacitor Capacity

    // Check for existence of some attributes that may or may not have already been loaded and set them
    // to default values:
	// Hull Damage
	if( !(sShipRef->HasAttribute(AttrDamage)) )
        sShipRef->SetAttribute(AttrDamage, 0, true );
    // Theoretical Maximum Targeting Range
    if( !(sShipRef->HasAttribute(AttrMaximumRangeCap)) )
        sShipRef->SetAttribute(AttrMaximumRangeCap, BUBBLE_DIAMETER_METERS, true );
    // Maximum Armor Damage Resonance
    if( !(sShipRef->HasAttribute(AttrArmorMaxDamageResonance)) )
        sShipRef->SetAttribute(AttrArmorMaxDamageResonance, 1.0f, true);
    // Maximum Shield Damage Resonance
    if( !(sShipRef->HasAttribute(AttrShieldMaxDamageResonance)) )
        sShipRef->SetAttribute(AttrShieldMaxDamageResonance, 1.0f, true);
    // Warp Speed Multiplier
    if( !(sShipRef.get()->HasAttribute(AttrWarpSpeedMultiplier)) )
        sShipRef.get()->SetAttribute(AttrWarpSpeedMultiplier, 1.0f, true);
    // CPU Load of the ship (new ships have zero load with no modules fitted, of course):
    if( !(sShipRef.get()->HasAttribute(AttrCpuLoad)) )
        sShipRef.get()->SetAttribute(AttrCpuLoad, 0, true);
    // Power Load of the ship (new ships have zero load with no modules fitted, of course):
    if( !(sShipRef.get()->HasAttribute(AttrPowerLoad)) )
        sShipRef.get()->SetAttribute(AttrPowerLoad, 0, true);
	// Warp Scramble Status of the ship (most ships have zero warp scramble status, but some already have it defined):
	if( !(sShipRef.get()->HasAttribute(AttrWarpScrambleStatus)) )
		sShipRef.get()->SetAttribute(AttrWarpScrambleStatus, 0.0, true);

	// Shield Resonance
	// AttrShieldEmDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrShieldEmDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrShieldEmDamageResonance, 1.0, true);
	// AttrShieldExplosiveDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrShieldExplosiveDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrShieldExplosiveDamageResonance, 1.0, true);
	// AttrShieldKineticDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrShieldKineticDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrShieldKineticDamageResonance, 1.0, true);
	// AttrShieldThermalDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrShieldThermalDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrShieldThermalDamageResonance, 1.0, true);

	// Armor Resonance
	// AttrArmorEmDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrArmorEmDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrArmorEmDamageResonance, 1.0, true);
	// AttrArmorExplosiveDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrArmorExplosiveDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrArmorExplosiveDamageResonance, 1.0, true);
	// AttrArmorKineticDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrArmorKineticDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrArmorKineticDamageResonance, 1.0, true);
	// AttrArmorThermalDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrArmorThermalDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrArmorThermalDamageResonance, 1.0, true);

	// Hull Resonance
	// AttrHullEmDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrHullEmDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrHullEmDamageResonance, 1.0, true);
	// AttrHullExplosiveDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrHullExplosiveDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrHullExplosiveDamageResonance, 1.0, true);
	// AttrHullKineticDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrHullKineticDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrHullKineticDamageResonance, 1.0, true);
	// AttrHullThermalDamageResonance
	if( !(sShipRef.get()->HasAttribute(AttrHullThermalDamageResonance)) )
		sShipRef.get()->SetAttribute(AttrHullThermalDamageResonance, 1.0, true);

	// AttrTurretSlotsLeft
	if( !(sShipRef.get()->HasAttribute(AttrTurretSlotsLeft)) )
		sShipRef.get()->SetAttribute(AttrTurretSlotsLeft, 0, true);
	// AttrLauncherSlotsLeft
	if( !(sShipRef.get()->HasAttribute(AttrLauncherSlotsLeft)) )
		sShipRef.get()->SetAttribute(AttrLauncherSlotsLeft, 0, true);

    return sShipRef;
}
示例#6
0
bool Ship::ValidateBoardShip(ShipRef ship, CharacterRef character)
{

	SkillRef requiredSkill;
	
	//Primary Skill
	if(ship->GetAttribute(AttrRequiredSkill1).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill1).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill1Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}

	//Secondary Skill
	if(ship->GetAttribute(AttrRequiredSkill2).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill2).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill2Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}
	
	//Tertiary Skill
	if(ship->GetAttribute(AttrRequiredSkill3).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill3).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill3Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}
	
	//Quarternary Skill
	if(ship->GetAttribute(AttrRequiredSkill4).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill4).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill4Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}
	
	//Quinary Skill
	if(ship->GetAttribute(AttrRequiredSkill5).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill5).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill5Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}
	
	//Senary Skill
	if(ship->GetAttribute(AttrRequiredSkill6).get_int() != 0)
	{
		requiredSkill = character->GetSkill( ship->GetAttribute(AttrRequiredSkill6).get_int() );
		if( !requiredSkill )
			return false;

		if( ship->GetAttribute(AttrRequiredSkill6Level) > requiredSkill->GetAttribute(AttrSkillLevel) )
			return false;
	}

	return true;
}