• <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(37)

            Whenever a character needs updating, rendering, or what have you, a pointer to
            the linked list of characters is needed in order to iterate the list. Either that or
            maybe your application needs access to the character data. Either way, the following
            functions will help you out:

                sCharacter* get_root_char()
                {
                    
            return m_root_char;
                }

                sCharacter* get_char(
            long id)
                {
                    
            for(sCharacter* character = m_root_char; character != NULL; character = character->next)
                    {
                        
            if(id == character->id)
                            
            return character;
                    }

                    
            return NULL;
                }

            During specific functions, it becomes necessary for characters (such as monsters)
            to make sure that they can see another character before attacking or casting a spell.
            A function of your design is required to verify that such a line of sight is clear.
            Returning a value of true states that a character is in sight of another one:


                virtual bool line_of_sight(sCharacter* source, sCharacter* target,
                                           
            float source_x, float source_y, float source_z,
                                           
            float target_x, float target_y, float target_z)
                {
                    
            // make sure there is a line of sight between characters.

                    
            return true;
                }

            When the character controller (or outside code) needs one of the character’s abilities,
            it needs to retrieve it with the following group of functions. These functions
            take into account the various modifiers such as status ailments and equipped items:


                long get_to_hit(const sCharacter* character)
                {
                    
            if(character == NULL)
                        
            return 0;

                    
            long to_hit = character->char_def.to_hit;

                    
            if(character->ailments & AILMENT_BLIND)
                        to_hit *= 0.75f;

                    
            if(character->ailments & AILMENT_HAWKEYE)
                        to_hit *= 1.5f;

                    
            return to_hit;
                }

                
            long get_agility(const sCharacter* character)
                {
                    
            if(character == NULL)
                        
            return 0;

                    
            long agility = character->char_def.agility;

                    
            if(character->ailments & AILMENT_CLUMSY)
                        agility *= 0.75f;

                    
            if(character->ailments & AILMENT_SUREFOOTED)
                        agility *= 1.5f;

                    
            return agility;
                }

                
            long get_attack(const sCharacter* character)
                {
                    
            if(character == NULL)
                        
            return 0;

                    
            long attack = character->char_def.attack;

                    
            // adjust attack based on item value
                    if(character->char_def.weapon != -1 && m_mil)
                        attack *= (m_mil[character->char_def.weapon].value / 100.0f + 1.0f);

                    
            if(character->ailments & AILMENT_WEAK)
                        attack *= 0.5f;

                    
            if(character->ailments & AILMENT_STRONG)
                        attack *= 1.5f;

                    
            return attack;
                }
                
                
            long get_defense(const sCharacter* character)
                {
                    
            if(character == NULL)
                        
            return 0;

                    
            long defense = character->char_def.defense;

                    
            if(character->char_def.armor != -1 && m_mil)
                        defense *= (m_mil[character->char_def.armor].value / 100.0f + 1.0f);

                    
            if(character->char_def.shield != -1 && m_mil)
                        defense *= (m_mil[character->char_def.shield].value / 100.0f + 1.0f);

                    
            if(character->ailments & AILMENT_WEAK)
                        defense *= 0.5f;

                    
            if(character->ailments & AILMENT_STRONG)
                        defense *= 1.5f;

                    
            if(defense < 0)     // boudns check
                        defense = 0;

                    
            return defense;
                }

                
            long get_resistance(const sCharacter* character)
                {
                    
            if(character == NULL)
                        
            return 0;

                    
            long resistance = character->char_def.resistance;

                    
            if(character->ailments & AILMENT_ENCHANTED)
                        resistance *= 0.5f;

                    
            if(character->ailments & AILMENT_BARRIER)
                        resistance *= 1.5f;

                    
            return resistance;
                }

                
            long get_mental(const sCharacter* character)
                {
                    
            if(character == NULL)
                        
            return 0;

                    
            long mental = character->char_def.mental;

                    
            if(character->ailments & AILMENT_DUMBFOUNDED)
                        mental *= 0.5f;

                    
            return mental;
                }

                
            float get_speed(const sCharacter* character)
                {
                    
            if(character == NULL)
                        
            return 0.0f;

                    
            float speed = character->char_def.speed;

                    
            if(character->ailments & AILMENT_SLOW)
                        speed *= 0.5f;

                    
            if(character->ailments & AILMENT_FAST)
                        speed *= 1.5f;

                    
            if(speed < 1.0f)    // bounds check
                        speed = 1.0f;

                    
            return speed;
                }

                
            float get_charge_rate(const sCharacter* character)
                {
                    
            if(character == NULL)
                        
            return 0;

                    
            float charge_rate = character->char_def.charge_rate;

                    
            if(character->ailments & AILMENT_SLOW)
                        charge_rate *= 0.75f;

                    
            if(character->ailments & AILMENT_FAST)
                        charge_rate *= 1.5f;

                    
            return charge_rate;
                }

            posted on 2007-12-04 19:05 lovedday 閱讀(245) 評論(0)  編輯 收藏 引用

            公告

            導航

            統(tǒng)計

            常用鏈接

            隨筆分類(178)

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

            搜索

            最新評論

            久久av免费天堂小草播放| 国产精品久久婷婷六月丁香| 2021少妇久久久久久久久久| 2020久久精品国产免费| 91久久福利国产成人精品| 亚洲国产日韩欧美久久| 狠狠色狠狠色综合久久| 久久久久久久尹人综合网亚洲| 人妻少妇精品久久| 亚洲AV无码久久精品成人 | 欧美日韩成人精品久久久免费看 | 中文字幕精品久久| 91精品国产高清91久久久久久| 国内精品久久久久久中文字幕| 久久久久久亚洲精品影院| 精品国产一区二区三区久久| 亚洲日韩欧美一区久久久久我| 久久精品无码专区免费青青| 亚洲国产综合久久天堂| 久久国产精品久久久| 久久亚洲AV无码精品色午夜麻豆| 久久精品一区二区| 久久久久99精品成人片欧美| 国产精品久久久久久五月尺| 国产亚洲色婷婷久久99精品91| 久久A级毛片免费观看| 久久久久久久久波多野高潮| 免费一级欧美大片久久网| 一本久久a久久精品综合夜夜| 色婷婷综合久久久久中文一区二区| 三级韩国一区久久二区综合| 成人a毛片久久免费播放| 久久精品国产一区二区三区日韩| 国产精品青草久久久久婷婷| 欧美亚洲色综久久精品国产| 久久青青草视频| 久久久久亚洲AV片无码下载蜜桃| 久久久久久久久久久免费精品| 久久青青草原国产精品免费 | 久久99精品国产自在现线小黄鸭 | 久久久久亚洲AV成人网|