• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            天行健 君子當自強而不息

            Controlling Players and Characters(26)

             

            Taking a Swing

            When a character takes a swing at another character, this action triggers the
            process that determines whether the blow hit the target. Determining whether the
            attack hit involves an attacking character’s to-hit ability and a defending character’s
            agility ability. Remember that the higher the ability values, the better the chance to
            hit or dodge the attack.

            The to-hit ability can range from 0 (always misses) to 999 (always hits). By taking
            a random number and comparing it to the to-hit value, you can quickly determine
            whether a hit was accomplished. If the random number is equal to or less than the
            to-hit attribute, the blow lands. The following code illustrates how to determine
            whether a hit is successful:

            // ToHit = character’s to-hit attribute value
            long RandomValue = rand() % 1000;
            BOOL HitFlag = (RandomValue <= ToHit) ? TRUE : FALSE;

            In the preceding code, HitFlag is set to TRUE if the blow lands, or rather if the blow
            should land. In order to improve the chances of hitting a target, the attacker can
            have specific status ailments that decrease or increase the to-hit value. Two status
            ailments in use that affect the attacker’s to-hit ability are Blind and Hawkeye. The
            Blind status ailment reduces the to-hit chance ability by 25 percent, whereas
            Hawkeye increases the chances to hit by 50 percent.

            To apply either status ailment modifiers, multiply the determined to-hit value:

            if(Ailments & AILMENT_BLIND)
              ToHit = (long)((float)ToHit * 0.75f);

            if(Ailments & AILMENT_HAWKEYE)
              ToHit = (long)((float)ToHit * 1.5f);

            long RandomValue = rand() % 999;
            BOOL HitFlag = (RandomValue <= ToHit) ? TRUE : FALSE;

             

            Dodging an Attack

            Remember that a victim’s agility ability comes into play when being attacked. The
            greater the defender’s agility, the greater the chance the victim dodges the attack.
            You calculate whether the defender dodges the attack in the same way that you
            check whether the attacker makes a hit:

            // Agility = character’s agility ability
            RandomValue = rand() % 999;
            BOOL DodgeFlag = (RandomValue <= Agility) ? TRUE : FALSE;

            In order to decrease or increase the chances of dodging an attack, you
            can use the Clumsy and Surefooted status ailments. Clumsy decreases
            the chances of dodging and attack by 25 percent, whereas Surefooted
            increases the chances by 50 percent (meaning that characters that are
            affected by both the Clumsy and Surefooted ailments have their
            chances of dodging an attack increased by 25%):

            CAUTION
            You can determine from the agility dodging calculations that the higher the
            agility, the higher the chance of dodging the attack. For that reason, you generally
            don’t set a character’s agility too high because they can become untouchable.

            if(Ailments & AILMENT_CLUMSY)
              Agility = (long)((float)Agility * 0.75f);

            if(Ailments & AILMENT_SUREFOOTED)
              Agility = (long)((float)Agility * 1.5f);

            long RandomValue = rand() % 999;
            BOOL DodgeFlag = (RandomValue <= Agility) ? TRUE : FALSE;

             

            Dealing Damage

            When it is determined that the blow hit the victim, it’s time to calculate how much
            damage was done, which is where the character’s attack and defense abilities come
            into play. Damage is usually variable, which means that rarely does the same attack
            do the same damage each time. Again, you use a little randomness.

            To keep things simple, you can take the attacker’s attack ability value (or at least 90
            percent to 110 percent of it) and subtract the victim’s defense value (at least 80
            percent to 100 percent of it). Note that status ailments are an issue here as well,
            along with the use of items to increase the attack and defense abilities.

            That’s right. Equipped items add a multiplier to the attack and defense abilities.
            The item modifier value is the key. The value represents a value from 0 and up
            that, when divided by 100 and increased by one, gives you a multiplier value to use
            in conjunction with the ability value. For example, a weapon with a modifier value
            of 150 increases the attack ability by 50 percent:

            // Attack = character’s attack ability value
            // Item[] = master item list array
            long Attack = (long)((float)Attack * (((float)Item[Weapon].Value / 100.0f) + 1.0f));

            Getting back to status ailments, two affect both attack and defense—Weak and Strong.
            Weak reduces attack and defense by half whereas Strong increases the values by 50 percent.
            Here’s how everything works to determine the amount of damage to apply:

            // Attack = attacker’s attack ability value
            // Defense = defenders defense ability value
            // Item[] = master item list array
            // Weapon = weapon # in item list (or -1 if none)
            // Armor = armor # in item list (or -1 if none)
            // Shield = shield # in item list (or -1 if none)
            // Determine attack amount
            // Start with adding equipping weapon modifier

            if(Weapon != -1)
              long Attack = (long)((float)Attack * (((float)Item[Weapon].Value / 100.0f) + 1.0f));

            // Adjust by status ailments
            if(Ailments & AILMENT_WEAK)
              Attack = (long)((float)Attack * 0.5f);

            if(Ailments & AILMENT_STRONG)
              Attack = (long)((float)Attack * 1.5f);

            // Determine defense amount
            // Apply armor and shield modifiers
            if(Armor != -1)
              Defense = (long)((float)Defense * (((float)Item[Armor].Value / 100.0f) + 1.0f);

            if(Shield != -1)
              Defense = (long)((float)Defense * (((float)Item[Shield].Value / 100.0f) + 1.0f);

            // Apply status ailments
            if(Ailments & AILMENT_WEAK)
              Defense = (long)((float)Defense * 0.5f);

            if(Ailments & AILMENT_STRONG)
              Defense = (long)((float)Defense * 1.5f);

            float DamagePercent = ((float)(rand() % 70) + 50.0f) / 100.0f;
            long DamageAmount = (long)((float)Attack * DamagePercent);

            // Determine damage amount (use some randomness in there)
            float Range = (float)((rand() % 20) + 90) / 100.0f;
            long DmgAmount = (long)((float)Attack * Range);
            Range = (float)((rand() % 20) + 80) / 100.0f;
            DmgAmount -= (long)((float)Defense * Range);

            At long last, the DmgAmount variable will contain the amount of damage that is dealt.
            You’re not done at this point, however, because now character class comes into
            play. If an attack is strong against the character’s class type, damage is doubled.
            If the victim is of the same class as the attack, that attack cures the
            victim for half the amount of damage dealt! I’ll let you work those into the calculations.

            CAUTION
            Again, the defense ability of a character shouldn’t be so high that the defending
            character rarely takes any damage when an attack hits.

            posted on 2007-12-03 20:31 lovedday 閱讀(265) 評論(0)  編輯 收藏 引用

            公告

            導航

            統計

            常用鏈接

            隨筆分類(178)

            3D游戲編程相關鏈接

            搜索

            最新評論

            久久精品国产亚洲AV大全| 久久99精品国产麻豆宅宅| 好久久免费视频高清| 欧美激情精品久久久久| 色欲综合久久躁天天躁| 亚洲精品美女久久777777| 99久久国产亚洲高清观看2024 | 免费精品99久久国产综合精品| 久久91精品国产91久久户| 亚洲国产精品综合久久一线| 国产成人久久精品一区二区三区| 国产—久久香蕉国产线看观看| 久久婷婷五月综合97色直播| 国産精品久久久久久久| 日韩人妻无码一区二区三区久久| 国产成人综合久久精品尤物| 久久无码AV中文出轨人妻| 久久香蕉国产线看观看乱码| 亚洲综合熟女久久久30p| 久久精品亚洲精品国产欧美| 国产日产久久高清欧美一区| 久久亚洲中文字幕精品一区| 久久男人中文字幕资源站| 久久成人精品视频| 粉嫩小泬无遮挡久久久久久| 亚洲中文字幕久久精品无码APP | 国产精品一区二区久久精品无码 | 国内精品久久国产大陆| 亚洲中文字幕久久精品无码APP| 久久毛片免费看一区二区三区| 国产精品久久免费| 久久99精品久久久久久久久久| 久久久久久国产精品无码下载 | 国产亚洲婷婷香蕉久久精品| 国产精品女同久久久久电影院| 亚洲av伊人久久综合密臀性色| 亚洲欧美日韩精品久久亚洲区| 午夜精品久久久内射近拍高清| 欧美一级久久久久久久大片| 色综合久久88色综合天天 | 亚洲精品无码久久毛片|