otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.59k stars 1.06k forks source link

[Question] onManaChange(creature, attacker, manaChange, origin) #1700

Open conde2 opened 8 years ago

conde2 commented 8 years ago

How do I know if the player is gaining mana or losing mana ?

Because manaChange is always positive.

conde2 commented 8 years ago

https://github.com/otland/forgottenserver/blob/70590833b25f6b6a137c5e45ce29b254edddadf8/src/game.cpp#L4105

Shouldn't it be manaLoss? https://github.com/otland/forgottenserver/blob/70590833b25f6b6a137c5e45ce29b254edddadf8/src/game.cpp#L4120

conde2 commented 7 years ago

@WibbenZ @Mkalo Could you guys check this issue please ?

ranisalt commented 7 years ago

Shouldn't it be manaLoss?

No. manaLoss is the absolute value (on the else branch, manaChange is non-positive so manaLoss is non-negative). The value sent to onManaChange can be positive or negative, from the code you shown.

Mkalo commented 7 years ago

I do have this: https://gist.github.com/Mkalo/2b1c4bcd772e161a1200cfeb820d3aba

But I never created a PR cause I didn't have time before, I could do it if this is okay.

@ranisalt

WibbenZ commented 7 years ago

Imo this issue is kinda related to #1211, seeing as the functions need an overhaul.

Mkalo commented 7 years ago

I don't know if onManaChange should be executed for spell casting anyway, (It doesnt use any combat function just Creature::changeMana).

We could change that and make it fire a combat (Game::combatChangeMana) and use ORIGIN_SPELL.

WibbenZ commented 7 years ago

As mark wrote this function should be used as much as we can. Look at #1226