Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Kotor Conditional Scripts

Page: 1 of 1
 Fallen Guardian
03-12-2011, 11:24 PM
#1
Does anyone know what the condition script is for say

There are two NPC's attacking you with a third standing by watching. Is there a way so that the conversation only starts if both NPC's are dead. So in NPC A's ondeath field the script will say if NPC B is dead then NPC C's conversation will start. And for NPC B's ondeath field if NPC A is dead then NPC's conversation will start.

Is there a certain script for that?
 Qui-Gon Glenn
03-12-2011, 11:36 PM
#2
This is a conditional inside a normal script: a "conditional" script is one that is actually declared int YourCondtional(blah, blah).

When you spawn in your creature, attach a local variable to that creature and set it to 10. In your OnDeath script, use the standard script but have it change your local variable for the creature to 20. Do the same for the other creatures.

Then, make a standard script: void main(), that has a conditional statement inside of it.

A conditional statement is an if then, a while do, a for do, etc. Mostly, we use ifs.

if ((GetLocalVar(yourNPCa) == 20) && (GetLocalVar(yourNPCb) == 20))

ActionStartConversation(yourconversation);

this script is totally rough hewn, and I may have some of the local variable concepts crossed up, but that is the general gist of the situation. The only way the dialog will fire in this case is if both are dead. If not, the script does nothing.

Take a look through the local variables tutorial, and the NWNLexicon or KotOR Tool Function Helper can be very educational.

EDIT: Well, now that I think about it, this script will probably only run once, and if the conditions are not matched, no joy. I am sure there is a better way to do this, so perhaps a more active scripter will help you out, but the idea came to me of the good-old invisible placeable, and you would attach this script to the invisible placeable's heartbeat script. The placeable would be spawned near the combatants.
 Fallen Guardian
03-12-2011, 11:52 PM
#3
Alright thanks.
 Qui-Gon Glenn
03-15-2011, 12:35 AM
#4
Fallen Guardian, there is a reason why I haven't given you better advice... I don't know my functions as well as I should... and I should let others give advice first sometimes, if I don't really know the answer.

However, I have good news :D

I am an idiot, and have forgotten a very basic function, that is particularly helpful in your situation:

int GetIsDead(oNPC) is what we need!

So, rather than going through all the hooey I was telling you about local variables (which I should really study more before acting like the professor) try this script, or something like it. I am writing it as I write this post, so it surely will not compile the first time, but here goes:

void main()
{
object oPC=GetFirstPC();
object oDyingOne=GetObjectByTag("DyingNPCOne");
object oDyingTwo=GetObjectByTag("DyingNPCTwo");

if (GetIsDead(oDyingOne)) && (GetIsDead(oDyingTwo))
{
ActionStartConversation(oPC, "YourConversationName");
}
}
This is not a complete script - or rather it will need to be inserted as a custom User Defined Event in your third Surviving Talker's OnHeartBeat event.

Hope this helps! Often the simplest solution is the best :)
 Fallen Guardian
03-15-2011, 12:50 AM
#5
Thanks a lot.
 Qui-Gon Glenn
03-20-2011, 3:13 PM
#6
void main()
{
object oPC=GetFirstPC();
object oDyingOne=GetObjectByTag("DyingNPCOne");
object oDyingTwo=GetObjectByTag("DyingNPCTwo");

if ((GetIsDead(oDyingOne)) && (GetIsDead(oDyingTwo)))
{
ActionStartConversation(oPC, "YourConversationName");
}
}
You may have figured this out, but what was missing was an open and closing parentheses around the main conditional, so that it was all one big condition. This script does compile :)

Your WIP thread is looking quite impressive; really nice work with the Chiss skin and the reskinned Endar Spire!
Page: 1 of 1