Jump to content

Placing a copy of an object reference at an object in papyrus


DarkWolfModding

Recommended Posts

I need to know if there's a command somewhere in papyrus (I've looked on the creation kit website and cant seem to find it) where i have a object reference in lets say the AAAMarkers Cell and when i use a spell on an object it will place a copy of the object reference in the AAAMarkers at the location of the spell used. i know that translatetoref is not what im looking for as it just moves the object to the reference.

 

and how would I make the spell work on the object like a static item or such maybe with a keyword or something telling the spell that the object the spell is used on is from the mod and can be editable. Cant seem to figure those settings out. Would I use OnMagicEffectApply and put the script on the object or would I Use the normal OnEffectStart and onEffectFinish?

 

Why I need to know is I want to make an improvement to this mod in scripts Sky-Placer and what I want to do is have various objects like lets say a chest that's converted into a misc item (In ck) which cant be used and when the player drops it it gets placed at their feet and rotates among the z axis where the player is looking. then you use a spell on the object and it will place a copy of the useable chest ObjectReference (From AAAMarkers cell) at the exact location of the static one and then when the new chest is placed the temporary one is deleted.

 

When I was testing the scripts I used multiple boolean values and it was supposed to check if the boolean value was true and set the objects position according to the boolean values like

IsDoor

isStatic

IsContainer

isFurniture

 

but it didnt seem to work with the OnContainerChanged Event. :(

 

Please help!

Link to comment
Share on other sites

What you want to use to create a new instance of X object at Y location is PlaceAtMe. However, I've not attempted what you are wanting to do so I cannot give any advice as to where you should use that function in your scripts.

instead of using the form as it says in the placeatme syntax can it be an ObjectReference Instead?

Link to comment
Share on other sites

No. It clearly states that it will not place a copy of an object reference. If your object reference is different than its base (an added script or something), edit the base and make a new base record (change the ID name) then make the base identical to the object reference. Then you can use PlaceAtMe to place other instances of the base which will be identical to the stored object reference in your markers cell.

Link to comment
Share on other sites

No. It clearly states that it will not place a copy of an object reference. If your object reference is different than its base (an added script or something), edit the base and make a new base record (change the ID name) then make the base identical to the object reference. Then you can use PlaceAtMe to place other instances of the base which will be identical to the stored object reference in your markers cell.

Ive seen in some scripts a "As Form" function in them. Ill mess around with the scripts and see what I can come up with

Link to comment
Share on other sites

You could try that but the reference object still needs to be unmodified from the original. That means no added script, no added keywords, no linked refs, none of that stuff.

 

Let's say...

Scenario One

I have a static container at the player's feet.

I have a working container in a hidden cell. It is scripted to allow certain items. The base is stock so the reference only is scripted.

I cannot use PlaceAtMe to have another instance of the base with the desired script.

I would first need to make a new base that has the desired script attached. Then any additional instances placed with PlaceAtMe would have the desired script too.

 

Scenario Two

I have a static container at the player's feet.

I have a working container in a hidden cell. It is not scripted. Has no additional keywords, linked refs or anything like that.

I am free to use PlaceAtMe and have identical instances anywhere I want.

 

In both cases, the code could be something like

 

Form TheCont = RealContainerRef.GetBaseObject()
StaticContainer.PlaceAtMe(TheCont,1)

Or

StaticContainer.PlaceAtMe(RealContainerRef.GetBaseObject(),1)

 

 

Link to comment
Share on other sites

You could try that but the reference object still needs to be unmodified from the original. That means no added script, no added keywords, no linked refs, none of that stuff.

 

Let's say...

Scenario One

I have a static container at the player's feet.

I have a working container in a hidden cell. It is scripted to allow certain items. The base is stock so the reference only is scripted.

I cannot use PlaceAtMe to have another instance of the base with the desired script.

I would first need to make a new base that has the desired script attached. Then any additional instances placed with PlaceAtMe would have the desired script too.

 

Scenario Two

I have a static container at the player's feet.

I have a working container in a hidden cell. It is not scripted. Has no additional keywords, linked refs or anything like that.

I am free to use PlaceAtMe and have identical instances anywhere I want.

 

In both cases, the code could be something like

 

Form TheCont = RealContainerRef.GetBaseObject()
StaticContainer.PlaceAtMe(TheCont,1)

Or

StaticContainer.PlaceAtMe(RealContainerRef.GetBaseObject(),1)

 

 

so would this work

(I havent checked for syntax errors but there shouldn't be by the looks of it.

 

 

Scriptname ExampleScript Extends ObjectReference

import game

import debug

import form

import utility

 

ObjectReference Property UseableChest Auto

MagicEffect Property placeChestSpell Auto

Form UseableChestBase = UseableChest.getBaseObject()

 

 

Event OnEffectApply(ObjectReference akCaster, MagicEffect akEffect)

akCaster.PlaceAtMe(UseableChestBase, 1) ;Place Chest at reference chest

wait(3.0)

akCaster.Delete()

EndEvent

 

 

Edited by DarkWolfModding
Link to comment
Share on other sites

  • Recently Browsing   0 members

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