Jump to content

ObjectReference Spell?


davidnowlin

Recommended Posts

I designed a teleportation system that works and that I really like... all except the animations. I have a custom spell that teleports the player from anywhere in skyrim to a playerhouse I'm designing and a teleporter in the house made from a bunch of triggerboxes and a skyrim CWmap that allows the player to teleport back out again to one of 30 locations all over the worldspace. The problem is I'm new at this sort of thing and I can't figure out how to get the animations to match up. I like the SummonTargetFX animation from the SummonDramoraLord spell, so I'm using that for my custom spell and would like it to use it for the objectreference oriented teleport-out part too, but I don't know how to script it.

 

I've thought of two solutions, but I don't know how to do either one.

 

1) have the 30 click-box-triggers fire off a magic effect identical to the one the spell uses. The problem here is that the triggers are based on objectreference scripts using onActivate events and the spell is an activeMagicEffect script using an onEffectFinish script. I don't know enough about scripting to tell how to make one into the other. Is there a way to make an activator cast a spell on the player when clicked?

 

2) construct the spell from the ground up. This is what I tried to do, and so far I have not succeeded. I can make the activator trigger boxes force a static animation to play using playGamebryoAnimation. The animation I've been using is FXDA14PortalDoor, which opens up a nice little ball o' magic. I think I can make it open the ball o magic where the player is standing (the teleporter is big enough so that you can't reach all the buttons from one spot, so in 3rd person view, it looks odd for the animation to open up from a static location if the player is off center). But the problem is, I don't like the animation. I want it to be the same one as the spell (SummonTargetFX). This ARTO form type does not appear to have an object I can place in the world, or move to the player with placeAtMe.

 

I'd rather do it the first way anyway, since that just seems easier (dialog boxes already exist for mapping out all the different parts of a magic effect). But any help with either method would be appreciated.

 

Thanks in advance

Link to comment
Share on other sites

  1. Hmm... DefaultCastOnTriggerSCRIPT or ApplyMagicDamageOnEnter? Something like that maybe.
  2. Heh. You should copy one of the summoning spells that have the effects you want, remove the part that summons the creature, and have the activator cast it at the player.

Link to comment
Share on other sites

  1. Hmm... DefaultCastOnTriggerSCRIPT or ApplyMagicDamageOnEnter? Something like that maybe.
  2. Heh. You should copy one of the summoning spells that have the effects you want, remove the part that summons the creature, and have the activator cast it at the player.

 

 

Okay, after a couple of hours of trying to parse what this means I haven't actually gotten anywhere. No, that's not true. I did find the 'cast - spell' entry on the creation kit wiki, which tells me, essentially, the following:

 

Function Cast(ObjectReference akSource, ObjectReference akTarget = None) native

 

 

I've tried to figure out what this means too, and I am really not getting anywhere. It seems clear that the akSource and akTarget need to be replace with the caster and the target of the spell (both 'Player' in my case) but I can't figure out how you would pass a property that the spell script requires into it.

 

Here are the two spell scripts I have now:

 

First, the Object script

 

Scriptname a00TeleporterCityScript extends ObjectReference  

ObjectReference property teleDest auto
ObjectReference Player

Event OnActivate(ObjectReference akActionRef)
Player = Game.GetPlayer()
Utility.Wait(2.25)
Player.MoveTo(teleDest)
EndEvent

 

The script requires that two properties be defined: "Player" and "teleDest" the destination for the spell. I have, at this point, simply defined them as properties on the objects. Each trigger box uses the same script to send the player to a different 'teleDest' which is defined as a property by right-clicking on the script in the script tab of the object's properties. Not difficult.

 

Here's the spell:

 

Scriptname a00TeleportSpellSCR extends activemagiceffect  

ObjectReference property teleDest auto

Event OnEffectFinish(Actor target, Actor caster)
    target.moveTo(teleDest)
EndEvent

 

This too requires a 'teleDest' property, which I have defined by attaching the COCMarker for my player home directly to the spell, which is why the spell is only one-way. In order to have each clickable object send the player to a different place, I need to have a way to have each button pass a different destination into the spell as it fires. I have a feeling it will look something like this:

 

Scriptname a00TeleporterCityScript extends ObjectReference  

ObjectReference property teleDest auto
ObjectReference Player

Event OnActivate(ObjectReference akActionRef)
Player = Game.GetPlayer()
Utility.Wait(2.25)
Function Cast(ObjectReference Player, ObjectReference Player = None) native
EndEvent

 

...but I can tell this won't work without even trying it because nothing in this script tells the spell where to send the player.

 

Comments? Suggestions?

 

Thanks for your help so far, but additional help is still needed. :tongue:

Edited by davidnowlin
Link to comment
Share on other sites

Ok. Sorry I wasn't more explicit the first time. Here is what I was suggesting.

 

Copy one of the summon spells to use for your teleport visual effects and sounds. To do this, first look in Magic > Spell list for the spell to use, say Conjure Familiar. The 'RightHand'/'LeftHand' spells are usually for NPCs I think, so don't use one of those. Alright, so you found ConjureFamiliar and have it open. Edit the effect and you'll see that the Magic Effect used in the spell is SummonFamiliar. In the Object Window, go to the Magic Effect list and open SummonFamiliar. Make a few changes:

  • ID = TeleportFXActor
  • Name = Teleport FX
  • Archetype = Script
  • Delivery = Target Actor
  • Base Cost = 0
  • No Duration = YES
  • Painless = YES
  • Keywords = delete
  • Description = delete
  • Casting Time = 0

Click OK. It will ask if you want to create a new Form. Click YES. Back in the spell window, close the effect item dialog. Delete the current effect from the Effects list. Make a few changes to the spell:

  • ID = TeleportFX
  • Name = Teleport FX
  • Delivery = Target Actor
  • Casting Perk = NONE
  • Disallow Spell Absorb = YES
  • Ignore Resistance = YES

Add a new effect and pick TeleportFXActor from the combo. Click OK, OK. It will ask you if you want to make a new Form. Click YES.

 

Ok. So we have a spell that should look the same as Conjure Familiar but not actually summon anything. Right. Onward to the script.

 

Scriptname a00TeleporterCityScript extends ObjectReference

ObjectReference Property teleDest Auto
Spell Property TeleportFX Auto

Event OnActivate(ObjectReference akActionRef)

; cast the flashy spell at whoever activated me
TeleportFX.Cast(self, akActionRef)

; wait a bit while the effects play
Utility.Wait(2.5)

; teleport whoever to the destination
akActionRef.MoveTo(Destination)

EndEvent

Alright. Edit your a00TeleporterCityScript script and past in my version. Save. Properties, TeleportFX, Auto-Fill. OK. You'll have to Auto-Fill the TeleportFX property on each button your script is attached to.

Link to comment
Share on other sites

 

1) have the 30 click-box-triggers fire off a magic effect identical to the one the spell uses. The problem here is that the triggers are based on objectreference scripts using onActivate events and the spell is an activeMagicEffect script using an onEffectFinish script. I don't know enough about scripting to tell how to make one into the other. Is there a way to make an activator cast a spell on the player when clicked?

 

 

Not at the creation kit right now, but per http://www.creationkit.com/Activator, Activators have a script that can be associated with them. In that script just have an OnActivate Event handle casting the spell on the player.

 

 

 

ScriptName TestActivatorScript Extends ObjectReference
Spell Property TeleportSpell Auto

Event OnActivate(ObjectReference akActionRef)
    TeleportSpell.Cast(akActionRef,akActionRef)
EndEvent

 

Am I missing something in your description?

 

-MM

Link to comment
Share on other sites

 

 

Not at the creation kit right now, but per http://www.creationkit.com/Activator, Activators have a script that can be associated with them. In that script just have an OnActivate Event handle casting the spell on the player.

 

 

 

ScriptName TestActivatorScript Extends ObjectReference
Spell Property TeleportSpell Auto

Event OnActivate(ObjectReference akActionRef)
    TeleportSpell.Cast(akActionRef,akActionRef)
EndEvent

 

Am I missing something in your description?

 

-MM

 

I appreciate your efforts, guys, but it doesn't work. I think I know what this is supposed to accomplish: The basic idea is just create a spell that does nothing except flashy animation, have the trigger cast the spell on the actor and then use the trigger script to do the moveTo()... Because of the way the original spell is set up, the animation isn't happening.

 

When you cast a summon spell, the animation that I want goes off at the point the caster is looking at, not at the caster. I think that's the problem. I tested it and could not get the button to make the animation run. So I put the spell on the player to see what happens if you cast it like a normal spell. Nothing. I got the sound effects (which I'm not getting when I press the button) but no animation. So I went back and made the casting type 'self' instead of 'target actor' and tested that one... No problem. I get the animation and the sound effects when the player casts it... but not when the button casts it. I tried each of the following to see what happens when I have the box cast the spell itself as opposed to having the box force the player to cast the spell:

 

TeleportFX.cast(Player, Player)

TeleportFX.cast(self, Player)

TeleportFX.cast(self, akActionRef)

TeleportFX.cast(akActionRef, akActionRef)

 

... Nothing works. I know I'm missing something here, but I don't know what. I even tried making the spell into a delivery: target location instead because that's what the original is, and that doesn't work either.

 

:wallbash:

Edited by davidnowlin
Link to comment
Share on other sites

Nope. That's not it. I think.

 

I wanted to test out my theory that it was the spell's natural delivery type that was the problem, so I chose a spell that is specifically a target actor spell: healing hands. I didn't modify it or anything. I just changed the script to cast healing hands instead of the teleport spell. Nothing. I tried both (self, akActionRef) and (akActionRef, akActionRef). No response. There's something wrong with the way we're trying to use the 'cast' command.

Link to comment
Share on other sites

I am the stupidest man alive. I was doing all my tests from a save that was already in the cell. Apparently that kept the box from loading right and it didn't ever change, no matter what changes I made to the spell. :tongue:

 

When I started just doing a coc [location] from the load screen, it started working like a charm. Still had some trouble getting the animation to load at first, but I copied a healing spell instead of a conjure spell and then just tweaked it with the right animations and voila! It works.

 

I can't thank you guys enough. Not only do I have a working script; I now know basic function syntax in papyrus. Beers are on me.

 

:biggrin:

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...