Script-added spells

Post » Fri Oct 19, 2012 4:50 am

I'm writing a script which is intended to add one of two spells based on a global variable's value. The spell needs to be removed/expire after 60 seconds. So my question is, do I need to remove the spell manually with the timer I am floating? Or, if I assign a spell duration of 60 seconds to a spell and then use AddSpell (I'd rather not use cast), will the effect properly expire after 60 seconds on it own? I have to float a timer either way because I want to play a sound after 60 seconds to signal the effect expiring.

I assume it can't hurt to remove it manually even if it'd remove on its own. If I remove it manually, should I just use an ability instead of a spell with duration? Or does it not matter? Can I ask anymore questions?

For reference, this is the current script. Not compiled, so there might be some errors (just wrote this up in wordpad since I don't have access to MWEdit or the CS).

Begin md_MI_loc_hilbongardFloat Timer ; timer is unneseccary if a 60 second spell added to the player through this script will become inactive on its ownif ( GetDistance Player <= 512 )			    Set Timer to Timer + GetSecondsPassed			    if ( md_lore_hilbon != 0 ) ; global variable set in dialogue or from reading lore books							    player->addspell md_MI_loc_hilbon_lore_sp ; special spell which has either extra bonus effects, or less penalties							    PlaySound "cast success"							    if ( Timer > 60 )											    player->removespell md_MI_loc_hilbon_lore_sp											    PlaySound "cast fail"							    endif			    elseif ( md_lore_hilbon == 0 )							    player->addspell md_MI_loc_hilbon_sp ; the standard lore-less spell effect							    PlaySound "cast success"							    if ( Timer > 60 )											    player->removespell md_MI_loc_hilbon_sp											    PlaySound "cast fail"							    endif			    endifendif
User avatar
Leah
 
Posts: 3358
Joined: Wed Nov 01, 2006 3:11 pm

Post » Thu Oct 18, 2012 10:01 pm

Simple spell, when AddScript'ed, applies to your list of *known* spells rather that list of suffered effects. So, your choice is either to make some NPC *cast* the spell on you, or yes, use an ability that has to be removed manually.
Begin md_MI_loc_hilbongardshort doOncefloat Timerif ( doOnce == 0 )    if ( GetDistance Player <= 512 )	    set doOnce to 1	    set Timer to 0 ; not necessary if the spell is applied only once, but needs to be reset otherwise	    if ( md_lore_hilbon != 0 ) ; global variable set in dialogue or from reading lore books		    player->addspell md_MI_loc_hilbon_lore_sp ; special spell which has either extra bonus effects, or less penalties	    else ; no need to specify a contrary condition if there are only two possibilities		    player->addspell md_MI_loc_hilbon_sp ; the standard lore-less spell effect	    endif	    PlaySound "cast success"    endifendifif ( doOnce == 1 )    Set Timer to Timer + GetSecondsPassed    if ( Timer > 60 )	    if ( md_lore_hilbon != 0 ) ; global variable set in dialogue or from reading lore books		    player->removespell md_MI_loc_hilbon_lore_sp	    else		    player->removespell md_MI_loc_hilbon_sp	    endif	    PlaySound "cast fail"	    set doOnce to 2    endifendif; This part is only necessary if the spell can be applied more than onceif ( doOnce == 2 )    if ( GetDistance Player > 512 ) ; to make the spell not be applied immediately again if PC did not walk away from the giver.	    set doOnce to 0    endifendif
User avatar
мistrєss
 
Posts: 3168
Joined: Thu Dec 14, 2006 3:13 am


Return to III - Morrowind