I'm attempting to create a spell that the player can cast to teleport himself to a particular location based on what trigger box he is currently in. So, for example, if the player casts the spell while within triggerArea1, then teleport the player to Destination1. If the player casts the spell within triggerArea2, then teleport the player to Destination2. And vice versa. As part of my intended level design, I need it to work this way. I have two different scripts, one for trigger box and one for the spell. However, since one is an object reference and the other is an active magic effect, I'm having trouble getting one script to access properties declared in the other. I know some of the code shown below probably has a lot of issues (and if anyone knows a better way to handle this, please help). My triggerbox script:
Scriptname Area1 extends ObjectReference
ObjectReference Location1
Actor Property PlayerREF Auto
Bool Property EnableTeleport Auto
Function TeleportEnable()
EnableTeleport = True
return
EndFunction
Function TeleportDisable()
EnableTeleport = False
return
EndFunction
Event OnTriggerEnter(ObjectReference akActionRef)
If akActionRef == PlayerREF
TeleportEnable()
EndIf
EndEvent
Event OnTriggerLeave(ObjectReference akActionRef)
If akActionRef == PlayerREF
TeleportDisable()
EndIf
EndEvent
My spell script (partial):
Scriptname JR_Teleportation extends activemagiceffect
{Teleports the caster to a different domain.}
ObjectReference property teleDest auto
ObjectReference property teleBegin auto
Bool Property EnableTeleport Auto
Event OnEffectFinish(Actor target, Actor caster)
if EnableTeleport = True
target.MoveTo(teleDest)
EndIf
EndEvent
What I want to do is pass the boolean value for "EnableTeleport" from the trigger box script to the spell script. But I've been unable to figure out a way to do this. I read somewhere that property values can only be passed between scripts if those scripts are attached to objects that are linked. However, I can't use a linked ref between my two scripts because my active magic effect is not something that can be dragged into the render window (like a trigger can). I would appreciate any help in getting my code to work for my idea.