Important Site Docs
Articles
Placeatme Tutorial for Oblivion
- Details
- Category: The Elder Scrolls 4: Oblivion Modding Guides
- Last Updated on Monday, 12 September 2011 21:45
- Written by Giskard
- Hits: 1473
Placeatme Tutorial for Oblivion
Introduction
The basic usage of the placeatme command is explained the in the Oblivion construction wiki which can be read HERE but I will quickly cover the basics again in this tutorial.
The Placeatme command is a very dangerous command to use unless you know what you are doing. It allows you to place thousands, millions or billions of items in to a game and depending on the game settings, the game will not track them but will remember them because they where scripted in to the game. Slowly as you place more and more items, you bloat the players saved game, eventually corrupting it and breaking it. So to stop that from happening you have to track everything you place and that makes using the placeatme command a lot more difficult that it first appeared. Despite what the Construction Wiki claims, OBSE is not needed for this, just a little scripting. You will find whilst OBSE is a cool program, most of its functions can be achieved with the basic Construction kit and basic script commands. They are just longer scripts thats all. There are some things OBSE does that the standard CS does not do of course.
In this tutorial I will be assuming your using Creatures or NPCs since it is unwise to use the placeatme command on anything else.
General rules of usage.
If you want to place an item, such as a sword or potion, your better off using the additem or removeitem command, its much safer. If you want to place large static objects using this command DONT! Those things do not expire, they will slowly fill up the game unless your clever and control how many are placed and cap it at a specific amount so once that is reached, no more are placed after that. Placeatme items have no names you can refer to them with, you cannot check for them later or track them. Not reliably anyway.
We will be exploring how to do it safely for NPCs and Creatures in this tutorial.
The system explained below is used by the Kvatch Rising Dark Brotherhood quests, it is an adaptation of a system I have used previously in Fighters Guild Contracts and The Elder Council mods. So if you need some working examples. Check out Kvatch Rising... NOT the other 2, they are older and use a different more long winded system.
All of which use this command safely and have done for over 2 years now.
Basic usage
Here is the command and it's requirements, taken from the wiki.
PlaceAtMe ItemID, count, [distance], [direction]
Here is an example of its usage
player.PlaceAtMe Ninja, 1, 256, 1
And here are the directions
0 = front
1 = back
2 = left
3 = right
Now we leave the wiki, which is still worth reading to get the other hints and tips it provides but lacks the detail I am about to provide.
Which is why I am writing this tutorial.
Setting things up.
Using placeatme safely is not as simple as you may think, you need a quest to control what you place and a script to do the work for you. So lets start there.
Go to the Oblivion Construction Set and load up your mod or make a new one, then go to the character menu and select Quests. When it opens, right click in the quest list and select new, give your quest a name, for this tutorial I will call it "myquest" and then go to the script box which currently says none.
Here is a trick Iuse to create new quest scripts quickly without having to remember the exact layout or requirements, helps when your a noob working on scripts and it becomes an habbit when your not :D
Click on the 3 dots next to the script box, a script window will appear, click on the red arrow pointing right to get the AbandonedMineTrap02Script up. Click in the window with the script displayed, press control A to highlight all of the script, press control C to copy it (CTRL A and CTRL C) and then close the window without changing anything. Say no to saving it if asked. Now go and click on those 3 dots again, go to the script menu in the window that appears and select new, then press control v (CTRL V) to paste the AbandonedMineTrap02Script script in to your new script window.
NOTE: you cannot just rename the abandonedmine script because it really renames it, eg removes the original. Oppps...
Then edit it from this.
scriptName AbandonedMineTrap02Script
short triggered
begin gameMode
if ( getDistance player < 160 ) && ( triggered == 0 )
playgroup forward 1
AbandonedMineTrap03REF.playgroup unequip 1
set triggered to 1
endif
end
to this
scriptName myquestScript
begin gameMode
end
Notice I changed the script name to myquestscript, that must be done. You must always change the script name. This becomes the filename when saved (not look for the file, it does not exist, its part of your mods esp).
Now set the Script Type to Quest and save your script.
Close the script window if it is still open, close the quest window and then reopen the quest window by going to the Character menu and selecting quest, then find Myquest again and open it. Tick Start Game Enabled, give it a priority of 20. Now go to the script box, click on the downward arrow and find your myquestscript and select it. At this point its best to close the quest window and save your mod. Then reopen the quest mod window and go to your myquest and open that script again. It just makes sure its all saved off correction and the CS has updated it self.
When you write a script try and find it but its not there, thats why, you need to close the quest window to trigger an update to the available scripts.
Creating a monster
Make your NPC or Creature normally and call it mymonster. If you want to call it something else, just change mymonster to what ever you want it to be and replace mymonster with your own name when ever you see it in this tutorial.
Now we make the following changes too it.
Make sure "No Low Level Processing" in the creature of npc window is NOT TICKED.
That is one of the causes of the save game bloating, anything with that ticked disappears when you leave the cell but placeatme is a script command and scripted items are persistance and are remembered by your saved game. That means anything placed with placeatme is also remembered by your save game even after it disappears from your game. I believe they solved this problem in Fallout 3 but never really confirmed it. Normal spawns remember the spawn points and reload them when you enter a cell after 3 days, they are not scripted so are not remembered by your saved game and thus do not have this problem.
But placeatme stuff just vanishes, yet remains part of your game save. So when using placeatme, "No Low Level Processing" is BAD, very BAD! We want these things to be remembered so you can kill them and remove them from the game that way. Death is a method of cleaning up your placed creatures or NPCs you see.
I could be wrong but I think its a simple persistant object issue hardcoded in the game basically. Which means using custom creatures or NPCs may remove the bloating from your save if a mod is disabled later. Thats how these things usually work. So theres a tip for you, stick to custom NPCs and Creatures for this command and you may give your selve a way to clean up any mess you cause by disabling the mod later and resaving your game.
Next we need to create a script for our NPC or Creature
Click on the 3 dots next to your NPC or Creatures script box and cut and past this script in to it. We cannot put in the actual code that works the magic yet because the var needed has not been declared or created in the quest and it would give an error when saving if we added it early. This is an chicken and the egg situation. Both our quest script and our npc script both need the other. So we just create the shell now and then go and create the chicken later.
Here is the script you need to add to your NPC or Creature, you can change the name of the script if you wish, it does not matter. Just remember what you called it.
ScriptName myquestbodycounterScript
Begin OnDeath
End
Set it to Script Type Object.
If the script is not assigned to your NPC or creature right away, close your NPC or creatures window, reopen it and find your script. It should be called myquestbodycounterScript. Save your mod after you have done this.
Editing the Quest Script
Now we make some changes to the above script and add the NPC or creature name as well as the code to control it to our quest. This script will only allow 1 NPC or creature to spawn this way and it will constantly spawn that creature or NPC at the players position. Leading to endless attacks on the player if that creature is an unfriendly creature or npc. If you want to make it spawn at a marker, replace the "player" with the name of your marker and it will ensure the creature or NPC is always at that location. Respawning it the moment it dies with a new one. Might take 5 seconds for the scripts to run and spawn the new copy of the creature of NPC.
Add any AI packages you want and that creature or NPC will use them like any other creature or NPC.
Here is the new script.
scriptName myquestScript
; this is the var that does the work for us
short bodycount
begin gameMode
; Here we check of the monster is dead but checking the bodycount var which is updated by the creature or npcs death script
if (bodycount == 2)
set bodycount to 0
endif
; this is where we add 1 monster if none exist or all are dead
if (bodycount == 0)
player.PlaceAtMe mymonster, 1, 256, 1
set bodycount to 1
endif
end
We have have done is place mymonster at the player if the bodycount is 0, and stop it placing more if bodycount is greater than 0. Which is it because we set it to 1 when we placed our monster.
If you do want to make that monster spawn at a marker instead of a player, place a marker, give it a new name, lets call it mymarker or something and then replace the line below
player.PlaceAtMe mymonster, 1, 256, 1
With this
mymarker.PlaceAtMe mymonster, 1, 256, 1
in the above script. Change mymarker to what ever you called your marker of course.
You can create hot zones of activity using this method, imaging a constantly spawning set of skeletons in a dungeon that never empties. Yes folks this command may be dangerous if not used correctly but its lots of fun when used properly. There is 1 side effect, all these creatures you place are tracked by the game and do use up CPU time. So do not go too mad.
Editing the NPC or Creatures Ondeath Script.
Open your NPC or creatures window again and go to the script you attached to it, remember it is the one listed in the script box. Adding the new part to it which is "set myquest.bodycount to 2" between the Begin ondeath and the end commands.
ScriptName myquestbodycounterScript
Begin OnDeath
set myquest.bodycount to 2
end
Before I move on, notice how I have myquests.bodycount in the script.
Some word of explanation is required. I am sure you can guess what a Global var is, it is one all quests and scripts can access. Well that code above allows all quests to access a local var. By naming our quest and var in our quest script this way. We tell any other script to look for the script attached too myquest and find our var bodycount and use that. Which is a long winded way of saying, we have our own version of a Global var if we use myquest.bodycount instead of just bodycount in our commands.
To summarize.
This is as good as a global var and will work in other quests and scripts.
Set myquest.bodycount to 2
This is a local var, when writen like this, it will only work in the quest script that declared it with the short bodycount command.
Set bodycount to 2
You see, you learn something new every day :D
Extra Tips:
That's it, that's how you spawn 1 creature at a time, wait for it to die, then spawn another.
Spawning 5 Creatures at a time.
What if we want 5 creatures to spawn at a time ?
Well you need to change the scripts for that.
I am deliberately NOT going to use the Placeatme's Count option here which would allow me to add more creatures easily because I want you to see how to add multiple creatures of a different type. I'll be using the same mymonster creature but just imagine you made 5 different versions of it and used the same death script on them all. You see where I am going here ?
Lets edit the quest script first.
We need a new way to control the scripts flow, bodycount is now really the bodycount, so lets have a bodycountreset var to control it.
scriptName myquestScript
short bodycount
short bodycountreset
begin gameMode
; Here we check how many monsters have died and if the bodycount reset is still at zero.
; the bodycount number heré is 5, thats how many creatures we want to spawn and how many we want to died before they spawn again.
; This number should always match exactly the number below. So 5 up here, means the Placeatme command below needs a count of 5, or 5 lines placing 5 creatures.
if (bodycount == 5) && (bodycountreset == 0)
set bodycount to 0
set bodycountreset to 1
endif
; If the bodycount is 0 and bodycount reset is 1 then we need to place some monsters.
; you can change mymonster for other monsters here, 1 per line, or use the first number to set how many of each you need,
; eg player.PlaceAtMe mymonster, 5, 256, 1 would place 5 mymonsters by the player :D
; remember the number spawned here has to match the number in the bodycount var above, which is 5 in this case.
if (bodycount == 0) && (bodycountreset == 1)
player.PlaceAtMe mymonster, 1, 256, 1
player.PlaceAtMe mymonster, 1, 256, 1
player.PlaceAtMe mymonster, 1, 256, 1
player.PlaceAtMe mymonster, 1, 256, 1
player.PlaceAtMe mymonster, 1, 256, 1
set bodycountreset to 0
endif
end
Now the Creature or NPC script
ScriptName myquestbodycounterScript
Begin OnDeath
set myquest.bodycount to myquest.bodycount + 1
end
What we did here is we add 1 to the bodycount var every time a creature or var dies instead of setting it to 1, allowing it to count upwards until all are dead, eg all 5, making bodycount = 5 when completed. And we check when it reaches 5 and reset everybody so they all spawn again.
Other Ideas:
Suppose you created several NPCs and added that ondeath script to them all. Suppose they all had special packages of their own, unlike random spawns which may be used anywhere. If the spawn is a marker not the player, you will know exactly where these NPCs will appear and can customise their AI packages for that area. Making them sit, stand, fight, patrol, what ever you want. And when they die, instead of having to wait 3 days in a different cell for them to respawn, they would instantly be replaced by an exact copy of the original.
Final thoughts.
The idea of spawning creatures this way is a cool one, but you cannot go mad using this system. Even when you tightly control them on a basis of what goes in, has to die before another can be placed, there is still the CUP overhead to think about. Oblivion is not as optimized as Fallout 3, it cannot handle as many NPCs running around as Fallout 3 can. So becareful here.
Learn how to adjust the above scripts to control the number that spawn but remember, everything you place this way is saved when you save your game, so when testing mods using this idea, DO NOT SAVE YOUR GAME. Test this without saving and only start saving when you know it works because if you save and its broken, then your game save will remember the broken data. Changing the var names used can often allow you to continue but it cannot remove the previous attempts mistakes.
This whole tutorial is really an advanced topic and should not be handled by noobies, if you want to practice it, fine, but best stick to throw away saves and keep the mod you make private so not to harm anybody elses games until your better at this stuff.
Login Form
Forum and Website Logins
Please be aware that the forum and the main website are 2 completely different logins.
Skyrim Menu
Fallout New Vegas Menu
Fallout 3 Menu
Oblivion Menu
Game Guides
Misc Menu
Who is online
We have 186 guests and one member online
Members Online Today
Total Members Online Today: 14Atzros FatGiant nerdistmonk TheRealColumbus Yutzwagon giskard 42wolfe42 DOW Garathil Gryphon nikki191 oblivionmaster310 Portpower Vagn














