Difference between revisions of "PlaceAtMe"

1,911 bytes added ,  02:22, 28 December 2010
m
→‎Warning: Repeated Use Causes Save-Game Bloat: Replaced external link with equivalent internal link.
imported>Gamall
m (spelling)
imported>JdeRau
m (→‎Warning: Repeated Use Causes Save-Game Bloat: Replaced external link with equivalent internal link.)
 
(17 intermediate revisions by 10 users not shown)
Line 2: Line 2:
  PlaceAtMe ''ItemID, count, [distance], [direction]''  
  PlaceAtMe ''ItemID, count, [distance], [direction]''  
'''Example:'''
'''Example:'''
  player.PlaceAtMe Ninja Man, 1, 256, 1  
  player.PlaceAtMe Ninja, 1, 256, 1  


 
Places the object at the calling object, in the direction you specify and the distance. If that location is not safe (in the air, in a wall, etc), the object will be placed at one of the other axes or at the calling object's exact location.  
Places the object at the calling object, in the direction you specify and the distance. If that location is not safe (in the air, in a wall, etc), the object will be placed at one of the other axes or at the object's exact location.  


Direction is:  
Direction is:  
Line 12: Line 11:
:2 = left  
:2 = left  
:3 = right  
:3 = right  
The placed object gets the same XYZ angle values as the calling object. Note that world objects placed at the player will be tilted if the player is looking up or down (player X angle not zero ... object X angle not zero).


This function can be used with leveled ''creature'' lists as well.   
This function can be used with leveled ''creature'' lists as well.   
Line 17: Line 18:
It can't be used with leveled ''items'', though. Leveled items are not supposed to be placed into the world - you can use them exclusively inside containers. Trying to create an item from a leveled list this way will just cause the yellow exclamation mark (Marker_Error.NIF) to appear.
It can't be used with leveled ''items'', though. Leveled items are not supposed to be placed into the world - you can use them exclusively inside containers. Trying to create an item from a leveled list this way will just cause the yellow exclamation mark (Marker_Error.NIF) to appear.


==Warning : Disable is not Destroy !==
==Warning: Repeated Use Causes Save-Game Bloat==
 
Objects created with '''PlaceAtMe''' are not automatically deleted by the game. (Calling the Disable function only hides the object, but does not delete it.) As a result, they become part of the savegame file and increase its size.
 
Use the [[DeleteReference]] function to delete non-actor objects created with PlaceAtMe. This requires running the CS with [[Oblivion Script Extender]] version 18 or later.
 
To delete an actor, you can [[MoveTo|move them to]] an interior cell the player is not in, [[kill]] them and [[ResetInterior|reset]] the cell. When the player next enters the cell, all dead actors in the cell are deleted. Note this requires the player to actually enter the cell before actors in it will be deleted, which can restrict usefulness. [[Talk:Common_Mistakes|recent tests]] seem to show that living actors are removed as well.
 
Objects frequently created with '''PlaceAtMe''' and never deleted can result in huge savegame files. Once the savegame file is around 10 megs problems start to arise, including extended load times, game instability and crashes, and at extreme levels, considerable performance loss and an inability to load the game.


Note that is is really unclear at the moment whether or not disabled PlaceAtMe'd objects are ultimately cleaned out of the savegames. Tests seem to show they are not, which can be a serious problem with spells that create lots of activators, for instance, and then disable them.  
As a rule of thumb, it's OK to use '''PlaceAtMe''' a finite number of times (i.e., a quest script that runs once and creates 20 '''PlaceAtMe''' objects). It's not OK if your script can potentially use '''PlaceAtMe''' an infinite number of times (i.e., a Summon spell that creates a new creature with '''PlaceAtMe''', an activator/button that creates a new sword).


So it seems only advisable to recommend the use of [[MoveTo]] on persistant references, whenever possible, instead of the couple [[PlaceAtMe]] / [[Disable]].
When possible, use different functions to avoid these problems. For instance, for summonings you can create a persistent creature, place it in a remote cell in the CS, and when the spell is cast use '''''CreatureRef.[[MoveTo]] player''''' (note that there's more to summoning, but that avoids the '''PlaceAtMe''' problems). If you need an object to appear, create and place it in the CS, make sure it's "Persistent" and "Initially Disabled", and use '''''ObjectRef.[[Enable]]'''''.


Most of the time, MoveTo will prove at least as convenient as PlaceAtMe. However, if really ''need'' to use PlaceAtMe in your mod, it would be fair to indicate that fact in your mod's Readme file.
If you really ''need'' to use PlaceAtMe in your mod, it would be fair to indicate that fact in your mod's Readme file.


==Getting the Created Object's Reference==
==Getting the Created Object's Reference==
Line 39: Line 48:
The refName variable will now have a reference to ObjectToBeCreated.
The refName variable will now have a reference to ObjectToBeCreated.


This reference is only reliable for objects that can't be picked up. Accessing the reference of an inventory-item after someone picked it up can cause a CTD.
This reference is only reliable for objects that can't be picked up (when they're picked up the reference is destroyed). Accessing the reference of an inventory-item after someone picked it up can cause a CTD.
 
==Console Use==
When using PlaceAtMe with the console, you must use the desired item's [[FormID]], not the EditorID.


So, instead of using
Note that [[GetSelf]] won't return the correct reference when used on '''PlaceAtMe''' objects.
player.PlaceAtMe lockpick 1, 256, 0
to give yourself a lockpick, you must use
player.PlaceAtMe 00000A 1, 256, 0


The [[FormID]] can be found on the tab just to the right of the EditorID tab in the Construction Set. This is true for all items and actors, although the FormID tab may need to be enlarged.
==Usage in same frame as creation==
If you use the referenced item in the same frame as you use PlaceAtMe, that is
<pre>set pItem to (player.PlaceAtMe IronBow 1, 0, 0)
pItem.Activate player ;this adds the bow to the player</pre>
that item's script may not run. Wait a frame, especially if using Activate.


[[Category: Functions]]
[[Category: Functions]]
[[Category:Functions (CS)]]
[[Category: Functions (CS 1.0)]]
[[Category: Miscellaneous Functions]]
[[Category: Miscellaneous Functions]]
[[Category: Miscellaneous Functions (CS 1.0)]]
<!-- Begin Search Terms
Place
At
Me
End Search Terms -->
Anonymous user