Fair Strides

Fair Strides' Script Shack

Recommended Posts

How do I compile changes I made to an extracted nwscript.nss to a usable form for Kotor 2?

 

You don't compile nwscript.nss at all. Ideally you don't even modify it as nwscript.nss is just the basic script that's "included" in all scripts when they're compiled. So if you really need to make those changes to nwscript.nss, you need to drop it into your Override and then recompile EVERY other script that uses the relevant part of nwscript.nss.

Share this post


Link to post
Share on other sites

I see. Basically I've got some code to add to the heartbeat script that will check to see if each character has taken my custom "feat" via the use of a TRUE or FALSE statement, and then equip an item to the corresponding characters invisible item slot to grant the bonus described by the "feat". (I am aware some slots are occupied already) The feat itself is just a dummy that the player clicks to give the impression of a feat, and does not have to do anything other than appear in the UI during feat selection. It is my understanding that I must edit the nwscript.nss to have a "Constant" that is used by Feat.2da in order to have my "Feat" appear in this menu to be selected, and thus change the 0 to a 1 and equip the item as a result. Is this correct? Or is there a better way to do so.

Share this post


Link to post
Share on other sites

I'll try the fighters with just default scripts and see what the faction setting does. I did try to see how they did the sparring sequence with Bastila in the training montage on Dantooine, but in the relevant DLG I could only see scripts that equipped and unequipped the swords, not anything that actually controlled the animations of the cutscene.

 

 

Sounds like you got it, but the Bastila vs Player training montage actually uses cutscene animations. So nothing that can be re-used elsewhere.

Share this post


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

Just want to say, I always enjoy hanging in the script shack!

 

Happy New Year @Fair_Strides, and all you scriptheads out there!

Share this post


Link to post
Share on other sites

So poking through nwscript.nss I found this:

// 708: SetNPCSelectability
void SetNPCSelectability(int nNPC, int nSelectability);
Does this (as I hope) disable clicking on the NPC? I am trying to kill the selection circle and health bar showing on some NPCs but haven't found any obvious method to do so.

 

If so, what script would this be best incorporated into?

Share this post


Link to post
Share on other sites

Unfortunately no. That function determines whether you can select a party member in the menu.

 

I don't know of a script function for what you want. It would more likely to be a flag in the UTC file. I know Doesn't Reorient on PC will make the character ignore any interaction, and I know you can remove the health bars on doors, but I can't recall if you can do that with characters. The health bars on the Sith that spar on Korriban are visible, so that's not a good sign, but there's tons of unused functionality in the game so it may still be possible.

Share this post


Link to post
Share on other sites

Yeah there's nothing in the UTC that does it, not that I can see at any rate. I was sure I had seen non-interactive NPCs in the game with no UI elements, but maybe it was only in TSL. If it wasn't combat-related I could just cheat it by making them a placeable, but that's not really practical for sparring.

 

The Doesn't Reorient thing would be useful for some of the others at least. How would I go about incorporating that?

Share this post


Link to post
Share on other sites

That's strange. It's in the UTC regardless. I believe it's the Interruptable boolean. It all shows up if you edit with K-GFF instead. There are lots more booleans that don't show up in KOTOR Tool, some of which aren't even used in the game, so it's possible there's one that does what you want. Maybe.

Share this post


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

They are using the Predator and Prey factions so they attack each other without attacking anyone else.

Ok, interesting.

 

I know that when I started helping an individual here with spawning a new NPC on the Endar Spire, he had set their faction to "neutral" (I think) which made him unselectable for conversation. Just had a barkstring over his head.

 

Somehow, via more scripting (wheeeee!) you may be able to get the results you are looking for by playing around with this.

Share this post


Link to post
Share on other sites

The non-combatant NPCs are Neutral, set to No Interrupt, and still have the selection circles/health bars. I could actually set them as placeables, but I'm not that fussed on those ones having the health bars.

 

Could I at least script the fighters to always stay at full HP? If they must have health bars, I'd prefer to have them full like all the neutral NPCs, not at 1 HP.

Share this post


Link to post
Share on other sites

The non-combatant NPCs are Neutral, set to No Interrupt, and still have the selection circles/health bars. I could actually set them as placeables, but I'm not that fussed on those ones having the health bars.

 

Could I at least script the fighters to always stay at full HP? If they must have health bars, I'd prefer to have them full like all the neutral NPCs, not at 1 HP.

Life hacks, make their HP max and current as 1.

Then it shows a full bar regardless.

  • Like 1

Share this post


Link to post
Share on other sites

I checked what BioWare did for the dueling Sith, and it looks like they had one of the character scripts heal them up between combat. The scripts I tried to look at wouldn't decompile, so copying what they did directly probably isn't an option, but repeating the effect certainly is. The 1 HP hack sounds a lot easier if it would work though.

  • Like 1

Share this post


Link to post
Share on other sites

Life hacks, make their HP max and current as 1.

Then it shows a full bar regardless.

Nice, that works. Thanks.

 

The 1 HP hack sounds a lot easier if it would work though.

Yeah it figures I would try to make my life difficult when there is an easy solution staring me in the face. Thanks for checking out the Korriban scripts though.

  • Like 1

Share this post


Link to post
Share on other sites

I have been doing a bit of testing of edited versions of the K1 Enclave on Dantooine of late, and that requires loading from a save before leaving Taris (seeing as you don't get another opportunity to save beforehand). I've noticed I repeatedly experience a bug that, on further investigation, seems to be fairly common amongst other people as well. Namely, that during the cutscene just prior to escaping Taris where Malak orders Admiral Karath to continue the bombardment, you can can see your party members standing at the back of the bridge. I had a look through the stunt module and couldn't see any reason why they would be there, but I was wondering whether scripting could be used to check for their presence and teleport them out of sight.

 

This is the module's onload script:

void main() {
	if ((GetIsPC(GetEnteringObject()) == 1)) {
		AssignCommand(GetFirstPC(), ActionStartConversation(GetObjectByTag("DarthMalak", 0), "scene_06", 0, 0, 1, "", "", "", "", "", ""));
		PlayRoomAnimation("StuntRoom40d", 1);
	}
}
I was thinking perhaps some sort of if loop with GetObjectByTag, or is there something specific for current party members? Although how would you teleport them? I know you can force the character to walk/run to a waypoint or object with a move command, but this needs to be a forced instantaneous relocation. As to where, adding a new waypoint is easy enough if that helps. The script needs to be injected into the module anyway, given its generic name (k_scene_start).

 

Somewhat related, in the following stunt module, onboard the Ebon Hawk where Bastila says to head to Dantooine and Carth warns of incoming fighters, I noticed that the party members - who are just standing in the hallway - often block the camera during the opening camera move at the beginning of the scene (especially the walking carpet Zaalbar). I'm wondering again if this might be addressed with the stunt module's onload script:

void main() {
	if ((GetIsPC(GetEnteringObject()) == 1)) {
		if ((IsAvailableCreature(2) == 0)) {
			AurPostString("Adding Carth to Party", 5, 14, 1.0);
			AddAvailableNPCByTemplate(2, "p_carth");
		}
		if ((IsNPCPartyMember(2) == 0)) {
			AurPostString("Spawning Carth", 5, 15, 1.0);
			SpawnAvailableNPC(2, GetLocation(GetObjectByTag("WP01", 0)));
		}
		if ((IsAvailableCreature(0) == 0)) {
			AddAvailableNPCByTemplate(0, "p_bastilla");
		}
		if ((IsNPCPartyMember(0) == 0)) {
			SpawnAvailableNPC(0, GetLocation(GetObjectByTag("WP01", 0)));
		}
		SetPartyLeader(0xFFFFFFFF);
		AssignCommand(GetFirstPC(), ClearAllEffects());
		AssignCommand(GetObjectByTag("Bastila", 0), ClearAllEffects());
		AssignCommand(GetObjectByTag("Carth", 0), ClearAllEffects());
		PlayRoomAnimation("m12aa_01q", 9);
		AssignCommand(GetObjectByTag("CutStart", 0), ActionStartConversation(GetFirstPC(), "scene_start", 0, 0, 1, "", "", "", "", "", ""));
	}
}
Perhaps in both cases, rather than searching for them and moving, a simpler solution might be forcibly clearing the party? Although I am guessing that case, clearing the party in the first script should be sufficient to handle both.

 

That said, given the gravity of the situation surrounding the escape, I think it would make sense in the EH scene if everyone were in the cockpit. There are two passenger seats, so perhaps Mission and Canderous could be seated on those, with Zaalbar and T3 standing out of the way in the back corner (behind Bastila). Looking at m12aa_01q, the room animation appears to only be switching out the skybox (which is actually pretty clever). The character animations for Carth and Bastila would seem to be all done via scene_start.dlg, so presumably additional ones could be added for the rest of the team, with extra waypoints for positioning. For the script side of things, would it just be a case of duplicating the existing entries for the rest of the team?

Share this post


Link to post
Share on other sites

Stunt_06 is the Leviathan cutscene module in question. Stunt_07 is the following Ebon Hawk scene.

 

If you grab ChAiNz.2da's save collection (which is what I use for testing), 000134 - Game133 will have you right at the Ebon Hawk ready to escape Taris, which will launch you straight into the Leviathan cutscene.

Share this post


Link to post
Share on other sites

Loading up the level's files, I believe the issue is the fact that the module's spawn-in point is right in the middle of the room.

 

If you want to move them back behind the door, you have two options:

 

1. Open the "module.ifo" file in K-GFF and set the "Mod_Entry_X", "Mod_Entry_Y", and "Mod_Entry_Z" fields to 244.0, 55.1, and 8.99.

2. Modify the script to move the PCs to those coordinates using "AssignCommand(, ActionJumpToLocation(Location(Vector(244.0, 55.1, 8.99), 0.0)));"

Share this post


Link to post
Share on other sites

The IFO edit works, although the X value needs to be something more like 200. I'm curious as to how to get the script version to work though, since I suck at scripting. This attempt was a failure:

void main() {
	if ((GetIsPC(GetEnteringObject()) == 1))
	{
		AssignCommand(GetObjectByTag("Bastila", 0), ActionJumpToLocation(Location(Vector(244.0, 55.1, 8.99), 0.0)));
		AssignCommand(GetObjectByTag("Carth", 0), ActionJumpToLocation(Location(Vector(244.0, 55.1, 8.99), 0.0)));
		AssignCommand(GetObjectByTag("Mission", 0), ActionJumpToLocation(Location(Vector(244.0, 55.1, 8.99), 0.0)));
		AssignCommand(GetObjectByTag("Zaalbar", 0), ActionJumpToLocation(Location(Vector(244.0, 55.1, 8.99), 0.0)));
		AssignCommand(GetObjectByTag("Cand", 0), ActionJumpToLocation(Location(Vector(244.0, 55.1, 8.99), 0.0)));
		AssignCommand(GetObjectByTag("T3M4", 0), ActionJumpToLocation(Location(Vector(244.0, 55.1, 8.99), 0.0)));
		AssignCommand(GetFirstPC(), ActionStartConversation(GetObjectByTag("DarthMalak", 0), "scene_06", 0, 0, 1, "", "", "", "", "", ""));
		PlayRoomAnimation("StuntRoom40d", 1);
	}
}
Also I noticed the player is present as well.

Share this post


Link to post
Share on other sites

void main() {
if ((GetIsPC(GetEnteringObject()) == 1))
{
location lJump = Location(Vector(244.0, 55.1, 8.99), 0.0);

int iIndex = 0;
object oTarget = GetPartyMemberByIndex(iIndex);

while(GetIsObjectValid(oTarget) == 1)
{
AssignCommand(oTarget, ActionJumpToLocation(lJump));

iIndex++;
oTarget = GetPartyMemberByindex(iIndex);
}

AssignCommand(GetFirstPC(), ActionStartConversation(GetObjectByTag("DarthMalak"), "scene_06", 0, 0, 1, "", "", "", "", "", ""));

PlayRoomAnimation("StuntRoom40d", 1);

}
}

Share this post


Link to post
Share on other sites

Cheers.

 

The player's index is -1, so should int iIndex = 0 be int iIndex = -1 instead?

int NPC_PLAYER          = -1;
int NPC_BASTILA         = 0;
int NPC_CANDEROUS       = 1;
int NPC_CARTH           = 2;
int NPC_HK_47           = 3;
int NPC_JOLEE           = 4;
int NPC_JUHANI          = 5;
int NPC_MISSION         = 6;
int NPC_T3_M4           = 7;
int NPC_ZAALBAR         = 8;

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.