locoguano Posted July 6, 2006 Share Posted July 6, 2006 I'm just starting with learing scripts.. I do better by looking at a completed one and disecting than by reading a tutorial... I need a script for a conversation that will do a level check.. so if the npc being addressed is below a certain level, he will get something like: "Sorry, you arent ready for this" Then, if the npc is at the right level they get the appropriate response... Link to comment Share on other sites More sharing options...
locoguano Posted July 6, 2006 Author Share Posted July 6, 2006 Ok.. looking at the one used for handmaiden... //:: c_003handfight /* parameter 1 = string identifier for a global number parameter 2 = value to compare to GetGlobalNumber(param1) returns TRUE if values are EQUAL. */ //:: Created By: Anthony Davis (modified by CFA 8-30-04) #include "k_inc_debug" int StartingConditional() { string tString = GetScriptStringParameter(); int tInt = GetScriptParameter( 1 ); int LevelInt = GetScriptParameter( 2 ); // This checks to see if the player has won a certain tier of fighting with // the Handmaiden, and if he's at a good enough level to go on to the next // tier. if ( ( GetGlobalNumber(tString) == tInt ) && ( GetGlobalNumber ("G_PC_LEVEL") < LevelInt ) ) { return TRUE; } return FALSE; } I see that if the level check is less than what is set in the parameters, then the string continues to the "sorry bub, you're not there yet"... so if it returns false, how do i make it jump to the appropriate dialogue? Link to comment Share on other sites More sharing options...
Lit Ridl Posted July 6, 2006 Share Posted July 6, 2006 Look for c_pc_level in your Kotor II source scripts. Link to comment Share on other sites More sharing options...
Darkkender Posted July 6, 2006 Share Posted July 6, 2006 Actually you will want to set a basic conditional script up in the "DLG" file. It will check that the Pc's level is 10 let's say and then the Dialog branch will appear. If your PC's level is 9 the Dialog branch will be invisible in game. You may want to disect a few dialog files and look for there conditional scripts and look at those scripts sources to help you on your way. Link to comment Share on other sites More sharing options...
stoffe Posted July 6, 2006 Share Posted July 6, 2006 Ok.. looking at the one used for handmaiden... (snip) I see that if the level check is less than what is set in the parameters, then the string continues to the "sorry bub, you're not there yet"... so if it returns false, how do i make it jump to the appropriate dialogue? Dialog conditional scripts (running the StartingConditional() function), assigned to one of the Conditional script slots in a dialog node, return either true or false to the dialog system. If the value returned is true the dialog node the script is attached to will be available. If it's an entry node the NPC will speak it when it is reached during conversation. If it's a reply node it will become available for the player to pick as a response. For entry nodes there can be several available entries at a location in the dialog tree, but the game will only use one of them. It starts at the top of the list of available entries and checks the conditional scripts (if any). The first entry node to return true on its conditional check will be used, an any entries below it in the list will be skipped, regardless of their availability condition. Thus the ordering of entry nodes is important. If no entries have a true condition the conversation will end. For reply nodes all nodes with a conditional returning true will be listed for the player to pick from. If no nodes are available the conversation ends. Nodes with no conditional scripts assigned will be treated the same as if the script had returned true. As a quick example you have a dialog where, at a specific point in the conversation tree, you have three entry nodes concerning to some training the NPC can offer: "You are experienced enough to learn. I will train you." [Conditional:checkpclevel] "You are a quick learner. I can teach you nothing more." [Conditional:checkpcteach] "You are not experienced enough to be able to learn what I can teach." [Conditional:none] The Topmost entry node has a conditional script, checkpclevel, which in its simplest form would look like: int StartingConditional() { return (!GetLocalBoolean(GetPCSpeaker(), 142) && (GetHitDice(GetPCSpeaker()) >= 12)); } This would return true if the character level of the player character is 12 or higher, and the player has not already been trained (assuming that the training sets local boolean 142 to true), otherwise false. The second entry has a conditional script, checkpcteach, which checks if the player has already been trained, which might look like: int StartingConditional() { return GetLocalBoolean(GetPCSpeaker(), 142); } ...which, if it returns true would signal that the player has already been through this branch of dialog earlier, doing training, and thus subsequent attempts should show the "Already done that" response. The final entry, the "fallthrough" entry, has no conditional check script and is what will be displayed if both the above entries had their conditional checks returning false. I.e. if The player's level wasn't high enough, and the training hasn't been done already. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.