RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Player character won't fight back

siran

Sorceror
First of all, all scripts compile and there is no crash. If I attack a creature (doesn't matter what kind, I'm currently testing with a Mongbat), the creature fights and does damage to me but my character just stands there, in war mode, doing nothing. Changing weapons makes no difference, but if I have no weapon (wrestling with fists) then I do fight back.

One little curve, if I save the game while in war mode against a combatant, when I reboot the server my character DOES fight back with his weapon. But the next combatant he again does not.

Here are the relevant sections of my BaseWeapon script, and when I add attacker.SendMessage lines and defender.SendMessage lines in the OnHit, CheckHit, and OnSwing methods, only the defender messages appear when the problem is happening. After a save & reboot, both attacker & defender messages appear until the combatant is dead then for the next combatant only defneder messages appear again.

Code:
    public virtual bool CheckHit( Mobile attacker, Mobile defender )
        {
            BaseWeapon atkWeapon = attacker.Weapon as BaseWeapon;
            BaseWeapon defWeapon = defender.Weapon as BaseWeapon;
 
            Skill atkSkill = attacker.Skills[atkWeapon.Skill];
            Skill defSkill = defender.Skills[defWeapon.Skill];
 
            double atkValue = atkWeapon.GetAttackSkillValue( attacker, defender );
            double defValue = defWeapon.GetDefendSkillValue( attacker, defender );
           
            // byron 7/10/14 - *********************************************************************
            double attackerMagerySkill = attacker.Skills[SkillName.Magery].Base;
            double attackerAxeFightingSkill = attacker.Skills[SkillName.AxeFighting].Base;
            double attackerFencingSkill = attacker.Skills[SkillName.Fencing].Base;
            double attackerJoustingSkill = attacker.Skills[SkillName.Jousting].Base;
            double attackerKnifeFightingSkill = attacker.Skills[SkillName.KnifeFighting].Base;
            double attackerMacingSkill = attacker.Skills[SkillName.Macing].Base;
            double attackerMacingClubSkill = attacker.Skills[SkillName.Club].Base;
            double attackerMacingFlailSkill = attacker.Skills[SkillName.Flail].Base;
            double attackerMacingHammerSkill = attacker.Skills[SkillName.Hammer].Base;
            double attackerPoleArmSkill = attacker.Skills[SkillName.PoleArm].Base;
            double attackerSpearFightingSkill = attacker.Skills[SkillName.SpearFighting].Base;
            double attackerSwordsmanshipSkill = attacker.Skills[SkillName.Swords].Base;
            double attackerTwoHandedSwordsSkill = attacker.Skills[SkillName.TwoHandedSwords].Base;
            double attackerQuarterStaffSkill = attacker.Skills[SkillName.QuarterStaff].Base;
            atkValue = attacker.Skills[SkillName.Wrestling].Base;
            atkSkill = attacker.Skills[SkillName.Wrestling];
            if (atkWeapon is BaseAxe)
            {
                atkValue = attackerAxeFightingSkill;
                atkSkill = attacker.Skills[SkillName.AxeFighting];
            }
            else if (atkWeapon is BaseRapier)
            {
                atkValue = attackerFencingSkill;
                atkSkill = attacker.Skills[SkillName.Fencing];
            }
            else if (atkWeapon is BaseKnife)
            {
                atkValue = attackerKnifeFightingSkill;
                atkSkill = attacker.Skills[SkillName.KnifeFighting];
            }
            else if (atkWeapon is BaseSword)
            {
                atkValue = attackerSwordsmanshipSkill;
                atkSkill = attacker.Skills[SkillName.Swords];
                if (atkWeapon is BaseTwoHandedSword)
                {
                    atkValue = attackerTwoHandedSwordsSkill;
                    atkSkill = attacker.Skills[SkillName.TwoHandedSwords];
                }
            }
            else if (atkWeapon is BaseMace)
            {
                atkValue = attackerMacingSkill;
                atkSkill = attacker.Skills[SkillName.Macing];
                if (atkWeapon is BaseClub)
                {
                    atkValue = attackerMacingClubSkill;
                    atkSkill = attacker.Skills[SkillName.Club];
                }
                else if (atkWeapon is BaseFlail)
                {
                    atkValue = attackerMacingFlailSkill;
                    atkSkill = attacker.Skills[SkillName.Flail];
                }
                else if (atkWeapon is BaseHammer)
                {
                    atkValue = attackerMacingHammerSkill;
                    atkSkill = attacker.Skills[SkillName.Hammer];
                }
            }
            else if (atkWeapon is BasePoleArm)
            {
                atkValue = attackerPoleArmSkill;
                atkSkill = attacker.Skills[SkillName.PoleArm];
                if (atkWeapon is BaseSpear)
                {
                    atkValue = attackerSpearFightingSkill;
                    atkSkill = attacker.Skills[SkillName.SpearFighting];
                }
                else if (atkWeapon is BaseLance)
                {
                    atkValue = attackerJoustingSkill;
                    atkSkill = attacker.Skills[SkillName.Jousting];
                }
            }
            else if (atkWeapon is BaseQuarterStaff)
            {
                atkValue = attackerQuarterStaffSkill;
                atkSkill = attacker.Skills[SkillName.QuarterStaff];
            }
           
            // Apply Skill Modifiers
            if (m_AosWeaponAttributes.UseBestSkill != 0)
            {
                  atkValue = attackerAxeFightingSkill;
                  atkSkill = attacker.Skills[SkillName.AxeFighting];
                  if (attackerFencingSkill > atkValue)
                  {
                      atkValue = attackerFencingSkill;
                      atkSkill = attacker.Skills[SkillName.Fencing];
                  }
                  else if (attackerJoustingSkill > atkValue)
                  {
                      atkValue = attackerJoustingSkill;
                      atkSkill = attacker.Skills[SkillName.Jousting];
                  }
                  else if (attackerKnifeFightingSkill > atkValue)
                  {
                      atkValue = attackerKnifeFightingSkill;
                      atkSkill = attacker.Skills[SkillName.KnifeFighting];
                  }
                  else if (attackerMacingSkill > atkValue)
                  {
                      atkValue = attackerMacingSkill;
                      atkSkill = attacker.Skills[SkillName.Macing];
                  }
                  else if (attackerMacingClubSkill > atkValue)
                  {
                      atkValue = attackerMacingClubSkill;
                      atkSkill = attacker.Skills[SkillName.Club];
                  }
                  else if (attackerMacingFlailSkill > atkValue)
                  {
                      atkValue = attackerMacingFlailSkill;
                      atkSkill = attacker.Skills[SkillName.Flail];
                  }
                  else if (attackerMacingHammerSkill > atkValue)
                  {
                      atkValue = attackerMacingHammerSkill;
                      atkSkill = attacker.Skills[SkillName.Hammer];
                  }
                  else if (attackerPoleArmSkill > atkValue)
                  {
                      atkValue = attackerPoleArmSkill;
                      atkSkill = attacker.Skills[SkillName.PoleArm];
                  }
                  else if (attackerSpearFightingSkill > atkValue)
                  {
                      atkValue = attackerSpearFightingSkill;
                      atkSkill = attacker.Skills[SkillName.SpearFighting];
                  }
                  else if (attackerSwordsmanshipSkill > atkValue)
                  {
                      atkValue = attackerSwordsmanshipSkill;
                      atkSkill = attacker.Skills[SkillName.Swords];
                  }
                  else if (attackerTwoHandedSwordsSkill > atkValue)
                  {
                      atkValue = attackerTwoHandedSwordsSkill;
                      atkSkill = attacker.Skills[SkillName.TwoHandedSwords];
                  }
                  else if (attackerQuarterStaffSkill > atkValue)
                  {
                      atkValue = attackerQuarterStaffSkill;
                      atkSkill = attacker.Skills[SkillName.QuarterStaff];
                  }
            }
            else if (m_AosWeaponAttributes.MageWeapon != 0)
            {
                  if (attackerMagerySkill > atkValue)
                  {
                      atkValue = attackerMagerySkill;
                      atkSkill = attacker.Skills[SkillName.Magery];
                  }
            }
            atkValue *= GetMountModifier (attacker, defender);
         
            // Defender
            double defenderMagerySkill = defender.Skills[SkillName.Magery].Base;
            double defenderAxeFightingSkill = defender.Skills[SkillName.AxeFighting].Base;
            double defenderFencingSkill = defender.Skills[SkillName.Fencing].Base;
            double defenderJoustingSkill = defender.Skills[SkillName.Jousting].Base;
            double defenderKnifeFightingSkill = defender.Skills[SkillName.KnifeFighting].Base;
            double defenderMacingSkill = defender.Skills[SkillName.Macing].Base;
            double defenderMacingClubSkill = defender.Skills[SkillName.Club].Base;
            double defenderMacingFlailSkill = defender.Skills[SkillName.Flail].Base;
            double defenderMacingHammerSkill = defender.Skills[SkillName.Hammer].Base;
            double defenderPoleArmSkill = defender.Skills[SkillName.PoleArm].Base;
            double defenderSpearFightingSkill = defender.Skills[SkillName.SpearFighting].Base;
            double defenderSwordsmanshipSkill = defender.Skills[SkillName.Swords].Base;
            double defenderTwoHandedSwordsSkill = defender.Skills[SkillName.TwoHandedSwords].Base;
            double defenderQuarterStaffSkill = defender.Skills[SkillName.QuarterStaff].Base;
            defValue = defender.Skills[SkillName.Wrestling].Base;
            if (defWeapon is BaseAxe)
                defValue = defenderAxeFightingSkill;
            else if (defWeapon is BaseRapier)
                defValue = defenderFencingSkill;
            else if (defWeapon is BaseKnife)
                  defValue = defenderKnifeFightingSkill;
            else if (defWeapon is BaseSword)
            {
                  defValue = defenderSwordsmanshipSkill;
                  if (defWeapon is BaseTwoHandedSword)
                      defValue = defenderTwoHandedSwordsSkill;
            }
            else if (defWeapon is BaseMace)
            {
                  defValue = defenderMacingSkill;
                  if (defWeapon is BaseClub)
                      defValue = defenderMacingClubSkill;
                  else if (defWeapon is BaseFlail)
                      defValue = defenderMacingFlailSkill;
                  else if (defWeapon is BaseHammer)
                      defValue = defenderMacingHammerSkill;
            }
            else if (defWeapon is BasePoleArm)
            {
                  defValue = defenderPoleArmSkill;
                  if (defWeapon is BaseSpear)
                      defValue = defenderSpearFightingSkill;
                  else if (defWeapon is BaseLance)
                      defValue = defenderJoustingSkill;
            }
            else if (defWeapon is BaseQuarterStaff)
            {
                  defValue = defenderQuarterStaffSkill;
            }
            if (m_AosWeaponAttributes.UseBestSkill != 0)
            {
                  defValue = defenderAxeFightingSkill;
                  if (defenderFencingSkill > defValue)
                  {
                      defValue = defenderFencingSkill;
                  }
                  else if (defenderJoustingSkill > defValue)
                  {
                      defValue = defenderJoustingSkill;                       
                  }
                  else if (defenderKnifeFightingSkill > defValue)
                  {
                      defValue = defenderKnifeFightingSkill;                       
                  }
                  else if (defenderMacingSkill > defValue)
                  {
                      defValue = defenderMacingSkill;                       
                  }
                  else if (defenderMacingClubSkill > defValue)
                  {
                      defValue = defenderMacingClubSkill;                       
                  }
                  else if (defenderMacingFlailSkill > defValue)
                  {
                      defValue = defenderMacingFlailSkill;                       
                  }
                  else if (defenderMacingHammerSkill > defValue)
                  {
                      defValue = defenderMacingHammerSkill;                       
                  }
                  else if (defenderPoleArmSkill > defValue)
                  {
                      defValue = defenderPoleArmSkill;                       
                  }
                  else if (defenderSpearFightingSkill > defValue)
                  {
                      defValue = defenderSpearFightingSkill;                       
                  }
                  else if (defenderSwordsmanshipSkill > defValue)
                  {
                      defValue = defenderSwordsmanshipSkill;                       
                  }
                  else if (defenderTwoHandedSwordsSkill > defValue)
                  {
                      defValue = defenderTwoHandedSwordsSkill;   
                  }
                  else if (defenderQuarterStaffSkill > defValue)
                  {
                      defValue = defenderQuarterStaffSkill;
                  }
            }
            else if (m_AosWeaponAttributes.MageWeapon != 0)
            {
                  if (defenderMagerySkill > defValue)
                  {
                      defValue = defenderMagerySkill;
                  }
            }
            defValue *= GetMountModifier (defender, attacker);
                                 
            //**************************************************************************************
           
            double ourValue, theirValue;
 
            int bonus = GetHitChanceBonus();
 
            if ( Core.AOS )
            {
                if ( atkValue <= -20.0 )
                    atkValue = -19.9;
 
                if ( defValue <= -20.0 )
                    defValue = -19.9;
 
                bonus += AosAttributes.GetValue( attacker, AosAttribute.AttackChance );
 
                if ( Spells.Chivalry.DivineFurySpell.UnderEffect( attacker ) )
                    bonus += 10; // attacker gets 10% bonus when they're under divine fury
 
                if ( CheckAnimal( attacker, typeof( GreyWolf ) ) || CheckAnimal( attacker, typeof( BakeKitsune ) ) )
                    bonus += 20; // attacker gets 20% bonus when under Wolf or Bake Kitsune form
 
                if ( HitLower.IsUnderAttackEffect( attacker ) )
                    bonus -= 25; // Under Hit Lower Attack effect -> 25% malus
 
                WeaponAbility ability = WeaponAbility.GetCurrentAbility( attacker );
 
                if ( ability != null )
                    bonus += ability.AccuracyBonus;
 
                SpecialMove move = SpecialMove.GetCurrentMove( attacker );
 
                if ( move != null )
                    bonus += move.GetAccuracyBonus( attacker );
 
                // Max Hit Chance Increase = 45%
                if ( bonus > 45 )
                    bonus = 45;
 
                ourValue = (atkValue + 20.0) * (100 + bonus);
 
                bonus = AosAttributes.GetValue( defender, AosAttribute.DefendChance );
 
                if ( Spells.Chivalry.DivineFurySpell.UnderEffect( defender ) )
                    bonus -= 20; // defender loses 20% bonus when they're under divine fury
 
                if ( HitLower.IsUnderDefenseEffect( defender ) )
                    bonus -= 25; // Under Hit Lower Defense effect -> 25% malus
                   
                int blockBonus = 0;
 
                if ( Block.GetBonus( defender, ref blockBonus ) )
                    bonus += blockBonus;
 
                int surpriseMalus = 0;
 
                if ( SurpriseAttack.GetMalus( defender, ref surpriseMalus ) )
                    bonus -= surpriseMalus;
 
                int discordanceEffect = 0;
 
                // Defender loses -0/-28% if under the effect of Discordance.
                if ( SkillHandlers.Discordance.GetEffect( attacker, ref discordanceEffect ) )
                    bonus -= discordanceEffect;
 
                // Defense Chance Increase = 45%
                if ( bonus > 45 )
                    bonus = 45;
 
                theirValue = (defValue + 20.0) * (100 + bonus);
 
                bonus = 0;
            }
            else
            {
                if ( atkValue <= -50.0 )
                    atkValue = -49.9;
 
                if ( defValue <= -50.0 )
                    defValue = -49.9;
 
                ourValue = (atkValue + 50.0);
                theirValue = (defValue + 50.0);
            }
 
            double chance = ourValue / (theirValue * 2.0);
 
            chance *= 1.0 + ((double)bonus / 100);
 
            if ( Core.AOS && chance < 0.02 )
                chance = 0.02;
           
            return attacker.CheckSkill( atkSkill.SkillName, chance );
        }
 
        public virtual TimeSpan GetDelay( Mobile m )
        {
            double speed = this.Speed;
 
            if ( speed == 0 )
                return TimeSpan.FromHours( 1.0 );
 
            double delayInSeconds;
 
            if ( Core.SE )
            {
                /*
                * This is likely true for Core.AOS as well... both guides report the same
                * formula, and both are wrong.
                * The old formula left in for AOS for legacy & because we aren't quite 100%
                * Sure that AOS has THIS formula
                */
                int bonus = AosAttributes.GetValue( m, AosAttribute.WeaponSpeed );
 
                if ( Spells.Chivalry.DivineFurySpell.UnderEffect( m ) )
                    bonus += 10;
 
                // Bonus granted by successful use of Honorable Execution.
                bonus += HonorableExecution.GetSwingBonus( m );
 
                if( DualWield.Registry.Contains( m ) )
                    bonus += ((DualWield.DualWieldTimer)DualWield.Registry[m]).BonusSwingSpeed;
 
                if( Feint.Registry.Contains( m ) )
                    bonus -= ((Feint.FeintTimer)Feint.Registry[m]).SwingSpeedReduction;
 
                TransformContext context = TransformationSpellHelper.GetContext( m );
 
                if( context != null && context.Spell is ReaperFormSpell )
                    bonus += ((ReaperFormSpell)context.Spell).SwingSpeedBonus;
 
                int discordanceEffect = 0;
 
                // Discordance gives a malus of -0/-28% to swing speed.
                if ( SkillHandlers.Discordance.GetEffect( m, ref discordanceEffect ) )
                    bonus -= discordanceEffect;
 
                if( EssenceOfWindSpell.IsDebuffed( m ) )
                    bonus -= EssenceOfWindSpell.GetSSIMalus( m );
 
                if ( bonus > 60 )
                    bonus = 60;
               
                double ticks;
 
                if ( Core.ML )
                {
                    int stamTicks = m.Stam / 30;
 
                    ticks = speed * 4;
                    ticks = Math.Floor( ( ticks - stamTicks ) * ( 100.0 / ( 100 + bonus ) ) );
                }
                else
                {
                    speed = Math.Floor( speed * ( bonus + 100.0 ) / 100.0 );
 
                    if ( speed <= 0 )
                        speed = 1;
 
                    ticks = Math.Floor( ( 80000.0 / ( ( m.Stam + 100 ) * speed ) ) - 2 );
                }
               
                // Swing speed currently capped at one swing every 1.25 seconds (5 ticks).
                if ( ticks < 5 )
                    ticks = 5;
 
                delayInSeconds = ticks * 0.25;
            }
            else if ( Core.AOS )
            {
                int v = (m.Stam + 100) * (int) speed;
 
                int bonus = AosAttributes.GetValue( m, AosAttribute.WeaponSpeed );
 
                if ( Spells.Chivalry.DivineFurySpell.UnderEffect( m ) )
                    bonus += 10;
 
                int discordanceEffect = 0;
 
                // Discordance gives a malus of -0/-28% to swing speed.
                if ( SkillHandlers.Discordance.GetEffect( m, ref discordanceEffect ) )
                    bonus -= discordanceEffect;
 
                v += AOS.Scale( v, bonus );
 
                if ( v <= 0 )
                    v = 1;
 
                delayInSeconds = Math.Floor( 40000.0 / v ) * 0.5;
 
                // Maximum swing rate capped at one swing per second
                // OSI dev said that it has and is supposed to be 1.25
                if ( delayInSeconds < 1.25 )
                    delayInSeconds = 1.25;
            }
            else
            {
                int v = (m.Stam + 100) * (int) speed;
 
                if ( v <= 0 )
                    v = 1;
 
                delayInSeconds = 15000.0 / v;
            }
 
            return TimeSpan.FromSeconds( delayInSeconds );
        }
 
        public virtual void OnBeforeSwing( Mobile attacker, Mobile defender )
        {
            WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );
 
            if( a != null && !a.OnBeforeSwing( attacker, defender ) )
                WeaponAbility.ClearCurrentAbility( attacker );
 
            SpecialMove move = SpecialMove.GetCurrentMove( attacker );
 
            if( move != null && !move.OnBeforeSwing( attacker, defender ) )
                SpecialMove.ClearCurrentMove( attacker );
        }
 
        public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender )
        {
            return OnSwing( attacker, defender, 1.0 );
        }
 
        public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender, double damageBonus )
        {
            bool canSwing = true;
           
            if ( Core.AOS )
            {
                canSwing = ( !attacker.Paralyzed && !attacker.Frozen );
 
                if ( canSwing )
                {
                    Spell sp = attacker.Spell as Spell;
 
                    canSwing = ( sp == null || !sp.IsCasting || !sp.BlocksMovement );
                }
 
                if ( canSwing )
                {
                    PlayerMobile p = attacker as PlayerMobile;
 
                    canSwing = ( p == null || p.PeacedUntil <= DateTime.UtcNow );
                }
            }
 
            #region Dueling
            if ( attacker is PlayerMobile )
            {
                PlayerMobile pm = (PlayerMobile)attacker;
 
                if ( pm.DuelContext != null && !pm.DuelContext.CheckItemEquip( attacker, this ) )
                    canSwing = false;
            }
            #endregion
 
            if ( canSwing && attacker.HarmfulCheck( defender ) )
            {
                attacker.DisruptiveAction();
 
                if ( attacker.NetState != null )
                    attacker.Send( new Swing( 0, attacker, defender ) );
 
                if ( attacker is BaseCreature )
                {
                    BaseCreature bc = (BaseCreature)attacker;
                    WeaponAbility ab = bc.GetWeaponAbility();
 
                    if ( ab != null )
                    {
                        if ( bc.WeaponAbilityChance > Utility.RandomDouble() )
                            WeaponAbility.SetCurrentAbility( bc, ab );
                        else
                            WeaponAbility.ClearCurrentAbility( bc );
                    }
                }
 
                if ( CheckHit( attacker, defender ) )
                    OnHit( attacker, defender, damageBonus );
                else
                    OnMiss( attacker, defender );
            }
 
            return GetDelay( attacker );
        }
 

pooka01

Sorceror
Just a question and a thought,
Are you attacking directly the mongbat? or are you wauiting for counter attack by itself?
If you are waiting for it to counter-attack, i'm sure i saw something in razor or ingame options about auto attacking the combatant.
I could be wrong tho...

Edit: Also it should technically auto target the aggressor when it spots and attack you on far sight, so that's weird, could be AI issues too, cause when a creatures attacks you, and you go in peace, then back to war, if it damages you it should not attack the aggressor automatically.
 

ThatDudeJBob

Sorceror
I had this issue a little bit ago with my Soul Evolution Sword.
I'm pretty sure that i had this issue when i added some "GetProperties", "NameProperties" or something of the like.
What was the latest thing you added before you started to get this problem.
 

siran

Sorceror
ThatDudeJBob: I have extensively modified BaseWeapon and individual weapon scripts, but currently nothing in GetProperties or NameProperties. I just tested with both staff character and normal player character with same results.
Pooka: It doesn't matter if I attack the mongbat or wait till it aggresses on me. There are no changes to the AI scripts.

It is as if the OnSwing, OnHit, and CheckHit routines are only being called for the mongbat, not for the player. The player character never swings back unless you unequip and fight with fists. Or, weirdly, if during combat you save and reboot when you log back in the player character is fighting back.
 

pooka01

Sorceror
I would take a guess and compare basemeleeweapon (or fists.cs not sure which), and comparing it with baseweapon to se if there is anything missing.
 

siran

Sorceror
Well I'm really stumped on this one. Over the last couple of days I have done a lot of testing and nothing adds up.

1. Created two player characters and attempted combat with each other. It doesn't matter what kind of weapon is equipped (have tried swords, maces, bows, knives, etc.). Have put messages into the various methods of BaseWeapon and SkillCheck to see if they get executed or not. After booting server, one (and only one) player will swing/fire at the other, one time. Then nothing. Unequip all weapons and they will fist fight just fine, continually hitting each other until somebody dies.
2. The messages in BaseWeapon and SkillCheck show up only the one time that a player character swings. Those routines are not getting executed afterward.
3. The one time that a swing is taken, skillchecks are made for the weapon skill, tactics, and anatomy (passive checks are working).
4. Focus skillchecks are made constantly even though the combatants stand there doing nothing.
5. All tests are between player characters (not admin, gm, etc.) and are in Felucca in unguarded region.
6. If combat is between BaseCreature and player, player gets one swing and then only the creature fights. The creature will continue fighting forever or until the player dies.
7. The one swing does not reset between combatants. (The player will get one swing at one opponent and then will never swing again regardless of weapon changes, combatant changes, etc.) UNLESS you switch to fists, in which case the player will fight normally.

I have checked, rechecked all mods to SkillCheck, BaseWeapon, individual weapon scripts and can find nothing. I cannot find where the combat is initiated for a player. (OnDoubleClick in BaseCreature, for example, or in Mobile.cs, or in PlayerMobile).

Does anyone know how the OnSwing or OnBeforeSwing method ever gets initiated?
 

pooka01

Sorceror
here is my onswing method, if you need to compare, i'm using runuo 2.0 rc1 tho, so avoid copy pasting :p
Code:
public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender )
  {
   return OnSwing( attacker, defender, 1.0 );
  }
  public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender, double damageBonus )
  {
   bool canSwing = true;
   if ( Core.AOS )
   {
    canSwing = ( !attacker.Paralyzed && !attacker.Frozen );
    if ( canSwing )
    {
     Spell sp = attacker.Spell as Spell;
     canSwing = ( sp == null || !sp.IsCasting || !sp.BlocksMovement );
    }
   }
   if ( canSwing && attacker.HarmfulCheck( defender ) )
   {
    attacker.DisruptiveAction();
    if ( attacker.NetState != null )
     attacker.Send( new Swing( 0, attacker, defender ) );
    if ( attacker is BaseCreature )
    {
     BaseCreature bc = (BaseCreature)attacker;
     WeaponAbility ab = bc.GetWeaponAbility();
     if ( ab != null )
     {
      if ( bc.WeaponAbilityChance > Utility.RandomDouble() )
       WeaponAbility.SetCurrentAbility( bc, ab );
      else
       WeaponAbility.ClearCurrentAbility( bc );
     }
    }
    if ( CheckHit( attacker, defender ) )
     OnHit( attacker, defender, damageBonus );
    else
     OnMiss( attacker, defender );
   }
   return GetDelay( attacker );
  }
 
Top