• <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>

            天行健 君子當(dāng)自強(qiáng)而不息

            Controlling Players and Characters(27)

             

            Spells in Combat

            Now, you can put all the neat spells that your game has to offer to good use. You
            know how spells work, but you need to know how the spells affect the characters.
            Remember that the spell controller tracks only the meshes that create the visual
            side of spells; the character controller determines the effects of the spells.

            Spells in combat are used mainly to damage an opponent. A spell uses a series of
            calculations to determine the outcome of the spell’s effects, just as physical attacks
            do. Spells have a chance of failing, which is determined by the spell’s chance value
            in the spell definition.

            The chance of a spell working is increased by the caster’s mental ability, which uses
            the following calculation to determine the multiplier to apply to the chance value:

            // Chance = spell’s chance of working
            // Mental = caster’s mental ability
            Chance = (long)(((float)Mental / 100.0f + 1.0f) * (float)Chance);

            The last line shows that the mental value can range from 0 and up. A value of 150
            means to increase the chance by 50 percent, whereas a value of 200 means to double
            the chances. To aid victims of a spell, the target characters have their associated
            resistance abilities factored in as well:

            // Resistance = target’s resistance ability
            Chance = (long)((1.0f - (float)GetResistance(Target) / 100.0f) * (float)Chance);

            When it is determined that the spell took effect, the appropriate actions can be
            taken to handle the results. The only spell effect you want to contend with at this
            time is damage. Whenever damage is dealt to a victim, the victim’s resistance ability
            is used to reduce the amount of damage. Resistance is a percentage value, which
            means that a value of 0 does not reduce spell damage, whereas a value of 100 completely
            dispels damage.

            Status ailments also work their way into spell casting. An ailment of Silenced means a
            character can’t even cast magic spells, whereas an ailment of Dumbfounded reduces
            a character’s mental ability by half. Finally, the Enchanted and Barrier ailments
            reduce the victim’s resistance by half or increase the resistance by 50 percent, respectively.

            You can use the following code to determine whether a spell affects the victim and
            just how much damage is dealt:

            // Chance = Magic spell’s chance of working
            // Mental = Spell caster’s mental ability
            // Resistance = victim character’s resistance amount
            // Amount = base damage amount spell causes
            // Apply status ailments to mental and resistance

            if(Ailments & AILMENT_DUMBFOUNDED)
              Mental /= 2;

            if(Ailments & AILMENT_ENCHANTED)
              Resistance = (long)((float)Resistance * 0.5f);

            if(Ailments & AILMENT_BARRIER)
              Resistance = (long)((float)Resistance * 1.5f);

            // Check chance of working and calculate damage
            Chance=(long)(((float)Mental / 100.0f + 1.0f) * (float)Chance);

            if((rand() % 100) < Chance) {
              float Resist = 1.0f - ((float)Resistance / 100.0f);
              long DmgAmount = (long)((float)Amount * Resist);

              // Apply extra class damage or cure-class amounts here
            }

            After a spell has hit its target, the proper amount of damage to apply is calculated.
            Remember that certain classes of spells can cause twice as much damage as the spell
            normally would to a character, whereas other spells can cure half the damage dealt.
             

            Intelligence in Combat

            Although your game’s players are completely capable of controlling their player
            characters, it’s up to you to control the NPCs. In order to make your game worthy,
            the NPCs’ artificial intelligence needs to be up to par for combating. Their actions
            need to mimic yours, from choosing to attack, healing themselves, or casting a spell.

            Characters are given a rudimentary intelligence when it comes to combat. If a character
            has lost over half of his health or is under the effects of a status ailment, that
            character will attempt to heal himself or dispel the ailments. This means it will
            search through its list of known spells (if any) and cast the appropriate spell for aid.

            If, on the other hand, a PC comes into another character’s range, a hostile charac-
            ter then chooses to either perform a physical attack or a magical attack (if any
            spells are known). You need to assign the chances that a character will perform
            either type of attack. Note that attacks are based on the built-up charge of the
            attacking creature—the charge must be full in order for the creature to attack.

            When the decision is made to attack a nearby character, either the attack is performed
            or a magic spell is chosen. Only spells that hurt other characters are cast. If a character
            does not have a viable target character in range, the game randomly decides that
            the character in question will attempt to enhance itself by using a status ailment-causing
            spell, in this way raising its strength, agility, or other beneficial ailment.

            The specifics on performing the preceding actions come into play when you create
            a character controller that will make such decisions for your characters.

            posted on 2007-12-03 21:00 lovedday 閱讀(148) 評(píng)論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            公告

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            隨筆分類(178)

            3D游戲編程相關(guān)鏈接

            搜索

            最新評(píng)論

            伊人丁香狠狠色综合久久| 欧美与黑人午夜性猛交久久久| 久久久久亚洲AV成人片| 久久久久久久久久久久中文字幕| 国产V综合V亚洲欧美久久| 大蕉久久伊人中文字幕| 午夜精品久久久久久久久| 精品精品国产自在久久高清| 一本色综合久久| 国产 亚洲 欧美 另类 久久| 久久亚洲精品无码AV红樱桃| 久久国产高清一区二区三区| 欧美熟妇另类久久久久久不卡| 久久久WWW成人| 99精品国产综合久久久久五月天| 久久r热这里有精品视频| 精品国产乱码久久久久久人妻| 99久久精品国产毛片| 亚洲∧v久久久无码精品| 日韩久久久久中文字幕人妻| 亚洲国产成人久久综合一| 18岁日韩内射颜射午夜久久成人| 怡红院日本一道日本久久 | 久久经典免费视频| 久久er热视频在这里精品| 国产情侣久久久久aⅴ免费| 久久丫忘忧草产品| 久久久久久免费视频| 国产亚洲精午夜久久久久久| 精品久久香蕉国产线看观看亚洲| 欧美va久久久噜噜噜久久| 亚洲国产精品无码久久一线| 国产成人精品三上悠亚久久| 女人高潮久久久叫人喷水| 亚洲美日韩Av中文字幕无码久久久妻妇| 国产精品无码久久综合网| 天天久久狠狠色综合| 大香网伊人久久综合网2020| 国产三级观看久久| 国产精品狼人久久久久影院| 久久久免费观成人影院|