• 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!

Fix/Patch [CreatureEvent] onAdvance "SKILL__EXPERIENCE"

Exedion

Active Member
Joined
Jun 11, 2007
Messages
628
Reaction score
30
This is a small patch to give a better use of parameters in "onAdvance" creature event with "SKILL__EXPERIENCE", take a look:


if you use a script like this:
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
	if(skill == SKILL__EXPERIENCE) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Exp1: ".. oldLevel ..". Exp2: ".. newLevel ..".")
		return false
	end

you will get a message like this:
Code:
Exp1: 5320. Exp2: 5320.

because "oldLevel" and "newLevel" give the same result: the exp for next level.

with this small patch you can get the current experience gained with "oldLevel" and with "newLevel" you get the experience for next level.

in player.cpp fin this code:

[cpp]
CreatureEventList advanceEvents = getCreatureEvents(CREATURE_EVENT_ADVANCE);
for(CreatureEventList::iterator it = advanceEvents.begin(); it != advanceEvents.end(); ++it)
(*it)->executeAdvance(this, SKILL__EXPERIENCE, tmp, experience);
[/cpp]

and remplace with:

[cpp]
CreatureEventList advanceEvents = getCreatureEvents(CREATURE_EVENT_ADVANCE);
for(CreatureEventList::iterator it = advanceEvents.begin(); it != advanceEvents.end(); ++it)
(*it)->executeAdvance(this, SKILL__EXPERIENCE, gainExp, experience);
[/cpp]

now when you get 1200 exp for killing a monster, your message will be:
Code:
Exp1: 1200. Exp2: 5320.

enjoy.
 
idk, but when you use SKILL__EXPERIENCE at skill in onAdvance, not show you current gained experience with any parameter, with oldLevel and newLevel, ever show the experience needed for next level, with this patch you can return the current gained experience, for many purposes like add bonus experience based in the experience gained for each creature, or shared custom exp with a pet or special summon (in my case) or any else :)
 
Back
Top