Jump to content

Need help with script to summon several skeletons with one spell.


Deleted31005User

Recommended Posts

This is regarding my mod Tel Nalta II:

Something that I always wanted to add was an extra spell that allows the player to summon a small army of undead, for example like 3-5 skeletons with just one summon spell.

The idea is that these skeletons are temporary but they cannot be actual summoned creatures, otherwise you'll be stuck with a limit of 1-2 skeletons and it would also remove any previous creatures you had summoned.

 

I lack any experience with scripts myself so hopefully someone can help me out here.

Edited by Guest
Link to comment
Share on other sites

There are template scripts that would allow you to do this by using PlaceAtMe(). You can find them in use by some summoning spells, for example the werewolf's howl of brotherhood. However another option would be to add a perk that increases the number of summons for your specific spell only. You can see an example of this approach by checking the Ritual Stone's functions.

Link to comment
Share on other sites

The script itself would likely be something like this:

Scriptname SummonMultipleSkeletons Extends ActiveMagicEffect

ActorBase Property Skele Auto;make this your skeleton, should be friendly to the player
Actor Skele1 
Actor Skele2
Actor Skele3
Actor Skele4
Actor Skele5

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Skele1 = akCaster.PlaceActorAtMe(Skele)
	Skele2 = akCaster.PlaceActorAtMe(Skele)
	Skele3 = akCaster.PlaceActorAtMe(Skele)
	Skele4 = akCaster.PlaceActorAtMe(Skele)
	Skele5 = akCaster.PlaceActorAtMe(Skele)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	KillAndDisable(Skele1)
	KillAndDisable(Skele2)
	KillAndDisable(Skele3)
	KillAndDisable(Skele4)
	KillAndDisable(Skele5)
EndEvent

Function KillAndDisable(Actor target)
	target.Kill()
	target.Disable(true)
        target.Delete()
EndFunction

Edit: Typos.

Edited by Mattiewagg
Link to comment
Share on other sites

  On 7/10/2015 at 1:11 AM, firepower02 said:

Does that script won't bloat up your save file? Everytime the spell ends, there will be tons of skeleton litter all over the place.

It disables them and then deletes them...

Link to comment
Share on other sites

If your using SKSE 1.7.3, it has an awesome Batch Spawn function.

 

Spawns all your items in 1 frame at the same time.

Since PlaceAtme is fairly slow to run consecutively eg: spawns an item, spawns another item, etc

Bam, all items spawned simultaneously and optionally placed at offsets to the the spawn location.

So you do a loop and optionally fills some position offset arrays and add to the batch spawn list (which is fast)

call an FX eg: Conjure fx and fire the batch spawn, bam your skele's all spawned in one go.

 

Can provide an example of it if you like.

But drawback is the your mod requires SKSE 1.7.3 (to me that's not a drawback, but to others may be)

 

I use the batch spawn function in my own bookcase script and all the books plop on the shelf in one instead of one by one.

 

If there were batch functions like: Delete, Disable, Enable, MoveTo etc, then you could do some impressive stuff on the fly in the blink of an eye.

Instead of one by one in view of the eye and waiting for a loop that gets slowed down by repetitive calls to Delete, Disable, Enable or MoveTo.

Link to comment
Share on other sites

  On 7/10/2015 at 1:47 AM, sLoPpYdOtBiGhOlE said:

If your using SKSE 1.7.3, it has an awesome Batch Spawn function.

 

Spawns all your items in 1 frame at the same time.

Since PlaceAtme is fairly slow to run consecutively eg: spawns an item, spawns another item, etc

Bam, all items spawned simultaneously and optionally placed at offsets to the the spawn location.

So you do a loop and optionally fills some position offset arrays and add to the batch spawn list (which is fast)

call an FX eg: Conjure fx and fire the batch spawn, bam your skele's all spawned in one go.

 

Can provide an example of it if you like.

But drawback is the your mod requires SKSE 1.7.3 (to me that's not a drawback, but to others may be)

 

I use the batch spawn function in my own bookcase script and all the books plop on the shelf in one instead of one by one.

 

If there were batch functions like: Delete, Disable, Enable, MoveTo etc, then you could do some impressive stuff on the fly in the blink of an eye.

Instead of one by one in view of the eye and waiting for a loop that gets slowed down by repetitive calls to Delete, Disable, Enable or MoveTo.

So it's multithreaded PlaceAtMe? That's awesome they're doing that.

Link to comment
Share on other sites

Not Sure about multithreaded, but it spawns everything in a frame.

This is the SpawnTask script from SKSE 1.7.3 (just in case you don't feel like digging).

I only had that to go by for the description, but it's impressive when in action (to me anyway):

  Reveal hidden contents

 

Link to comment
Share on other sites

Well its hard for me to understand all that technical talk, but you can give me example if you want Sloppy.

My mod already has some scripts in it that requires SKSE, so having it require SKSE 1.7.3 won't make a big difference.

 

Though 1.7.3 is still in beta, won't that give any issues?

Edited by Guest
Link to comment
Share on other sites

Sure here you go, basically the same thing as Mattiewagg, but using SKSE SpawnTask.

Difference being in this version is it's a little more dynamic.

In other words you don't need to edit the script to add or remove the amount of skeletons you want to spawn.

Just fill the properties with what your after and the script does the rest.

Didn't do anything fancy with placing them when they spawn, just basically spawns in front of you in a heap.

Scriptname MultiSkeletonEffectScript Extends ActiveMagicEffect

ActorBase Property Skeleton Auto ;Add DunPlayerAllyFaction to your base skeleton to be friendly with player, Maybe add a Follow AI Package as well.
Int Property SkeletonAmount = 5 Auto ;How many skeletons you want to spawn, try a large amout to see spawn task do it's thing.
Activator Property SummonTargetFXActivator Auto ;Summon fx, deletes itself after 5 seconds.
ObjectReference[] Skeletons

Event OnEffectStart(Actor akTarget, Actor akCaster)
    Float[] fOffset = New Float[3]
    Float[] fRotation = New Float[3]
    fOffset[0] = 300 * Math.Sin(akCaster.GetAngleZ())
    fOffset[1] = 300 * Math.Cos(akCaster.GetAngleZ())
    Int taskId = SpawnerTask.Create()
    SpawnerTask.AddSpawn(taskId, SummonTargetFXActivator, akCaster, fOffset, fRotation)
    Int i = SkeletonAmount
    While i
        i -= 1
        SpawnerTask.AddSpawn(taskId, Skeleton, akCaster, fOffset, fRotation)
    EndWhile
    Skeletons = SpawnerTask.Run(taskId)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
    Int i = Skeletons.Length
    While i > 1 ;Ignore summon FX it deletes itself
        i -= 1
        (Skeletons[i] As Actor).Kill()
        Skeletons[i].Disable(True)
        Skeletons[i].Delete()
    EndWhile
EndEvent

Here's an example of the above script in use

 

Anything in the esp is named MultiSkeleton, so Multi as a filter gets you what your after in CK pretty quick.

 

Because I'm lazy I just did a key press and it adds the spell to you, press the same key again and it removes the spell from you.

"K" is the key to press.

The spell itself is an ability type and not in a school, Just so you can see how the spawn works.

The Spawned Skeletons are player friendly and will follow you.

 

Try setting the SkeletonAmount property on the effect script to something like 20 or 100 (providing your hardware and game can take it).

Just to see what it's like with spawning large amounts of items.

 

Edit: As for 1.7.3 being beta, so was 1.7.2, but people seem to have forgot about that now that 1.7.3 is out and they think that 1.7.2 was never beta.

I've been using 1.7.3 since it's initial release and I can't say it's broken anything for me at all.

Once again it just offered me a nice little set of functions that I can make use of here there as well as gradually lifting limits with each release on that crappy papyrus scripting engine.

 

1.7.3 fixes CreateXXXXXArray function failing to null fill when creating a ReferenceAlias array.

Love the CreateXXXXXArray functions as they can be initialized with a variable and they can be greater the 128 elements.

So at least you can create array on the fly based on the return of a count held in a variable.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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