/** * Is called when this object has been inserted with an object * @param object object that has been inserted */ int SaberInventoryContainerComponent::notifyObjectInserted(SceneObject* sceneObject, SceneObject* object) { ManagedReference<WeaponObject*> weao = cast<WeaponObject*>( sceneObject->getParent().get().get()); Locker locker(weao); if (weao->isJediWeapon()) { ManagedReference<LightsaberCrystalComponent*> crystal = cast<LightsaberCrystalComponent*>( object); if (crystal->getColor() == 31){ weao->setAttackSpeed(weao->getAttackSpeed() + crystal->getAttackSpeed()); weao->setMinDamage(weao->getMinDamage() + crystal->getMinimumDamage()); weao->setMaxDamage(weao->getMaxDamage() + crystal->getMaximumDamage()); weao->setHealthAttackCost(weao->getHealthAttackCost() + crystal->getSacHealth()); weao->setActionAttackCost(weao->getActionAttackCost() + crystal->getSacAction()); weao->setMindAttackCost(weao->getMindAttackCost() + crystal->getSacMind()); weao->setWoundsRatio(weao->getWoundsRatio() + crystal->getWoundChance()); weao->setForceCost(weao->getForceCost() + crystal->getForceCost()); } if (crystal->getColor() != 31) { int color = crystal->getColor(); weao->setBladeColor(color); weao->setCustomizationVariable("/private/index_color_blade", color, true); } } return sceneObject->notifyObjectInserted(object); }
int LightsaberCrystalComponentImplementation::inflictDamage(TangibleObject* attacker, int damageType, float damage, bool destroy, bool notifyClient) { if (isDestroyed()) { return 0; } TangibleObjectImplementation::inflictDamage(attacker, damageType, damage, destroy, notifyClient); if (isDestroyed()) { ManagedReference<WeaponObject*> weapon = cast<WeaponObject*>(_this.getReferenceUnsafeStaticCast()->getParent().get()->getParent().get().get()); if (weapon != NULL) { if (getColor() == 31) { weapon->setAttackSpeed(weapon->getAttackSpeed() - getAttackSpeed()); weapon->setMinDamage(weapon->getMinDamage() - getMinimumDamage()); weapon->setMaxDamage(weapon->getMaxDamage() - getMaximumDamage()); weapon->setHealthAttackCost(weapon->getHealthAttackCost() - getSacHealth()); weapon->setActionAttackCost(weapon->getActionAttackCost() - getSacAction()); weapon->setMindAttackCost(weapon->getMindAttackCost() - getSacMind()); weapon->setWoundsRatio(weapon->getWoundsRatio() - getWoundChance()); weapon->setForceCost(weapon->getForceCost() - getForceCost()); } if (getColor() != 31) { weapon->setBladeColor(31); weapon->setCustomizationVariable("/private/index_color_blade", 31, true); if (weapon->isEquipped()) { ManagedReference<CreatureObject*> parent = cast<CreatureObject*>(weapon->getParent().get().get()); ManagedReference<SceneObject*> inventory = parent->getSlottedObject("inventory"); inventory->transferObject(weapon, -1, true, true); parent->sendSystemMessage("@jedi_spam:lightsaber_no_color"); //That lightsaber can not be used until it has a color-modifying Force crystal installed. } } } } return 0; }