Ir para conteúdo

Pesquisar na Comunidade

Mostrando resultados para as tags ''tesãozinho''.



Mais opções de pesquisa

  • Pesquisar por Tags

    Digite tags separadas por vírgulas
  • Pesquisar por Autor

Tipo de Conteúdo


Fóruns

  • A Cidade OTBR
    • OTServ Brasil
    • Atendimento
    • Taverna
  • Projetos Open Source
    • Canary
    • OTServBR-Global
    • Mehah OTClient
    • MyAAC
  • OpenTibia
    • Notícias e Discussões
    • Suporte - Dúvidas, Bugs, Erros
    • Downloads
    • Tutoriais
    • Show-Off
  • Outros
    • Design

Encontrado 1 registro

  1. onGainExp

    Explicação: É uma função/callback (chame do que quiser) que funciona quando o player ganha Experiencia. Ótimo pra usar em sistemas de PET e Pokemons com leveis. Instalação: Vá no arquivo creatureevent.h e depois de CREATURE_EVENT_OUTFIT, Coloque isso: CREATURE_EVENT_GAINEXP, E depois de: uint32_t executeOutfit(Creature* creature, const Outfit_t& old, const Outfit_t& current); Adicione isso: uint32_t executeGainExp(Player* player, int32_t value); Agora abra o arquivo creatureevent.cpp e depois disso: else if(tmpStr == "outfit") m_type = CREATURE_EVENT_OUTFIT; Adicione isso: else if(tmpStr == "gainexp") m_type = CREATURE_EVENT_GAINEXP; Agora procure por isso: case CREATURE_EVENT_OUTFIT: return "onOutfit"; E adicione isso após: case CREATURE_EVENT_GAINEXP: return "onGainExp"; Agora procure por: case CREATURE_EVENT_OUTFIT: return "cid, old, current"; E adicione isso após: case CREATURE_EVENT_GAINEXP: return "cid, value"; E após: uint32_t CreatureEvent::executeStatsChange Adicione isso: uint32_t CreatureEvent::executeGainExp(Player* player, int32_t value) { //onGainExp(cid, value) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local value = " << value << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEvent(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, value); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::executeGainExp] Call stack overflow." << std::endl; return 0; } } Agora vá em players.cpp e procure por: bool Player::gainExperience(double& gainExp, Creature* target) E troque por: bool Player::gainExperience(double& gainExp, Creature* target) { if(!rateExperience(gainExp, target)) return false; if(gainExp >= 1) { bool deny = false; CreatureEventList gainExpEvents = this->getCreatureEvents(CREATURE_EVENT_GAINEXP); for(CreatureEventList::iterator it = gainExpEvents.begin(); it != gainExpEvents.end(); ++it) { if(!(*it)->executeGainExp(this, gainExp)) deny = true; } if(deny) return false; if(gainExp >= level) { if(Condition* condition = Condition::createCondition( CONDITIONID_DEFAULT, CONDITION_SOUL, 4 * 60 * 1000)) { condition->setParam(CONDITIONPARAM_SOULGAIN, vocation->getGainAmount(GAIN_SOUL)); condition->setParam(CONDITIONPARAM_SOULTICKS, (vocation->getGainTicks(GAIN_SOUL) * 1000)); addCondition(condition); } } addExperience((uint64_t)gainExp); } } Utilização: Para usar é só criar um creaturescripts mais ou menos assim: function onGainExp(cid, value) local k,x = storage, value if getPlayerStorageValue(cid,k) > x then return false -- não vai ganhar exp end return true -- vai ganhar exp end
×