📄 questfunction.cpp
字号:
}
}
::LogInFile( szFilename, "CScriptTime-Mapmove :: Name:%s, InvItem: %s", ch->Name, szItem.c_str() );
}
//CScriptTimer
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CScriptCounter
void CScriptCounter::ClearCounter()
{
m_iSpeciesNum = 0;
m_iSpeciesType =0;
m_iSpeciesMuch =0;
m_iCounter = 0;
m_bStart = false;
m_ID =0;
m_szName[0] ='\0';
}
void CScriptCounter::SendSCRIPT_COUNTER( int iType)
{
t_packet packet;
packet.h.header.type = iType;
packet.h.header.size = sizeof( t_script_counter);
packet.u.script_counter.iNum = m_iSpeciesNum;
packet.u.script_counter.iType = m_iSpeciesType;
packet.u.script_counter.iMuch = m_iSpeciesMuch;
packet.u.script_counter.iCounter = m_iCounter;
QueuePacket( connections, m_ID, &packet, 1 );
}
void CScriptCounter::RecvSCRIPT_COUNTER()
{
}
bool CScriptCounter::StartCounter()
{
if( m_bStart == true ) return false;
SendSCRIPT_COUNTER( CMD_SCRIPT_COUNTER_START);
m_bStart = true;
m_iCounter =0;
return true;
}
void CScriptCounter::RunCounter( int iNum )
{
if( iNum != GetSpeciesNum() ) return;
AddCounter();
if( GetCounter() == GetSpeciesMuch() )
{
//墨款磐甫 倒促 蔼捞 瘤唱搁 肛眠绰单 瘤陛篮 肛眠瘤 救纳 父惦
//EndCounter(); //俊辑 // 021129
}
}
void CScriptCounter::AddCounter()
{
m_iCounter++;
SendSCRIPT_COUNTER( CMD_SCRIPT_COUNTER_SYNC );
}
void CScriptCounter::EndCounter()
{
SendSCRIPT_COUNTER( CMD_SCRIPT_COUNTER_END );
//ClearCounter(); //救肛眠霸窃.
}
//CScriptCounter
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CRequital
int CRequital::LoadRequitalTable()
{
char szQuery[0xff];
HSTMT hStmt= NULL ;
RETCODE ret ;
SDWORD cbValue ;
SQLAllocStmt(hDBC, &hStmt);
// strcpy( szQuery, "select * from requital_list order by npc_index" ); // BBD 040318
sprintf( szQuery, "select * from requital_list where map_num = %d order by npc_index ", MapNumber ); // BBD 040318
ret= SQLExecDirect(hStmt, (UCHAR *)szQuery, SQL_NTS) ;
if(ret == SQL_SUCCESS_WITH_INFO || ret == SQL_SUCCESS)
{
ret = SQLFetch( hStmt );
while( ret == SQL_SUCCESS )
{
table_requital_list table;
//Map_num,Npc_index,Quest_no, Quest_step,Item_no, Item_rare_type, ,Item_rare_count, Real_Fame,Dual_Fame, Tile_area;
ret = SQLGetData( hStmt, 1, SQL_C_LONG, &table.Map_num, 0, &cbValue );
ret = SQLGetData( hStmt, 2, SQL_C_LONG, &table.Npc_index, 0, &cbValue );
ret = SQLGetData( hStmt, 3, SQL_C_LONG, &table.Quest_no, 0, &cbValue );
ret = SQLGetData( hStmt, 4, SQL_C_LONG, &table.Quest_step, 0, &cbValue );
ret = SQLGetData( hStmt, 5, SQL_C_LONG, &table.Item_no, 0, &cbValue );
ret = SQLGetData( hStmt, 6, SQL_C_LONG, &table.Item_rare_type, 0, &cbValue );
ret = SQLGetData( hStmt, 7, SQL_C_LONG, &table.Item_Max, 0, &cbValue );
ret = SQLGetData( hStmt, 8, SQL_C_LONG, &table.Item_Min, 0, &cbValue );
ret = SQLGetData( hStmt, 9, SQL_C_LONG, &table.Item_rare_count, 0, &cbValue );
ret = SQLGetData( hStmt, 10,SQL_C_LONG, &table.Real_Fame, 0, &cbValue );
ret = SQLGetData( hStmt, 11,SQL_C_LONG, &table.Dual_Fame, 0, &cbValue );
ret = SQLGetData( hStmt, 12,SQL_C_LONG, &table.Tile_area, 0, &cbValue );
ret = SQLGetData( hStmt, 13,SQL_C_LONG, &table.WarStatus, 0, &cbValue ); // BBD 040318
ret = SQLGetData( hStmt, 14,SQL_C_LONG, &table.Sardonyx, 0, &cbValue ); // BBD 040329
ret = SQLGetData( hStmt, 15,SQL_C_LONG, &table.LeafOfBlessed, 0, &cbValue ); // BBD 040329
ret = SQLGetData( hStmt, 16,SQL_C_LONG, &table.ref_index, 0, &cbValue ); // BBD 040329
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS)
{
MyLog( LOG_FATAL, "Table : requital_list : Error!!! (%d)", ret) ;
SQLFreeStmt(hStmt, SQL_DROP); // BBD 040329
return -1;
}
SetRequitalTable( table );
ret = SQLFetch( hStmt );
}
SQLFreeStmt(hStmt, SQL_DROP); // BBD 040329
return 1;
}
SQLFreeStmt(hStmt, SQL_DROP); // BBD 040329
return 0;
}
list<table_requital_list >::iterator CRequital::GetRequital_KillNpc( const int index ) //npc甫 磷看阑锭 林绰 秦琶狼 辆幅
{
REQUITALLISTITER itFind = find_if(m_tRequital.begin(), m_tRequital.end(), bind2nd( IsNpcIndexHere(), index ) );
if( itFind != m_tRequital.end() )
{
return itFind;
}
return NULL;
}
//<! BBD 040329
list<table_requital_Item >::iterator CRequital::GetRequital_ItemIttr( const int index)
{
REQUITALITEMITER itFind = find_if(m_tRequitalItem.begin(), m_tRequitalItem.end(), bind2nd( IsItemIndex(), index ) );
if( itFind != m_tRequitalItem.end() )
{
return itFind;
}
return NULL;
}
//> BBD 040329
//CRequital
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int InitLoadQuestTable() //涅胶飘俊 包访等 抛捞喉狼 肺靛
{
g_QuestInMap.IniteAllTable();
if( 1 != g_QuestInMap.LoadQuestInMap() ) return -1;
if( 1 != g_QuestInMap.LoadQuestInfoByStep() ) return -2;
//焊胶磷咯 秦琶林绰 抛捞喉 肺靛
if( 1 != g_QuestInMap.LoadRequitalTable() ) return -3; // 021105 kyo
if( 1 != g_QuestInMap.LoadRequitalItemTable() ) return -4; // BBD 040329
return 1;
}
//<! BBD 040329
int CRequital::LoadRequitalItemTable()
{
char szQuery[0xff];
HSTMT hStmt= NULL ;
RETCODE ret ;
SDWORD cbValue ;
SQLAllocStmt(hDBC, &hStmt);
strcpy( szQuery, "select * from requital_item order by [index]" );
ret= SQLExecDirect(hStmt, (UCHAR *)szQuery, SQL_NTS) ;
if(ret == SQL_SUCCESS_WITH_INFO || ret == SQL_SUCCESS)
{
ret = SQLFetch( hStmt );
while( ret == SQL_SUCCESS )
{
table_requital_Item table;
//Map_num,Npc_index,Quest_no, Quest_step,Item_no, Item_rare_type, ,Item_rare_count, Real_Fame,Dual_Fame, Tile_area;
ret = SQLGetData( hStmt, 1, SQL_C_LONG, &table.index, 0, &cbValue );
ret = SQLGetData( hStmt, 2, SQL_C_LONG, &table.count, 0, &cbValue );
ret = SQLGetData( hStmt, 3, SQL_C_LONG, &table.rate, 0, &cbValue );
ret = SQLGetData( hStmt, 4, SQL_C_LONG, &table.item_no[0], 0, &cbValue );
ret = SQLGetData( hStmt, 5, SQL_C_LONG, &table.item_no[1], 0, &cbValue );
ret = SQLGetData( hStmt, 6, SQL_C_LONG, &table.item_no[2], 0, &cbValue );
ret = SQLGetData( hStmt, 7, SQL_C_LONG, &table.item_no[3], 0, &cbValue );
ret = SQLGetData( hStmt, 8, SQL_C_LONG, &table.item_no[4], 0, &cbValue );
ret = SQLGetData( hStmt, 9, SQL_C_LONG, &table.grade, 0, &cbValue );
ret = SQLGetData( hStmt, 10,SQL_C_LONG, &table.kind1, 0, &cbValue );
ret = SQLGetData( hStmt, 11,SQL_C_LONG, &table.kind2, 0, &cbValue );
ret = SQLGetData( hStmt, 12,SQL_C_LONG, &table.kind3, 0, &cbValue );
ret = SQLGetData( hStmt, 13,SQL_C_LONG, &table.IsDynamic, 0, &cbValue );
ret = SQLGetData( hStmt, 14,SQL_C_LONG, &table.HighRare, 0, &cbValue );
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS)
{
MyLog( LOG_FATAL, "Table : requital_list : Error!!! (%d)", ret) ;
SQLFreeStmt(hStmt, SQL_DROP);
return -1;
}
SetRequitalItemTable( table );
ret = SQLFetch( hStmt );
}
SQLFreeStmt(hStmt, SQL_DROP);
return 1;
}
SQLFreeStmt(hStmt, SQL_DROP);
return 0;
}
//> BBD 040329
//<! BBD 040329 // 搬拌籍俊 包茄 焊惑窃荐
bool CQuestInMap::Requital_About_SealStone( const int cn, int nSardAmount, int nLeafAmount, int nRef_index)
{
CHARLIST *ch = CheckServerId( cn);
if( !ch ) return false;
int a,b,c;
RareMain RareAttr;
ItemAttr Item;
POS pos;
//<! BBD 040401
int rate = rand()%10;
switch(rate)
{
// 荤靛 林扁////////////////////////////////////////////////////////////////////////
case 0:
case 1:
case 2:
{
for(int i = 0; i < nSardAmount; i++) // 荤靛甫林磊
{
Item = ::GenerateItem(SARD_ID); // BBD 040331
if( SearchInv( ch->inv, a, b, c ))
{
ch->inv[a][b][c] = Item;
SetItemPos( INV, a, b, c, &pos );
::SendItemEventLog( &Item, ch->GetServerID(), 0, SILT_MAKE_BY_DB, 100 );
SendServerEachItem( &pos, &Item, cn); // 捞逞捞 DB单阁栏肺 酒袍肺弊 巢扁扼绊 茄促
/* Send_RareItemMakeLog( cn, Item.item_no,
0,0,0,0,0,
0,0,0,0,
Item.attr[IATTR_LIMIT],
Item.attr[IATTR_MUCH],
0,3000,MapInfo[MapNumber].port,
0,0,0,0,
3000,0
); */
}
else // 牢亥俊 磊府绝澜
{
return false;
}
}
break;
}
// 绵蕾 林扁////////////////////////////////////////////////////////////////////////
case 3:
case 4:
case 5:
{
for(int i = 0; i < nLeafAmount; i++) // 绵汗狼 蕾荤蓖甫林磊
{
Item = ::GenerateItem(LEAFBLESS_ID); // BBD 040331
if( SearchInv( ch->inv, a, b, c ))
{
ch->inv[a][b][c] = Item;
SetItemPos( INV, a, b, c, &pos );
::SendItemEventLog( &Item, ch->GetServerID(), 0, SILT_MAKE_BY_DB, 100 );
SendServerEachItem( &pos, &Item, cn); // 捞逞捞 DB单阁栏肺 酒袍肺弊 巢扁扼绊 茄促
/* Send_RareItemMakeLog( cn, Item.item_no,
0,0,0,0,0,
0,0,0,0,
Item.attr[IATTR_LIMIT],
Item.attr[IATTR_MUCH],
0,3000,MapInfo[MapNumber].port,
0,0,0,0,
3000,0
); */
}
else // 牢亥俊 磊府绝澜
{
return false;
}
}
break;
}
// 酒捞袍 林扁////////////////////////////////////////////////////////////////////////
case 6:
case 7:
case 8:
case 9:
{
if(nRef_index) // 曼炼牢郸胶啊 乐栏搁 酒袍阑 父甸绢林磊
{
if(m_cRequital)
{
REQUITALITEMITER it = m_cRequital->GetRequital_ItemIttr(nRef_index);
if(it != NULL) // 秦寸 酒捞袍狼 牢郸胶甫 茫疽衬?
{
int rate = rand()%100;
if(rate < (*it).rate) // 犬伏郴肺 甸绢吭衬?
{
if(!SearchInv( ch->inv, a, b, c )) // 牢亥俊 磊府绝澜 {
{
return false;
}
// 秦寸等 仇捞 割俺狼 酒捞袍阑 焊蜡沁绰瘤 犬牢
int amount = 0;
for(int i = 0; i < 5; i++)
{
if((*it).item_no[i])
{
amount++;
}
}
if(!amount) // 卿~ 茄俺档 绝促
{
return true;
}
int rate2 = rand()%amount; // 乐绰肮荐 吝(item_no1 ~ 5) 茄仇阑 榜扼霖促
// 酒捞袍阑 父电促
ItemAttr item = ::GenerateItem((*it).item_no[rate2]); // BBD 040331
ItemMgr.MakeRareAttr(item.attr[IATTR_RARE_MAIN], (*it).grade, (*it).kind1, (*it).kind2, (*it).kind3,
(*it).IsDynamic, (*it).HighRare);
ch->inv[a][b][c] = item; // 酒捞袍阑 持绢霖促.
SetItemPos( INV, a, b, c, &pos );
::SendItemEventLog( &item, ch->GetServerID(), 0, SILT_MAKE_BY_DB, 100 );
SendServerEachItem( &pos, &item, cn); // 捞逞捞 DB单阁栏肺 酒袍肺弊 巢扁扼绊 茄促
}
}
}
}
break;
}
default:
{
break;
}
}
//> BBD 040401
return true;
}
//> BBD 040329 // 搬拌籍俊 包茄 焊惑窃荐
//<! BBD 040401 某腐磐狼 惫啊俊 蝶扼 酒捞袍 焊惑咯何甫 魄窜
int DecideRequitalByNationDefensePoint(CHARLIST *ch)
{
int NationIndex = 0;
switch(ch->name_status.nation) // 惫啊 犬牢
{
case N_VYSEUS:
{
NationIndex = 0;
break;
}
case N_ZYPERN:
{
NationIndex = 1;
break;
}
case N_YILSE:
{
NationIndex = 2;
break;
}
default:
{
return -1; // 卿 惩 绢蠢唱扼 仇捞衬?
}
}
int DefensePoint = g_DefensePoint[NationIndex];
int DefIndex = 0;
// 硅凯狼 秦寸 牢郸胶甫 茫澜
if(DefensePoint >= 100)
{
DefIndex = 0;
}
else if(DefensePoint >= 80 && DefensePoint < 100)
{
DefIndex = 1;
}
else if(DefensePoint >= 70 && DefensePoint < 80)
{
DefIndex = 2;
}
else if(DefensePoint >= 60 && DefensePoint < 70)
{
DefIndex = 3;
}
else if(DefensePoint >= 50 && DefensePoint < 60)
{
DefIndex = 4;
}
else if(DefensePoint >= 40 && DefensePoint < 50)
{
DefIndex = 5;
}
else if(DefensePoint >= 30 && DefensePoint < 40)
{
DefIndex = 6;
}
else
{
DefIndex = 7;
}
int RequitalRate = g_RequitalItemRate[DefIndex];
int rate = rand()%100;
if(rate < RequitalRate)
{
return 1; // 犬伏郴肺 甸绢吭促.
}
else
{
return 0; // 犬伏郴肺 臼甸绢吭促.
}
}
//> BBD 040401 某腐磐狼 惫啊俊 蝶扼 酒捞袍 焊惑咯何甫 魄窜
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -