📄 dungeon.cpp
字号:
case CScenarioBoss::NT_DRAGON_LOAD :
case CScenarioBoss::NT_NORMAL_DRAGON :
{
SAFE_DELETE_ARRAY(m_pBoss);
m_pBoss = new CScenarioBoss[2];
m_nBossCount = 2;
int ret =0 ;
#ifdef _KEIN_TEST_
ret += m_pBoss[0].CreateBoss( CScenarioBoss::NT_DRAGON_HEART, 0, 317, 312 );
ret += m_pBoss[1].CreateBoss( boss_type, 0, 320, 310 );
#else
ret += m_pBoss[0].CreateBoss( CScenarioBoss::NT_DRAGON_HEART, 0, 489, 75 );
ret += m_pBoss[1].CreateBoss( boss_type, 0, 492, 73 );
#endif
if( ret != 2 )
{
SAFE_DELETE_ARRAY(m_pBoss);
m_nBossCount = 0;
}
else
{
char data = 0;
if( boss_type == CScenarioBoss::NT_DRAGON_LOAD )
{
data = 1;
}
::SendScenarioMessage(SEND_ALL, SMT_CREATE_DRAGON, &data, 1 );
}
break;
}
case CScenarioBoss::NT_NORMAL_BOSS :
{
if( !m_nBoss ) return 0;
SAFE_DELETE_ARRAY(m_pBoss);
m_pBoss = new CScenarioBoss[1];
m_nBossCount = 1;
int ret = m_pBoss->CreateBoss( CScenarioBoss::NT_NORMAL_BOSS, m_nBoss, m_nBossX, m_nBossY );
if( ret != 1 )
{
SAFE_DELETE_ARRAY(m_pBoss);
m_nBossCount = 0;
}
else
{
POINTS xy;
xy.x = m_nBossX;
xy.y = m_nBossY;
::SendScenarioMessage(SEND_ALL, SMT_CREATE_BOSS, (char *)&xy, sizeof( POINTS ) );
if( !m_pFollower && m_nFollower )
{
m_pFollower = new CScenarioBoss[m_nFollowerCount];
for( int i=0; i<m_nFollowerCount; i++ )
{
m_pFollower[i].CreateBoss( CScenarioBoss::NT_FOLLOWER, m_nFollower, m_nBossX+(rand()%5)-3, m_nBossY+(rand()%5)-3 );
}
}
}
break;
}
}
return 1;
}
int CDungeonObject::DeletBoss()
{
if( !m_pBoss ) return 0;
int ret = 0;
for( int i=0; i<m_nBossCount; i++ )
{
ret += m_pBoss[i].DeleteBoss();
}
return ( m_nBossCount == ret )?1:0;
}
void CDungeonObject::SendObjectTileAttr( short int cn )
{
if( IsActive() )
{
if( m_eTileType2 )
{
::SendTileAttr( m_Index, m_eTileType2, m_nEventNo2, m_nInputX, m_nInputY, m_nRange2, cn );
}
}
else
{
if( m_eTileType1 )
{
::SendTileAttr( m_Index, m_eTileType1, m_nEventNo1, m_nInputX, m_nInputY, m_nRange1, cn );
}
}
}
///////////////////////////////////////////////////////////////////////////
// 甘俊辑 嘛篮霸 酒囱吧 积己矫懦锭....
int CreateMapObject( int object_no, DWORD attr, int x, int y )
{
ItemAttr object;
object.item_no = 25000+object_no;
object.attr[0] = 1;
object.attr[1] = 1;
if( object_no == 1 ) attr |= IA2_HIDE; // 救焊咯霖促.
object.attr[IATTR_ATTR] = attr;
object.attr[3] = 1;
object.attr[4] = 1;
object.attr[5] = 1;
int id = AddItemList( object.item_no, object.attr, 0, x*TILE_SIZE+TILE_SIZE/2, y*TILE_SIZE+TILE_SIZE/2, 0, 0 );
return id;
}
// 唱吝俊 瘤匡锭甫 措厚秦辑 index甫 沥秦 霖促.
void SendTileAttr( int index, int type, int number, int x, int y, int range, short int cn )
{
t_packet packet;
packet.h.header.type = CMD_SETTING_MAP_TILE_EVENT;
packet.h.header.size = sizeof( k_setting_map_tile );
packet.u.kein.setting_map_tile.index = index;
packet.u.kein.setting_map_tile.type = type;
packet.u.kein.setting_map_tile.number = number;
packet.u.kein.setting_map_tile.x = x;
packet.u.kein.setting_map_tile.y = y;
packet.u.kein.setting_map_tile.range = range;
if( cn == SEND_ALL )
{
g_pUserManager->SendPacket(&packet); // CSD-CN-031213
}
else
{
QueuePacket( connections, cn, &packet, 1 );
}
}
////////////////////////////////////////////////////////////////
// class CDungeonMap functions
int CDungeonMap::NewJoin( short int cn ) // 盖贸澜 捞 甘俊 甸绢柯 荤恩俊霸 焊郴临波..
{
for( int i=0; i<m_nObjectCount; i++ )
{
m_pObject[i].SendObjectTileAttr( cn ); // 鸥老 加己阑 焊郴霖促.
}
return 1;
}
int CDungeonMap::SetActive()
{
static int dungeon_key[] = { 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49 };
static int dungeon_key_count = sizeof( dungeon_key )/sizeof( int );
if( m_nDungeonType == DT_PASSWORD )
{
int param = rand();
m_nTrapCount = dungeon_key[param%dungeon_key_count];
ResetKey();
}
m_bActive = true;
for( int i=0; i<m_nObjectCount; i++ )
{
m_pObject[i].CloseObject(1); // 阁胶磐甫 积己矫挪促.
}
char layer = m_nLayer;
::SendScenarioMessage(SEND_ALL, SMT_START_LAYER, &layer, 1 );
return 1;
}
int CDungeonMap::SetClose()
{
for( int i=0; i<m_nObjectCount; i++ )
{
m_pObject[i].CloseObject( 0 );
}
m_bActive = false;
return 1;
}
// 皋矫瘤 殿废
int CDungeonMap::SetHistory( CHARLIST *ch, CDungeonObject *pDO, int type )
{
CDungeonHistory *pData;
pData = new CDungeonHistory;
int layer = pDO->m_nLayer;
int msg_type;
switch( pDO->m_nExecuteType )
{
case pDO->OET_NORMAL_TRAP : msg_type = CDungeonHistory::NORMAL_TRAP_OPEN ; break;
case pDO->OET_POTAL_BOSS : msg_type = CDungeonHistory::MIDDLE_BOSS_OPEN ; break;
case pDO->OET_POTAL_OUT_LAYER : msg_type = CDungeonHistory::LAYER_POTAL_OPEN ; break;
case pDO->OET_POTAL_OUT_DUNGEON : msg_type = CDungeonHistory::DUNGEON_POTAL_OPEN; break;
}
msg_type+= pDO->IsActive()? 0:1;
pData->SetData( msg_type, layer, ch?ch->Name:NULL );
if( type ) // 傈眉 甘栏肺 焊郴绰 皋矫瘤
{
::SendDungeonHistory( pData );
}
else // 磊扁 甘父 焊咯林绰 皋矫瘤
{
CDungeonMap *pDungeonMap = g_pDungeonMap->GetDungeonMapByLayer( layer );
if( pDungeonMap ) pDungeonMap->m_History.AddNodeLimit( pData, 15 );
// 030211 YGI
MyLog( 0, "[Scenario message] Local, type:%d, layer:%d, name:[%s]", msg_type, layer, ch?ch->Name:" " );
}
return 1;
}
// 坷宏璃飘俊 包访等 捞亥飘 鸥老阑 光疽阑 版快
bool CDungeonMap::CheckObject( int cn, int event_no )
{
CHARLIST *ch = CheckServerId( cn );
if( !ch ) return false;
if( !event_no ) return false;
CDungeonObject *pDOb;
int call_menu = 0;
int result = 0;
for( int i=0; i<m_nObjectCount; i++ )
{
if( m_pObject[i].IsActive() )
{
if( m_pObject[i].m_nEventNo2 == event_no )
{
m_pObject[i].Execute( cn );;
pDOb = &m_pObject[i];
if( m_pObject[i].m_nExecuteType == pDOb->OET_NORMAL_TRAP ) { call_menu = 1; }
result = 1;
}
}
else
{
if( m_pObject[i].m_nEventNo1 == event_no )
{
m_pObject[i].TryActive( ch );
if( m_pObject[i].m_nExecuteType == pDOb->OET_NORMAL_TRAP ) { call_menu = 1; }
result = 1;
}
}
}
if( call_menu )
{
int menunum = 0;
if( m_nDungeonType == DT_PASSWORD )
{
menunum = 137; // 钮宏 牢器
}
else
{
menunum = 136; // trap info
}
::SendCallSmallMenu( cn, 0, menunum );
}
return result?true:false;
}
CDungeonObject *CDungeonMap::GetObjectByEventNo( int event_no )
{
if( !event_no ) return NULL;
for( int i=0; i<m_nObjectCount; i++ )
{
if( m_pObject[i].IsActive() )
{
if( m_pObject[i].m_nEventNo2 == event_no )
{
return &m_pObject[i];
}
}
else
{
if( m_pObject[i].m_nEventNo1 == event_no )
{
return &m_pObject[i];
}
}
}
return NULL;
}
// 坷宏璃飘 焊咯临锭 event档 焊郴霖促.
int CDungeonMap::SendEventWhenAddItem( int item_index, short int cn )
{
for( int i=0; i<m_nObjectCount; i++ )
{
if( m_pObject[i].m_ObjectId == -1 ) continue;
if( m_pObject[i].m_ObjectId == item_index )
{
m_pObject[i].SendObjectTileAttr( cn );
}
}
return 1;
}
int CDungeonMap::SetInt( int *pTemp, int max )
{
int *pData = &m_nLayer;
for( int i=0; i<max; i++ )
{
pData[i] = pTemp[i];
}
return 1;
}
int CDungeonMap::Load( int layer )
{
int count=0;
char condition[512];
sprintf( condition, "map_name = '%s' AND layer = %d ", MapName, layer );
::GetRowLineOfSQL( "scenario_trap", "id", &count, condition );
if( count <= 0 ) return 0;
SetDungeonObject( count );
LoadDungeonTrap( m_pObject, layer );
return 1;
}
void CDungeonMap::Proc()
{
if( m_bActive )
{
m_nMessageCount --;
if( m_nMessageCount <= 0 )
{
m_nMessageCount = MESSAGE_COUNT;
if( m_nDungeonType == DT_PASSWORD )
{
// 鞠龋甫 啊福媚 霖促.
char data = m_nTrapCount;
if( m_nMessageOption )
::SendScenarioMessage(SEND_ALL, 3, &data, 1 );
}
else
{
//char data;
// m_nLayer
//SendScenarioMessage(SEND_ALL, 6, &data, 1 );
}
}
}
for( int i=0; i<m_nObjectCount; i++ )
{
m_pObject[i].CheckCloseTime();
}
}
int CDungeonMap::GetTrapCount( int &count, int &active_count , int &active_time )
{
count = 0;
active_count = 0;
active_time = 99999;
for( int i=0; i<m_nObjectCount; i++ )
{
if( m_pObject[i].m_nExecuteType == CDungeonObject::OET_NORMAL_TRAP )
{
count++;
if( m_pObject[i].m_bActive )
{
active_count++;
int going_time = g_curr_time - m_pObject[i].m_dwOpenTime;
int wait_time = (m_pObject[i].m_nTime - going_time)/60.0 + 0.5;
if( active_time > wait_time ) active_time = wait_time;
}
}
}
if( active_time == 99999 ) active_time = 0;
return 1;
}
int CDungeonMap::SetTrapKey( int count, CHARLIST *ch )
{
int total =0;
if( m_nDungeonType != DT_PASSWORD ) return 0;
for( int i=0; i<7; i++ )
{
if( !m_pKey[i] ) break;
total += m_pKey[i];
}
if( i == 7 ) return 0;
m_pKey[i] = count;
total += count;
if( i == 6 )
{
if( m_nTrapCount == total )
{
// 咀萍宏 矫挪促.
// 炼钦俊 己傍沁嚼聪促.
::SendScenarioMessage(SEND_ALL, 4, ch->Name, strlen(ch->Name)+1 );
for( int a=0; a<m_nObjectCount; a++ )
{
if( m_pObject[a].m_nNeedType == CDungeonObject::ONT_NEED_QUBE
|| m_pObject[a].m_nNeedType == CDungeonObject::ONT_NEED_QUBE2 )
{
m_pObject[a].SetActive( ch );
}
}
m_nMessageOption = 0;
return 1;
}
else
{
// 炼钦俊 撇啡扁 锭巩俊 贸澜何磐 促矫 矫累钦聪促.
::SendScenarioMessage(SEND_ALL, 5, ch->Name, strlen(ch->Name)+1 );
ResetKey();
return 0;
}
}
return 0;
}
int CDungeonMap::KillBoss( CHARLIST *user, CHARLIST *boss )
{
for( int i=0; i<m_nObjectCount; i++ )
{
m_pObject[i].KillBoss( user, boss );
}
return 1;
}
void CDungeonMap::OpenDragonRoadObject()
{
for( int i=0; i<m_nObjectCount; i++ )
{
if( m_pObject[i].m_nNeedType == CDungeonObject::ONT_NEED_DRAGON )
{
m_pObject[i].SetActive( NULL );
}
}
}
void CDungeonMap::CloseDragonRoadObject()
{
for( int i=0; i<m_nObjectCount; i++ )
{
if( m_pObject[i].m_nNeedType == CDungeonObject::ONT_NEED_DRAGON )
{
m_pObject[i].CloseObject();
}
}
}
int CDungeonMap::DeleteDragon() // 靛贰帮阑 茫酒 磷牢促.
{
for( int i=0; i<m_nObjectCount; i++ )
{
if( m_pObject[i].m_pBoss && m_pObject[i].IsDragonLoad() )
{
m_pObject[i].DeletBoss();
return 1;
}
}
return 0;
}
///////////////////////////////////////////////
void CDungeonMapMgr::GetOutDugeon( int type )
{
// ox_select // 函荐甫 捞侩茄促.
static char temp[DRAGON_MAX_CONNECTIONS_];
ZeroMemory( temp, DRAGON_MAX_CONNECTIONS_ );
switch( type )
{
case GOT_END_BOSS_POTAL :
{
if( !pPotalList ) return;
pPotalList->SetFind();
while( pPotalList->FindNext() )
{
temp[pPotalList->GetFind()] = 1;
}
DeletePotalMember();
break;
}
}
// 030211 YGI -------------
static char why_out[5][40] = // 恐 泼板绰瘤
{
" ",
"END_BOSS_POTAL",
"END_LAYER",
"END_SCENARIO",
"END_VOTE"
};
// ------------------------
CHARLIST *ch;
for( int i = DRAGON_CONNECTIONS_START; i < DRAGON_MAX_CONNECTIONS; i++ )
{
ch = CheckServerId( i );
if( !ch ) continue;
if( temp[i] ) continue;
::GotoUser( GetDungeonMap()->m_szOutMap, GetDungeonMap()->m_nOutX, GetDungeonMap()->m_nOutY, i );
MyLog( 0, "Dungeon Scenario : move user by '%s' [%s]<%s:%d:%d>", why_out[type], ch->Name, GetDungeonMap()->m_szOutMap, GetDungeonMap()->m_nOutX, GetDungeonMap()->m_nOutY );
}
}
int CDungeonMapMgr::DropDragonItem()
{
if( !pVoteFalse && !pVoteTrue ) return 0;
SAFE_DELETE(g_pDragonItem);
g_pDragonItem = new CScenarioDragonItem;
g_pDragonItem->DropDragonItem( pVoteTrue, pVoteFalse );
return 1;
}
int CDungeonMapMgr::EndUserFightByDragon()
{
// count1, count2甫 技焊绊 巢酒乐栏搁 矫埃捞 促登辑 场巢, 茄率捞 绝栏搁 场
// 寒阑 绝局霖促.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -