PDA

View Full Version : KotOR : single dialog line & failure of spawn check


Revan's Soul
07-20-2009, 06:17 PM
Hello,

I have two modding questions about KotOR 1.

1) I've made a custom NPC with a dialog, but I was wondering if it's possible to create a script that makes the NPC say something to himself when you come within a certain distance, without the NPC actually talking to you. It's like that Mandalorian Zuka muttering to himself in the Mandalorian camp in TSL. I've looked up his dlg file but I couldn't find any clues there and his scripts are compiled so I can't look into them. He's also supposed to say it only once, before you take a quest.

I've learned a lot about scripting and modding over the past weeks browsing on the forum, but I couldn't find an answer for this. I thought perhaps of triggering the script when the PC walks over a waypoint, but I don't know how to create waypoints or attach scripts to them. The script itself creates a problem too. I've added the string the NPC uses to dialog.tlk. I know I'm supposed to use append.dlk but when I used the method described in TSL patcher manual to join the files, it didn't work. Anyway, now there's just a very thin bar above his head, no lettering and the VO sound file doesn't run. What am I doing wrong in this script? :p I've looked through dozens of posts but I can't find the answer. One thing I can think of that I did wrong, but I'm not sure : the number for the first entry in the quest is 10, so I thought if it was below 10, it would indicate the quest hadn't been taken yet.

This is the conditional script I want to use. Essentially, if the conditions of the script aren't met, he's just supposed to stand there until the PC starts a conversation, but I don't know how to write that alternative of not doing anything :p. Clear actions maybe?


void main()
{

object oNPC = GetObjectByTag("Akazz");
object oPC = GetFirstPC();

if ((GetJournalEntry("Tarm02_scientist") < 10) && (GetDistanceBetween(oNPC, oPC) <= 2.0))
{
AssignCommand(oNPC, ActionDoCommand(SetFacing(270.0)));
ActionBarkString(49265);
}
else
?
}

2) I've used a script I found on the Holowan forum to check if he's spawned already, but when i Quicksave and Quickload, he shows up multiple times. The same for another custom character I created. I've had him 3x in the same room, while the placeables only spawn once.

This is the modified onenter script of the module the NPC's appear in.

void main()
{
object oEntering = GetEnteringObject();
object oPC=GetFirstPC();

if (GetIsPC(oEntering))
{
//check if the object is already there to avoid multiple objects
if (!GetIsObjectValid(GetObjectByTag("o")))
{
CreateObject(OBJECT_TYPE_CREATURE, "tar02_akazz", Location(Vector(136.67,137.01,0.0), 0.0));
}

if (!GetIsObjectValid(GetObjectByTag("o")))
{
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_holoart1", Location(Vector(139.17, 133.13, 0.0), 0.0));
}

if (!GetIsObjectValid(GetObjectByTag("o")))
{
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_desk1", Location(Vector(134.63, 141.25, 0.0), 134.0));
}

if (!GetIsObjectValid(GetObjectByTag("o")))
{
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_bed2", Location(Vector(143.07, 137.69, 0.0), 43.0));
}


if (!GetIsObjectValid(GetObjectByTag("o")))
{
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_chair2", Location(Vector(135.31, 140.40, 0.0), 28.0));
}

ExecuteScript("old_k_ptar_a02aa_en", OBJECT_SELF);
}

}

I'd appreciate any help. Pls keep in mind I haven't been modding long, so kindly tell me exactly what to do :)

Trench
07-20-2009, 06:58 PM
I think all you have to do is create a dialogue string without a reply (for the first question).

Star Admiral
07-20-2009, 09:17 PM
For the OnEnter script, you need to change the "o" in the GetObjectByTag() to the tag of your particular character, otherwise the character/placeable will continue to spawn. You can find the tag in the UTC (creatures) or UTP (placeable) file for that given item.

- Star Admiral

Revan's Soul
07-21-2009, 04:47 PM
Thanks for the replies guys. I've replaced the "0" with the NPC's and placeables' tags, but now stuff isn't appearing O.o I think I'll have to tweak it a little more.

The single dialog line also worked, had some very good help. Thanks guys!

Revan's Soul
07-22-2009, 05:01 AM
Ok new thing....I've managed to make an onheartbeat script work that the NPC says something as you approach, but I think I need to increase the frequency of the proximity check in the heartbeat script because sometimes he says something right away and sometimes he waits. I think it's checked every few seconds? I don't know....How do I increase the frequency of the checks? Thanks.

glovemaster
07-22-2009, 07:51 AM
What I like to do, is to put the main part of your script into a separate function and then fire it several times from the main().
Like so:
void checkIfPCIsApproaching(){
// The code you have.
}

void main() {
float fBeat = 6.0; // I believe it is 6 seconds.
float fCheck = 0.1; // Every 1/10th of a second by default.
float f;
for(f = 0.0; f < fBeat; f = (f + fCheck)) {
checkIfPCIsApproaching();
}
}

This works, but the game usually does this sort of stuff with Triggers.