CrEaToXx wrote:Would this work?
Code: Select all
onComputeAccuracy = function(champion, weapon, attack, attackType, level)
if level > 0 and weapon == "short_bow" then return 1 end
if level > 0 and weapon == "longbow" then return 2 end
end,
Hey CrEaToXx,
It certainly will not - it should crash at character creation....
The onComputeAccuracy hook would be why... your first line:
Code: Select all
if level > 0 and weapon == "short_bow" then
will be checking champion hands and returning nil for weapon before you have begun the game >> crash
Notice this asset pack trait is ok though
(as you cant make attacks in character creation):
Code: Select all
defineTrait{
name = "weapon_specialization",
uiName = "Martial Training",
icon = 0,
charGen = true,
description = "You are trained to use a wide variety of melee weapons. Melee attacks gain Accuracy +7.",
onComputeAccuracy = function(champion, weapon, attack, attackType, level)
if level > 0 and attackType == "melee" then return 7 end
end,
}
So, change your hook to something like this (for now) :
onComputeAccuracy = function(champion, weapon, attack, attackType, level)
if level > 0 then
if attackType == "missile" then
print(champion:getName(), weapon.go.name, attack:getName(), attackType, level)
if weapon and weapon.go.name == "short_bow" then
print(weapon.go.name)
return 50
elseif weapon and weapon.go.name == "crossbow" then
print(weapon.go.name)
return 20
end
end
end
end, [/code]
EDIT: This^^ works
![Smile :)](./images/smilies/icon_e_smile.gif)
- and Ive included console prints so you can see the values of args/vars
I dont have time right now to reply in full, but here is a link to a thread that can probably help further.
viewtopic.php?f=22&t=9966
As minmay has stated -you cannot cleanly give a bonus to damage or pierce....
But this thread does have a (still not clean) work around by checking champion hands/weapons every frame
Im actually still using this work around as - AFAIK - its the best we can do about damage and pierce
(minmay - if Im outdated or incorrect here pls leme know!)
EDIT: In fact, pls do confirm whether this approach is still ok (although not clean) to use
- its been a while since that thread was posted, I have built quite a lengthy script around it - just want to make sure
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)