📄 op_magic.cpp
字号:
}
else
{ // 促弗 甘栏肺 厘家 捞悼
MapMove(pTarget->GetServerID(), (char*)strMapName.c_str(), nX, nY);
}
// 扁撅等 捞悼 厘家 沥焊 檬扁拳
pTarget->ClearTransMap();
}
/////////////////////////// 0111 捞痹绕 /////////////////////////////////
void SendCMD_MAGICTRAP_EXPOSE( t_server_magictrap_expose *p)
{
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICTRAP_EXPOSE;
packet.h.header.size = sizeof(t_server_magictrap_expose);
packet.u.angra.server_magictrap_expose.target_id = (short int)p->target_id;
packet.u.angra.server_magictrap_expose.x = (short int)p->x;
packet.u.angra.server_magictrap_expose.y = (short int)p->y;
packet.u.angra.server_magictrap_expose.trap_Type = (short int)p->trap_Type;
if(p->target_id<10000)
{
QueuePacket(connections, p->target_id, &packet, 1); //措惑眉俊霸 傈价
CastMe2Other( p->target_id, &packet ); //措惑眉甫 官扼焊绊 乐绰 葛电 PC
}
else
CastNPC2Other( p->target_id-10000, &packet );
}
void SendCMD_MAGIC_POSITION( t_server_magic_position *p)
{
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGIC_POSITION;
packet.h.header.size = sizeof(t_server_magic_position);
packet.u.angra.server_magic_position.nType= p->nType;
packet.u.angra.server_magic_position.idTarget = p->idTarget;
packet.u.angra.server_magic_position.nX = p->nX;
packet.u.angra.server_magic_position.nY = p->nY;
if (p->idTarget >= 10000)
{
CastNPC2Other(p->idTarget - 10000, &packet);
}
else
{
QueuePacket(connections, p->idTarget, &packet, 1); //措惑眉俊霸 傈价
CastMe2Other(p->idTarget, &packet); //措惑眉甫 官扼焊绊 乐绰 葛电 PC
}
}
void RecvCMD_CLIENT_CHARACTER_DEMAND(int cn, t_client_character_demand *p)
{ //< CSD-030515
CHARLIST* target = GetCharListPtr(p->target_id);
switch (p->command_type)
{
case CCD_PLAYSOUND_EVENT1:
{ // 青荤澜厩 免仿 夸没
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = 851;
packet.u.angra.server_magic_command.sub_command = 0;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, cn, &packet, 1);
break;
}
case CCD_PLAYSOUND_EVENT2:
{ // 冠荐家府 夸没
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = 853;
packet.u.angra.server_magic_command.sub_command = 0;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, cn, &packet, 1);
break;
}
case CCD_START_QUEST:
{ // 涅胶飘 矫累澜厩 免仿 夸没
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = CCD_START_QUEST;
packet.u.angra.server_magic_command.sub_command = 0;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, p->target_id, &packet, 1);
break;
}
case CCD_END_QUEST:
{ // 涅胶飘 辆丰 免仿 夸没
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = CCD_END_QUEST;
packet.u.angra.server_magic_command.sub_command = 0;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, p->target_id, &packet, 1);
break;
}
case CCD_QUEST_SALUTE:
{
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = CCD_QUEST_SALUTE;
packet.u.angra.server_magic_command.sub_command = p->target_id;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, p->target_id, &packet, 1);
break;
}
case CCD_QUEST_GETSKILL:
{ // 涅胶飘 扁贱裙垫 免仿 夸没
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = CCD_QUEST_GETSKILL;
packet.u.angra.server_magic_command.sub_command = 0;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, p->target_id, &packet, 1);
break;
}
case CCD_QUEST_GETITEM:
{ // 涅胶飘 酒捞袍裙垫 免仿 夸没
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = CCD_QUEST_GETITEM;
packet.u.angra.server_magic_command.sub_command = 0;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, p->target_id, &packet, 1);
break;
}
case CCD_QUEST_MONSTER:
{ // 涅胶飘 阁胶磐狼 魔涝
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = CCD_QUEST_MONSTER;
packet.u.angra.server_magic_command.sub_command = 0;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, cn, &packet, 1);
break;
}
case CCD_START_QUEST_BBS:
{ // 傍磊荤亲(急器)
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = CCD_START_QUEST_BBS;
packet.u.angra.server_magic_command.sub_command = 0;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, cn, &packet, 1);
break;//葛电 立加磊俊霸 傈崔
}
case CCD_END_QUEST_BBS: //傍磊荤亲(辆丰) 惑炔 辆丰.
{
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = CCD_END_QUEST_BBS;
packet.u.angra.server_magic_command.sub_command = 0;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, cn, &packet, 1);
break;
}
case CCD_COMPLETE_QUEST:
{ // 涅胶飘甫 付公府 沁阑锭 瓤苞
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICCOMMAND;
packet.h.header.size = sizeof(t_server_magic_command);
packet.u.angra.server_magic_command.command = CCD_COMPLETE_QUEST;
packet.u.angra.server_magic_command.sub_command = p->target_id;
packet.u.angra.server_magic_command.sub_term = 0;
QueuePacket(connections, cn, &packet, 1);
break;
}
case CCD_FIGHT_LOSE: // 1:1 措搬葛靛牢 版快..
{ // 柳版快
Fight_Stone_End(cn, 1);
break;
}
case CCD_FIGHT_DRAW:
{ // 厚变版快
Fight_Stone_End(cn, 3);
break;
}
case CCD_FIGHT_LOGOUT:
{ // 肺弊酒眶茄 版快
Fight_Stone_End(cn, 4);
break;
}
}
} //> CSD-030515
void LoadConditionTable(void)
{
FILE* file;
int buff = 0;
char DataPath[MAX_PATH];
wsprintf( DataPath, "%s/data/condition_table.txt", GameServerDataPath );
file = fopen( DataPath, "rt");
if(file)
{
for(int i=0; i<8; i++)
for(int j=0; j<8; j++)
fscanf(file, "%d", &g_Condition_Table[i][j] );
fclose(file);
file=fopen("./OutPut/condition_table.bin", "wb" );
if(file)
{
fwrite( g_Condition_Table, sizeof(int), 64, file);
fclose(file);
}
}
else
{
file = fopen( "./OutPut/condition_table.bin", "rb" );
if(file)
{
fread( g_Condition_Table, sizeof(int), 64, file);
fclose(file);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// 担 汲摹 包访 窃荐(0111) //
///////////////////////////////////////////////////////////////////////////////////////////////////
void InitTrap()
{
memset(g_lpMagicTrap, 0, sizeof(g_lpMagicTrap));
}
BOOL InsertTrap(short int tile_X, short int tile_Y, short int trap_Type, DWORD continue_Time)
{
if (tile_X < 0) return FALSE;
if (tile_Y < 0) return FALSE;
if (tile_X >= g_Map.file.wWidth - 1) return FALSE;
if (tile_Y >= g_Map.file.wHeight -1) return FALSE;
LPTILE tile = &TileMap[tile_X][tile_Y];
if (tile == NULL) return FALSE;
if (tile->attr_dont) return FALSE;
if (tile->attr_magic) return FALSE;
if (tile->attr_inside) return FALSE;
if (tile->attr_map) return FALSE;
if (tile->occupied) return FALSE;
if (tile->attr_light) return FALSE;
tile->attr_magic = 1;
// 傈开 硅版 鸥老 加己俊 飘乏 汲摹 加己 何咯
g_MagicTrap.trap_X = tile_X;
g_MagicTrap.trap_Y = tile_Y;
g_MagicTrap.trap_Type = trap_Type;
g_MagicTrap.Time = continue_Time;
AddTrap(&g_lpMagicTrap[tile_X/((g_Map.file.wWidth+7)/8)][tile_Y/((g_Map.file.wHeight+7)/8)], &g_MagicTrap);
return TRUE;
}
void AddTrap( LPMAGICTRAP *Header, LPMAGICTRAP lpMagicTrap_add ) //傅农靛 府胶飘狼 赣府俊 嘿咯 持扁
{
LPMAGICTRAP t, temp;
if( *Header == NULL ) //傅农靛 府胶飘 弥檬 积己
{
MemAlloc( *Header, sizeof( MAGICTRAP ));
(*Header)->trap_X = lpMagicTrap_add->trap_X;
(*Header)->trap_Y = lpMagicTrap_add->trap_Y;
(*Header)->trap_Type = lpMagicTrap_add->trap_Type;
(*Header)->Time = lpMagicTrap_add->Time;
(*Header)->prev = NULL;
(*Header)->next = NULL;
}
else //捞固 积己等 府胶飘俊 梅啊 楷搬/肺爹秦柯 单捞磐啊 乐阑 版快
{
t = NULL;
MemAlloc( t, sizeof( MAGICTRAP ));
t->trap_X = lpMagicTrap_add->trap_X;
t->trap_Y = lpMagicTrap_add->trap_Y;
t->trap_Type = lpMagicTrap_add->trap_Type;
t->Time = lpMagicTrap_add->Time;
temp = *Header ;
temp->prev = t;
t->next = temp;
t->prev = NULL;
*Header = t;
}
}
void DeleteTrap( LPMAGICTRAP *Header, LPMAGICTRAP lpMagicTrap_Delete)
{
LPMAGICTRAP t = *Header;//g_lpMapSkillTable;
while( t != NULL )
{
if( t == lpMagicTrap_Delete )
{
if( lpMagicTrap_Delete == *Header ) //header啊 力芭登绰 版快
{
t = (*Header)->next;
if(*Header!=NULL)
MemFree( *Header );
if(t!=NULL)
{
*Header = t;
(*Header)->prev = NULL;
}
return;
}
else
{
if ( t->prev != NULL )
{
t->prev->next = t->next;
}
if( t->next != NULL )
{
t->next->prev = t->prev;
}
MemFree( t );
return;
}
}
t= t->next;
}
}
// 甘篮 例措谅钎...7
LPMAGICTRAP FindTrap( LPMAGICTRAP *Header, short int tile_X, short int tile_Y )
{
LPMAGICTRAP t;
t = *Header;
while( t != NULL )
{
if( t->trap_X == tile_X && t->trap_Y == tile_Y )
{
return t;
}
t = t->next;
}
return NULL;
}
bool SearchTrap(CHARLIST* pCaster, int nX, int nY)
{ // 努腐茄 瘤痢狼 瘤抚 5鸥老 瘤开俊 付过栏肺 拱扒/怠/付过眉 沤瘤
for (int i = -2; i < 3; i++)
{
const int nFindX = nX + i;
for (int j = -2; j < 3; j++)
{
const int nFindY = nY + j;
if (TileMap[nFindX][nFindY].attr_magic == 1)
{ // 付过 瓤苞 乐绰 版快
LPMAGICTRAP lpHeader = g_lpMagicTrap[nFindX/((g_Map.file.wWidth+7)/8)][nFindY/((g_Map.file.wHeight+7)/8)];
LPMAGICTRAP lpMagicTrap = FindTrap(&lpHeader, nFindX, nFindY);
if (lpMagicTrap != NULL)
{ //茫篮 飘乏捞 乐绰 版快
t_packet packet;
packet.h.header.type = CMD_SERVER_MAGICAL_DETECT;
packet.h.header.size = sizeof(t_server_magical_detect);
packet.u.angra.server_magical_detect.tile_X = nFindX;
packet.u.angra.server_magical_detect.tile_Y = nFindY;
packet.u.angra.server_magical_detect.type = MAGIC_TRAP;
// 措惑眉俊霸 搬苞 傈价
QueuePacket(connections, pCaster->GetServerID(), &packet, 1);
return true;
}
}
}
}
return false;
}
void SendExposeTrap(CHARLIST* lpChar, short int tile_X, short int tile_Y, short int trap_Type) //单固瘤 贸府 棺 瓤苞楷免配废 努扼捞攫飘俊 沥焊 傈价
{
t_server_magictrap_expose server_magictrap_expose;
if (lpChar->SprType == SPRITETYPE_NPC)
{
server_magictrap_expose.target_id = lpChar->GetServerID() + 10000;
}
else
{
server_magictrap_expose.target_id = lpChar->GetServerID();
}
server_magictrap_expose.x = (short int)tile_X;
server_magictrap_expose.y = (short int)tile_Y;
server_magictrap_expose.trap_Type = (short int)trap_Type;
SendCMD_MAGICTRAP_EXPOSE( &server_magictrap_expose );
}
void CheckTimeTrap(void)
{
static DWORD time;
if( g_curr_time - time < 10 ) return;
time = g_curr_time;
LPMAGICTRAP magictrap, t;
for(int i=0;i<8;i++)
{
for(int j=0;j<8;j++)
{
magictrap = g_lpMagicTrap[i][j];
while(magictrap!=NULL)
{
if(magictrap->Time <= g_curr_time)
{
TileMap[magictrap->trap_X][magictrap->trap_Y].attr_magic = 0; //蜡瓤 矫埃 版苞茄 版快
t = magictrap->next;
DeleteTrap(&g_lpMagicTrap[i][j], magictrap);
magictrap=t;
continue;
}
magictrap=magictrap->next;
}
}
}
}
void NPCLostSight(CHARLIST *target, int Time)
{
target->ApplyCurse(4, CON_SLOW, g_curr_time + Time);
}
BOOL ReturnSuccessResult(int small_Dice, int big_Dice, CHARLIST *caster)
{
short int wisdom = caster->Wis; //max:500
short int intelligence= caster->Int; //max:500
short int WS_PS = caster->wsps; //max:500
short int total_Rate = (wisdom+intelligence+WSPS)/100; //己傍犬伏狼 焊沥(歹窍绰蔼) -> 0~50鳖瘤 荐摹
big_Dice += total_Rate;
rollDice(small_Dice, dice1) ;
rollDice(big_Dice, dice2) ;
if (dice1 <= dice2)
{
return TRUE;
}
return FALSE;
}
void Recv_fight_stone(int cn, t_packet packet) //cn 菩哦阑 焊辰 哪..
{ //< CSD-030515
const int attack_id = cn;
const int defend_id = packet.u.angra.server_fight_stone.fight_id; //轿快绰 仇俊霸档 flag甫 拎具..
CHARLIST* attacker = CheckServerId(attack_id);
if (attacker == NULL)
{
return;
}
if(attacker->fight_flag!=1)
{
attacker->fight_flag = packet.u.angra.server_fight_stone.fight_flag;
attacker->fight_id = defend_id;
}
CHARLIST* defender = CheckServerId(defend_id);
if (defender == NULL)
{
return;
}
if(defender->fight_flag!=1)
{
defender->fight_flag = packet.u.angra.server_fight_stone.fight_flag;
defender->fight_id = attack_id;
}
} //> CSD-030515
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -