[crossfire] Re: [CF-Devel] Missing archetypes used by python plugin

Andreas Kirschbaum kirschbaum at myrealbox.com
Thu Jan 20 16:23:19 CST 2005


Todd Mitchell wrote:
>
     
      Another big thing along the same lines would be to clean up the spell
     
     >
     
      and skill stuff... I don't know how the spell and skill wrappers can
     
     >
     
      be loaded into the plugin any longer now that they are dynamically
     
     >
     
      loaded from the arches, but this is a lot of legacy code in the
     
     >
     
      plugin.
     
     
The solution to the skill stuff could be to remove the SkillXxx()
wrapper functions and to convert skill ids into skill names:

    GetSkillExperience(object who, string skill)
    SetSkillExperience(object who, string skill, long exp)

You could use these functions as follows:

    who = CFPython.WhoIsActivator()
    exp = CFPython.GetSkillExperience(who, "alchemy")
    if exp != None:
        CFPython.SetSkillExperience(who, "alchemy", exp+1)
    else:
        CFPython.Write("You do not know how to do alchemy!", who)


For the spell related functions, the following code did work for me:

    who = CFPython.WhoIsActivator()

    # learn a spell
    spell = CFPython.CreateObject("spell_large_fireball", (0, 0))
    CFPython.AcquireSpell(who, spell)
    CFPython.RemoveObject(spell)

    # forget a spell
    CFPython.ForgetSpell(who, "large fireball")

Note: I had to create the spell object with CreateObject() at the
(arbitrary) position (0, 0) because I could not find a function to
create a (spell-)object that is not part of a map (and not inside an
inventory).

That said, I think the spell wrapper functions are not needed anymore
and could be removed.

    
    


More information about the crossfire mailing list