Reztea

A couple scripting questions?

Recommended Posts

How would I go about starting a conversation after killing a group of people? Like when Canderous and his mercenaries along with Revan and his party killed the Rakghouls in the Undercity before Canderous joined them.


 


(K1 Script).


 


Another thing, how can I "lock" a party member and make them required to be in your party for the time being?


 


And one last thing. (If this simply isn't possible, I get it) Is it possible to change the lighting of a module? Im trying to get a reddish type of feel for Dantooine,


 

Share this post


Link to post
Share on other sites

You can use SetNPCSelectability to lock a party member. 

void main() {
SetNPCSelectability(<Party Members Integer Value>, FALSE);
}

think the values for party members are as follows:

0 - Bastila

1 - Canderous

2 - Carth

3 - HK-47

4 - Jolee

5 - Juhani

6 - Mission

7 - T3-M4

8 - Zaalbar

 

But I'm not totally sure (that's just the order it goes on the party select screen). Alternatively you can use SetAreaUnescapable() which stops you from being able to change your party entirely.

Share this post


Link to post
Share on other sites

 

How would I go about starting a conversation after killing a group of people? Like when Canderous and his mercenaries along with Revan and his party killed the Rakghouls in the Undercity before Canderous joined them.

 

(K1 Script).

 

Another thing, how can I "lock" a party member and make them required to be in your party for the time being?

 

And one last thing. (If this simply isn't possible, I get it) Is it possible to change the lighting of a module? Im trying to get a reddish type of feel for Dantooine,

 

 

I don't know how the conversation in this scene is started, but you could use the creature's OnDeath script. If it's more than one creature, have the script check if any of the others are still alive (i.e. valid objects) and if they aren't, then start the conversation. That's what I would do at least.

 

And what do you mean by changing the lighting? Do you want to change it with a script or just generally change it?

 

You can use SetNPCSelectability to lock a party member.

 

Correct me if I'm wrong, but I always thought that this does the exact opposite: It prevents a party member from being selected (like Bastila on Korriban), while Reztea is looking to lock a party member in place, preventing you from using someone else.

Share this post


Link to post
Share on other sites

I don't know how the conversation in this scene is started, but you could use the creature's OnDeath script. If it's more than one creature, have the script check if any of the others are still alive (i.e. valid objects) and if they aren't, then start the conversation. That's what I would do at least.

An example would be as if:

 

Jedi: Let us duel!

Sith: You've sealed your fate!

 

*You're the Jedi, and the Sith bought backup, you need to kill every Sith there, once they all are killed, another Sith who had nothing to do with the battle but was in the module will then speak to you*

 

You know how terrible I am with scripting, an example script would be useful. :)

 

And what do you mean by changing the lighting? Do you want to change it with a script or just generally change it?

 

I want to just generally change the lighting.

Share this post


Link to post
Share on other sites

You can use SetNPCSelectability to lock a party member. 

void main() {
SetNPCSelectability(<Party Members Integer Value>, FALSE);
}

think the values for party members are as follows:

0 - Bastila

1 - Canderous

2 - Carth

3 - HK-47

4 - Jolee

5 - Juhani

6 - Mission

7 - T3-M4

8 - Zaalbar

 

But I'm not totally sure (that's just the order it goes on the party select screen). Alternatively you can use SetAreaUnescapable() which stops you from being able to change your party entirely.

I thought that shuts down availability to be selected at all, Perhaps I should've given an example.

 

Like when you took the basilisk to Onderon and Kreia was required to come with you. Like that, sorry for any confusing I'm causing.

Share this post


Link to post
Share on other sites

Correct me if I'm wrong, but I always thought that this does the exact opposite: It prevents a party member from being selected (like Bastila on Korriban), while Reztea is looking to lock a party member in place, preventing you from using someone else.

 

It does, but if they're already in the party it prevents you from switching them out. I guess that's probably not the best way of doing it though.

Share this post


Link to post
Share on other sites

Try this for the "After fight dialog start":

void main(){

object oChar = GetNearestObjectByTag("<AddTagOfFightingNPCs>", 2);

if(!GetIsObjectValid(oChar))
{
  AssignCommand(GetObjectByTag("<AddTagOfSpeakingNPC>"), ActionStartConversation(GetFirstPC(), "<AddDialogFileNameWithoutExtension>"));
}

}

You need to add the appropriate tags etc. where I noted them. Also this assumes that all NPCs you're fighting have the same tag. If they don't, then you need to define additional objects in the same way as oChar but with other tags and then also add them to the if condition, e.g. !GetIsObjectValid(oChar) && !GetIsObjectValid(oChar2)

 

Then use this as the OnDeath script for all of your fighting NPCs. It might work, or it might not. If it starts the conversation too early, i.e. before all enemies were killed, try changing the 2 to 1 in the object definition.

Share this post


Link to post
Share on other sites

A function that can greatly help you would be the ShowPartySelectionGUI one, in addition to the SetNPCSelectability function already provided by DarthRevan101.

// 712: ShowPartySelectionGUI
// Brings up the party selection GUI for the player to
// select the members of the party from
// if exit script is specified, will be executed when
// the GUI is exited

void ShowPartySelectionGUI(string sExitScript = "", int nForceNPC1 = -1, int nForceNPC2 = -1);

The int nForceNPC1 and nForceNPC2 are numbers from the npc.2da file (though DarthRevan101 did get the order correct :) ). This can be done to lock a party member, but would need to be supplied every time you activate the screen through scripting. The SetNPCSelectability will allow you to remove the ability to select an NPC. If memory serves, DarthRevan101 is correct that this can be done to an already-active party member to keep them in the party.

 

--------------------------------------------

 

As to changing the lighting of a level, if the level had animations on the lights in the level's models, then it could be possible to change the lighting through scripting. Otherwise, the best you can do is change the color of the fog in the level (and even then, you can't change the level of the fog... :( ).

Share this post


Link to post
Share on other sites

I'm only a beginner so I could be wrong, but for triggering a conversation when a group of enemies dies here's how they did it for the very fist encounter on the endar spire:

 

In the OnSpawn script for the two sith the local boolean SW_FLAG_EVENT_ON_DEATH is set to true. What this does is trigger the OnUserDefined event when OnDeath is triggered. This is because of a conditional in the default OnDeath script, k_def_death01.nss I think. Actually, each default event script has a corresponding SW_FLAG_EVENT_ON_* boolean that triggers OnUserDefined.

 

So once each of the sith die their OnUserDefined script activates and that script first checks if a global number representing the amount of dead enemies (in this case it's called END_ROOM3_DEAD) is greater than or equal to 1 and if so the conversation occurs. If you haven't killed all the enemies yet then the global number is incremented. In this case there are 2 sith you have to kill which leads me to believe that all global numbers are initialized as -1. Someone please correct me if I'm wrong.

 

 

Now if you wanna make your own script then what you gotta do is go into globalcat.2da where all the global numbers/booleans are stored and add a new global number to represent the amount of dead enemies. Then add a line in the OnSpawn script that sets SW_FLAG_EVENT_ON_DEATH to true

SetLocalBoolean(OBJECT_SELF, SW_FLAG_EVENT_ON_DEATH, TRUE);

Then make a custom OnUserDefined script or add to the existing one. Here is the decompiled OnUserDefined script of those sith:

void main() {
	int int1 = GetUserDefinedEventNumber();
	if ((int1 == 1001)) {
	}
	else {
		if ((int1 == 1002)) {
		}
		else {
			if ((int1 == 1003)) {
			}
			else {
				if ((int1 == 1004)) {
				}
				else {
					if ((int1 == 1005)) {
					}
					else {
						if ((int1 == 1006)) {
						}
						else {
							if ((int1 == 1007)) {
								int nGlobal = GetGlobalNumber("END_ROOM3_DEAD");
								object object1 = sub1();
								object oPC = GetFirstPC();
								int nCurHP = GetCurrentHitPoints(oPC);
								int nMaxHP = GetMaxHitPoints(oPC);
								int int9 = GetCurrentHitPoints(object1);
								int int11 = GetMaxHitPoints(object1);
								if ((nGlobal >= 1)) {
									sub2(intGLOB_163); // TRASK_ROOM3_DONE
									SetLocked(GetObjectByTag("end_door05", 0), 0);
									if (((int9 < int11) || (nCurHP < nMaxHP))) {
										CancelCombat(sub1());
										CancelCombat(GetFirstPC());
										DelayCommand(1.0, sub3());
									}
								}
								SetGlobalNumber("END_ROOM3_DEAD", (nGlobal + 1));
							}
							else {
								if ((int1 == 1008)) {
								}
								else {
									if ((int1 == 1009)) {
									}
									else {
										if ((int1 == 1010)) {
										}
										else {
											if ((int1 == intGLOB_21)) {
												sub4("wp_homebase");
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

Each default OnEvent script has its own OnUserDefinedEventNumber() that can be used in a script like this to determine which event is triggering OnUserDefined. In this case the OnDeath event number is 1007. Actually this script is decompiled they probably used a switch statement in the original source code instead of these nested if statements. You can also just delete the nested if statements if you want and just check if the event number is 1007.

 

Then just do what they did and check if (nGlobal >= number_of_dead_enemies) then trigger the conversation but make sure to cancel combat like they did:

CancelCombat(sub1());
CancelCombat(GetFirstPC());
DelayCommand(1.0, sub3());

sub1() returns Trask and sub3() I'm assuming is ActionStartConversation().

  • Like 1

Share this post


Link to post
Share on other sites
Guest Qui-Gon Glenn

^^^ that's how i would have done it, using the user defined On_Death

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.