int LogisticsVariant::removeComponent( long xCoord, long yCoord ) { LogisticsChassis::ComponentInfo* info = const_cast<LogisticsChassis::ComponentInfo*>(getComponentAtLocation( xCoord, yCoord )); if ( !info ) return -1; if ( info->component && info->component->getType() == COMPONENT_FORM_HEATSINK ) { if ( getMaxHeat() - info->component->getDamage() < getHeat() ) return INSUFFICIENT_HEAT; } if ( !info ) return INVALID_LOCATION; for ( int i = 0; i < componentCount; i++ ) { if ( &components[i] == info ) { memmove( &components[i], &components[i + 1], (componentCount - ( i + 1 )) * sizeof( LogisticsChassis::ComponentInfo ) ); break; } } componentCount --; return 0; }
void VehicleObjectImplementation::fillAttributeList(AttributeListMessage* alm, CreatureObject* object){ alm->insertAttribute("armorrating", "@obj_attr_n:armor_pierce_none"); //None StringBuffer kin; kin << Math::getPrecision(getKinetic(),1) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_kinetic", kin.toString()); StringBuffer ene; ene << Math::getPrecision(getEnergy(),1) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_energy", ene.toString()); StringBuffer bla; bla << Math::getPrecision(getBlast(),1) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_blast", bla.toString()); StringBuffer stu; stu << Math::getPrecision(getStun(),1) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_stun", stu.toString()); StringBuffer lig; lig << Math::getPrecision(getLightSaber(),1) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_restraint", lig.toString()); StringBuffer hea; hea << Math::getPrecision(getHeat(),1) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_heat", hea.toString()); StringBuffer col; col << Math::getPrecision(getCold(),1) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_cold", col.toString()); StringBuffer aci; aci << Math::getPrecision(getAcid(),1) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_acid", aci.toString()); StringBuffer ele; ele << Math::getPrecision(getElectricity(),1) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_electrical", ele.toString()); ManagedReference<CreatureObject* > linkedCreature = this->linkedCreature.get(); if( linkedCreature == NULL ) return; alm->insertAttribute("@obj_attr_n:owner", linkedCreature->getFirstName()); }
// if you pass in -1's for x and y, we'll figure out where it can go, and return where it went int LogisticsVariant::canAddComponent( LogisticsComponent* pComponent, long& x, long& y ) const { /* weight no longer matters int weight = getWeight(); if ( weight + pComponent->getWeight() > chassis->maxWeight ) return COMPONENT_TOO_HEAVY;*/ if ( getHeat() + pComponent->getHeat() > getMaxHeat() ) return COMPONENT_TOO_HOT; if ( pComponent->getType() == COMPONENT_FORM_JUMPJET ) { if ( !chassis->canHaveJumpJets ) return JUMPJETS_NOT_ALLOWED; else if ( hasJumpJets() ) return ONLY_ONE_JUMPJET_ALLOWED; else if ( ( x!= -1 && x != -2) || ( y != -1 && y != -2 ) ) return COMPONENT_SLOT_FULL; return 0; } else if ( x == -2 && y == -2 ) // trying to put something illegal in jump jet slot return COMPONENT_SLOT_FULL; if ( x!= -1 && y != -1 ) { for ( int i = 0; i < pComponent->getComponentWidth(); i++ ) { for ( int j = 0; j < pComponent->getComponentHeight(); j++ ) { if ( getComponentAtLocation( x + i, y + j) || x + i >= chassis->componentAreaWidth || j + y >= chassis->componentAreaHeight ) return COMPONENT_SLOT_FULL; } } } else { for ( int j = 0; j < chassis->componentAreaHeight && x == -1; j++ ) { for ( int i = 0; i < chassis->componentAreaWidth && x == -1; i++ ) { if ( !getComponentAtLocation( i, j ) ) { bool bAdd = true; for ( int l = 0; l < pComponent->getComponentHeight(); ++l ) { for ( int k =0; k < pComponent->getComponentWidth(); ++k ) { if ( getComponentAtLocation( i +k, j + l ) || ( i + k >= chassis->componentAreaWidth ) || ( j +l >= chassis->componentAreaHeight ) ) { bAdd = false; break; break; } } } if ( bAdd ) { x = i; y = j; } } } } if ( x == -1 || y == -1 ) { return ADD_COMPONENT_FAILED; } } if ( pComponent->getType() == COMPONENT_FORM_BULK ) { if ( getArmor() + 32 > getMaxArmor() ) return NO_MORE_ARMOR; } if ( pComponent->getType() == COMPONENT_FORM_SENSOR ) { if ( !chassis->canHaveAdvSensor ) return SENSORS_NOT_ALLOWED; else if ( hasSensor() ) return ONLY_ONE_SENSOR_ALLOWED; } if ( pComponent->getType() == COMPONENT_FORM_ECM ) { if ( !chassis->canHaveECM ) return ECM_NOT_ALLOWED; else if ( hasECM() ) return ONLY_ONE_ECM_ALLOWED; } return 0; }
void TurretDataComponent::fillAttributeList(AttributeListMessage* alm) { if (getParent() == NULL) return; ManagedReference<InstallationObject*> turret = cast<InstallationObject*>(getParent()); alm->insertAttribute("condition",String::valueOf(turret->getMaxCondition() - turret->getConditionDamage()) + "/" + String::valueOf(turret->getMaxCondition())); if (getArmorRating() == 0) alm->insertAttribute("armorrating", "None"); else if (getArmorRating() == 1) alm->insertAttribute("armorrating", "Light"); else if (getArmorRating() == 2) alm->insertAttribute("armorrating", "Medium"); else if (getArmorRating() == 3) alm->insertAttribute("armorrating", "Heavy"); if (getKinetic() > 90) { StringBuffer txt; txt << round(getKinetic()) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_kinetic", txt.toString()); } if (getEnergy() > 90) { StringBuffer txt; txt << round(getEnergy()) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_energy", txt.toString()); } if (getElectricity() > 90) { StringBuffer txt; txt << round(getElectricity()) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_elemental_electrical", txt.toString()); } if (getStun() > 90) { StringBuffer txt; txt << round(getStun()) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_stun", txt.toString()); } if (getBlast() > 90) { StringBuffer txt; txt << round(getBlast()) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_blast", txt.toString()); } if (getHeat() > 90) { StringBuffer txt; txt << round(getHeat()) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_elemental_heat", txt.toString()); } if (getCold() > 90) { StringBuffer txt; txt << round(getCold()) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_elemental_cold", txt.toString()); } if (getAcid() > 90) { StringBuffer txt; txt << round(getAcid()) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_elemental_acid", txt.toString()); } if (getLightSaber() > 90) { StringBuffer txt; txt << round(getLightSaber()) << "%"; alm->insertAttribute("cat_armor_special_protection.armor_eff_restraint", txt.toString()); } if (getKinetic() > 0 && getKinetic() <= 90) { StringBuffer txt; txt << round(getKinetic()) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_kinetic", txt.toString()); } if (getEnergy() > 0 && getEnergy() <= 90) { StringBuffer txt; txt << round(getEnergy()) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_energy", txt.toString()); } if (getElectricity() > 0 && getElectricity() <= 90) { StringBuffer txt; txt << round(getElectricity()) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_electrical", txt.toString()); } if (getStun() > 0 && getStun() <= 90) { StringBuffer txt; txt << round(getStun()) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_stun", txt.toString()); } if (getBlast() > 0 && getBlast() <= 90) { StringBuffer txt; txt << round(getBlast()) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_blast", txt.toString()); } if (getHeat() > 0 && getHeat() <= 90) { StringBuffer txt; txt << round(getHeat()) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_heat", txt.toString()); } if (getCold() > 0 && getCold() <= 90) { StringBuffer txt; txt << round(getCold()) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_cold", txt.toString()); } if (getAcid() > 0 && getAcid() <= 90) { StringBuffer txt; txt << round(getAcid()) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_elemental_acid", txt.toString()); } if (getLightSaber() > 0 && getLightSaber() <= 90) { StringBuffer txt; txt << round(getLightSaber()) << "%"; alm->insertAttribute("cat_armor_effectiveness.armor_eff_restraint", txt.toString()); } if (getKinetic() < 0) alm->insertAttribute("cat_armor_vulnerability.armor_eff_kinetic", "-"); if (getEnergy() < 0) alm->insertAttribute("cat_armor_vulnerability.armor_eff_energy", "-"); if (getElectricity() < 0) alm->insertAttribute("cat_armor_vulnerability.armor_eff_elemental_electrical", "-"); if (getStun() < 0) alm->insertAttribute("cat_armor_vulnerability.armor_eff_stun", "-"); if (getBlast() < 0) alm->insertAttribute("cat_armor_vulnerability.armor_eff_blast", "-"); if (getHeat() < 0) alm->insertAttribute("cat_armor_vulnerability.armor_eff_elemental_heat", "-"); if (getCold() < 0) alm->insertAttribute("cat_armor_vulnerability.armor_eff_elemental_cold", "-"); if (getAcid() < 0) alm->insertAttribute("cat_armor_vulnerability.armor_eff_elemental_acid", "-"); if (getLightSaber() < 0) alm->insertAttribute("cat_armor_vulnerability.armor_eff_restraint", "-"); }