// 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);
}
Wednesday, 12 September 2007
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:
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.
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//////////////////
//:: 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.
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.
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.
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.
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
Subscribe to:
Posts (Atom)