Spawn Items?

Post » Fri May 27, 2011 8:31 pm

is it possible, by scripting, to spawn an item in a certain spot after conditions are met?
User avatar
Star Dunkels Macmillan
 
Posts: 3421
Joined: Thu Aug 31, 2006 4:00 pm

Post » Fri May 27, 2011 6:56 pm

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.
User avatar
vicki kitterman
 
Posts: 3494
Joined: Mon Aug 07, 2006 11:58 am

Post » Sat May 28, 2011 6:05 am

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?
User avatar
Damian Parsons
 
Posts: 3375
Joined: Wed Nov 07, 2007 6:48 am

Post » Sat May 28, 2011 8:36 am

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.
User avatar
Tyler F
 
Posts: 3420
Joined: Mon Aug 27, 2007 8:07 pm

Post » Sat May 28, 2011 6:08 am

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?
User avatar
Alisia Lisha
 
Posts: 3480
Joined: Tue Dec 05, 2006 8:52 pm

Post » Sat May 28, 2011 10:41 am

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.
User avatar
Steeeph
 
Posts: 3443
Joined: Wed Apr 04, 2007 8:28 am

Post » Sat May 28, 2011 9:12 am

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.
User avatar
JR Cash
 
Posts: 3441
Joined: Tue Oct 02, 2007 12:59 pm

Post » Fri May 27, 2011 9:00 pm

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

User avatar
Lady Shocka
 
Posts: 3452
Joined: Mon Aug 21, 2006 10:59 pm

Post » Fri May 27, 2011 6:25 pm

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

User avatar
chloe hampson
 
Posts: 3493
Joined: Sun Jun 25, 2006 12:15 pm


Return to III - Morrowind