Deleted31005User Posted July 9, 2015 Share Posted July 9, 2015 (edited) 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 July 9, 2015 by Guest Link to comment Share on other sites More sharing options...
lofgren Posted July 9, 2015 Share Posted July 9, 2015 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 More sharing options...
Mattiewagg Posted July 9, 2015 Share Posted July 9, 2015 (edited) 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() EndFunctionEdit: Typos. Edited July 10, 2015 by Mattiewagg Link to comment Share on other sites More sharing options...
firepower02 Posted July 10, 2015 Share Posted July 10, 2015 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. Link to comment Share on other sites More sharing options...
Mattiewagg Posted July 10, 2015 Share Posted July 10, 2015 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 More sharing options...
sLoPpYdOtBiGhOlE Posted July 10, 2015 Share Posted July 10, 2015 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, etcBam, 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 More sharing options...
Mattiewagg Posted July 10, 2015 Share Posted July 10, 2015 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, etcBam, 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 More sharing options...
sLoPpYdOtBiGhOlE Posted July 10, 2015 Share Posted July 10, 2015 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 Scriptname SpawnerTask Hidden ; SpawnerTask allows to spawn and position an arbitrary number references in game world. ; It's effectively a batch combination of PlaceAtMe and SetPosition/MoveTo that smoothly executes in a single frame. ; ; Example: ; ; ObjectReference player = ... ; Form chair = ... ; float[] offset = new float[3] ; float[] rotation = new float[3] ; ; ; Allocate new task ; int taskId = SpawnerTask.Create() ; ; ; No rotation ; rotation[0] = 0 ; rotation[1] = 0 ; rotation[2] = 0 ; ; ; Spawn 100 chairs in a grid above the player ; int i = 0 ; while i < 100 ; offset[0] = -250 + (i / 10) * 50 ; offset[1] = -250 + (i % 10) * 50 ; offset[2] = 200 ; ; SpawnerTask.AddSpawn(taskId, chair, player, offset, rotation) ; i += 1 ; endWhile ; ; ; Run the task and return all placed references in an array ; ObjectReference[] spawned = SpawnerTask.Run(taskId) ; Creates a new SpawnerTask and returns a handle, which is an identifier for the created task. ; The task handle is valid until the task has been run or canceled, or until the calling stack has exited. ; (Function type: non-delayed) ; int Function Create() global native ; Adds a spawn to the task identified by the given handle. ; Running the task places a new instance of formToPlace at target reference with given rotation and position offset. Parameters are analogously defined to PlaceAtMe. ; Multiple spawns can be added to the same task to be executed in a batch (which is the purpose). ; (Function type: non-delayed) ; Function AddSpawn(int handle, Form formToPlace, ObjectReference target, float[] positionOffset, float[] rotation, int count = 1, bool bForcePersist = false, bool bInitiallyDisabled = false) global native ; Runs the task and returns the spawned references in an array. May return arrays with a size larger than 128. ; The resources allocated to the task are freed in the process, so the same task handle cannot be run twice. ; (Function type: latent) ; ObjectReference[] Function Run(int handle) global native ; Cancels a task before running it and frees its allocated resources. ; Tasks cannot be canceled once they have been started with Run, and vice versa. ; Function Cancel(int handle) global native Link to comment Share on other sites More sharing options...
Deleted31005User Posted July 10, 2015 Author Share Posted July 10, 2015 (edited) 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 July 10, 2015 by Guest Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted July 10, 2015 Share Posted July 10, 2015 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 EndEventHere'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 More sharing options...
Recommended Posts