Skip to content

Making a door check for an item

Ugly_DuckUgly_Duck Member Posts: 179
edited April 2022 in Builders - Scripting
This is probably the simplest thing in the world, but I'm clueless (again). I'm trying to make a door start a conversation with the PC; this part I got. Next, check the PCs inventory for a particular item, a guild insignia. If the PC has it, teleport the PC to the waypoint (WP_INSIDE_GUILDHOUSE_001) inside the guild house. If he doesn't have the item, deny access and say something silly in the conversation like, "Bugger off! Ye ain't allowed in!".

Another thing, this is with the conversation editor. I don't know how to make different text for options, such as the above. Where the conversation has 3 outcomes:
1.) (Checks inventory & HAS the item) "Yes, I have the item."
2.) (Checks inventory & DOESN'T have the item) "No, I don't have the item."
3.) Do nothing & walk away.

I searched the lexicon for "Talking Doors" and nothing showed up.

Also, have the PC KEEP the item used to enter the guild house.

Comments

  • NeverwinterWightsNeverwinterWights Member Posts: 339
    edited April 2022
    Click on a line in the conversation that you want to show up conditionally. If you look over to the left there are tabs, it should be on the "text appears when...". If you look down a little from there you will see the script drop box and then to the left of that a little wizard hat. If you click the wizard hat it can guide you through what you need and make the script for you.
  • sunxresunxre Member Posts: 23
    So, for the script under text appears when
    //int's are whole numbers. Can be both negative and positive. Since this is old. There are no boeans(true or false). So any positive (above 0) is true, and 0 is false.
    
          
    Int StartingConditional()
    {
      object player = GetLastSpeaker(); 
      object item = GetFirstItemInInventory(pc); //literally item is equal to the first item in inventory.
    //saves the first item onto the variable
      while(GetIsObjectValid(item)) //while loop function. Literally keeps repeating everything 
    //between the { } under it until the condition is false
      {
        If(GetTag(item) == "whatever tag you gave it")
        {  
          return TRUE; //this function is essentially a variable, like the objects above. 
    //This basically gives a value to the variable, and stops reading the rest of this functions code. 
    //Return = stop reading lines in function, and return to previous operation.
        }
        Item = GetNExtItemInInventory(); // finds the item after whatever the previous item was
      }
      return FALSE; //once the above code finally finds an inventory slot with no valid item. The very next line is run. Which happens to return false.
      
    }
    
  • MelkiorMelkior Member Posts: 179
    One of the handiest tools you can use for conversation with a door is the Invisible Object. You place one just inside the door and then give it the name of the character who your PC is supposed to be communicating with (eg Door Guard) and in the conversation file, use the tag of the invisible object instead of the tag for the door as the one the PC is talking to.

    Something I've found useful is to see how the OC did stuff like this. You just copy the appropriate chapter of the OC to the "modules" folder and then rename the extension to .mod so that the toolset can "see" it. You can then open the OC, open the area where you know it did something similar and see how it was done so you can copy and adapt it.
  • MelkiorMelkior Member Posts: 179
    After thinking about it, there are several simpler ways of doing this, depending on your requirements.
    I'm assuming this is for multi-player because the simplest way of doing it for single-player is just to use the guild token as the key to unlock the door.
    One way of doing it for multi-player is to allow anyone to open the door but then use the OnTransitionClick to deny non-members entry to the building, optionally with a message.
    Another way is to use the OnFailToOpen script to check if the person attempting to open the door is holding the guild token and if they are, send the person inside the guild.
    Both of these approaches to the problem are simpler to script and also faster for the player than having to go into a conversation.
  • TarotRedhandTarotRedhand Member Posts: 1,481
    @Ugly_Duck three links you may find useful -

    NwN Lexicon 1.69 - Searchable chm document with all the pre-EE script functions explained.
    Online lexicon list and explanation of all the new EE functions.
    Just The FAQs, ma'am - Contains the scripting Frequently Asked Questions (with answers) in pdf format.

    TR
Sign In or Register to comment.