• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[C++]New Creature Event

Exedion

Active Member
Joined
Jun 11, 2007
Messages
629
Reaction score
30
Is there any way to make "onGainExperience(cid, value)"??

If so, could post it here?
 
What this function should to do??
This function will be executed when the player gain exp (by killing monster or by a function)
It would be cool if you could return false and that you can add extra exp etc..
yes, with TRUE and FALSE booleans

maybe can be make in this function of player.cpp

[cpp]bool Player::gainExperience(double& gainExp, Creature* target)
{
if(!rateExperience(gainExp, target))
return false;

//soul regeneration
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);
return true;
}[/cpp]

or maybe in creature.cpp

[cpp]void Creature::onGainExperience(double& gainExp, Creature* target, bool multiplied)
{
if(gainExp <= 0)
return;

if(master)
{
gainExp = gainExp / 2;
master->onGainExperience(gainExp, target, multiplied);
}
else if(!multiplied)
gainExp *= g_config.getDouble(ConfigManager::RATE_EXPERIENCE);

int16_t color = g_config.getNumber(ConfigManager::EXPERIENCE_COLOR);
if(color < 0)
color = random_range(0, 255);

std::stringstream ss;
ss << (uint64_t)gainExp;
g_game.addAnimatedText(getPosition(), (uint8_t)color, ss.str());
}

void Creature::onGainSharedExperience(double& gainExp, Creature* target, bool multiplied)
{
if(gainExp <= 0)
return;

if(master)
{
gainExp = gainExp / 2;
master->onGainSharedExperience(gainExp, target, multiplied);
}
else if(!multiplied)
gainExp *= g_config.getDouble(ConfigManager::RATE_EXPERIENCE);

int16_t color = g_config.getNumber(ConfigManager::EXPERIENCE_COLOR);
if(color < 0)
color = random_range(0, 255);

std::stringstream ss;
ss << (uint64_t)gainExp;
g_game.addAnimatedText(getPosition(), (uint8_t)color, ss.str());
}[/cpp]
 
Last edited:
Back
Top