Preventing a magic projectile from being fired

Post » Sat Mar 09, 2013 6:03 am

If this was just for the player, adding a perk which modified the cost of the spell would achieve the same thing. You would get the not enough magicka message. I've changed this message to display "You are unable to cast this spell"
User avatar
Connor Wing
 
Posts: 3465
Joined: Wed Jun 20, 2007 1:22 am

Post » Sat Mar 09, 2013 12:55 am

Not the same thing at all, really. That way you're unifying two restrictions into one, which is plain ugly.

Players need to know exactly what's preventing them from casting a spell, whether if they're low on magicka or not skilled enough to cast it properly, and you need two separate messages for the two causes.
User avatar
Hazel Sian ogden
 
Posts: 3425
Joined: Tue Jul 04, 2006 7:10 am

Post » Fri Mar 08, 2013 9:29 pm

I'm disappointed in that interruptCast() function. It would be so great for this but alas, I guess its never gonna be viable outside of Objectreference.
User avatar
SaVino GοΜ
 
Posts: 3360
Joined: Mon Sep 17, 2007 8:00 pm

Post » Sat Mar 09, 2013 2:14 am

Not the same thing at all, really. That way you're unifying two restrictions into one, which is plain ugly.

Players need to know exactly what's preventing them from casting a spell, whether if they're low on magicka or not skilled enough to cast it properly, and you need two separate messages for the two causes.
You could easily add a small script to fire your own notification over the top of the vanilla one. You'd just have to deal with 2 pop ups instead of 1.
User avatar
Verity Hurding
 
Posts: 3455
Joined: Sat Jul 22, 2006 1:29 pm

Post » Sat Mar 09, 2013 5:47 am

I'm disappointed in that interruptCast() function. It would be so great for this but alas, I guess its never gonna be viable outside of Objectreference.

Yup. Too bad it doesn't work with Aimed spells because once the projectile is gone, it's gone. Works as intended for Concentration spells though.

You could easily add a small script to fire your own notification over the top of the vanilla one. You'd just have to deal with 2 pop ups instead of 1.

I don't like it, too spammy. Moreover, the spell cost method can't work with NPC since they are able to cast spells regardless of their magicka pool.
User avatar
Maria Garcia
 
Posts: 3358
Joined: Sat Jul 01, 2006 6:59 am

Post » Fri Mar 08, 2013 10:41 pm

OMG hang on a second. InterruptCast *IS* actually working as intended on all kind of spells, I have no idea why it didn't work before in an earlier version of the script. A matter of timing I presume. I condensed the script as much as possible and it actually works, no need to unequip/equip the spell anymore. Yay!

Spoiler

Scriptname CastingManagement extends activemagiceffect  Message Property SpellFailedMSG Auto				; fill this with something along the lines of "The spell failed."Actor Property PlayerREF AutoSound Property MAGFail AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)	bool LeftSpellFailed = false							; we use these to check whether we should	bool RightSpellFailed = false							; inform the player that the spell failed or not	float LeftSpellSkill									; we need separate skill checks for either hands	float RightSpellSkill	int RandomRate = Utility.RandomInt()	Spell LeftHandSpell = akCaster.GetEquippedSpell(0)	; first off, get the equipped spells..	Spell RightHandSpell = akCaster.GetEquippedSpell(1)	if ( LeftHandSpell )		LeftSpellSkill = GetSpellSkill (LeftHandSpell, akCaster)	; ..then check for the casting actor skill		if ( ( RandomRate - LeftSpellSkill ) > 0 )			akCaster.InterruptCast()			LeftSpellFailed = true		endif	endif	if ( RightHandSpell )		RightSpellSkill = GetSpellSkill (RightHandSpell, akCaster)		if ( ( RandomRate - RightSpellSkill ) > 0 )			akCaster.InterruptCast()			RightSpellFailed = true		endif	endif	If ( ( akCaster == PlayerREF ) && ( ( LeftSpellFailed ) || ( RightSpellFailed ) ) )   	 SpellFailedMSG.Show()					; your spell failed! LOL! NOOB!		MAGFail.play(akCaster)	EndIfEndEventFloat Function GetSpellSkill(Spell ActorSpell, Actor CastingActor)	float ActorSkill	if ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Alteration" )		ActorSkill = CastingActor.GetActorValue("Alteration")			elseif ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Conjuration")		ActorSkill = CastingActor.GetActorValue("Conjuration")	elseif ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Destruction")		ActorSkill = CastingActor.GetActorValue("Destruction")	elseif ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Illusion" )		ActorSkill = CastingActor.GetActorValue("Illusion")	elseif ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Restoration" )		ActorSkill = CastingActor.GetActorValue("Restoration")	endif			return ActorSkillEndFunction

edit: yes, it's indeed a matter of timing. If using InterruptCast, if you time the button release right you can fire the projectile even though the spell is supposed to fail -- InterruptCast is too slow.
User avatar
Rebecca Clare Smith
 
Posts: 3508
Joined: Fri Aug 04, 2006 4:13 pm

Post » Sat Mar 09, 2013 6:16 am

A lot of things in Papyrus are like that. If the game chooses that moment to hiccup or a script gets delayed for a split second, all bets are off. I just encountered one of those a couple of days ago: Playidle, when used on the player character, will allow the player to cancel the Idle animation if they hit the controls at just the right (or wrong) moment, even if you disable controls before playing the animation. It also cancels the animation if the player releases a control after it starts. You have to disable controls, wait a tick, THEN play the idle in order for it to work as expected, which turns what should be a single line of script into three plus an artificial delay.
User avatar
helen buchan
 
Posts: 3464
Joined: Wed Sep 13, 2006 7:17 am

Post » Fri Mar 08, 2013 8:54 pm

Heh, I'm learning that the hard way.. I condensed the script to the maximum just for the hell of it to no avail, InterruptCast is so damn slow and unreliable. Just Papyrus being Papyrus I guess.

Spoiler

Scriptname CastingManagement extends activemagiceffect  Sound Property MAGFail AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)	Bool SpellFail = false	Spell LeftHandSpell = akCaster.GetEquippedSpell(0)	Spell RightHandSpell = akCaster.GetEquippedSpell(1)	if ( LeftHandSpell )		SpellFail = ( ( Utility.RandomInt() - akCaster.GetActorValue( LeftHandSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() ) ) > 0 )	endif	if ( RightHandSpell )		SpellFail = ( ( Utility.RandomInt() - akCaster.GetActorValue( RightHandSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() ) ) > 0 )	endif	if ( SpellFail )		akCaster.InterruptCast()		MAGFail.play(akCaster)	endifEndEvent
User avatar
Lewis Morel
 
Posts: 3431
Joined: Thu Aug 16, 2007 7:40 pm

Previous

Return to V - Skyrim