Otimo Code Honux, Assim como todos os outros que voce posta.
- Fórum
- OTServ
- Recursos
- Linguagens de Programação
- Passagem Secreta
info
Grupo: Conde
Registrado: 12/10/05
Posts: 568
Reputação: +12
Gênero: Masculino
Char no Tibia: Homao Dapoha

info
Grupo: Campones
Registrado: 23/07/05
Posts: 71
Reputação: +1

@Addict
kem dera kra ![]()
hj eu já sei fz esse code umas 3 vezes menor hahaha....
e isso td eh code q qualker um consegue fazer, se fosse algo difícil... mais sab como eh neh kra, melhor libera do q alguem faça antes de vc ![]()
kra... mt bom u code... perfeito... ^^
mas... eu sei ki vc naum vai dar suport... mas... vc sabe como é a função de decay? pq eu naum sei... :S... si souber plz fla aki...
Ty
Flw...
PS.: I'm just a noob trying make one ot... ^^
Editado Abril 21 por frerety
info
Grupo: Visconde
Registrado: 03/10/05
Posts: 301
Reputação: +8
Gênero: Masculino
code mt rox, só falta completar com decay
cya~~
Editado Abril 21 por colex
info
Grupo: Campones
Registrado: 23/07/05
Posts: 71
Reputação: +1

@frerety e colex
eu tenho já com o decay, porém não vou publicar.
@frerety
faça um addEvent e uma função para o retornar o ID anterior...
@honux
Ty... haUhAUhuA... mas eu naum sei neim colocar delay... aHUaHuhaUhua... ^^... Ty
CyA!
Simplesmente perfeito ^^.
info
Grupo: Campones
Registrado: 15/01/06
Posts: 37
Reputação: 0
Char no Tibia: Zen Knight

Olá,
Muito Bom o Code, Vou bota-lo no meu OT.
OBS: Porquê você não faz outro code, que quando falar outro palavra, Tipo Alakazam, a passagem feche?
Abraços,
Zen




info
Grupo: Campones
Registrado: 23/07/05
Posts: 71
Reputação: +1
Bom, como eu sai da equipe que eu tava, resolvi começar a liberar alguns codes que eu havia feito para a mesma.
Infelizmente não darei suporte ao code, pois não é nada tão difícil de fazer e compreender mesmo.
Ahhh.... :
Opnião Própria -> Code útil para servidores de RPG, onde realmente tem que se procurar coisas, descobrir passagens e tudo mais.
Créditos :
Honux ( ou Kyo ).
NÃO PERMITO O POST DESTE CÓDIGO EM NENHUM OUTRO FÓRUM ALÉM DO OTFANS. QUER DIZER, ESTE CODE NÃO PODERÁ SER POSTADO NO OTN00BBR.
Esse code está faltando apenas o 'decay' dos grounds modificados pelo code, que eu havia começado a fazer mas como eu sai da equipe eu parei de fazer.
O que o code faz:
Você sabe que nem em filme quando um cara chega na frente da estante e fala " Abra Cadabra " e abre uma passagem secreta? A mesma coisa, porém como está incompleto a passagem não fecha. Também é possível criar items, sumonar npcs e monstros além da passagem.
Protocol: 7.6
na função : bool Game::internalCreatureSay(Creature* creature, SpeakClasses type, const std::string& text)
abaixo de :
//First, check if this was a command for(int i = 0; i < commandTags.size(); i++){ if(commandTags[i] == text.substr(0,1)){ return commands.exeCommand(creature, text); } }adicione :
Player *player = dynamic_cast<Player *>(creature);Tile* tile = player->getTile();if(tile->isSpecialArea() && IsSpecialWords(text, creature)){ player->sendTextMessage(MSG_BLUE_TEXT, "A Secret Passage has been open!");}agora no final adicione :
void Game::doSpecialAreaList(int x, int y, int z, int id, std::string words, std::string files){specialarea[id][0] = x;specialarea[id][1] = y;specialarea[id][2] = z;word[id] = words;file[id] = files;}bool Game::IsSpecialWords(const std::string& text, Creature* creature){Position pos = creature->getPosition();for(int specialarea_list = 0; specialarea_list < 100; specialarea_list++){ if(pos.x == specialarea[specialarea_list][0] && pos.y == specialarea[specialarea_list][1] && pos.z == specialarea[specialarea_list][2] && word[specialarea_list] == text){ ReturnFileName(specialarea_list); return true; }}return false; }bool Game::loadSpecialAreas() { std::string file="data/Special Areas/Special_Areas.xml"; xmlDocPtr doc; doc = xmlParseFile(file.c_str()); if (doc) { xmlNodePtr root, tmp; root = xmlDocGetRootElement(doc); if (xmlStrcmp(root->name, (const xmlChar*)"SpecialAreas")) { xmlFreeDoc(doc); return -1; } tmp = root->children; while(tmp) { if (strcmp((const char*) tmp->name, "area")==0){ unsigned int id = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id")); unsigned int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); unsigned int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); unsigned char z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); std::string text = (const char*)xmlGetProp(tmp, (const xmlChar *) "words");; std::string file = (const char*)xmlGetProp(tmp, (const xmlChar *) "file");; doSpecialAreaList(x, y, z, id, text, file); Tile* tile = map->getTile(x, y, z); if (tile){ tile->setFlag(TILESTATE_SPECIALAREA); } } tmp=tmp->next; } xmlFreeDoc(doc); return 0; } return -1;}int Game::ReturnFileName(int id){loadSpecialID(file[id], id);}bool Game::loadSpecialID(std::string safile, int id) { std::string file="data/Special Areas/"+safile+".xml"; xmlDocPtr doc; doc = xmlParseFile(file.c_str()); if (doc) { xmlNodePtr root, tmp, tmw; root = xmlDocGetRootElement(doc); if (xmlStrcmp(root->name, (const xmlChar*)"SpecialAreas")) { xmlFreeDoc(doc); return -1; } tmp = root->children; while(tmp) { //well... lets add an Item if (strcmp((const char*) tmp->name, "item")==0){ unsigned int item_id = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id")); unsigned int item_count = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "count")); unsigned int item_oldid = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "oldid")); unsigned int item_x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); unsigned int item_y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); unsigned int item_z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); unsigned int item_time = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "time")); AddnewItem(id, item_id, item_count, item_oldid, item_x, item_y, item_z, item_time); } // well, the ground should be the same but... i like to make the things bigger hahaha if (strcmp((const char*) tmp->name, "ground")==0){ unsigned int item_id = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id")); unsigned int item_oldid = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "oldid")); unsigned int item_x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); unsigned int item_y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); unsigned int item_z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); unsigned int item_time = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "time")); AddnewItem(id, item_id, 0, item_oldid, item_x, item_y, item_z, item_time); } if (strcmp((const char*) tmp->name, "monster")==0){ std::string npc_name = (const char*) xmlGetProp(tmp, (const xmlChar*) "name"); unsigned int posx = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); unsigned int posy = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); unsigned int posz = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); SummonNPC(npc_name, posx, posy, posz, 1); } if (strcmp((const char*) tmp->name, "npc")==0){ std::string npc_name = (const char*) xmlGetProp(tmp, (const xmlChar*) "name"); unsigned int posx = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); unsigned int posy = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); unsigned int posz = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); SummonNPC(npc_name, posx, posy, posz, 0); } tmp=tmp->next; } xmlFreeDoc(doc); return 0; } return -1;}void Game::AddnewItem(int area_id, int id, int count, int oldid, int x, int y, int z, int time){if(donotdothat[area_id] == 0){ Tile* tile = map->getTile(x, y, z);if(count != 0){ Item* item = Item::CreateItem(id); internalAddItem(tile, item); addEvent(makeTask(1000, boost::bind(&Game::AddnewItem, this, area_id, id, 0, oldid, x, y, z, time))); donotdothat[area_id] = 1;}else{ Item* item = Item::CreateItem(id, count); internalAddItem(tile, item);}}else if(donotdothat[area_id] == 1){ Tile* tile = map->getTile(x, y, z); Item* newground = Item::CreateItem(oldid); internalAddItem(tile, newground); donotdothat[area_id] = 0;}} void Game::SummonNPC(std::string name, int x, int y, int z, int kind){Position pos;pos.x = x;pos.y = y;pos.z = z;if(kind == 0){Npc* npc = new Npc(name); if(!npc->isLoaded()) delete npc; if(!placeCreature(pos, npc)) delete npc;}else{Monster* npc = Monster::createMonster(name);if(!npc)delete npc;if(!placeCreature(pos, npc))delete npc;}}game.h
Em baixo de "Public" adicione :
tile.cpp
procure por :
void Tile::setPz(){ setFlag(TILESTATE_PROTECTIONZONE);}adicione após :
bool Tile::isSpecialArea() const{ return hasFlag(TILESTATE_SPECIALAREA);}tile.h
após :
adicione uma vírgula no final do 2 e isto no final:
ficando assim :
enum tileflags_t{ TILESTATE_NONE = 0, TILESTATE_PROTECTIONZONE = 1, TILESTATE_HOUSE = 2, TILESTATE_SPECIALAREA = 3};após:
adicione :
otserv.cpp
procure por:
std::pair<unsigned long, unsigned long> IpNetMask; IpNetMask.first = inet_addr("127.0.0.1"); IpNetMask.second = 0xFFFFFFFF; serverIPs.push_back(IpNetMask);antes adicione :
std::cout << ":: Loading Special Areas ... "; if(g_game.loadSpecialAreas()){ ErrorMessage("Could not load Special_Areas.xml ...!"); return -1; } std::cout << "[done]" << std::endl;acho que postei todas as funções.
Agora crie uma pasta dentro da sua pasta data com o nome de "Special Areas", dentro dela um arquivo XML chamado "Special_Areas".
um exemplo de arquivo Special_Areas.xml
Special_Areas.xml
os arquivos a serem lidos serão respectivamente o "file" escrito.
exemplo da área 1 ( anterior ):
1.xml
Existe 4 funções para você utilizar no XML da Area Respectiva :
<ground id="ID_NO_QUAL_VAI_MUDAR" oldid="NÃO_FUNFA" x="POSIÇÃO_X" y="POSIÇÃO_Y" z="POSIÇÃO_Z" time="NÃO_FUNFA"/>
<item id="ID_NO_QUAL_VAI_MUDAR" count="QUANTIDADE_OU_TIPO_DO_ITEM" oldid="NÃO_FUNFA" x="POSIÇÃO_X" y="POSIÇÃO_Y" z="POSIÇÃO_Z" time="NÃO_FUNFA"/>
<monster name="NOME_DO_MONSTRO" x="POSIÇÃO_X" y="POSIÇÃO_Y" z="POSIÇÃO_Z"/>
<npc name="NOME_DO_NPC" x="POSIÇÃO_X" y="POSIÇÃO_Y" z="POSIÇÃO_Z"/>
E como configurar o Special_Areas.xml :
<area id="ID_DA_AREA" x="POSIÇÃO_X" y="POSIÇÃO_Y" z="POSIÇÃO_Z" words="PALAVRAS QUE TEM QUE FALAR NAQUELE TILE" file="ARQUIVO DA ÁREA"/>
Lembrando :
NÃO Oferecerei suporte a perguntas do tipo :
O que são Sources?
Onde fica o Game.cpp?
O que esse code faz?
e qualquer outra pergunta idiota do típico de pessoas que não lêem o inteiro.
Kyo ~*
Editado Março 11 por honux