void WeaponObjectImplementation::loadTemplateData(SharedObjectTemplate* templateData) { TangibleObjectImplementation::loadTemplateData(templateData); weaponTemplate = dynamic_cast<SharedWeaponObjectTemplate*>(templateData); certified = false; attackType = weaponTemplate->getAttackType(); weaponEffect = weaponTemplate->getWeaponEffect(); weaponEffectIndex = weaponTemplate->getWeaponEffectIndex(); damageType = weaponTemplate->getDamageType(); armorPiercing = weaponTemplate->getArmorPiercing(); healthAttackCost = weaponTemplate->getHealthAttackCost(); actionAttackCost = weaponTemplate->getActionAttackCost(); mindAttackCost = weaponTemplate->getMindAttackCost(); forceCost = weaponTemplate->getForceCost(); pointBlankAccuracy = weaponTemplate->getPointBlankAccuracy(); pointBlankRange = weaponTemplate->getPointBlankRange(); idealRange = weaponTemplate->getIdealRange(); idealAccuracy = weaponTemplate->getIdealAccuracy(); int templateMaxRange = weaponTemplate->getMaxRange(); if (templateMaxRange > 5 ) maxRange = templateMaxRange; maxRangeAccuracy = weaponTemplate->getMaxRangeAccuracy(); minDamage = weaponTemplate->getMinDamage(); maxDamage = weaponTemplate->getMaxDamage(); woundsRatio = weaponTemplate->getWoundsRatio(); damageRadius = weaponTemplate->getArea(); float templateAttackSpeed = weaponTemplate->getAttackSpeed(); if (templateAttackSpeed > 1) attackSpeed = templateAttackSpeed; if (!isJediWeapon()) { setSliceable(true); } else if (isJediWeapon()) { setSliceable(false); } }
void WeaponObjectImplementation::decay(CreatureObject* user) { if (_this.getReferenceUnsafeStaticCast() == user->getSlottedObject("default_weapon") || user->isAiAgent() || hasAntiDecayKit()) { return; } int roll = System::random(100); int chance = 5; if (hasPowerup()) chance += 10; if (roll < chance) { if (isJediWeapon()) { ManagedReference<SceneObject*> saberInv = getSlottedObject("saber_inv"); // TODO: is this supposed to be every crystal, or random crystal(s)? for (int i = 0; i < saberInv->getContainerObjectsSize(); i++) { ManagedReference<LightsaberCrystalComponent*> crystal = saberInv->getContainerObject(i).castTo<LightsaberCrystalComponent*>(); if (crystal != NULL) { crystal->inflictDamage(crystal, 0, 1, true, true); } } } else { inflictDamage(_this.getReferenceUnsafeStaticCast(), 0, 1, true, true); if (((float)conditionDamage - 1 / (float)maxCondition < 0.75) && ((float)conditionDamage / (float)maxCondition > 0.75)) user->sendSystemMessage("@combat_effects:weapon_quarter"); if (((float)conditionDamage - 1 / (float)maxCondition < 0.50) && ((float)conditionDamage / (float)maxCondition > 0.50)) user->sendSystemMessage("@combat_effects:weapon_half"); } } }
void WeaponObjectImplementation::sendContainerTo(CreatureObject* player) { if (isJediWeapon()) { ManagedReference<SceneObject*> saberInv = getSlottedObject("saber_inv"); if (saberInv != NULL) { saberInv->sendDestroyTo(player); //saberInv->closeContainerTo(player, true); saberInv->sendWithoutContainerObjectsTo(player); saberInv->openContainerTo(player); } } }
void WeaponObjectImplementation::updateCraftingValues(CraftingValues* values, bool firstUpdate) { /* * Incoming Values: Ranges: * mindamage Differs between weapons * maxdamage * attackspeed * woundchance * roundsused * hitpoints * zerorangemod * maxrange * maxrangemod * midrange * midrangemod * charges * attackhealthcost * attackactioncost * attackmindcost */ float value = 0.f; setMinDamage(MAX(values->getCurrentValue("mindamage"), 0)); setMaxDamage(MAX(values->getCurrentValue("maxdamage"), 0)); setAttackSpeed(values->getCurrentValue("attackspeed")); setHealthAttackCost((int)values->getCurrentValue("attackhealthcost")); setActionAttackCost((int)values->getCurrentValue("attackactioncost")); setMindAttackCost((int)values->getCurrentValue("attackmindcost")); if (isJediWeapon()) { setForceCost((int)values->getCurrentValue("forcecost")); setBladeColor(31); } value = values->getCurrentValue("woundchance"); if(value != CraftingValues::VALUENOTFOUND) setWoundsRatio(value); //value = craftingValues->getCurrentValue("roundsused"); //if(value != DraftSchematicValuesImplementation::VALUENOTFOUND) //_this.getReferenceUnsafeStaticCast()->set_______(value); value = values->getCurrentValue("zerorangemod"); if(value != CraftingValues::VALUENOTFOUND) setPointBlankAccuracy((int)value); value = values->getCurrentValue("maxrange"); if(value != CraftingValues::VALUENOTFOUND) setMaxRange((int)value); value = values->getCurrentValue("maxrangemod"); if(value != CraftingValues::VALUENOTFOUND) setMaxRangeAccuracy((int)value); value = values->getCurrentValue("midrange"); if(value != CraftingValues::VALUENOTFOUND) setIdealRange((int)value); value = values->getCurrentValue("midrangemod"); if(value != CraftingValues::VALUENOTFOUND) setIdealAccuracy((int)value); //value = craftingValues->getCurrentValue("charges"); //if(value != CraftingValues::VALUENOTFOUND) // setUsesRemaining((int)value); value = values->getCurrentValue("hitpoints"); if(value != CraftingValues::VALUENOTFOUND) setMaxCondition((int)value); setConditionDamage(0); }