Difference between revisions of "Removing "Placeatme Objects""
imported>JOG (No tutorial, and I doubt everything works.) |
imported>Elder m |
||
Line 1: | Line 1: | ||
REMOVABLE PlaceAtMe OBJECTS by | REMOVABLE PlaceAtMe OBJECTS by Guidobot | ||
This is to | 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. | 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. | ||
Line 9: | Line 9: | ||
Example #1 | Example #1 | ||
; creation | ; creation | ||
Line 19: | Line 16: | ||
placerRef.Activate player | placerRef.Activate player | ||
placerRef.RemoveMe | placerRef.RemoveMe | ||
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. | 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. | ||
Line 26: | Line 22: | ||
For example 2 the effect is split between the creator and target object. | For example 2 the effect is split between the creator and target object. | ||
scn MyPlacerScript | scn MyPlacerScript | ||
Line 39: | Line 32: | ||
End | End | ||
To use/destroy the object: | To use/destroy the object: | ||
; creation | ; creation | ||
Line 52: | Line 40: | ||
; destruction | ; destruction | ||
placerRef.Activate player | placerRef.Activate player | ||
You can also get more imaginative but you may have some extra timing issues. | You can also get more imaginative but you may have some extra timing issues. | ||
Example 3 requires a bit more work on the placer object: | Example 3 requires a bit more work on the placer object: | ||
short stage | short stage | ||
Line 75: | Line 59: | ||
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 use/destroy these objects: | ||
; creation | ; creation | ||
Line 87: | Line 67: | ||
; 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. | |||
Destroying Summoned Creatures | |||
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. | |||
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) 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]] | [[category: Useful_Code]] |
Revision as of 17:27, 11 September 2006
REMOVABLE PlaceAtMe OBJECTS by Guidobot
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.
Example #1
; creation set placerRef to player.PlaceAtMe MyPlacer 1 50 0 ; ... ; destruction placerRef.Activate player placerRef.RemoveMe
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.
In the following examples the same effect will work for scripted objects.
For example 2 the effect is 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 requires a bit more work on the placer object:
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 use/destroy these objects:
; creation set placerRef to player.PlaceAtMe 1 50 0 ; ... ; destruction 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.
Destroying Summoned Creatures
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.
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) 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)