Easy script question

Post » Sat Aug 22, 2009 11:41 pm

I'm attaching this script to an enchantment, which is then applied to a dagger that's supposed to kill the player if it hits him 7 times, each with a 50% chance of actually counting as a hit.

Will this work?

ScriptName MASdaggarscriptshort init						short Random			Short HitsRef Target				Begin ScriptEffectStart	if ( init == 0 )		set Target to GetSelf		set init to 1	endifEndBegin GameModeIf ( Target == Player )	if ( init == 1 )		set Random to GetRandomPercent		if ( Random > 50 )			Set Hits to ( Hits + 1 )		Endif		If ( Hits == 3 )			Messagebox "3 Hits"		Elseif ( Hits == 6 )			Messagebox "6 Hits"		Elseif ( Hits >= 7 )			Player.Kill		Endif		Set init to 0	EndifEndifEnd


And would it matter how long i set the effect duration to?
User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Sat Aug 22, 2009 6:05 pm

It looks like it should, but it's not clear if you intend any limit to how much time can elapse between hits. As it stands, you could get hit once, go off and do the Mages Guild quests, get hit again, go finish the Main Quest, get hit again, ...

I'd expect some kind of reset condition, but I'm unclear what the appropriate circumstance would be. There should at least be some way of turning this off to remove the danger when the quest it's part of finishes.
User avatar
Leanne Molloy
 
Posts: 3342
Joined: Sat Sep 02, 2006 1:09 am

Post » Sun Aug 23, 2009 1:21 am

No, it won't work because each time the effect is being applied, the old script is being cleared and a new one is being added. If you want to make an easy counter for something like this, you should either store the hit count within a quest script, or make use of a hidden faction on the player which is removed after the quest is done. Basically, you need to keep a tally of hits outside of the effect script.

Also, gamemode blocks don't work in spell scripts. You will need to use scripteffectupdate. This block however will only run for as many seconds as the duration of the effect allows, so if you are setting any variables within this block to be used further down this block, you may need a 1-2 second duration.
User avatar
Manuel rivera
 
Posts: 3395
Joined: Mon Sep 10, 2007 4:12 pm

Post » Sun Aug 23, 2009 2:13 am

No, it won't work because each time the effect is being applied, the old script is being cleared and a new one is being added. If you want to make an easy counter for something like this, you should either store the hit count within a quest script, or make use of a hidden faction on the player which is removed after the quest is done. Basically, you need to keep a tally of hits outside of the effect script.

Ah, thanks. I knew something smelled fishy, but i couldn't place my hand on what it was.
User avatar
BRIANNA
 
Posts: 3438
Joined: Thu Jan 11, 2007 7:51 pm


Return to IV - Oblivion