Complete Example Scripts: Difference between revisions
Jump to navigation
Jump to search
Added repeatable summon script
imported>JustinOther m (→Creating a Simple Toggle: Simplified and removed unused property) |
imported>JustinOther (Added repeatable summon script) |
||
| Line 815: | Line 815: | ||
EndIf | EndIf | ||
EndFunction</Source> | EndFunction</Source> | ||
= Summon Spell = | |||
*The below will summon YourSummonREF from wherever they are to the player. In this example, it's dealt with by a spell, but the function could be placed and/or called elsweyr. If as a spell, be sure to set the cooldown time to about 3.0 seconds so the caster can't cast it again until it's worked itself out. | |||
<Source lang="Papyrus">ScriptName RepeatableSummonEffectScript extends ActiveMagicEffect | |||
Actor Property YourSummonREF Auto ; An ObjectReference will also work with the summon function | |||
Event OnEffectStart(Actor akTarget, Actor akCaster) | |||
Summon(akCaster, YourSummonREF) | |||
EndEvent | |||
Function Summon(ObjectReference akSummoner = None, ObjectReference akSummon = None, Float afDistance = 150.0, Float afZOffset = 0.0, ObjectReference arPortal = None, Int aiStage = 0) | |||
While aiStage < 6 | |||
aiStage += 1 | |||
If aiStage == 1 ; Shroud summon with portal | |||
arPortal = akSummon.PlaceAtMe(Game.GetForm(0x0007CD55)) ; SummonTargetFXActivator disables and deletes itself | |||
ElseIf aiStage == 2 ; Disable Summon | |||
akSummon.Disable() | |||
ElseIf aiStage == 3 ; Move portal in front of summoner | |||
arPortal.MoveTo(akSummoner, Math.Sin(akSummoner.GetAngleZ()) * afDistance, Math.Cos(akSummoner.GetAngleZ()) * afDistance, afZOffset) | |||
ElseIf aiStage == 4 ; Move summon to portal | |||
akSummon.MoveTo(arPortal) | |||
ElseIf aiStage == 5 ; Enable summon as the portal dissipates | |||
akSummon.Enable() | |||
EndIf | |||
Utility.Wait(0.6) | |||
EndWhile | |||
EndFunction</source> | |||