[crossfire] Spellcasting Swords & Python Troubles

Alex Schultz alex_sch at telus.net
Wed May 25 00:49:06 CDT 2005


Andreas Kirschbaum wrote:

>
     
     Alex Schultz wrote:
     
     >
     
     
     >>
     
     From further analysis, I found that it is happening somewhere inside
     
     >>
     
     this call "(PlugList[findPlugin(evt->plugin)].eventfunc) (&CFP);"
     
     >>
     
     (server/attack.c line 693) but after the spell gets a chance to
     
     >>
     
     activate.
     
     >>
     
     
     >
     
     
     >
     
     You were right: the crash here happens because the called function
     
     >
     
     accesses an already freed object. The attached patch (fix-crash.diff)
     
     >
     
     fixes that problem for me but I'm not yet sure if it handles all
     
     >
     
     possible cases.
     
     >
     
     
     That appears to fix the problem I was having perfectly :-)

>
     
     
     >
     
     
     >
     
     The other two attached files (test and swordcast.py) implement a few
     
     >
     
     spell casting swords. You should use the current CVS server because it
     
     >
     
     uses your new Python functions.
     
     >
     
     
     Here's the current state of my version of swordcast.py that's working 
perfectly with it. It uses a rod instead of a spell inside to store both 
the casting level and I'm attempting to make it so that can also be used 
to limit how rapidly the spell can cast (as in slower than you hits) by 
using the spellpoint storage of rods. I'm attaching it here, and when 
using it one also has to remember to set the rod to "no_drop 1". This 
version also supports arrows and bolts properly by checking the 
direction of the weapon of the arrow instead of the player when it's a 
arrow being shot.

>
     
     
     >
     
     Note that I do not put a rod into the sword's inventory -- I just use
     
     >
     
     the spell itself. But this version still has a few problems left:
     
     >
     
     
     >
     
      - It uses CastAbility() but not CastSpell(). CastAbility() creates the
     
     >
     
        spell object from the archetype name. Therefore it uses default
     
     >
     
        values (level 0) for the spell.
     
     >
     
     
     >
     
        I cannot use CastSpell() (which takes a spell object) because it does
     
     >
     
        not include a "caster" parameter. Any objections to add that
     
     >
     
        parameter so that both functions (CastAbility and CastSpell)
     
     >
     
        basically have the same parameter list? (Btw: no script in
     
     >
     
        /maps-bigworld/python currently calls that function.)
     
     >
     
     
     I don't have any objections, though for this script I prefer using a 
approach that allows one to set the casting level to something other 
than the default spell level.

>
     
     
     >
     
      - With some spells (for example firebolt) you gain only one handed
     
     >
     
        experience (both for direct kills from the sword and for kills from
     
     >
     
        the spell).
     
     >
     
     
     I don't encounter that with my version of it. Probably because the sword 
is casting it and it looks at the sword's default skill with direct 
hits, whereas with mine, spellcasting goes through the rod, whose 
default skill is use_magic_item.

       Alex Schultz (aka Rednaxela)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: swordcast.py
Type: application/x-python
Size: 756 bytes
Desc: not available
Url : 
     
     http://shadowknight.real-time.com/pipermail/crossfire/attachments/20050524/04134e76/swordcast.bin
     
     
    


More information about the crossfire mailing list