📄 skill.cpp
字号:
for( i = 0 ; i < 3 ; i ++)
for( j = 0 ; j < 3 ; j ++)
for( m = 0 ; m < 8 ; m ++ )
{
tempitem = &ch->inv[i][j][m];
if( tempitem->item_no == item->item_no &&
tempitem->attr[ 0] == item->attr[0] &&
tempitem->attr[ 1] == item->attr[1] &&
tempitem->attr[ 2] == item->attr[2] &&
tempitem->attr[ 3] == item->attr[3] &&
tempitem->attr[ 4] == item->attr[4] &&
tempitem->attr[ 5] == item->attr[5] )
{
// amount ..
return true;
}
}
for( i = 0 ; i < 8 ; i ++)
{
tempitem = &ch->equip[i];
if( tempitem->item_no == item->item_no &&
tempitem->attr[ 0] == item->attr[0] &&
tempitem->attr[ 1] == item->attr[1] &&
tempitem->attr[ 2] == item->attr[2] &&
tempitem->attr[ 3] == item->attr[3] &&
tempitem->attr[ 4] == item->attr[4] &&
tempitem->attr[ 5] == item->attr[5] )
{
// amount ..
return true;
}
}
for( i = 0 ; i < 7 ; i ++)
{
tempitem = &ch->quick[i];
if( tempitem->item_no == item->item_no &&
tempitem->attr[ 0] == item->attr[0] &&
tempitem->attr[ 1] == item->attr[1] &&
tempitem->attr[ 2] == item->attr[2] &&
tempitem->attr[ 3] == item->attr[3] &&
tempitem->attr[ 4] == item->attr[4] &&
tempitem->attr[ 5] == item->attr[5] )
{
// amount ..
return true;
}
}
tempitem = &ch->handheld;
if( tempitem->item_no == item->item_no &&
tempitem->attr[ 0] == item->attr[0] &&
tempitem->attr[ 1] == item->attr[1] &&
tempitem->attr[ 2] == item->attr[2] &&
tempitem->attr[ 3] == item->attr[3] &&
tempitem->attr[ 4] == item->attr[4] &&
tempitem->attr[ 5] == item->attr[5] )
{
// amount ..
return true;
}
return false;
}
bool youvegotitInventory(const int cn, int target_id )
{
CHARLIST *ch = GetCharListPtr(cn);
if( !ch ) return false; // 020620 YGI
int i,j,m;
for( i = 0 ; i < 3 ; i ++)
for( j = 0 ; j < 3 ; j ++)
for( m = 0 ; m < 8 ; m ++ )
if( ch->inv[i][j][m].item_no == target_id )
{
return true;
}
for( i = 0 ; i < 8 ; i ++)
if( ch->equip[i].item_no == target_id )
{
return true;
}
for( i = 0 ; i < 7 ; i ++)
if( ch->quick[i].item_no == target_id )
{
return true;
}
if( ch->handheld.item_no == target_id )
{
return true;
}
return false;
}
CItem_Join *ReturnItemJoinTable(const int cn, int skillno, int target_id )
{
int i;
for( i = 0 ; i < TotalItemJoinTableCount ; i ++)
{
if( item_join[i].item_id == target_id && item_join[i].need_skill1 == skillno )
{
return &item_join[i];
}
}
return NULL;
}
int AddSkillExp2Exp(const int cn, int skillno, int hitrate )
{
int fix;
int inc;
int lev;
CHARLIST *ch;
ch = &connections[ cn].chrlst;
int kind = SkillTbl[skillno].MotherSkillType; // 0527 YGI
lev = ch->skillexp[kind].skillexp / 10000;
if( lev < 1 ) lev = 1;
if( lev > 100 ) lev = 100;
//1010 zhh 版氰摹 抛捞喉俊 辑 佬绢 甸咯辑 贸府茄促.捞固 抛捞喉阑 佬绢 甸捞绊 乐瘤父 老窜 捞吧肺 绊媚敌促. 货肺款 抛捞喉捞扼绊
//积阿等促.
inc = SkillExp[hitrate][lev];
fix = SkillTbl[ skillno].Ability_Fix; // 0 <= fix <= SKILL_ABILITY_FIX_
inc = inc * fix / SKILL_EXP_FIX_;
ch->ChangeUpAddExp(inc); // CSD-TW-030624
isLevelUp(ch);
return 1;
}
//-------------------------------------------------------------------------------------------------------------------------
// 扁瓷 :
// 牢 磊 : 0 <= hitrate <= 100
// 府畔蔼 :
//-------------------------------------------------------------------------------------------------------------------------
int AddSkillExp(const int cn, int skillno, int hitrate )
{
int expadd;
int fix;
bool myjob =false;
switch( connections[ cn].chrlst.Job )
{
case J_FAMER : if( SkillTbl[skillno].Select_Farmer == 1 ) myjob = true; break;
case J_MINNER : if( SkillTbl[skillno].Select_miner == 1 ) myjob = true; break;
case J_FISHER : if( SkillTbl[skillno].Select_fisher == 1 ) myjob = true; break;
case J_LUMBERJACK : if( SkillTbl[skillno].Select_Lumberjack == 1 ) myjob = true; break;
case J_BUTCHER : if( SkillTbl[skillno].Select_Butcher == 1 ) myjob = true; break;
case J_HERB_DIGGER : if( SkillTbl[skillno].Select_Herbdigger == 1 ) myjob = true; break;
case J_HERDSMAN : if( SkillTbl[skillno].Select_herdman == 1 ) myjob = true; break;
case J_CARPENTER : if( SkillTbl[skillno].Select_Carpenter == 1 ) myjob = true; break;
case J_BLACKSMITH : if( SkillTbl[skillno].Select_Blacksmith == 1 ) myjob = true; break;
case J_COOKER : if( SkillTbl[skillno].Select_Cooking == 1 ) myjob = true; break;
case J_TAILOR : if( SkillTbl[skillno].Select_Tailoring == 1 ) myjob = true; break;
case J_BOWCRAFT : if( SkillTbl[skillno].Select_Bowcraft_Fletcher == 1 ) myjob = true; break;
case J_ALCHEMIST : if( SkillTbl[skillno].Select_Alchemy == 1 ) myjob = true; break;
case J_CANDLEMAKER : if( SkillTbl[skillno].Select_Candlemaker == 1 ) myjob = true; break;
case J_MERCHANT : if( SkillTbl[skillno].Select_Merchant == 1 ) myjob = true; break;
}
if( myjob == true ) // 瘤陛 荤侩窍绰 扁贱捞...
{}
fix = SkillTbl[ skillno].Ability_Fix; // 0 <= fix <= SKILL_ABILITY_FIX_
//1010 zhh 胶懦饭骇苞 犬伏俊 蝶扼辑 掘绢瘤绰 版氰摹啊 促福促.
int skilllevel=connections[ cn].chrlst.skillexp[SkillTbl[skillno].MotherSkillType].skillexp/10000;
if(skilllevel<0) skilllevel=0; //救傈厘摹甸
if(skilllevel>100) skilllevel=100; //救傈厘摹甸
if(hitrate<0) hitrate=0; //救傈厘摹甸
if(hitrate>100) hitrate=100; //救傈厘摹甸
expadd = fix * SkillLevelExp[hitrate][skilllevel];
// expadd = fix * ( 1 +(100 - hitrate)*(100 - hitrate) / 30 ); // 0607
//1010 zhh 胶懦饭骇苞 犬伏俊 蝶扼辑 掘绢瘤绰 版氰摹啊 促福促.咯扁鳖瘤
expadd /= SKILL_ABILITY_FIX_;
int inc = SkillTbl[skillno].MotherSkillType; // 0527 YGI
//001214 zhh //酒贰俊 乐带 版氰摹 林绰 风凭阑 困肺 缠绢 棵啡促.胶懦 版氰摹绰 救棵扼档 版氰摹绰 坷弗档废 荐沥.
AddSkillExp2Exp( cn, skillno, hitrate );
if (connections[cn].chrlst.skillexp[inc].skillexp >= MAX_JOB_LEVEL*10000)
{ //< CSD-040223
return 1;
} //> CSD-040223
//001214 zhh //gm老 版快绰 版氰摹甫 憋栏搁 救等促.
//011012 lsw >
if( connections[ cn].chrlst.skillexp[ inc].skillexp > 999999 )
{
}
else
{
connections[ cn].chrlst.skillexp[ inc].skillexp += expadd;
if( connections[ cn].chrlst.skillexp[ inc].skillexp > 999999 )
{
connections[ cn].chrlst.skillexp[ inc].skillexp = 999999;
return 1;
}
}
//011022 lsw >
SkillMgr.SendSkillExp( inc, connections[ cn].chrlst.skillexp[inc], cn);
//011022 lsw <
return 1;
}
/**************************************************************************************************
SkillTbl[skillno].MotherSkillExp : 己傍伏 拌魂 狼 屈怕
(2000.6.3 16:25)
(唱狼 瓷仿(mybase/10000) - 弥家摹(needmin))
己傍伏 = ---------------------------------------------- * k1 + K2
(弥措摹(needmax) - 弥家摹(needmin))
mybase = connections[ cn].chrlst.skillexp[ 45 ]; ( 0 =< n< 1,000,000 )
-->版氰摹肺 拌魂窍绊 Level阑 免仿且锭, / 10000栏肺 茄促.
***************************************************************************************************/
int ReturnTamingPoint(const int cn , int skillno, int target_id, CItem_Join *joinitem = NULL )
{
int tame_add;
int base, mybase;
int needmin, needmax;
int k1,k2;
if( cn >= 10000 ) return 0;
needmin = skillProb_needmin( skillno, target_id, joinitem );
needmax = skillProb_needmax( skillno, target_id, joinitem );
base = needmax - needmin;
if( base < 0 ) return 0; // 俊矾八免风凭..
if( base <= 0 ) base = 1; // min == max牢版快 ?
mybase = connections[ cn].chrlst.skillexp[ SkillTbl[skillno].MotherSkillType].skillexp / 10000 - needmin;
double k = (double)mybase / (double)base;
k1 = skillProb_k1( skillno, joinitem );
k2 = skillProb_k2( skillno, joinitem );
int t = k * k1 + k2;
if( t > 100 ) t = 100;
tame_add= SkillTbl[ skillno].Produce_Fix * t / 10000;
return tame_add;
}
int ReturnSkillProbablityNoExpAdd(const int cn, const int skillno, const int x, const int y, const int targettype, const int target_id, CItem_Join *joinitem = NULL )
{
int hitrate;
int base, mybase;
int needmin, needmax;
int k1,k2;
if( cn >= 10000 ) return 0;
needmin = skillProb_needmin( skillno, target_id, joinitem );
needmax = skillProb_needmax( skillno, target_id, joinitem );
base = needmax - needmin;
if( base < 0 ) return 0;
if( base <= 0 ) base = 1;
mybase = connections[ cn].chrlst.skillexp[ SkillTbl[skillno].MotherSkillType].skillexp / 10000 - needmin;
double k = (double)mybase / (double)base;
if(k>1) k=1;
k1 = skillProb_k1( skillno, joinitem );
k2 = skillProb_k2( skillno, joinitem );
hitrate = (int)(k * k1 + k2);
if( hitrate < 0 ) hitrate = 0;
if( hitrate > 100 ) hitrate = 100;
return hitrate;
}
void SkillTargetTypeItemMake(const int cn, t_client_skill_info *sp)
{
t_packet p;
ItemAttr item = {0,};
CItem_Join join;
CHARLIST *ch= GetCharListPtr(cn);
if( !ch ) return; // 020620 YGI
unsigned int iAttr3 = 0;
int RareType = 0;
int SuccessMuch = 0;//己傍 荐樊
int iTryRare = sp->s.p1;
int iRareGroup = sp->s.p2;
int iTryMakeCount = sp->s.p3;
if( iTryMakeCount > 10 )
{
return;
}
const int skillno = sp->skillno;
const int x = sp->x;
const int y = sp->y;
const int targettype = sp->targettype;
const int target_id = sp->target_id;
const int check = SkillMgr.CheckYouCanSkillIt( cn, join, skillno, x, y, target_id );//鉴辑 林狼.. //咯扁辑 Join阑 函版 矫难霖促
const int hitrate = ReturnSkillProbablityNoExpAdd( cn, skillno, x, y, targettype, target_id, &join );
switch(iTryRare)
{
case 1:
{
iTryMakeCount = 1;//饭绢 矫档甫 窍搁 矫档肮荐绰 1捞 等促
}break;
case 21:
case 31:
case 41:
{
}break;
default://饭绢 矫档啊 酒聪搁 弊缝俊 蔼甸绢客档 瘤况 滚赴促
{
iRareGroup =0;
}break;
}
switch( check )// 扁贱阑 镜荐 乐绰 惑炔牢瘤甫 眉农茄促.
{
case ITEMMAKE_YOUCAN:{break;}//唱绰 捞 酒捞袍阑 父甸 荐 乐促!
default://父甸 荐 绝促
{
SendSkillResultFail( cn, skillno, check );
return;
}
break;
}
// DecreaseEquipDuration(ch,(rand()%6+1)*iTryMakeCount,WT_WEAPON,0,false);//胶懦砒 郴备仿 皑家 //矫档冉荐 父怒
//矫埃 眉农 1俺寸 1.5 檬 掉饭捞甫 冈绰促
if( global_time < ch->dwSkillMakeitemTime ) {return;}
else{ ch->dwSkillMakeitemTime = global_time+iTryMakeCount*1500;}
for(int count = 0 ; count < iTryMakeCount ; count++)
{
int r = (rand()%100)+1; // 己傍犬伏阑 拌魂茄促.
if( r < hitrate ) { SuccessMuch++; }//己傍茄 肮荐 备茄促
}
int amount[4] ={ join.resource1_amount,join.resource2_amount,join.resource3_amount,join.resource4_amount };
int resource[4] ={ join.resource1,join.resource2,join.resource3,join.resource4 };
int resultresource[2] ={ join.Result_resource1, join.Result_resource2 };
// ItemJoin抛捞喉俊 乐绰 搬苞蔼措肺 贸府
for ( int cou = 0 ; cou < iTryMakeCount; cou++ ) //府家胶 瘤况林绊 捍 鞍篮芭 冻迸 林扁
{//府家胶绰 矫档茄 冉荐父怒 瘤款促
HungryMuchAdd( ch , HT_SKILL );//020214 lsw
int roll = 0;
for(; roll < 4; roll++)
{
for( int i = 0 ; i < amount[roll] ; i ++)
{
if (!DeleteMakeItemResource(ch, resource[roll]))
{
SendSkillResultFail( cn, skillno, ITEMMAKE_NOT_RESOURCE);
return;
}
else//1 2 父 乐绰单
{
if( 0 < roll && 2 > roll ) //炼牢 1 2 父 搬苞 府家胶啊 粮犁
{
if( resultresource[roll])
{
item = GenerateItem( resultresource[roll] );
DropItem( ch->X + (rand()%40) - 40, ch->Y + (rand()%40) - 40, &item);
}
}
}
}
}
AddSkillExp( cn, skillno, hitrate );//版氰摹 咯矾锅 林扁
}
//钙胶 锭巩俊 给父甸搁 酒捞袍 救 荤扼瘤绊,
RareType = TryRareItem(cn,skillno,join,iTryRare,iRareGroup,iTryMakeCount,SuccessMuch);//饭绢 鸥涝 罐酒坷扁
if( !SuccessMuch )//角菩 皋技瘤
{
RareType = 0;
SendSkillResultFail( cn, skillno );
if(iTryRare)
{
OutMessage(cn,2,259);//酒捞袍捞 角菩窍咯 父甸荐 绝澜
return;
}
else
{
OutMessage(cn,2,260);//酒捞袍捞 角菩窍咯 父甸荐 绝澜
}
}
if(iTryRare && RareType && SuccessMuch)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -