Getting What is in the targets crosshairs (Target Location)

Post » Fri Nov 16, 2012 12:09 pm

Im creating a spell that teleports the player to where he is looking. To do this i currently summon an invisible NPC. Here is what my magic effect looks like [img]http://localhostr.com/files/iCDGZWt/Magic%20Effect.png[/img]

My question is, when the spell is cast, and the invisible NPC is created... how do i teleport to it? How do i reference the summon in my script so i can use CasterRef.MoveTo(SummonRef) ?

At the moment my teleport script looks like this:

Spoiler
scriptName TeleportScriptEffect extends activeMagicEffectimport gameimport utility;VFXActivator property SummonFX Auto;Summon parameterseffectShader property fadeOutFX autoeffectShader property fadeInFX autovisualEffect property TrailFX auto;Internal variables.actor casteractor targetobjectReference casterRefobjectReference targetRefEvent OnEffectStart(Actor akTarget, Actor akCaster)	caster = akCaster	target = akTarget	targetRef = (target as ObjectReference)	casterRef = (caster as ObjectReference)	if (!caster.IsDead())		;Perform the swap.		fadeOutFX.play(casterRef)		caster.setGhost(TRUE)		Utility.Wait(0.5)				casterRef.MoveTo(targetRef)		casterRef.PlaceAtMe(SummonFX)		Utility.Wait(0.5)		fadeOutFX.stop(casterRef)		caster.setGhost(FALSE)		caster.evaluatePackage()	EndIf		; additional check - seen instances where NPC with this ability would not die!	if Caster.getActorValue("Health") < 0		caster.kill()	endifEndEvent
User avatar
Christine Pane
 
Posts: 3306
Joined: Mon Apr 23, 2007 2:14 am

Post » Fri Nov 16, 2012 1:25 pm

I would also like to know this, I was experimenting with a similar feature for a custom spell and couldn't think of how to do this.
User avatar
jason worrell
 
Posts: 3345
Joined: Sat May 19, 2007 12:26 am

Post » Fri Nov 16, 2012 10:00 pm

You may want to look into using a projectile to place a marker, then move the player to the marker. You will have the same effect without going through walls. I was working on something kind of similar moving a chest about with a projectile spell, it worked quite well.
User avatar
Anna Watts
 
Posts: 3476
Joined: Sat Jun 17, 2006 8:31 pm

Post » Sat Nov 17, 2012 1:07 am

Updated the main post with my current question / status
User avatar
Brittany Abner
 
Posts: 3401
Joined: Wed Oct 24, 2007 10:48 pm

Post » Fri Nov 16, 2012 2:55 pm

You see that one box labeled projectile? Make a projectile and add it there. In the projectile, you can choose to place markers where the projectile hits as well.

You can use spells to cast projectiles. When the projectile meets a surface, you can let that projectile place a marker where it hits. You can then add a script to that marker, or to the spell itself, to move the player to the location of the marker.

I was doing the same thing with moving a chest about, because of what I was attempting my scripting was a lot more convoluted, but I'll try summing it up as best as I can recall.

The problem using projectiles is you have to call the event through the spell script, to a function in a script attached to the marker the projectile creates, you can't reference the marker through the magic script. So you make a function in a script on the marker like

Function MovePlayerToMe()    PlayerRef.MoveTo(Self)Endfunction


Then in the script for the spell, reference the function attached to the marker (I forget how to do that atm ~_~;, it's late)

The spell would cast, call an event, and move you to where the projectile landed.
User avatar
Siidney
 
Posts: 3378
Joined: Fri Mar 23, 2007 11:54 pm

Post » Fri Nov 16, 2012 1:17 pm

I'm having a similar problem. I want to have it so that when a player casts the spell, a door is summoned/moved to the target location as well as it's door marker. So far I haven't put together a script because I can't figure out how to get the location data from the target.
User avatar
Jynx Anthropic
 
Posts: 3352
Joined: Fri Sep 08, 2006 9:36 pm

Post » Fri Nov 16, 2012 7:27 pm

This is a thorny problem. Although it's not possible to just get what's under the crosshairs, it is possible to spawn an object at the target location and then do stuff with it. Check my comment here for info:
http://www.gamesas.com/topic/1388269-some-help-creating-an-instant-teleport-or-blink-spell/page__view__findpost__p__21112091

This is faster than using a projectile and is the same method used by the Throw Voice shout.
User avatar
Adriana Lenzo
 
Posts: 3446
Joined: Tue Apr 03, 2007 1:32 am


Return to V - Skyrim