Teleportation Script error

Post » Sun Nov 18, 2012 4:53 pm

Hey everyone. Yep yep it's me again.

This time with the following: I made a spell that is supposed to teleport you to a cell i made, and upon casting it again teleport you back.

It does teleport you, but as soon as you arrive, you are teleported back instantly.


This is my script, it is a little long and has a few things not related to the teleporting directly, but they are still necessarry for my spell so sorry if it is a little confusing.

Also the "UseBlindness" Check is there because i use the same script (with different Globals though so they don't screw each other up) for a spell that transports any NPC(except of dragons) you look at while triggering the spell to the same cell and holds them there for a while. If UseBlindness is true then it is only for the spell that sends NPC's there. If False for the spell that teleports the PC.

The problem occurs for both Spells though, NPC's are only send there for a second and then transported back instantly again too.

Scriptname A0KamuiScript extends activemagiceffectGlobalVariable Property Blindness  AutoGlobalVariable Property InUse  AutoGlobalVariable Property Uses  AutoGlobalVariable Property sharinuse  AutoImageSpaceModifier Property BlindnessFX AutoBool Property UseBlindness AutoObjectReference Property Marking  AutoObjectReference Property CellMarker  AutoCell Property CellCheck AutoActor Property Target Auto Hiddenevent OnEffectStart ( Actor akTarget, Actor Caster )if InUse.getvalue() == 0  If Caster.getav("Magicka") >= 100   Caster.damageav("Magicka",100)   Target = akTarget   if (Target.GetParentCell() != CellCheck)	If UseBlindness == true	 Target.SetAlert(false)	EndIf	Marking.MoveTo (Target)	Target.MoveTo (CellMarker)	InUse.setvalue(1)	Uses.setvalue(Uses.getvalue() + 1)   Endif  EndIf  If UseBlindness == true   if sharinuse.getvalue() == 1	if Blindness.getValue() <= 1.2	 Blindness.mod(0.005)	EndIf	BlindnessFX.remove()	BlindnessFX.apply(Blindness.getvalue())   EndIf  EndIfElseif  InUse.getvalue() == 1  self.dispel()EndIfEndEventevent OnEffectFinish ( Actor akTarget, Actor Caster )if (Target.GetParentCell() == CellCheck)  Target.Moveto (Marking)  InUse.setvalue(0)EndIfEndEvent

I hope anyone can help me there. I bet it is something tiny and dumb that i simply don't find.


EDIT: Also, does someone know how to make a armor that makes one look like a skeleton as long as you wear it?
User avatar
Far'ed K.G.h.m
 
Posts: 3464
Joined: Sat Jul 14, 2007 11:03 pm

Post » Mon Nov 19, 2012 1:40 am

Is this spell an Ability that gets applied to the target via AddSpell?
User avatar
herrade
 
Posts: 3469
Joined: Thu Apr 05, 2007 1:09 pm

Post » Mon Nov 19, 2012 5:36 am

No it is a lesser power. The effect is directly applied with a duration of 5 minutes. For the self teleport via Target: Self. For the other version via Target: Target Actor
User avatar
Vicki Gunn
 
Posts: 3397
Joined: Thu Nov 23, 2006 9:59 am

Post » Mon Nov 19, 2012 8:07 am

Well it definitely sounds like the OnEffectFinish event is getting called too soon. You can confirm that by sticking a Debug.Trace("OnEffectFinish event fired!") line in the event and then check the log file to confirm it's getting called early.

Then you just have to work out why. I do know that spells weirdly when running outside a loaded cell. Maybe moving the target to the remote cell is ending the effect. Try having it move the target to another location in the current cell, instead, just as a test, and see if it lasts the full allotted time.

If that works, then we know it's moving the target to another cell that's causing the problem. An alternative might be to stick a RegisterForSingleUpdate(300) at the end of the OnEffectStart code, and move the code in OnEffectFinish to OnUpdate. A somewhat cleaner (though more labor-intensive) workaround might be to attach the script to an Ability spell instead, and have the Self or Target Actor spell add the Ability to the target with AddSpell. The engine seems to do a better job of tracking applied Abilities than it does of spell effects, so you might not run into the same problem.
User avatar
Bambi
 
Posts: 3380
Joined: Tue Jan 30, 2007 1:20 pm

Post » Sun Nov 18, 2012 6:02 pm

I will try the debugging tomorrow. If that wields no fruits i will see what the problem might be.

My guess is that the If Event that checks if the ability is in use is somehow ignored or not used right, so that it runs the "unused-effect", then the else effect which says it should dispel itself thus firing the onfinish event, that is used to toggle the power off if the user uses it again.

I will try that out tomorrow as well.
User avatar
Destinyscharm
 
Posts: 3404
Joined: Sun Jul 23, 2006 6:06 pm

Post » Sun Nov 18, 2012 10:41 pm

Alright so it is not as i said. Only the start and end work, the else is ignored as it is supposed to.

I have a theory what might be happening. When the actor is teleported, then it is saved, deleted, and recreated where it is supposed to go. So i figure... is the deletion already enough to trigger a finish event?

I will try applying it as a spell like you suggested next. Maybe that helps
User avatar
stephanie eastwood
 
Posts: 3526
Joined: Thu Jun 08, 2006 1:25 pm

Post » Mon Nov 19, 2012 5:22 am

If that doesn't work, you could solve it by placing an invisible scripted activator at the target's location. In the OnLoad event of that Activator's script, use http://www.creationkit.com/FindClosestActorFromRef_-_Game(Self,100) to get the target's ObjectReference, then move it to the remote cell. The activator can then serve both as a guaranteed method for retrieve the actor later AND as the target point for the actor's retrieval.
User avatar
Adam
 
Posts: 3446
Joined: Sat Jun 02, 2007 2:56 pm

Post » Sun Nov 18, 2012 11:33 pm

Well i came to a point i need to start over. There are tons of errors in the script by now and i can't find them. I will start it over. But if i may ask a different question:
I am also making a spell that makes you become a ghost for 5 minutes(Script ghost, not game ghost. Attacks pass trough you but you don't get the blue see-trough effect. Now the problem is it is a self spell. And if you cast it once you become a ghost, so far so good. But if you cast it again since you are a ghost already you can't cast the spell again,as in, it can't hit you which....is inconvenient. Is there a way to do something like that without blocking the own spells? It should not make hitevents occur but make a exception for oneself.
User avatar
Evaa
 
Posts: 3502
Joined: Mon Dec 18, 2006 9:11 am

Post » Sun Nov 18, 2012 10:07 pm

If it's a self-targeted spell, can't you give it a 5-minute duration and just unghost the actor when the effect finishes?
User avatar
Kerri Lee
 
Posts: 3404
Joined: Sun Feb 25, 2007 9:37 pm

Post » Mon Nov 19, 2012 12:21 am

Yes that is what i did. I guess it works this way. I wanted it to be toggable, but i just put it down to 30 seconds and so it should work.
User avatar
(G-yen)
 
Posts: 3385
Joined: Thu Oct 11, 2007 11:10 pm


Return to V - Skyrim