Requesting Help Scripting Two Spells

Post » Tue Dec 13, 2016 12:07 pm

I am requesting scripting guidance on creating two spells please:


"Chambers"

Upon cast your location is marked and you are teleported to a fixed location that will never change (inside a player house I've created) ignoring interior or exterior restrictions.


"Return"

Upon cast you're teleported back to the initial marked location, again ignoring interior or exterior restrictions.


I'm wanting to avoid any popup menu/choice boxes to keep the scripting to a minimum. I've found other mods and tutorials on mark and recall spells, but they're always too extensive or feature rich. I'm just wanting two spells that do only what is necessary to teleport the player into the house I've made and then back to the exact spot they teleported from (no matter where that is).


I am new to modding but please know I will greatly appreciate you taking the time to help me. I will be sure to note your name in my "whom I'd like to thank" list when I release my mod.
User avatar
Dina Boudreau
 
Posts: 3410
Joined: Thu Jan 04, 2007 10:59 pm

Post » Tue Dec 13, 2016 5:26 pm

Why not just use one spell? Since you're going to a fixed location you can just have it go there if you're somewhere else and return to the last location if you're home. The script and setup for that is easy.



ScriptName SimpleHomeTeleportScript extends ActiveMagicEffect

ObjectReference Property HouseMarker Auto
{The destination marker in the house.}

ObjectReference Property ReturnMarker Auto
{The return marker, initially placed in the house too.}

Message Property HowToUseMsg Auto
{Optional: A message to show if player uses spell in house before going outside.}

Event OnEffectStart(Actor akTarget, Actor akCaster)
if akCaster.GetDistance(HouseMarker) > 9999.0 ; not at home
ReturnMarker.MoveTo(akCaster) ; set return marker
akCaster.MoveTo(HouseMarker) ; go home
elseif ReturnMarker.GetDistance(HouseMarker) > 9999.0 ; and return marker set
akCaster.MoveTo(ReturnMarker) ; return to previous spot
elseif HowToUseMsg ; at home but have never used spell outside yet
HowToUseMsg.Show()
endif
EndEvent

You need to place two XMarkerHeading objects in your house. Put both of them at the spot where you want the player to appear when teleporting home. The one that fills the HouseMarker property will always stay there but the ReturnMarker property will get moved out into the worldspace or some other cell when the player is teleported home so that the spell knows where to send the player when it's cast the second time.



The HowToUseMsg message is optional. If you don't fill that property then nothing will happen if the player casts the spell in the house before ever casting somewhere else. If you do fill it, that message gives you a chance to explain that the player needs to leave the house before using the spell for the first time.



Technically if you don't want the message you can remove that property and that last elseif from the code.




If you really want two separate spells, the two scripts would be very similar but you probably don't want to bother checking if the return marker has been set.



ScriptName SimpleTeleportHomeScript extends ActiveMagicEffect

ObjectReference Property HouseMarker Auto
{The destination marker in the house.}

ObjectReference Property ReturnMarker Auto
{The return marker, initially placed in the house too.}

Event OnEffectStart(Actor akTarget, Actor akCaster)
ReturnMarker.MoveTo(akCaster) ; set return marker
akCaster.MoveTo(HouseMarker) ; go home
EndEvent


ScriptName SimpleReturnFromHomeScript extends ActiveMagicEffect

ObjectReference Property ReturnMarker Auto
{The return marker, initially placed in the house too.}

Event OnEffectStart(Actor akTarget, Actor akCaster)
akCaster.MoveTo(ReturnMarker) ; return to previous spot
EndEvent
User avatar
rolanda h
 
Posts: 3314
Joined: Tue Mar 27, 2007 9:09 pm


Return to V - Skyrim