Thread: NPC Dual Wield
View Single Post
  #2  
Old 06-28-2009, 01:12 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Here's the code:

zone/MobAI.cpp
Code:
                                //now off hand
                                if (attack_dw_timer.Check() && CanThisClassDualWield()) 
                                {
                                        int myclass = GetClass();
                                        //can only dual weild without a weapon if your a monk
                                        if((GetEquipment(MATERIAL_SECONDARY) != 0 && GetLevel() > 39) || myclass == MONK || myclass == MONKGM) {
                                                float DualWieldProbability = (GetSkill(DUAL_WIELD) + GetLevel()) / 400.0f;
                                                DualWieldProbability -= MakeRandomFloat(0, 1);
                                                if(DualWieldProbability < 0){
                                                        Attack(target, 14);
                                                        if (CanThisClassDoubleAttack()) 
                                                        {
                                                                sint32 RandRoll = rand()%100;
                                                                if (RandRoll < (GetLevel() + 20))  
                                                                {
                                                                        if (Attack(target, 14));
                                                                }
                                                        } // if (CanThisClassDoubleAttack())
                                                }
                                        }
                                }
First of all, it looks like it's hard coded to be at least level 40 before we can duel wield. I honestly can't remember how this is supposed to be setup on Live, but if this is correct, it can very easily be changed to a rule.

Secondly, I honestly am not understanding why we're subtracting a random float with a value between 0 & 1 from our probability and checking to see if it's less than 0. Using your examples, that would put the probability somewhere between -0.55 & 0.45 for level 30 and between -0.325 & 0.675, which actually has an inverse affect on our probability to duel wield. Effectively, at level 70, the probability would be between 0.05 & 1.05, which will never be < 0.

Unless I'm misreading something, we should just be able to flip the check to > 0.

On a side note, if this is effectively broken, this could have a potentially large impact on DPS NPCs are dealing out at higher levels.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki

Last edited by AndMetal; 06-28-2009 at 09:15 AM..
Reply With Quote