Magic Spell help?

Post » Sat Dec 06, 2014 1:56 am

I want a teleport spell to only work if the player is inside a trigger box. Is there anything pre made that I could use? I thought of taking theTrapTriggerBase script and cutting out all the bits that don't apply but that would be most of it. Is there a simpler way to have the spell check that condition before taking effect? Can a scripted spell check on a script on an object?

User avatar
Benji
 
Posts: 3447
Joined: Tue May 15, 2007 11:58 pm

Post » Sat Dec 06, 2014 3:44 am

I could be wrong, but I don't believe there's a function to check on-demand if the player is inside a triggerbox, there are just enter/leave trigger events. I would suggest that you use a GetDistance condition on the spell's MagicEffect, which should probably work fine for the triggerbox (since I assume the distance will be measured from the center of the triggerbox). So, something like

GetDistance YourTriggerBoxReference < 1000

Where you would just replace 1000 with the number of units in the triggerbox radius. That way the magic effect will only work if the player is within that distance from the center of the triggerbox.

User avatar
Nicholas C
 
Posts: 3489
Joined: Tue Aug 07, 2007 8:20 am

Post » Fri Dec 05, 2014 3:28 pm

maybe gettriggerobjectcount playerref > 0 works

User avatar
Marcin Tomkow
 
Posts: 3399
Joined: Sun Aug 05, 2007 12:31 pm

Post » Sat Dec 06, 2014 1:50 am

It might be possible to mod a global variable when entering and leaving the trigger box.

This global variable could then be used in the teleport's magic effect to determine when it works.

There may be issues with the order of events firing if the player were to enter and leave very quickly, but this modified script (from CKWiki) would prevent this

Spoiler
Int InTrigger = 0GlobalVariable Property myGlobal Auto Event OnTriggerEnter(ObjectReference akTriggerRef)    if (InTrigger == 0)        if akTriggerRef == Game.GetPlayer()            InTrigger += 1               myGlobal.mod(1)                  debug.notification("Entered Trigger")        endif    endifEndEvent Event OnTriggerLeave(ObjectReference akTriggerRef)    if (InTrigger > 0)        if akTriggerRef == Game.GetPlayer()            InTrigger -= 1               myGlobal.mod(-1)                  debug.notification("Leaving Trigger")        endif    endifEndEvent 
User avatar
Unstoppable Judge
 
Posts: 3337
Joined: Sat Jul 29, 2006 11:22 pm


Return to V - Skyrim