Jump to content

I need help making a script for a multiple summons spell


LordChenzi

Recommended Posts

Here's the latest version of the script. Just a few minor tweaks. A demo esp and script is attached (summons 10 dogs).

 

To use the demo spell:

- Extract the files to your Skyrim Data folder

- Activate the esp

- Launch the game.

- In the console type: help "summon legion"

- Note the ID number of the spell, then type: player.addspell <ID#>

- The spell will be under Conjuration

 

 

 

Scriptname SummonNPCLegionScript extends ActiveMagicEffect
{Summons up to 10 NPC's of ActorBase "NPCType"}

;*********************************************************
;	PROPERTIES TO BE ASSIGNED IN THE CK
;********************************************************* 

ActorBase Property NPCType auto			; the type of NPC to summon
Int Property SizeOfLegion = 10 auto			; the number of NPCs to summon (DEFAULT=10)
Explosion Property AppearExplosion auto		; the summon explosion effect (OPTIONAL). "ExplosionIllusionDark01" works well.
EffectShader Property Shader auto			; the shader to apply to the NPC when summoned (OPTIONAL). "TimeFadeIn01FXS" works well.
EffectShader Property Shader2 auto			; the shader to apply to the NPC when spell ends (OPTIONAL). "TimeFadeOut01FXS" works well.
Faction Property PlayerFaction auto			; Faction used to make the npc a friend of the player.
Faction Property CWPlayerAlly auto			; Faction used to make the npc an ally of the player


;********************************************************* 

ObjectReference[] NPC	; an array to reference the summoned NPC's

;********************************************************* 

Event onEffectStart(Actor akTarget, Actor akCaster)

NPC = new ObjectReference[10] 		; arrays must be created within a function or event block. Arrays can be up to 256 in size.

If SizeOfLegion > NPC.Length
	SizeOfLegion = NPC.Length	; just for safety
EndIf

int count = 0

While count < SizeOfLegion

	NPC[count] = Game.GetPlayer().PlaceAtMe(NPCType)
	(NPC[count] as Actor).RemoveFromAllFactions()
	(NPC[count] as Actor).SetFactionRank(PlayerFaction, 5)
	(NPC[count] as Actor).AddToFaction(CWPlayerAlly)

	If AppearExplosion
		NPC[count].PlaceAtMe(AppearExplosion)
	EndIf

	NPC[count].Enable()	

	If Shader
		Shader.Play(NPC[count], 5)
	EndIf

	count += 1

EndWhile

EndEvent

;********************************************************* 

Event OnEffectFinish(Actor akTarget, Actor akCaster)

int count = 0

While count < SizeOfLegion

	If Shader
		Shader2.Play(NPC[count], 3)
	EndIf

	If AppearExplosion
		NPC[count].PlaceAtMe(AppearExplosion)
	EndIf

	NPC[count].DisableNoWait()
	count += 1

EndWhile

EndEvent

;********************************************************* 

 

Edited by steve40
Link to comment
Share on other sites

MoveTo does not create a new reference.

 

The way the Oblivion mods worked was that the summoned creatures would be resurrected and moved from their holding cell to the player's position. The same creatures would be reused over and over so that if the mod let you summon eight creatures at once, there would be eight persistent references added to the savegame bloat rather than an additional eight persistent references added each and every time the spell was cast. ( 8 < 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + ...)

Link to comment
Share on other sites

  • 1 year later...

Hey Guys!

 

I know this thread is a bit old, but it's pretty much what I'm looking for.

Scripting is a bit of a mystery to me, so my brother changed your script for me, to fit in my mod.

The basic idea is that if you read a specific book, you summon x NPCS.

He got it to work, but the summoned NPC's remain hostile. Could anybody be so nice and change the script to summon friendly NPC's? Thanks!

EDIT: It would also be nice if the book had a cooldown..

Scriptname AAABLACKBOOK extends ObjectReference  

Actor[] npcs; array holding the ref ids of summoned ncps

Int Property num_npcs = 10 auto                     ; Number of npcs to summon (default 10, max 15)
Explosion Property summon_explosion AUTO        ; Explosion Effect to use when an npc is summoned (optional)
EffectShader Property shader AUTO                ; Shader to apply to summoned npcs (optional)
ActorBase Property npc_type AUTO                     ; Type of npcs to summon
Int Property summon_friendly = 1 AUTO             ; 1 if summoned units are friendly, 0 if not

Event OnRead()
  npcs = new Actor[15]
  int i = 0

  While i < num_npcs
    npcs[i] = Game.GetPlayer().PlaceAtMe(npc_type) As Actor
    
    If summon_explosion
      npcs[i].PlaceAtMe(summon_explosion)
    EndIf

    If summon_friendly == 1
      npcs[i].MakePlayerFriend()
    EndIf
    
    npcs[i].Enable()
    
    If shader
      shader.Play(npcs[i], 2);
    EndIf

    i += 1

  EndWhile
EndEvent
Edited by kevchef
Link to comment
Share on other sites

  • 5 years later...
  • Recently Browsing   0 members

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