📄 skillmgr.cpp
字号:
// SkillMgr.cpp: implementation of the CSkillMgr class.
//
//////////////////////////////////////////////////////////////////////
#include "../stdafx.h"
#include "CItem.h"
#include "SkillMgr.h"
extern int PRAY_RECOVER_DIVINE_TIME; // 030520 kyo
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSkillMgr SkillMgr;
LEARNITEMCONVERT LIC[MAX_LEARN_ITEM_CONVERT];
t_RareItemBag RareItemBag[MAX_RAREITEMBAG];
t_BasicItemBag BasicItemBag[MAX_BASICITEMBAG];
t_ItemControlPercent ItemControlPercent[MAX_ITEMCONTROLPERCENT];
t_ItemFallPercent ItemFallPercent[MAX_ITEMFALLPERCENT];
t_ItemControl ItemControl[MAX_ITEMCONTROL];
CSkillMgr::CSkillMgr()
{
}
CSkillMgr::~CSkillMgr()
{
}
void CSkillMgr::AutoSetCanView(CHARLIST *ch)
{
if(ch->bCanViewGhost)
{
if(ch->dwCanViewGhostTime <= global_time)
{//杭 荐 绝霸 登菌阑锭 努扼捞攫飘俊霸 舅妨 拎具 茄促
if(RareEM.GetStaticRareGhost(ch->StaticRare))//杭荐 绝瘤父 饭绢锭巩俊 夯促
{
SetCanViewGhost(ch,STATIC_RARE_VIEW_FORCE_TIME);//郴何 俊辑 bCanViewGhost甫 true肺
}
else
{
SetCanViewGhost(ch,0);//郴何 俊辑 bCanViewGhost甫 false肺
}
}
}
if(ch->bCanViewBomb)
{
if(ch->dwCanViewBombTime <= global_time)
{//杭 荐 绝霸 登菌阑锭 努扼捞攫飘俊霸 舅妨 拎具 茄促
if(RareEM.GetStaticRareLandmine(ch->StaticRare))
{
SkillMgr.SetCanViewBomb(ch,STATIC_RARE_VIEW_FORCE_TIME);//020510 lsw
}
else
{
SkillMgr.SetCanViewBomb(ch,0);//020510 lsw
}
}
}
if(ch->bCanViewTrap)
{
if(ch->dwCanViewTrapTime <= global_time)
{//杭 荐 绝霸 登菌阑锭 努扼捞攫飘俊霸 舅妨 拎具 茄促
if(RareEM.GetStaticRareTraping(ch->StaticRare))
{
ch->bCanViewTrap = true;
ch->SendCharInfoBasic( VIEWTRAP, STATIC_RARE_VIEW_FORCE_TIME);//020704 lsw
}
else
{
ch->bCanViewTrap = false;
ch->SendCharInfoBasic( VIEWTRAP, 0);//020704 lsw
}
}
}
return;
}
bool CSkillMgr::IsRecoverAble(const int iNow,const int iMax)const//泅犁 蔼苞 弥措樊阑 厚背秦辑 弥措樊捞 泅犁焊促 腹栏搁 啊瓷窍促甫 府畔茄促
{
if(iNow < iMax)
{
return true;
}
return false;
}
// HP 磊悼雀汗
void CSkillMgr::AutoRecoverHp(CHARLIST *ch)
{
if( ch->bAlive != ALIVE_ )
{
ch->Hp = 0;
return;
}
const int cn = ch->GetServerID();
if( global_time >= ch->dwHpRecoverTime )//矫埃 眉农
{
int iCombatRecoverHp = 0;
int iCombatRecoverHpRate = 0;
int iCombatRecoverHpMax = 0;
int iCombatRecoverTime = 0;
const int nPassive = ch->GetPassiveCombat();
switch (nPassive)
{
case SIMUNIAN_BOSOM:
{
iCombatRecoverHp = ch->GetCombatValue(nPassive);
iCombatRecoverHpMax = 50;
iCombatRecoverTime = ch->GetCombatLevel(nPassive)*5000;
break;
}
}
//DEFAULT_RECOVER_HP_TIME 捞巴狼 欺季抛捞瘤 炼例 窍搁 歹 狐弗 雀汗 等促
ch->dwHpRecoverTime = global_time + DEFAULT_RECOVER_HP_TIME - iCombatRecoverTime;
const int iRecoverHp = ch->HpMax*(HP_RECOVER_RATE+RareEM.GetStaticRareFatal(ch->StaticRare)+iCombatRecoverHpRate)/100 + iCombatRecoverHp;//茄锅俊 5% 雀汗 矫难霖促//捞锅俊 雀汗 瞪 蔼
const int iRecoverHpMaxPercent = (DEFAULT_RECOVER_HP_MAX_PERCENT+ iCombatRecoverHpMax/*+RareEM.GetStaticRareLife_recovery(ch->StaticRare)*/);//弥措 雀汗 欺季抛捞瘤
const int iRecoverHpMax = ch->HpMax * iRecoverHpMaxPercent/100;
if(IsRecoverAble(ch->Hp,iRecoverHpMax ))
{
if(ch->IncLife(iRecoverHp,iRecoverHpMaxPercent))//函拳樊捞 乐促搁
{
ch->SendCharInfoBasic( HP, ch->Hp );//020704 lsw
}
}
}
return;
}
void CSkillMgr::AutoRecoverMp(CHARLIST *ch)
{//021026 lsw
if( ch->bAlive != ALIVE_ )
{
ch->Mana = 0;
return;
}
const int cn = ch->GetServerID();
//MP雀汗
if( ch->Spell == WIZARD_SPELL ) // Wizard...
{
if( global_time >= ch->dwManaRecoverTime )//矫埃 眉农
{ //DEFAULT_RECOVER_MANA_TIME 捞巴狼 欺季抛捞瘤 炼例 窍搁 歹 狐弗 雀汗 等促
const char cForRookie = MapInfo[MapNumber].forrookie;//5硅 歹 弧府 雀汗 等促
ch->dwManaRecoverTime = global_time +(( 2 == cForRookie || 3 == cForRookie)?DEFAULT_RECOVER_MANA_TIME/5:DEFAULT_RECOVER_MANA_TIME);
int iCombatRecoverMp = 0;
int iCombatRecoverMpRate = 0;
int iCombatRecoverMpMax = 0;
const int iRecoverMana = ch->ManaMax*(MANA_RECOVER_RATE+RareEM.GetStaticRareMagic(ch->StaticRare)+iCombatRecoverMpRate)/100 + iCombatRecoverMp;//茄锅俊 5% 雀汗 矫难霖促
const int iRecoverManaMaxPercent = (DEFAULT_RECOVER_MANA_MAX_PERCENT+RareEM.GetStaticRareMana_recovery(ch->StaticRare)+iCombatRecoverMpMax);
const int iRecoverManaMax = ch->ManaMax * iRecoverManaMaxPercent/100;
if(IsRecoverAble(ch->Mana,iRecoverManaMax))
{
if(ch->IncMana(iRecoverMana,iRecoverManaMaxPercent))//函拳樊捞 乐促搁
{
ch->SendCharInfoBasic( MP, ch->Mana );//020704 lsw
}
}
}
}
else // Priest..
{ //DEFAULT_RECOVER_DIVINE_TIME 捞巴狼 欺季抛捞瘤 炼例 窍搁 歹 狐弗 雀汗 等促
if( global_time >= ch->dwDivineRecoverTime )//矫埃 眉农
{ //< CSD-TW-030606
int nPlusTime = 0;
const char cForRookie = MapInfo[MapNumber].forrookie;
switch (cForRookie)
{
case 2:
case 3:
{
nPlusTime = DEFAULT_RECOVER_DIVINE_TIME/5;
break;
}
default:
{
nPlusTime = DEFAULT_RECOVER_DIVINE_TIME;
break;
}
}
if (ch->IsDivineUp())
{
nPlusTime -= Magic_Ref[PRAY].nHDPoint;
}
ch->dwDivineRecoverTime = global_time + nPlusTime;
int iCombatRecoverDivineRate = 0;
int iCombatRecoverDivineMax = 0;
const int iRecoverDivine = ch->ManaMax*(DIVINE_RECOVER_RATE+RareEM.GetStaticRareNature(ch->StaticRare)+iCombatRecoverDivineRate)/100;//茄锅俊 5% 雀汗 矫难霖促
const int iRecoverDivineMaxPercent = (DEFAULT_RECOVER_DIVINE_MAX_PERCENT + iCombatRecoverDivineMax);
const int iRecoverDivineMax = ch->ManaMax*iRecoverDivineMaxPercent/100;
if(IsRecoverAble(ch->Mana,iRecoverDivineMax))
{
if(ch->IncMana(iRecoverDivine,iRecoverDivineMaxPercent))//函拳樊捞 乐促搁
{
ch->SendCharInfoBasic( MP, ch->Mana );//020704 lsw
}
}
} //> CSD-TW-030606
}
}
//硅绊悄 霸捞瘤绰 弊成 瞒瘤 臼绰促 漂喊茄 惑炔俊辑父 蛮促(ex>狼磊)
void CSkillMgr::AutoChangeHungry( CHARLIST *ch )
{
if( ch->bAlive != ALIVE_ )
{
ch->Hungry =0;
ch->fChangeHungry = 0;
return;//混酒 乐瘤 臼栏搁 硅绊悄 霸捞瘤 函拳 绝促
}
const int cn = ch->GetServerID();
bool bSend = false;
if( global_time > ch->dwHungryRecoverTime )
{
const int iChangeHungry = abs((int)ch->fChangeHungry);
if(!iChangeHungry) {return;}
ch->dwHungryRecoverTime = global_time+DEFAULT_CHANGE_HUNGRY_TIME;//眉农窍绰 term
if( ch->DecHungry((int)iChangeHungry))
{
ch->fChangeHungry -= (float)iChangeHungry;//快急 荤侩樊阑 葛滴 拌魂 窍绊 狼磊俊 旧疽阑锭绰 雀汗阑 矫难霖促
bSend =true;
}
if(ch->nCurrentAction == 17 )//旧篮 惑怕
{
const int iRecoverHungry = ch->HungryMax * HUNGRY_CHANGE_RATE/100;//茄锅俊 5% 雀汗 矫难霖促
const int iRecoverHungryMaxPercent = DEFAULT_CHANGE_HUNGRY_MAX_PERCENT;
const int iRecoverHungryMax = ch->HungryMax * iRecoverHungryMaxPercent/100;
if(IsRecoverAble(ch->Hungry,iRecoverHungryMax))
{
if(ch->IncHungry(iRecoverHungry,iRecoverHungryMaxPercent ))
{
bSend = true;
}
}
}
if(bSend)
{
ch->SendCharInfoBasic( SP, ch->Hungry );//020704 lsw
}
}
return;
}
// CP 磊悼雀汗
void CSkillMgr::AutoRecoverCp(CHARLIST *ch)
{
if( ch->bAlive != ALIVE_ )
{
ch->Cp = 0;
return;
}
const int cn = ch->GetServerID();
if (global_time >= ch->dwCpRecoverTime && ch->Peacests) // 矫埃 眉农
{ //< CSD-TW-030624
// DEFAULT_RECOVER_CP_TIME 捞巴狼 欺季抛捞瘤 炼例 窍搁 歹 狐弗 雀汗
ch->dwCpRecoverTime = global_time + DEFAULT_RECOVER_CP_TIME;
int iRecoverCp = __max(ch->CpMax*CP_CHANGE_RATE/100, 1);
if (ch->IsRecoveryCombatState())
{ // 傈捧胶懦 饭骇俊 蝶扼 雀汗加档甫 棵赴促.
const int nRecoveryCombat = ch->GetRecoveryCombat();
const int nMinus = ch->HpMax*ch->GetCombatValue(nRecoveryCombat)/100;
if (ch->Cp < ch->CpMax && nMinus < ch->Hp)
{
const int nLife = ch->DecLife(nMinus, 1);
if (nLife != 0)
{
::SendCharacterCondition(ch, -nLife);
iRecoverCp = __max(ch->CpMax*ch->GetCombatValue(nRecoveryCombat)/100, 1);
}
}
}
const int iRecoverCpMaxPercent = DEFAULT_CHANGE_CP_MAX_PERCENT;
const int iRecoverCpMax = ch->CpMax;
if(IsRecoverAble(ch->Cp,iRecoverCpMax ))
{
if(ch->IncCombat(iRecoverCp,iRecoverCpMaxPercent))//函拳樊捞 乐促搁
{
ch->SendCharInfoBasic(CP, ch->Cp);
}
}
} //> CSD-TW-030624
}
void CSkillMgr::AutoRefreshRareMakeCount(CHARLIST *ch)//饭绢 酒捞袍阑 父电 荐樊 盎脚 窍绰 窃荐
{//021108 lsw
if( ch->bAlive != ALIVE_ ) {return;}
const int day = g_day%8;
const int month = g_mon%8;//0-11 鳖瘤
bool bSendFlag = false;
for ( int i =0; i < 7 ; i++ )
{//饭绢酒捞袍 肮荐
t_skillexp2 *skillexp2 = ((t_skillexp2*)&ch->skillexp[i]);
if( skillexp2->day != day)
{
skillexp2->day = day;
bSendFlag = true;
}
if( skillexp2->month != month)
{
skillexp2->month = month;
bSendFlag = true;
}
if(bSendFlag)
{
bSendFlag = false;
skillexp2->makecount = 0;
SendSkillExp(i, ch->skillexp[i], ch->GetServerID());
}
}
//扁己 殿废老 力芭 //殿废 朝楼绰 坷疵肺 何磐 割老捞促
t_SkillExp3 *pSkillexp3 = (t_SkillExp3*)&ch->skillexp[SKILL_MASTER];
if(pSkillexp3->skillType)
{
if(g_year > pSkillexp3->year)
{//秦啊 硅差菌促 瘤况扼
bSendFlag = true;
}
if(g_mon*30 + g_day > pSkillexp3->day)
{//朝捞 硅差菌促 瘤况扼
bSendFlag = true;
}
if(bSendFlag)
{
bSendFlag = false;
memset(pSkillexp3,0,sizeof(DWORD));//瘤况柳促
SendSkillExp(SKILL_MASTER, ch->skillexp[SKILL_MASTER], ch->GetServerID());
}
}
return;
}
bool CSkillMgr::CheckSkillNo( const int iSkillNo )const
{
//MAX_SKILL_NO MAX_SKILL_NO 捞 芭 蔼捞 MAX_SKILLMAIN焊促 累栏搁 救等促
// if( MAX_SKILL_NO <= skillno || 0 >= skillno)//0锅 胶懦篮 绝促
if( MAX_SKILLMAIN >= iSkillNo && 0 < iSkillNo)//0锅 胶懦篮 绝促
{
return true;
}
return false;
}
bool CSkillMgr::CheckIsYourSkill( LPCHARLIST ch, const int iSkillNo )const
{
if(!CheckSkillNo(iSkillNo)) { return false; }
if( ch->Skill[iSkillNo] ) { return true; }
return false;
}
int CSkillMgr::CorrectLearnItem(CHARLIST *ch)
{
int i = 0;
int j = 0;
for( ;i < MAX_LEARN_ITEM; i++)
{
for(;j < MAX_LEARN_ITEM_CONVERT; j++)
{
if(ch->Item[i] == LIC[j].iBeforeItemNo)
{
ch->Item[i] = LIC[j].iAfterItemNo;
// memcpy(p->u.change_map_protocol.mapdata6.ch_data.Item,(UCHAR *)ch->Item,SIZE_OF_ITEMINDEX );
break;
}
}
}
return 0;
}
int CSkillMgr::FindLearnItem( CHARLIST *ch, const int item_no ) // 硅款霸 乐栏搁 -1阑 府畔, 绝栏搁 item_max甫 府畔
{
// 020620 YGI
if( !ch ) return -1;
for( int i=0; i<ITEM_JOIN_MAX; i++ ) // 扁夯利栏肺 硅匡 鞘夸啊 绝绰 扒瘤..
{
if( item_join[i].item_id == item_no )
{
if( !item_join[i].need_know )
{
return -1; // 硅匡 鞘夸啊 绝促.
}
else break;
}
}
// CorrectLearnItem(ch);//???
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -