1. SPS Accounts:
    Do you find yourself coming back time after time? Do you appreciate the ongoing hard work to keep this community focused and successful in its mission? Please consider supporting us by upgrading to an SPS Account. Besides the warm and fuzzy feeling that comes from supporting a good cause, you'll also get a significant number of ever-expanding perks and benefits on the site and the forums. Click here to find out more.
    Dismiss Notice
Dismiss Notice
You are currently viewing Boards o' Magick as a guest, but you can register an account here. Registration is fast, easy and free. Once registered you will have access to search the forums, create and respond to threads, PM other members, upload screenshots and access many other features unavailable to guests.

BoM cultivates a friendly and welcoming atmosphere. We have been aiming for quality over quantity with our forums from their inception, and believe that this distinction is truly tangible and valued by our members. We'd love to have you join us today!

(If you have any problems with the registration process or your account login, please contact us. If you've forgotten your username or password, click here.)

Scripts & variables

Discussion in 'Neverwinter Nights (Classic)' started by Disciple of The Watch, Dec 26, 2006.

  1. Disciple of The Watch

    Disciple of The Watch Preparing The Coming of The New Order Veteran

    Joined:
    Aug 20, 2005
    Messages:
    7,024
    Likes Received:
    38
    Gender:
    Male
    I'm working on a module for NWN1, and while I grasp the basics, the module requires a couple of things that are out of my talent range. Here's what I need to setup:

    Shops: It's fairly easy to set up a shop, yeah, but seeing +3 weapons for sale when you're level 1 just doesn't fit. Here, A script or variable that would adjust the stuff for sale based on the PC's level's what I need on that one.

    Random encounters: To stay true to the concept of the game that inspired me to do the module, I need to stamp some random encounters on the world map.

    Keys/doors: Some areas I'm working on will require a specific key, and the door won't open unless you have that specific key (and also indestructible), to maintain continuity and avoid sequence breaking the plot. Also, can a non-key item be used to open a door, break a seal or some such?

    Loading a different map: At the end of the plot, the town is deserted and destroyed, and I was wondering if there was some way I could set up something that will load the destroyed city once a particular condition is met, if it's possible.

    That's what I have left to do on the checklist. If any of you happen to have an idea on one or more of those things, feel free to share it...
     
  2. Harbourboy

    Harbourboy Take thy form from off my door! Veteran Pillars of Eternity SP Immortalizer (for helping immortalize Sorcerer's Place in the game!)

    Joined:
    May 29, 2003
    Messages:
    13,354
    Likes Received:
    99
    Sounds cool! Unfortunately, I can't help with any of the above, although I'd be happy to test it for you (that's about the only thing I'd be any good at).
     
  3. Disciple of The Watch

    Disciple of The Watch Preparing The Coming of The New Order Veteran

    Joined:
    Aug 20, 2005
    Messages:
    7,024
    Likes Received:
    38
    Gender:
    Male
    You want to test it? Well, TBH, I didn't planned on releasing it - this was just a project I began to work on out of boredom, and I put some work on it when I have some time to kill.

    To be viable for release (supposing I ever do, this is based on an existing game and copyright issues likely would bite me in the ass), there are many things that need to be done, including the list about which I asked some help about... not to mention it's about 5% done... I still have a LOT of areas to build, quests and whatnots to code and rough edges to polish.

    But I'll keep your offer in mind nontheless, Harby.
     
  4. Sir Fink Gems: 13/31
    Latest gem: Ziose


    Joined:
    Aug 28, 2005
    Messages:
    576
    Likes Received:
    4
    The key thing I'm sure is doable, at least in the sense that you could change the icon of the key to something other than a key. Purely cosmetic but I suppose it would suit your purposes.

    The merchant thing, while I'm sure it's do-able, sounds a bit overly complex. Why not just set the level range for your module and stock merchants accordingly? Do you really want to make a module suitable for levels 1 through 15 or something?

    I'm certain the loading a different map can be done as I did just that with a module I was working on but stopped. It's been awhile though and I just can't remember how I did it.

    I'd suggest you head over to nwvault.com and search around in their database of scripts. It's chock full of good stuff that is free to download and use as you wish.
     
  5. Alavin

    Alavin If I wanted your view, I'd read your entrails Veteran

    Joined:
    Aug 26, 2003
    Messages:
    930
    Likes Received:
    0
    I don't have NWN installed on this computer; only my one in Leeds can run it properly, and I'm at home for Christmas. If you're willing/able to wait until 6th Jan, I can demonstrate exactly how to do them. Otherwise, here's the basic approach:

    Shops: an in-dialogue script that returns the levels the PCSpeaker has, then calls up an appropriate store. Pseudocode:

    if(GetHitDice(GetPCSpeaker()) > 4)
    {
    ActionOpenStore(I can't remember how this function works... or if this is even the proper name; this is for the higher level store);
    }
    else { ActionOpenStore(basic store); }

    Random Encounters: create maps for each encounter, and add a waypoint to each with a unique tag (eg WP_ENC_1). Use a random function to get a random number, and then use a switch statement to say what each number means. Pseudocode:

    int point = Random(10);
    if(GetIsPC(GetEnteringObject()) //Ensures only the PC changes location; assumes the transition is a trigger
    switch(point): //I think this is the syntax; I have a bad memory for this sort of thing
    {
    case 0:
    AssignCommand(GetEnteringObject(), ActionJumpToObject(GetWaypointByTag("WP_ENC_1")));
    case 1:
    AssignCommand(GetEnteringObject(), ActionJumpToObject(GetWaypointByTag("WP_ENC_1")));
    etc
    }

    Keys require no scripting at all. Go to the Lock tab of the door properties, and select that a key is required. Enter the key's tag where specified.

    Loading a new map: simple variable check. Set a variable to 1 when the town is destroyed, and in the transition script check that variable; if it's 0, go to the undestroyed town, and if it's 1, go to the destroyed.

    I wouldn't advise using the pseudocode as is; it almost certainly won't compile, and is for guidelines only. In a week I can help much more.
     
  6. Disciple of The Watch

    Disciple of The Watch Preparing The Coming of The New Order Veteran

    Joined:
    Aug 20, 2005
    Messages:
    7,024
    Likes Received:
    38
    Gender:
    Male
    What I had in mind for the shops was that, just like in the game which inspired the mod to me, is that the goods offered are determined by the PC's level.

    To further stay true to the spirit, I'm designing the mod to be suitable to a newly created level 1 PC, and I'm not sure about the highest suitable level. It's 11 in the original game, but once level 5 or so is past levels are horribly slow to gain, so I would say that the max level would roughly compare to level 16 in NWN.

    However, I was also considering a higher level "expansion" of some kind, as I always found that the game had quite many loose ends that could have made extra material. I'm not sure as of now, it'll depend on how the original project turns out.

    Sounds good to me. This project was originally built to kill time, and I have much left to do that do not require scripting or variables, so I have plenty of work cut out for me.
     
  7. Taza

    Taza Weird Modmaker Veteran

    Joined:
    Oct 23, 2002
    Messages:
    1,447
    Likes Received:
    25
    Alavin's advice is overall good.

    However, you can also add items based on some variables on the shop, a script to check PC level compared to triggered variables and adding items by resref.

    Basically:
    And you can also have random encounters with random creatures - use a script with CreateObject() and some method to randomly pick among them - generally, a switch/case and d100() should do the trick.
     
  8. Alavin

    Alavin If I wanted your view, I'd read your entrails Veteran

    Joined:
    Aug 26, 2003
    Messages:
    930
    Likes Received:
    0
    Right, here's stuff more likely to work:

    For the store, there are two options: Appraise checks, or no appraise checks. For appraise checks, use:

    #include "nw_i0_plot"
    void main()
    {
    if(GetHitDice(GetPCSpeaker()) > 4)
    gplotAppraiseOpenStore(GetNearestObjectByTag("Store_High"), GetPCSpeaker());
    else
    gplotAppraiseOpenStore(GetNearestObjectByTag("Store_Low"), GetPCSpeaker());
    }

    Put this as the script action in a conversation at the relevant point. If you don't want to use Appraise:

    void main()
    {
    if(GetHitDice(GetPCSpeaker()) > 4)
    OpenStore(GetNearestObjectByTag("Store_High"), GetPCSpeaker());
    else
    OpenStore(GetNearestObjectByTag("Store_Low"), GetPCSpeaker());
    }

    In both scripts, change the level and store tag as needed. Make sure you place all stores, or they won't open.

    Taza's approach also probably works, but it's not a method I've played with.

    Random Encounters: Taza's way is better. Create an area for your encounter (multiple areas are reasonably simple, but I'll just use one for my example). Create waypoints for each place you'd like creatures to appear, plus one for the player to appear on. In the area transition script, put something like this:

    void main()
    {

    int point = Random(10);
    if(GetIsPC(GetEnteringObject()))
    switch(point)
    {
    case 0:
    AssignCommand(GetEnteringObject(), ActionJumpToObject(GetWaypointByTag("WP_ENC_1")));
    CreateObject(OBJECT_TYPE_CREATURE, "orc", GetLocation(GetWaypointByTag("ENC_SP_1")));
    CreateObject(OBJECT_TYPE_CREATURE, "orc", GetLocation(GetWaypointByTag("ENC_SP_2")));
    case 1:
    AssignCommand(GetEnteringObject(), ActionJumpToObject(GetWaypointByTag("WP_ENC_1")));
    CreateObject(OBJECT_TYPE_CREATURE, "giant", GetLocation(GetWaypointByTag("ENC_SP_1")));
    }
    }

    Change waypoint tags as needed, and creature resrefs. Add more cases as needed, up to 9 in this case.

    Adding a selection of areas for this isn't too hard. Just make more areas, with waypoints with unique tags, and add cases for them.

    For the others, see my post above.
     
Sorcerer's Place is a project run entirely by fans and for fans. Maintaining Sorcerer's Place and a stable environment for all our hosted sites requires a substantial amount of our time and funds on a regular basis, so please consider supporting us to keep the site up & running smoothly. Thank you!

Sorcerers.net is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to products on amazon.com, amazon.ca and amazon.co.uk. Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.