kaiquegames069 Posted August 22, 2017 at 02:14 PM Share Posted August 22, 2017 at 02:14 PM Boas, Gostaria de saber se é possível bloquear pvp em um devido mapa? O mapa tem como destino "DROPS" Link to comment Share on other sites More sharing options...
[Admin] tierrilopes Posted August 23, 2017 at 12:46 AM Share Posted August 23, 2017 at 12:46 AM Game/src/battle.cpp Debaixo de: bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim){ Adicionar: switch(ch->GetMapIndex()){ case ID: //ID do mapa a bloquear { if (victim->IsPC() && ch->IsPC()) return false; } } Link to comment Share on other sites More sharing options...
kaiquegames069 Posted August 23, 2017 at 03:12 AM Author Share Posted August 23, 2017 at 03:12 AM Nesse caso ninguém vai conseguir atacar ninguém dentro do mapa certo? Apenas mobs? Link to comment Share on other sites More sharing options...
Dynamic Things Posted August 23, 2017 at 10:31 PM Share Posted August 23, 2017 at 10:31 PM Sim, isso só iria funcionar se o atacante for um jogador e se a vitima for um jogador { if (victim->IsPC() && ch->IsPC()) Link to comment Share on other sites More sharing options...
kaiquegames069 Posted August 31, 2017 at 03:52 PM Author Share Posted August 31, 2017 at 03:52 PM Eu fiz assim e me da erros. bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim) { // Bloqueio de PvP em Mapa switch(ch->GetMapIndex()){ case ID: 64 { if (victim->IsPC() && ch->IsPC()) return false; } } // Bloqueio de PvP em Mapa // »ó´ë¹æÀÌ Á×¾úÀ¸¸é Áß´ÜÇÑ´Ù. if (victim->IsDead()) return false; Link to comment Share on other sites More sharing options...
[Admin] tierrilopes Posted August 31, 2017 at 04:14 PM Share Posted August 31, 2017 at 04:14 PM Muda case ID: 64 Para case 64: Onde está ID é para ser substituído pelo número do mapa Link to comment Share on other sites More sharing options...
kaiquegames069 Posted August 31, 2017 at 04:15 PM Author Share Posted August 31, 2017 at 04:15 PM Obrigado! Link to comment Share on other sites More sharing options...
kaiquegames069 Posted October 11, 2017 at 09:45 PM Author Share Posted October 11, 2017 at 09:45 PM Tem alguma forma dessa função só funcionar quando eu ativar o evento pvm? No caso: game.set_event_flag("evento_pvm", 1) - Os players não conseguem atacar outros players. game.set_event_flag("evento_pvm", 0) - Os players já podem atacar normalmente. Link to comment Share on other sites More sharing options...
Sinval Posted October 11, 2017 at 10:48 PM Share Posted October 11, 2017 at 10:48 PM (edited) 1 hora atrás, kaiquegames069 disse: Tem alguma forma dessa função só funcionar quando eu ativar o evento pvm? No caso: game.set_event_flag("evento_pvm", 1) - Os players não conseguem atacar outros players. game.set_event_flag("evento_pvm", 0) - Os players já podem atacar normalmente. DWORD dwFlagBlockAtaque = quest::CQuestManager::instance().GetEventFlag("evento_pvm"); if ((dwFlagBlockAtaque == 1) && (GetMapIndex() == 1 || GetMapIndex() == 21 || GetMapIndex() == 41)) { if (victim->IsPC() && ch->IsPC()) return false; } Isso deve funcionar. Edited October 11, 2017 at 10:51 PM by Sinval Link to comment Share on other sites More sharing options...
juniorsilva Posted October 11, 2017 at 10:49 PM Share Posted October 11, 2017 at 10:49 PM 55 minutos atrás, kaiquegames069 disse: Tem alguma forma dessa função só funcionar quando eu ativar o evento pvm? No caso: game.set_event_flag("evento_pvm", 1) - Os players não conseguem atacar outros players. game.set_event_flag("evento_pvm", 0) - Os players já podem atacar normalmente. #include "questmanager.h" if (quest::CQuestManager::instance().GetEventFlag("disable_event_pvm") == 0) { switch (ch->GetMapIndex()) { case 1: { if (victim->IsPC() && ch->IsPC()) return false; } } } Link to comment Share on other sites More sharing options...
kaiquegames069 Posted October 11, 2017 at 10:50 PM Author Share Posted October 11, 2017 at 10:50 PM No caso eu coloco essa função em qual arquivo e em qual local do arquivo? Link to comment Share on other sites More sharing options...
juniorsilva Posted October 11, 2017 at 11:04 PM Share Posted October 11, 2017 at 11:04 PM 12 minutos atrás, kaiquegames069 disse: No caso eu coloco essa função em qual arquivo e em qual local do arquivo? battle.cpp -> bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim) Link to comment Share on other sites More sharing options...
kaiquegames069 Posted October 11, 2017 at 11:13 PM Author Share Posted October 11, 2017 at 11:13 PM Obrigado pessoal! Link to comment Share on other sites More sharing options...
juniorsilva Posted October 11, 2017 at 11:22 PM Share Posted October 11, 2017 at 11:22 PM 3 minutos atrás, kaiquegames069 disse: Obrigado pessoal! Obs: Add #include "questmanager.h" abaixo do #include "locale_service.h". Link to comment Share on other sites More sharing options...
kaiquegames069 Posted October 11, 2017 at 11:23 PM Author Share Posted October 11, 2017 at 11:23 PM Just now, juniorsilva said: Obs: Add #include "questmanager.h" abaixo do #include "locale_service.h". Deixa te perguntar, tem alguma forma disso funciona sem precisar de index? Exemplo ativei o evento todos os mapas bloqueiam o pvp até que o evento pvm termine? Link to comment Share on other sites More sharing options...
[Admin] tierrilopes Posted October 11, 2017 at 11:30 PM Share Posted October 11, 2017 at 11:30 PM Basta remover o switch do exemplo do juniorsilva if (quest::CQuestManager::instance().GetEventFlag("disable_event_pvm") == 0){ if (victim->IsPC() && ch->IsPC()) return false;} Link to comment Share on other sites More sharing options...
kaiquegames069 Posted October 11, 2017 at 11:32 PM Author Share Posted October 11, 2017 at 11:32 PM Perfeito, irei testar aqui. Link to comment Share on other sites More sharing options...
[Admin] tierrilopes Posted October 11, 2017 at 11:43 PM Share Posted October 11, 2017 at 11:43 PM ch->GetMapIndex() é a função que diz em que mapa o jogador está O que o switch faz é avaliar o valor dessa mesma função ch->GetMapIndex() case X: Permite realizar uma ação quando o valor da função for X Também poderia ser feito com if, mas com case fica mais rápido adicionar novos valores, pois podes ter vários case a realizar a mesma função. Em termos de escrita fica mais curto do que if e visualmente mais apelativo no tema do tópico case 1: case 3: case 4: { açãoASD(); açãoQWE(); } case 2: case 6: { açãoZXC(); } Também podes realizar uma ação caso o valor da função seja diferente dos colocados nos case. Isto será realizado caso a função não seja nenhum dos valores anteriores. default equivale ao else do if Através do seguinte: default: { açãoQWERTY(); } ____________ Exemplo do uso de if e for (função do Vegas): #ifdef ENABLE_NEW_AFFECT_POTION int listAffects[] = { AFFECT_POTION_1, AFFECT_POTION_2, AFFECT_POTION_3, AFFECT_POTION_4, AFFECT_POTION_5, AFFECT_POTION_6}; for (int i = 0; i < _countof(listAffects); i++) { if (pkAff->dwType == listAffects[i]) { ++it; continue; } } #endif Exemplo de como neste caso, um switch seria bem mais simples e rápido, sendo por isso mais eficiente no tempo gasto a codificar: #ifdef ENABLE_NEW_AFFECT_POTION switch (pkAff->dwType){ case AFFECT_POTION_1: case AFFECT_POTION_2: case AFFECT_POTION_3: case AFFECT_POTION_4: case AFFECT_POTION_5: case AFFECT_POTION_6: { ++it; continue;}} #endif Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now