Questions concerning scripting

Post » Fri May 27, 2011 3:22 am

1 - I have made a custom NPC aligned with the Imperial Legion ranking at spearman. How do I make it so that attacking said NPC (striking the first blow) doesn't put a bounty on your head and expel you from the faction?

2 - How do I make it so that the script affecting the Imperial Legion uniform doesn't apply to one specific NPC which in my case would speak to the player regardless of rank and uniform?

3 - I have made a small rectangular area around the player with carpets. How do I make it so that the TES script detects the player leaving this area? Should I use the script used on Lava or something else?
User avatar
Sweet Blighty
 
Posts: 3423
Joined: Wed Jun 21, 2006 6:39 am

Post » Fri May 27, 2011 2:16 pm

1-2 - Why the NPC *has* to be aligned with Legion in CS? Wouldn't having Legion-related texts in dialog be enough?

3 - Unless the area is too big for it, you could cheat - place in the center of a *square* area an item with the script that checks *circular* proximity with GetDistance command. Otherwise... well the script could look like this:
begin AreaCheckshort insidecheckshort coordset insidecheck to 0set coord to player->GetPos, xset coord to coord - GetPos, xif ( coord > 1000)  set insidecheck to 1endifif ( coord < -1000)  set insidecheck to 1endifset coord to player->GetPos, yset coord to coord - GetPos, yif ( coord > 1000)  set insidecheck to 1endifif ( coord < -1000)  set insidecheck to 1endifif ( insidecheck == 1 ); trigger whateverendifend

The item is placed in the center of the area, the size of the area is assumed to be 2000x2000 units.
User avatar
Dalley hussain
 
Posts: 3480
Joined: Sun Jun 18, 2006 2:45 am

Post » Fri May 27, 2011 5:24 am

1 and 2.. have the NPC attack you first.

3.. create a logical "bounding box" for the rugs. Find out the top-left, top-right, bottom-left, and bottom-right corners of the rugs, and check that the player's position is inside them. If not, do whatever your player-not-on-carpet action is.
User avatar
мistrєss
 
Posts: 3168
Joined: Thu Dec 14, 2006 3:13 am

Post » Fri May 27, 2011 5:10 am

1 and 2.. have the NPC attack you first.

3.. create a logical "bounding box" for the rugs. Find out the top-left, top-right, bottom-left, and bottom-right corners of the rugs, and check that the player's position is inside them. If not, do whatever your player-not-on-carpet action is.


I'm trying to run a modified "openclose" script for animated chests.

begin opencloseshort stateIf ( Player->GetItemCount "Iron Key" == 0 )If ( OnActivate == 1 )If ( State == 0 )PlaySound3D "LockedChest"MessageBox "The chest is locked"EndifEndifEndifIf ( State == 0 )If ( OnActivate == 1 )PlaySound3D "Chest Open"PlayGroup "Idle2" Set State to 1Endif ElseIf ( State == 1 )If ( OnActivate == 1 )PlaySound3D "Chest Close"PlayGroup "Idle3" Set State to 0EndifEndifend openclose


Why does the chest refuse to close without the key?
User avatar
jessica Villacis
 
Posts: 3385
Joined: Tue Jan 23, 2007 2:03 pm

Post » Fri May 27, 2011 2:07 pm

Firstly.. you should test for onActivate once, and the do all your other clauses after that. Secondly, I don't know why it was doing that.. I didn't look that hard.. I just rewrote it. Try this:

begin opencloseshort stateif ( onActivate == 1 )	if ( state == 0 )		if ( player->GetItemCount, "Iron Key" == 0 )			PlaySound3D, "LockedChest"			MessageBox, "The chest is locked."		else			PlaySound3D, "Chest Open"			PlayGroup, "Idle2"		endif	elseif ( state == 1 )		PlaySound3D, "Chest Close"		PlayGroup, "Idle3"		set state to 0	endifendifend openclose

User avatar
Jeff Tingler
 
Posts: 3609
Joined: Sat Oct 13, 2007 7:55 pm

Post » Fri May 27, 2011 4:41 pm

Firstly.. you should test for onActivate once, and the do all your other clauses after that. Secondly, I don't know why it was doing that.. I didn't look that hard.. I just rewrote it. Try this:

begin opencloseshort stateif ( onActivate == 1 )	if ( state == 0 )		if ( player->GetItemCount, "Iron Key" == 0 )			PlaySound3D, "LockedChest"			MessageBox, "The chest is locked."		else			PlaySound3D, "Chest Open"			PlayGroup, "Idle2"		endif	elseif ( state == 1 )		PlaySound3D, "Chest Close"		PlayGroup, "Idle3"		set state to 0	endifendifend openclose


Doesn't work. Refuses to close with key. Gives locked message without (and refuses to close).
User avatar
Ryan Lutz
 
Posts: 3465
Joined: Sun Sep 09, 2007 12:39 pm

Post » Fri May 27, 2011 9:18 am

Does it play sound on open/close? Insert a "set state to 1" into the "Chest Open" block.
User avatar
louise hamilton
 
Posts: 3412
Joined: Wed Jun 07, 2006 9:16 am

Post » Fri May 27, 2011 12:41 am

LOL Kir.. I forgot about setting the state to 1. :embarrass:
User avatar
Nicole Kraus
 
Posts: 3432
Joined: Sat Apr 14, 2007 11:34 pm

Post » Fri May 27, 2011 3:59 pm

I can barely believe I overlooked that.
I'm tinkering around with "do once" conditions as mentioned in Morrowind Scripting for Dummies.

begin opencloseshort stateshort controlvarif ( onactivate == 1 )	if ( state == 0 )if ( controlvar == 0 )		if ( player->GetItemCount, "Iron Key" == 0 )			PlaySound3D, "LockedChest"			MessageBox, "The chest is locked."		elseif ( controlvar == 1 )			PlaySound3D, "Chest Open"			PlayGroup, "Idle2"set state to 1		endif	elseif ( state == 1 )		PlaySound3D, "Chest Close"		PlayGroup, "Idle3"		set state to 0	endifendifend openclose


I'm all confused now. I'm not too sure where to add the setting of controlvar. How do I make the door not require a key after being opened successfully? I thought it would be cool to auto-lock, but it doesn't feel appropriate.
User avatar
Lakyn Ellery
 
Posts: 3447
Joined: Sat Jan 27, 2007 1:02 pm


Return to III - Morrowind