Papyrus Portal Spell Scripting

Post » Thu Jun 21, 2012 11:06 am

I've been trying to make a mod that features a portal spell. I've looked all over for any similar implementations, and I've asked around before, but it seems that I'm in the same boat with more people than not.

I have this script, which currently teleports a player to a marker and moves a different marker to the player's previous location, but it doesn't do anything else. I can't find any way to set a variable that can send the player back to the other marker, which is the intended goal. A simultaneous Mark+Recall spell that switches function with every other use.

The script I have so far is:


Scriptname PDTeleportScript extends activemagiceffect  ObjectReference property DestinationMarker autoObjectReference property ReturnMarker autoEvent OnEffectFinish(Actor target, Actor caster)	 ReturnMarker.MoveTo(target)	 target.MoveTo(DestinationMarker)EndEvent

If this were Oblivion, it would ideally be something along the lines of:

if PlayerAtDestination = 0	 ReturnMarker.MoveTo player	 player.MoveTo DestinationMarker	 set PlayerAtDestination to 1else	 player.MoveTo ReturnMarker	 set PlayerAtDestination to 0endif

I just can't figure out how to translate that to Papyrus.

The overall intended function is still not as elegant as I'd like, which would preferably prevent indoor use and spawn a physical portal activator/door/thing. But I have no idea what I'm doing, so baby steps come first.

First person to help gets a picture of Adrien Brody or something.
User avatar
Shannon Marie Jones
 
Posts: 3391
Joined: Sun Nov 12, 2006 3:19 pm

Post » Thu Jun 21, 2012 8:47 am

Hmmm. Well, one thing you could do is have a quest with a few location aliases. Basically the properties are the location want to go to, and the one where the other side of the portal is. Then you have a script that when cast moves the player, and updates the quest. The quest has an OnUpdate event that says Okay, memorize the locations in these two references as a variable, clear the aliases, and then reset them switched.

Maybe that would work?
User avatar
Sarah Unwin
 
Posts: 3413
Joined: Tue Aug 01, 2006 10:31 pm

Post » Thu Jun 21, 2012 1:23 am

By a Mark and Recall spell that alternates functions every use, do you mean something like this?
  • Cast spell -> Marker01 moves to Player, Player moves to Marker02
  • Player walks around.
  • Cast spell -> Marker02 moves to Player, Player moves to Marker01
  • Player walks around.
  • Cast spell -> Marker01 moves to Player, Player moves to Marker02
  • etc.
To get something like that to work, you're going to need to have a global variable or some other way to store a variable, because you can't store it in your spell script.

If you use a global variable for example, you could use this script:

Scriptname Example extends ActiveMagicEffectGlobalVariable Property MyGlobal AutoObjectReference Property Marker01 AutoObjectReference Property Marker02 AutoActivator Property Portal AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)    if (akTarget.IsInInterior())        Debug.MessageBox("You cannot use this spell inside an interior cell.")        Return    endif    ObjectReference PortalRef = akTarget.PlaceAtMe(Portal)    Utility.Wait(1)    PortalRef.Disable()    PortalRef.Delete()    if (MyGlobal.Value)        MyGlobal.SetValue(0.0)        Marker01.MoveTo(akTarget)        akTarget.MoveTo(Marker02)    else        MyGlobal.SetValue(1.0)        Marker02.MoveTo(akTarget)        akTarget.MoveTo(Marker01)    endifEndEvent

I am not sure if you need to call PlayAnimation on the portal activators.
User avatar
Chad Holloway
 
Posts: 3388
Joined: Wed Nov 21, 2007 5:21 am

Post » Thu Jun 21, 2012 6:03 am

By a Mark and Recall spell that alternates functions every use, do you mean something like this?
  • Cast spell -> Marker01 moves to Player, Player moves to Marker02
  • Player walks around.
  • Cast spell -> Marker02 moves to Player, Player moves to Marker01
  • Player walks around.
  • Cast spell -> Marker01 moves to Player, Player moves to Marker02
  • etc.
To get something like that to work, you're going to need to have a global variable or some other way to store a variable, because you can't store it in your spell script.

If you use a global variable for example, you could use this script:

Scriptname Example extends ActiveMagicEffectGlobalVariable Property MyGlobal AutoObjectReference Property Marker01 AutoObjectReference Property Marker02 AutoActivator Property Portal AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)	if (akTarget.IsInInterior())		Debug.MessageBox("You cannot use this spell inside an interior cell.")		Return	endif	ObjectReference PortalRef = akTarget.PlaceAtMe(Portal)	Utility.Wait(1)	PortalRef.Disable()	PortalRef.Delete()	if (MyGlobal.Value)		MyGlobal.SetValue(0.0)		Marker01.MoveTo(akTarget)		akTarget.MoveTo(Marker02)	else		MyGlobal.SetValue(1.0)		Marker02.MoveTo(akTarget)		akTarget.MoveTo(Marker01)	endifEndEvent

I am not sure if you need to call PlayAnimation on the portal activators.

That is pretty much exactly my intention. I'm unfamiliar with global variables though. I gave the section of the creation kit wiki a read-through, but it just seems confusing. Is it now impossible to store separate variables within a script without adding to some sort of external list?

Oh, and thanks to both of you individuals who responded for the help. Here's a picture of http://i.imgur.com/ag2tA.jpg.
User avatar
Maeva
 
Posts: 3349
Joined: Mon Mar 26, 2007 11:27 pm

Post » Thu Jun 21, 2012 11:07 am

Is it now impossible to store separate variables within a script without adding to some sort of external list?


Variables in spell scripts aren't permanently stored anywhere. They only exist as long as the magic effect script is running.

Each time you cast the spell, a new instance of the magic effect is created. So every time you cast the spell, the variables will be at their default values.
User avatar
DarkGypsy
 
Posts: 3309
Joined: Tue Jan 23, 2007 11:32 am

Post » Thu Jun 21, 2012 4:31 am

Well you could create a simple mark spell with a long duration and call that later with a recall spell could you not? And because spell effects overwrite when a bee one is cast you can change your mark location anytime you please. Or you could tie it to a variable inside a quest script and access that with your recall spell.
User avatar
Rodney C
 
Posts: 3520
Joined: Sat Aug 18, 2007 12:54 am


Return to V - Skyrim