Jump to content

Spell Scripting Help


jamochawoke

Recommended Posts

Well after many many many tests I finally got it down to a simple script and spellcast. The spell is nothing but a dummy with the shader I want (basically to initiate the casting animation of the werewolf).

 

scn WerewolfSpellActivate

ref self
ref target
short rndresult
float timer


Begin GameMode
   if (IsInCombat == 1)
	set rndresult to GetRandomPercent
	set timer to timer - GetSecondsPassed

	if (timer == 5)
		ModActorValue Speed -20
	endif

	if (GetAV Magicka >= 20) && (timer <= 0)
		set self to GetSelf
         	set target to GetCombatTarget
         	if (GetDistance target > 500)
			Cast WerewolfBloodthirst self
			if (rndresult <= 49)
				PlaySound WerewolfHowl
			elseif (rndresult <= 100)
				PlaySound WerewolfHowl2
			endif
			ModActorValue Speed 20
              	ModActorValue Magicka -20
			set timer to 30
		endif
    	endif
endif
End

 

It works really well.

 

However, there is one bug I've noticed. After 2 or 3 activations of the script the werewolf stops losing Speed and instead keeps the speed buffs (they might even be stacking I'm not sure).

 

It's not a huge bug, but I'd like to figure out what causes it.

 

By the way. Thanks to everyone who's been helping. All of you are so awesome! I've given kudos to everyone who replied to this thread trying to help me :)

Edited by jamochawoke
Link to comment
Share on other sites

I think the reason the effect stacked is because of:

 

if (timer == 5)
ModActorValue Speed -20
endif

 

The chances of the timer being exactly 5 is very low. GetSecondsPassed doesn't actually return exact seconds, but rather the amount of time since the last frame. So this part of the script probably doesn't fire.

 

Instead of using PlaySound, maybe you should try PlaySound3D.

 

If you have OBSE, I really suggest using ModActorValue2 instead of ModActorValue. Reading the description for ModAV tells you that if you use it from a script, then it's permanent unless you readjust it through script. So using "ModActorValue Magicka -20" enough times will eventually mean that the werewolf would have less than 20 magicka, with no way to recover no matter how much time passes.

 

If you're really just going to use the spell to play the magic effect and not anything else, how about using PlayMagicEffectVisuals instead of going through the trouble of making and casting a spell? Unless you want to see the casting animation of course.

Edited by fg109
Link to comment
Share on other sites

Got everything to work exactly as I wanted it, even though I had to go about it in a roundabout way.

 

* PlaySound3D refused to work for my sound file... it was just way too quiet for a piercing howl (and I spent about 4 hours messing with the sliders) so I just messed with the attenuation and used PlaySound. It sounds natural enough to pass!

 

I completely redid the script and went back to the script activates spell which has a spellscript way of doing it and got everything to work!

 

scn WerewolfSpellActivate

ref self
ref target
short rndresult
float timer


Begin GameMode
   if (IsInCombat == 1)
	set rndresult to GetRandomPercent
	set timer to timer - GetSecondsPassed

	if (GetAV Magicka >= 20) && (timer <= 0)
                   set self to GetSelf
         	                   set target to GetCombatTarget
         	                   if (GetDistance target > 500)
		Cast WerewolfBloodthirst self
		if (rndresult <= 45)
			PlaySound WerewolfHowl
		elseif (rndresult <= 100)
			PlaySound WerewolfHowl2
		endif
              	     ModActorValue Magicka -20
	     set timer to 30
	     endif
    	               endif
     endif
End

 

scriptname WerewolfHowling

Begin ScriptEffectStart 
ModActorValue Speed 20
End

Begin ScriptEffectFinish
ModActorValue Speed -20
End

 

Even though I don't have OBSE installed and had to resort to using ModActorValue (which reduces the magicka total each time it's used) I just gave the werewolf enough spell points to start with so he'd cast it around 3 times (if he switched targets that was far away or if your fight was really long and you are running)... I think this actually gives the benefit of making the effect less annoying as you won't hear it as often (especially if multiple werewolf fight).

 

I've done a lot more work on the wolf to add atmosphere including messing with animatons and everything is going well. There's some other things I'd like to get done with the animations but that's going to need its own thread I think.

 

Thanks so much for your help guys!!!

Edited by jamochawoke
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...