Difference between revisions of "Removing "Placeatme Objects""

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Elder
m
imported>QQuix
(Byline removed)
 
(18 intermediate revisions by 7 users not shown)
Line 1: Line 1:
REMOVABLE PlaceAtMe OBJECTS by Guidobot
{{Deprecated Article}}
{{Update}}
{{Errors}}


----
Note: This is much easier to do with OBSE's [[DeleteReference]]
----


This is to overcome the issues removing items placed in the game in 3D.
The Disable method removes these objects while the player is not in the same Cell but they are saved (and reloaded) when the player moves back, even though you wouldn't know.


In this first example it is assumed that you placer object is just that, i.e. just there to be used as a marker for targetting or such.
This describes how to remove objects created by the PlaceAtMe command, given that the Disable method is now known to only hide objects in their 3D state. (It does not seem to hide them if they are in your inventory.)
 
 
In the first example it is assumed that your placer item is an inventory item put down, for whatever reason, and then later deleted (after one frame).




Example #1: effect in external script (not on PlaceAtMe object)
Example #1: effect in external script (not on PlaceAtMe object)


scn MyScript
ref placerRef
Begin GameMode ; or other
; destruction - after in inventory
if placerRef
  if GetContainer == player
    placerRef.RemoveMe
  endif
  Return
endif
  ; creation
  ; creation
  set placerRef to player.PlaceAtMe MyPlacer 1 50 0
  set placerRef to player.PlaceAtMe MyPlacer 1 50 0
  ; ...
  ; destruction
  ; ... more code here
  ; destruction - put into player inventory
  placerRef.Activate player
  placerRef.Activate player
  placerRef.RemoveMe        ; safe only for un-scripted items
   
End


If you do Activate followed directly by RemoveMe it will work but any attached script will not be transferred. As stated on the CS Wiki you should ensure a frame click happens. In fact this is not appear to be actually necessary - you can achieve the same effect by having another script do the RemoveMe for you - it's just that the current script has to return.
Note: If you supply a container/actor argument to [b]RemoveMe[/b] it may work but any attached script will be lost. It seems some operations take a frame or two to work, especially those that attach one object to another. (Removing a script from an object could be useful.)


In the following examples the same effect will work for scripted objects.




Line 62: Line 83:
  End
  End


Something like this may be useful for those that already have lots of PlaceAtMe objects. Since to use/destroy these objects:
Something like this may be useful for those that already have lots of PlaceAtMe objects since to (create and) destroy these objects:


  ; creation
  ; creation
  set placerRef to player.PlaceAtMe 1 50 0
  set placerRef to player.PlaceAtMe MyPlacer 1 50 0
  ; ...
  ; ...
  ; destruction
  ; destruction
  placerRef.Disable
  placerRef.Disable


With all these examples you are well advised to experiment to se what works for you. It's possible that longer scripts may need some extra work, especially if you are using stackable items.
With all these examples you are well advised to experiment to see what works for you. It's possible that longer scripts may need some extra work, especially if you are using stackable items.
 
 
Ok, what I forgot to mention is the message spam you get when you get when the player picks this item up. To avoid this you can use a ''shadow'' (disabled persistant actor at player location) to pick up the item instead of the player.
 
 
Destroying Static PlaceAtMe Objects
 
 
Almost any object can be added to the game at run time using PlaceAtMe but, unfortunately, most of the interesting stuff, e.g. plants, traps, doors, lights, etc., are static objects. This means that you can't just pick them up to destory them, as like the items mentioned above. You can disable them but then they will be in your (save) game forever. However, you can overcome this by a little extra work after unpacking the BSA and creating your own items that look like these objects.
 
First you have to unpack the object you want to place, e.g. a fountain, from the BSA archive. (There are several options for this described ''here'' on the Wiki.) Then all you have to do is take any inventory item, e.g. an hourglass, copy it to make a new base object and then replace it's model with the one you unpacked.
 
Interestingly, your new item will aquire the activation properties of the item but the default characteristics of the model. In the example here, you will see a fountain that you can pick up and then see in your inventory as an hourglass, which can then be dropped again as a fountain! In some cases you will ''also'' get the model animations and properties. For example, you can create Harrada plant seeds that you can drop out of your inventory. However, more usually you just want to be able to activate the static object to pick it up so that its script can do a '''RemoveMe''' to destroy itself.




Line 76: Line 110:




If you employ PlaceAtMe to create a 'summoned' creature (object) then I'd affraid you'll have to accept that this object cannot be destroyed. If you want it to vanish (on death or after a time-out) you can only use Disable (and Kill) to make it disappear. The dead critter will be removed eventually like normal dead actors after ~3 game days.
If you employ PlaceAtMe to create a 'summoned' creature (object) then you'll have to accept that this object cannot be destroyed. If you want it to vanish (on death or after a time-out) you can only use Disable (and Kill) to make it disappear. The dead critter object will eventually be deleted like normal dead actors after ~3 game days.


Normally this isn't a problem. However, if you need to totally destroy the critters (e.g. because you use a pack of them) then the correct way to do this is not use the PlaceAtMe method at all. Instead you have two options:
Normally this isn't a problem. However, if you need to totally destroy the critters (e.g. because you use a pack of them) then the correct way to do this is not use the PlaceAtMe method at all. Instead you have two options:
Line 83: Line 117:


2) Otherwise:
2) Otherwise:
a) create single creature model that you wish to employ saved statically in a hidden (remote) room you created.
b) set critterRef to MyCritter.CreateFullActorCopy
c) critterRef.MoveTo player 50 50 0  (if necessary - may require next frame)
d) critterRef.DeleteFullActorCopy    (when done)


[[category: Useful_Code]]
a) copy/create the base actor model that you wish to employ and/or a persistant reference copy in a hidden room.
 
b) set critterRef to MyCritter.CreateFullActorCopy ; takes several frames
 
c) critterRef.MoveTo player 50 50 0  ; immediate but only logical position
 
d) critterRef.DeleteFullActorCopy    ; when done
 
 
Note: CreateFullActorCopy creatures ''do not'' inherit any script or AI packages attached to the the base model. You can add scripts using '''AddSpell <ability>''' or via '''AddItem <token> 1''' commands but be aware that CFAC creatures do not appear immediately and you cannot perform these command in the same frame as you created the copy.
 
You can now use the destroyref command from refstuff to delete stuff from game

Latest revision as of 06:29, 24 June 2012





Note: This is much easier to do with OBSE's DeleteReference



This describes how to remove objects created by the PlaceAtMe command, given that the Disable method is now known to only hide objects in their 3D state. (It does not seem to hide them if they are in your inventory.)


In the first example it is assumed that your placer item is an inventory item put down, for whatever reason, and then later deleted (after one frame).


Example #1: effect in external script (not on PlaceAtMe object)

scn MyScript

ref placerRef

Begin GameMode ; or other

; destruction - after in inventory
if placerRef
  if GetContainer == player
    placerRef.RemoveMe
  endif
  Return
endif
; creation
set placerRef to player.PlaceAtMe MyPlacer 1 50 0

; ... more code here

; destruction - put into player inventory
placerRef.Activate player

End

Note: If you supply a container/actor argument to [b]RemoveMe[/b] it may work but any attached script will be lost. It seems some operations take a frame or two to work, especially those that attach one object to another. (Removing a script from an object could be useful.)


Example #2: effect split between the creator and target object.

scn MyPlacerScript

Begin GameMode

if GetContainer
  RemoveMe
endif

End

To use/destroy the object:

; creation
set placerRef to player.PlaceAtMe MyPlacer 1 50 0
; ...
; destruction
placerRef.Activate player

You can also get more imaginative but you may have some extra timing issues.


Example #3: effect on a scripted item (triggered by Disable)

short stage

Begin GameMode

if GetDisabled
  if stage == 0
    Activate player
    set stage to 1
  else
    RemoveMe
  endif
endif

End

Something like this may be useful for those that already have lots of PlaceAtMe objects since to (create and) destroy these objects:

; creation
set placerRef to player.PlaceAtMe MyPlacer 1 50 0
; ...
; destruction
placerRef.Disable

With all these examples you are well advised to experiment to see what works for you. It's possible that longer scripts may need some extra work, especially if you are using stackable items.


Ok, what I forgot to mention is the message spam you get when you get when the player picks this item up. To avoid this you can use a shadow (disabled persistant actor at player location) to pick up the item instead of the player.


Destroying Static PlaceAtMe Objects


Almost any object can be added to the game at run time using PlaceAtMe but, unfortunately, most of the interesting stuff, e.g. plants, traps, doors, lights, etc., are static objects. This means that you can't just pick them up to destory them, as like the items mentioned above. You can disable them but then they will be in your (save) game forever. However, you can overcome this by a little extra work after unpacking the BSA and creating your own items that look like these objects.

First you have to unpack the object you want to place, e.g. a fountain, from the BSA archive. (There are several options for this described here on the Wiki.) Then all you have to do is take any inventory item, e.g. an hourglass, copy it to make a new base object and then replace it's model with the one you unpacked.

Interestingly, your new item will aquire the activation properties of the item but the default characteristics of the model. In the example here, you will see a fountain that you can pick up and then see in your inventory as an hourglass, which can then be dropped again as a fountain! In some cases you will also get the model animations and properties. For example, you can create Harrada plant seeds that you can drop out of your inventory. However, more usually you just want to be able to activate the static object to pick it up so that its script can do a RemoveMe to destroy itself.


Destroying Summoned Creatures


If you employ PlaceAtMe to create a 'summoned' creature (object) then you'll have to accept that this object cannot be destroyed. If you want it to vanish (on death or after a time-out) you can only use Disable (and Kill) to make it disappear. The dead critter object will eventually be deleted like normal dead actors after ~3 game days.

Normally this isn't a problem. However, if you need to totally destroy the critters (e.g. because you use a pack of them) then the correct way to do this is not use the PlaceAtMe method at all. Instead you have two options:

1) For a single creature (or small number of creatures) use a hidden location and teleport them to the player and back again as needed. (You may also have to manage their health, etc., if they end up in combat.)

2) Otherwise:

a) copy/create the base actor model that you wish to employ and/or a persistant reference copy in a hidden room.

b) set critterRef to MyCritter.CreateFullActorCopy ; takes several frames

c) critterRef.MoveTo player 50 50 0  ; immediate but only logical position

d) critterRef.DeleteFullActorCopy  ; when done


Note: CreateFullActorCopy creatures do not inherit any script or AI packages attached to the the base model. You can add scripts using AddSpell <ability> or via AddItem <token> 1 commands but be aware that CFAC creatures do not appear immediately and you cannot perform these command in the same frame as you created the copy.

You can now use the destroyref command from refstuff to delete stuff from game