That looks like a pretty fun plugin for custom servers wanting to simulate ranged attacks. I have actually been wanting to add one in that simulates it more like you might see on Live using the following commands and more:
Code:
CheckLoSToLoc(x, y, z, [mob_size])
ProjectileAnim(mob, item_id, [IsArrow?, speed, angle, tilt, arc])
DoSpecialAttackDamage()
Though, I may have to go even further and try to export some of the damage calculating functions from mob.cpp to perl so I can use the actual damage calculations for the NPC as if it was meleeing the client(s). I will have to look into it, but maybe some of these functions could be exported to allow for some cool flexibility:
Code:
bool Mob::CheckHitChance(Mob* other, SkillType skillinuse, int Hand)
bool Mob::AvoidDamage(Mob* other, sint32 &damage)
void Mob::MeleeMitigation(Mob *attacker, sint32 &damage, sint32 minhit)
bool NPC::Attack(Mob* other, int Hand, bool bRiposte)
sint32 Mob::ReduceDamage(sint32 damage)
sint32 Mob::ReduceMagicalDamage(sint32 damage)
I also think it would be nice to have an option for setting timers to allow it to set the timer in milliseconds instead of seconds. A simple optional bool at the end of the command should work just fine. You could then adjust timers to happen at any interval you could possibly want
Or, maybe I should just do it the right way and try to just write it all in the source code so Ranger class NPCs with Bows in their loot table or with a Bow weapon model equiped will use ranged attacks automatically (maybe with a rule option to enable). I think KLS has some ranged NPC code started already, so it might just mean finishing that code off. I think the hard part will be making it so they don't constantly run toward the character, as I think they should just get within a certain range and check LoS and shoot from that position until they are out of range or lose their LoS to the target.