Jump to content

Scripting PlaceAtMe


Gribbleshnibit8

Recommended Posts

Ok, I'm trying to figure out the use of this function. The wiki says that you need to call a delete on it if you create it this way, however, what if the item is to be picked up and used? I would assume (from the explanation of the delete function) that a mark for delete would be unnecessary in this instance.

 

This is my use. I've made a Nuka Cola cooler that is actually an animated activator with a compartment (scaled down Protectron pod). I had it working with a simple MoveTo command (still coded there) that would move an already placed one from in the cell into the closed pod, and back out when it's done. But I'd like to make it make a new Iced Nuka Cola in the machine to be grabbed when it opens, which this should do. I really just want to confirm that indeed it does not need the markfordelete on the created item.

 

scn aaColNukaCoolerSCRIPT

short hasItems
short button
short NukaCooler	;lab0
short ProcessButton	
float NukaCoolerTime
ref placedObject


Begin onActivate

if IsActionRef player == 1
	if player.getItemCount NukaCola > 0
		if NukaCooler == 0
			set ProcessButton to 1
			ShowMessage aaColNukaCoolerMsg
		elseif NukaCooler == 1
			ShowMessage aaColNukaCoolerMsg01
		elseIf NukaCooler == 2
			set NukaCooler to 0
			ShowMessage aaColNukaCoolerMsg02
			Player.AddItem MS05IceNukaCola 1
			NukaRef.moveTo aaColNukaCoolerRef 50.0 1.0 1.0
			setOpenState 1
		endif
	endif
endif
end


Begin GameMode

Set Button to GetButtonPressed
if Button > -1
	if ProcessButton == 1
		if Button == 0
			Player.RemoveItem NukaCola 1
			setOpenState 0
			set NukaCooler to 1
			set NukaCoolerTime to GetCurrentTime
			set placedObject to aaColNukaCoolerRef.placeAtMe MS05IceNukaCola 1
			placedObject.setPos x -0.923
			placedObject.setPos y -0.959
			placedObject.setPos z -3.7073
		;NukaRef.moveTo aaColNukaCoolerRef -0.923 -0.959 -3.7073
		elseif button == 2
		endif
	endif
	set ProcessButton to 0
endif

if NukaCooler == 1
	if GetCurrentTime - NukaCoolerTime >= .30
		set NukaCooler to 2
	endif
endif

end

 

 

Also, is it possible to make code modular, in that I can include references to items from another mod, even if that mod isn't currently installed? Would this code work in game without blowing up? Specifically to allow this to make ice cold versions of other nuka cola or other drinks from other mods.

Link to comment
Share on other sites

You don't have to worry about disabling and marking for deletion with the nuka colas that you spawn with PlaceAtMe. That is really intended for creatures you spawn to save on save game bloat. If your code is continually spawning nuka colas all over the place, you could see how this might adversely affect the game. But in your case, its not a problem. A couple of extra nuka cola in the cell isn't going to blow up the save game data or the game. I have found in practice, spawning a few creatures with placeatme doesn't harm the game either. Its considered poor form, but won't blow up the game. A trigger that spawns creatures, however, can create enough to cause a problem if the trigger is triggered often enough.

 

As for referencing items from other mods. As long as the items or objects are persistent, have an Editor Reference ID AND are loaded, its totally fine. The problem with referencing objects from other mods is that they may not be there if the mod isn't loaded and that can cause CTDs. That's why its best not to do this. What you would end up doing is making your mod be a child of the other mod - meaning your mod would have multiple parents besides the normal Fallout3.esm. This would make it such that you would not be able to load your mod in the GECK without the other mod loading as well. But that doesn't stop the other mod from being removed from the game. If this occurs, errors or CTDs will occur. Its better to just copy the resources you want to use into your mod.

Link to comment
Share on other sites

A couple of extra nuka cola in the cell isn't going to blow up the save game data or the game.

 

Well, after looking at the wiki descriptions, from what I understand about it, when the item is picked up by the PC it is basically removed from the cell. And when you drop it again a new instance of the object is created, which is then covered by the built in deletion. Correct me if I'm wrong on that though.

 

Its better to just copy the resources you want to use into your mod.

 

Alright, guess that won't work. Be kind of stupid to have one file dependent upon about 12 other masters just to be able to sort stuff better. Wish there was a mod detection method or something to use. Oh well, hindsight being 20/20 and all.

Link to comment
Share on other sites

You can use PlaceAtMe for explosions also, which should include MarkForDelete. Pretty obvious why you don't need them to be saved.

 

It seems that Cipscis is well versed in how PlaceAtMe should be handled, and is also an excellent scripter. His tutorials might mention it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...