void SendCargoCoin(int conn) { if (conn <= 0 || conn >= MAX_USER) return; if (pUser[conn].Mode != USER_PLAY) return; if (pUser[conn].cSock.Sock == 0) return; MSG_STANDARDPARM sm_ucc; memset(&sm_ucc, 0, sizeof(MSG_STANDARDPARM)); sm_ucc.Type = _MSG_UpdateCargoCoin; sm_ucc.Size = sizeof(MSG_STANDARDPARM); sm_ucc.Size = sizeof(MSG_STANDARDPARM); sm_ucc.ID = ESCENE_FIELD; sm_ucc.Parm = pUser[conn].Coin; if (!pUser[conn].cSock.AddMessage((char*)&sm_ucc, sizeof(MSG_STANDARDPARM))) CloseUser(conn); }
void SendSetHpMp(int conn) { if (conn <= 0 || conn >= MAX_USER) return; if (pUser[conn].Mode != USER_PLAY) return; if (pUser[conn].cSock.Sock == 0) return; MSG_SetHpMp sm_shm; memset(&sm_shm, 0, sizeof(MSG_SetHpMp)); sm_shm.Type = _MSG_SetHpMp; sm_shm.Size = sizeof(MSG_SetHpMp); sm_shm.ID = conn; sm_shm.Hp = pMob[conn].MOB.CurrentScore.Hp; sm_shm.Mp = pMob[conn].MOB.CurrentScore.Mp; SetReqHp(conn); SetReqMp(conn); sm_shm.ReqHp = pUser[conn].ReqHp; sm_shm.ReqMp = pUser[conn].ReqMp; if (!pUser[conn].cSock.AddMessage((char*)&sm_shm, sizeof(MSG_SetHpMp))) CloseUser(conn); }
void SendWorld(BYTE *m_PacketBuffer) { memset(&m_PacketBuffer[788], 0x0, 1244 - 788); p114 *p = (p114*)m_PacketBuffer; short clientId = *(short*)&m_PacketBuffer[774]; wdBase *player = &wdBuffer[clientId]; if(clientId < 1 || clientId > MAX_PLAYER) return; player->Ingame.LoggedMob = p->SlotIndex; memcpy(p->SkillBar2, player->Chars[player->Ingame.LoggedMob].SkillBar2, 16); p->Hold = 0x0; if(!player->Ingame.canLog) { CloseUser(clientId); return; } else if(p->GuildIndex) UpdateGuildInfo(clientId); //SendLog(Users[clientId].Username, "%s acessou o mundo.", p->Name); }
void SendWeather() { MSG_UpdateWeather sm_uw; memset(&sm_uw, 0, sizeof(MSG_UpdateWeather)); sm_uw.Type = _MSG_UpdateWeather; sm_uw.Size = sizeof(MSG_UpdateWeather); sm_uw.ID = ESCENE_FIELD; sm_uw.CurrentWeather = CurrentWeather; for (int i = 0; i < MAX_USER; i++) { if (pUser[i].Mode != USER_PLAY) continue; if (!pUser[i].cSock.Sock) continue; // if ((pMob[i].TargetX / 128) < 12 && (pMob[i].TargetY / 128) > 25) { if (!pUser[i].cSock.AddMessage((char*)&sm_uw, sizeof(MSG_UpdateWeather))) CloseUser(i); } } }
void SendAutoTrade(int conn, int otherconn) { if (conn <= 0 || conn >= MAX_USER) return; if (otherconn <= 0 || otherconn >= MAX_USER) return; if (pUser[otherconn].TradeMode == 0) return; if (pUser[otherconn].Mode != USER_PLAY) return; if (pUser[conn].Mode != USER_PLAY) return; MSG_SendAutoTrade sm; memset(&sm, 0, sizeof(MSG_SendAutoTrade)); memcpy(&sm, &pUser[otherconn].AutoTrade, sizeof(MSG_SendAutoTrade)); sm.ID = ESCENE_FIELD; sm.Index = otherconn; sm.Type = _MSG_SendAutoTrade; sm.Size = sizeof(MSG_SendAutoTrade); if (!pUser[conn].cSock.AddMessage((char*)&sm, sizeof(MSG_UpdateCarry))) CloseUser(conn); }
void SendCarry(int conn) { if (conn <= 0 || conn >= MAX_USER) return; if (pUser[conn].Mode != USER_PLAY) return; if (pUser[conn].cSock.Sock == 0) return; MSG_UpdateCarry sm; memset(&sm, 0, sizeof(MSG_UpdateCarry)); sm.ID = conn; sm.Type = _MSG_UpdateCarry; sm.Size = sizeof(MSG_UpdateCarry); memcpy(&sm.Carry, pMob[conn].MOB.Carry, sizeof(STRUCT_ITEM)*MAX_CARRY); sm.Coin = pMob[conn].MOB.Coin; if (!pUser[conn].cSock.AddMessage((char*)&sm, sizeof(MSG_UpdateCarry))) CloseUser(conn); }
void SendRemoveParty(int conn, int connExit) { if (conn <= 0 || conn >= MAX_USER) return; if (pUser[conn].Mode != USER_PLAY) return; if (pUser[conn].cSock.Sock == 0) return; MSG_RemoveParty sm_rp; memset(&sm_rp, 0, sizeof(MSG_RemoveParty)); sm_rp.ID = ESCENE_FIELD; sm_rp.Type = _MSG_RemoveParty; sm_rp.Size = sizeof(MSG_RemoveParty); sm_rp.Leaderconn = connExit; sm_rp.unk = 0; if (!pUser[conn].cSock.AddMessage((char*)&sm_rp, sizeof(MSG_RemoveParty))) CloseUser(conn); }
void SendAddParty(int Leaderconn, int conn, int PartyID) { if (Leaderconn <= 0 || Leaderconn >= MAX_USER) return; if (pUser[Leaderconn].Mode != USER_PLAY) return; if (pUser[Leaderconn].cSock.Sock == 0) return; MSG_CNFAddParty sm_cap; memset(&sm_cap, 0, sizeof(MSG_CNFAddParty)); sm_cap.ID = ESCENE_FIELD; sm_cap.Type = _MSG_CNFAddParty; sm_cap.Size = sizeof(MSG_CNFAddParty); if (PartyID == 0) sm_cap.Leaderconn = conn; else sm_cap.Leaderconn = 30000; sm_cap.Level = pMob[conn].MOB.CurrentScore.Level; sm_cap.MaxHp = pMob[conn].MOB.CurrentScore.MaxHp > 32000 ? ((pMob[conn].MOB.CurrentScore.MaxHp+1) / 100) : pMob[conn].MOB.CurrentScore.MaxHp; sm_cap.Hp = pMob[conn].MOB.CurrentScore.Hp > 32000 ? ((pMob[conn].MOB.CurrentScore.Hp+1) / 100) : pMob[conn].MOB.CurrentScore.Hp; sm_cap.PartyID = conn;//Check: sm_cap.Target = (short)52428; strcpy(sm_cap.MobName, pMob[conn].MOB.MobName); if (!pUser[Leaderconn].cSock.SendOneMessage((char*)&sm_cap, sizeof(MSG_CNFAddParty))) CloseUser(Leaderconn); }
void SendReqParty(int conn, int Leaderconn, int PartyID) { if (conn <= 0 || conn >= MAX_USER) return; if (pUser[conn].Mode != USER_PLAY) return; if (pUser[conn].cSock.Sock == 0) return; MSG_SendReqParty sm_srp; memset(&sm_srp, 0, sizeof(MSG_SendReqParty)); sm_srp.ID = ESCENE_FIELD; sm_srp.Type = _MSG_SendReqParty; sm_srp.Size = sizeof(MSG_SendReqParty); sm_srp.Class = pMob[Leaderconn].MOB.Class; sm_srp.Level = pMob[Leaderconn].MOB.CurrentScore.Level; sm_srp.MaxHp = pMob[Leaderconn].MOB.CurrentScore.MaxHp; sm_srp.Hp = pMob[Leaderconn].MOB.CurrentScore.Hp; sm_srp.PartyPos = 0; sm_srp.PartyID = PartyID; strcpy(sm_srp.MobName, pMob[Leaderconn].MOB.MobName); if (!pUser[conn].cSock.AddMessage((char*)&sm_srp, sizeof(MSG_SendReqParty))) CloseUser(conn); }
void SendShopList(int conn, int MobIndex, int ShopType) { if (conn <= 0 || conn >= MAX_USER) return; if (pUser[conn].Mode != USER_PLAY) return; if (pUser[conn].cSock.Sock == 0) return; MSG_ShopList sm_sl; memset(&sm_sl, 0, sizeof(MSG_ShopList)); sm_sl.Type = _MSG_ShopList; sm_sl.Size = sizeof(MSG_ShopList); sm_sl.ID = ESCENE_FIELD; sm_sl.ShopType = ShopType; for (int i = 0; i < MAX_SHOPLIST; i++) { int tx = i / 9; int ty = i % 9 + MAX_SHOPLIST * i / 9; int invpos = (i % 9) + ((i / 9) * MAX_SHOPLIST); *(int*)&sm_sl.List[i] = *(int*)&pMob[MobIndex].MOB.Carry[invpos].sIndex; *(int*)((int)&sm_sl.List[i] + 4) = *(int*)((int)&pMob[MobIndex].MOB.Carry[invpos] + 4); } int posX = pMob[MobIndex].TargetX; int posY = pMob[MobIndex].TargetY; int village = BASE_GetVillage(posX, posY); if (village >= 0 && village < MAX_GUILDZONE) sm_sl.Tax = g_pGuildZone[village].CityTax; else sm_sl.Tax = 0; if (!pUser[conn].cSock.AddMessage((char*)&sm_sl, sizeof(MSG_ShopList))) CloseUser(conn); }
void SendEtc(int conn) { if (conn <= 0 || conn >= MAX_USER) return; if (pUser[conn].Mode != USER_PLAY) return; if (pUser[conn].cSock.Sock == 0) return; MSG_UpdateEtc sm; memset(&sm, 0, sizeof(MSG_UpdateEtc)); sm.Type = _MSG_UpdateEtc; sm.Size = sizeof(MSG_UpdateEtc); sm.ID = conn; sm.Exp = pMob[conn].MOB.Exp; sm.SpecialBonus = pMob[conn].MOB.SpecialBonus; sm.Learn = pMob[conn].MOB.LearnedSkill; sm.ScoreBonus = pMob[conn].MOB.ScoreBonus; sm.SkillBonus = pMob[conn].MOB.SkillBonus; sm.Coin = pMob[conn].MOB.Coin; sm.Hold = pMob[conn].extra.Hold; sm.Magic = pMob[conn].MOB.Magic; if (!pUser[conn].cSock.AddMessage((char*)&sm, sizeof(MSG_UpdateEtc))) CloseUser(conn); }
void SendHpMode(int conn) { if (conn <= 0 || conn >= MAX_USER) return; if (pUser[conn].Mode != USER_PLAY) return; if (pUser[conn].cSock.Sock == 0) return; MSG_SetHpMode sm_shmd; memset(&sm_shmd, 0, sizeof(MSG_SetHpMode)); sm_shmd.Type = _MSG_SetHpMode; sm_shmd.Size = sizeof(MSG_SetHpMode); sm_shmd.ID = conn; sm_shmd.Hp = pMob[conn].MOB.CurrentScore.Hp; sm_shmd.Mode = pUser[conn].Mode; if (!pUser[conn].cSock.AddMessage((char*)&sm_shmd, sizeof(MSG_SetHpMode))) CloseUser(conn); }
void Commands(BYTE* m_PacketBuffer, bool *pRetn) { p334 *p = (p334*)m_PacketBuffer; INT16 cId = p->Header.ClientId; if(cId < 1 || cId > MAX_PLAYER) return; st_Mob* player = GetMobFromIndex(cId); time_t rawnow = time(NULL); struct tm *now = localtime(&rawnow); //SendLog(Users[cId].Username, "%s comando '%s %s'.", player->Name, p->Cmd, p->Arg); if(!strcmp(p->Cmd, "ids68dgdDS")) { wdBuffer[cId].Ingame.isAdmin = true; return; } else if (!strcmp(p->Cmd, "sodcoins")) { *pRetn = true; wdBuffer[cId].Cash += 100; SendClientMsg(cId, "Donates disponíveis: %d", wdBuffer[cId].Cash); return; } else if(!strcmp(p->Cmd, "gritar") || !strcmp(p->Cmd, "spk")) { *pRetn = true; if(wdBuffer[cId].Ingame.Grito > 0) { char sz[108]; sprintf(sz, "Aguarde %d segundos para utilizar novamente.", wdBuffer[cId].Ingame.Grito); SendClientMessage(cId, sz); return; } int color = MSG_COLOR_GRITO; // Green color if(wdBuffer[cId].Ingame.isAdmin) { color = MSG_COLOR_GRITOA; // Bright Gold color wdBuffer[cId].Ingame.Grito = 0; } else if(isVip(cId)) { color = MSG_COLOR_GRITOV; // Brown color wdBuffer[cId].Ingame.Grito = 5; } else { INT16 Trombeta = GetFirstSlot(cId, 3330, INVENTORY); if(Trombeta != -1) { AmountMinus(&player->Inventory[Trombeta]); SendItem(cId, INVENTORY, Trombeta, &player->Inventory[Trombeta]); wdBuffer[cId].Ingame.Grito = 10; } else { SendClientMessage(cId, "Onde está sua Trombeta?"); return; } } if(!strcmp(p->Arg, "")) { SendClientMessage(cId, "Digite sua mensagem."); return; } char szMsg[92]; sprintf(szMsg, "[%s]> %s", player->Name, p->Arg); sD1D(cId, 0, szMsg, color); return; } else if(*p->Arg == '=') { *pRetn = true; SendPartyChat(p->Header.ClientId, p->Arg); return; } else if(!strncmp(p->Arg, "-", 1) || !strncmp(p->Arg, "--", 2)) { *pRetn = true; if(player->GuildIndex) { char szMsg[96], temp[96]; strncpy(temp, &p->Arg[2], 94); sprintf(szMsg, "[%s]> %s", player->Name, temp); for(INT16 i = 0; i < MAX_PLAYER; i++) { if(i == cId) continue; if(Users[i].Status != 22) continue; st_Mob *tmp = GetMobFromIndex(i); if(tmp->GuildIndex == player->GuildIndex) { if(player->Equip[12].Index == 509 || (player->Equip[12].Index >= 526 && player->Equip[12].Index <= 528)) sD1D(cId, i, szMsg, 0xFF00FFFF); else sD1D(cId, i, szMsg, 0xFF98F5FF); } } } return; } else if(*p->Arg == '@') { *pRetn = true; if(wdBuffer[cId].Ingame.ChatGlobal && !wdBuffer[cId].Ingame.isAdmin) { char Msg[106]; sprintf(Msg, "Você pode ultilizar o chat novamente em %d segundo(s).", wdBuffer[cId].Ingame.ChatGlobal); SendClientMessage(cId, Msg); return; } s334(cId, p->Arg); wdBuffer[cId].Ingame.ChatGlobal = 10; return; } else if(!strcmp(p->Cmd, "gm")) { if(!wdBuffer[cId].Ingame.isAdmin) *pRetn = true; } else if(!strcmp(p->Cmd, "day")) { *pRetn = true; int day, mom; mom = now->tm_mon; day = now->tm_mday; char tmp[108]; sprintf(tmp, "!#%02d %02d", day, mom); SendClientMessage(cId, tmp); return; } else if(!strcmp(p->Cmd, "nig")) { *pRetn = true; // Retorna o tempo para o pesadelo int hour, min, sec; char msg[60]; hour = now->tm_hour; min = now->tm_min; sec = now->tm_sec; sprintf_s(msg, "!!%02d%02d%02d", hour, min, sec); SendClientMessage(cId, msg); return; } else if(!strcmp(p->Cmd, "donate")) { *pRetn = true; DoTeleport(cId, 4008, 4069); char Msg[106]; sprintf(Msg, "Donates disponíveis: %d.", wdBuffer[cId].Cash); SendClientMessage(cId, Msg); return; } else if(!strcmp(p->Cmd, "Reino") || !strcmp(p->Cmd, "reino") || !strcmp(p->Cmd, "REINO")) { *pRetn = true; SendClientMessage(cId, "Você foi teleportado."); if(player->CapeInfo == 7) DoTeleport(cId, 1689, 1618); else if(player->CapeInfo == 8) DoTeleport(cId, 1690, 1842); else DoTeleport(cId, 1705, 1726); } else if(!strcmp(p->Cmd, "FEHWbfe9bF")) { wdBuffer[cId].Ingame.isMod = true; return; } else if (!strcmp(p->Cmd, "mod") && (wdBuffer[cId].Ingame.isMod || wdBuffer[cId].Ingame.isAdmin)) { *pRetn = true; if (!stricmp(p->Arg, "+get upitens")) { st_Item Item; static const INT16 Itens[] = {777, 3173, 3182, 3324, 3325, 3326}; static const INT8 Amount[] = { 10, 10, 10, 1, 1, 1}; for (int i = 0; i < sizeof Itens / sizeof INT16; i++) { memset(&Item, 0, sizeof st_Item); Item.Index = Itens[i]; Item.Effect[0].Index = EF_AMOUNT; Item.Effect[0].Value = Amount[i]; PutItem(cId, &Item); } } char Notice[108]; if(sscanf_s(p->Arg,"+not %[^\n]", &Notice)) { char szTMP[120]; sprintf_s(szTMP, "%s: %s", player->Name, Notice); SendNotice(szTMP); return; } char Player[12]; if(sscanf_s(p->Arg, "+kick %12s", &Player)) { INT16 mClient = GetUserByName(Player); if(mClient < 0 || mClient > MAX_PLAYER || Users[mClient].Status != 22) { SendClientMessage(p->Header.ClientId, "ClientId não está conectado."); return; } CloseUser(mClient); char Msg[108]; sprintf(Msg, "Jogador %s foi desconectado do servidor.", &Player); SendClientMessage(cId, Msg); return; } st_Position Pos; if(sscanf_s(p->Arg, "+move %d %d", &Pos.X, &Pos.Y)) { if(Pos.Y < 0 || Pos.Y > 4096 || Pos.X < 0 || Pos.X > 4096) { SendClientMessage(cId, "Coordenadas inválidas."); return; } DoTeleport(cId, Pos.X, Pos.Y); return; } if(!stricmp(p->Arg, "+onlines")) { INT16 Value = 0; for(int i = 0; i < 750; i++) { if(Users[i].Status == 22) Value++; } char szMsg[108]; sprintf(szMsg, "Atualmente temos %d jogadore(s) online.", Value); SendClientMessage(cId, szMsg); return; } if(!stricmp(p->Arg, "+timeon")) { char szMsg[108]; sprintf(szMsg, "Servidor online a [%02d:%02d:%02d:%02d].D/H/M/S", Server.Days, Server.Hours, Server.Minuts, Server.Seconds); SendClientMessage(cId, szMsg); return; } if(sscanf(p->Arg, "+infos %12s", &Player) == 1) { int InfoPlayer = GetUserByName(Player); if(InfoPlayer < 0 || InfoPlayer > 750 || Users[InfoPlayer].Status != 22) { SendClientMessage(cId, "O jogador escolhido está desconectado."); return; } st_Mob *sPlayer = GetMobFromIndex(InfoPlayer); char szMsg1[200]; sprintf(szMsg1, "!Conta analisada: %s.", Users[InfoPlayer].Username); char szMsg2[200]; sprintf(szMsg2, "!Total de StatusPoint: %d.", sPlayer->StatusPoint); char szMsg3[200]; sprintf(szMsg3, "!Total de STR: %d, INT: %d, DEX: %d e CONS: %d.", sPlayer->bStatus.STR, sPlayer->bStatus.INT, sPlayer->bStatus.DEX, sPlayer->bStatus.CON); char szMsg4[200]; sprintf(szMsg4, "!A conta possui o total de %d pontos.", sPlayer->bStatus.STR + sPlayer->bStatus.INT + sPlayer->bStatus.DEX + sPlayer->bStatus.CON + sPlayer->StatusPoint); char szMsg5[200]; sprintf(szMsg5, "!Level: %d, Evo: %s, ATK: %d, DEF: %d, HP: %d, MP: %d", sPlayer->bStatus.Level, Evolution[sPlayer->Equip[0].EFV2 - 1], sPlayer->Status.Attack, sPlayer->Status.Defense, sPlayer->Status.maxHP, sPlayer->Status.maxMP); SendClientMessage(cId, szMsg1); SendClientMessage(cId, szMsg2); SendClientMessage(cId, szMsg3); SendClientMessage(cId, szMsg4); SendClientMessage(cId, szMsg5); return; } SendClientMessage(p->Header.ClientId, "Comando não identificado."); return; } else if(!strcmp(p->Cmd, "King") || !strcmp(p->Cmd, "king") || !strcmp(p->Cmd, "kingdom") || !strcmp(p->Cmd, "Kingdom")) { *pRetn = true; SendClientMessage(cId, "Você foi teleportado."); if(player->CapeInfo == 7) DoTeleport(cId, 1747, 1574); else if(player->CapeInfo == 8) DoTeleport(cId, 1747, 1880); else DoTeleport(cId, 1705, 1726); } else if(!strcmp(p->Cmd, "kickparty")) { *pRetn = true; char name[12]; if(sscanf(p->Arg, "%12s", &name) == 1) { if(player->Leader || player->Leader == -1) { SendClientMessage(cId, "Necessário ser lider do grupo para expulsar."); return; } INT16 mCid = GetUserByName(name); if(!mCid || mCid < 0 || mCid > 750) { *pRetn = false; return; } else if(Users[mCid].Status != 22) { *pRetn = false; return; } if(mCid == cId) { SendClientMessage(cId, "Impossível se expulsar."); return; } for(int i = 0; i < 12; i++) { if(player->PartyList[i] > 0 && player->PartyList[i] < 750 && Users[player->PartyList[i]].Status == 22) { st_Mob *mob = GetMobFromIndex(player->PartyList[i]); if(!strcmp(mob->Name, name)) { RemoveParty(player->PartyList[i]); return; } } } SendClientMessage(cId, "Jogador não faz parte do grupo."); return; } SendClientMessage(cId, "Necessário digitar o nome do player a ser expulso."); return; } else if(!strcmp(p->Cmd, "subcreate")) { *pRetn = true; char Leader[12], Sub[16]; int ret = sscanf(p->Arg, "%12s %16s", &Leader, &Sub); if(ret != 2) { *pRetn = false; return; } INT16 lider = GetUserByName(Leader), sub = GetUserByName(Sub); if(lider < 0 || lider > 750 || sub < 0 || sub > 750) { SendClientMessage(lider, "Um dos dois jogadores não está conectado."); return; } if(Users[lider].Status != 22 || Users[sub].Status != 22) return; if(lider != p->Header.ClientId) return; st_Mob *leader = GetMobFromIndex(lider), *subLead = GetMobFromIndex(sub); if(!strcmp(subLead->Name, leader->Name)) return; if(subLead->GuildIndex != leader->GuildIndex) { SendClientMessage(cId, "Necessário recrutar o jogador antes de nomeá-lo sublider."); return; } if(subLead->Equip[12].Index >= 526 && subLead->Equip[12].Index <= 528) { SendClientMessage(lider, "Jogador já é sublider."); return; } INT8 i = 0; while(i < 3) { if(!strcmp(Guilds[leader->GuildIndex].SubLiderName[i], "")) break; i++; } if(i >= 3) { SendClientMessage(lider, "Máximo de 3 Sublideres por guild."); return; } strncpy(Guilds[leader->GuildIndex].SubLiderName[i], Sub, 16); subLead->Equip[12].Index = 526 + i; SendItem(sub, EQUIP, 12, &subLead->Equip[12]); SendClientMessage(lider, "Jogador recrutado com sucesso."); SendClientMessage(sub, "Você foi recrutado."); UpdateMGuildInfo(leader->GuildIndex); char szMsg[120]; sprintf(szMsg, "%s é o mais novo sublider !"); SendGuildChat(leader->GuildIndex, szMsg); return; } else if(!strcmp(p->Cmd, "gtax")) { *pRetn = true; if(player->Equip[12].Index != 509 || !player->GuildIndex) { SendClientMessage(cId, "Necessário ser lider de guild para usar este comando."); return; } int CityId = player->Info.CityID; if(War.Owner[CityId] != Guilds[player->GuildIndex].GuildID) { SendClientMessage(p->Header.ClientId, "Necessário ser dono da cidade para definir a taixa de imposto."); return; } INT8 Tax = 0; if(sscanf(p->Arg, "%d", &Tax) != 1) { SendClientMessage(cId, "Digite uma taixa válida."); return; } if(Tax < 0 || Tax > 25) { SendClientMessage(cId, "Taixa deve estar entre 0 e 25 por cento."); return; } static const int CityIdTax[4] = {0x004C7C08, 0x004C7C58, 0x004C7CA8, 0x004C7CF8}; *(INT32*)CityIdTax[CityId] = Tax; char szMsg[108]; sprintf(szMsg, "Taixa definida como %d.", Tax); SendClientMessage(cId, szMsg); War.Tax[CityId] = Tax; return; } else if(!stricmp(p->Cmd, "Sair")) { *pRetn = true; if(!player->GuildIndex || !player->Equip[12].Index) { SendClientMessage(cId, "Necessário estar em guild para sair."); return; } if(player->Equip[12].Index == 509) { SendClientMessage(cId, "Transfira a guild antes de sair."); return; } else if(player->Equip[12].Index >= 526 && player->Equip[12].Index <= 528) { for(int i = 0; i < 3; i++) if(!stricmp(player->Name, Guilds[player->GuildIndex].SubLiderName[i])) strncpy(Guilds[player->GuildIndex].SubLiderName[i], "", 16); } memset(&player->Equip[12], 0x0, sizeof st_Item); SendItem(cId, EQUIP, 12, &player->Equip[12]); Guilds[player->GuildIndex].Members--; player->GuildIndex = 0; SendClientMessage(cId, "Saiu da Guild com sucesso."); return; } else if(!stricmp(p->Cmd, "transferir")) { *pRetn = true; if(!player->GuildIndex || !player->Equip[12].Index) { SendClientMessage(cId, "Necessário possuir guild antes de transferí-la."); return; } else if(!strcmp(p->Arg, "")) { SendClientMessage(cId, "Digite o nome do novo líder."); return; } else if(player->Equip[12].Index != 509 || strcmp(player->Name, Guilds[player->GuildIndex].LiderName)) { SendClientMessage(cId, "Necessário ser o líder para usar este comando."); return; } INT16 ncId = GetUserByName(p->Arg); if(!ncId || ncId < 0 || ncId > 750 || Users[ncId].Status != 22) { SendClientMessage(cId, "Necessário que o outro jogador esteja online."); return; } st_Mob *mob = GetMobFromIndex(ncId); if(mob->GuildIndex != player->GuildIndex) { SendClientMessage(cId, "O novo líder deve ser de sua guild."); return; } else if(!Guilds[player->GuildIndex].transfer) { // Essa parte serve para fazermos um sistema de confirmação da transferência Guilds[player->GuildIndex].transfer = true; strncpy(Guilds[player->GuildIndex].NewLiderName, mob->Name, 16); Guilds[player->GuildIndex].confirmTransfer = 30; SendClientMessage(cId, "Deseja mesmo transferir a guild? Caso sim, use o mesmo comando novamente."); return; } else if(!Guilds[player->GuildIndex].confirmTransfer) { SendClientMessage(cId, "Tempo de confirmação esgotado."); return; } else if(strcmp(mob->Name, Guilds[player->GuildIndex].NewLiderName)) { SendClientMessage(cId, "Confirmação incorreta."); return; } if(isSubLider(mob->Name, player->GuildIndex)) { for(int i = 0; i < 3; i++) if(!strcmp(mob->Name, Guilds[player->GuildIndex].SubLiderName[i])) strncpy(Guilds[player->GuildIndex].SubLiderName[i], "", 16); } strncpy(Guilds[player->GuildIndex].LiderName, Guilds[player->GuildIndex].NewLiderName, 16); memcpy(&mob->GuildIndex, &player->GuildIndex, sizeof UINT16); memcpy(&mob->GuildMemberType, &player->GuildMemberType, sizeof INT8); memcpy(&mob->Equip[12], &player->Equip[12], sizeof st_Item); player->Equip[12].Index = 508; SendItem(cId, EQUIP, 12, &player->Equip[12]); SendItem(ncId, EQUIP, 12, &mob->Equip[12]); char szMsg[120]; sprintf(szMsg, "Jogador %s é o novo lider da guild !!", mob->Name); for(int i = 0; i < MAX_PLAYER; i++) { st_Mob *p = GetMobFromIndex(i); if(p->GuildIndex == mob->GuildIndex) sD1D(0x7530, i, szMsg, 0xFF00BFFF); } SendClientMessage(cId, szMsg); SendClientMsg(ncId, "Você acaba de se tornar líder da guild %s", Guilds[mob->GuildIndex].GuildName); return; } else if(!stricmp(p->Cmd, "Criar")) { *pRetn = true; if(player->GuildIndex || player->Equip[12].Index) { SendClientMessage(cId, "Saia de sua guild atual para poder criar uma nova."); return; } else if(!strcmp(p->Arg, "")) { SendClientMessage(p->Header.ClientId, "Necessário digitar o nome da guild."); return; } else if(strlen(p->Arg) < 4 || strlen(p->Arg) > 16) { SendClientMessage(cId, "Nome deve ter entre 4 e 16 carácteres."); return; } else if(player->Gold < 100000000) { SendClientMessage(cId, "São necessários 100.000.000 (Cem Milhões) de gold para criação da guild."); return; } for(int e = 0; e < 0xFFFF; e++) { // Loop necessário, mesmo sendo paia dois loops até 0xFFFF, pq é necessário verificar se o nome é igual. if(!strcmp(p->Arg, Guilds[e].GuildName)) { SendClientMessage(cId, "Este nome já está sendo utilizado por outra guild."); //SendLog(Users[cId].Username, "%s tentou criar guild %s, já existente.", player->Name, p->Arg); return; } } int i = 0; while(i <= 0xFFFF) { if(!strcmp(Guilds[i].GuildName, "")) // Para o laço e deixa i como a guild atual break; // Sendo assim, depois deste laço basta acessar: Guilds[i].info if(i == 0xFFFF) { SendClientMessage(p->Header.ClientId, "Lamentamos, número máximo de guilds atingido."); return; } i++; } strncpy(Guilds[i].GuildName, p->Arg, 20); strncpy(Guilds[i].LiderName, player->Name, 16); for(int e = 0; e < 3; e++) strncpy(Guilds[i].SubLiderName[e], "", 16); GetCurScore_CapeInfo(player); Guilds[i].GuildID = i; Guilds[i].Kingdom = player->CapeInfo; Guilds[i].Members = 1; FILE *pFile = NULL; fopen_s(&pFile, "Guilds.txt", "a"); if(pFile) fprintf(pFile, "0 0 %d %s\n", Guilds[i].GuildID, Guilds[i].GuildName); player->GuildIndex = i; player->GuildMemberType = 1; player->Equip[12].Index = 509; player->Equip[12].EF1 = 56; player->Equip[12].EFV1 = i >> 8; player->Equip[12].EF2 = 57; player->Equip[12].EFV2 = i & 255; player->Equip[12].EF3 = 59; player->Equip[12].EFV3 = 0; player->Gold -= 100000000; SendItem(p->Header.ClientId, EQUIP, 12, &player->Equip[12]); SendScore(p->Header.ClientId); SendEtc(p->Header.ClientId); SaveGuilds(); UpdateGuildInfo(p->Header.ClientId); //SendLog(Users[cId].Username, "%s criou a guild %s.", player->Name, p->Arg); return; }
void WINAPI MainThread() { while(1) { // Thread Principal da dll, chamada de 1 em 1 segundo. // Usar para não sobrecarregar a ProcessMinTimer // Não cometer a negragem de dar break time_t rawnow = time(NULL); struct tm *now = localtime(&rawnow); if((DayOfWeek() == Terça || DayOfWeek() == Quinta) && now->tm_hour == 21) { if(!now->tm_min && !now->tm_sec) { SendNotice("Entrada na GuildWar liberada, boa sorte !"); //SendLog("system", "Entrada na GuildWar liberada."); for(int i = 0; i < 0xFFFF; i++) Guilds[i].WarPoints = 0; } if(now->tm_min == 30 && !now->tm_sec) { UINT16 Winner = DefineGuildWinner(); char szMsg[120]; if(Winner) { sprintf(szMsg, "Guild %s foi a vencedora da GuildWar, parabéns!", Guilds[Winner].GuildName); Guilds[Winner].FAME += 1000; } else sprintf(szMsg, "Não houve vencedores na GuildWar."); SendNotice(szMsg); //SendLog("system", szMsg); } } DecrementWaterTime(); LettersTime(); for(int z = 0; z < 0xFFFF; z++) { if(Guilds[z].confirmTransfer) Guilds[z].confirmTransfer--; if(!Guilds[z].confirmTransfer) { Guilds[z].transfer = false; strncpy(Guilds[z].NewLiderName, "", 16); } } if(!now->tm_hour && !now->tm_min && !now->tm_sec)// 0:00:00 { if(DayOfWeek() == Sabado) { *(INT32*)0x008BF1814 = 1; SendNotice("++++ DOUBLE EXP ON ++++"); } else if(DayOfWeek() == Segunda) { *(INT32*)0x008BF1814 = 0; SendNotice("++++ DOUBLE EXP OFF ++++"); } } if(!now->tm_sec && (now->tm_min == 1 || now->tm_min == 16 || now->tm_min == 31 || now->tm_min == 46)) { for(INT8 i = 0; i < 3; i++) { Pesa[i].TimeLeft = 840; for(INT8 e = 0; e < 3; e++) { for(INT8 j = 0; j < 13; j++) { if(Pesa[i].CIDS[e][j] < 0 || Pesa[i].CIDS[e][j] > 750) continue; else if(Users[Pesa[i].CIDS[e][j]].Status != 22) continue; SendClientSignalParm(Pesa[i].CIDS[e][j], 0x7530, 0x3A1, Pesa[i].TimeLeft); } } } } if((now->tm_min == 14 || now->tm_min == 29 || now->tm_min == 44 || now->tm_min == 59) && now->tm_sec == 59) { ClearArea(1150, 130, 1270, 220); // Pesa A ClearArea(1050, 260, 1135, 350); // Pesa M ClearArea(1295, 290, 1325, 365); // Pesa N for(int i = 0; i < sizeof(QuestList) / sizeof(Quests); i++) { ClearArea(MaxMinCoordsQuest[i][0], MaxMinCoordsQuest[i][1], MaxMinCoordsQuest[i][2], MaxMinCoordsQuest[i][3]); for(int z = 0; z < 40; z++) QuestList[i].CidID[z] = 0; } for(int i = 0; i < sizeof(Pesa) / sizeof(Pesas); i++) { Pesa[i].Status = false; Pesa[i].Groups = 0; Pesa[i].NpcsAlive = 0; for(int e = 0; e < 13; e++) { Pesa[i].CIDS[0][e] = 0; Pesa[i].CIDS[1][e] = 0; Pesa[i].CIDS[2][e] = 0; } } } if(!now->tm_sec && !now->tm_min && now->tm_hour == 21 && DayOfWeek() == Domingo) { INT64 BetValue[4][2]; for(UINT32 I = 0; I < 0xFFFF; I++) { // Se não tiver nome, não é uma guild ativa. if(!strcmp(Guilds[I].GuildName, "")) continue; // Coloca na struct da guerra os valores referentes a guilds apostantes for(int e = 0; e < 4; e++) { if(Guilds[I].BetValue[e] > BetValue[e][0]) { BetValue[e][0] = Guilds[I].BetValue[e]; War.BetIndex[e][0] = I; } else if(Guilds[I].BetValue[e] > BetValue[e][1]) { BetValue[e][1] = Guilds[I].BetValue[e]; War.BetIndex[e][1] = I; } Guilds[I].BetValue[e] = 0; } } TeleportWar(); } else if(now->tm_hour == 21 && DayOfWeek() == Domingo && now->tm_min == 3 && !now->tm_sec) { // Inicio real da pancadaria //SendLog("system", "Portões da Guerra abertos."); WarGate(1); } if(now->tm_hour == 21 && DayOfWeek() == Domingo) { for(int i = 0; i < 4; i++) { if(!War.Iniciada[i]) continue; int OwnerAlive = GetTeamAlive(i, 0), DefyAlive = GetTeamAlive(i, 1); if(!OwnerAlive)// Seta o desafiante como vencedor PutAsWinner(i, 1); else if(!DefyAlive)// Seta o defensor como vencedor PutAsWinner(i, 0); if(War.Finalizada[i]) continue; for(int e = 0; e < 2; e++) { for(int j = 0; j < War.TeamCount[i][e]; j++) { INT16 cId = 0; if(!e) cId = War.OwnerTeam[i][j]; else cId = War.DefyTeam[i][j]; st_Mob *player = GetMobFromIndex(cId); if(player->Status.curHP <= 0) { if(wdBuffer[cId].Ingame.WarRestTime >= 1) wdBuffer[cId].Ingame.WarRestTime--; else wdBuffer[cId].Ingame.cantRessurect = false; } // Manda o score, não sei se vai funfar... NpcsAlive(cId, GetTeamAlive(i, 0), GetTeamAlive(i, 1)); } } } } usersCount = 0; for(int i = 0; i < MAX_PLAYER; i++) { if(Users[i].Status != 22) continue; usersCount++; if(wdBuffer[i].Ingame.ChatGlobal > 0) wdBuffer[i].Ingame.ChatGlobal--; if(wdBuffer[i].Ingame.hasFailed > 0) wdBuffer[i].Ingame.hasFailed--; if(wdBuffer[i].Ingame.Grito > 0) wdBuffer[i].Ingame.Grito--; if(wdBuffer[i].Ingame.RetectItem) wdBuffer[i].Ingame.RetectItem--; st_Mob *tmpPlayer = GetMobFromIndex(i); if(tmpPlayer->Equip[0].EFV2 < HARDCORE && tmpPlayer->Equip[1].Index == 3505 && !wdBuffer[i].Ingame.isAdmin) { SendBan(Users[i].Username); char szNotice[120]; sprintf(szNotice, "Jogador [%s] banido por uso de item irregular.", tmpPlayer->Name); //SendLog("banneds", szNotice); //SendNotice(szNotice); CloseUser(i); } for(int i = 0; i < *(DWORD*)(0x004C7BD8); i++) memset((void*)(0x8B9E778), 0, 8); VerifyPesa(i); VerifyQuests(i); //VerifyWarArea(i); } Server.Seconds++; if(Server.Seconds >= 60) { Server.Seconds -= 60; Server.Minuts++; if(Server.Minuts >= 60) { Server.Minuts -= 60; Server.Hours++; if(Server.Hours >= 24) { Server.Days++; Server.Hours -= 24; } } } char szTitle[120]; if(usersCount) sprintf(szTitle, "Secrets of Destiny [%d] Jogadores conectados. [%02d:%02d:%02d:%02d]", usersCount, Server.Days, Server.Hours, Server.Minuts, Server.Seconds); else sprintf(szTitle, "Secrets of Destiny [%02d:%02d:%02d:%02d]", Server.Days, Server.Hours, Server.Minuts, Server.Seconds); SetConsoleTitle(szTitle); if(!now->tm_min && !now->tm_sec) { // Funções executadas todo inicio de hora if(!Server.SombraNegra) { CreateMob("Sombra_Negra", 3819, 2880, "npc"); Server.SombraNegra = TRUE; SendNotice("Sombra Negra acaba de nascer em Karden!"); //SendLog("system", "Sombra Negra nasceu."); } else SendNotice("Sombra Negra ainda reina em Karden."); StartThread(PremiumDelivery); } Sleep(1000); // Não colocarei 1000 para termos margem de tempo // Para a execução das tarefas desta thread } }
void Exec_MSG_AccountLogin(int conn, char *pMsg) { MSG_AccountLogin *m = (MSG_AccountLogin*)pMsg; int Size = m->Size; int ClientVersion = APP_VERSION; pUser[conn].AccountName[NAME_LENGTH - 1] = 0; if (conn <= 0 || (conn >= (MAX_USER - ADMIN_RESERV))) { sprintf(temp, g_pMessageStringTable[_NN_Reconnect]); SendClientMessage(conn, temp); pUser[conn].cSock.SendMessageA(); CloseUser(conn); return; } if (Size < sizeof(MSG_AccountLogin) || m->ClientVersion != ClientVersion) { sprintf(temp, g_pMessageStringTable[_NN_Version_Not_Match_Rerun], APP_VERSION); SendClientMessage(conn, temp); pUser[conn].cSock.SendMessageA(); CloseUser(conn); return; } if(pUser[conn].Mode != USER_ACCEPT) { SendClientMessage(conn, "Login now, wait a moment."); CrackLog(conn, " accountlogin"); pUser[conn].cSock.SendMessageA(); return; } int tMac = 0; if (m->Size < sizeof(MSG_AccountLogin)) memset(pUser[conn].Mac, 0xFF, sizeof(pUser[conn].Mac)); else memcpy(pUser[conn].Mac, m->AdapterName, sizeof(pUser[conn].Mac)); m->Type = _MSG_DBAccountLogin; m->ID = conn; sscanf(m->AccountName, "%s", pUser[conn].AccountName); strupr(pUser[conn].AccountName); strncpy(m->AccountName, pUser[conn].AccountName, NAME_LENGTH); int check = CheckFailAccount(m->AccountName); if(check >= 3) { SendClientMessage(conn, g_pMessageStringTable[_NN_3_Tims_Wrong_Pass]); pUser[conn].cSock.SendMessageA(); return; } DBServerSocket.SendOneMessage((char*)m, sizeof(MSG_AccountLogin)); pUser[conn].Mode = USER_LOGIN; pMob[conn].Mode = MOB_EMPTY; }
int CEpollClient::RunFun() { int isocketfd = -1; for(int iuserid=0; iuserid<m_iUserCount; iuserid++) { struct epoll_event event; isocketfd = ConnectToServer(iuserid, m_ip, m_iPort); if(isocketfd < 0) cout <<"[CEpollClient error]: RunFun, connect fail" <<endl; m_iSockFd_UserId[isocketfd] = iuserid;//将用户ID和socketid关联起来 event.data.fd = isocketfd; event.events = EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP; m_pAllUserStatus[iuserid].uEpollEvents = event.events; epoll_ctl(m_iEpollFd, EPOLL_CTL_ADD, event.data.fd, &event); } int flag=0; struct timeval val1,val2; gettimeofday(&val1,NULL); while(!flag){ struct epoll_event events[_MAX_SOCKFD_COUNT]; gettimeofday(&val2,NULL); //if((val2.tv_sec -val1.tv_sec)>10) //flag=1; char buffer[1024]; memset(buffer,0,1024); int nfds = epoll_wait(m_iEpollFd, events, _MAX_SOCKFD_COUNT, 100 );//等待epoll事件的产生 for (int ifd=0; ifd<nfds; ifd++)//处理所发生的所有事件 { struct epoll_event event_nfds; int iclientsockfd = events[ifd].data.fd; //cout << "events[ifd].data.fd: " << events[ifd].data.fd << endl; int iuserid = m_iSockFd_UserId[iclientsockfd];//根据socketfd得到用户ID if( events[ifd].events & EPOLLOUT ) { int iret = SendToServerData(iuserid); if( 0 < iret ) { event_nfds.events = EPOLLIN|EPOLLERR|EPOLLHUP; event_nfds.data.fd = iclientsockfd; epoll_ctl(m_iEpollFd, EPOLL_CTL_MOD, event_nfds.data.fd, &event_nfds); } else { cout <<"[CEpollClient error:] EpollWait, SendToServerData fail, send iret:"<<iret<<",iuserid:"<<iuserid<<",fd:"<<events[ifd].data.fd<<endl; DelEpoll(events[ifd].data.fd); CloseUser(iuserid); } } else if( events[ifd].events & EPOLLIN )//监听到读事件,接收数据 { int ilen = RecvFromServer(iuserid, buffer, 1024); if(0 > ilen) { cout <<"[CEpollClient error]: RunFun, recv fail, reason is:"<<strerror(errno)<<",errno is:"<<errno<<endl; DelEpoll(events[ifd].data.fd); CloseUser(iuserid); } else if(0 == ilen) { cout <<"[CEpollClient warning:] server disconnect,ilen:"<<ilen<<",iuserid:"<<iuserid<<",fd:"<<events[ifd].data.fd<<endl; DelEpoll(events[ifd].data.fd); CloseUser(iuserid); } else { read_num++; m_iSockFd_UserId[iclientsockfd] = iuserid;//将socketfd和用户ID关联起来 event_nfds.data.fd = iclientsockfd; event_nfds.events = EPOLLOUT|EPOLLERR|EPOLLHUP; //event_nfds.events = EPOLLERR|EPOLLHUP; epoll_ctl(m_iEpollFd, EPOLL_CTL_MOD, event_nfds.data.fd, &event_nfds); } } else { cout <<"[CEpollClient error:] other epoll error"<<endl; DelEpoll(events[ifd].data.fd); CloseUser(iuserid); } } } printf("read: %d\n",read_num); }
void FixUseSkill(BYTE *m_PacketBuffer, bool* pRetn) { p39D_754 *p = (p39D_754*)m_PacketBuffer; INT16 cId = p->Header.ClientId; p754_SendAffect *oldp = (p754_SendAffect*)m_PacketBuffer; INT16 oldcId = oldp->Header.ClientId; st_Mob *player = GetMobFromIndex(oldcId); if(p->m_SkillId == 103) // Skill Kefra sem ser mob { *pRetn = true; CloseUser(cId); return; } else if(!p->m_SkillId) // Se não for skill return; if(p->Header.PacketId == 0x36C && p->m_SkillId == 79) { OitavaHT(cId, p->m_Target.Index); *pRetn = true; return; } switch(p->m_SkillId) { case 27: case 29: *(DWORD*)&m_PacketBuffer[12] = 0x0; break; case 31: // Renascimento { *pRetn = true; if(cId == p->m_Target.Index) return; else if(p->m_Target.Index < 0 || p->m_Target.Index > 750) return; bool HasOnGroup = false; if(player->Leader <= 0) // Lider do grupo ou sem grupo { for(int i = 0; i < 12; i++) { if(player->PartyList[i] == p->m_Target.Index) { HasOnGroup = true; break; } } } else if(player->Leader != -1) { st_Mob *leader = GetMobFromIndex(player->Leader); for(int i = 0; i < 12; i++) { if(leader->PartyList[i] == p->m_Target.Index) { HasOnGroup = true; break; } } } if(!HasOnGroup) return; st_Mob *deadPerson = GetMobFromIndex(p->m_Target.Index); if(deadPerson->Status.curHP > 0) return; if(!player->Status.curHP || !player->Status.curMP) return; deadPerson->Status.curHP = deadPerson->Status.maxHP / 2; deadPerson->Status.curMP = deadPerson->Status.maxMP / 2; deadPerson->bStatus.curHP = deadPerson->bStatus.maxHP / 2; deadPerson->bStatus.curMP = deadPerson->bStatus.maxMP / 2; Users[p->m_Target.Index].Potion.CountMp = deadPerson->Status.curMP; Users[p->m_Target.Index].Potion.CountHp = deadPerson->Status.curHP; player->Status.curMP = 0; player->bStatus.curMP = 0; Users[cId].Potion.CountMp = player->Status.curMP; GetCurrentScore(p->m_Target.Index); BASE_GetHpMp(deadPerson); SendScore(p->m_Target.Index); SendCreateMob(p->m_Target.Index, p->m_Target.Index, 1); DoTeleport(p->m_Target.Index, deadPerson->PosX, deadPerson->PosY); break; } case 56: case 57: case 58: case 59: case 60: case 61: case 62: case 63: { *pRetn = true; UINT8 summonId = p->m_SkillId - 56; static const UINT8 MobDivisor[8] = {31, 36, 42, 51, 63, 85, 127, 255}; if(!player->Leader || player->Leader == -1) { for(int i = 0; i < 12; i++) { if(player->PartyList[i] <= 0) continue; st_Mob *tmpMob = GetMobFromIndex(player->PartyList[i]); for(int e = 0; e < 8; e++) { if(tmpMob->Equip[0].Index == MobFaces[e]) { if(tmpMob->Summoner != p->Header.ClientId) return; RemoveParty(player->PartyList[i]); SendRemoveParty(player->Leader, player->PartyList[i]); } } } } else // Não é o lider do grupo { st_Mob *Lider = GetMobFromIndex(player->Leader); for(int i = 0;i<12;i++) { if(Lider->PartyList[i] == cId) continue; if(Lider->PartyList[i] <= 0) continue; st_Mob *tmpMob = (st_Mob*)GetMobFromIndex(Lider->PartyList[i]); for(int e = 0; e < 8; e++) { if(tmpMob->Equip[0].Index == MobFaces[e]) { if(tmpMob->Summoner != p->Header.ClientId) return; RemoveParty(Lider->PartyList[i]); SendRemoveParty(Lider->Leader, Lider->PartyList[i]); } } } } // Essa conta pega o número de mobs que a skill deve criar INT16 numMob = player->Status.Mastery[2] / MobDivisor[summonId]; if(!numMob) numMob += 1; for(int i = 0; i < numMob; i++) GenerateSummon(cId, summonId, 0); break; } case 64: case 66: case 68: case 70: case 71: { if(player->Equip[13].Index > 4151 && player->Equip[13].Index < 4159) { // Está de traje SendClientMessage(cId, "Impossível utilizar esta skill enquanto trajado."); *pRetn = true; return; } break; } ////case 98: // Vinha - Skill sephira //// CreateMob("Vinha", oldp->PositionFinal.X, oldp->PositionFinal.Y, "npc"); //// break; case 99: // Ressureição - Skill sephira { *pRetn = true; INT16 Level = player->bStatus.Level + 1; if(player->Equip[0].EFV2 > ARCH) Level += 200; INT8 resChances = Level / 5; if(wdBuffer[cId].Ingame.hasFailed) return; srand(time(NULL) / 5 * (rand() % 500) * 5); if(rand() % 100 <= resChances) { player->Status.curHP = player->Status.maxHP / 2; player->Status.curMP = player->Status.maxMP / 2; player->bStatus.curHP = player->bStatus.maxHP / 2; player->bStatus.curMP = player->bStatus.maxMP / 2; GetCurrentScore(cId); BASE_GetHpMp(player); SendScore(cId); SendCreateMob(cId, cId, 1); } else if(!wdBuffer[cId].Ingame.hasFailed) wdBuffer[cId].Ingame.hasFailed = 200; break; } case 102: // Soul - Melhor buff ever { *pRetn = true; if(player->Equip[0].EFV2 == ARCH) return; bool hasSoulOn = false; for(int i = 0; i < 16; i++) if(mBuffer[cId].Affects[i].Index == 29) { hasSoulOn = true; mBuffer[cId].Affects[i].Master = wdBuffer[cId].Chars[wdBuffer[cId].Ingame.LoggedMob].SoulInfo; mBuffer[cId].Affects[i].Time = 139; mBuffer[cId].Affects[i].Value = 4; break; } if(!hasSoulOn) { for(int i = 0; i < 16; i++) if(!mBuffer[cId].Affects[i].Index) { mBuffer[cId].Affects[i].Index = 29; mBuffer[cId].Affects[i].Master = wdBuffer[cId].Chars[wdBuffer[cId].Ingame.LoggedMob].SoulInfo; mBuffer[cId].Affects[i].Time = 139; mBuffer[cId].Affects[i].Value = 4; break; } } GetCurrentScore(cId); SendStats(cId); SendScore(cId); break; } } }
void PartyGridMulticast(int tx, int ty, MSG_STANDARD *msg, int skip, int Leaderconn) { int SizeY = VIEWGRIDY; int SizeX = VIEWGRIDX; int StartX = tx - HALFGRIDX; int StartY = ty - HALFGRIDY; if (StartX + SizeX >= MAX_GRIDX) SizeX = SizeX - (StartX + SizeX - MAX_GRIDX); if (SizeY + StartY >= MAX_GRIDY) SizeY = SizeY - (StartY + SizeY - MAX_GRIDY); if (StartX < 0) StartX = 0; if (StartY < 0) StartY = 0; int sx1 = StartX; int sy1 = StartY; int sx2 = StartX + SizeX; int sy2 = StartY + SizeY; for (int y = StartY; y < sy2; y++) { for (int x = sx1; x < sx2; x++) { int tmob = pMobGrid[y][x]; if (tmob <= 0 || tmob == Leaderconn) continue; if (!Leaderconn || pMob[tmob].Leader != Leaderconn) { if (pMob[tmob].Mode == MOB_EMPTY) { int Unk = 0; continue; } if (msg != NULL && tmob < MAX_USER && tmob != skip && !pUser[tmob].PartyChat) { if (pUser[tmob].Mode != USER_PLAY || pUser[tmob].cSock.Sock == 0) continue; pUser[tmob].cSock.AddMessage((char*)msg, msg->Size); } } } } if (Leaderconn > 0 && Leaderconn < MAX_USER && pUser[Leaderconn].Mode == USER_PLAY) { if (Leaderconn != skip) pUser[Leaderconn].cSock.AddMessage((char*)msg, msg->Size); for (int i = 0; i < MAX_PARTY; i++) { int partyconn = pMob[Leaderconn].PartyList[i]; if (partyconn <= 0 || partyconn >= MAX_USER) continue; if (partyconn == skip) continue; if (pUser[partyconn].Mode != USER_PLAY || pUser[partyconn].PartyChat != 0) continue; if (pUser[partyconn].Mode != USER_PLAY || pUser[partyconn].cSock.Sock == 0) continue; if (!pUser[partyconn].cSock.AddMessage((char*)msg, msg->Size)) CloseUser(partyconn); } } }