Jump to content

Would like help scripting a spell effect


ahotbanana

Recommended Posts

I've been working on a fairly detailed (albeit linear) quest. As part of that quest I am giving the player access to a lot of new spell effects that I will be scripting. On the whole, I am finding this to not be a problem as most of the effects are pretty simple things. However, on one of the more bizarre effects I want to implement I have run into a problem.

 

Basically, I want the spell to create a copy of the target actor (which will exist a finite amount of time) and for the duration of its life have it fight alongside the player. I was planning to use CreateFullActorCopy and then target the copy with the already defined spell Command Humanoid. My problem is that I don't know how to target the copy with a spell.

 

Any help would be much appreciated.

Link to comment
Share on other sites

You can set the reference variable at the time of creating the copy. Once you have that, your script can manipulate the copied NPC in any way you can code:

 

set newRef to NPCToBeCopied.CreateFullActorCopy
Activator.Cast CommandHumanoidSpell newRef

 

Also check out the Summon Doppleganger mod - reverse engineering it might give you some good scripting insights. :)

Link to comment
Share on other sites

After your done with the copy, be sure to delete it with:

ref.DeleteFullActorCopy

 

This is because any copy that you don't clean remains stuck inside your savegame. As the number of copies increase, the size of the savegame file will increase until it causes the game to run at extremely slow speeds. This is known as "Savegame Bloating" or "The Frozen Door Bug".

 

 

On a side note, DeleteFullActorCopy also acts as a return function; no lines following the function will be processed. Make sure it is called last, either within the spell or the "Do Once Loop." Just a friendly heads up :thumbsup:

Link to comment
Share on other sites

I am not so sure about using a script to cast "Command Humanoid" on the clone. Wouldn't using

 

Activator.Cast CommandHumanoidSpell newRef

 

mean that the clone becomes the activator's ally? That doesn't make sense, since an activator doesn't choose sides in a fight. So you'll need to script an NPC or the Player to cast the spell. However there's a problem with the cast function so that NPCs don't cast spells at targets that are further away than the "on touch" distance.

 

Perhaps you should just raise the clone's disposition towards the player to 100, or add it to the PlayerFaction.

Link to comment
Share on other sites

Thanks for the replies, everyone!

 

I wasn't planning on having any NPCs use the spells, so although I'm sure it's horrible practise, I might just use the cast function.

 

I am running into a very similar problem, though. Using "activator" returns an error message when I try to save the script, if I omit it entirely the target of the spell casts command humanoid on the clone (and hence you just increase your enemies by casting the spell) and if I use "player.cast" nothing happens at all. I've tried modding the disposition too and making the copy and the player both join a faction as soon as the spell is cast... neither worked. I've looked through all of the CS commands and can't find anything that does what I want.

 

The idea of using a faction has come closest to achieving what I want (the clone doesn't attack ANYONE, in the others it tends to attack ME). Is there a way of making a faction fight anything that is fighting the player?

 

@WarRatsG: Yeah, I was wondering if I was going to run into problems with that... thanks for the heads up (I was planning to just use disable... *facepalm*)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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