背景:
阅读文章

combatd中skill_power的溢出及解决办法

[日期:2010-05-01] 来源:  作者:52mudWIZ [字体: ]

方法
#define APPLY_ATTACK_LIMIT 400
#define FIGHT_ATTACK_LIMIT 200
#define APPLY_DODGE_LIMIT 30
#define FIGHT_DODGE_LIMIT 200
#define APPLY_PARRY_LIMIT 30
#define FIGHT_PARRY_LIMIT 200


#define APPLY_DEFENSE_LIMIT 200

        varargs int skill_power(object ob, string skill, int usage)
        {
                int status, level, power, a_d_ratio,a_d_ratio_set, gin_ratio,sen_ratio;
                int eff_level,afford,tmp;
                string map_skill;

                if( !living(ob) )
                        return 0;

                a_d_ratio = 0;
                a_d_ratio_set = 0;
                if( objectp(ob) )
                {
                        if( intp(ob->query("env/attack")) )
                                a_d_ratio = (int)ob->query("env/attack");
                        else
                                a_d_ratio = 50;
                }

                if( a_d_ratio == 0)
                        a_d_ratio = 50;
                else if( a_d_ratio > 100)
                        a_d_ratio = 100;
                else if( a_d_ratio < 0)
                        a_d_ratio = 1;

                if( a_d_ratio != a_d_ratio_set )
                        ob->set("env/attack",a_d_ratio);

                // if enable parry as weapon but no weapon  then set no_parry skill
                if( skill == "no_parry")
                        level = ob->query_skill("parry",1)/2;
                else
                        level = ob->query_skill(skill);

                switch(usage) {
                                case SKILL_USAGE_ATTACK:
                                        tmp=ob->query_temp("apply/attack");
                                        if(tmp>APPLY_ATTACK_LIMIT) tmp=APPLY_ATTACK_LIMIT;
                                        level += tmp;

                                        // for action["attack"] cmy
                                        //                      CHANNEL_D->do_channel(ob,"sys",sprintf("origin:%d,add %d " , level,ob->query_temp("fighting/attack")));
                                        tmp=ob->query_temp("fighting/attack");
                                        if(tmp>FIGHT_ATTACK_LIMIT) tmp=FIGHT_ATTACK_LIMIT;
                                        level = level * (100 + tmp) / 100;

                                        //                      CHANNEL_D->do_channel(ob,"sys",skill+ sprintf(" after:%d " , level));

                                        break;
                                case SKILL_USAGE_DEFENSE:
                                        tmp=ob->query_temp("apply/defense");
                                        if(tmp>APPLY_DEFENSE_LIMIT) tmp=APPLY_DEFENSE_LIMIT;
                                        level += tmp;

                                        // for action["dodge"] cmy
                                        if (ob->is_fighting()) {
                                                //                      CHANNEL_D->do_channel(ob,"sys",sprintf("%s origin:%d,add %d ", skill,level,ob->query_temp("fighting/"+skill)));
                                                if( skill == "dodge") {
                                                        tmp = ob->query_temp("apply/dodge");
                                                        if( tmp > APPLY_DODGE_LIMIT ) tmp = APPLY_DODGE_LIMIT;
                                                        level += tmp;
                                                        if( stringp(map_skill= (ob->query_skill_mapped(skill))) && ( eff_level = SKILL_D(map_skill)->effective_level()) > 0)
                                                                level = level * eff_level / 10;      
                                                        //                      CHANNEL_D->do_channel(ob,"sys", sprintf(" dodge eff_level:%d " , eff_level));
                                                        tmp=ob->query_temp("fighting/dodge");
                                                        if(tmp>FIGHT_DODGE_LIMIT) tmp=FIGHT_DODGE_LIMIT;
                                                        level = level * (100 + tmp) / 100;
                                                }
                                                else /*if( skill == "parry")*/
                                                {
                                                        tmp = ob->query_temp("apply/parry");
                                                        if( tmp > APPLY_PARRY_LIMIT) tmp = APPLY_PARRY_LIMIT;
                                                        level += tmp;
                                                        if( stringp(map_skill= (ob->query_skill_mapped(skill))) && ( eff_level = SKILL_D(map_skill)->effective_level()) > 0)
                                                                level = level * eff_level / 10;      

                                                        tmp=ob->query_temp("fighting/parry");
                                                        if(tmp>FIGHT_PARRY_LIMIT) tmp=FIGHT_PARRY_LIMIT;
                                                        level = level * (100 + tmp) / 100;
                                                }
                                                //                      CHANNEL_D->do_channel(ob,"sys",skill+ sprintf(" after:%d " , level));
                                        }

                                        break;
                }

                if( !level ) return (int)ob->query("combat_exp") / 2;

                /********************changed by meteoric*******************/
                if(level>3000) level=3000; //防止溢出
                power = (level*level/25)*(level/6);

                //if set attack 100,then ap*=2 and dp = 0
                //if set attack 0,then ap = 0 and dp*=2

                power = power + ob->query("combat_exp")/25;
                /***************************end**************************/

                gin_ratio = 100;
                sen_ratio = 100;
                //神影响攻击,精影响防御
                if( (status = ob->query("max_sen")) > 0 && power > 1000 ) sen_ratio = 100 * ob->query("sen") / status;
                if( (status = ob->query("max_gin")) > 0 && power > 1000 ) gin_ratio = 100 * ob->query("gin") / status;

                if(gin_ratio < 50 )   gin_ratio = 50;
                if(sen_ratio < 50 )     sen_ratio = 50;

                //允许部分超常发挥的情况       
                if(gin_ratio > 120 )    gin_ratio = 120;
                if(sen_ratio > 120 )    sen_ratio = 120;


                if( usage == SKILL_USAGE_ATTACK)       power = power*a_d_ratio/100*sen_ratio;
                else if( usage == SKILL_USAGE_DEFENSE) power = power*(100-a_d_ratio)/100*gin_ratio;

                afford = (int)ob->query_encumbrance() * 100 / (int)ob->query_max_encumbrance();
                //负重(>10%)影响攻击与躲闪
                if( afford > 10 && (skill == "dodge" || usage == SKILL_USAGE_ATTACK) ) power -= power/100*afford;

                if( power < 100 ) power = 100;

                return power;         
        } 

收藏 推荐 打印 | 录入:sbso | 阅读:
相关内容       巫师  wiz 
本文评论   [发表评论]   全部评论 (0)
内容推送
52mud提供
一起回忆泥巴游戏QQ群68186072
52mud官方微信公众平台
热门评论