ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Thu Feb 23, 2017 11:32 am

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Thu Oct 10, 2013 7:59 pm 
Offline
Uruivellas

Joined: Tue Dec 13, 2005 12:35 am
Posts: 702
I've noticed that the Golemcraft realm in my T2 fork doesn't always use mana, or take a turn to cast. About 4 times out of 5, golem summoning spells are cast instantly and without any mana use. Obviously this is really bad, and not intended behavior.

I have the spells and the mkey defined correctly AFAICT, and the schools system is supposed to handle turns and mana pretty much automatically; so I'm left wondering if there's a bug somewhere in the Lua subsystem. For the record this is still based on 2.3.9-ah (the last version using Lua).

(And yes, if I had my druthers I'd rewrite the whole thing in Python/TkInter or something, and solve the interface proble too. Unfortunately I have neither the time nor the expertise at thsi point.)

_________________
"These aren't the hobbits you're looking for."


Top
 Profile  
 
PostPosted: Fri Oct 11, 2013 1:56 pm 
Offline
Sher'Tul

Joined: Wed Jan 07, 2004 5:01 pm
Posts: 1302
Location: Finland
This is most likely not related at all but reminds me of monster possession in which you can often use abilities without cost.

Just wondering if it's possible your spells to be linked into those skills or something.

_________________
Stronk is a potent combatant with a terrifying appearance.


Top
 Profile  
 
PostPosted: Fri Oct 11, 2013 2:40 pm 
Offline
Uruivellas

Joined: Tue Dec 13, 2005 12:35 am
Posts: 702
Probably not; Golemcraft uses the Lua subsystem, whereas Possession is implemented entirely in C. You're right though - I had seen that with Possessor powers... Thanks in any case.

_________________
"These aren't the hobbits you're looking for."


Top
 Profile  
 
PostPosted: Tue Oct 15, 2013 6:25 pm 
Offline
Spiderkin

Joined: Sat Mar 18, 2006 12:48 pm
Posts: 476
I seem to vaguely recall noticing something like the following while rewriting to C: (It's been a while, so YMMV.)

The "use-mana-and-energy" flag being returned by the Lua coda was essentially random (arbitrary) due to some sort of interface problem between the Lua and the C code. I can't really recall why, exactly, but perhaps it had something to do with using 32-bit in the return type declared in the *.pkg file versus 64-bit in the *.h file for the same function. (I recall at least one such instance, but I can't really remember if it had anything to do with this particular issue.)

Or maybe it was just a question of the Lua code not actually returning anything and the C code just assuming that something had been returned and using the un-initialized variable.

EDIT: For clarity, I'd missed a negation.


Last edited by AnonymousHero on Sun Oct 20, 2013 7:15 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Tue Oct 15, 2013 10:28 pm 
Offline
Uruivellas

Joined: Tue Dec 13, 2005 12:35 am
Posts: 702
Thank you (and blech). I will see if I can do something about it.

_________________
"These aren't the hobbits you're looking for."


Top
 Profile  
 
PostPosted: Fri Oct 18, 2013 3:46 pm 
Offline
Uruivellas

Joined: Tue Dec 13, 2005 12:35 am
Posts: 702
Hmm. I am having some trouble finding the function that indicates spell success... There is lua_spell_success(), aka magic_power_success(), but it is never called anywhere in the code. Do you recall what functions might be involved?

_________________
"These aren't the hobbits you're looking for."


Top
 Profile  
 
PostPosted: Sun Oct 20, 2013 7:20 am 
Offline
Spiderkin

Joined: Sat Mar 18, 2006 12:48 pm
Posts: 476
I think it was "cast_school_spell", but you should probably double-check everything which adjustst "p_ptr->msp" (directly or indirectly through adjust_power).


Top
 Profile  
 
PostPosted: Fri Nov 01, 2013 1:11 pm 
Offline
Uruivellas

Joined: Tue Dec 13, 2005 12:35 am
Posts: 702
Okay, the problem seems to be that the cost is only exacted if the spell fails. Weird.

(cast_school_spell() in lib/core/s_aux.lua does have a flag for disabling spell costs, but I don't think that's getting triggered. And anyway this doesn't happen with other spell schools...)

_________________
"These aren't the hobbits you're looking for."


Top
 Profile  
 
PostPosted: Thu Dec 26, 2013 2:14 pm 
Offline
Uruivellas

Joined: Tue Dec 13, 2005 12:35 am
Posts: 702
GOT IT. Finally. The problem is that Lua functions that do not return TRUE result in spells not using SP or energy. My functions were not returning anything, and so didn't work properly.

_________________
"These aren't the hobbits you're looking for."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group