if source:getMaster() then
return
end
if not source or source:isPlayer() then
return exp
end
no, since if you add exp to a player without a source, you can't use the method to get master on nil valueShouldn't he put it before not after?
That is it /\ /\ lolHe means he doesn't want summons to gain exp
if you dont want to do it in sources, you might be able to register a creature event for gaining xp (not sure if it works on creatures), and add the xp gained to its master
void Creature::onGainExperience(uint64_t gainExp, Creature* target)
{
if (gainExp == 0 || !master) {
return;
}
gainExp /= 2;
master->onGainExperience(gainExp, target);
SpectatorVec list;
g_game.map.getSpectators(list, position, false, true);
if (list.empty()) {
return;
}
TextMessage message(MESSAGE_EXPERIENCE_OTHERS, ucfirst(getNameDescription()) + " gained " + std::to_string(gainExp) + (gainExp != 1 ? " experience points." : " experience point."));
message.position = position;
message.primary.color = TEXTCOLOR_WHITE_EXP;
message.primary.value = gainExp;
for (Creature* spectator : list) {
spectator->getPlayer()->sendTextMessage(message);
}
}
void Creature::addDamagePoints(Creature* attacker, int32_t damagePoints)
{
if (damagePoints <= 0) {
return;
}
uint32_t attackerId = attacker->id;
auto it = damageMap.find(attackerId);
if (it == damageMap.end()) {
CountBlock_t cb;
cb.ticks = OTSYS_TIME();
cb.total = damagePoints;
damageMap[attackerId] = cb;
} else {
it->second.total += damagePoints;
it->second.ticks = OTSYS_TIME();
}
lastHitCreatureId = attackerId;
}
not really, since if you can get how much the creature is getting, you can transfer the exp to the player so that the player doesn't lose out on any exp@mezuf98
This is only a visual enchantment, why you want that summons not gain exp?
stealing exp? what you mean, explain me a lil bit plsI want to the summons dont steal exp from the Player... The player gain all exp.
thanks all, but not solved =(
when you have a summon and it hits a monster, some of the experience from that monster goes to the summon instead of the playerstealing exp? what you mean, explain me a lil bit pls