Page 1 of 1

Spawn Items?

PostPosted: Fri May 27, 2011 8:31 pm
by Star Dunkels Macmillan
is it possible, by scripting, to spawn an item in a certain spot after conditions are met?

Spawn Items?

PostPosted: Fri May 27, 2011 6:56 pm
by vicki kitterman
For sure, the Enable/Disable commands are some the most basic scripting.

But they will be different depending on what condition needs to be met. Journal Indexes are common though, for quests.

quick example:
begin scriptif ( GetDisabled == 0 )	if ( GetJournalIndex "journal_name" < 5 )		Disable	endifelseif ( GetDisabled == 1 )	if ( GetJournalIndex "journal_name" >= 5 )		Enable	endifendifend


http://planetelderscrolls.gamespy.com/View.php?id=6083&view=Mods.Detail is a great guide to get yourself scripting.
Another way to figure out simple scripts like this, is just to see what Bethesda did, then emulate their scripts.

Spawn Items?

PostPosted: Sat May 28, 2011 6:05 am
by Damian Parsons
For sure, the Enable/Disable commands are some the most basic scripting.

But they will be different depending on what condition needs to be met. Journal Indexes are common though, for quests.

quick example:
begin scriptif ( GetDisabled == 0 )	if ( GetJournalIndex "journal_name" < 5 )		Disable	endifelseif ( GetDisabled == 1 )	if ( GetJournalIndex "journal_name" >= 5 )		Enable	endifendifend


http://planetelderscrolls.gamespy.com/View.php?id=6083&view=Mods.Detail is a great guide to get yourself scripting.
Another way to figure out simple scripts like this, is just to see what Bethesda did, then emulate their scripts.


but where exactly would this object enable to?

Spawn Items?

PostPosted: Sat May 28, 2011 8:36 am
by Tyler F
but where exactly would this object enable to?

The location where you place it. Disable will hide the object from any interaction, until it is Enabled.

Spawn Items?

PostPosted: Sat May 28, 2011 6:08 am
by Alisia Lisha
The location where you place it. Disable will hide the object from any interaction, until it is Enabled.


so, if I were to place an object in a cell with an enable script on it along with a disable script if conditions are not met, as soon as the conditions are met it will spawn?

Spawn Items?

PostPosted: Sat May 28, 2011 10:41 am
by Steeeph
Also, is it possible to spawn an item if an npc is in a certain place? I am creating a mod where an npc teleports around morrowind, and am trying to script it to where he teleports after you change cells, and where a note spawns near where he was.

Spawn Items?

PostPosted: Sat May 28, 2011 9:12 am
by JR Cash
Also, is it possible to spawn an item if an npc is in a certain place? I am creating a mod where an npc teleports around morrowind, and am trying to script it to where he teleports after you change cells, and where a note spawns near where he was.


I'm not sure I fully understand what you're trying to achieve. You can spawn an item to an NPC's location by:

1.) Spawning the item to the player's location:
PlaceAtPC, "some_item", 1, 0, 0


2.) Assigning a script to the spawned item that changes its position to that of your NPC:
Begin somescriptshort dooncefloat local_posif ( doonce == 0 )	set local_pos to ( "some_npc"->GetPos, X )	SetPos, X, local_pos	set local_pos to ( "some_npc"->GetPos, Y )	SetPos, Y, local_pos	set local_pos to ( "some_npc"->GetPos, Z )	SetPos, Z, local_pos	set doonce to 1endifEnd


As for checking what cell the player currently is in, you can use http://uesp.net/wiki/Tes3Mod:GetPCCell. Since you need the NPC to be in a loaded cell for its local script to run, it means that he's either in the same cell as the player, or in an adjacent exterior cell. If you need to determine his exterior cell exactly, you can use GetPos checks.

Spawn Items?

PostPosted: Fri May 27, 2011 9:00 pm
by Lady Shocka
What I mean is, I'm trying to get an item to spawn at the same time as the NPC teleports. I have a script on the NPC that teleports them when you change your cell, and I would like to spawn the item in the same spot that the npc was at before he teleports also when you change your cell. I write a script, but it keeps telling me I have a mismatched if statement.

begin Stranger_Second_Note

if ( CellChanged == 1 )
if ( GetJournalIndex "Quest_of_Ages_1" == 30 )
Enable

endif

if ( CellChanged == 0 )
if ( GetJournalIndex "Quest_of_Ages_1" <= 30 )
Disable

endif

end


Spawn Items?

PostPosted: Fri May 27, 2011 6:25 pm
by chloe hampson
Those if statements are mismatched because you need to have exactly as many endifs as ifs in any script. Also, it is bugged in a way because it would immediately disable the item in the next frame after enabling it, as the second journal check allows a value of 30 to pass. This is how it could look cleaned up:

Begin Stranger_Second_Noteif ( GetJournalIndex "Quest_of_Ages_1" < 30 )	if ( GetDisabled == 0 )		Disable	endifelseif ( CellChanged == 1 )	if ( GetDisabled == 1 )		Enable	endifendifEnd