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.)

Neverwinter Nights Forum Update

Discussion in 'Game/SP News & Comments' started by NewsPro, Jun 28, 2002.

  1. NewsPro Gems: 30/31
    Latest gem: King's Tears


    Joined:
    May 19, 2015
    Messages:
    3,599
    Likes Received:
    0
    (Originally posted by Z-Layrex)

    David Gaider, Designer

    Templates: I think that's one of the scripts used for the generic script templates. There are a number of templates which we used which form an easy base for a number of basic quests... there's a fetch quest, rescue quest, assassination quest, etc. These have template dialogues, template NPCs and use a set of scripts which you will see all over the script database (nw_c2_assvict1 for the assassination victim, nw_d2_j_assa01 for one of the assassination plotgiver's dialog scripts, nw_d2_j_fetch01 for one of the fetch plotiver's dialog scripts, etc.) These scripts are set up to work in a very specific manner, with the user only needing to plug values in a few places and adjust the template dialogue to suit them. They won't work well otherwise... that escort script, for example, is setting a variable which is looked for by the rescued prisoner's template dialogue file. Not much use to you unless you have that. The description on the script should probably mention that it's not a general 'follow the PC' script and just for a specific plot where an NPC follows the PC, but it's not incorrect. (Incidentally, I imagine these template plots are being prepped-up with sufficient documentation and will be released for you all to use at some point. I don't know that for sure, but it'd be a waste of all the work we did on 'em otherwise.)

    Follow Scripts: I don't know how to do follow scripts, I'm afraid. We used to have an ActionFollow command, but it was probably taken out because it didn't work very well. All I could suggest is that you use the OnHeartbeat event to have the NPC check if GetDistanceToObject (the PC) is greater than a certain amount... if so, then ActionMoveToObject.Might also want to add in there, that if that distance becomes too large, then ActionJumpToObject (like the henchmen do sometimes). Otherwise, I'd suggest opening up the henchmen scripts and see how they follow.

    Generic AI: I wouldn't suggest altering the generic AI include unless you really, really have to. It shouldn't be necessary, anyway. If you go into your NPC's OnSpawn script, copy it and save it under a different name. Then uncomment the line 'SetSpawnInCondition (NW_FLAG_ON_DIALOGUE_EVENT);' and recompile the script. This sets up your NPC to fire a UserDefinedEvent # 1004 whenever someone 'shouts' near him. Now if I wanted that NPC to respond to the shout 'Come Here' when stated by the NPC's PC master (the identity of which is stored in an object variable on the NPC), I have to do the following:

    1) First, you need to tell your NPC which verbal commands to listen to. This would be added to the OnSpawn script using the SetListenPattern command.

    2) Then, in the OnUserDefined script, you want to GetListenPatternNumber() and see if it matches up with the integer set in the OnSpawn.

    So, for 'Come Here', I'd need to make sure that the proper SetSpawnInCondition line was uncommented for the OnDialogue event and the following line added:

    SetListenPattern (OBJECT_SELF, "Come Here", 100);

    Then I could add this as my OnUserDefined script:

    void main()
    {
    int nEvent = GetUserDefinedEventNumber();
    if (nEvent == 1004) // OnDialogue Event
    {
    int nMatch = GetListenPatternNumber();
    object oMaster = GetLocalInt(OBJECT_SELF, "Master");
    object oShouter = GetLastSpeaker();
    if(nMatch != -1 && GetIsObjectValid(oShouter) && GetIsPC(oShouter) && (oShouter == oMaster))
    {
    if (nMatch == 100) // Come Here: NPC moves to PC
    {
    ClearAllActions();
    ActionMoveToObject(oShouter, TRUE, 2.0);
    }
    }
    }
    }


    Sharing Variables: First you have to use a SetLocal command to actually set the variable on an object... then you can use a GetLocal command from any script to retrieve it. Let's say you wanted to set the "Alive" string variable to be equal to the PC's name (not sure why you're using GetAttackTarget, but I'll go with that). Let's say you want it to be set module-wide. You would set it by doing this:

    SetLocalString (GetModule(), "Alive", GetName(OBJECT_SELF));

    Then from any other script, you could retrieve that string from the module:

    GetLocalString (GetModule(), "Alive");

    Generally, however, when getting a variable, you want to use it in the context of a definition:

    string sName = GetLocalString (GetModule(), "Alive");

    That way in the new script the variable sName would be equal to the name of the PC in the original script.


    Scripting: If I wanted a wolf to flee when it reached a certain damage point:

    1) Copy it's OnSpawn script and re-save it under a new name. Uncomment the 'OnDamaged' flag (the 'SetSpawnInCondition (NW_FLAG_DAMAGED_EVENT);' line).

    2) In the OnUserDefined section, put a script that does something like the following:

    (nwscript)
    void main()
    {
    int nEvent = GetUserDefinedEventNumber();
    if (nEvent == 1006) // OnDamaged event
    {
    int nCurHP = GetCurrentHitPoints();
    int nMaxHP = GetMaxHitPoints();
    if ((nMaxHP/2) < nCurHP) // if at less that 50% HP
    {
    // clear actions and flee to exit waypoint
    ClearAllActions();
    ActionMoveToObject (GetWaypointByTag("oExit"), TRUE);
    // don't accept any more input from AI scripts
    SetCommandable (FALSE);
    }
    }
    }


    Custom Tokens:

    Quote: i.e. You have a SetCustomToken( int nToken, string sText ), but no GetCustomToken(int nToken). Can I, instead call GetLocalInt(GetModule(), "CUSTOM" + nToken), or is there some other cunning incantation?

    No, there is no GetCustomToken. Custom tokens are only for use in dialogue. Once set, they are global, but it's up to you to track what custom tokens you have.


    Dragons: It should be easier to use the special abilities in possession with the 1.19 patch (and the regular AI should have your creatures using them normally, as well). Would have been nice to have the DM faction/PvP bug fixed for 1.19, as well, but we're still working on it. That one's a very high priority to get fixed asap.
     
    Last edited by a moderator: Jan 4, 2018
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.