Ir para conteúdo

[CreatureScripts]Function onGainExp(cid, value)


Posts Recomendados

Créditos:knightxd


creatureevent.h

 

depois de:

[codeCREATURE_EVENT_OUTFIT,[/code]

adicione:
CREATURE_EVENT_GAINEXP,

 

depois de:

uint32_t executeOutfit(Creature* creature, const Outfit_t& old, const Outfit_t& current);

 

adicione:

uint32_t executeGainExp(Player* player, int32_t value);


creatureevent.cpp

 

depois de:

else if(tmpStr == "outfit")
m_type = CREATURE_EVENT_OUTFIT;

 

adicione:

else if(tmpStr == "gainexp")
m_type = CREATURE_EVENT_GAINEXP;

 

depois de:

case CREATURE_EVENT_OUTFIT:
return "onOutfit";

 

adicione:

case CREATURE_EVENT_GAINEXP:
return "onGainExp";

 

depois de:

case CREATURE_EVENT_OUTFIT:
return "cid, old, current";

 

adicione:

case CREATURE_EVENT_GAINEXP:
return "cid, value";

 

depois de:

uint32_t CreatureEvent::executeStatsChange

 

adicione:

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;
}
}


players.cpp

 

procure por:

bool Player::gainExperience(double& gainExp, Creature* target)

 

substitua:


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);
}
}

Link para o comentário
Compartilhar em outros sites

  • 1 month later...

vc nem testo a parada e ja vai postando

n dis nem pa ki verção e isso ai

 

ja tinha visto o poste do kinght

essa script n funciona

 

ps: v 0.4

Editado por Foxkbt
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...