glovemaster Posted April 5, 2007 Share Posted April 5, 2007 Hi, i need a script to check if a door is open, and then another script to check if a door is closed. Please. Thanks ~GM Link to comment Share on other sites More sharing options...
Pavlos Posted April 5, 2007 Share Posted April 5, 2007 Hi, i need a script to check if a door is open, and then another script to check if a door is closed. Please. Thanks ~GM You could use something like this to check if it is open: int StartingConditional() { object oDoor = GetObjectByTag("MyDoorTag"); return (GetIsOpen(oDoor)); } And this to check if it is closed: int StartingConditional() { object oDoor = GetObjectByTag("MyDoorTag"); return (GetIsOpen(oDoor) == FALSE); } They should work. If you're doing this for KotOR II and it is for a dialogue then you will only need one of these and you can make use of the not logic option . Link to comment Share on other sites More sharing options...
glovemaster Posted April 5, 2007 Author Share Posted April 5, 2007 Thanks, those should work fine.. I'll test them in a moment, can some one correct me on this please? OpenStore(my_store, OBJECT_SELF, 0, 0); Thanks again, GM Link to comment Share on other sites More sharing options...
Pavlos Posted April 5, 2007 Share Posted April 5, 2007 Thanks, those should work fine.. I'll test them in a moment, can some one correct me on this please? I presume that your store doesn't open? I'm presuming this is just a sample of the script where the problem lies? Rather than OBJECT_SELF you may wish to try GetPCSpeaker(). There is a tutorial written by stoffe here. You may as well just use the scripts provided by it - they should work . Link to comment Share on other sites More sharing options...
glovemaster Posted April 5, 2007 Author Share Posted April 5, 2007 Ah that helps, thanks im going to test now. --EDIT---------- Results: It works fine now. I can start and stop a force field from a terminal. I am still having problems with the store opening. I use the script: void main() { object oStore = GetObjectByTag("[color=green]TAG[/color]"); if (!GetIsObjectValid(oStore)) oStore = CreateObject(OBJECT_TYPE_STORE, "[color=orange]RESREF[/color]", GetLocation(OBJECT_SELF)); if (GetIsObjectValid(oStore)) DelayCommand(0.5, OpenStore(oStore, GetPCSpeaker())); } Whats wrong with it? I have the dialogue file in a seperate module file that the script but thats by "_DLG" and "_S" Link to comment Share on other sites More sharing options...
stoffe Posted April 5, 2007 Share Posted April 5, 2007 void main() { object oStore = GetObjectByTag("[color=green]TAG[/color]"); if (!GetIsObjectValid(oStore)) oStore = CreateObject(OBJECT_TYPE_STORE, "[color=orange]RESREF[/color]", GetLocation(OBJECT_SELF)); if (GetIsObjectValid(oStore)) DelayCommand(0.5, OpenStore(oStore, GetPCSpeaker())); } Whats wrong with it? I have the dialogue file in a seperate module file that the script but thats by "_DLG" and "_S" Have you replaced TAG with the tag of your store object, and RESREF with the name of the UTM file containing its template? Link to comment Share on other sites More sharing options...
glovemaster Posted April 5, 2007 Author Share Posted April 5, 2007 I think i have found the problem, im using "GetPcSpeaker()" and the speaker is the computer.. lol I'll change it so that the script executes on a line where my PC is speaking Link to comment Share on other sites More sharing options...
stoffe Posted April 5, 2007 Share Posted April 5, 2007 I think i have found the problem, im using "GetPcSpeaker()" and the speaker is the computer.. lol I'll change it so that the script executes on a line where my PC is speaking GetPCSpeaker()is the player character that an NPC is in conversation with. OBJECT_SELF is the NPC that "owns" the dialog (i.e. the one that has it set in its template who the player clicked on to start conversation, or the one running an ActionStartConversation() action). It doesn't matter if the script is run from an Entry or Reply node. If the script isn't run inside a conversation you should use GetFirstPC() or GetObjectByTag() instead. Link to comment Share on other sites More sharing options...
glovemaster Posted April 5, 2007 Author Share Posted April 5, 2007 Thanks i've got that all sorted now Thanks again! ~GM Link to comment Share on other sites More sharing options...
glovemaster Posted April 5, 2007 Author Share Posted April 5, 2007 Does any one know if it would be possible to change the weather from a script? Link to comment Share on other sites More sharing options...
stoffe Posted April 5, 2007 Share Posted April 5, 2007 Does any one know if it would be possible to change the weather from a script? There are no functions to modify the weather in an area in the KOTOR version of NWScript, as far as I know. NWN has such functions, but since weather works differently in TSL (it can be set independently for rooms) those functions are missing here. Only way I can think of would be to have two otherwise identical areas with different weather and switch transitioning between them depending on what weather should be used. Though that's quite a bit of work if it doesn't have any bearing on the story. Link to comment Share on other sites More sharing options...
glovemaster Posted April 5, 2007 Author Share Posted April 5, 2007 Ah thanks, that should work aswell. Thanks.. again! Link to comment Share on other sites More sharing options...
glovemaster Posted April 6, 2007 Author Share Posted April 6, 2007 does any one know how to check if the PC has an item? Thanks! GM Link to comment Share on other sites More sharing options...
stoffe Posted April 6, 2007 Share Posted April 6, 2007 does any one know how to check if the PC has an item? int ST_HasItem(string sTag, object oOwner=OBJECT_SELF) { return GetIsObjectValid(GetItemPossessedBy(oOwner, sTag)); } void main() { if (ST_HasItem("[color=Yellow]MyItemTag[/color]", GetFirstPC())) { // Player has the item with the tag MyItemTag. } } Replace MyItemTag with the tag of the item you want to check for. Link to comment Share on other sites More sharing options...
glovemaster Posted April 6, 2007 Author Share Posted April 6, 2007 Thank you! Link to comment Share on other sites More sharing options...
glovemaster Posted April 7, 2007 Author Share Posted April 7, 2007 Last question, (i hope) I need a script to make sure that the party leader has not got an item. I'm using this script: void main() { GetIsObjectValid(GetItemPossessedBy(GetPartyLeader(), "my_item")) == FALSE; } It compiles properly so i assume its a working script, but its not doing the job.. Also, can someone check this over for me please? void main() { CreateItemOnObject( "my_item", GetPartyLeader(), 1 ); } Thanks, GM Link to comment Share on other sites More sharing options...
stoffe Posted April 7, 2007 Share Posted April 7, 2007 Last question, (i hope) I need a script to make sure that the party leader has not got an item. Do you mean that the character should have the item equipped in one of their inventory slots, or just in the "backpack" inventory? Also, part members share the inventory of the main character while they are in the party. The GetPartyLeader() function will return the character that the player is currently in control of, which is not necessarily the main character (Revan/Exile), it could be another party member that the player has clicked on the portrait of, or used tab to switch to. Thus, as long as they are in the party you should check the inventory of the main character (GetFirstPC()) instead, unless you are looking for an item equipped in an inventory slot. If this is to be used in dialog keep in mind that you're always in conversation with the main character regardless of which party member you control when you initiate conversation with some NPC. Link to comment Share on other sites More sharing options...
glovemaster Posted April 7, 2007 Author Share Posted April 7, 2007 Thanks Stoffe but It doesnt seem to be working. I've just read through it this thread and i must admit, i havent been very clear.. Which i guess isn't always helpful :S. I want to give the PC an item from a terminal (dialogue). But i want it so that the PC can't get the item more than once. On the dialogue node i have the conditional script: void main() { GetIsObjectValid(GetItemPossessedBy(GetFirstPC(), "[color=red]item[/color]")) == FALSE; } So that the PC can only select that option if they dont have the item And then from that node i use the script: void main() { CreateItemOnObject( "[color=red]item[/color]", GetFirstPC(), 1 ); } Im note sure if the give item script is correct as i am not getting the option in the dialogue. Can someone please correct me? Thanks, GM Link to comment Share on other sites More sharing options...
stoffe Posted April 7, 2007 Share Posted April 7, 2007 On the dialogue node i have the conditional script: void main() { GetIsObjectValid(GetItemPossessedBy(GetFirstPC(), "[color=red]item[/color]")) == FALSE; } So that the PC can only select that option if they dont have the item That's not a valid conditional script, since the main() function does not return anything (void). Conditional scripts must use a StartingConditional() function instead and return true or false. Like: int StartingConditional() { return !GetIsObjectValid(GetItemPossessedBy(GetFirstPC(), "item")); } That script would make the dialog node it's called from available it the player does not have an item with the tag item in their inventory. Link to comment Share on other sites More sharing options...
glovemaster Posted April 7, 2007 Author Share Posted April 7, 2007 Thanks, that worked perfectly! Link to comment Share on other sites More sharing options...
glovemaster Posted April 10, 2007 Author Share Posted April 10, 2007 this isn't a script but, would it be possible to add option to the menu on a door with "security" and those options? Im guessing i have to edit a 2da file? lol Link to comment Share on other sites More sharing options...
Pavlos Posted April 10, 2007 Share Posted April 10, 2007 this isn't a script but, would it be possible to add option to the menu on a door with "security" and those options? Im guessing i have to edit a 2da file? lol I'm not sure what you mean. Do you want to know how to lock the door? If so: Open up your UTD (your door) in KotOR Tool and click on the "Lock" tab. Check the box labelled "Locked" and then you can set the DC of the lock to increase or decrease the security skill level required to open it. Link to comment Share on other sites More sharing options...
glovemaster Posted April 10, 2007 Author Share Posted April 10, 2007 I mean when you target/hover cursor over a door, you get an option selectable by "2" on the keyboard (by default) and it has options such as "security", I want to add an option to the menu, is that possible? I can't find a 2da file for it? Link to comment Share on other sites More sharing options...
Pavlos Posted April 10, 2007 Share Posted April 10, 2007 I mean when you target/hover cursor over a door, you get an option selectable by "2" on the keyboard (by default) and it has options such as "security", I want to add an option to the menu, is that possible? I can't find a 2da file for it? Provided the door has a faction of Hostile_1 (Hostile_2 should work fine too, though) and is locked then all the correct menus (bash, unlock, mine) should fill in. Link to comment Share on other sites More sharing options...
glovemaster Posted April 10, 2007 Author Share Posted April 10, 2007 So how would you add an option to the menu? So you would have: unlock, bash, *custom*, etc.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.