当前位置: 首页>>代码示例>>C#>>正文


C# CharData.GetSkillChance方法代码示例

本文整理汇总了C#中MUDEngine.CharData.GetSkillChance方法的典型用法代码示例。如果您正苦于以下问题:C# CharData.GetSkillChance方法的具体用法?C# CharData.GetSkillChance怎么用?C# CharData.GetSkillChance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MUDEngine.CharData的用法示例。


在下文中一共展示了CharData.GetSkillChance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckDodge

        /// <summary>
        /// Checks whether the victim is able to dodge the attacker's swing.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="victim"></param>
        /// <returns></returns>
        public static bool CheckDodge( CharData ch, CharData victim )
        {
            if( !victim.IsAwake() || victim.CurrentPosition < Position.reclining )
                return false;

            if (ch.IsAffected(Affect.AFFECT_DAZZLE))
                return false;

            if( !victim.HasSkill( "dodge" ) )
                return false;

            int chance = victim.GetSkillChance("dodge");

            // Size difference bonus for dodge for halflings - they get 2% dodge
            // bonus per size difference between them and the attacker. -- Xangis
            // Drow get a flat 15% bonus.
            if( victim.GetRace() == Race.RACE_HALFLING )
            {
                if( ch.CurrentSize > victim.CurrentSize )
                {
                    chance += 3 * ( ch.CurrentSize - victim.CurrentSize );
                }
            }
            else if( victim.HasInnate( Race.RACE_GOOD_DODGE ) )
            {
                chance += 8;
            }
            else if( victim.HasInnate( Race.RACE_BAD_DODGE ) )
            {
                chance -= 3;
            }

            // Bashed mobs/creatures have a hard time dodging
            if( victim.CurrentPosition < Position.fighting )
            {
                chance -= 25;
            }

            // Leap is 16% max at level 50.  Considering crappy thri hitpoints it's necessary.
            if( victim.GetRace() == Race.RACE_THRIKREEN && MUDMath.NumberPercent() <= ( victim.Level / 3 ) )
            {
                SocketConnection.Act( "$N&n leaps over your attack.", ch, null, victim, SocketConnection.MessageTarget.character );
                SocketConnection.Act( "You leap over $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.victim );
                SocketConnection.Act( "$N&n leaps over $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.room_vict );
                return true;
            }

            victim.PracticeSkill( "dodge" );

            if( MUDMath.NumberPercent() >= chance - ch.Level )
                return false;

            switch( MUDMath.NumberRange( 1, 2 ) )
            {
                case 1:
                    SocketConnection.Act( "$N&n dodges your attack.", ch, null, victim, SocketConnection.MessageTarget.character );
                    SocketConnection.Act( "You dodge $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.victim );
                    SocketConnection.Act( "$N&n dodges $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.room_vict );
                    break;
                case 2:
                    SocketConnection.Act( "$N&n sidesteps your attack.", ch, null, victim, SocketConnection.MessageTarget.character );
                    SocketConnection.Act( "You narrowly dodge $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.victim );
                    SocketConnection.Act( "$N&n avoids $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.room_vict );
                    break;
                default:
                    break;
            }

            if( ch.Fighting == null )
                SetFighting( ch, victim );
            if( victim.Fighting == null )
                SetFighting( victim, ch );

            return true;
        }
开发者ID:carriercomm,项目名称:ModernMUD,代码行数:81,代码来源:Combat.cs

示例2: CheckShieldBlock

        /// <summary>
        /// Checks for block if holding shield.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="victim"></param>
        /// <returns></returns>
        static bool CheckShieldBlock( CharData ch, CharData victim )
        {
            if( !victim.HasSkill( "shield block" ) )
                return false;

            if( ch.IsAffected( Affect.AFFECT_DAZZLE ) )
                return false;

            if( !victim.IsAwake() || victim.CurrentPosition < Position.reclining )
                return false;

            Object obj = Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_one );
            if( !obj || ( obj.ItemType != ObjTemplate.ObjectType.shield ) )
            {
                if( !( obj = Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_two ) ) )
                    return false;
                if( obj.ItemType != ObjTemplate.ObjectType.shield )
                    return false;
            }
            if( obj.ItemType != ObjTemplate.ObjectType.shield )
            {
                if( !( obj = Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_two ) ) )
                    return false;
                if( obj.ItemType != ObjTemplate.ObjectType.shield )
                    return false;
            }

            int chance = ch.GetSkillChance("shield block");
            victim.PracticeSkill("shield block");

            if (MUDMath.NumberPercent() >= ((chance - ch.Level) / 2))
            {
                return false;
            }

            switch( MUDMath.NumberRange( 1, 5 ) )
            {
                case 1:
                    SocketConnection.Act( "You block $n&n's attack with your shield.", ch, null, victim, SocketConnection.MessageTarget.victim );
                    SocketConnection.Act( "$N&n blocks your attack with a shield.", ch, null, victim, SocketConnection.MessageTarget.character );
                    SocketConnection.Act( "$N&n blocks $n&n's attack with a shield.", ch, null, victim, SocketConnection.MessageTarget.room_vict );
                    break;
                case 2:
                    // If we were really smart we would check to see whether both the shield
                    // and weapon were made of metal before we gave a sparks message...
                    SocketConnection.Act( "&+CS&n&+cp&+Car&n&+ck&+Cs&n fly off your shield as you block $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.victim );
                    SocketConnection.Act( "$N&n defends against your attack with a shield.", ch, null, victim, SocketConnection.MessageTarget.character );
                    SocketConnection.Act( "$N&n deflects $n&n's attack with a shield.", ch, null, victim, SocketConnection.MessageTarget.room_vict );
                    break;
                case 3:
                    SocketConnection.Act("You bring up your shield to block $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$N&n brings up %s shield to block your attack.", ch, null, victim, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$N&n brings up %s shield to blocks $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.room_vict);
                    break;
                case 4:
                    SocketConnection.Act("You knock $n&n's attack aside with your shield.", ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$N&n knocks your attack aside with $S shield.", ch, null, victim, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$N&n knocks $n&n's attack aside with $S shield.", ch, null, victim, SocketConnection.MessageTarget.room_vict);
                    break;
                case 5:
                    SocketConnection.Act("You hear a thud as $n&n's weapon smacks into your shield.", ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("Your weapon smacks into $N&n's shield with a thud.", ch, null, victim, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n's weapon smacks into $N&'s shield with a thud.", ch, null, victim, SocketConnection.MessageTarget.room_vict);
                    break;
                default:
                    break;
            }

            if( ch.Fighting == null )
                SetFighting( ch, victim );
            if( victim.Fighting == null )
                SetFighting( victim, ch );

            return true;
        }
开发者ID:carriercomm,项目名称:ModernMUD,代码行数:81,代码来源:Combat.cs

示例3: CheckParry

        /// <summary>
        /// Checks whether the victim is able to parry a swing.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="victim"></param>
        /// <returns></returns>
        static bool CheckParry( CharData ch, CharData victim )
        {
            if( !victim.IsAwake() || victim.CurrentPosition < Position.reclining )
                return false;

            if (ch.IsAffected(Affect.AFFECT_DAZZLE))
                return false;

            if( !victim.HasSkill( "parry" ) )
                return false;

            int chance = ch.GetSkillChance("parry");
            if (victim.IsNPC())
            {
                // Mobs more often than not don't have weapons
                // so they should get bonuses for actually
                // having them
                if( !Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_one ) )
                {
                    if( !Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_two ) )
                        chance -= 5;
                }
                else
                    chance += 5;
            }
            else
            {
                // No weapon means no parry.  Only secondary weapon means 50% chance to parry.
                if( !Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_one ) )
                {
                    if( !Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_two ) )
                        return false;
                    chance /= 2;
                }

                victim.PracticeSkill( "parry" );
            }

            if( MUDMath.NumberPercent() >= ( chance - ch.Level ) / 2 )
                return false;

            switch( MUDMath.NumberRange(1,3))
            {
                case 1:
                    SocketConnection.Act( "$N&n skillfully parries your attack.", ch, null, victim, SocketConnection.MessageTarget.character );
                    SocketConnection.Act( "You parry $n&n's fierce attack.", ch, null, victim, SocketConnection.MessageTarget.victim );
                    SocketConnection.Act( "$N&n parries $n&n's attack.", ch, null, victim, SocketConnection.MessageTarget.room_vict );
                    break;
                case 2:
                    SocketConnection.Act("$N&n knocks your blow aside with $S weapon.", ch, null, victim, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("You knock $n&n's clumsy attack aside with your weapon.", ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$N&n knocks $n&n's attack aside with $S weapon.", ch, null, victim, SocketConnection.MessageTarget.room_vict);
                    break;
                case 3:
                    SocketConnection.Act("$N&n deflects your attack with $S weapon.", ch, null, victim, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("You deflect $n&n's attack with your weapon.", ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$N&n deflects $n&n's attack aside with $S weapon.", ch, null, victim, SocketConnection.MessageTarget.room_vict);
                    break;
            }
            if( ch.Fighting == null )
                SetFighting( ch, victim );
            if( victim.Fighting == null )
                SetFighting( victim, ch );
            return true;
        }
开发者ID:carriercomm,项目名称:ModernMUD,代码行数:71,代码来源:Combat.cs

示例4: CheckRiposte

        /// <summary>
        /// Checks whether the victim is able to riposte the attacker's swing.  Returns false
        /// if failed, true if successful.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="victim"></param>
        /// <returns></returns>
        static bool CheckRiposte( CharData ch, CharData victim )
        {
            if( !victim.IsAwake() || victim.CurrentPosition < Position.reclining )
                return false;

            if( ch.IsAffected( Affect.AFFECT_DAZZLE ) )
                return false;

            if( ch.IsAffected( Affect.AFFECT_BLIND ) )
                return false;

            if( ch.IsAffected(Affect.AFFECT_CASTING ) )
                return false;

            if( !victim.HasSkill( "riposte" ) )
                return false;

            int chance = ch.GetSkillChance("riposte");
            if (victim.IsNPC())
            {
                // Mobs more often than not don't have weapons
                // so they should get bonuses for actually
                // having them
                if( Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_one ) )
                {
                    chance += 3;
                }
            }
            else
            {
                if( !Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_one ) )
                {
                    // Have to have a weapon to riposte.  If only holding secondary weapon chances are lowered.
                    if( !Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_two ))
                    {
                        return false;
                    }
                    chance /= 2;
                }

                victim.PracticeSkill( "riposte" );
            }

            if( MUDMath.NumberPercent() >= (( chance - ch.Level ) / 3 ) )
                return false;

            switch( MUDMath.NumberRange(1,3))
            {
                case 1:
                    SocketConnection.Act( "$N&n deflects your blow and strikes back at YOU!", ch, null, victim, SocketConnection.MessageTarget.character );
                    SocketConnection.Act( "You deflect $n&n's attack and strike back at $m.", ch, null, victim, SocketConnection.MessageTarget.victim );
                    SocketConnection.Act( "$N&n deflects $n&n's attack and strikes back at $m.", ch, null, victim, SocketConnection.MessageTarget.room_vict );
                    break;
                case 2:
                    SocketConnection.Act("$N&n knocks your swing aside and strikes back at YOU!", ch, null, victim, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("You knock $n&n's attack aside and strikes back at $m.", ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$N&n knocks $n&n's attack aside and strikes back at $m.", ch, null, victim, SocketConnection.MessageTarget.room_vict);
                    break;
                case 3:
                    SocketConnection.Act("$N&n blocks your strike and swings back at YOU!", ch, null, victim, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("You block $n&n's strike aside and swing back at $m.", ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$N&n block $n&n's strike and swings back at $m.", ch, null, victim, SocketConnection.MessageTarget.room_vict);
                    break;
            }
            return true;
        }
开发者ID:carriercomm,项目名称:ModernMUD,代码行数:73,代码来源:Combat.cs

示例5: SingleAttack


//.........这里部分代码省略.........

            /* Made really lucky chars get saved by the godz. */
            if( diceroll == 0 || ( diceroll <= 196 && diceroll < hitroll - victimAC )
                     || ( MUDMath.NumberPercent() < victim.GetCurrLuck() / 40 ) )
            {
                /* Miss. */
                return InflictDamage(ch, victim, 0, skill, weapon, damType);
            }

            /*
            * Hit.
            * Calc damage.
            *
            * NPCs are more badass barehanded than players.  If they weren't
            * the game would be too damned easy since mobs almost never have
            * weapons.
            *
            * Increased mob damage by about 1/6
            * It was previously level/2 to level*3/2 (25-75 at 50, average 50)
            * It is now level*3/5 to level*10/6      (30-87 at 50, average 59)
            *
            * Added the + ch.level - 1 'cause mobs still not hittin' hard enough
            */
            if( ch.IsNPC() )
            {
                dam = MUDMath.NumberRange( ( ch.Level * 3 / 5 ), ( ch.Level * 14 / 8 ) )
                      + ( ch.Level - 1 );
                if (wield)
                {
                    dam += MUDMath.Dice(wield.Values[1], wield.Values[2]);
                }
                else if (ch.CheckSkill("unarmed damage"))
                {
                    dam += MUDMath.NumberRange(1, (ch.GetSkillChance("unarmed damage") / 12));
                }
            }
            else
            {
                if (wield)
                {
                    dam = MUDMath.Dice(wield.Values[1], wield.Values[2]);
                }
                else
                {
                    if (!ch.IsClass(CharClass.Names.monk))
                    {
                        dam = MUDMath.NumberRange(1, (2 + (int)ch.CurrentSize / 3));
                        if (ch.CheckSkill("unarmed damage"))
                        {
                            dam += MUDMath.NumberRange(1, (ch.GetSkillChance("unarmed damage") / 12));
                        }
                    }
                    else
                    {
                        int min;
                        // monk barehanded damage - Xangis
                        ch.PracticeSkill("unarmed damage");
                        chance = ch.GetSkillChance("unarmed damage");
                        if (chance < 13)
                        {
                            min = 1;
                        }
                        else
                        {
                            min = chance / 13;
                        }
开发者ID:carriercomm,项目名称:ModernMUD,代码行数:67,代码来源:Combat.cs


注:本文中的MUDEngine.CharData.GetSkillChance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。