Magic gets messed up when saving
I know I ask a lot of questions, but this is TEH IMPORTANTZORZ!
In my DMOD, in the START-1.C I add three magic spells along with Dink's fists. They all work fine and everything (It's these three spells from dink's source: item-fb.c, item-ice.c, item-sfb.c. I assume those are fireball, acid rain, and hellfire, yeah?).
But if I save with one of the spells equipped, then load that save game, for some reason it disarms the spell. So the green bar fills up around the magic box, but there's no spell in there and if you try to cast it Dink says his thing about not knowing any magic. Anyone know what could be causing this? I haven't edited them yet apart from changing the &magic_cost variable.
You can obviously re-equip it via the inventory, but it's kinda a hassle and I just don't get what is going wrong here...
NOTE: This only seems to be the case with acid rain and hellfire. If I save with the normal fireball equipped then it works fine
In my DMOD, in the START-1.C I add three magic spells along with Dink's fists. They all work fine and everything (It's these three spells from dink's source: item-fb.c, item-ice.c, item-sfb.c. I assume those are fireball, acid rain, and hellfire, yeah?).
But if I save with one of the spells equipped, then load that save game, for some reason it disarms the spell. So the green bar fills up around the magic box, but there's no spell in there and if you try to cast it Dink says his thing about not knowing any magic. Anyone know what could be causing this? I haven't edited them yet apart from changing the &magic_cost variable.
You can obviously re-equip it via the inventory, but it's kinda a hassle and I just don't get what is going wrong here...
NOTE: This only seems to be the case with acid rain and hellfire. If I save with the normal fireball equipped then it works fine

It seems to happen when you have more magic than items in your inventory. Having at least as much items as magic is the only way to fix it as far as I know.
well for what i know it is a engine bug as i also happens with weapons if anything else but the main weapon is equipped(usually the fists). and I've seen it happen in each and every D-mod i did(and i mean them all not counting I kara Gu as that only had i weapon(if you don't count the element swapping of it) even in some non combat ones(though there it didn't aid you by free stat points) and well for me it as you probably figured isn't just for magic also purchased weapons. and sorry to disappoint Erwin but that doesn't fix it as i had it with equal amounts of spells and inventory.
and dunno with causes it but seems like a hardcode counter error in the saving system. though I'm not sure as i'm no expert nor created it.
and dunno with causes it but seems like a hardcode counter error in the saving system. though I'm not sure as i'm no expert nor created it.
Alright then, I guess I'll just remove the other magics
Couldn't you just have him start with elixers or something like that?
you could have placeholder items, like I did in my armour demo.
Or just save the slot you have the weapon/magic equiped in in a global variable and reload it on loading (attach it to the main procedure of the savebot for example).
March 3rd 2011, 08:58 AM

JugglyGhost


Hey, that's actually not a bad idea, Kyle.
I'll try that when I get back to my laptop
I'll try that when I get back to my laptop

Doesn't work... But I don't really need all the magic, so I'll probably just remove them and leave hell-fire or something...

Why won't it work?
Just make global ints so that you will increase one when equipping a certain spell and decrease it when you take it off. And then when loading the save game just make sure that if &hellfirespell, for example, is 1 then equip it. If not, then do nothing.
Just make global ints so that you will increase one when equipping a certain spell and decrease it when you take it off. And then when loading the save game just make sure that if &hellfirespell, for example, is 1 then equip it. If not, then do nothing.
Exactly what Skull said, except, you only need one global variable really, to store the slot number in of the equiped spell

Huh... I hadn't thought of doing it that way. I made a global called &oldmagic, which was updated whenever the player saved. So the save machine had &oldmagic = &cur_magic just before the save_game();.
And then in START-2.C (or whichever it is for loading) I had it load the game then &cur_magic = &oldmagic then arm_magic();. Not sure why, but that didn't work. Skull's way might though, I'm not sure... Anyway, it's all too much hassle and I've already removed the other magic now so... Yeah. Other than this, my DMOD's coming along nicely now.
I had a bit of a scare earlier when I realised how far behind schedule I was, but I'm managing to speed up a bit (hopefully I don't get too sloppy).
And then in START-2.C (or whichever it is for loading) I had it load the game then &cur_magic = &oldmagic then arm_magic();. Not sure why, but that didn't work. Skull's way might though, I'm not sure... Anyway, it's all too much hassle and I've already removed the other magic now so... Yeah. Other than this, my DMOD's coming along nicely now.
I had a bit of a scare earlier when I realised how far behind schedule I was, but I'm managing to speed up a bit (hopefully I don't get too sloppy).
Why would you delete the magic if you now have a way of fixing it? Quitters, argh!