PDA

View Full Version : Some general scripting confusion


Robespierre
06-26-2008, 01:53 AM
Rather than clutter up the forums with multiple threads, I’ve decided to ask all of my modding questions in one thread. *Sharp intake of breath*. Alright, here goes:

1) Can someone please tell me what’s wrong with the following script:

void main() {

ExecuteScript("old_k_512_enter", OBJECT_SELF);

if(GetGlobalBoolean("502_talin_approach"))

{
ExecuteScript("k_baal_spawn", OBJECT_SELF);
}

}

The global is 1, but for some reason the creature refuses to spawn. He spawns fine without the global boolean condition, so I can’t work out what’s wrong here.

2) In the dialog editor, there is a field called “fadetype”. Can someone please explain to me the different values you can put in here, and what they do?

3) I have this script:

void main() {
object oNPC=GetObjectByTag("corp_talin");
location lMe=GetLocation(GetFirstPC());
ActionDoCommand(SetCommandable(TRUE,oNPC));
AssignCommand (oNPC,ActionForceMoveToLocation(lMe,FALSE));
AssignCommand (oNPC, ActionStartConversation(GetFirstPC()));
}

Which is supposed to move my NPC “corp_talin” towards the PC when the PC gets within sight of the NPC. Is this script correct, where do I put in (in relation to the .utc, I know that you have to put it in the override) and do I need to set any other values (range of sight of the NPC or anything like that)?

4) I want to make a conditional that states that if five globals are set as TRUE, then a particular dialog option should appear. I tried making this code, but it didn’t work:

int StartingConditional() {
if (GetGlobalBoolean("502Terlyn_done")) & if GetGlobalBoolean("502Tolas_done")) & if (GetGlobalBoolean("512Xaart_done")) & if (GetGlobalBoolean("512Sakarie_done")) & if (GetGlobalBoolean("512Gormo_done"));
return 1; {

return 0;
}
}

Thanks for the help!

glovemaster
06-26-2008, 03:04 AM
1) While there is no syntax problem with your script I think the problem is likely with ExecuteScript() as this halts execution of the current script until the other has been executed, and since your executing an onEnter script it could be that the script doesn't actually end to allow for your script to finish compiling.
Though thats just a guess I'm pretty confident that moving that line to the end and instead of using ExecuteScript, just put the contents of that script in the brackets.
void main() {
if(GetGlobalBoolean("502_talin_approach"))
{
// Contents of "k_baal_spawn.nss"
}

ExecuteScript("old_k_512_enter", OBJECT_SELF);
}

2) Unsure, its been a while since I touched the dialogue editor :p

3) Your script looks right, I'm guessing that unless its triggered from dialog you set it on the onNoticed or is it onSeen event?

4) Try this, your if ( ) statement cannot end with a semi-colon and to say "And" in an if statement you need to use two "&" signs together: &&
int StartingConditional() {
if (GetGlobalBoolean("502Terlyn_done") && GetGlobalBoolean("502Tolas_done") && GetGlobalBoolean("512Xaart_done") && GetGlobalBoolean("512Sakarie_done") && GetGlobalBoolean("512Gormo_done"))
return TRUE;
return FALSE;
}

It could be this but I am unsure at the moment, I guess you could try both.
int StartingConditional(){
return (GetGlobalBoolean("502Terlyn_done") && GetGlobalBoolean("502Tolas_done") && GetGlobalBoolean("512Xaart_done") && GetGlobalBoolean("512Sakarie_done") && GetGlobalBoolean("512Gormo_done"));
}

stoffe
06-26-2008, 06:03 AM
1) Can someone please tell me what’s wrong with the following script:
ExecuteScript("k_baal_spawn", OBJECT_SELF);


Nothing wrong with the script you posted. What does the "k_baal_spawn" script look like? Also, make sure you have added the 502_talin_approach variable to the globalcat.2da file, or the game won't keep track of it.


3) I have this script:
Which is supposed to move my NPC “corp_talin” towards the PC when the PC gets within sight of the NPC. Is this script correct, where do I put in (in relation to the .utc, I know that you have to put it in the override) and do I need to set any other values (range of sight of the NPC or anything like that)?

If you put it as the corp_talin NPC's Perception event script (OnNoticed) you'll have to modify so it only triggers when the NPC sees the player, and only does it once. Like:

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

if (!GetLocalBoolean(OBJECT_SELF, 40) && GetLastPerceptionSeen() && (GetLastPerceived() == oPC)) {
location lMe = GetLocation(oPC);

SetCommandable(TRUE);
ClearAllActions();
ActionForceMoveToLocation(lMe, FALSE);
ActionStartConversation(oPC);

SetLocalBoolean(OBJECT_SELF, 40, TRUE);
}
else {
ExecuteScript("k_ai_master", OBJECT_SELF, 1002);
}
}


There is a field for setting the perception range of an NPC in the UTC file, if you want to make the distance it triggers at smaller or bigger than normal.

Stream
06-26-2008, 03:58 PM
For the first script, I may be wrong but it looks like the problem is with the Boolean condition, you've stated the name of the Boolean but not the state it's got to be, also, like Stoffe said, have you added it to globalcat.2da and have you added as a Boolean or number?

--Stream

Robespierre
07-02-2008, 09:31 PM
Ah, I'm back!

1) Yes, we can all laugh now. I didn’t have the correct version of the globalcat.2da in my override.

2) The Kotor Tool dialog editor was actually the most helpful here. It told me what the numbers actually mean.

4) Again, we can all laugh. Two hours later, I worked out that this didn’t work because I used GetGlobalBoolean instead of GetGlobalNumber.

Alright, some new questions!

3) Soffe, I have tried just about everything to get this script to work, but for some reason the NPC doesn’t actually walk up to me when he starts the conversation. Any ideas as to why he doesn’t walk up to me?

5) Once my NPC has finished walking to a waypoint, I want him to turn around. Is there a simple script that does this?

6) You know those bags that appear after someone dies? Is it possible to just spawn the bag with some items in it? Either that or an equivalent placeable that disappears after you open it.

7) I have a journal entry system set up. However, it involves the journal entries switching back to previous node entries (ie, those with a lower node number than the one it is currently at). For some reason, the game doesn’t seem to me attempting to switch back to a previous dialog entry, and refuses to swap. Is there a way around this?