Jump to content

Capabilities of: OnTutorialEvent - ScriptObject


Recommended Posts

Whats the error?

 

Nevermind I know what's the problem. Try this.(don't have access to CK so there was mistake)

 

Scriptname CaDW_Drop_WW extends ObjectReference

 

Furniture property pCaDW_FO4_co_Tool_PortableWeaponsWorkbenchGround auto const mandatory

MiscObject property pCaDW_FO4_co_Tool_PortableWeaponsWorkbenchInventory auto const mandatory

 

ObjectReference workbenchRef

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

if (!akNewContainer && akOldContainer == game.getPlayer())

;self.MoveToNearestNavmeshLocation()

self.disable()

workbenchRef = self.placeAtMe(pCaDW_FO4_co_Tool_PortableWeaponsWorkbenchGround)

utility.wait(0.5)

self.delete()

endif

endEvent

 

Event OnExitFurniture(ObjectReference akActionRef)

if (akActionRef == game.getPlayer())

utility.wait(1.0)

workbenchRef.disable()

akActionRef.addItem(pCaDW_FO4_co_Tool_PortableWeaponsWorkbenchInventory)

utility.wait(0.2)

workbenchRef.delete()

endIf

EndEvent

Edited by shavkacagarikia
Link to comment
Share on other sites

Ok. It seems I was too tired yesterday and needed some sleep. The OnExitFurniture won't fire because of 1) the script is attached on misc item and you never exit that misc item, you exit furniture. 2) OnExitFurniture event doesn't fire for workbenches. So to make your script work we will need to register for remote event of game.getplayer() actor, which is OnGetUp. It will fire when player exits our workbench. Like this:

Scriptname CaDW_Drop_WW extends ObjectReference

Furniture property pCaDW_FO4_co_Tool_PortableWeaponsWorkbenchGround auto const

ObjectReference workbenchRef

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	if (!akNewContainer && akOldContainer == game.getPlayer())
		self.disable()
		workbenchRef = self.placeAtMe(pCaDW_FO4_co_Tool_PortableWeaponsWorkbenchGround)
		workbenchRef.MoveToNearestNavmeshLocation()
		workbenchRef.SetAngle(0.0, 0.0, workbenchRef.getAngleZ())
		RegisterForRemoteEvent(game.getplayer(), "OnGetUp")
		utility.wait(0.5)
		self.delete()
	endif
endEvent

Event Actor.OnGetUp(Actor sender, ObjectReference akFurniture)
	if (sender == game.getplayer() && akFurniture == workbenchRef)
		utility.wait(1.0)
		workbenchRef.disable()
		game.getplayer().addItem(self)
		utility.wait(0.2)
		workbenchRef.delete()
                UnregisterForRemoteEvent(game.getplayer(), "OnGetUp")
	endif
endEvent

But I (as user) prefer player to be able to disable wokbench when he needs that, not when he exits it. If you think same I can suggest you how to add another button next to activation button which will remove worbench.

Edited by shavkacagarikia
Link to comment
Share on other sites

An extra button would be great I think shavkacgarikia but there is something else i need the script to do.

 

I just had a brain wave of how it could be used in my mod. Just one more thing for perfection.

 

Is it possible to move items using a form list into a container I can place in qasmoke when the workbench is activated and then when the workbench is deactivated return the contents of the container to the player?

 

I have set up a form list called: CaDW_RPWW_ItemFilter

and a container called: CaDW_RPWW_Container

Link to comment
Share on other sites

You can use it to limit what you use the workbench for. In my case i can restrict it to only allow mods to be swapped or with my mod Craft and Dismantle Weapons to not allow mod crafting so it can only be used in the feild to salvage weapon mods.

Link to comment
Share on other sites

Then you basically need to remove all junk items from player. Yes it is possible to remove needed components using formlist with RemoveItem and passing formlist there.

Scriptname CaDW_Drop_WW extends ObjectReference

Furniture property pCaDW_FO4_co_Tool_PortableWeaponsWorkbenchGround auto const

ObjectReference workbenchRef
Container MyContainer
FormList MyFormList

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	if (!akNewContainer && akOldContainer == game.getPlayer())
		self.disable()
		workbenchRef = self.placeAtMe(pCaDW_FO4_co_Tool_PortableWeaponsWorkbenchGround)
		workbenchRef.MoveToNearestNavmeshLocation()
		workbenchRef.SetAngle(0.0, 0.0, workbenchRef.getAngleZ())
		RegisterForRemoteEvent(game.getplayer(), "OnGetUp")
		RegisterForRemoteEvent(workbenchRef, "OnActivate")
		utility.wait(0.5)
		self.delete()
	endif
endEvent

Event ObjectReference.OnActivate(ObjectReference akSender, ObjectReference akActionRef)
  	if (akSender == workbenchRef && akActionRef == game.getplayer())
  		Game.GetPlayer().RemoveItem(MyFormlist, -1, true, MyContainer)
                UnregisterForRemoteEvent(workbenchRef, "OnActivate")
  	endif

EndEvent

Event Actor.OnGetUp(Actor sender, ObjectReference akFurniture)
	if (sender == game.getplayer() && akFurniture == workbenchRef)
		utility.wait(1.0)
		workbenchRef.disable()
		game.getplayer().addItem(self)
		MyContainer.RemoveItem(MyFormlist, -1, true, game.getplayer())
		utility.wait(0.2)
		workbenchRef.delete()
                UnregisterForRemoteEvent(game.getplayer(), "OnGetUp")
	endif
endEvent

You will need to fill Formlist and Container properties with the needed ones.

Link to comment
Share on other sites

Hiya,

 

got a compile error:

 

Compiling "CaDW_Drop_WW.psc"...
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\CaDW_Drop_WW.psc(24,54): type mismatch on parameter 4 - cannot pass a container to a objectreference
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\CaDW_Drop_WW.psc(35,14): RemoveItem is not a function or does not exist
No output generated for CaDW_Drop_WW.psc, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on CaDW_Drop_WW.psc
Was I meant to paste something into the script or just select the container and list when i add a script to an object in CK?
Link to comment
Share on other sites

  • Recently Browsing   0 members

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