Muito bom em o/ posta mais funções XD
- Forums
- OTServ
- Recursos
- Linguagens de Programação
- onSetOpponnent(cid, monster)
CA
onSetOpponnent(cid, monster)
By caotic, 17 de abr. de 2014 in Linguagens de Programação
onsetopponent
script
8
1.3k
info
Group: Banidos
Joined: 08/01/13
Posts: 105
Reputation: +19
Tibia Character: LordParaibano

17 de abril de 2014 às 03:22
17 de abril de 2014 às 08:55
onTarget?
info
Group: Príncipe
Joined: 19/08/10
Posts: 4k
Reputation: +1.1k
Gender: Masculino

17 de abril de 2014 às 09:32
e n faltou dizer aonde ela vai ser chamada nas sources? ![]()
17 de abril de 2014 às 09:52
Otima função ![]()
info
Group: Infante
Joined: 04/03/11
Posts: 1.6k
Reputation: +393
Tibia Character: No Have

17 de abril de 2014 às 10:53
Na verdade onSetOpoonent acontence antes do player ir para o targerlist.onTarget?
...
falto sim xD
bem..
ja foi colocado
Edited Abril 17 by caotic
17 de abril de 2014 às 11:28
Na verdade onSetOpoonent acontence antes do player ir para o targerlist.
...
falto sim xD
bem..
ja foi colocado
Então ela só pode ser utilizada por monstros, afinal eles que possuem targetlist e friendlist, correto?
Edited Abril 17 by Garou







info
Group: Infante
Joined: 04/03/11
Posts: 1.6k
Reputation: +393
Tibia Character: No Have
Ola galera xtibanaana.
O creatureevent onsetopponent acontence quando uma criatura seta outra como opponent para ir prosseguir como target.
Vá em creatureevent.cpp e procure:
Adicione embaixo:
Procure:
Coloque embaixo:
Continuado procure:
Coloque abaixo:
Adicione a função:
uint32_t CreatureEvent::executeSetOpponent(Creature* creature, Creature* target) { //onSetOpponent(cid, monster) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << 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", creature->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executePrepareDeath] Call stack overflow." << std::endl; return 0; } }Vá em creatureevent.h e procure:
Adicione embaixo:
Procure:
Coloque embaixo:
Vá em monster.cpp e procure a função:
Substitua por essa:
bool Monster::isOpponent(const Creature* creature) { bool opponent = true; CreatureEventList attackEvents = getCreatureEvents(CREATURE_EVENT_OPPONENT); Creature* target = g_game.getCreatureByID(creature->getID()); for(CreatureEventList::iterator it = attackEvents.begin(); it != attackEvents.end(); ++it) { if(!(*it)->executeSetOpponent(target, this)) opponent = false; } if (!opponent) { return false; } return (isSummon() && getMaster()->getPlayer() && creature != getMaster()) || ((creature->getPlayer() && !creature->getPlayer()->hasFlag(PlayerFlag_IgnoredByMonsters)) || (creature->getMaster() && creature->getMaster()->getPlayer())); }Exemplo:
function onSetOpponent(cid, target) local blockedpass = {"Fire Devil", "Demon", "Lord Dragon"} if table.find(blockedpass, getCreatureName(target)) then return true end return true endEdited Abril 17 by caotic