This was more complicated than i first thought, i'll give you my thought process for this coding flow.
As far as i'm aware, we need to build a table of weapons which allow us to map the skill type onto them. So i did the following table and assigned it to a class:
Code
ranged_weapons = {
["Gastraphetes"]='Marksmanship',
["Fomalhaut"]='Marksmanship',
["Armageddon"]='Marksmanship',
["Annihilator"]='Marksmanship',
["Fail-Not"]='Archery',
["Gandiva"]='Archery',
["Yoichinoyumi"]='Archery',
["Sparrowhawk +2"]='Archery',
}
classes.rangedSkill = ranged_weapons
Since we need to track the distance plus setting, it would need to be declared globally, i typically do this under job_setup() using:
Now we can use this code to update a variable of our choosing as follows:
Code
skill = classes.rangedSkill[player.equipment.range]
And now were ready to do a function for assigning that value into Distanceplus:
Code
function set_trueShot_range() -- Requires distancePlus
skill = classes.rangedSkill[player.equipment.range]
if not dpsetting then
if skill == 'Marksmanship' and player.equipment.range == "Gastraphetes" then
dpsetting = 'xbow'
else
dpsetting = 'gun'
end
if skill == 'Archery' then
dpsetting = 'Bow'
end
if dpsetting then
send_command('dp '..dpsetting..'')
end
end
end
So now that we have those pieces, we need it to check regularly, i found the best place to do this is in the precast() functions as follows:
Code
if spell.type == 'WeaponSkill' or spell.action_type == 'Ranged Attack' then
set_trueShot_range()
end
As a sidebar, if you have an ammo checking or handling function, you may need to weave this into it, or use this as an augment.
I hope you found this helpful in some way, i'd be happy to discuss it in more detail if youre interested in that.