Jump to content

Need help. Trigger Box Spawns actors then kills them.


m00resy

Recommended Posts

I'm trying to make an triggerbox that when activated spawns 3 actors on XMarkers. However I need it so when you activate the triggerbox again it kills them. So far I can spawn them but I don't know how to set the script to kill the actors. It should work similar to a lightswitch function.

 

I'm pretty new to this so trying to get my head around the script. This is what I have so far.

 

Scriptname ZigguratSummonScript extends ObjectReference Const
ObjectReference Property XMarker Auto Const
ObjectReference Property XMarker02 Auto Const
ObjectReference Property XMarker03 Auto Const
ActorBase Property ZigguratSummonActor Auto Const
ActorBase Property ZigguratSummonActor02 Auto Const
ActorBase Property ZigguratSummonActor03 Auto Const
;events
Event OnActivate(ObjectReference akActionRef)
if (akActionRef == Game.GetPlayer())
XMarker.PlaceActorAtMe(ZigguratSummonActor)
XMarker02.PlaceActorAtMe(ZigguratSummonActor02)
XMarker03.PlaceActorAtMe(ZigguratSummonActor03)
debug.Notification("test")
endif
EndEvent
Any help would be appreciated.
Link to comment
Share on other sites

To do this you can add 3 more ObjectReference properties to your script and then spawning them like this:

Scriptname ZigguratSummonScript extends ObjectReference Const
 
ObjectReference Property XMarker Auto Const
 
ObjectReference Property XMarker02 Auto Const
 
ObjectReference Property XMarker03 Auto Const
 
ActorBase Property ZigguratSummonActor Auto Const
 
ActorBase Property ZigguratSummonActor02 Auto Const
 
ActorBase Property ZigguratSummonActor03 Auto Const
 
;Add these and don't fill them with anything in the CK
ObjectReference Property Actor01 Auto
ObjectReference Property Actor02 Auto
ObjectReference Property Actor03 Auto
 
;events
Event OnActivate(ObjectReference akActionRef)
   if (akActionRef == Game.GetPlayer())
      If(!Actor01 && !Actor02 && !Actor03) ;If none of the properties are filled spawn the actors
         Actor01 = XMarker.PlaceActorAtMe(ZigguratSummonActor)
         Actor02 = XMarker02.PlaceActorAtMe(ZigguratSummonActor02)
         Actor03 = XMarker03.PlaceActorAtMe(ZigguratSummonActor03)
         debug.Notification("test")
      Else ;if any or all of the actors are alive then kill them and reset their properties.

         (Actor01 As Actor).Kill()
         (Actor02 As Actor).Kill()
         (Actor03 As Actor).Kill()
 

         Actor01.Delete(); this removes their bodies if you don't want that then you can remove these.
         Actor02.Delete()
         Actor03.Delete()
 

         Actor01 = None
         Actor02 = None
         Actor03 = None

   endif
EndEvent

This will keep repeating if you want it to only spawn and kill once the you'll have to add a bloolean property and add it to the first if statement.

Edited by LoneRaptor
Link to comment
Share on other sites

I've made these changes so far going off what you have done thank you, this is what it looks like right now.

 

Scriptname ZigguratSummonScript extends ObjectReference Const

ObjectReference Property XMarker Auto Const

ObjectReference Property XMarker02 Auto Const

ObjectReference Property XMarker03 Auto Const

ActorBase Property ZigguratSummonActor Auto Const

ActorBase Property ZigguratSummonActor02 Auto Const

ActorBase Property ZigguratSummonActor03 Auto Const

ObjectReference Property Actor01 Auto Const

ObjectReference Property Actor02 Auto Const

ObjectReference Property Actor03 Auto Const


;events
Event OnActivate(ObjectReference akActionRef)
	if (akActionRef == Game.GetPlayer())
		If(!Actor01 && !Actor02 && !Actor03) ;If none of the properties are filled spawn the actors
			Actor01 = XMarker.PlaceActorAtMe(ZigguratSummonActor)
			Actor02 = XMarker02.PlaceActorAtMe(ZigguratSummonActor02)
			Actor03 = XMarker03.PlaceActorAtMe(ZigguratSummonActor03)
			debug.Notification("test")
		Else ;if any or all of the actors are alive then kill them and reset their properties.

			(Actor01 As Actor).Kill()
			(Actor02 As Actor).Kill()
			(Actor03 As Actor).Kill()

			Actor01.Delete(); this removes their bodies if you don't want that then you can remove these.
			Actor02.Delete()
			Actor03.Delete()

			Actor01 = None
			Actor02 = None
			Actor03 = None
		EndIf
	ENDIF
EndEvent

Unfortunately I'm getting some compiling errors that make no sense to me.

 

Compiling "ZigguratSummonScript"...
C:\Users\AppData\Local\Temp\PapyrusTemp\ZigguratSummonScript.psc(26,3): property Actor01 on script zigguratsummonscript is read-only, you cannot give it a value
C:\Users\AppData\Local\Temp\PapyrusTemp\ZigguratSummonScript.psc(26,3): type mismatch while assigning to a none (cast missing or types unrelated)
C:\Users\AppData\Local\Temp\PapyrusTemp\ZigguratSummonScript.psc(27,3): property Actor02 on script zigguratsummonscript is read-only, you cannot give it a value
C:\Users\AppData\Local\Temp\PapyrusTemp\ZigguratSummonScript.psc(27,3): type mismatch while assigning to a none (cast missing or types unrelated)
C:\Users\AppData\Local\Temp\PapyrusTemp\ZigguratSummonScript.psc(28,3): property Actor03 on script zigguratsummonscript is read-only, you cannot give it a value
C:\Users\AppData\Local\Temp\PapyrusTemp\ZigguratSummonScript.psc(28,3): type mismatch while assigning to a none (cast missing or types unrelated)
C:\Users\AppData\Local\Temp\PapyrusTemp\ZigguratSummonScript.psc(40,3): property Actor01 on script zigguratsummonscript is read-only, you cannot give it a value
C:\Users\AppData\Local\Temp\PapyrusTemp\ZigguratSummonScript.psc(41,3): property Actor02 on script zigguratsummonscript is read-only, you cannot give it a value
C:\Users\AppData\Local\Temp\PapyrusTemp\ZigguratSummonScript.psc(42,3): property Actor03 on script zigguratsummonscript is read-only, you cannot give it a value
No output generated for ZigguratSummonScript, compilation failed.

My actor object references are cont which I cant unckeck, not sure what im doing wrong there.

Link to comment
Share on other sites

That worked! You are a life saver thank you very much. I'm going to experiment around and see if i can add an effect to them when they spawn. Similar to synth spawning. I'm guessing I add an explosion property. If anyone wants to use this as reference ill leave it here.

Scriptname ZigguratSummonScript extends ObjectReference

ObjectReference Property XMarker Auto Const

ObjectReference Property XMarker02 Auto Const

ObjectReference Property XMarker03 Auto Const

ActorBase Property ZigguratSummonActor Auto Const

ActorBase Property ZigguratSummonActor02 Auto Const

ActorBase Property ZigguratSummonActor03 Auto Const

ObjectReference Property Actor01 Auto

ObjectReference Property Actor02 Auto

ObjectReference Property Actor03 Auto


;events
Event OnActivate(ObjectReference akActionRef)
	if (akActionRef == Game.GetPlayer())
		If(!Actor01 && !Actor02 && !Actor03) ;If none of the properties are filled spawn the actors
			Actor01 = XMarker.PlaceActorAtMe(ZigguratSummonActor)
			Actor02 = XMarker02.PlaceActorAtMe(ZigguratSummonActor02)
			Actor03 = XMarker03.PlaceActorAtMe(ZigguratSummonActor03)
			debug.Notification("test")
		Else ;if any or all of the actors are alive then kill them and reset their properties.

			debug.Notification("Test2")

			(Actor01 As Actor).Kill()
			(Actor02 As Actor).Kill()
			(Actor03 As Actor).Kill()

			Actor01.Delete(); this removes their bodies if you don't want that then you can remove these.
			Actor02.Delete()
			Actor03.Delete()

			Actor01 = None
			Actor02 = None
			Actor03 = None
		EndIf
	ENDIF
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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