[7.92]combat/pvp Zoning

lithium
em Linguagens de Programação

lithium

avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 04/09/06Posts: 190

Com esse code você pode fazer areas de pvp tipo uma parte do map pvp e outra non-pvp ^^

 

Vamos ao code gogogo =]

 

no final de game.cpp adicione

 

#ifdef __COMBAT_ZONES__
bool Game::loadCombatZones()
{
   xmlDocPtr doc = xmlParseFile(std::string(g_config.getString(ConfigManager::DATA_DIRECTORY) + "pvpzones.xml").c_str());
   if(!doc)
       return false;
   xmlNodePtr root, zone, tiles;
   root = xmlDocGetRootElement(doc);
   if(xmlStrcmp(root->name,(const xmlChar*)"zones"))
   {
       puts("MALFORMED PVP ZONES XML FILE!");
       return false;
   }
   zone = root->children;
   while(zone)
   {
       if(!xmlStrcmp(zone->name,(const xmlChar*)"zone"))
       {
           tileflags_t pvplvl = TILESTATE_NONE;
           std::string strlvl;
           if(!readXMLString(zone, "pvp", strlvl))
           {
               puts("ERROR: pvp zone missing pvp level!");
               continue;
           }
           toLowerCaseString(strlvl);
           if(strlvl == "none" || strlvl == "no" || strlvl == "nopvp" || strlvl == "0")
               pvplvl = TILESTATE_NOPVP;
           else if(strlvl == "yes" || strlvl == "normal" || strlvl == "pvp" || strlvl == "1")
               pvplvl = TILESTATE_PVP;
           else if(strlvl == "enforced" || strlvl == "e" || strlvl == "pvp-enforced" || strlvl == "2")
               pvplvl = TILESTATE_PVP_ENFORCED;
           else
           {
               printf("ERROR: invalid pvp level: %s\n", strlvl.c_str());
               continue;
           }
           tiles = zone->children;
           while(tiles)
           {
               if(!xmlStrcmp(tiles->name,(const xmlChar*)"tile"))
               {
                  int x, y, z;
                  if(readXMLInteger(tiles,"x",x)
                     && readXMLInteger(tiles,"y",y)
                     && readXMLInteger(tiles,"z",z))
                  {
                         Tile* t = map->getTile(x, y, z);
                         if(t)
                             t->setFlag(pvplvl);
                  }
               }
               else if(!xmlStrcmp(tiles->name,(const xmlChar*)"tiles"))
               {
                  int tox, toy, toz, fromx, fromy, fromz;
                  if(readXMLInteger(tiles,"tox",tox)
                     && readXMLInteger(tiles,"toy",toy)
                     && readXMLInteger(tiles,"toz",toz)
                     && readXMLInteger(tiles,"fromx",fromx)
                     && readXMLInteger(tiles,"fromy",fromy)
                     && readXMLInteger(tiles,"fromz",fromz))
                  {
                       if(tox < fromx)
                           std::swap(tox, fromx);
                       if(toy < fromy)
                           std::swap(toy, fromy);
                       if(toz < fromz)
                           std::swap(toz, fromz);
                       for(int x = fromx; x <= tox; x++)
                       {
                          for(int y = fromy; y <= toy; y++)
                          {
                             for(int z = fromz; z <= toz; z++)
                             {
                                 Tile* t = map->getTile(x, y, z);
                                 if(t)
                                     t->setFlag(pvplvl);
                             }
                          }
                       }
                  }
               }
               tiles = tiles->next;
           }
       }
       zone = zone->next;
   }

   return true;
}
#endif //__COMBAT_ZONES__

 

em game.h, substitua:

#ifndef __COMBAT_ZONES__
WorldType_t getWorldType() const {return worldType;}
#else
WorldType_t getWorldType(const Creature* attacker = NULL, const Creature* target = NULL) const
{
       if(!attacker || !target)
           return worldType;

       if(attacker->getPlayer() && target->getPlayer())
       {
           if(worldType == WORLD_TYPE_NO_PVP)
           {
               if(attacker->getTile()->hasFlag(TILESTATE_PVP_ENFORCED) && target->getTile()->hasFlag(TILESTATE_PVP_ENFORCED))
                   return WORLD_TYPE_PVP_ENFORCED;
               else if(attacker->getTile()->hasFlag(TILESTATE_PVP) && target->getTile()->hasFlag(TILESTATE_PVP))
                   return WORLD_TYPE_PVP;
           }
           else
           {
               if(attacker->getTile()->hasFlag(TILESTATE_NOPVP) || target->getTile()->hasFlag(TILESTATE_NOPVP))
                   return WORLD_TYPE_NO_PVP;
           }
       }

       return worldType;
   }

   bool loadCombatZones();
#endif //__COMBAT_ZONES__

 

em tile.h depois de:

TILESTATE_HOUSE = 2

 

adcione:

#ifdef __COMBAT_ZONES__
, TILESTATE_NOPVP = 4,
TILESTATE_PVP = 8,
TILESTATE_PVP_ENFORCED = 16,
#endif //__COMBAT_ZONES__

 

em combat.cpp, substituir:

if(g_game.getWorldType() == WORLD_TYPE_NO_PVP){

 

por:

if(g_game.getWorldType(
   #ifdef __COMBAT_ZONES__
   attacker, target
   #endif //__COMBAT_ZONES__
   ) == WORLD_TYPE_NO_PVP){

 

em player.cpp, na função Player::getGainedExperience, substituir:

if(g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED){

 

por:

if(g_game.getWorldType(
   #ifdef __COMBAT_ZONES__
   attacker, this
   #endif //__COMBAT_ZONES__
   ) == WORLD_TYPE_PVP_ENFORCED){

 

em otserv.cpp, depois de:

if(!g_game.loadMap(g_config.getString(ConfigManage r::MAP_FILE), g_config.getString(ConfigManager::MAP_KIND))){
return -1;
}

 

adicione:

#ifdef __COMBAT_ZONES__
if(g_game.loadCombatZones())
    puts(":: Loaded Combat Zones!");
#endif //__COMBAT_ZONES__

 

adicione aos parametros ALT+P

-D__COMBAT_ZONES__

 

agora é so dar rebuild all CTRL+F11

 

Créditos: Nfries88

 

copie qualquer arquivo .XML renomei para pvpzones, apague tudo que estiver escrito nele e cole isso, e coloque o dentro da pasta data.

<?xml version="1.0" encoding="UTF-8"?>
<zones>
<!--zone pvp="normal">
 <tiles fromx="" fromy="" fromz="" tox="" toy="" toz="" />
</zone-->
</zones>

 

em "zone pvp=" você pode usar "normal" = pvp "non"=non "pvp enforced"=pvp enforced

tibiaa4e

Ex amante de Tibia
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 18/12/05Posts: 912Gênero: MasculinoChar no Tibia: Kohzete

opa

bem lgl

ta 100% ?

 

se tiver falo com o zorzin pra add na 1.2 (1.1 só pra bugs :S)

 

flws :hi:

Aposentado de OTserver e Tibia

Meus melhores tutoriais
Enciclopédia Pasta Data
Tutorial de quest

lithium

avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 04/09/06Posts: 190

@tibiaa4e

sim ta 100% ^^ eu testei ele aqui

Jvchequer

"Veni, vidi, vici."
avatar
Lenda
Lenda

INFOS

Grupo: LendaRegistrado: 10/10/05Posts: 2161Char no Tibia: Master Chequer

Vamos ver se entendi?

 

Basicamente esse Code coloca uma area Pvp enforced em um Ot No-pvp ou pvp?

 

Cya

1271330714-U1306.gif

 

~ Fiz parte da Equipe Xtibia em um tempo que Tibia era minha família. Saudades de todos vocês.

lithium

avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 04/09/06Posts: 190

@Jvchequer

você pode por exemplo coloca uma parte do mapa pvp outra parte non-pvp e outra pvp-enforced se quiser ^^

suboras

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 28/10/05Posts: 91

HEUhuehueuhue

Cara Topico MT BOM x)

 

Eu passei a tarde td tentando faze pvp arena po meu ot 7.9.. nm consegui x(~

 

Mais esse code, vai ajuda pakas, MT BM ^^

 

EDITED------

Tipow cara, nao tem como vc hospedar os codes em um arquivo.text no rapidshare e colar o link no tuto ?!?! eh q aki em casa, a maioria das vezes que eu copio algum code do X-tibia, ele vem sem a formatação (enter e tals) =/

 

@topic

em otserv.cpp, depois de:

if(!g_game.loadMap(g_config.getString(ConfigManage r::MAP_FILE), g_config.getString(ConfigManager::MAP_KIND))){

return -1;

}

 

Aki esta errado, nao seria:

 

em otserv.cpp, depois de:

if(!g_game.loadMap(g_config.getString ConfigManager::MAP_FILE), g_config.getString(ConfigManager::MAP_KIND))){
return -1;
}

 

copie qualquer arquivo .XML renomei para pvpzones, apague tudo que estiver escrito nele e cole isso, e coloque o dentro da pasta data.

<?xml version="1.0" encoding="UTF-8"?>
<zones>
<!--zone pvp="normal">
<tiles fromx="" fromy="" fromz="" tox="" toy="" toz="" />
</zone-->
</zones>

 

em "zone pvp=" você pode usar "normal" = pvp "non"=non "pvp enforced"=pvp enforced

 

aki:

 

em "zone pvp=" você pode usar "normal" = pvp "non"=non "pvp enforced"=pvp enforced

 

esta errado nao eh non, e sim nopvp...

edita o seu topico ai.. :wink:

 

Aki nao funfou... =/

Xike-Ots...

 

Vlws~

 

OBS: Te Mandei uma MP

//Suboras

~~ SµßØ®åS 7H3 3RVA5 ~~

§···x···§ -~> :þ Open Tibia Server :þ <-~ §···x···§

:.?¿.:Duvidas:.¿?.: {&} :.!¡.:Contatos:.!¡.:
>·>·>·> suboras@hotmail.com <·<·<·<
_-¯_-¯_-¯_-¯_-¯ [ou] ¯-_¯-_¯-_¯-_¯-_
¥ õ Msn: suboras@hotmail.com õ ¥
¯-_-¯-_-¯-_-¯-_ [»«] _-¯-_-¯-_-¯-_-¯


§···x···§ -~> I remember u ... <-~ §···x···§

Open Tibia Serve Tutos & Codes ««»» Trabalhos ««»»
Comando, "!premium" -> http://www.xtibia.com/forum/index.php?showtopic=45395

Comando, "/pum" -> http://www.xtibia.com/forum/index.php?showtopic=45539


<- ACTION DO DADO (DICE), IGUAL TIBIA GLOBAL (PERFEITA) ->
http://www.xtibia.com/forum/index.php?showtopic=46671


Atenciosamente :
________________________
~-> SµßØ®åS <-~
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

PessoaMan

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 17/12/07Posts: 2Char no Tibia: Uchila'Sasuke

aki também naum funfou

Felp321

Helloween Rulez \o/
avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 08/01/08Posts: 192Char no Tibia: Felp Guardian

. Affe meu tibia é 8.22... tenta faze um sistema esses pra 8.22 por favor cara!!! Eu tava querendo bastante... Se voce fizer vou achar bem legal XD Tenta aí faze!

. Atenciosamente,

. Felipe

"Elapsam semel occasionem non ipse potest Iuppiter reprehendere"