Friday, 21 September 2007

Italics and bold in conversations

Use the ordinary html tags, <i> and <b> with their respective closing tags for bold and italic.

Includes - starting with group, ginc_group

All the include scripts are wonderful function libraries. Just starting to explore these.

ginc_group for example has handlers for creating and dealing with groups of creatures.

// Add up to iMax creatures with tag sTag to group sGroupName
void GroupAddTag(string sGroupName, string sTag, int iMax=20, int bOverridePrevGroup=FALSE)

// spawn creatures in - in BMA formation - and add them to a group
// if there are creatures already in the group, the new ones will be tacked on to the end and placed
// in formation accordingly.
void SpawnCreaturesInGroupAtWP(int iNum, string sTemplate, string sGroupName, string sWayPoint="SPAWN_POINT")

You can handle them as a group to face a waypoint, move to an object etc etc.
Then on the death of this group, various functions are available, eg:
GroupOnDeathBeginConversation
GroupOnDeathSetJournalEntry

Thursday, 20 September 2007

Miserable as hell

Me and the weather. No birds. Dark.

8.42 Power cut now over. Power went off at about 7.40.

Sunday, 16 September 2007

Use Selection button to make only what you want selectable

In the top left you have a dropdown menu called Selection. This allows you to chose which things to select (placables, creatures, sounds etc.). This is very helpful for selecting placeables and creatures placed under trees. It's also very helpful when selecting doors, waypoints and triggers. I usually set this to "None" whenever I'm not actively working on a part of the area, and just looking around trying to find out what to tweak next. No chance of dragging something out of place

Also, the show/hide button next to it is great for finding what you need to work on.
Found

Fixing door problems

You can double-click on the building, and it will suck its doors back into place. If you use your imagination, you can hear the rush of wind as it does so.
Source: Neverwinter Nights: Doors Flying Off Their Hinges
Address : http://nwn2forums.bioware.com/forums/viewtopic.html?topic=570637&forum=113

Terrain window unusable in Vista

Known bug. Have to switch Themes - right click on Desktop, choose Personalize[!] and then Themes and choose Windows Classic. Bit stark and not exactly what people buy Vista for, but the Terrain window will now be readable.

Wednesday, 12 September 2007

Change PC or NPC name

RandomName()
Generates a random name.
SetFirstName works on PC or NPC - probably also on a placeable or item

string sCreatureTag="n_gerana";
void main(string sCreatureTag)
{
object oVictim = GetNearestCreature(0,0);//haven't sorted this one yet
oVictim = GetObjectByTag(sCreatureTag);
string sNewname = RandomName();

//All names I've got so far are male sounding so
//if female add an 'a'
if (1==GetGender(oVictim))
{
sNewname = sNewname +"a";
}
SetFirstName (oVictim,sNewname);
sNewname = RandomName();
SetLastName(oVictim,sNewname);
}

Lie down on bed, untried or rather no success with this yet

// Play custom animation (returns void)
void C_PlayCustomAnimation(object oObject, string sAnimationName,
int nLooping, float fSpeed = 1.0f)
{
PlayCustomAnimation(oObject, sAnimationName, nLooping, fSpeed);
}
void C_Laydown(object oTarget)
{
float fDelay;
if (GetGender(oTarget) == GENDER_FEMALE) {
fDelay = 3.33;
} else {
fDelay = 2.33;
}
PlayCustomAnimation(oTarget, "laydownb", 0);
DelayCommand(fDelay, C_PlayCustomAnimation(oTarget, "proneb", 1);
}

Two children playing tag

Both need the following variable set in their onspawn or otherwise: X0_COMBAT_CONDITION = 4 (Int)
Put this code in their OnHeartbeat:
//::///////////////////////////////////////////////
//:: gb_am_heart
//:: Copyright (c) 2005 Obsidian Entertainment
//:://////////////////////////////////////////////
/*
Ambient system heartbeat.
*/
//:://////////////////////////////////////////////
//:: Created By: Brian Fox
//:: Created On: 1/5/06
//:://////////////////////////////////////////////
#include "x2_am_inc"
#include "nw_i0_generic"
//:://////////////////////////////////////////////
void debugit(string s);
//:://////////////////////////////////////////////
void main()
{
if ( GetAILevel() < AI_LEVEL_LOW || NoPlayerInArea() ) return; // * don't run this if no one is around
//if ( GetAmbientBusy(OBJECT_SELF) == TRUE )
//{
// debugit( "ambient mode = TRUE" );
//}
//if ( GetReady(OBJECT_SELF) == FALSE )
//{
// debugit( "not ready" );
//}
//if ( GetInTransition(OBJECT_SELF) == TRUE )
//{
// debugit( "transition" );
//}
//else
//{
// debugit( "no transition" );
//}
if ( GetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY) )
{
if ( TalentAdvancedBuff(40.0) )
{
SetSpawnInCondition( NW_FLAG_FAST_BUFF_ENEMY, FALSE );
return;
}
}
// * Nov 8: added conditions before they are allowed to try and leave
if ( GetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING) )
{
// * bk NOV 1: Trying to streamline the day/night transitioning
// * scripting
// * Nov 8: Adding the transition setting to it, to prevent
// * the barmaid from being over eager in serving drinks to everyone
// * even after closing
if ( GetCurrentAction() != ACTION_MOVETOPOINT && GetCurrentAction() != ACTION_DIALOGOBJECT )
{
//debugit( "going to check on waypoints" );
object oDayWay = GetObjectByTag( "POST_" + GetTag(OBJECT_SELF) );
object oNightWay = GetObjectByTag( "NIGHT_" + GetTag(OBJECT_SELF) );
if ( GetIsObjectValid(oDayWay) == TRUE && GetIsDay() == TRUE && GetArea(oDayWay) != GetArea(OBJECT_SELF) )
{
SetInTransition( TRUE, OBJECT_SELF );
WalkWayPoints( TRUE );
}
else if ( GetIsObjectValid(oNightWay) == TRUE && GetIsNight() == TRUE && GetArea(oNightWay) != GetArea(OBJECT_SELF) )
{
SetInTransition( TRUE, OBJECT_SELF );
WalkWayPoints( TRUE );
}
else // * I am in the right area
{
if ( GetInTransition() == TRUE )
{
SetInTransition( FALSE, OBJECT_SELF );
}
}
}
}
DoJob();
SetLocalLocation( OBJECT_SELF, MY_LOCAL_LOCATION_VAR_NAME, GetLocation(OBJECT_SELF) );
if ( GetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT) )
{
SignalEvent( OBJECT_SELF, EventUserDefined(1001) );
}
}
//:://////////////////////////////////////////////
void debugit( string s )
{
//if ( GetTag(OBJECT_SELF) == "TownWait01" )
//if ( GetLocalInt(OBJECT_SELF, "NW_L_RANDOMTAG") == 0 )
//SetLocalInt( OBJECT_SELF, "NW_L_RANDOMTAG", Random(10000) );
}
//:://////////////////end of code//////////////////


NOTE - only way you can post code into blogger - if you want to keep the default convert line breaks on - is to use DIV with overflow - ie put style="overflow:auto; height:300px; width:400px;" for instance. You can't use textareas.

Debug Text=1

Script exceptions can be seen all of the time by changing the nwn.ini in the directory where NWN2 is installed. There is a setting for Debug Text=0. Change it to Debug Text=1. Also make sure DebugMode is set to 1. I highly recommend this change for anyone doing scripting so you don’t have to enable seeing exceptions every time you test. Each time the game is patched the nwn.ini gets overwritten so be sure to reapply this change. The settings may work in the My Documents nwn.ini so it won't get overridden, I haven't tried that.
Source

My notes on this, I am trying it out.

Tuesday, 11 September 2007

Create a new spell?

You can apparently alter one of the spell scripts that are already there. In the 2da you'll find a column named impactscript. This is the script that gets fired if you cast the spell. But you may also add new scripts to your 2da. most of the columns are quite self-explaining.

Untried at this moment.

Monday, 10 September 2007

Stackable shortcut S

Stack placeables on top of one another by changing the Stackable attribute to True.

Shortcut, use S. Select the placeable and press S (this changes the "Stackable" option to True). Then, just copy and paste the placeable as many times as you want.

Sunday, 9 September 2007

FloatingTextStringOnCreature ONLY works on PC

Remarks

This function seems to be most useful for notifying PCs (and possibly their party) of in game effects (detections, environmental perceptions, etc), and not as a way to facilitate PC-to-creature communication. For instance, if a PC passes a Listen check they could be notified via Ambient Text (“You hear footsteps coming down the hall”). Other uses could include Onomatopoeia originating from the PC (“Snap!”, “Cough!”, “Hick!”) and brief game feedback (simulate an overheard conversation, time from a sundial, item status, etc).

This function will not work on placeable objects of any kind, and text targeted to NPCs will never be visible to PCs. You can simulate text coming from a sign, sundial, or any other placeable object by floating it above the PC you want to notify, as long as the PC is near to the object when the text will appear.
Source: NWN Lexicon


NOTE But you can use SpeakString() - Am going to test this for placeables, particularly signs, as well as creatures. It floats the text so is a good replacement. Search for an entry later on this.
Update: It does work, it gives the name of the placeable in square brackets followed by the text of the SpeakString. Text floats upwards.

Thursday, 6 September 2007

Set Local Variable on the PC

void main( )
{
object oSelf = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
SetLocalInt(oSelf, "Value1", 1);
SetLocalFloat(oSelf, "Value2", 3.40);
SetLocalString(oSelf, "Quest1", "Quest completed!");
}


NWN2 Local Variables...
* NWN2 Local Variables are preferred over NWN2 global variables because they are assigned to specific objects and in that sense protected.
* Can be accessed by any object.
* Come in three types: integer, float, and string.
* Used to store information with a specific object.
* Used to get information from a specific object.


Source: NWN2 Scripting Setting Local Variables

Wednesday, 5 September 2007

Tip: Debug using SendMessageToPC

//Debug String
SendMessageToPC(GetFirstPC(), "value of global int intValue is " + IntToString(intValue));

Spawnees and conversations

When a creature is added to an encounter if it already has a conversation it seems from my experimentation that the conversation will not fire. What does work is an onconversation script. So far, I have used these with the convo in SpeakStrings but can't see why it can't also start up a convo by tag.

Baking hell - too many objects

Constant difficulties here. Only solution is to convert as many placeables as possible to environment objects.

Tuesday, 4 September 2007

Interface hell - using conditionals and parameters in convo editor

Interface hell. The conversation editor. When you are using the conditional tab or the action tab, pressing Refresh will eventually get you a little box to add things like starting conditional values.

Click Add to get a list of scripts, select one, then press Refresh to get the little box/es in which to enter values. Same system for the Conditions.

Try it out, it does work quite well, just clunky and pretty hidden.

Item - create special item with script on activate

You would not believe how tortuous this process is!!!

In item properties, under cast spell in 'item properties' window, you put in 'unique power'.
NOTE!!! Choose your base object with care, as gem for instance does not have anything available in 'item properties' window!!
Then you create a new script - don't worry there is nowhere in the item properties to link this in, it is done otherwise.
Use the 'item activate' template, then write out what you want the script to do when the item is activated.
The name of the script has to be i_tagofitem_ac.
Now, whenever the item is used by the player, the script will execute.

===============================================================

Item Scripts
Use the following for item scripts:

i__ac
script to execute when item activated

i__aq
script to execute when item acquired

i__ua
script to execute when item unacquired

i__eq
script to execute when item equipped

i__ue
script to execute when item unequipped


The module events will be written to automatically execute the proper script.

StringToObject - possibly can use to reference

//RWT-OEI 03/12/07
//Convert a 'string' to an object data type.
//This does not guarentee that the 'object' is anything valid
object StringToObject( string sString );


Try this for mock arrays
babble1, babble2 etc, to reference them

try and report back captain

My encounter creatures aren’t wandering around. How can I fix this?

My encounter creatures aren’t wandering around. How can I fix this?
Make sure your spawn script has the following:

if (GetIsEncounterCreature())
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS, TRUE);

Randomly pick a dialog response

gc_rand_1of(int iMax)
Used to randomly pick a dialog response.

Use parameters 2 through X for each entry after the first, decrementing by 1 for each branch down.

Example: 3 entries would have the following conditionals:

gc_rand_1of(3)

gc_rand_1of(2)

The final entry doesn't need a check since it is a certainty.

Monday, 3 September 2007

Add Henchman

ga_add_companion(string sTarget)

This script adds the target as a henchman to the party.
Parameters:
string sTarget = Tag of the henchman to add. If blank, add dialog OWNER.

Multiple speakers in conversations

How to achieve this: In the Node tab, set the Speaker field to the tag of the speaker. NOTE: helpfully[!!!] this only appears in the lines already designated to be spoken by the NPC not the PC.