Spawning objects like "placeatme" with Papyrus

Post » Wed Jun 20, 2012 5:17 am

Hello everyone, I have been wondering something for a few days.
I am trying to make a mod with the creation kit that can allow you to set up fire camps by "equipping" firewood. (Actually I am french but I guess this object is called Firewood in the english game as I noticed it in the creation kit. But that's not really important though.)
The thing is that I can't figure out how to spawn a new object dynamically in the game ! I mean, I need to have the firecamp already set in the game somewhere, and then place it at the player when he equips the Firewood, but that doesn't allow me to set several firecamps as I need to have all of them already preset in the game. If the player wants to set 10 fires, it will move the same fire over and over so that there is only one firecamp at a time... I could preset 10 of them but you see there is a problem because the player could want to set 11 of them... That's why dynamical allocation is made in programming, when we don't already know wat the user's going to do. But it doesn't seem to be a Papyrus feature, for all I know.
But maybe I'm wrong, and that's why I am asking you.

Is there a way to spawn an object with a function like :
"FireCampRef = createObject(Campfire01Burning)
FireCampRef.placeAt(Player.GetRef())" ?

I wonder how it could be impossible as you can spawn whatever you want with the console command "placeatme". I know it's not really spawning, it's a duplication of an already existing object. But that would be fine as well ! I would need only one firecamp that I could duplicate as the player wants a new one. Maybe we could access console commands from Papyrus ? I don't know.

And maybe I try do to it the wrong way, so maybe you could tell me how you would do the following feature :
As a simple example, how would you make a stone that spawns bread on the floor everytime you activate it ? If I active the stone x times, there would be x pieces of bread on the floor.

Please help me, that's the only thing I need to know to do every mods I planned to make. :biggrin: Thanks a lot in advance ! Looking forward to reading your ideas !
User avatar
Naomi Ward
 
Posts: 3450
Joined: Fri Jul 14, 2006 8:37 pm

Post » Wed Jun 20, 2012 5:30 am

It's there already. http://www.creationkit.com/PlaceAtMe_-_ObjectReference

That takes a Form, and you can get the form of an objectref with http://www.creationkit.com/GetBaseObject_-_ObjectReference()
User avatar
^_^
 
Posts: 3394
Joined: Thu May 31, 2007 12:01 am

Post » Wed Jun 20, 2012 6:18 am

Lol, I don't know how I missed it in the documentation. ^^ I thought I already read all the ObjectReference Script section, which I obviously didn't...
In any case, thank you and sorry for the stupid question !

EDIT : By the way, is there any method that can transform an object into another, I mean like setting fire to the firecamp by replacing Campfire01Off by Campfire01Burning ?
User avatar
Josee Leach
 
Posts: 3371
Joined: Tue Dec 26, 2006 10:50 pm

Post » Wed Jun 20, 2012 12:25 am

yvw, and no worries, I think everyone here has a moment from time to time :)

There's a whole 'destruction data' scheme for objects, which sounds quite appropriate for a fire. I've never looked into it though.
The *destruction* commands might be just what you are looking for.
User avatar
Myles
 
Posts: 3341
Joined: Sun Oct 21, 2007 12:52 pm

Post » Wed Jun 20, 2012 7:26 am

Actually I can't had Destruction Data to Campfire01Off Oo I think that's because it's "static". And I can't associate any script on it at all...
And to be honest, I don't know what are destruction data made for ^^
User avatar
Lexy Dick
 
Posts: 3459
Joined: Mon Feb 12, 2007 12:15 pm

Post » Wed Jun 20, 2012 1:18 pm

Well you could use FindClosestRefOfType to a variable you can call "OldFire" on the "off" fire type, create a burning one with NewFire = OldFire.PlaceAtMe(BurningFireType,1), set your NewFire's rotation to match the existing one's with NewFire.MoveTo(OldFire), and finally use OldFire.Disable() to turn off the "unburning" one. You could then turn the fire off and on by alternating Enable() and Disable() on whichever one you want on at any particular time.
User avatar
sarah taylor
 
Posts: 3490
Joined: Thu Nov 16, 2006 3:36 pm

Post » Wed Jun 20, 2012 1:22 am

Thank you Redwood Elf, actually I already did this, but maybe there would be a better solution, so I asked anyway. :P
Now I would like to finish this clearly.

Is there anything I can do to activate an object which is not an activator ? I would like to "activate" my fire to make it burn, so that the player has to set it on fire (In exchange of some firewood). Do I have to create an Activator out of the MiscItem ? If so, what is the best way to do it ? I found also that "placeatme" doesn't take the ground inclination in account so that the fire is straight when put on a grade, and it's not very good looking. ^^ (Don't know if that sentence means anything, tell me if it doesn't.) It's not very important indeed, but if I can fix it in a simple way that would be great. :)

My mod is actually not only about campfires, but if I can do this I'll be able do deal with the other things easily. ^^
User avatar
nath
 
Posts: 3463
Joined: Mon Jan 22, 2007 5:34 am

Post » Wed Jun 20, 2012 4:09 am

The MoveTo should make it match the rotation of the original object...as for making it match the terrain underneath, rots o ruck with that, since nobody here appears to have any idea how to rotate an object on it's local axes instead of the sequential Z>Y>X rotations the game engine uses. You could drop two objects...one like a shield that will havok settle to an orientation matching the terrain, and then have the fire match that object's orientation. The problem with that is, you have a 50% chance that when the object settles, it will be upside down..heh.
User avatar
Victor Oropeza
 
Posts: 3362
Joined: Sun Aug 12, 2007 4:23 pm

Post » Wed Jun 20, 2012 9:52 am

Alright it seems complicated and/or unefficient so I will let it as it is ^^ Thank you anyway !
User avatar
Dona BlackHeart
 
Posts: 3405
Joined: Fri Dec 22, 2006 4:05 pm


Return to V - Skyrim