📄 battle_magic.c
字号:
pethurt = 20 + BATTLE_CalAttMagicEffect( AttEle , petattr[( AttEle + 1 ) %4] , petattr[AttEle] ); charahurt = 10 * charahurt / ( charahurt + pethurt ); if( charahurt < 2 ) return 2; else if( charahurt > 8 ) return 8; return charahurt;}static int BATTLE_AttrCalc( int My_Fire, // 愤坌础(膜恳熬仃月幻丹) int My_Water, int My_Earth, int My_Wind, int My_None, int Vs_Fire, // 锹澎础 int Vs_Water, int Vs_Earth, int Vs_Wind, int Vs_None){ int iRet = 0; // 绍及 猾 宁煌允月[ My_Fire = My_Fire * Vs_None * AJ_UP // 绍 雄中 + My_Fire * Vs_Fire * AJ_SAME // 绍 绍 元 + My_Fire * Vs_Water * AJ_DOWN // 绍 浇中 + My_Fire * Vs_Earth * AJ_SAME // 绍 萝 元 + My_Fire * Vs_Wind * AJ_UP; // 绍 氘 雄中 // 及 猾 宁煌允月[ My_Water = My_Water * Vs_None * AJ_UP // 雄中 + My_Water * Vs_Fire * AJ_UP // 绍 雄中 + My_Water * Vs_Water * AJ_SAME // 元 + My_Water * Vs_Earth * AJ_DOWN // 萝 浇中 + My_Water * Vs_Wind * AJ_SAME; // 氘 元 // 萝 My_Earth = My_Earth * Vs_None * AJ_UP // 萝 雄中 + My_Earth * Vs_Fire * AJ_SAME // 萝 绍 元 + My_Earth * Vs_Water * AJ_UP // 萝 雄中 + My_Earth * Vs_Earth * AJ_SAME // 萝 萝 元 + My_Earth * Vs_Wind * AJ_DOWN; // 萝 氘 浇中 // 氘 My_Wind = My_Wind * Vs_None * AJ_UP // 氘 雄中 + My_Wind * Vs_Fire * AJ_DOWN // 氘 绍 浇中 + My_Wind * Vs_Water * AJ_SAME // 氘 元 + My_Wind * Vs_Earth * AJ_UP // 氘 萝 雄中 + My_Wind * Vs_Wind * AJ_SAME; // 氘 氘 元 // 箪岭 My_None = My_None * Vs_None * AJ_SAME // 元 + My_None * Vs_Fire * AJ_DOWN // 绍 浇中 + My_None * Vs_Water * AJ_DOWN // 浇中 + My_None * Vs_Earth * AJ_DOWN // 萝 浇中 + My_None * Vs_Wind * AJ_DOWN; // 氘 浇中 // 蝈 宁煌允月 iRet = (My_Fire + My_Water + My_Earth + My_Wind + My_None) ; // 喘仃遥壬匀井曰匹 五仁卅匀凶及匹公及坌尺日允 return (iRet * D_ATTR);}extern float BATTLE_FieldAttAdjust(int battleindex,int pAt_Fire,int pAt_Water,int pAt_Earth,int pAt_Wind);#ifndef _FIX_MAGICDAMAGEstatic int BATTLE_AttrAdjust( int attackindex, int defindex, int damage){ int At_Fire, At_Earth, At_Water, At_Wind, At_none; int Df_Fire, Df_Earth, Df_Water, Df_Wind, Df_none; float At_FieldPow, Df_FieldPow; BATTLE_GetAttr(attackindex,&At_Fire,&At_Water,&At_Earth,&At_Wind,&At_none); At_FieldPow = BATTLE_FieldAttAdjust( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ), At_Fire, At_Water, At_Earth, At_Wind ); At_Fire *= damage; At_Water *= damage; At_Earth *= damage; At_Wind *= damage; At_none *= damage; BATTLE_GetAttr( defindex, &Df_Fire, &Df_Water, &Df_Earth,&Df_Wind, &Df_none ); Df_FieldPow = BATTLE_FieldAttAdjust( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ), Df_Fire, Df_Water, Df_Earth, Df_Wind ); damage = BATTLE_AttrCalc( At_Fire, At_Water, At_Earth, At_Wind, At_none, Df_Fire, Df_Water, Df_Earth, Df_Wind, Df_none ); damage *= (At_FieldPow / Df_FieldPow); return damage;}#endif// 计算闪避率// return: 0:没闪过 1:闪过int BATTLE_MagicDodge(int charindex,int nDefKind,int nFieldAttr){ float fLuck = 0,fResist = 0;#ifdef _EQUIT_DEFMAGIC float Dluck=0.0;#endif int charType = CHAR_getInt( charindex, CHAR_WHICHTYPE); // 如果是防守者是玩家 if( charType == CHAR_TYPEPLAYER ){ fLuck = (float)CHAR_getInt( charindex, CHAR_LUCK) * 3; fResist = (float)CHAR_getInt( charindex, CHAR_EARTH_RESIST + nFieldAttr) * 0.15; fLuck += fResist;#ifdef _EQUIT_DEFMAGIC Dluck = (float)(CHAR_getWorkInt( charindex, CHAR_EQUITQUIMAGIC)*0.9); fLuck += Dluck;#endif }else {// 如果是防守者是宠物 fLuck = (float)CHAR_getInt( charindex, CHAR_LV) * 0.2; if(fLuck > 30) fLuck = 30; } if(rand()%100+1 > (int)fLuck) return 0; else return 1;}#define DEF_MAGIC_NUM 4extern void BATTLE_changeRideImage( int index );#ifdef _FIX_MAGICDAMAGEvoid BATTLE_MultiAttMagic( int battleindex, int attackNo, int toNo, int attIdx ,int FieldAttr ,int Power, int MagicLv)#elsevoid BATTLE_MultiAttMagic( int battleindex, int attackNo, int toNo , int attIdx, int FieldAttr , int Power)#endif{ int list[SIDE_OFFSET * 2 + 1]; int listidx,i,j,k,z; int basex , basey , magicattidx,def_is_player[10],def_be_hit[10]; int att_magic_lv[4]; int def_magic_resist[DEF_MAGIC_NUM]; int attvalue , charahp , pethp , charaidx , petidx , charahurt,pet_att_lv = 1,pet_def_lv = 1,charahurt_temp; char szcommand[256]; int AttIsPlayer=0,DefIsPlayer=0; int getexp = 0;#ifndef _FIX_MAGICDAMAGE int att_magic_exp_add,att_magic_exp_sub,def_magic_exp_add,def_magic_exp_sub; int lv_up_exp,DefFieldAttr = 0; float temp = 0.0f;// int attattr[5], defattr[5]; char msgbuf[64]; char kind[4][3] = {"地","水","火","风"};#else BOOL TrueMagic=FALSE;#endif // terry if((z = BATTLE_MultiList(battleindex,toNo,list)) == -1) return; else { if(z != toNo) toNo = z; } BATTLE_AttMagicEffect( battleindex , attackNo , list , attIdx ); // 计算攻击的人物清单 if( attackNo < 10 ) magicattidx = attIdx * 2 + 1; else magicattidx = attIdx * 2; listidx = 0; memset(def_is_player,-1,sizeof(def_is_player)); memset(def_be_hit,-1,sizeof(def_be_hit)); // 单人攻击 if( toNo < 20 ){ toNo = list[0]; basex = CharTableIdx[toNo][1]; basey = CharTableIdx[toNo][0]; for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ if( toNo < 10 && ( j < 2 || j > 3 ) ) continue; else if( toNo >= 10 && ( j < 0 || j > 1 ) ) continue; // 计算那些人需要加入清单 for( k = 0 ; k < 5 ; k++ ){ if( basex - 2 + k < 0 || basex - 2 + k > 4 ) continue; if( ATTMAGIC_magic[magicattidx].siField[i][k] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][basex - 2 + k] ) ) { list[listidx] = CharTable[j][basex - 2 + k]; listidx++; } } } }else if( 20 == toNo ){ // 右下全体 for( i = 0 ; i < 2 ; i++ ){ for( j = 0 ; j < 5 ; j++ ){ if( ATTMAGIC_magic[magicattidx].siField[i][j] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[i + 2][j] ) ){ list[listidx] = CharTable[i + 2][j]; listidx++; } } } }else if( 21 == toNo ){ // 左上全体 for( i = 0 ; i < 2 ; i++ ){ for( j = 0 ; j < 5 ; j++ ){ if( ATTMAGIC_magic[magicattidx].siField[i][j] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[i][j] ) ){ list[listidx] = CharTable[i][j]; listidx++; } } } } // 左上第一列 , 左上第二列 , 右下第一列 , 右下第二列 else if( 23 == toNo || 24 == toNo || 25 == toNo || 26 == toNo ){ basey = toNo - 23; for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ if( ( 25 == toNo || 26 == toNo ) && ( j < 2 || j > 3 ) ) continue; else if( ( 23 == toNo || 24 == toNo ) && ( j < 0 || j > 1 ) ) continue; // 计算那些人需要加入清单 for( k = 0 ; k < 5 ; k++ ){ if( ATTMAGIC_magic[magicattidx].siField[i][k] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][k] ) ) { list[listidx] = CharTable[j][k]; listidx++; } } } } qsort( list , listidx , sizeof( list[0] ) , ( FUNC )SortLoc );// 排序位置 // 取得人物的属性(不论玩家或是宠物) //BATTLE_GetAttr( BATTLE_No2Index( battleindex , attackNo ) , &attattr[2] , &attattr[1] , &attattr[0] , &attattr[3] , &attattr[4] ); // 如果攻击者是玩家,取得人物的魔法熟练度及魔法抗性 { int attType = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_WHICHTYPE); int Check=0; AttIsPlayer=0; if( attType == CHAR_TYPEPLAYER) { AttIsPlayer = 1; for(i=0;i<4;i++){ // att_magic_lv[i]: i = 0:地 1:水 2:火 3:风 att_magic_lv[i] = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+i); } }else if( attType == CHAR_TYPEENEMY ) { for(i=0;i<4;i++){ att_magic_lv[i] = (CHAR_getInt(BATTLE_No2Index(battleindex,attackNo), CHAR_LV)*0.9); } }else {#ifdef _FIX_MAGICDAMAGE AttIsPlayer = 1;#endif for(i=0;i<4;i++){#ifdef _FIX_MAGICDAMAGE att_magic_lv[i] = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+i);#else att_magic_lv[i] = 0;#endif } } Check = rand()%100;#ifdef _FIX_MAGICDAMAGE if( Check > att_magic_lv[ FieldAttr] ) TrueMagic = FALSE; else TrueMagic = TRUE;#endif } pet_att_lv = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo), CHAR_LV); z = 0; for(i=0;i<listidx;i++){ charaidx = BATTLE_No2Index( battleindex , list[i] ); petidx = BATTLE_getRidePet( charaidx ); //BATTLE_GetAttr( charaidx , &defattr[2] , &defattr[1] , &defattr[0] , &defattr[3] , &defattr[4] ); {//andy_fix int defType = CHAR_getInt(charaidx,CHAR_WHICHTYPE); DefIsPlayer = 0; if( defType == CHAR_TYPEPLAYER) { DefIsPlayer = 1; for(j=0;j<DEF_MAGIC_NUM;j++){ // def_magic_resist[i]: i = 0:地 1:水 2:火 3:风 def_magic_resist[j] = CHAR_getInt(charaidx,CHAR_EARTH_RESIST+j);#ifdef _EQUIT_DEFMAGIC def_magic_resist[j] += CHAR_getWorkInt( charaidx, CHAR_EQUITDEFMAGIC_E+j);#endif } }else if( defType == CHAR_TYPEENEMY ) { for(j=0;j<DEF_MAGIC_NUM;j++){ def_magic_resist[j] = (CHAR_getInt(charaidx,CHAR_LV)*0.5); } }else { //PET#ifdef _FIX_MAGICDAMAGE DefIsPlayer = 1;#endif for(j=0;j<DEF_MAGIC_NUM;j++){#ifdef _FIX_MAGICDAMAGE def_magic_resist[j] = CHAR_getInt(charaidx,CHAR_EARTH_RESIST+j); //def_magic_resist[j] += CHAR_getWorkInt( charaidx, CHAR_EQUITDEFMAGIC_E+j);#else def_magic_resist[j] = 0;#endif } }#ifdef _MAGIC_DEFMAGICATT if( CHAR_getWorkInt( charaidx, CHAR_DEFMAGICSTATUS ) > 0 ){ float def = (float)(CHAR_getWorkInt( charaidx, CHAR_OTHERSTATUSNUMS )); def = def/100; for(j=0;j<DEF_MAGIC_NUM;j++){ if( def_magic_resist[j] <= 0 ) continue; def_magic_resist[j] += def_magic_resist[j] * def; } }#endif } pet_def_lv = CHAR_getInt(charaidx,CHAR_LV); if(BATTLE_MagicDodge(charaidx,DefIsPlayer,FieldAttr)){ // 计算闪避率 attvalue = pethp = 0; if( 0 == ATTMAGIC_magic[magicattidx].uiAttackType ) {// 单人攻击 sprintf( szcommand , "%X|%X|%X|%X|" , toNo , list[i] , attvalue , pethp ); }else{ // 多人攻击 sprintf( szcommand , "%X|%X|%X|%X|" , list[i] , list[i] , attvalue, pethp ); } BATTLESTR_ADD( szcommand ); continue; }else{ // 没闪过,计算攻击力#ifdef _FIX_MAGICDAMAGE float Kmagic = ((float)att_magic_lv[FieldAttr]*1.4 - (float)def_magic_resist[FieldAttr]); float Mmagic = (float)att_magic_lv[FieldAttr]; float Amagic=0.00; int APower=0; if( Kmagic < 0 ) Kmagic = 0; if( Mmagic < 1 ) Mmagic = 1; Amagic = (Kmagic*Kmagic) / (Mmagic*Mmagic); Amagic += ((float)(rand()%20))/100; APower = (int)(Power*(1+(float)MagicLv/10) * Amagic); //MagicLv //andy_log //print("\natt_magic_lv:%d", att_magic_lv[FieldAttr]); //print( "Player:%s\n", CHAR_getUseName( charaidx)); //print( "ANDY Magic Power:%d Amagic:%f APower:%d \n", Power, Amagic, APower); def_be_hit[getexp++] = charaidx; // 记下被打的人的index attvalue = BATTLE_getMagicAdjustInt( BATTLE_No2Index(battleindex,attackNo), charaidx, MagicLv, FieldAttr, APower); //andy_log// print("attvalue:%d \n", attvalue); if( TrueMagic == FALSE ) {//使用失败 attvalue*=0.7; } if( DefIsPlayer ) { Magic_ComputeDefExp( charaidx, FieldAttr, MagicLv, attvalue); }#else def_be_hit[getexp++] = charaidx; // 记下被打的人的index // 计算属性相克 attvalue = BATTLE_AttrAdjust(BATTLE_No2Index(battleindex,attackNo),charaidx,Power); if(DefIsPlayer){ // 被打的是玩家 def_is_player[z++] = list[i]; if(AttIsPlayer){ // 如果是玩家用魔法攻击 temp = ((float)att_magic_lv[FieldAttr] - (float)def_magic_resist[FieldAttr])/(float)def_magic_resist[FieldAttr] / 100; attvalue = Power + Power * temp + attvalue; }else{ temp = ((float)pet_att_lv - (float)def_magic_resist[FieldAttr]) / (float)def_magic_resist[FieldAttr] / 100; attvalue = Power + Power * temp + attvalue; } }else{// 被打的是宠物 if(AttIsPlayer){// 如果是玩家用魔法攻击 temp = ((float)att_magic_lv[FieldAttr] - (float)pet_def_lv) / (float)pet_def_lv / 100; attvalue = Power + Power * temp + attvalue;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -