NWN2

NWN2 specific content.

Downloads

Since the 1.23 update, all Player side downloads are done via the NWN2 Auto-Downloader.  Simply log into your server and NWN2 will automatically download all the haks and pwc files for you.

Builders

If you are wishing to build for ALFA, please read this page:

Technical / Rewarding Experience

So, if you're going to be writing your own scripts that reward XP, there are a few functions in acr_xp_i that should be all that you need:
 

//! Award XP to oPC for completing a static quest of some sort.
void ACR_AwardStaticQuestXP(object oPC, string sPlotID, int nQuestXP);

//! Awards XP to the party which oPCParty is a member of, for killing oKill.
void ACR_AwardCombatXP(object oPCParty, object oKill);

//! Awards XP to a PC for overcoming a specific challenge which could have
//! lethal consequences.
void ACR_AwardLethalChallengeXP(object oPC, float fCR);

//! Awards XP to a PC for overcoming a specific challenge.
void ACR_AwardNonlethalChallengeXP(object oPC, float fCR);



The comment lines should cover most of what they do, but one that's enticingly hanging out in the open is this fellow:
 

//! Gives nXpAmount to oCreature.
//! This function, and none other, must be used whenever XP is directly given to
//! a PC. Any other function may not work reliably, if at all.
//! NOTE: LOGGING WILL NEED TO BE HANDLED BY THE CALLING APPLICATION
void ACR_GiveXPToPC(object oPC, int nXpAmount);


So, firstly, the original author's line wherein caps lock is cruise control for cool covers why this one is dangerous. Particulrly-advanced coders, with familiarity with our database and such, shouldn't be afraid to use this, but should approach knowing that they'll be responsible for their own logs, and that Hialmar might make them upgrade the parser to provide results to less-technically-inclined people who may need to review them in the course of their work (knowing how to write SQL queries is not prerequisite for the PA position or for any PA staff positions, and we're in very big trouble as a community if it ever becomes one)

So, running down the others-- first example, we've reached a point in a conversation where we're providing a simple quest reward; we're not tracking this in a journal-- we didn't update any "quest states". This guy just has a standing thing in his conversation, like a gang rivalry-- the Jets will pay if you rough up any of the Sharks. They might even sing you a song:
 

void main()
{
    ACR_AwardStaticQuestXP(GetPCSpeaker(), "BeatUpTheJets", 20);
}



Second example-- you've killed something that tried to kill you back. The ACR will be trying to catch all of these itself, and any creature killed by conventional combat should be so handled-- but if you have any special unique circumstances wherein a creature is being killed as part of a legitimate challenge, but the instrument of death wasn't in the core mechanics (systems that manage sea combat would be the standard example of this) you'd probably be looking at...
 

void KillCreatureWithOddTool(object oKiller, object oKilled)
{
   if(!GetIsPC(oKilled)) // let's make sure no one exploits this for CvC, hmm?
   {
      ACR_AwardCombatXP(oKiller, oKilled);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oKilled);
   }
}



Third and fourth examples would be used in similar fashion-- and would be catch-alls for things that give XP but don't fit into any other possible category in the ACR. They award XP as if you killed a creature of fCR, with the difference being in how they're logged (lethal challenge or nonlethal challenge)-- so this can be used for things that highbies shouldn't get much reward for: that DC 20 trap is hair raising for a level 1, but a level 15? Deserves 1 xp, if any.
 

void main()
{
   ACR_AwardLethalChallengeXP(GetLastUsedBy(), 2.0f);
}

 

Technical / Connecting to the MySQL Database (NWNX4)

  1. THIS PAGE IS SERIOUSLY OUT OF DATE REFER TO https://www.alandfaraway.info/wiki/Basic_Host_Requirements FOR MORE CURRENT INSTRUCTIONS
  2. Download and extract the following NWNX4 files from the link below to a dedicated folder on your host machine (eg. C:\NWNX4):

  3. NWNX4_Controller.exe
    NWNX4_GUI.exe

    madCHook.dll
    NWNX4_Hook.dll
    xp_mysql.dll
    xp_time.dll

    nwnx.ini
    xp_mysql.ini

    http://nwnx.org/index.php?id=nwnx4
     
  4. Copy the madCHook.dll file to your Neverwinter Nights 2 game folder (where the game installed itself).
     
  5. You will need to configure nwnx.ini with your module and game information. The most important line is the parameters entry:

    parameters = -module "My Module" -servervault 1 -publicserver 1

    If you prefer to launch your module in directory mode, use the -moduledir paramater in place of -module.
     
  6. You will need to configure xp_mysql.ini with the correct connection details for the remote database server. Please contact the IA, TA, or DMA for that information.
     
  7. Once you have the file configured, you can launch your server using the NWNX4_GUI.exe program (NOT nwn2server.exe as you normally would). It will automatically launch nwn2server for you.

    Alternatively, you can install NWNX4 as a service on your host machine by issuing the following commands in your NWNX4 folder (only recommended for advanced users):

    NWNX4_Controller.exe -installservice
    NWNX4_Controller.exe -startservice

    NWNX4 will show up as a Windows service, which can be started and stopped like any other service on your machine (via Services in Administrative Tools). You can enable the nwn2server dialog window by navigating to the NWNX4 service, clicking on its properties, selecting the "Log On" tab, and checking the "Desktop Interaction" box.

    Other service commands you can issue using NWNX4_Controller.exe:

    -serviceno Specify service instance number
    -stopservice Stop the NWNX service
    -uninstallservice Uninstall the NWNX service
    -interactive Start in interactive mode
     
  8. Note: NWNX logs are recorded in the nwnx.txt file, and MySQL logs are recorded in the xp_mysql.txt file in the install folder. These will help you identify any configuration or run time sql problems (like bad queries).

Technical / Building ACR Compatible Doors

While the basemod contains every door listed in the DMG with appropriate settings, builders may wish to create their own doors. ALFA has scripts which provide a number of mechanics not ordinarily found in NWN, and every door has an extra set of options because of this.

As with creating new creatures, items, and so forth, the easiest way to make a new door is to copy/edit an existing one. For information on editing the settings of an existing door, skip the next section.

Creating a new door. If you aren't editing an existing door, you will have to configure a number of options. To start off with, you'll need to make sure all of the door's event scripts are set correctly. ALFA's event scripts for doors are as follows: // Update for longer NWN2 file names

  • acf_door_onclosed
  • acf_door_onconversation
  • acf_door_ondamaged
  • acf_door_ondeath
  • acf_door_ondisarm
  • acf_door_onheartbeat
  • acf_door_onlock
  • acf_door_onmeleeattacked
  • acf_door_onopen
  • acf_door_onspellcastat
  • acf_door_ontraptriggered
  • acf_door_onunlock
  • acf_door_onused
  • acf_door_onuserdefined
  • acf_door_onclick
  • acf_door_onfailtoopen

If you want to add custom event scripts to your doors, you can of course do so. Just make sure each event script includes the file acr_door_i, and calls the appropriate function for that event, listed here.

  • ACR_DoorOnClosed()
  • ACR_DoorOnConversation()
  • ACR_DoorOnDamaged()
  • ACR_DoorOnDeath()
  • ACR_DoorOnDisarm()
  • ACR_DoorOnHeartbeat()
  • ACR_DoorOnLock()
  • ACR_DoorOnMeleeAttacked()
  • ACR_DoorOnOpen()
  • ACR_DoorOnSpellCastAt()
  • ACR_DoorOnTrapTriggered()
  • ACR_DoorOnUnlock()
  • ACR_DoorOnUsed()
  • ACR_DoorOnUserDefined()
  • ACR_DoorOnClick()
  • ACR_DoorOnFailToOpen()

Again, the easiest way to do this is to edit an existing acr_door_* file and save it under a different name. Failure to properly call ALFA's door scripts can break multiple systems of the ACR. So make sure you've got them in there.

Editing a door's settings: Aside from the standard NWN options of doors, we've provided a few more to give PCs and builders more options. These options can be accessed by editing the door's local variables. They are as follows: (For information on what local variables are, and how to edit them, go here: Using Local Variables in the NWN2 Toolset)

ACR_DOOR_CLOSE_DELAY (float) The number of seconds a door will stay open before automatically closing itself. If set to zero or less than zero, the door will not close itself automatically.

ACR_DOOR_CLOSE_NEAR_PCS (integer) If set to 1, the door will auto-close regardless of any nearby PCs. If set to 0 (the default), the door will wait until PCs are out of visual range before closing itself.

ACR_DOOR_STUCK_DC (integer) If non-zero, the door is considered "stuck", and therefore cannot be opened unless forced. The value defined is the strength-check DC to "un-stick" the door. If someone tries to force a locked and stuck door open, the strength DC used is the higher of this value and ACR_DOOR_BREAK_DC. The default value is 0.

ACR_DOOR_BREAK_DC (integer) The DC to break open this door, as per DMG rules. Breaking open a door does not destroy it like doing damage to it would in NWN, but it does keep the door from being able to be locked again. If this value is zero, the door cannot be forced open. Valid values are from 0 to 255.

ACR_DOOR_FAIL_OPEN_MESSAGE (string) This is a custom message sent to PCs who try to open the door and fail. This can be used in conjunction with ACR_DOOR_UNLOCK_PASSWORD to setup doors that require a spoken password to access (even useful for door riddles).

ACR_DOOR_OPEN_MESSAGE (string) This message is "spoken" by the door when it is opened. It is usually used to give the PCs a description of the area beyond an AT, if any.

ACR_DOOR_UNLOCK_HOUR (integer) This is the time of day (in hours) the door unlocks itself. Generally used for shops and things which are only open during certain hours of the day. It will only unlock once, so if something else locks it afterwards, it will remain locked until either another creature unlocks it, or its next unlock time. Valid values are 0 to 23. If you don't wish the door locking or unlocking itself automatically, leave both this variable and ACR_DOOR_LOCK_HOUR set to 0 (the default value).

ACR_DOOR_LOCK_HOUR (integer) This is the time of day (in hours) the door locks itself. Generally used for shops and things which are only open during certain hours of the day. It will only lock once, so if something else unlocks it afterwards, it will remain unlocked until either another creature locks it, or its next lock time. Valid values are 0 to 23. If you don't wish the door locking or unlocking itself automatically, leave both this variable and ACR_DOOR_UNLOCK_HOUR set to 0 (the default value).

ACR_DOOR_UNLOCK_SPELLID (int) This is the Spell ID for doors that require a specific spell to unlock. This will only work for spell IDs greater than 0. Be sure to set the door's default lock status to locked.

ACR_DOOR_UNLOCK_PASSWORD (string) This is what a player must speak to gain access to a password protected door. Leave this empty to require no password. Otherwise, be sure to set the door's default lock status to locked.

ACR_DOOR_AUTO_LOCK (integer) If non-zero, the door will automatically lock itself each time it is shut.

ACR_DOOR_LISTEN_DC_MOD (integer) This modifier is applied to creatures trying to listen to conversations occuring behind a closed doors. The DMG lists this a +5 for every door, but some customization is allowed for different door types. If undefined or set to 0, the door cannot be listened through.

ACR_DOOR_KNOCK_IMMUNE (integer) If nonzero, this door is immune to the spell knock. If zero, it is not immune.

ACR_DOOR_UNMOVABLE (integer) If nonzero, the door cannot be opened or closed by a non-DM creature, even if unlocked. Scripts can still open or close it, however. This setting is often used to represent large doors which a PC could not realistically close on their own even if they were unlocked, like the huge gates on castles and other fortifications.

ACR_AT_SIZE (integer) If nonzero, this setting specifies the maximum sized creature which can fit through this doorway. Anything large will be given a message saying it is too large to fit inside. Valid values are as follows:

  • 1 = Fine
  • 2 = Diminutive
  • 3 = Tiny
  • 4 = Small
  • 5 = Medium
  • 6 = Large
  • 7 = Huge
  • 8 = Gargantuan
  • 9 = Colossal

Note that currently, NWN2 does not support creature sizes of fine, diminutive, gargantuan or colossal. These values are provided here for future compatibility.

Note that if none of these variables are defined, they default to zero. So a door without them would never close or lock itself, wouldn't be stuck or barred at all, would not be able to be forced open, and wouldn't have any sort of a custom message printed if a PC failed to open it.

Technical / Building ACR Compatible Items

All items should be priced according to 3.5 edition canon (Player's Hand Book, Dungeon Master's Guide, etc), and to the ALFA specific exceptions set forth by ALFA Standards. DO NOT MAKE ITEMS WORTH LESS THAN 1 GP YET! Our currency system for silver and copper pieces is not yet ready, and we may not know how it will work until we have the client in our hands.

Premise: An item should be identifiable from it's tag/resref.

<prefix>_it_<type>_<description>_<ID>

<prefix> is either "abr" (minus the quotes) for default ALFA items, or a three digit code of the server.

<type> is a three-letter abbreviation describing the slot occupied by the item.

<description> is the number of fields necessary to describe any additional properties on the item.

<ID> is an optional two-digit number used to distinguish items with identical properties. Leave the <ID> off of tags - it goes on resrefs only.

Item tags should NEVER be longer than 28 characters. The game allows 32, so don't use them all.

Scripting: For information on how to script items, go here.

Examples: A standard longsword would be, Tag: abr_it_wpn_longsword ResRef: abr_it_wpn_longword_01

TYPE

Ammunition amm Armor arm (includes shields) Boots boo Cloaks clk Gloves glv Helmets hlm Weapons wpn

DESCRIPTIONS

Materials

  • Abyssal Bloodiron ay
  • Adamantine ad
  • Alchemical Silver sa
  • Arandur aa
  • Astral Driftmetal as
  • Aurorum au
  • Bluewood bw
  • Cold Iron ci
  • Copper co
  • Darksteel dk
  • Darkwood (Zalantar) za
  • Dlarun dl
  • Dragonbone db
  • Dragonfang df
  • Dragonhide dh
  • Dragonscale ds
  • Duskwood du
  • Fever Iron fr
  • Fiendbone fb
  • Frystalline fy
  • Gold go
  • Hide hi
  • Hizagkuur hz
  • Laminated Steel ls
  • Living Metal lm
  • Mithral mi
  • Obsidian ob
  • Pandemonic Silver ps
  • Platinum pt
  • Serren se
  • Silver sv
  • Solarian Truesteel tr
  • Sondarr so
  • Suzailian Chainweave ch
  • Weirwood ww
  • Ysgardian Heartwire ys

Quality

  • Arcane Spell Failure -10% asf1
  • Drowcraft dc
  • Masterwork mw
  • Plus one e1
  • Poor po
  • Armour Class +1 ac1
  • Bonus Spell, Level 0 sb0
  • Bonus Spell, Levels 0, 1, 2 sb012
  • Damage Resistance 1 dr1
  • Damage Resistance 5/magic dr5m
  • Damage Resistance Fire 5 drf5
  • Feat: Alertness fale
  • Feat: Ambidexterity famb
  • Feat: Combat Casting fcca
  • Feat: Darkvision fdar
  • Feat: Dodge fdod
  • Feat: Extra Turning fext
  • Feat: Mobility fmob
  • Feat: Spell Focus (One) fsf1
  • Feat: Spell Penetration fpen
  • Feat: Two Weapon Fighting ftwf
  • Feat: Weapon Finesse fwfi
  • Spell Immunity, Level 0 si0
  • Spell Resistance 12 sr12
  • Freedom of Movement fom
  • Immunity: Death Magic ide
  • Immunity: Disease idi
  • Immunity: Drain idr
  • Immunity: Fear ife
  • Immunity: Gas iga
  • Immunity: Magic Missle imm
  • Immunity: Paralysis ipa
  • Immunity: Poison ipo
  • Save, Acid +1 sac1
  • Save, Cold +1 sco1
  • Save, Death +1 sde1
  • Save, Disease +1 sds1
  • Save, Fear +1 sfe1
  • Save, Fire +1 sfi1
  • Save, Fort +1 sfo1
  • Save, Mind +1 smi1
  • Save, Negative +1 sne1
  • Save, Poison +1 spo1
  • Save, Reflex +1 sre1
  • Save, Sonic +1 sso1
  • Save, Universal +1 sa1
  • Save, Will +1 swi1
  • Hide +1 hi1
  • Damage, Acid +1 da1
  • Damage, Bludgeoning +1 db1
  • Damage, Cold +1 dc1
  • Damage, Divine +1 dd1
  • Damage, Fire +1 df1
  • Damage, Magic +1 dm1
  • Damage, Negative +1 dn1
  • Damage, Piercing +1 dp1
  • Damage, Slashing +1 ds1
  • Damage, Sonic +1 do1
  • Feat: Cleave fcle
  • Feat: Disarm fdis
  • Feat: Improved Critical ficr
  • Feat: Point Blank Shot fpbs
  • Feat: Rapid Shot frap
  • Feat: Weapon Specialisation fwsp
  • Keen ke
  • Massive Criticals +1 mc1
  • Mighty +1 m1
  • Sure Striking sst
  • Vampiric +1 dv1
  • Wounding +1 dw1

CLASSIFICATION This is added in the toolset with a string seperated by the '|' character for each category. The HDMs of every server are free to make their own rules as too where items should be placed, but be aware the DM client cannot see more than one step "deep" into the category tree.

Technical / ACR Data Persistence

Data persistence API

The following functions are available for use in scripts to store persistent data (available across server resets). Be sure to delete any data that is no longer needed or to set expiration on data that you know will only be relevant for a fixed duration. This will help keep the size of the database down and minimize latency on queries (that can lag the game).

Note: NWNx4 must be installed and configured properly? on the host server for these functions to work.

This function executes an SQL statement. - sSQL: The SQL string to execute - Returns: Nothing void ACR_SQLQuery(string sSQL)

This function retrieves the next row of the result set returned by the most recent query. Call this before using ACR_SQLGetData(). - mode: Selects a result set in a multi set result
Leave the parameter empty to advance to the next row in the resultset.
Pass "NEXT" as parameter to fetch the first row of the next resultset. - Returns: SQL_SUCCESS if there is a row, SQL_ERROR if there are no more rows. int ACR_SQLFetch(string mode = " ")

This function retrieves the data in a specific column within the current row of the result set. - nCol: The index of the column to retrieve (max column size 65K) in the result row - Returns: The data in column nCol string ACR_SQLGetData(int nCol = 0)

This function returns the number of rows that were affected by the last INSERT, UPDATE, or DELETE operation. - Returns: Number of rows affected int ACR_SQLGetAffectedRows()

This function handles special characters (like ') for database storage. Problems can arise with SQL commands if variables or values have single or double quotes in their names. This function encodes these quotes so the underlying database can safely store them. - sString: The string to encode string ACR_SQLEncodeSpecialChars(string sString)

This function stores a persistent string. - oObject: The object for which the data is being stored - sVarName: The unique variable name - sValue: The value to record Optional parameters: - iExpiration: The number of days the persistent variable should be kept in database (default: 0=forever) void ACR_SetPersistentString(object oObject, string sVarName, string sValue, int iExpiration = 0)

This function stores a persistent integer. - oObject: The object for which the data is being stored - sVarName: The unique variable name - iValue: The value to record Optional parameters: - iExpiration: The number of days the persistent variable should be kept in database (default: 0=forever) void ACR_SetPersistentInt(object oObject, string sVarName, int iValue, int iExpiration = 0)

This function stores a persistent float. - oObject: The object for which the data is being stored - sVarName: The unique variable name - fValue: The value to record Optional parameters: - iExpiration: The number of days the persistent variable should be kept in database (default: 0=forever) void ACR_SetPersistentFloat(object oObject, string sVarName, float fValue, int iExpiration = 0)

This function stores a persistent location. - oObject: The object for which the data is being stored - sVarName: The unique variable name - lValue: The value to record Optional parameters: - iExpiration: The number of days the persistent variable should be kept in database (default: 0=forever) void ACR_SetPersistentLocation(object oObject, string sVarName, location lValue, int iExpiration = 0)

This function stores a persistent vector. - oObject: The object for which the data is being stored - sVarName: The unique variable name - vValue: The value to record Optional parameters: - iExpiration: The number of days the persistent variable should be kept in database (default: 0=forever) void ACR_SetPersistentVector(object oObject, string sVarName, vector vValue, int iExpiration = 0)

This function stores a persistent object. - oObject: The object for which the data is being stored - sVarName: The unique variable name - oItem: The object to record Optional parameters: - iExpiration: The number of days the persistent variable should be kept in database (default: 0=forever) void ACR_SetPersistentObject(object oObject, string sVarName, object oItem, int iExpiration = 0)

This function retrieves a persistent string. - oObject: The object for which the data is being retrieved - sVarName: The unique variable name - Returns: '' on error string ACR_GetPersistentString(object oObject, string sVarName)

This function retrieves a persistent int. - oObject: The object for which the data is being retrieved - sVarName: The unique variable name - Returns: 0 on error int ACR_GetPersistentInt(object oObject, string sVarName)

This function retrieves a persistent float. - oObject: The object for which the data is being retrieved - sVarName: The unique variable name - Returns: 0 on error float ACR_GetPersistentFloat(object oObject, string sVarName)

This function retrieves a persistent location. - oObject: The object for which the data is being retrieved - sVarName: The unique variable name - Returns: 0 on error location ACR_GetPersistentLocation(object oObject, string sVarname)

This function retrieves a persistent vector. - oObject: The object for which the data is being retrieved - sVarName: The unique variable name - Returns: 0 on error vector ACR_GetPersistentVector(object oObject, string sVarName)

This function retrieves a persistent object. - oObject: The object for which the data is being retrieved - sVarName: The unique variable name - Returns: 0 on error object ACR_GetPersistentObject(object oObject, string sVarName)

This function deletes a persistent record. - oObject: The object for which the data is being deleted - sVarName: The unique variable name void ACR_DeletePersistentVariable(object oObject, string sVarName)

This function converts a location to a string. - lLocation: The location to convert - Returns: A string equivalent string ACR_LocationToString(location lLocation)

This function converts a string to a location. - sLocation: The string to convert - Returns: A location location ACR_StringToLocation(string sLocation)

This function converts a vector to a string. - vVector: The vector to convert - Returns: A string equivalent string ACR_VectorToString(vector vVector)

This function converts a string to a vector. - sVector: The string to convert - Returns: A vector vector ACR_StringToVector(string sVector)

This function retrieves the CD Key of the player - always use this with exit events in place of the normal NWScript function (it returns null). - oPC: player whose CD Key to retrieve - Returns: oPC's CD Key string ACR_GetPCPublicCDKey(object oPC)

This function retrieves the database ID of the character (useful for direct queries using ACR_SQLQuery()). - oPC: player whose character ID to retrieve - Returns: oPC's character ID int ACR_GetCharacterID(object oPC)

 

Auxiliary database connections

There is support for creating "auxiliary" database connections (to other MySQL servers), though this support is not recommended for most usage.  Use the standard data persistence API instead in nearly all cases.

Auxiliary database connection documentation page.

Syndicate content