The Dink Network

Magic gets messed up when saving

February 28th 2011, 08:52 AM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
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
March 2nd 2011, 05:15 PM
bonca.gif
Erwin
Peasant He/Him Netherlands
Friendship is magic 
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.
March 2nd 2011, 05:40 PM
knights.gif
merder
Peasant He/Him Netherlands
The Voice in the back of your head! 
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.
March 2nd 2011, 05:48 PM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
Alright then, I guess I'll just remove the other magics
March 2nd 2011, 07:58 PM
pillbug.gif
pillbug
Peasant He/Him United States
Love! True love! 
Couldn't you just have him start with elixers or something like that?
March 3rd 2011, 12:31 AM
burntree.gif
Fireball5
Peasant He/Him Australia
Let me heat that up for you... 
you could have placeholder items, like I did in my armour demo.
March 3rd 2011, 04:49 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
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
anon.gif
JugglyGhost
Ghost They/Them
 
Hey, that's actually not a bad idea, Kyle.
I'll try that when I get back to my laptop
March 5th 2011, 04:29 AM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
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...
March 5th 2011, 05:25 AM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
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.
March 5th 2011, 05:51 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
Exactly what Skull said, except, you only need one global variable really, to store the slot number in of the equiped spell
March 5th 2011, 07:57 AM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
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).
March 5th 2011, 09:40 AM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Why would you delete the magic if you now have a way of fixing it? Quitters, argh!
March 5th 2011, 09:54 AM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
Because I'm being lazy! Critics, argh!