Leo32
Getting back into it...
- Joined
- Sep 21, 2007
- Messages
- 987
- Solutions
- 14
- Reaction score
- 532
I've got a curly one here.
I'm using this function:
Works perfectly, for mana changes for everything (Manadrain, potions etc) EXCEPT for spells.
I've noticed other ppl have mentioned this:
Is it currently an open ticket here:
spells.cpp
I would like manachanges from player spells to go through the same CREATURE_EVENT_MANACHANGE function like everything else:
Which should solve the issue yeah?
game.cpp
The purpose is so these numbers can be manipulated and Mana Costs: -XX% attributes can be added to items.
Because my c++ is absolute trash, does anyone have any idea on what changes I'd need to make to spells.cpp(?) to do this?
I'm using this function:
Lua:
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
end
Works perfectly, for mana changes for everything (Manadrain, potions etc) EXCEPT for spells.
I've noticed other ppl have mentioned this:
Change onManaChange event. by Mkalo · Pull Request #2198 · otland/forgottenserver
Now onManaChange have the same parameters as onHealthChange and expects 4 return values as onHealthChange. That makes it more flexible to check damage type and secondary damage info. If the combat ...
github.com
[Question] onManaChange(creature, attacker, manaChange, origin) · Issue #1700 · otland/forgottenserver
How do I know if the player is gaining mana or losing mana ? Because manaChange is always positive.
github.com
Is it currently an open ticket here:
onManaChange for spells · Issue #1211 · otland/forgottenserver
onManaChange is not executed when I use spells. my script is registered correctly, because it works when a monster attacks with manadrain Want to back this issue? Post a bounty on it! We accept bou...
github.com
spells.cpp
C++:
void Spell::postCastSpell(Player* player, uint32_t manaCost, uint32_t soulCost)
{
if (manaCost > 0) {
player->addManaSpent(manaCost);
player->changeMana(-static_cast<int32_t>(manaCost)); // this is the line that needs to change AFAIK
}
if (!player->hasFlag(PlayerFlag_HasInfiniteSoul)) {
if (soulCost > 0) {
player->changeSoul(-static_cast<int32_t>(soulCost));
}
}
}
I would like manachanges from player spells to go through the same CREATURE_EVENT_MANACHANGE function like everything else:
Which should solve the issue yeah?
game.cpp
C++:
bool Game::combatChangeMana(Creature* attacker, Creature* target, CombatDamage& damage)
...
...
if (damage.origin != ORIGIN_NONE) {
const auto& events = target->getCreatureEvents(CREATURE_EVENT_MANACHANGE);
if (!events.empty()) {
for (CreatureEvent* creatureEvent : events) {
creatureEvent->executeManaChange(target, attacker, damage);
}
damage.origin = ORIGIN_NONE;
return combatChangeMana(attacker, target, damage);
}
}
...
...
The purpose is so these numbers can be manipulated and Mana Costs: -XX% attributes can be added to items.
Because my c++ is absolute trash, does anyone have any idea on what changes I'd need to make to spells.cpp(?) to do this?
Last edited: