How do you code a breakable weapon?
Posted: Sat Feb 07, 2015 12:15 pm
I`m trying to define a weapon on LOG1 that will break after a few uses (a wooden spear or similar). Ive tried cloning the legionary spear and messed around with the onDealDamage code, adding it to the item code itself and tried using the 'return true' function, but cant get anything to work. Any ideas greatly appreciated:
The above is just a test code. The spear works as normal, but wont break.
Thanks
George
Code: Select all
defineObject{
name = "rusty_spear",
class = "Item",
uiName = "Old, rusty spear",
model = "assets/models/items/skeleton_spear.fbx",
gfxIndex = 208,
attackPower = 10,
accuracy = 0,
coolDownTime = 2,
attackMethod = "meleeAttack",
attackSwipe = "thrust",
attackSound = "swipe",
impactSound = "impact_blade",
weight = 3.0,
reachWeapon = true,
onDealDamage = function(self, monster, damage)
if math.random() <= 0.35 then
hudPrint("The spear has broken!")
return true
end
end,
}Thanks
George