Magic

Magic

190k Downloads

Get wand spells

christophe6 opened this issue · 5 comments

commented

Hi

I'm trying to get wether a player has all the spells for his wand path but it seems like the getSpells() list is empty and hasSpell(String spell) always returns false. I do not know why because the player has the spells.

CODE: https://hastebin.com/yutivebice.cs

Thanks!

commented

Is the player holding the wand when you make these checks?

You may be better off checking the player’s active class - the wand doesn’t actually contain spells anymore, though it should advertise them if the player is holding them.

commented

More info: maybe try

mage.getActiveClass().getSpells()

Or hasSpell- MageClass and Wand share the CasterProperties interface, but classes should always work while wands (with the current survival setup) will only work when active and held.

commented

Wow, thanks! Got that fixed with the getActiveWand() method. I'm trying to upgrade a wand to the next path but the energy is not modified upon upgrade. Do you know a fix for that?
https://hastebin.com/bebiraxaqa.coffeescript

commented

Sorry for the late reply! So this is kind of a tricky area, just calling setPath won't really "upgrade" the wand, it just changes the path.

You instead need to call WandUpgradePath.upgrade() - here's an example (this is from UpgradePathAction)

            WandUpgradePath path = wand.getPath();
            WandUpgradePath nextPath = path != null ? path.getUpgrade() : null;
            if (nextPath != null && path.checkUpgradeRequirements(wand, null) && !path.canEnchant(wand)) {
                path.upgrade(wand, mage);
                return SpellResult.CAST;
            }

Let me know if that makes sense!

commented

Sorry for the late reply but it did work ;)! Thanks!