📄 eventmgr.cpp
字号:
return m_eventSound.IsActive();
}
if( type & ET_EVENT_MESSAGE )
{
return m_eventMessage.IsActive();
}
return 0;
}
// 捞亥飘啊 场抄 版快 贸府
int CEventMgr::CheckCloseEvent( int type )
{
if( type & ET_EVENT_NPC_CREATE )
{
for( int i=0; i<m_eventNpcCreate.m_nEventCount; i++ )
{
m_eventNpcCreate.GetEventPoint( i )->CheckClearCreatedNpc();
}
}
return 1;
}
void *CEventMgr::GetActiveEvent( int type )
{
if( type & ET_EVENT_NPC_ITEM )
{
return m_eventNpcItem.GetActiveEvent();
}
if( type & ET_EVENT_NPC_CREATE )
{
return m_eventNpcCreate.GetActiveEvent();
}
if( type & ET_EVENT_OBJECT )
{
return m_eventObject.GetActiveEvent();
}
if( type & ET_EVENT_SOUND )
{
return m_eventSound.GetActiveEvent();
}
if( type & ET_EVENT_MESSAGE )
{
return m_eventMessage.GetActiveEvent();
}
return 0;
}
int CEventMgr::Proc()
{
// 阁胶磐 积己犬牢
m_eventNpcCreate.m_listActive.SetFind();
while( m_eventNpcCreate.m_listActive.FindNext() )
{
int index = m_eventNpcCreate.m_listActive.GetFind();
m_eventNpcCreate.GetEventPoint( index )->CreateNpc();
}
// 捞亥飘 皋矫瘤 犬牢
m_eventMessage.m_listActive.SetFind();
while( m_eventMessage.m_listActive.FindNext() )
{
int index = m_eventMessage.m_listActive.GetFind();
m_eventMessage.GetEventPoint( index )->CheckEvent();
}
// 021128 YGI
static DWORD dwCheckTime = g_curr_time;
if( g_curr_time - dwCheckTime > 600 ) // 10盒付促 眉农茄促.
{
CheckActiveEvent( ET_EVENT_NPC_CREATE );
CheckCloseEvent( ET_EVENT_NPC_CREATE );
dwCheckTime = g_curr_time;
}
return 1;
}
// 秦寸 捞亥飘甫 荐青沁栏搁 1阑 府畔茄促.
int CEventMgr::CheckScriptNo( int npc_index, short int cn )
{
if( !NPCList[npc_index].eventno ) return 0;
int ret = 0;
m_eventNpcScript.m_listActive.SetFind();
while( m_eventNpcScript.m_listActive.FindNext() )
{
int index = m_eventNpcScript.m_listActive.GetFind();
ret += m_eventNpcScript.GetEventPoint( index )->CheckEvent( npc_index, cn );
}
return ret;
}
CEventNpcScript *CEventMgr::GetEventNpcScript( int script_no )
{
for( int i=0; i<m_eventNpcScript.m_nEventCount; i++ )
{
if( m_eventNpcScript.m_pEvent[i].m_nScriptNo == script_no )
return &m_eventNpcScript.m_pEvent[i];
}
return NULL;
}
CEventNpcScript *CEventMgr::GetEventNpcScriptByEventNo( int event_no )
{
for( int i=0; i<m_eventNpcScript.m_nEventCount; i++ )
{
if( m_eventNpcScript.m_pEvent[i].m_nEventNo == event_no )
return &m_eventNpcScript.m_pEvent[i];
}
return NULL;
}
CEventMoveMap *CEventMgr::GetEventMoveMapPoint( int event_no )
{
for( int i=0; i<m_eventMoveMap.m_nEventCount; i++ )
{
if( m_eventMoveMap.m_pEvent[i].m_nEventNo == event_no )
return &m_eventMoveMap.m_pEvent[i];
}
return NULL;
}
///////////////////////////////////////////////////////////////////////////////////
void CheckEventWhenKillMonster( CHARLIST *pKiller, CHARLIST *pNpc )
{
if( pNpc->generationtype == GT_SCENARIO_MONSTER )
{
KilledScenarioBoss( pKiller, pNpc );
}
g_EventMgr.CheckNpcItem( pNpc );
// 040105 YGI 焊拱
if( pNpc->generationtype == GT_TREASUER_GUARD )
{
g_TreasureGuardMgr.KilledTreasureGuard( pKiller, pNpc );
}
}
void SendSaveAmountEventNpcItem( int event_no, int amount )
{
t_packet packet;
packet.h.header.type = CMD_SAVE_AMOUNT_EVENT_NPC_ITEM;
int *data = (int *)packet.u.data;
data[0] = event_no;
data[1] = amount;
packet.h.header.size = sizeof( int ) *2;
QueuePacket( connections, DB_DEMON, &packet, 1 );
}
///////////////////////////////////////////////////////////////////////////////////
// light_version
CLightVersion g_LightVersion;
int CLightVersion::LoadLightVersionMap()
{
char filename[256];
sprintf( filename, "%s/data/light_map.txt", GameServerDataPath );
FILE *fp;
fp = fopen( filename, "rt" );
if( !fp ) return 0;
Clear(); // 函荐 努府绢
char temp[255];
while( fgets( temp, 255, fp ) )
{
if( CheckContinueLine( temp[0] ) ) continue;
m_nCount++;
}
fseek( fp, 0, SEEK_SET );
m_szlpMap = new string[m_nCount];
int count = 0;
while( fgets( temp, 255, fp ) )
{
if( CheckContinueLine( temp[0] ) ) continue;
strupr( temp );
m_szlpMap[count++] = temp;
}
fclose( fp );
return 1;
}
bool CLightVersion::IsAbleMapMove( CHARLIST *ch, const char *mapname )
{
if( !IsLightVersion( ch ) ) return true;
for( int i=0; i<m_nCount; i++ )
{
if( _stricmp( mapname, m_szlpMap[i].c_str() ) == 0 ) return true;
}
return false;
}
bool CLightVersion::IsLightVersion( CHARLIST *ch )
{
return (ch->installType)?true:false;
}
bool CheckContinueLine( char check )
{
if( check == 0 || check == ' ' || check == ';' || check == '#' || check == '\n' ) return true;
return false;
}
/////////////////////////////////////////////////////////////////////
// 030627 YGI
bool InitEventFlag()
{
int nRow = 0;
char query[256];
sprintf( query, "mapname = '%s'", MapName );
GetRowLineOfSQL( "Event_MoveWhenDie", "*", &nRow, query );
g_EventFlagMgr.SetMoveMapWhenDie( (nRow<=0)?0:1 );
g_EventFlagMgr.InitSaveLogFlag(); // 030919 HK YGI
// 040105 YGI 焊拱
// 焊拱 茫扁 捞亥飘侩
LoadEventTreasureXY();
LoadEventTreasureGuard();
return true;
}
// 030919 HK YGI
/////////////////////////////////////////////////////////////////////
//CEventFlagMgr member functions
void CEventFlagMgr ::InitSaveLogFlag()
{
m_bSaveLogAboutSaveUserData = (int)GetPrivateProfileInt("option", "savelogflag_when_save_user_data" ,0,MapServerConfigFileName);
}
/////////////////////////////////////////////////////////////
// 040105 YGI 焊拱
int CTreasureGuardMgr::CreateGuard( int index, int treasure_class, int x, int y, int cn )
{// 焊拱 瘤糯捞 免悼
if( treasure_class<0 || treasure_class>=5 ) return 0;
int count = 0; // 醚 免泅 俺荐
for( int i=0; i<g_TreasureGuardTBL[treasure_class].m_nCount; i++ )
{
int spr_no = g_TreasureGuardTBL[treasure_class].m_pNpcNo[i];
int max = g_TreasureGuardTBL[treasure_class].m_pNpcCount[i];
if( !spr_no || !max ) continue;
for( int j=0; j<max; j++ )
{
const int id = ::GetDeleteAbleNPC();//030211 lsw
if( id >= 0 )
{
::DeleteNpc( id );
}
else
{//瘤匡 荐 乐绰 阁胶磐啊 绝促搁
::MyLog(0,"Critical Error Can't Get Normal Monster(CTreasureGuardMgr::CreateGuard())");
break;
}
int xx = x+(5-rand()%11);
int yy = y+(5-rand()%11);
NPC_Create( id, spr_no, xx, yy, 0, index, GT_TREASUER_GUARD);
count++;
}
}
if( count <= 0 ) return 0; // 积己 角菩
POINTS data;
data.x = treasure_class+1; // 焊拱 惑磊俊 持绢临蔼. 1何磐 矫累
data.y = count;
AddNew( index, data );
return 1; // 积己 己傍
}
/////////////////////////////////////////////////////////////
CEventFindTreasure g_EventFindTreasure;
CTreasureGuardTBL g_TreasureGuardTBL[5];
CTreasureGuardMgr g_TreasureGuardMgr;
#include "LogManager.h"
int CTreasureGuardMgr::KilledTreasureGuard( CHARLIST *user, CHARLIST *boss )
{
int index = boss->generationpos; // 脾绢 唱柯 弊缝 锅龋
ITOR_MAP_GUARD itor = m_Data.find(index);
if (itor == m_Data.end()) return 0;
itor->second.y--;
if( itor->second.y == 0 ) // 葛滴 促 磷看促.
{
// 焊拱 惯斑
ItemAttr item = ::GenerateItem( TREASURE_BOX );
item.attr[IATTR_TREASURE_MAP] = itor->second.x;
::DropItem( boss->X, boss->Y, &item );
string strPath;
char temp[256];
sprintf( temp, "<%02d:%02d:%02d>", g_mon+1, g_day,g_hour, g_min, g_sec );
sprintf( temp, "%s drop treasure box ( %s(%d, %d) : %d(%d) )", temp, MapName, boss->X/TILE_SIZE, boss->Y/TILE_SIZE, item.item_no, item.attr[IATTR_LIMIT] );
if( g_pLogManager->GetLogPath(strPath) )
{
char temp_path[80];
sprintf( temp_path, "%s/Event/event_treasure_box.txt", strPath.c_str());
::SaveLogDefault( temp_path, temp, 0 );
}
else
{
MyLog( 0, "SaveTreasureLogFile fail");
}
MyLog( 0, temp );
m_Data.erase(itor); // 府胶飘(甘)俊辑 昏力
}
return 1;
}
// 焊拱 瘤档 酒捞袍牢啊?
int IsTreasureMapItem( int item_no )
{
int level = 0;
switch( item_no )
{
case LOW_LEVEL_MAP : level = 1; break;
case MIDDLE_LEVEL_MAP : level = 2; break;
case HIGH_LEVEL_MAP : level = 3; break;
case UNKNOWN_MAP : level = 4; break;
}
return level;
}
CTreasureMapItem GetTreasureAttr( ItemAttr *item )
{
CTreasureMapItem attr;
memcpy( &attr, &item->attr[IATTR_TREASURE_MAP], sizeof( DWORD ) );
return attr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -