Tony Araujo 282 Posted March 18, 2019 Report Share Posted March 18, 2019 (edited) [C++] Monsters Passive System testado: TFS - 0.3.6 (porém acredito que funcione em outros) autor: Tony Araújo (OrochiElf) Eai galera, tranquilão? Estou eu aqui novamente, e hoje eu vou compartilhar com vocês um sistema que eu vejo muitas pessoas pedindo e buscando ajuda (principalmente no meu inbox kkkkk), seria ele o sistema de monstros passivos, que consiste naquela criatura que só ataca o jogador que o atacou, caso contrário ele fica andando normalmente. O sistema foi desenvolvido em cima do código do TFS 0.3.6, porém caso instale prestando bastante atenção em outras versões, funcione, talvez seja necessário mudar algum código, porém bem simples. Bom, vamos ao sistema. Em creature.cpp, procure pela função: bool Creature::setAttackedCreature(Creature* creature) E altere esta condição: if(attackedCreature) { onAttackedCreature(attackedCreature); attackedCreature->onAttacked(); } Por esta: if(attackedCreature) { onAttackedCreature(attackedCreature); attackedCreature->onAttacked(); attackedCreature->addDamagePoints(this, 0); } Procure pela função: void Creature::addDamagePoints(Creature* attacker, int32_t damagePoints) E troque por esta: void Creature::addDamagePoints(Creature* attacker, int32_t damagePoints) { uint32_t attackerId = 0; if(attacker) attackerId = attacker->isPlayerSummon() ? attacker->getMaster()->getID() : attacker->getID(); CountMap::iterator it = damageMap.find(attackerId); if(it != damageMap.end()) { it->second.ticks = OTSYS_TIME(); if(damagePoints > 0) it->second.total += damagePoints; } else damageMap[attackerId] = CountBlock_t(damagePoints); if(damagePoints > 0) lastHitCreature = attackerId; } Agora vá em monster.cpp e procure pela função: void Monster::onThink(uint32_t interval) E dentro dela, procure pela condição: else if(!targetList.empty()) E troque por esta: else if(!targetList.empty()) { if(!followCreature || !hasFollowPath) searchTarget(); } Procure pela função: bool Monster::selectTarget(Creature* creature) E troque por esta: bool Monster::selectTarget(Creature* creature) { #ifdef __DEBUG__ std::cout << "Selecting target... " << std::endl; #endif if(!isTarget(creature)) return false; uint32_t targetId = creature->isPlayerSummon() ? creature->getMaster()->getID() : creature->getID(); if(!isHostile() && !hasBeenAttacked(targetId)) return false; CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature); if(it == targetList.end()) { //Target not found in our target list. #ifdef __DEBUG__ std::cout << "Target not found in targetList." << std::endl; #endif return false; } if(setAttackedCreature(creature)) Dispatcher::getInstance().addTask(createTask(boost::bind(&Game::checkCreatureAttack, &g_game, getID()))); return setFollowCreature(creature, true); } Bom galera, espero que gostem e que façam bom uso. Qualquer bug ou problema, comenta aí pra eu resolver. Edited March 18, 2019 by Tony Araujo FlamesAdmin, Mixlortt, nociam and 7 others 9 1 Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/ Share on other sites More sharing options...
Walox 46 Posted March 18, 2019 Report Share Posted March 18, 2019 Muito bom cara! Parabéns em ^^ Vai ajudar muito os OTADMINS. E que venha contribuindo mais e mais com a comunidade ❤️ segura meu REP+ Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1750001 Share on other sites More sharing options...
boxxer321 67 Posted March 18, 2019 Report Share Posted March 18, 2019 O Pokémon vira agressivo para todos os jogadores ou somente para qm atacou? Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1750003 Share on other sites More sharing options...
Tony Araujo 282 Posted March 18, 2019 Author Report Share Posted March 18, 2019 Agora, boxxer321 disse: O Pokémon vira agressivo para todos os jogadores ou somente para qm atacou? Somente pra quem atacou. Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1750004 Share on other sites More sharing options...
Ayron5 40 Posted March 18, 2019 Report Share Posted March 18, 2019 2 horas atrás, Tony Araujo disse: [C++] Monsters Passive System testado: TFS - 0.3.6 (porém acredito que funcione em outros) autor: Tony Araújo (OrochiElf) Eai galera, tranquilão? Estou eu aqui novamente, e hoje eu vou compartilhar com vocês um sistema que eu vejo muitas pessoas pedindo e buscando ajuda (principalmente no meu inbox kkkkk), seria ele o sistema de monstros passivos, que consiste naquela criatura que só ataca o jogador que o atacou, caso contrário ele fica andando normalmente. O sistema foi desenvolvido em cima do código do TFS 0.3.6, porém caso instale prestando bastante atenção em outras versões, funcione, talvez seja necessário mudar algum código, porém bem simples. Bom, vamos ao sistema. Em creature.cpp, procure pela função: bool Creature::setAttackedCreature(Creature* creature) E altere esta condição: if(attackedCreature) { onAttackedCreature(attackedCreature); attackedCreature->onAttacked(); } Por esta: if(attackedCreature) { onAttackedCreature(attackedCreature); attackedCreature->onAttacked(); attackedCreature->addDamagePoints(this, 0); } Procure pela função: void Creature::addDamagePoints(Creature* attacker, int32_t damagePoints) E troque por esta: Mostrar conteúdo oculto void Creature::addDamagePoints(Creature* attacker, int32_t damagePoints) { uint32_t attackerId = 0; if(attacker) attackerId = attacker->isPlayerSummon() ? attacker->getMaster()->getID() : attacker->getID(); CountMap::iterator it = damageMap.find(attackerId); if(it != damageMap.end()) { it->second.ticks = OTSYS_TIME(); if(damagePoints > 0) it->second.total += damagePoints; } else damageMap[attackerId] = CountBlock_t(damagePoints); if(damagePoints > 0) lastHitCreature = attackerId; } Agora vá em monster.cpp e procure pela função: void Monster::onThink(uint32_t interval) E dentro dela, procure pela condição: else if(!targetList.empty()) E troque por esta: else if(!targetList.empty()) { if(!followCreature || !hasFollowPath) searchTarget(); } Procure pela função: bool Monster::selectTarget(Creature* creature) E troque por esta: Mostrar conteúdo oculto bool Monster::selectTarget(Creature* creature) { #ifdef __DEBUG__ std::cout << "Selecting target... " << std::endl; #endif if(!isTarget(creature)) return false; uint32_t targetId = creature->isPlayerSummon() ? creature->getMaster()->getID() : creature->getID(); if(!isHostile() && !hasBeenAttacked(targetId)) return false; CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature); if(it == targetList.end()) { //Target not found in our target list. #ifdef __DEBUG__ std::cout << "Target not found in targetList." << std::endl; #endif return false; } if(setAttackedCreature(creature)) Dispatcher::getInstance().addTask(createTask(boost::bind(&Game::checkCreatureAttack, &g_game, getID()))); return setFollowCreature(creature, true); } Bom galera, espero que gostem e que façam bom uso. Qualquer bug ou problema, comenta aí pra eu resolver. Muito bom brother! Eu consegui esse mesmo resultado usando outro tutorial antigamente kkk Vai ajudar muita gente, parabéns! Reputado+! Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1750005 Share on other sites More sharing options...
FlamesAdmin 261 Posted March 18, 2019 Report Share Posted March 18, 2019 #off parece que teremos um server svke aqui? #topic belo trabalho Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1750010 Share on other sites More sharing options...
Tony Araujo 282 Posted March 18, 2019 Author Report Share Posted March 18, 2019 3 horas atrás, Ayron5 disse: Muito bom brother! Eu consegui esse mesmo resultado usando outro tutorial antigamente kkk Vai ajudar muita gente, parabéns! Reputado+! De nada brother. Eu lembro, tinha um tutorial antigo, porém eu vi muita gente tendo muita dificuldade pra instalar, e o código também tava um pouco confuso. Daí resolvi postar esse aqui pra galera 24 minutos atrás, FlamesAdmin disse: #off parece que teremos um server svke aqui? #topic belo trabalho Temos sim brother kkkkk, www.facebook.com/oldPokemonOT inclusive to fazendo open test nele hoje. Se quiser aparecer por lá. Volta as 17h Obrigado mano ;D Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1750011 Share on other sites More sharing options...
FlamesAdmin 261 Posted March 18, 2019 Report Share Posted March 18, 2019 @Tony Araujo opa, se der apareço sim. Vai ser uma honra Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1750013 Share on other sites More sharing options...
XZero 68 Posted March 21, 2019 Report Share Posted March 21, 2019 Tem alguma função especifica para setar o pokémon para ser passivo ? Não cheguei a testar, mas creio que todos os pokémons ficam passivos certo ? Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1750108 Share on other sites More sharing options...
Tony Araujo 282 Posted March 22, 2019 Author Report Share Posted March 22, 2019 4 horas atrás, XZero disse: Tem alguma função especifica para setar o pokémon para ser passivo ? Não cheguei a testar, mas creio que todos os pokémons ficam passivos certo ? É aquela tag <flag hostile="0"/> do monster, se for 0, ele é passivo XZero 1 Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1750115 Share on other sites More sharing options...
psalex 0 Posted July 13, 2019 Report Share Posted July 13, 2019 fiz e não deu certo aqui, compilo a source sem erros, mas não deu nenhum resultado, mesmo colocando <flag hostile="0"/> no monster, ele continua agressivo. Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1752473 Share on other sites More sharing options...
FlamesAdmin 261 Posted July 13, 2019 Report Share Posted July 13, 2019 1 hora atrás, psalex disse: fiz e não deu certo aqui, compilo a source sem erros, mas não deu nenhum resultado, mesmo colocando <flag hostile="0"/> no monster, ele continua agressivo. tenta colocar essas duas <flag hostile="0"/> <flag passive="0"/> Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1752476 Share on other sites More sharing options...
FlamesAdmin 261 Posted July 27, 2019 Report Share Posted July 27, 2019 Único problema no sistema é quando vc ataca o monstro passivo, sobe uma escada e espera uns 10 segundos +/- e desce, vc precisa atacar o monstro novamente Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1752658 Share on other sites More sharing options...
sirvitor4 0 Posted November 24, 2019 Report Share Posted November 24, 2019 Compilei tudo certinho mas o pokemon continua hostil mesmo sem a flag hostil/passive(ou com) e mesmo com o passivepokemons comentado... Alguém tem um solução? Base pokemasterx Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1754864 Share on other sites More sharing options...
Albe 1 Posted December 29, 2019 Report Share Posted December 29, 2019 Em 24/11/2019 em 00:38, sirvitor4 disse: Compilei tudo certinho mas o pokemon continua hostil mesmo sem a flag hostil/passive(ou com) e mesmo com o passivepokemons comentado... Alguém tem um solução? Base pokemasterx Eu vi um servidor "pokemasterX" com pokemons passivos ONLINE (continua). Essa basa já não tem o sistema de passivos nela? (mesmo que aparentemente não esteja funcionando). Link to comment https://xtibia.com/forum/topic/249401-c-monsters-passive-system-no-bugs/#findComment-1755651 Share on other sites More sharing options...
Recommended Posts