How to end a spell (Vigor)

Discussion in 'General Modification' started by Kharagh, Sep 12, 2016.

Remove all ads!
  1. Kharagh

    Kharagh Established Member

    Joined:
    Sep 20, 2014
    Messages:
    117
    Likes Received:
    1
    So this vigor spell works, but it also continues to say "Vigor OnBeginRound" every round (in the console - using Temple+), even after the healing ends. Any suggestions on how to completely end the spell (the lines for "if (heal_count > 14): spell.spell_end( spell.id )" were meant to accomplish this task, but they don't)?

    from toee import *

    def OnBeginSpellCast( spell ):
    print "Vigor OnBeginSpellCast"
    print "spell.target_list=", spell.target_list
    print "spell.caster=", spell.caster, " caster.level= ", spell.caster_level
    game.particles( "sp-conjuration-conjure", spell.caster )

    def OnSpellEffect( spell ):
    print "Vigor OnSpellEffect"

    spell.duration = 10 + min( 5, spell.caster.stat_level_get( spell.caster_class ) )

    target = spell.target_list[0]

    # Use any spell effect with a duration that you will not be using while under
    # the effects of lesser vigor
    #target.obj.condition_add_with_args( 'sp-Barkskin', spell.id, spell.duration, 0 )
    #target.partsys_id = game.particles( 'sp-Cure Minor Wounds', target.obj )

    dice = dice_new( "1d1" )
    #dice.bonus = 1
    target.obj.heal( OBJ_HANDLE_NULL, dice )
    target.obj.healsubdual( OBJ_HANDLE_NULL, dice )
    heal_count = 1
    while (heal_count < spell.duration):
    game.timeevent_add( heal_later, ( target, spell, dice ), (heal_count * 6000) )
    heal_count = heal_count + 1
    # end while
    if (heal_count > 14):
    spell.spell_end( spell.id )

    def OnBeginRound( spell ):
    print "Vigor OnBeginRound"

    def OnEndSpellCast( spell ):
    print "Vigor OnEndSpellCast"

    def heal_later( target, spell, dice ):
    target.obj.heal( OBJ_HANDLE_NULL, dice )
    target.obj.healsubdual( OBJ_HANDLE_NULL, dice )
     
  2. WinstonShnozwick

    WinstonShnozwick Established Member

    Joined:
    Mar 2, 2011
    Messages:
    628
    Likes Received:
    23
    I see a problem already, maybe. It sets the spell.duration to 10+ minimum of 5 or spell caster level. And heal count being greater than 14 only ends the spell. The while loop only increments heal count while it is less than spell duration. So if spell duration is less than 14, which it seems to be possible to be, you will never hit this end condition to end the spell.
     
  3. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    5,001
    Likes Received:
    250
    I believe fixes for all 3 vigor spells have already been posted, search for the "I'm Participating" thread. Shiningted's domain spell expansion mod and sitra achara's vigor spell fixes are on about page 5.
     
  4. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    You need to remove target before ending the spell.
    Code:
    spell.target_list.remove_target(target.obj)
    spell.spell_end(spell.id)
    I've fixed this for the next Temple+ version, so you don't have to worry about it too much.

    On that note, is the addon still buried in the "I'm participating" thread? That's a damn shame...
     
  5. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    5,001
    Likes Received:
    250
    I believe so, though I have merged those files into my next IWD bundle already
     
  6. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,654
    Likes Received:
    352
    Yeah that's my fault, I meant to do a proper thread in the downloads section but have been distracted.

    What is the difference between,

    spell.spell_end( spell.id )

    and

    spell.spell_end( spell.id, 1 )
     
  7. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    The 1 forces a spell end even if not all targets have been removed.
     
  8. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,654
    Likes Received:
    352
    Thanks. Is that a Temple+ thing or a normal thing?
     
  9. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Nope, that's from vanilla ToEE. As a reminder I recommended you to apply this to KotB in the Looking for Livonya spell, which can otherwise can massive slowdowns over time.
     
  10. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,654
    Likes Received:
    352
    Yeah that's why I was asking. Already done, thanks again.
     
Our Host!