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


C# GameLiving.WeaponDamage方法代码示例

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


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

示例1: ExecuteStyle

        /// <summary>
        /// Executes the style of the given player. Prints
        /// out messages to the player notifying him of his success or failure.
        /// </summary>
        /// <param name="living">The living executing the styles</param>
        /// <param name="attackData">
        /// The AttackData that will be modified to contain the 
        /// new damage and the executed style.
        /// </param>
        /// <param name="weapon">The weapon used to execute the style</param>
        /// <returns>true if a style was performed, false if not</returns>
        public static bool ExecuteStyle(GameLiving living, AttackData attackData, InventoryItem weapon)
        {
            //First thing in processors, lock the objects you modify
            //This way it makes sure the objects are not modified by
            //several different threads at the same time!

            GamePlayer player = living as GamePlayer;
            lock (living)
            {
                //Does the player want to execute a style at all?
                if (attackData.Style == null)
                    return false;

                if (weapon != null && weapon.Object_Type == (int)eObjectType.Shield)
                {
                    attackData.AnimationId = (weapon.Hand != 1) ? attackData.Style.Icon : attackData.Style.TwoHandAnimation; // 2h shield?
                }
                int fatCost = 0;
                if (weapon != null)
                    fatCost = CalculateEnduranceCost(living, attackData.Style, weapon.SPD_ABS);

                //Reduce endurance if styled attack missed
                switch (attackData.AttackResult)
                {
                    case GameLiving.eAttackResult.Blocked:
                    case GameLiving.eAttackResult.Evaded:
                    case GameLiving.eAttackResult.Missed:
                    case GameLiving.eAttackResult.Parried:
                        if (player != null) //No mob endu lost yet
                            living.Endurance -= Math.Max(1, fatCost / 2);
                        return false;
                }

                //Ignore all other attack results
                if (attackData.AttackResult != GameLiving.eAttackResult.HitUnstyled
                    && attackData.AttackResult != GameLiving.eAttackResult.HitStyle)
                    return false;

                //Did primary and backup style fail?
                if (!CanUseStyle(living, attackData.Style, weapon))
                {
                    if (player != null)
                    {
                        // reduce players endurance, full endurance if failed style
                        player.Endurance -= fatCost;

                        //"You must be hidden to perform this style!"
                        //Print a style-fail message
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "StyleProcessor.ExecuteStyle.ExecuteFail", attackData.Style.Name), eChatType.CT_YouHit, eChatLoc.CL_SystemWindow);
                    }
                    return false;
                }
                else
                {
                    //Style worked! Print out some nice info and add the damage! :)
                    //Growth * Style Spec * Effective Speed / Unstyled Damage Cap

                    bool staticGrowth = attackData.Style.StealthRequirement;  //static growth is not a function of (effective) weapon speed
                    double absorbRatio = attackData.Damage / living.UnstyledDamageCap(weapon); //scaling factor for style damage
                    double effectiveWeaponSpeed = living.AttackSpeed(weapon) * 0.001;
                    double styleGrowth = Math.Max(0,attackData.Style.GrowthOffset + attackData.Style.GrowthRate * living.GetModifiedSpecLevel(attackData.Style.Spec));
                    double styleDamageBonus = living.GetModified(eProperty.StyleDamage) * 0.01 - 1;

                    if (staticGrowth)
                    {
                        if (living.AttackWeapon.Item_Type == Slot.TWOHAND)
                        {
                            styleGrowth = styleGrowth * 1.25 + living.WeaponDamage(living.AttackWeapon) * Math.Max(0,living.AttackWeapon.SPD_ABS - 21) * 10 / 66d;
                        }
                        attackData.StyleDamage = (int)(absorbRatio * styleGrowth * ServerProperties.Properties.CS_OPENING_EFFECTIVENESS);
                    }
                    else
                        attackData.StyleDamage = (int)(absorbRatio * styleGrowth * effectiveWeaponSpeed);

                    attackData.StyleDamage += (int)(attackData.Damage * styleDamageBonus);

                    //Eden - style absorb bonus
                    int absorb=0;
                    if(attackData.Target is GamePlayer && attackData.Target.GetModified(eProperty.StyleAbsorb) > 0)
                    {
                        absorb=(int)Math.Floor((double)attackData.StyleDamage * ((double)attackData.Target.GetModified(eProperty.StyleAbsorb)/100));
                        attackData.StyleDamage -= absorb;
                    }

                    //Increase regular damage by styledamage ... like on live servers
                    attackData.Damage += attackData.StyleDamage;

                    if (player != null)
                    {
//.........这里部分代码省略.........
开发者ID:mynew4,项目名称:DOLSharp,代码行数:101,代码来源:StyleProcessor.cs


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