Global Action - Neverwinter Vault



Table of contents

Table of contents i

Global Action 1

Global Artificial Intellegence 249

Global Being (Creature) 299

Global Conditional 415

Global Door 487

Global Dungeon Master 488

Global Group 499

Global Include 504

Global Placeables 794

Global Reports 811

Global Trigger 858

Graphical User Interace 862

Apendix 900

NWN2 Stock scripts

VOL I

Main Scripts

presented by

Gamemaster x

&

The knights of the charred table



kalifornica@

Foreword

Hi, Gamemaster X here. I was peeking up the games skirt and looking at all its private parts and it occurred to me it would be nice to have all the stock scripts in an e-book format. What you have here is VOL 1 of a three part series of Neverwinter Nights 2 Stock scripts (the ones that install with the game).

VOL 1 concentrates on Main Scripts or those scripts not specific to spells or a specific area. My intention is for the final series to be laid out as follows.

VOL I Main Scripts

VOL II Spell Scripts

VOl III Area Scripts

Vol IV 2da

Global Action

// ga_alignment

/*

This changes the player's alignment

nActType = From a scale from +3 (Saintly/Paragon) to -3 (Fiendish/Anarchic),

how much the act affects alignment

bLawChaosAxis = 0 means adjust Good/Evil axis, 1 means adjust Law/Chaos axis

*/

// FAB 10/5

// EPF 6/6/05 chose different variable name for second parameter

// ChazM 4/3/06 - Added conversion functions to maintain the functionality of this script, calibrated to the 101 point scale being used.

// DBR 4/13/6 - Adjustment was being converted as if it was a final value instead of a delta.

// DBR 4/18/6 - forgot to adjust for good/lawful as well.

// ChazM 5/3/06 - complete rewrite - simplified to no longer be context sensitive to current alignment.

// ChazM 5/3/06 - changed adjustment for 1-point acts, added "incarnate" acts

// EPF 7/10/06 - added debug strings for balance testing

// EPF 7/20/06 - dampened adjustment values for 1-3. Previous values made it too difficult to

// remain neutral, which makes it just about impossible to play a druid.

// ChazM 8/31/06 - Changed debug display to values instead of alignment constants; removed old commented code

#include "ginc_debug"

const int ACT_EVIL_INCARNATE = -4;

const int ACT_EVIL_FIENDISH = -3;

const int ACT_EVIL_MALEVOLENT = -2;

const int ACT_EVIL_IMPISH = -1;

const int ACT_GOOD_KINDLY = 1;

const int ACT_GOOD_BENEVOLENT = 2;

const int ACT_GOOD_SAINTLY = 3;

const int ACT_GOOD_INCARNATE = 4;

const int ACT_CHAOTIC_INCARNATE = -4;

const int ACT_CHAOTIC_ANARCHIC = -3;

const int ACT_CHAOTIC_FEY = -2;

const int ACT_CHAOTIC_WILD = -1;

const int ACT_LAWFUL_HONEST = 1;

const int ACT_LAWFUL_ORDERLY = 2;

const int ACT_LAWFUL_PARAGON = 3;

const int ACT_LAWFUL_INCARNATE = 4;

// Adjust Alignment notes:

// Alignment is not treated as a continuous scale running from 0 to 100, but in three bands running from 0 to 30, 31 to 69 and 70 to 100.

// Whenever a call to AdjustAlignment takes you over one of these boundaries,

// your characters alignment is automatically placed at the middle of the new band, ie 15, 50 or 85.

int LawChaosAxisAdjustment(object oPC, int iLawChaosActType)

{

int iAdjustment = 0;

switch ( iLawChaosActType )

{

case ACT_CHAOTIC_INCARNATE:

iAdjustment = -70;

break;

case ACT_CHAOTIC_ANARCHIC:

iAdjustment = -10;

break;

case ACT_CHAOTIC_FEY:

iAdjustment = -3;

break;

case ACT_CHAOTIC_WILD:

iAdjustment = -1;

break;

case 0: // Neutral acts not currently tracked

iAdjustment = 0;

break;

case ACT_LAWFUL_HONEST:

iAdjustment = 1;

break;

case ACT_LAWFUL_ORDERLY:

iAdjustment = 3;

break;

case ACT_LAWFUL_PARAGON:

iAdjustment = 10;

break;

case ACT_LAWFUL_INCARNATE:

iAdjustment = 70;

break;

}

if (iAdjustment > 0)

AdjustAlignment(oPC, ALIGNMENT_LAWFUL, iAdjustment);

else

AdjustAlignment(oPC, ALIGNMENT_CHAOTIC, -iAdjustment);

return (iAdjustment);

}

int GoodEvilAxisAdjustment(object oPC, int iGoodEvilActType)

{

int iAdjustment = 0;

switch ( iGoodEvilActType )

{

case ACT_EVIL_INCARNATE:

iAdjustment = -70;

break;

case ACT_EVIL_FIENDISH:

iAdjustment = -10;

break;

case ACT_EVIL_MALEVOLENT:

iAdjustment = -3;

break;

case ACT_EVIL_IMPISH:

iAdjustment = -1;

break;

case 0: // Neutral acts not currently tracked

iAdjustment = 0;

break;

case ACT_GOOD_KINDLY:

iAdjustment = 1;

break;

case ACT_GOOD_BENEVOLENT:

iAdjustment = 3;

break;

case ACT_GOOD_SAINTLY:

iAdjustment = 10;

break;

case ACT_GOOD_INCARNATE:

iAdjustment = 70;

break;

}

if (iAdjustment > 0)

AdjustAlignment(oPC, ALIGNMENT_GOOD, iAdjustment);

else

AdjustAlignment(oPC, ALIGNMENT_EVIL, -iAdjustment);

return (iAdjustment);

}

void main(int iActType, int bLawChaosAxis)

{

object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

int nAdjustment;

if (bLawChaosAxis == 0)

{

nAdjustment = GoodEvilAxisAdjustment(oPC, iActType);

PrettyMessage("Alignment shifted on Good-Evil Axis by " + IntToString(nAdjustment));

PrettyMessage("Overall Alignment on this axis = " + IntToString(GetGoodEvilValue(oPC)));

}

else

{

nAdjustment = LawChaosAxisAdjustment(oPC, iActType);

PrettyMessage("Alignment shifted on Law-Chaos Axis by " + IntToString(nAdjustment));

PrettyMessage("Overall Alignment on this axis = " + IntToString(GetLawChaosValue(oPC)));

}

}

// ga_attack

/*

This script makes the sAttacker attack the PC. It should be placed on an [END DIALOG] node.

Parameters:

string sAttacker = Tag of attacker whom will attack the PC. Default is OWNER.

*/

// FAB 10/7

// ChazM 4/26

#include "ginc_param_const"

#include "ginc_actions"

void main(string sAttacker)

{

object oAttacker = GetTarget(sAttacker, TARGET_OWNER);

object oTarget = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

StandardAttack(oAttacker, oTarget);

}

// ga_attack_target

/*

This script makes the sAttacker attack the sTarget. It should be placed on an [END DIALOG] node.

Parameters:

string sAttacker = Tag of attacker. Default is OWNER.

string sTarget = Tag of Target. Default is PC.

*/

// FAB 10/7

// ChazM 4/26

#include "ginc_param_const"

#include "ginc_actions"

void main(string sAttacker, string sTarget)

{

object oAttacker = GetTarget(sAttacker, TARGET_OWNER);

object oTarget = GetTarget(sTarget, TARGET_PC);

StandardAttack(oAttacker, oTarget);

}

// ga_blackout

//

// wrapper function for FadeToBlackParty() to instantly make screen black. Useful for the

// first node of conversations.

// CGaw & BMa 2/13/06 - Created.

#include "ginc_cutscene"

void main()

{

object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

FadeToBlackParty(oPC, 1, 0.0);

}

// ga_camera_facing_point_party

/*

Point the cameras of all PCs' in the Speaker's party to target sTarget.

Camera will be fDistance meters away from the PC, and

pitched at fPitch degrees.

-fDistance can be between 1 and 25. At least 5 is advisable in most cases.

0 = use distance of current camera value

-fPitch can be between 1 and 89. 89 is nearly parallel to the ground.

1 is almost directly overhead. 60-70 is usually a reasonable default.

0 = use pitch of current camera value

- nTransitionType can be 0 or between 1 and 100. The higher the number, the faster the transition.

0 = snap to new facing, no transition.

*/

// EPF 9/14/06

// ChazM 9/15/06 - added defaults for current cam, moved funcs to ginc_cutscene

#include "ginc_param_const"

#include "x0_i0_position"

#include "ginc_cutscene"

#include "ginc_math"

void main(string sTarget, float fDistance, float fPitch, int nTransitionType)

{

object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

if(!GetIsObjectValid(oPC))

{

return; //if there's no PC speaker, there's no point in setting the cam anyway.

}

// SetCameraFacing() uses -1.0 to use current camera default, we'll use 0.0 as well.

if (IsFloatNearInt(fDistance, 0))

fDistance = -1.0f;

if (IsFloatNearInt(fPitch, 0))

fPitch = -1.0f;

object oTarget = GetTarget(sTarget);

if(GetIsObjectValid(oTarget))

{

SetCameraFacingPointParty(oPC, oTarget, fDistance, fPitch, nTransitionType);

}

}

// ga_clear_comp()

/*

Removes all roster members from the PC party. Removed roster members are not despawned.

*/

// BMA-OEI 7/20/05

// EPF 1/9/06 -- added RemoveAllCompanions call.

// TDE 3/23/06 -- Replaced entire script with DespawnAllCompanions.

// BMA-OEI 5/23/06 -- replaced w/ RemoveRosterMembersFromParty(), updated comment

#include "ginc_companion"

void main()

{

object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

RemoveRosterMembersFromParty(oPC, FALSE, FALSE);

}

//ga_commandable

/*

Set's target's commandable state.

0 = action stack can not be modified

1 = action stack can be modified

*/

//ChazM 6/28/06

#include "ginc_param_const"

void main(string sTarget, int iCommandable)

{

object oTarget = GetTarget(sTarget);

AssignCommand(oTarget, SetCommandable(iCommandable));

int iCommandable = GetCommandable(oTarget);

PrettyDebug(GetName(oTarget) + " commandable state is " + IntToString(iCommandable));

}

// ga_compshift

/*

This is the companion shift script that adjusts a companion's

reaction to the PC

nCompanion = This is the integer value of the companion in question

nChange = This is the amount their reaction is adjusted

nOverride = If this isn't equal to 0, the companions reaction is

set to this amount. Use with caution.

*/

// FAB 10/4

void main(int nGP, int nAllPCs)

{

/*

This is a temp script - a real script will be added later

nCompanion

1: Khelgar

nChange

-3: Strong negative change

-2: Medium negative change

-1: Small negative change

+1: Small positive change

+2: Medium positive change

+3: Strong positive change

*/

}

// ga_conversation_self

/*

start a conversation file with yourself.

Parameters:

string sConversation = Conversation file to start.

*/

// ChazM 2/25/06

// #include "ginc_param_const"

void main(string sConversation)

{

object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

AssignCommand(oPC, ActionStartConversation(oPC, sConversation, TRUE, FALSE));

}

// ga_create_obj(string sObjectType, string sTemplate, string sLocationTag, int bUseAppearAnimation, string sNewTag, float fDelay)

/*

Wrapper for CreateObject() with optional delay.

Parameters:

string sObjectType = Object type. The following are allowed:

C - CREATURE

P - PLACEABLE

I - ITEM

W - WAYPOINT

S - STORE

string sTemplate = Name of the template to create.

string sLocationTag = Tag of the waypoint at which to create the object.

int bUseAppearAnimation = If =1, object will use appear animation.

string sNewTag = Optional new tag for created object.

float fDelay = Delay, in seconds, before creating the object.

*/

// TDE 3/9/05

// ChazM 3/11/05

// BMA-OEI 1/11/06 removed default params

#include "ginc_param_const"

#include "ginc_actions"

void main(string sObjectType, string sTemplate, string sLocationTag, int bUseAppearAnimation, string sNewTag, float fDelay)

{

object oLocation = GetObjectByTag(sLocationTag);

location lLocation = GetLocation(oLocation);

int iObjType = GetObjectTypes(sObjectType);

DelayCommand(fDelay, ActionCreateObject(iObjType, sTemplate, lLocation, bUseAppearAnimation, sNewTag));

}

// ga_cutscene_move

//

// Move and delay the advancing of the conversation for a maximum of nMilliseconds.

// Conversation will also advance if the move completes.

// "" for sMoverTag -> OBJECT_SELF

#include "ginc_misc"

void main(string sWPTag, int nMilliseconds, int bRun, string sMoverTag)

{

object oTarget;

if(sMoverTag == "")

{

oTarget = OBJECT_SELF;

}

else

{

oTarget = GetTarget(sMoverTag);

}

ActionPauseCutscene(nMilliseconds);

AssignCutsceneActionToObject(oTarget, ActionMoveToObject(GetTarget(sWPTag), bRun));

}

// ga_date_advance

/*

Advance date by amount indicated

nYear - Number of years to advance.

nMonth - Number of months to advance.

nDay - Number of days to advance.

*/

// ChazM 6/27/06

void main(int nYear, int nMonth, int nDay)

{

nYear = GetCalendarYear() + nYear;

nMonth = GetCalendarMonth() + nMonth;

nDay = GetCalendarDay() + nDay;

// Set the new date

SetCalendar(nYear, nMonth, nDay);

}

// ga_date_set

/*

Advance date by amount indicated

nYear - Specific year to set calendar to from 1340 to 32001.

nMonth - Specific month to set calendar from 1 to 12.

nDay - Specific day to set calendar to from 1 to 28.

*/

// ChazM 6/27/06

void main(int nYear, int nMonth, int nDay)

{

// Set the new date

SetCalendar(nYear, nMonth, nDay);

}

// ga_death

/*

This script makes objects appear dead

sTag = The tag(s) of the object(s) to make dead. You can pass multiple

tags, seperated by commas (NO SPACES) to make multiple objects dead

(ie. "Object1,Object2,Object3")

iInstance = The instance of the object(s) to make dead. Pass -1 to make

all instances dead.

*/

// TDE 3/7/05

// BMA-OEI 1/11/06 removed default param

// TDE 8/3/06 - Set Immortal and Plot flags to FALSE, Added some debug strings

// TDE 8/28/06 - Changed SetIsDestroyable to (FALSE, FALSE, TRUE) so that the corpses can be looted

#include "ginc_debug"

void Death(string sTagString, int iInstance = 0)

{

PrettyDebug("Applying Death Effect To: " + sTagString + " Instance = " + IntToString(iInstance));

if (iInstance == -1)

{

int iInst;

object oObject;

while (GetIsObjectValid(GetObjectByTag(sTagString, iInst)))

{

oObject = GetObjectByTag(sTagString, iInst);

AssignCommand(oObject, SetIsDestroyable( FALSE,FALSE,TRUE ));

SetImmortal( oObject, FALSE );

SetPlotFlag( oObject, FALSE );

effect eFX = EffectDeath();

PrettyDebug("Name of oObject = " + GetName(oObject));

ApplyEffectToObject( DURATION_TYPE_INSTANT,eFX,oObject );

iInst ++;

}

}

else

{

object oObject = GetObjectByTag(sTagString, iInstance);

AssignCommand(oObject, SetIsDestroyable( FALSE,FALSE,TRUE ));

SetImmortal( oObject, FALSE );

SetPlotFlag( oObject, FALSE );

effect eFX = EffectDeath();

PrettyDebug("Name of oObject = " + GetName(oObject));

ApplyEffectToObject( DURATION_TYPE_INSTANT,eFX,oObject );

}

}

void main(string sTagString, int iInstance)

{

string newString = sTagString;

int iLen = GetStringLength(sTagString);

//find first comma

int CommaPos = FindSubString( newString, "," );

while(CommaPos != -1)

{

string tempString = GetSubString(newString, 0, CommaPos);

Death(tempString, iInstance);

newString = GetSubString(newString, CommaPos + 1, iLen);

iLen = GetStringLength(newString);

CommaPos = FindSubString( newString, "," );

}

//newString is equal to last tag to destroy

Death(newString, iInstance);

}

// ga_destroy

/*

This script destroys objects

sTag = The tag(s) of the object(s) to destroy. You can pass multiple

tags, seperated by commas (NO SPACES) to destroy multiple objects

(ie. "Object1,Object2,Object3")

NOTE: There may eventually be a function to eat white space

(See Mantis 3296), but for now do not put spaces in the string.

iInstance = The instance of the object to destroy. Pass -1 to destroy

all instances. Pass 0 to destroy the first instance.

fDelay = The delay before destroying the object(s)

*/

// TDE 3/7/05

// ChazM 3/8/05 - commented and tweaked.

// ChazM 6/7/05 - fixed bug, modified comment

// BMA-OEI 1/11/06 removed default param

// detroy all objects (iInstance=-1) or a specific instance of object

void Destroy(string sTagString, int iInstance = 0, float fDelay = 0.0)

{

if (iInstance == -1)

{ // delete all objects

int iInst = 0;

object oObject = GetObjectByTag(sTagString, iInst);

while (GetIsObjectValid(oObject))

{

DestroyObject (oObject, fDelay);

iInst ++;

oObject = GetObjectByTag(sTagString, iInst);

}

}

else

{ // delete a specific instance of object

DestroyObject (GetObjectByTag(sTagString, iInstance), fDelay);

}

}

void main(string sTagString, int iInstance, float fDelay)

{

string sNewString = sTagString;

int iLen = GetStringLength(sTagString);

int iCommaPos = FindSubString( sNewString, "," ); //find first comma

while(iCommaPos != -1)

{

// get first tag and destroy it

string sTempString = GetSubString(sNewString , 0, iCommaPos);

Destroy(sTempString, iInstance, fDelay);

// drop first tag and comma

sNewString = GetSubString(sNewString, iCommaPos + 1, iLen);

// determine new length

iLen = GetStringLength(sNewString);

// get next comma position (returns -1 if not found)

iCommaPos = FindSubString(sNewString, "," );

}

//sNewString is equal to last tag to destroy

Destroy(sNewString, iInstance, fDelay);

}

// ga_destroy_item

/*

This takes an item from a player

sItemTag = This is the string name of the item's tag

nQuantity = The number of items to destroy. -1 is all of the Player's items of that tag.

nPCFaction = Take from the whole PC faction

*/

// FAB 9/30

// DBR 8/10/6

#include "nw_i0_plot"

void DestroyItems(object oTarget,string sItem,int nNumItems)

{

int nCount = 0;

object oItem = GetFirstItemInInventory(oTarget);

while (GetIsObjectValid(oItem) == TRUE && nCount < nNumItems)

{

if (GetTag(oItem) == sItem)

{

//ActionTakeItem(oItem,oTarget);

DestroyObject(oItem,0.1f);

nCount++;

}

oItem = GetNextItemInInventory(oTarget);

}

return;

}

void main(string sItemTag,int nQuantity,int bPCFaction)

{

int nTotalItem;

object oPCF,oPC = (GetPCSpeaker()==OBJECT_INVALID?GetFirstPC():GetPCSpeaker());

object oItem; // Items in inventory

if ( bPCFaction == 0 )

{

if ( nQuantity < 0 ) // Destroy all instances of the item

{

nTotalItem = GetNumItems( oPC,sItemTag );

DestroyItems( oPC,sItemTag,nTotalItem );

}

else

{

DestroyItems( oPC,sItemTag,nQuantity );

}

}

else // For multiple players

{

oPCF = GetFirstFactionMember(oPC,FALSE);

while (( GetIsObjectValid(oPCF) )&&(nQuantity!=0))

{

if ( nQuantity < 0 ) // Destroy all instances of the item

{

nTotalItem = GetNumItems( oPCF,sItemTag );

DestroyItems( oPCF,sItemTag,nTotalItem );

}

else

{

nTotalItem = GetNumItems( oPCF,sItemTag );

nQuantity -= nTotalItem;

if (nQuantity 1)

{

if (GetIsStackableItem(sItemTemplate))

{

CreateItemOnObject(sItemTemplate, oTarget, nNumToCreate);

}

else

for (i=1; i current Journal Entry. (Default: =0)

*/

// BMA-OEI 10/14/05

// BMA-OEI 1/11/06 removed default params

void main(string sCategoryTag, int nEntryID, int bAllPartyMembers, int bAllPlayers, int bAllowOverrideHigher)

{

object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

AddJournalQuestEntry(sCategoryTag, nEntryID, oPC, bAllPartyMembers, bAllPlayers, bAllowOverrideHigher);

}

// ga_jump(string sDestination, string sTarget, float fDelay)

/*

Jump an object to a waypoint or another object.

Parameters:

string sDestination = Tag of waypoint or object to jump to.

string sTarget = Tag of object to jump. Default is OWNER

float fDelay = Delay before JumpToObject()

*/

// TDE 3/9/05

// ChazM 3/11/05

// BMA 7/13/05 changed Delay/Assign to Assign/Delay

// BMA-OEI 1/11/06 removed default param

#include "ginc_param_const"

void main(string sDestination, string sTarget, float fDelay)

{

object oDestination = GetTarget(sDestination);

object oTarget = GetTarget(sTarget, TARGET_OWNER);

AssignCommand(oTarget, DelayCommand(fDelay, JumpToObject(oDestination)));

}

// ga_jump_faction(string sTagOfMember, string sTagOfWayPoint, int iFormation, string sFormationParams)

/*

Jump faction into formation at sTagOfWayPoint.

Parameters:

string sTagOfMember = Tag of member in faction to jump.

string sTagOfWayPoint = Tag of waypoint.

int iFormation = DOES NOTHING.

string sFormationParams = DOES NOTHING.

*/

// BMA 5/24/05

// ChazM 5/26/05

// ChazM 6/2/05 updated to work w/ new features

// BMA-OEI 1/11/06 removed default param, use default U7 formation

// ChazM 3/3/06 Added error message for when this is used in campaign on a PC to do an area transition

#include "ginc_param_const"

#include "ginc_group"

#include "ginc_transition"

void main(string sTagOfMember, string sTagOfWayPoint, int iFormation, string sFormationParams)

{

object oTarget = GetTarget(sTagOfMember, TARGET_OBJECT_SELF);

//float fRadius = StringToFloat(sFormationParams);

//if (fRadius =0)

SetLocalInt(OBJECT_SELF, VAR_AP_BLOCKCOUNT, nBlockCount + 1 );

AIContinueInterruptedScript(CREATURE_SCRIPT_ON_BLOCKED_BY_DOOR); //this script is an interrupt script, so this must be called

//when you want the original to play

}

//::///////////////////////////////////////////////////////////////////////////

//::

//:: gai_counterspell_dcr

//::

//:: Determine Combat Round for the Spell Queue AI.

//::

//:: Spell Queue AI's will cast spells form an ordered list attached to them.

//:: To Attach a list, use the function ******, the conversation script ******,

//:: or manually using these variables (must be done pre-spawn) *******.

//::

//::///////////////////////////////////////////////////////////////////////////

// DBR 1/30/06

#include "nw_i0_generic"

#include "x2_inc_switches"

#include "ginc_param_const"

#include "ginc_ai"

#include "nw_i0_plot"

//#include "ginc_debug"

object GetSuitableSpellCaster()

{

object oWiz=GetNearestCreature(CREATURE_TYPE_CLASS,CLASS_TYPE_WIZARD,OBJECT_SELF,1,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,CREATURE_TYPE_IS_ALIVE,TRUE);

object oSor=GetNearestCreature(CREATURE_TYPE_CLASS,CLASS_TYPE_SORCERER,OBJECT_SELF,1,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,CREATURE_TYPE_IS_ALIVE,TRUE);

if (!GetIsObjectValid(oWiz))

return oSor;

if (!GetIsObjectValid(oSor))

return oWiz;

if ((GetDistanceBetween(OBJECT_SELF,oSor))10.0f)||(!GetIsObjectValid(oSpellCaster)))

return;//standard DCR

else if (!GetActionMode(OBJECT_SELF,ACTION_MODE_COUNTERSPELL))

{

// PrettyDebug("Trying to perform CounterSpell on: " + GetTag(oSpellCaster));

SetActionMode(OBJECT_SELF,ACTION_MODE_COUNTERSPELL,TRUE);

__TurnCombatRoundOn(TRUE);

ActionCounterSpell(oSpellCaster);

__TurnCombatRoundOn(FALSE);

SetCreatureOverrideAIScriptFinished();//Tell Determine Combat Round That I handled things.

return;

}

}

//otherwise standard DCR

}

//::///////////////////////////////////////////////////////////////////////////

//::

//:: gai_damagetracker_b

//::

//:: Tracks those who have hurt me, much like my lists of names from high school.

//:: from ginc_ai, used by the "attack who damaged me most" AI type

//::

//::///////////////////////////////////////////////////////////////////////////

// DBR 2/1/06

#include "ginc_ai"

//#include "ginc_debug"

int GetCreatureIndex(object oDamager);

void BSortDown(int index);

void main()

{

object oDamager=GetLastDamager();

int nDamage = GetTotalDamageDealt();

// PrettyMessage(GetTag(oDamager) + " Has hit me for " + IntToString(nDamage));

int index = GetCreatureIndex(oDamager);

//increase totaled damage count

SetLocalInt(OBJECT_SELF, VAR_AP_DAMAGER_PTS + IntToString(index), GetLocalInt(OBJECT_SELF,VAR_AP_DAMAGER_PTS+IntToString(index))+nDamage);

if (index>1)

BSortDown(index);

AIContinueInterruptedScript(CREATURE_SCRIPT_ON_DAMAGED); //this script is an interrupt script, so this must be called

//when you want the original to play

}

void BSortDown(int index)

{

int nVal = GetLocalInt(OBJECT_SELF,VAR_AP_DAMAGER_PTS+IntToString(index));

int nNextVal = GetLocalInt(OBJECT_SELF,VAR_AP_DAMAGER_PTS+IntToString(index-1));

if (nVal>nNextVal)//swap me down one

{

object oMe=GetLocalObject(OBJECT_SELF,VAR_AP_DAMAGER+IntToString(index));

object oNext=GetLocalObject(OBJECT_SELF,VAR_AP_DAMAGER+IntToString(index-1));

SetLocalObject(OBJECT_SELF,VAR_AP_DAMAGER+IntToString(index-1),oMe);

SetLocalObject(OBJECT_SELF,VAR_AP_DAMAGER+IntToString(index),oNext);

SetLocalInt(OBJECT_SELF,VAR_AP_DAMAGER_PTS+IntToString(index-1),nVal);

SetLocalInt(OBJECT_SELF,VAR_AP_DAMAGER_PTS+IntToString(index),nNextVal);

}

if (index>2)//reursive, unless we're at the beginning of the list

BSortDown(index-1);

}

int GetCreatureIndex(object oDamager)

{

int i=0;

int nNumEntries=GetLocalInt(OBJECT_SELF,VAR_AP_NUM_DAMAGERS);

while (i= 1)

sList = sListElement;

for (i=2; i= 0)

DelayCommand(0.5, AssignCommand(oTarget, ActionEquipItem(oItem, iEquipSlot)));

}

// give all w/ sTargetTag, specified equipment and put in specified slot

void DoEquipmentUpgrade(string sTargetTag, string sItemResRef, int iEquipSlot)

{

int i = 0;

object oTarget = GetObjectByTag(sTargetTag, i);

while (GetIsObjectValid(oTarget))

{

// PrintString("Equiping NPC " + GetName(oTarget) + " - index " + IntToString(i));

EquipNewItem(oTarget, sItemResRef, iEquipSlot);

oTarget = GetObjectByTag(sTargetTag, ++i);

}

DebugMessage("Total number of creatures updated: " + IntToString(i));

}

// store info on item about current owner and slot equipped

void RememberEquippedItem(object oOwner, int iSlot)

{

object oInventoryItem = GetItemInSlot(iSlot, oOwner);

if (oInventoryItem != OBJECT_INVALID)

{

SetLocalInt(oInventoryItem, LAST_SLOT_NUM, iSlot);

SetLocalObject(oInventoryItem, LAST_SLOT_OBJ, oOwner);

}

}

// store info on all equipped items of owner

void RememberEquippedItems(object oOwner)

{

int iSlot;

for (iSlot = 0; iSlot < NUM_INVENTORY_SLOTS; iSlot++)

{

RememberEquippedItem(oOwner, iSlot);

}

}

// restore item to slot last remembered

void RestoreEquippedItem(object oOwner, object oInventoryItem, int bReset=TRUE)

{

int iSlot = GetLocalInt(oInventoryItem, LAST_SLOT_NUM);

//object oOrigOwner = GetLocalObject(oInventoryItem, LAST_SLOT_OBJ);

if (iSlot > 0)

{

AssignCommand(oOwner, ActionEquipItem(oInventoryItem, iSlot));

if (bReset)

{

DeleteLocalInt(oInventoryItem, LAST_SLOT_NUM);

DeleteLocalObject(oInventoryItem, LAST_SLOT_OBJ);

}

}

}

// Restore all inventory items to equipment slot last remembered (if any)

void RestoreEquippedItems(object oOwner, int bReset=TRUE)

{

object oInventoryItem = GetFirstItemInInventory(oOwner);

object oLeftHandItem;

int iSlot;

while (oInventoryItem != OBJECT_INVALID)

{

iSlot = GetLocalInt(oInventoryItem, LAST_SLOT_NUM);

//EPF 8/29/06 left hand must be equipped after right. Otherwise the engine

// will shift it to the right hand slot automatically.

if(iSlot != INVENTORY_SLOT_LEFTHAND)

{

RestoreEquippedItem(oOwner, oInventoryItem, bReset);

oInventoryItem = GetNextItemInInventory(oOwner);

}

else

{

oLeftHandItem = oInventoryItem;

}

}

if(GetIsObjectValid(oLeftHandItem))

{

RestoreEquippedItem(oOwner, oLeftHandItem, bReset);

}

}

// unequip item in specified slot, if any

void UnequipSlot(object oOwner, int iSlot)

{

object oInventoryItem = GetItemInSlot(iSlot, oOwner);

if (oInventoryItem != OBJECT_INVALID)

{

AssignCommand(oOwner, ActionUnequipItem(oInventoryItem));

}

}

// passing around carried stuff.

void GiveEquippedItem(object oGiver, object oReceiver, int iSlot)

{

if (GetObjectType(oGiver) != OBJECT_TYPE_CREATURE)

{

PrettyError("GiveEquippedItem(): Equipped Item Giver must be a creature!");

return;

}

object oInventoryItem = GetItemInSlot(iSlot, oGiver);

if (oInventoryItem != OBJECT_INVALID)

{

AssignCommand(oGiver, ActionUnequipItem(oInventoryItem));

//AssignCommand(oReceiver, ActionTakeItem(oInventoryItem, oGiver));

//AssignCommand(oGiver, ActionGiveItem(oInventoryItem, oReceiver));

TransferItem(oGiver, oReceiver, oInventoryItem);

}

}

void GiveAllEquippedItems(object oGiver, object oReceiver)

{

int iSlot;

for (iSlot = 0; iSlot < NUM_INVENTORY_SLOTS; iSlot++)

{

GiveEquippedItem(oGiver, oReceiver, iSlot);

}

}

// Transfer an item from giver to receiver.

// objects lack an action queue, so

void TransferItem(object oGiver, object oReceiver, object oInventoryItem)

{

// placeable give/take item commands are most dependable

if (GetObjectType(oReceiver) == OBJECT_TYPE_PLACEABLE)

{ // the receiver is a creature, so he can be assigned ActionTakeItem() commands to his queue

AssignCommand(oReceiver, ActionTakeItem(oInventoryItem, oGiver));

}

else //if ((GetObjectType(oGiver) == OBJECT_TYPE_PLACEABLE)

{ // if both are creatures, giving item better than taking since taking causes movement.

AssignCommand(oGiver, ActionGiveItem(oInventoryItem, oReceiver));

}

}

// are bags passed as full bags, or traversed?

// inventory space limits?

// stacked items?

void GiveAllInventory(object oGiver, object oReceiver)

{

//if ((GetObjectType(oGiver) != OBJECT_TYPE_CREATURE) && (GetObjectType(oReceiver) != OBJECT_TYPE_CREATURE))

//{

// PrettyError("GiveAllInventory(): At least one of Giver or Receiver must be a creature.");

// return;

//}

object oInventoryItem = GetFirstItemInInventory(oGiver);

while (oInventoryItem != OBJECT_INVALID)

{

TransferItem(oGiver, oReceiver, oInventoryItem);

//AssignCommand(oGiver, ActionGiveItem(oInventoryItem, oReceiver));

oInventoryItem = GetNextItemInInventory(oGiver);

}

}

// give gold, equipped items, and inventory

void GiveEverything(object oGiver, object oReceiver)

{

if (GetObjectType(oGiver) != OBJECT_TYPE_CREATURE)

{

PrettyError("GiveEverything(): Everything Giver must be a creature!");

return;

}

int iGold = GetGold(oGiver);// Remove gold to crate

AssignCommand(oReceiver, TakeGoldFromCreature(iGold, oGiver, FALSE));

GiveAllEquippedItems(oGiver, oReceiver);

GiveAllInventory(oGiver, oReceiver);

}

// Return number of items of Base Type in inventory

int CountInventoryItemsOfBaseType(int nBaseType, object oCreature=OBJECT_SELF)

{

object oItem = GetFirstItemInInventory(oCreature);

int iItemCount=0;

while (GetIsObjectValid(oItem))

{

if (GetBaseItemType(oItem) == nBaseType)

{

iItemCount++;

}

oItem = GetNextItemInInventory(oCreature);

}

return iItemCount;

}

object GetInventoryItemOfBaseType(int nBaseType, int nNth=1, object oCreature=OBJECT_SELF)

{

object oItem = GetFirstItemInInventory(oCreature);

int iItemCount=0;

while (GetIsObjectValid(oItem))

{

if (GetBaseItemType(oItem) == nBaseType)

{

iItemCount++;

if (iItemCount == nNth)

{

//PrettyDebug("Found requested item in inventory: " + GetName(oItem));

return (oItem);

}

}

oItem = GetNextItemInInventory(oCreature);

}

return OBJECT_INVALID;

}

// list items in inventory. Should work for placeables too.

int ListInventory(object oCreature=OBJECT_SELF)

{

object oItem = GetFirstItemInInventory(oCreature);

int i;

PrettyDebug("*** Items in the inventory of " + GetName(oCreature));

while (GetIsObjectValid(oItem))

{

i++;

PrettyDebug("Item " + IntToString(i) + ": " + GetName(oItem));

oItem = GetNextItemInInventory(oCreature);

}

return i;

}

// returns TRUE if an item was found

int EquipRandomArmorFromInventory()

{

int bRet = FALSE;

//PrettyDebug("Looking for something to change into");

int iCount = CountInventoryItemsOfBaseType(BASE_ITEM_ARMOR);

int iChoice = Random(iCount)+1;

object oArmor = GetInventoryItemOfBaseType(BASE_ITEM_ARMOR, iChoice);

if (GetIsObjectValid(oArmor))

{

bRet = TRUE;

ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_CHEST));

ActionEquipItem(oArmor, INVENTORY_SLOT_CHEST);

}

return (bRet);

}

// **** Functions for Identifying Item Types

// Is this a weapon of any type (including ammunition).

int GetIsWeapon(object oItem)

{

return(IPGetIsMeleeWeapon(oItem) || IPGetIsRangedWeapon(oItem) || IPGetIsProjectile(oItem));

}

// is this a shield?

int GetIsShield(object oItem)

{

int iType = GetBaseItemType(oItem);

int iRet = FALSE;

switch (iType)

{

case BASE_ITEM_SMALLSHIELD :

case BASE_ITEM_LARGESHIELD :

case BASE_ITEM_TOWERSHIELD :

iRet = TRUE;

break;

}

return iRet;

}

// Is this armor or shield?

int GetIsArmorOrShield(object oItem)

{

int iType = GetBaseItemType(oItem);

return ((iType == BASE_ITEM_ARMOR) || GetIsShield(oItem));

}

// Is item in specified (bit flag) category?

int GetIsItemCategory(object oItem, int iItemCategory)

{

int iThisCategory = GetItemCategory(oItem);

//int iRet = GetState(iThisCategory, iItemCategory);

//PrettyDebug(GetName(oItem) + " is in Category " + IntToString(iThisCategory) +

// " In passed category of [" + IntToString(iItemCategory) + "] = " + IntToString(iRet));

return (GetState(iThisCategory, iItemCategory));

}

// Returns basic category which is includes weapon, armor, and other

int GetItemCategory(object oItem)

{

int iRet;

if (!GetIsObjectValid(oItem))

iRet = ITEM_CATEGORY_NONE;

else if (GetIsWeapon(oItem))

iRet = ITEM_CATEGORY_WEAPON;

else if (GetIsArmorOrShield(oItem))

iRet = ITEM_CATEGORY_ARMOR_SHIELD;

else

iRet = ITEM_CATEGORY_OTHER;

/*

int iType = GetBaseItemType(oItem);

switch (iType)

{

// swords

case BASE_ITEM_SHORTSWORD :

case BASE_ITEM_LONGSWORD :

case BASE_ITEM_TWOBLADEDSWORD :

case BASE_ITEM_BASTARDSWORD :

case BASE_ITEM_GREATSWORD :

case BASE_ITEM_GREATAXE :

case BASE_ITEM_KATANA :

case BASE_ITEM_RAPIER :

case BASE_ITEM_SCIMITAR :

// axes

case BASE_ITEM_DOUBLEAXE :

case BASE_ITEM_BATTLEAXE :

case BASE_ITEM_HANDAXE :

case BASE_ITEM_DWARVENWARAXE :

// flails

case BASE_ITEM_LIGHTFLAIL :

case BASE_ITEM_HEAVYFLAIL :

// hammers

case BASE_ITEM_WARHAMMER :

case BASE_ITEM_LIGHTHAMMER :

// maces

case BASE_ITEM_DIREMACE :

case BASE_ITEM_LIGHTMACE :

// misc melee weapons

case BASE_ITEM_HALBERD :

case BASE_ITEM_DAGGER :

case BASE_ITEM_KAMA :

case BASE_ITEM_KUKRI :

case BASE_ITEM_MORNINGSTAR :

case BASE_ITEM_QUARTERSTAFF :

case BASE_ITEM_SHORTSPEAR :

case BASE_ITEM_SICKLE :

case BASE_ITEM_SCYTHE :

case BASE_ITEM_WHIP :

case BASE_ITEM_CLUB :

// creature weapons

case BASE_ITEM_CSLASHWEAPON :

case BASE_ITEM_CPIERCWEAPON :

case BASE_ITEM_CBLUDGWEAPON :

case BASE_ITEM_CSLSHPRCWEAP :

// ranged reapons

case BASE_ITEM_HEAVYCROSSBOW :

case BASE_ITEM_LIGHTCROSSBOW :

case BASE_ITEM_LONGBOW :

case BASE_ITEM_SHORTBOW :

case BASE_ITEM_SLING :

case BASE_ITEM_DART :

case BASE_ITEM_THROWINGAXE :

case BASE_ITEM_GRENADE :

case BASE_ITEM_SHURIKEN :

// ammunition

case BASE_ITEM_ARROW :

case BASE_ITEM_BULLET :

case BASE_ITEM_BOLT :

iRet = ITEM_CATEGORY_WEAPON;

break;

// armor/shield

case BASE_ITEM_ARMOR :

case BASE_ITEM_SMALLSHIELD :

case BASE_ITEM_LARGESHIELD :

case BASE_ITEM_TOWERSHIELD :

iRet = ITEM_CATEGORY_ARMOR_SHIELD;

break;

// equippable stuff

case BASE_ITEM_HELMET :

case BASE_ITEM_BELT :

case BASE_ITEM_BOOTS :

case BASE_ITEM_GLOVES :

case BASE_ITEM_RING :

case BASE_ITEM_AMULET :

case BASE_ITEM_BRACER :

case BASE_ITEM_CLOAK :

// misc items

case BASE_ITEM_MISCSMALL :

case BASE_ITEM_MISCMEDIUM :

case BASE_ITEM_MISCLARGE :

case BASE_ITEM_MISCTALL :

case BASE_ITEM_MISCWIDE :

case BASE_ITEM_MISCTHIN :

// magic items

case BASE_ITEM_MAGICROD :

case BASE_ITEM_MAGICSTAFF :

case BASE_ITEM_MAGICWAND :

case BASE_ITEM_SPELLSCROLL :

case BASE_ITEM_POTIONS :

// blank magic items

case BASE_ITEM_BLANK_POTION :

case BASE_ITEM_BLANK_SCROLL :

case BASE_ITEM_BLANK_WAND :

case BASE_ITEM_ENCHANTED_POTION :

case BASE_ITEM_ENCHANTED_SCROLL :

case BASE_ITEM_ENCHANTED_WAND :

// mundane items

case BASE_ITEM_HEALERSKIT :

case BASE_ITEM_BOOK :

case BASE_ITEM_SCROLL :

case BASE_ITEM_TORCH :

case BASE_ITEM_THIEVESTOOLS :

case BASE_ITEM_TRAPKIT :

case BASE_ITEM_KEY :

case BASE_ITEM_LARGEBOX :

case BASE_ITEM_CREATUREITEM :

case BASE_ITEM_GOLD :

case BASE_ITEM_GEM :

// crafting items

case BASE_ITEM_CRAFTMATERIALMED :

case BASE_ITEM_CRAFTMATERIALSML :

iRet = ITEM_CATEGORY_OTHER;

break;

}

*/

return (iRet);

}

// return slot item is equipped in on creature. -1 if not found

int GetSlotOfEquippedItem(object oItem, object oCreature)

{

int iSlot;

object oItemInSlot;

for (iSlot=0; iSlot nPlayerSkillRank)

{

nState = STATE_FAILED;

}

else

if (nNPCSkillRank < nPlayerSkillRank)

{

nState = STATE_WON;

}

else

if (nNPCSkillRank == nPlayerSkillRank)

{

nState = STATE_TIE;

}

if (nState == STATE_FAILED )

{

FloatingTextStrRefOnCreature(182468, oPC, FALSE);

}

else

if (nState == STATE_WON)

{

FloatingTextStrRefOnCreature(182470, oPC, FALSE);

}

else

if (nState == STATE_TIE)

{

FloatingTextStrRefOnCreature(182469, oPC, FALSE);

}

// * Hard cap of 30% max up or down

if (nAdjust > 30)

nAdjust = 30;

if (nAdjust < -30)

nAdjust = -30;

// nBonusMarkUp is added to the stores default mark up percentage on items sold (-100 to 100)

// (positive is good for player)

// Effect on selling items is only half of effect on buying items.

nBonusMarkUp = nBonusMarkUp + nAdjust/2;

// nBonusMarkDown is added to the stores default mark down percentage on items bought (-100 to 100)

// (negative is good for player)

nBonusMarkDown = nBonusMarkDown - nAdjust;

OpenStore(oStore, oPC, nBonusMarkUp, nBonusMarkDown);

}

// ginc_item_script

/*

include for item scripts

*/

// ChazM 9/8/06

// ChazM 9/12/06 added IsItemAcquiredByPartyMember()

//#include "x2_inc_itemprop"

#include "ginc_param_const"

#include "ginc_vars"

#include "ginc_debug"

/*

int SCRIPT_MODULE_ON_ACTIVATE_ITEM = 6;

int SCRIPT_MODULE_ON_ACQUIRE_ITEM = 7;

int SCRIPT_MODULE_ON_LOSE_ITEM = 8;

int SCRIPT_MODULE_ON_EQUIP_ITEM = 15;

int SCRIPT_MODULE_ON_UNEQUIP_ITEM = 16;

*/

//----------------------------------------------

// Prototypes

//----------------------------------------------

int IsItemAquiredByPartyMember();

int IsItemMarkedAsDone(object oItem, int iFlag=0);

void MarkItemAsDone(object oItem, int iFlag=0);

//----------------------------------------------

// Functions

//----------------------------------------------

// Can only be run use in an onAquire script.

// Checks if the item was aquired by a member of a

int IsItemAcquiredByPartyMember()

{

// Because a player can drag an item from a placeable’s inventory directly onto a companion’s portrait,

// bypassing his own inventory. This means the onAquire event fires on an unpossessed companion,

// who returns FALSE on the GetIsPC().

int iRet = FALSE;

object oPC = GetModuleItemAcquiredBy();

//if (GetFactionEqual(GetFirstPC(), oPC)) // won't work in multi-party

object oLeader = GetFactionLeader(oPC);

// only PC parties have faction leaders.

if (GetIsObjectValid(oLeader))

iRet = TRUE;

return (iRet);

}

// Check if marked as done.

// Optionally check if done for a specific flag

// recommened Usage: IsItemMarkedAsDone(oItem, SCRIPT_MODULE_ON_ACQUIRE_ITEM)

int IsItemMarkedAsDone(object oItem, int iFlag=0)

{

string sNVPName = GetDoneFlag(iFlag);

string sNVPList = GetLastName(oItem);

int iDoneOnce = StringToInt(GetNVPValue(sNVPList, sNVPName));

return (iDoneOnce);

}

// Set marked as done.

// Optionally set as done for a specific flag

// recommened Usage: MarkItemAsDone(oItem, SCRIPT_MODULE_ON_ACQUIRE_ITEM)

void MarkItemAsDone(object oItem, int iFlag=0)

{

string sNVPName = GetDoneFlag(iFlag);

string sNVPList = GetLastName(oItem);

sNVPList = AppendUniqueToNVP(sNVPList, sNVPName, IntToString(TRUE));

SetLastName(oItem, sNVPList);

}

// to be removed

/*

int ItemScriptAcquireRunBefore(object oItem)

{

return (FALSE);

}

*/

//void main(){}

// ginc_journal

/*

journal/quest related functions

*/

// ChazM 9/28/05

// ChazM 9/29/05 added GetQuestXPPercentRewarded(), RewardCappedQuestXP(), RewardPartyQuestXP(), RewardPartyCappedQuestXP(),

// renamed N2_Reward* functions, some temp functions

// ChazM 7/26/06 Added AwardXP(), SendMessageToParty()

#include "X0_I0_PARTYWIDE"

#include "ginc_vars"

#include "ginc_item"

//void main() {}

const string QPR_SUFFIX = "_XP_QPR";

// 2da table and column names

const string TABLE_XP_AWARD = "k_xp_awards";

const string COL_XP = "XP";

const string COL_STR_REF = "DescStrRef";

const string COL_TEXT = "DescriptionText";

//-------------------------------------------------

// Function Prototypes

//-------------------------------------------------

// Quest Info

int GetIsJournalQuestAssigned(string sPlotID, object oCreature);

int GetJournalQuestEntry(string sPlotID, object oCreature);

int GetQuestXPPercentRewarded(object oPC, string sQuestTag);

// Neverwinter 2 quest reward functions

// non-party rewards

int RewardCappedQuestXP(object oPC, string sQuestTag, int iQuestXPPercent = 100, int iQuestXPPercentCap = 100);

// party rewards

void RewardPartyUniqueItem(object oPC, string sItemResRef);

void RewardPartyItem(object oPC, string sItemResRef);

void RewardPartyGold(object oPC, int iGold);

void RewardPartyXP(object oPC, int iXP);

int RewardPartyQuestXP(object oPC, string sQuestTag, int iQuestXPPercent = 100);

void RewardPartyCappedQuestXP(object oPC, string sQuestTag, int iQuestXPPercent = 100, int iQuestXPPercentCap = 100);

// special objective rewards with accompanying text from k_xp_awards.2da

void AwardXP(object oPC, int iXPAwardID, int bWholeParty=TRUE);

// From: X0_I0_PARTYWIDE

//void GiveGoldToAllEqually(object oPC, int nGoldToDivide);

//void GiveGoldToAll(object oPC, int nGold);

//void GiveXPToAllEqually(object oPC, int nXPToDivide);

//void GiveXPToAll(object oPC, int nXP);

//-------------------------------------------------

// Function Definitions

//-------------------------------------------------

//----------------------------------------

// Quest Info

//----------------------------------------

// Determine if Quest sPlotID is not 0 (assumes non-zero as having been assigned).

int GetIsJournalQuestAssigned(string sPlotID, object oCreature)

{

return (GetJournalQuestEntry(sPlotID, oCreature) > 0);

}

/*

// Determine if Quest sPlotID is not 0, but has not reached an endpoint (entryID non-zero and non-endpoint).

GetIsJournalQuestActive(string sPlotID, object oCreature)

// Determine if Quest sPlotID has reached any endpoint.

GetIsJournalQuestFinished(string sPlotID, object oCreature)

*/

int GetJournalQuestEntry(string sPlotID, object oCreature)

{

int iQuestEntry = GetLocalInt(oCreature, "NW_JOURNAL_ENTRY" + sPlotID);

return (iQuestEntry);

}

// get the percent rewarded so far to this PC for this quest

int GetQuestXPPercentRewarded(object oPC, string sQuestTag)

{

string sXPQuestPercentRewarded = sQuestTag + QPR_SUFFIX;

int iQuestXPPercentRewarded = GetLocalInt(oPC, sXPQuestPercentRewarded);

return (iQuestXPPercentRewarded);

}

//----------------------------------------

// Quest Rewards (non-party)

//----------------------------------------

// reward xp amount to single player, subject to cap

// return amount awarded

int RewardCappedQuestXP(object oPC, string sQuestTag, int iQuestXPPercent = 100, int iQuestXPPercentCap = 100)

{

int iQuestXPPercentRewarded = GetQuestXPPercentRewarded(oPC, sQuestTag);

// reduce reward to cap amount if necessary

if ((iQuestXPPercentRewarded + iQuestXPPercent) > iQuestXPPercentCap)

{

iQuestXPPercent = iQuestXPPercentCap - iQuestXPPercentRewarded;

if (iQuestXPPercent < 0)

return (0);

}

string sXPQuestPercentRewarded = sQuestTag + QPR_SUFFIX;

int iQuestXPReward = (GetJournalQuestExperience(sQuestTag) * iQuestXPPercent)/100;

GiveXPToCreature(oPC, iQuestXPReward);

ModifyLocalInt(oPC, sXPQuestPercentRewarded, iQuestXPPercent);

return (iQuestXPReward);

}

//----------------------------------------

// Party Quest Rewards

//----------------------------------------

// reward w/ plot item - currently gives to all players so all can advance plot on their own

void RewardPartyUniqueItem(object oPC, string sItemResRef)

{

CreateItemOnFaction(oPC, sItemResRef);

}

// reward player w/ item - currently gives only one of the item - party must decide how to split it up.

void RewardPartyItem(object oPC, string sItemResRef)

{

CreateItemOnObject(sItemResRef, oPC);

}

// reward player w/ Gold - currently everyone gets full amount

void RewardPartyGold(object oPC, int iGold)

{

GiveGoldToAll(oPC, iGold);

//GiveGoldToAllEqually(oPC, iGold);

}

// reward player w/ XP - currently everyone gets full amount

// this should be used only for non-quest related XP rewards

void RewardPartyXP(object oPC, int iXP)

{

GiveXPToAll(oPC, iXP);

//GiveXPToAllEqually(oPC, iXP);

}

// Give XP rewards for quest. Amount given is tracked, but there is no cap.

// return amount awarded

int RewardPartyQuestXP(object oPC, string sQuestTag, int iQuestXPPercent = 100)

{

// Give the party XP

int iQuestXPReward = (GetJournalQuestExperience(sQuestTag) * iQuestXPPercent)/100;

GiveXPToAll(oPC, iQuestXPReward);

// track amount given

string sXPQuestPercentRewarded = sQuestTag + QPR_SUFFIX;

ModifyLocalIntOnFaction(oPC, sXPQuestPercentRewarded, iQuestXPPercent);

return (iQuestXPReward);

}

// reward xp amount to party, subject to cap

void RewardPartyCappedQuestXP(object oPC, string sQuestTag, int iQuestXPPercent = 100, int iQuestXPPercentCap = 100)

{

object oPartyMem = GetFirstFactionMember(oPC, TRUE);

while (GetIsObjectValid(oPartyMem))

{

RewardCappedQuestXP(oPartyMem, sQuestTag, iQuestXPPercent, iQuestXPPercentCap);

oPartyMem = GetNextFactionMember(oPC, TRUE);

}

}

void SendMessageToParty(object oPC, string sTlkText)

{

object oPartyMember = GetFirstFactionMember(oPC, TRUE); // PC's only

while(GetIsObjectValid(oPartyMember) == TRUE)

{

SendMessageToPC(oPartyMember, sTlkText);

// GiveXPToCreature(oPartyMember, iXP);

oPartyMember = GetNextFactionMember(oPC, TRUE); // PC's only

}

}

void AwardXP(object oPC, int iXPAwardID, int bWholeParty=TRUE)

{

string sWarnText;

int iXP = StringToInt(Get2DAString(TABLE_XP_AWARD, COL_XP, iXPAwardID));

int iStringRef = StringToInt(Get2DAString(TABLE_XP_AWARD, COL_STR_REF, iXPAwardID));

string sTlkText = GetStringByStrRef(iStringRef);

//string sText = Get2DAString(TABLE_XP_AWARD, COL_TEXT, iXPAwardID);

if (iStringRef == 0)

{

sWarnText = "DescStrRef not defined in k_xp_awards.2da for Row # " + IntToString(iXPAwardID);

PrettyError(sWarnText);

}

else if (sTlkText == "")

{

sWarnText = "String # " + IntToString(iStringRef) + " is empty or not found in Tlk table as specified in k_xp_awards.2da for Row # " + IntToString(iXPAwardID);

PrettyError(sWarnText);

}

if (bWholeParty)

{

SendMessageToParty(oPC, sTlkText);

RewardPartyXP(oPC, iXP);

}

else

{

SendMessageToPC(oPC, sTlkText);

GiveXPToCreature(oPC, iXP);

}

}

// From: X0_I0_PARTYWIDE

/********* REWARD FUNCTIONS ******************/

/*

// Given a gold amount, divides it equally among the party members

// of the given PC's party.

// None given to associates.

void GiveGoldToAllEqually(object oPC, int nGoldToDivide);

// Given a gold amount, gives that amount to all party members

// of the given PC's party.

// None given to associates.

void GiveGoldToAll(object oPC, int nGold);

// Given an XP amount, divides it equally among party members

// of the given PC's party.

// None given to associates.

// Tip: use with GetJournalQuestExperience() to

// get the amount of XP assigned to that quest in the

// journal.

void GiveXPToAllEqually(object oPC, int nXPToDivide);

// Given an XP amount, gives that amount to all party members

// of the given PC's party.

// None given to associates.

// Tip: use with GetJournalQuestExperience()

// get the amount of XP assigned to that quest in the

// journal.

void GiveXPToAll(object oPC, int nXP);

*/

// ginc_math

/*

Math related functions

*/

// ChazM 9/22/05

// ChazM 10/21/05 - added IsFloatNearInt()

// DBR - 2/13/06 - Adding optional parameter of precision to RandomFloat()

// BMA-OEI 5/4/06 - Added RandomFloatBetween(), RandomIntBetween()

// BMA/CGAW 5/18/06 - Updated RandomFloat(), RandomFloatBetween()

// ChazM 8/8/06 - Added SetLocalIntState(), GetLocalIntState(), SetState(), GetState()

// BMA-OEI 10/09/06 - Added GetHexStringDigitValue(), HexStringToInt()

//void main() {}

#include "ginc_debug"

const float EPSILON = 0.00001f;

//-------------------------------------------------

// Function Prototypes

//-------------------------------------------------

float RandomDelta(float fMagnitude);

float RandomFloat(float fNum);

float RandomFloatBetween( float fFloatA, float fFloatB=0.000f );

int RandomIntBetween( int nIntA, int nIntB=0 );

location GetNearbyLocation(location lTarget, float fDistance, float fFacingNoise=0.0f);

int IsIntInRange(int iVar, int iMin, int iMax);

int ScaleInt (int iNum, float fNum);

int IsFloatNearInt(float fValue, int iValue);

void SetLocalIntState(object oTarget, string sVariable, int iBitFlags, int bSet = TRUE);

int GetLocalIntState(object oTarget, string sVariable, int iBitFlags);

int SetState(int iValue, int iBitFlags, int bSet = TRUE);

int GetState(int iValue, int iBitFlags);

// Return ASCII value of hexadecimal digit sHexDigit

// * Returns -1 if sHexDigit is not a valid hex digit (0-aA)

int GetHexStringDigitValue( string sHexDigit );

// Return integer value of hexadecimal string sHexString

// * Can convert both "0x????" and "????" where "?" is a hex digit

int HexStringToInt( string sHexString );

//-------------------------------------------------

// Function Definitions

//-------------------------------------------------

// gives a random number between -fMagnitude and fMagnitude

// preserve 2 decimal places

float RandomDelta(float fMagnitude)

{

float fRet = IntToFloat(Random(FloatToInt(fMagnitude * 100.0f)))/100.0f;

if (d2()==1)

fRet = -fRet;

return (fRet);

}

// Returns a random float between fNum and 0. See RandomFloatBetween() for additional information.

float RandomFloat(float fNum)

{

float fRet = RandomFloatBetween( fNum );

return (fRet);

}

// Return a random float value between fFloatA and fFloatB

// NOTE: Maximum accuracy is produced when the difference between A and B is no more than:

// 32,767/10^N, where N = The number of contiguous digits to the right of the decimal point that are important.

// For instance, if the float should be accurate for three decimal places: xx.000, then to have maximum

// accuracy, the difference between A and B shouldn't be more than 32,767/10^3, or 32.767.

float RandomFloatBetween( float fFloatA, float fFloatB=0.000f )

{

float fLesserFloat;

float fGreaterFloat;

float fDifference;

float fRandomFloat;

float fMultiplier = IntToFloat( Random( 32767 ) ) / 32766.f;

if ( fFloatA = iMin) && (iVar fCompareValue + EPSILON)

return (FALSE);

if (fValue < fCompareValue - EPSILON)

return (FALSE);

return (TRUE);

}

// sets the bit flags on or off in the local int

void SetLocalIntState(object oTarget, string sVariable, int iBitFlags, int bSet = TRUE)

{

int iValue = GetLocalInt(oTarget, sVariable);

int iNewValue = SetState(iValue, iBitFlags, bSet);

SetLocalInt(oTarget, sVariable, iNewValue);

}

// returns TRUE or FALSE

// if multiple flags, will return true if any of iBitFlags are true.

int GetLocalIntState(object oTarget, string sVariable, int iBitFlags)

{

int iValue = GetLocalInt(oTarget, sVariable);

return (GetState(iValue, iBitFlags));

}

// sets state of iBitFlags in iValue and returns new value.

// if multiple flags, all will be modified

int SetState(int iValue, int iBitFlags, int bSet = TRUE)

{

if(bSet == TRUE)

{

iValue = iValue | iBitFlags;

}

else if (bSet == FALSE)

{

iValue = iValue & ~iBitFlags;

}

return (iValue);

}

// returns state of iBitFlag in iValue.

// if multiple flags, will return true if any are true.

int GetState(int iValue, int iBitFlags)

{

return (iValue & iBitFlags);

}

// Return ASCII value of hexadecimal digit sHexDigit

// * Returns -1 if sHexDigit is not a valid hex digit (0-aA)

int GetHexStringDigitValue( string sHexDigit )

{

int nValue = CharToASCII( sHexDigit );

if ( ( nValue >= 48 ) && ( nValue = 65 ) && ( nValue = 97 ) && ( nValue 0 )

{

int nPos = 0;

// Check for "0x" prefix

if ( nStringLen >= 2 )

{

if ( GetSubString( sHexString, 0, 2 ) == "0x" )

{

nPos = 2;

}

}

string sChar;

int nChar;

// For length of hex string

while ( nPos < nStringLen )

{

// Get digit at position nPos

sChar = GetSubString( sHexString, nPos, 1 );

nChar = GetHexStringDigitValue( sChar );

if ( nChar != -1 )

{

// "bitshift left 4", OR nChar

nReturn = ( nReturn 0 )

{

// Abort transition if domianted effect was found and removed

return;

}

}

}

// k_mod_load.nss campaign setting - override "Gather Party" transition

// TODO: What if oClicker is NPC?

if ( GetGlobalInt( VAR_GLOBAL_GATHER_PARTY ) == 1 )

{

GatherPartyTransition( oObject, oDestination );

return;

}

if ( GetIsPartyTransition( OBJECT_SELF ) == TRUE )

{

SinglePartyTransition( oObject, oDestination );

}

else

{

AssignCommand( oObject, JumpToObject( oDestination ) );

}

}

// Complain that party needs to be gathered!

void ReportPartyGather(object oPCF)

{

CloseGUIScreen(oPCF, "SCREEN_MESSAGEBOX_DEFAULT");

DelayCommand(

0.1,

DisplayMessageBox(

oPCF, // Display a message box for this PC

161846, // string ref to display

"", // Message to display

"", // Callback for clicking the OK button

"", // Callback for clicking the Cancel button

FALSE, // display the Cancel button

"SCREEN_MESSAGEBOX_DEFAULT", // Display the tutorial message box

-1, // OK string ref

"", // OK string

-1, // Cancel string ref

"" // Cancel string

)

);

}

// Check if party is gathered ( alive, not in conversation, and nearby )

int IsPartyGathered( object oPC )

{

object oArea = GetArea( oPC );

object oFM = GetFirstFactionMember( oPC, FALSE );

while ( GetIsObjectValid( oFM ) == TRUE )

{

// For all members in the area

if ( GetArea( oFM ) == oArea )

{

if ( ( GetIsDead( oFM ) == TRUE ) ||

( IsInConversation( oFM ) == TRUE ) ||

( GetDistanceBetween( oFM, oPC ) >= fGATHER_RADIUS ) )

{

return ( FALSE );

}

}

oFM = GetNextFactionMember( oPC, FALSE );

}

return ( TRUE );

}

// Transition to oTransitionTarget if oPC's party is gathered ( alive, not in conversation, and nearby )

// Otherwise, ask oPC to first gather the party.

void GatherPartyTransition( object oPC, object oTransitionTarget )

{

if ( ( GetIsPC( oPC ) == FALSE ) ||

( GetIsDead( oPC ) == TRUE ) ||

( IsInConversation( oPC ) == TRUE ) )

{

return;

}

if ( IsPartyGathered( oPC ) == FALSE )

{

ReportPartyGather( oPC );

return;

}

SinglePartyTransition( oPC, oTransitionTarget );

}

// Forces oPC's faction to be alive and commandable before sending

// them to oDestination via JumpPartyToArea().

void SinglePartyTransition( object oPC, object oDestination )

{

effect eRes = EffectResurrection();

// For each party member, revive and set commandable

object oFM = GetFirstFactionMember( oPC, FALSE );

while ( GetIsObjectValid( oFM ) == TRUE )

{

SetCommandable( TRUE );

ApplyEffectToObject( DURATION_TYPE_INSTANT, eRes, oFM );

oFM = GetNextFactionMember( oPC, FALSE );

}

// Transition and trigger FiredFromPartyTransition()

JumpPartyToArea( oPC, oDestination );

}

// ginc_trigger

/*

trigger related functions

*/

// ChazM 4/6/05

// ChazM 4/19/05 - added -1 Run option

// ChazM 5/3/05 - added Jump option, TalkNow, and CutsceneBars

// ChazM 5/6/05 - fixed TalkNow to start convo before running to player

// ChazM 5/25/05 - added OnceOnly

// EPF 6/3/05 - Making the entering object the target of the GetNearestObjectByTag() call, which is more reliable than having the

// trigger own the function.

// ChazM 6/14/05 - Fixed problem with target not being found.

// ChazM 6/14/05 - Blank for NPC_Tag now refers to the entering PC.

// ChazM 6/25/05 - Split functions from gtr_speak_node into this include

// ChazM 7/13/05 - Added bunch of PrintString()'s

// ChazM 7/13/05 - Modified StandardSpeakTriggerConditions() to support MultiUse

// EPF 7/29/05 - Speak trigger will now fire even if a player is in combat.

// ChazM 9/12/05 - Modified GetTriggerTarget()

// EPF 9/24/95 - found a second instance of a check that aborts the speak trigger if the player was in combat. Commented it out.

// BMA-OEI 1/6/06 - changed default GetTriggerTarget() to OBJECT_SELF

// BMA-OEI 1/13/06 - added GetTriggerTarget() warning, triggers as owners mess up random cams

// BMA-OEI 2/7/06 - Added comments/debug lines to GetTriggerTarget(), DoSpeakTrigger()

// EPF 2/10/06 - fixed compiler error in line 146.

// BMA-OEI 2/28/06 - added PrepareForConversation()

// BMA-OEI 3/6/06 - added CombatCutsceneSetup, updated StandardSpeakTriggerConditions() for any PC party member

// BMA-OEI 3/7/06 - modified CombatCutsceneCleanUp to use IPoint Cleaner

// BMA-OEI 3/21/06 - TODO: GetIsCompanionPossessionBlocked() check

// DBR 6/16/06 - Put in check for PC faction members in same area already in a MP cutscene. Also with BMA put in cases for all kinds of un-possessed companions setting off the trigger.

#include "ginc_cutscene"

#include "ginc_misc"

//#include "x2_inc_switches"

// ***** PROTOTYPES *****

// Return Target by tag or special identifier. Leave sTarget blank to use entering object.

object GetTriggerTarget(string sTarget, object oTriggeringObject);

// Check standard speak trigger conditions for entering object

int StandardSpeakTriggerConditions(object oEnter);

/* Starts a conversation based on variables set on trigger.

The following variables will be examined on the trigger. First 2 paramaters are required. Order is not important

NPC_Tag - Tag of creature to make comment. Must be in this area. Blank defaults to the entering PC.

Conversation - Conversation file to play.

Node - Node of the conversation to speak. Node indexes are set using gc_node() in the dialog conditionals.

Do not define a node 0, as this is reserved.

Run - Set to following:

2 - Target Jumps to PC

1 - Target runs to PC

0 - (default) Target Walks to PC

-1 - Target Stays Put (and TalkNow=1 by default)

TalkNow - Set to following:

0 - (default) use default based on Run mode.

1 - talk immediately, regardless of distance

2 - only talk when close (default except when Run = -1)

CutsceneBars - Set to following:

0 - (default) no cutscene bars

1 - show cutscene bars

OnceOnly - Controls whether or not NPC's Node index is cleared after it's first use. Set to following:

0 - (default) the node index is not reset by gc_node

1 - gc_node will reset the node index to 0 so that it only recognizes it once

MultiUse - Controls whether the Speak Trigger fires only once or on every enter

0 - (default) Only triggers once

1 - Triggers every time.

CombatCutsceneSetup - Controls whether to Plot party, Hide hostiles, hold AI for duration of conversation.

0 - (default) Normal speak trigger

1 - Use CombatCutsceneSetup() and QueueCombatCutsceneCleanUp()

*/

void DoSpeakTrigger(object oEnter);

// ***** DEFINITIONS *****

// Return Speaker Target by tag or special identifier. Leave sTarget blank to use triggering object.

object GetTriggerTarget(string sTarget, object oTriggeringObject)

{

object oTarget = OBJECT_INVALID;

if (sTarget == "")

{

oTarget = oTriggeringObject;

}

else

{

oTarget = GetNearestObjectByTag(sTarget, oTriggeringObject);

if (GetIsObjectValid(oTarget) == FALSE)

{

oTarget = GetNearestObjectByTag(sTarget);

}

}

if (GetIsObjectValid(oTarget) == FALSE)

{

PrettyDebug("GetTriggerTarget: ERROR - NPC target: " + sTarget + " was not found!");

}

return (oTarget);

}

// Standard SpeakTrigger should fire only if oEnter is in the PC party

int StandardSpeakTriggerConditions(object oEnter)

{

// Check if oEnter is in the PC's faction

if ( GetIsPC( oEnter ) == FALSE )

{

PrettyDebug( "SpeakTrigger: " + GetName(oEnter) + " is not a PC." );

object oPC = GetFirstPC();

if ( GetFactionEqual( oEnter, oPC ) == FALSE )

{

PrettyDebug( "SpeakTrigger: " + GetName(oEnter) + " is not in " + GetName(oPC) + "'s party." );

return ( FALSE );

}

}

// Check if SpeakTrigger can fire more than once

int bMultiUse = GetLocalInt(OBJECT_SELF, "MultiUse");

if ((bMultiUse == FALSE) && IsMarkedAsDone())

{

PrettyDebug( "SpeakTrigger: cannot fire more than once" );

return (FALSE);

}

// EPF 7/29/05 -- after modifying DetermineCombatRound(), it should be okay to fire a speak trigger, even when in combat.

// if (GetIsInCombat(oPC))

// return FALSE;

/* This is prone to error by typing scripts as var values and removed for now:

// ConditionScript - Condition script to run on entering PC to see if speak trigger should fire.

// use SetExecutedScriptReturnValue() with TRUE or FALSE to check conditions

// use stc_template as a template for the speak trigger conditions

string sConditionScript = GetLocalString(OBJECT_SELF, "ConditionScript");

if (sConditionScript != "")

if (!ExecuteScriptAndReturnInt(sConditionScript, oPC))

return FALSE;

*/

//DBR 6/16/06 - Check to make sure no one in this area is in a MP conversation

object oPCF = GetFirstFactionMember(oEnter,FALSE);

while (GetIsObjectValid(oPCF))

{

if ((IsInMultiplayerConversation(oPCF))&&(GetArea(oEnter)==GetArea(oPCF))) //MP conversation going on in this area

{

DelayCommand( 0.1f, PrettyError( "SpeakTrigger: " + GetName(oPCF) + " is already in a MP cutscene." ) );

return FALSE;

}

oPCF = GetNextFactionMember(oEnter,FALSE);

}

PrettyDebug( "SpeakTrigger: " + GetName(oEnter) + " passed the StandardSpeakTriggerConditions!" );

return (TRUE);

}

void DoSpeakTrigger(object oEnter)

{

string sNPCTag = GetLocalString(OBJECT_SELF, "NPC_Tag");

string sConversation = GetLocalString(OBJECT_SELF, "Conversation");

int iNodeIndex = GetLocalInt(OBJECT_SELF, "Node");

int nRun = GetLocalInt(OBJECT_SELF, "Run");

// Don't use 0 as user input for this since that is default if not there.

int nTalkNow = GetLocalInt(OBJECT_SELF, "TalkNow");

int bCutsceneBars = GetLocalInt(OBJECT_SELF, "CutsceneBars");

int bOnceOnly = GetLocalInt(OBJECT_SELF, "OnceOnly");

int bCombatCutsceneSetup = GetLocalInt(OBJECT_SELF, "CombatCutsceneSetup");

// Default values of ActionStartConversation()

int bPrivateConversation = FALSE;

int bPlayHello = TRUE;

int bIgnoreStartDistance = FALSE;

int bDisableCutsceneBars = TRUE;

bDisableCutsceneBars = !bCutsceneBars;

// Find conversation Speaker

// BMA-OEI 3/21/06 should we verify this in StandardSpeakTriggerConditions?

object oTarg = GetTriggerTarget(sNPCTag, oEnter);

if (GetIsObjectValid(oTarg) == FALSE)

{

PrettyDebug("DoSpeakTrigger: ERROR - Target speaker is invalid!");

return;

}

if (GetIsPC(oTarg) == TRUE)

{

PrettyDebug("DoSpeakTrigger: WARNING - SPEAKER: " + GetName(oTarg) + " is controlled by a PC!");

}

// DetermineCombatRound() modified so hopefully it should be okay to converse even while in combat.

// EPF 9/24/05

// if (GetIsInCombat(oTarg))

// {

// return;

// }

// Store info on target object

SetLocalInt(oTarg, "sn_NodeIndex", iNodeIndex );

SetLocalInt(oTarg, "sn_OnceOnly", bOnceOnly );

// If CombatCutsceneSetup is required

if (bCombatCutsceneSetup == 1)

{

CombatCutsceneSetup(oEnter);

}

// Revive and remove negative effects on PC party and oTarg

MakeConversable(oEnter, TRUE);

MakeConversable(oTarg, FALSE);

ClearPartyActions(oEnter, TRUE);

//DBR 6/16/06

if (GetIsOwnedByPlayer(oEnter) && (!GetIsPC(oEnter))) //oEnter is A "created" character not being possessed by anyone.

{

oEnter = SetOwnersControlledCompanion(GetControlledCharacter(oEnter),oEnter); //Warp the PC into his created character and return

}

else if (GetIsCompanionPossessionBlocked(oEnter)&&(!GetIsPC(oEnter))&&(!GetIsOwnedByPlayer(oEnter))) // oEnter is a companion who is not being controlled, and is blocked from possession

{

if (GetCanTalkToNonPlayerOwnedCreatures(oTarg)) //Target can talk to anyone, so whoever the faction leader is A-O-K to talk to this guy

{

object oLeader = GetFactionLeader(oEnter);

AssignCommand(oLeader, ClearAllActions(TRUE));

AssignCommand(oLeader, JumpToObject(oEnter));

oEnter = oLeader;

}

else //Picky NPC, force possession of an owned character and use them (since it is companion only in this case, any PC will do

{

object oLeader = GetFactionLeader(oEnter);

object oOwned = SetOwnersControlledCompanion(oLeader,GetOwnedCharacter(oLeader)); //Warp the PC into his created character and return

AssignCommand(oOwned, ClearAllActions(TRUE));

AssignCommand(oOwned, JumpToObject(oEnter));

oEnter = oOwned;

}

}

else if (!GetIsCompanionPossessionBlocked(oEnter)&&(!GetIsPC(oEnter))&&(!GetIsOwnedByPlayer(oEnter))) // oEnter is a companion who is not being controlled, but can be

{

oEnter = SetOwnersControlledCompanion(GetFactionLeader(oEnter),oEnter); //Force possession of Faction Leader into Companion

}

//All other cases involve oEnter being a PC or companion who is CURRENTLY being possessed by a player. They are fine to pass in, and engine will handle a swap if need be.

// If oEnter is still not controlled by a player

if (GetIsPC(oEnter) == FALSE)

{

object oLeader = GetFactionLeader(oEnter);

AssignCommand(oLeader, ClearAllActions(TRUE));

AssignCommand(oLeader, JumpToObject(oEnter));

oEnter = oLeader;

}

AssignCommand(oTarg, ClearAllActions(TRUE));

// If oTarg shouldn't move, start conversation immediately

if (nRun == -1)

{

nTalkNow = 1;

}

bIgnoreStartDistance = TRUE;

if (nTalkNow == 1)

{

AssignCommand(oTarg, ActionStartConversation(oEnter, sConversation, bPrivateConversation, bPlayHello, bIgnoreStartDistance, bDisableCutsceneBars));

}

else

{

PrettyDebug("DoSpeakTrigger: WARNING - TalkNow = 0, PC may not be ready for conversation!");

// If oTarg is too far from the PC

if (GetDistanceBetween(oEnter, oTarg) >= 3.0f)

{

bIgnoreStartDistance = FALSE;

switch (nRun)

{

case -1: // Don't move

break;

case 0: // Walk

AssignCommand(oTarg, ActionForceMoveToObject(oEnter, FALSE, 2.0f));

break;

case 1: // Run

AssignCommand(oTarg, ActionForceMoveToObject(oEnter, TRUE, 2.0f));

break;

case 2: // Jump

AssignCommand(oTarg, JumpToObject(oEnter));

break;

}

}

AssignCommand(oTarg, ActionStartConversation(oEnter, sConversation, bPrivateConversation, bPlayHello, bIgnoreStartDistance, bDisableCutsceneBars));

}

// If CombatCutsceneSetup is required

//if (bCombatCutsceneSetup == 1)

//{

// object oIPCleaner = CreateObject(OBJECT_TYPE_PLACEABLE, IPC_RESREF, GetLocation(oEnter));

// AssignCommand(oIPCleaner, QueueCombatCutsceneCleanUp());

//}

MarkAsDone();

}

// ginc_utility.nss

/*

This is the main utility script for NWN2

*/

// FAB 10/12/04

// ChazM 3/8/05 - file name changed

// BMA-OEI 8/03/05 - error checking if waypoint not valid, rewrote for legibility

// BMA-OEI 8/04/05 - added UT_FakeEncounter()

// BMA-OEI 8/28/05 - added UT_SpawnAtWP()

// **************

// SCRIPT DEFINES

// **************

// This function spawns resref sTemplate at each waypoint sWaypoint in the module.

void UT_FakeEncounter(string sTemplate, string sWaypoint, int bUseAppearAnimation = FALSE);

// This function spawns someone with resref sObject at waypoint "sp_".

// This command can be delayed and the object can be given a new tag after being spawned.

// If a delay isn't necessary then use GN_Spawn.

void UT_SpawnDelay(string sObject, int nInstance = 0, float fDelay = 0.0, string sNewTag = "");

// This function spawns someone with resref sObject at waypoint "sp_".

// It can be given a new tag after it is spawned. The function returns the object ID of what was created.

// If a delay is necessary then use GN_SpawnDaly (but you won't be able to get the object ID from that function).

object UT_Spawn(string sObject, int nInstance = 0, string sNewTag = "");

object UT_SpawnAtWP(string sTemplate, string sWaypoint, string sNewTag = "", int bUseAppearAnimation = FALSE);

// ***********************************

// PRIVATE FUNCTIONS - don't use these

// ***********************************

object UT_CreateObjectAtLocation(string sObject, location lLoc, string sNewTag, int bUseAppearAnimation = FALSE)

{

object oCreature;

if (sNewTag == "")

{

oCreature = CreateObject(OBJECT_TYPE_CREATURE, sObject, lLoc);

}

else

{

oCreature = CreateObject(OBJECT_TYPE_CREATURE, sObject, lLoc, FALSE, sNewTag);

}

return oCreature;

}

void UT_CreateObjectAtLocVoid(string sObject, location lLoc, string sNewTag, int bUseAppearAnimation = FALSE)

{

UT_CreateObjectAtLocation(sObject, lLoc, sNewTag, bUseAppearAnimation);

}

// **************

// MAIN FUNCTIONS

// **************

void UT_FakeEncounter(string sTemplate, string sWaypoint, int bUseAppearAnimation = FALSE)

{

object oWP;

int nCount = 0;

location lLoc;

oWP = GetObjectByTag(sWaypoint, nCount);

while (GetIsObjectValid(oWP) == TRUE)

{

lLoc = GetLocation(oWP);

UT_CreateObjectAtLocVoid(sTemplate, lLoc, "", bUseAppearAnimation);

nCount = nCount + 1;

oWP = GetObjectByTag(sWaypoint, nCount);

}

PrintString("ginc_utility: UT_FakeEncounter() spawned " + IntToString(nCount) + " " + sTemplate);

}

void UT_SpawnDelay(string sTemplate, int nInstance = 0, float fDelay = 0.0, string sNewTag = "")

{

object oWP;

location lLoc;

if (nInstance != 0)

{

oWP = GetWaypointByTag("sp_" + sTemplate + IntToString(nInstance));

}

else

{

oWP = GetWaypointByTag("sp_" + sTemplate);

}

if (GetIsObjectValid(oWP) == TRUE)

{

lLoc = GetLocation(oWP);

DelayCommand(fDelay, UT_CreateObjectAtLocVoid(sTemplate, lLoc, sNewTag));

}

else

{

PrintString("ginc_utility: UT_SpawnDelay() invalid waypoint");

}

}

object UT_Spawn(string sTemplate, int nInstance = 0, string sNewTag = "")

{

object oCreature;

object oWP;

location lLoc;

if (nInstance != 0)

{

oWP = GetWaypointByTag("sp_" + sTemplate + IntToString(nInstance));

}

else

{

oWP = GetWaypointByTag("sp_" + sTemplate);

}

if (GetIsObjectValid(oWP) == TRUE)

{

lLoc = GetLocation(oWP);

oCreature = UT_CreateObjectAtLocation(sTemplate, lLoc, sNewTag);

}

else

{

PrintString("ginc_utility: UT_Spawn() invalid waypoint");

}

return oCreature;

}

object UT_SpawnAtWP(string sTemplate, string sWaypoint, string sNewTag = "", int bUseAppearAnimation = FALSE)

{

object oCreature;

object oWP = GetObjectByTag(sWaypoint);

location lWP = GetLocation(oWP);

oCreature = UT_CreateObjectAtLocation(sTemplate, lWP, sNewTag, bUseAppearAnimation);

return oCreature;

}

// TEST MAIN - uncomment to debug the include file

/*void main()

{

}*/

// ginc_var_ops

//

// include file for common functionality with g*_global_* and g*_local_* scripts

// ChazM 4/12/05 (mod)

// ChazM 5/4/05 added CalcNewIntValue()

// ChazM 6/15/05 modified CompareInts() to be able to reference a companion's influence

// BMA-OEI 1/13/06 modified CheckVariableFloat for EPSILON check

// ChazM 8/24/06 CompareInts() no longer able to reference a companion's influence to remove dependency on kinc_companion

#include "ginc_companion"

#include "ginc_math"

// Prototypes

int CheckVariableFloat(float fValue, string sOperator, float fCheck);

int CheckVariableInt(int nValue, string sOperator, int nCheck);

int CompareInts(int nValue, string sCheck);

int CalcNewIntValue(int nOldValue, string sChange, int bDefaultIsDelta = FALSE);

// CheckVariableFloat()

//

// Evaluates the expression [fValue] [sOperator] [fCheck], as in, say, 5 < 3

// and returns the result -- true or false

// sOperator is =, >, fCheck);

}

//LESS THAN

if ( sOperator == "")

{

return (nValue > nCheck);

}

//LESS THAN

if ( sOperator == "" || sOperator == "= 0)

sValue = "";

nPostion = FindSubString(sValue,"&");

if (nPostion >= 0)

sValue = "";

return (sValue);

}

// output all on one line tabbed out 1 additional level

string XML(string sTag, string sValue)

{

sValue = ReplaceSpecialChars(sValue);

string sRet = "" + sValue + "" + LF;

int iNumSpaces = (giXMLTabLevel + 1) * TAB_SPACES;

string sSpaces = GetStringLeft(BLANK_SPACE_100, iNumSpaces);

PrintString(sSpaces + sRet);

return sRet;

}

// =======================================================================

// ABILITIES

// =======================================================================

string GetAbilityName(int iAbility)

{

string sRet;

switch (iAbility)

{

case ABILITY_STRENGTH: sRet = "Strength"; break;

case ABILITY_CONSTITUTION: sRet = "Constitution"; break;

case ABILITY_DEXTERITY: sRet = "Dexterity"; break;

case ABILITY_INTELLIGENCE: sRet = "Intelligence"; break;

case ABILITY_WISDOM: sRet = "Wisdom"; break;

case ABILITY_CHARISMA: sRet = "Charisma"; break;

}

return (sRet);

}

// Create a single Ability XML output

void XMLAbility(object oPC, int iAbility)

{

XMLOpen(TAG_ABILITY);

XML(TAG_ABILITY_NAME, GetAbilityName(iAbility));

XML(TAG_ABILITY_SCORE, IntToString(GetAbilityScore(oPC, iAbility)));

XML(TAG_ABILITY_MODIFIER, IntToString(GetAbilityModifier(iAbility, oPC)));

XMLClose(TAG_ABILITY);

}

// Create all Abilities XML output

void XMLAbilities(object oPC)

{

XMLOpen(TAG_ABILITIES);

XMLAbility(oPC, ABILITY_STRENGTH);

XMLAbility(oPC, ABILITY_CONSTITUTION);

XMLAbility(oPC, ABILITY_DEXTERITY);

XMLAbility(oPC, ABILITY_INTELLIGENCE);

XMLAbility(oPC, ABILITY_WISDOM);

XMLAbility(oPC, ABILITY_CHARISMA);

XMLClose(TAG_ABILITIES);

}

// =======================================================================

// ITEMS

// =======================================================================

void XMLItemProperty(itemproperty ipItemProperty)

{

int iPropType = GetItemPropertyType(ipItemProperty);

int iPropTypeStrRef = StringToInt(Get2DAString(ITEM_PROPS_2DA, ITEM_PROPS_NAME_COL, iPropType));

string sPropType = GetStringByStrRef(iPropTypeStrRef);

XMLOpen(TAG_ITEM_PROPERTY);

XML(TAG_ITEM_PROPERTY_TYPE, sPropType);

XMLClose(TAG_ITEM_PROPERTY);

}

void XMLItemProperties(object oItem)

{

XMLOpen(TAG_ITEM_PROPERTIES);

//Get the first itemproperty

itemproperty ipLoop=GetFirstItemProperty(oItem);

//Loop for as long as the ipLoop variable is valid

while (GetIsItemPropertyValid(ipLoop))

{

XMLItemProperty(ipLoop);

//Next itemproperty on the list...

ipLoop=GetNextItemProperty(oItem);

}

XMLClose(TAG_ITEM_PROPERTIES);

}

void XMLBaseItemType(object oItem)

{

int iBIT = GetBaseItemType(oItem);

int iBITStrRef = StringToInt(Get2DAString(BIT_2DA, BIT_NAME_COL, iBIT));

string sBITName = GetStringByStrRef(iBITStrRef);

XML(TAG_ITEM_TYPE, sBITName);

}

// Create a single Item XML output

void XMLItem(object oItem)

{

XMLOpen(TAG_ITEM);

XML(TAG_ITEM_NAME, GetName(oItem));

//XML(TAG_ITEM_VALUE, IntToString(GetValue(oItem)));

XML(TAG_ITEM_WEIGHT, IntToString(GetWeight(oItem)));

XML(TAG_ITEM_STACK_SIZE, IntToString(GetItemStackSize(oItem)));

XML(TAG_ITEM_AC_VALUE, IntToString(GetItemACValue(oItem)));

XML(TAG_ITEM_CHARGES, IntToString(GetItemCharges(oItem)));

XMLBaseItemType(oItem);

XMLItemProperties(oItem);

XMLClose(TAG_ITEM);

}

// =======================================================================

// EQUIPPED ITEMS

// =======================================================================

void XMLEquippedItems(object oPC)

{

int iSlot;

object oInventoryItem;

for (iSlot = 0; iSlot < NUM_INVENTORY_SLOTS; iSlot++)

{

oInventoryItem = GetItemInSlot(iSlot, oPC);

if (oInventoryItem != OBJECT_INVALID)

XMLItem(oInventoryItem);

}

}

// Create all EQUIPPED ITEMS XML output

void XMLEquipment(object oPC)

{

XMLOpen(TAG_EQUIPPED_ITEMS);

XMLEquippedItems(oPC);

XMLClose(TAG_EQUIPPED_ITEMS);

}

// =======================================================================

// INVENTORY ITEMS

// =======================================================================

void XMLInventoryItems(object oPC)

{

object oInventoryItem = GetFirstItemInInventory(oPC);

while (oInventoryItem != OBJECT_INVALID)

{

XMLItem(oInventoryItem);

oInventoryItem = GetNextItemInInventory(oPC);

}

}

// Create all INVENTORY XML output

void XMLInventory(object oPC)

{

XMLOpen(TAG_INVENTORY_ITEMS);

XMLInventoryItems(oPC);

XMLClose(TAG_INVENTORY_ITEMS);

}

// =======================================================================

// SKILLS

// =======================================================================

// Create a single Skill XML output (if creature has the skill)

void XMLSkill (int nSkill, object oPC)

{

int iSkillRank = GetSkillRank(nSkill, oPC);

int iBaseSkillRank = GetSkillRank(nSkill, oPC, TRUE);

if (GetHasSkill(nSkill, oPC) && (iBaseSkillRank>=0))

{

int iSkillName = StringToInt(Get2DAString(SKILLS_2DA, SKILLS_NAME_COL, nSkill));

string sSkillName = GetStringByStrRef(iSkillName);

int iSkillDesc = StringToInt(Get2DAString(SKILLS_2DA, SKILLS_DESC_COL, nSkill));

string sSkillDesc = GetStringByStrRef(iSkillDesc);

string sTrained;

if (iBaseSkillRank == 0)

sTrained = TEXT_FALSE;

else

sTrained = TEXT_TRUE;

XMLOpen(TAG_SKILL);

XML(TAG_SKILL_NAME, sSkillName);

XML(TAG_SKILL_RANK, IntToString(iSkillRank));

XML(TAG_SKILL_RANK_BASE, IntToString(iBaseSkillRank));

XML(TAG_SKILL_TRAINED, sTrained);

//XML(TAG_SKILL_DESCRIPTION, sSkillDesc);

XMLClose(TAG_SKILL);

}

}

// Create all Skills XML output

void XMLSkills(object oPC)

{

int i;

XMLOpen(TAG_SKILLS);

for (i=1;i nOther ) )

{

nClass = 1;

}

if ( ( nOther > nMelee ) && ( nOther > nMagic ) )

{

nClass = 2;

}

switch ( nClass )

{

case 0:

EquipMelee( oCreature );

break;

case 1:

EquipMagic( oCreature );

break;

case 2:

EquipOther( oCreature );

break;

}

EquipWeapon( oCreature );

}

void main()

{

PrettyDebug( "gr_equip_comps: equiping companions with high level gear" );

object oPC = GetFirstPC();

object oFM = GetFirstFactionMember( oPC, FALSE );

while ( GetIsObjectValid(oFM) )

{

// Give all roster members in party some equipment

if ( GetIsRosterMember(oFM) == TRUE )

{

Equip( oFM );

}

oFM = GetNextFactionMember( oPC, FALSE );

}

}

// gr_followleader

/*

Sets player to auto-follow the party leader.

This script for use with the dm_runscript console command

*/

// ChazM 11/6/05

void main()

{

object oLeader = GetFactionLeader(OBJECT_SELF);

if (GetIsObjectValid(oLeader) == TRUE)

{

AssignCommand(OBJECT_SELF, ActionForceFollowObject(oLeader, 3.0f));

}

}

// gr_followpos

/*

test script for setting up follow positions

*/

// ChazM 8/9/06

#include "ginc_debug"

#include "ginc_companion"

void main()

{

object oPC = GetFirstPC();

object oWho = GetFactionLeader(oPC);

object oMember = GetFirstFactionMember( oPC, FALSE );

int i = 0;

float fFollowDistance;

PrettyDebug("Everyone follow " + GetName(oWho) + "!");

while ( GetIsObjectValid( oMember ) == TRUE )

{

AssignCommand(oMember, ClearAllActions());

PrettyDebug(GetName(oMember) + " Follow Position = " + IntToString(i) );

SetLocalInt(oMember, "FollowPos", i); // this will by the default AI, but not in gb_comp_heart yet.

fFollowDistance = GetFollowDistance(oMember);

AssignCommand(oMember, ActionForceFollowObject(oWho, fFollowDistance, i));

i++;

oMember = GetNextFactionMember( oPC, FALSE );

}

}

// gr_henchinv

/*

open inventory of henchman 1.

This script for use with the dm_runscript console command

*/

// ChazM 11/13/05

void main()

{

OpenInventory(GetHenchman(), OBJECT_SELF);

}

//gr_input_test

#include "ginc_crafting"

void main()

{

object oPC = OBJECT_SELF;

object oItem = GetFirstItemInInventory(oPC);

SpeakString("about to rename item: " + GetName(oItem));

SetEnchantedItemName(oPC, oItem);

// DisplayInputBox( OBJECT_SELF, 0, "Test Message", "gui_input_ok", "", 1,

// "SCREEN_STRINGINPUT_MESSAGEBOX", 0, "OKAY", 0, "CANCEL", "DefaultSTR", "VariableSTring" );

}

// gr_instrument

/*

Gives player the instrument of death.

This script for use with the dm_runscript console command

*/

// ChazM 11/23/05

void AddSuperSpellItemProp(object oItem, int iSpell)

{

itemproperty ipAdd = ItemPropertyCastSpell(iSpell, IP_CONST_CASTSPELL_NUMUSES_UNLIMITED_USE);

AddItemProperty(DURATION_TYPE_PERMANENT, ipAdd, oItem);

}

// create an item and add super abilities to it.

void MakeInstrument()

{

object oItem = CreateItemOnObject("nw_it_novel002");

AddSuperSpellItemProp(oItem, IP_CONST_CASTSPELL_POWER_WORD_KILL_17);

AddSuperSpellItemProp(oItem, IP_CONST_CASTSPELL_WEIRD_17);

AddSuperSpellItemProp(oItem, IP_CONST_CASTSPELL_DOMINATE_MONSTER_17);

AddSuperSpellItemProp(oItem, IP_CONST_CASTSPELL_METEOR_SWARM_17);

AddSuperSpellItemProp(oItem, IP_CONST_CASTSPELL_SUMMON_CREATURE_IX_17);

AddSuperSpellItemProp(oItem, IP_CONST_CASTSPELL_WAIL_OF_THE_BANSHEE_17);

}

void main()

{

object oItem = CreateItemOnObject("instodeath");

//MakeInstrument();

}

// gr_item_report

/*

*/

// ChazM 10/26/06

#include "ginc_debug"

void main()

{

object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

object oItem = GetFirstItemInInventory(oPC);

string sOut = "First item in inventory: " + GetName(oItem) + " tag: " + GetTag(oItem) + " ResRef: " + GetResRef(oItem);

PrettyDebug(sOut);

AssignCommand(oPC, SpeakString(sOut));

}

// gr_jumpleader

/*

Teleports player to the party leader.

This script for use with the dm_runscript console command

*/

// ChazM 11/6/05

void main()

{

object oLeader = GetFactionLeader(OBJECT_SELF);

if (GetIsObjectValid(oLeader) == TRUE)

{

AssignCommand(OBJECT_SELF, JumpToObject(oLeader));

}

}

// gr_jumptodm

/*

jumpts player to the a DM.

This script for use with the dm_runscript console command

*/

// ChazM 11/13/05

void main()

{

object oDM = GetObjectByTag("gr_dm");

if (GetIsObjectValid(oDM) == TRUE)

{

AssignCommand(OBJECT_SELF, JumpToObject(oDM));

}

}

// gr_kill_aoe( float fRadius )

// Inflict massive damage to hostiles within fRadius meters

// BMA-OEI 8/30/06

#include "ginc_debug"

const float KILL_AOE_MIN_RADIUS = 9.0f;

const int KILL_AOE_MASSIVE_DAMAGE = 9999;

void main( float fRadius )

{

if ( fRadius < 0.1f )

{

fRadius = KILL_AOE_MIN_RADIUS;

}

object oKiller = OBJECT_SELF;

location lKiller = GetLocation( OBJECT_SELF );

effect eKill = EffectDamage( KILL_AOE_MASSIVE_DAMAGE );

object oTarget = GetFirstObjectInShape( SHAPE_SPHERE, fRadius, lKiller, TRUE, OBJECT_TYPE_CREATURE );

PrettyDebug( "gr_kill_aoe: searching for creatures hostile to " + GetName(oKiller) + " within " + FloatToString(fRadius) + " meters" );

while ( GetIsObjectValid( oTarget ) == TRUE )

{

if ( ( GetIsDead( oTarget ) == FALSE ) && ( GetIsEnemy( oTarget ) == TRUE ) )

{

DelayCommand( 0.1f, ApplyEffectToObject( DURATION_TYPE_INSTANT, eKill, oTarget ) );

PrettyMessage( "gr_kill_aoe: ** applying " + IntToString(KILL_AOE_MASSIVE_DAMAGE) + " damage to " + GetName(oTarget) );

}

oTarget = GetNextObjectInShape( SHAPE_SPHERE, fRadius, lKiller, TRUE, OBJECT_TYPE_CREATURE );

}

}

// gr_lostitems

/*

Opens up the LostItems store for the player. If no lost items store is found,

one is created.

Plot items aren't added to this store if it doesn't exist, so this command

be run once at the beginning of the module to make sure one is created.

This script for use with the dm_runscript console command

*/

// ChazM 11/6/05

const string TAG_LOST_ITEMS = "LostItems";

const string RR_LOST_ITEMS = "nw_lostitems";

void main()

{

object oStore = GetObjectByTag(TAG_LOST_ITEMS);

if (!GetIsObjectValid(oStore))

{

PrintString ("Creating Lost Items store");

oStore = CreateObject(OBJECT_TYPE_STORE, RR_LOST_ITEMS, GetLocation(OBJECT_SELF));

SetStoreMaxBuyPrice(oStore, 0);

}

OpenStore(oStore, OBJECT_SELF, -100);

}

// gr_outofmyway.nss

/*

Force nearby creatures to move away from the PC.

*/

// BMA-OEI 5/02/06

#include "ginc_debug"

const int MAX_CREATURES = 10;

const float MAX_DISTANCE = 5.0f;

void main()

{

location lTarget = GetLocation( OBJECT_SELF );

effect eVis = EffectVisualEffect( 535 );

ApplyEffectToObject( DURATION_TYPE_TEMPORARY, eVis, OBJECT_SELF, 3.0f );

int nCount = 1;

object oCreature = GetNearestCreature( CREATURE_TYPE_IS_ALIVE, CREATURE_ALIVE_TRUE, OBJECT_SELF, nCount );

while ( ( GetIsObjectValid( oCreature ) == TRUE ) && ( nCount < MAX_CREATURES ) )

{

if ( GetDistanceBetween( oCreature, OBJECT_SELF ) < MAX_DISTANCE )

{

PrettyMessage( "gr_outofmyway: attempting to move " + GetName( oCreature ) + " away from " + GetName( OBJECT_SELF ) );

AssignCommand( oCreature, ClearAllActions() );

AssignCommand( oCreature, ActionMoveAwayFromLocation( lTarget, FALSE, MAX_DISTANCE ) );

}

nCount = nCount + 1;

oCreature = GetNearestCreature( CREATURE_TYPE_IS_ALIVE, CREATURE_ALIVE_TRUE, OBJECT_SELF, nCount );

}

}

// gr_pc_spawn

/*

the spawn-like script for PC's

Sets up listening patterns and variables.

*/

// ChazM 9/13/06

// ChazM 9/14/06 Added Set DoneSpawn

// ChazM 9/20/06 - fixed inc.

// DBR 9/21/06 - Added a class check before setting the 'Open Lock' and 'Disable Trap' behavior.

#include "x0_inc_henai"

#include "ginc_math"

// this is run on the PC, so OBJECT_SELF != module for this funciton.

void main()

{

PrettyDebug(GetName(OBJECT_SELF) + ": PC Spawn script run!");

// Always set up listening patterns

// Sets up the special henchmen listening patterns (gb_setassociatelistenpatterns)

SetAssociateListenPatterns();

// Set standard combat listening patterns (x0_i0_spawncond)

SetListeningPatterns();

// Set additional henchman listening patterns (x0_inc_henai)

bkSetListeningPatterns();

// Only set up variables if we haven't done this before.

int iDoneSpawn = GetLocalInt(OBJECT_SELF, "DoneSpawn");

if (iDoneSpawn)

return;

SetLocalInt(OBJECT_SELF, "DoneSpawn", TRUE);

// Default behavior for henchmen at start

SetAssociateState(NW_ASC_SCALED_CASTING);

SetAssociateState(NW_ASC_HEAL_AT_50);

if (GetLevelByClass(CLASS_TYPE_ROGUE) > 0)

{

SetAssociateState(NW_ASC_RETRY_OPEN_LOCKS);

SetAssociateState(NW_ASC_DISARM_TRAPS);

}

// PC's won't use items by default when not controlled.

// This way they have someplace to put their scrolls and potions w/o them dissappearing.

SetLocalIntState(OBJECT_SELF, N2_TALENT_EXCLUDE, TALENT_EXCLUDE_ITEM, TRUE);

// * July 2003. Set this to true so henchmen

// * will hopefully run off a little less often

// * by default

// * September 2003. Bad decision. Reverted back

// * to original. This mode too often looks like a bug

// * because they hang back and don't help each other out.

// Players (like companions) defaulted to Defend.

SetAssociateState(NW_ASC_MODE_DEFEND_MASTER, TRUE);

SetAssociateState(NW_ASC_DISTANCE_2_METERS);

// Use melee weapons by default

SetAssociateState(NW_ASC_USE_RANGED_WEAPON, FALSE);

// Set starting location

//SetAssociateStartLocation();

// Set respawn location

//SetRespawnLocation();

// For some general behavior while we don't have a master,

// let's do some immobile animations

SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);

}

// gr_print_effects( string sTag )

// BMA-OEI 9/05/06

#include "ginc_debug"

#include "ginc_param_const"

void PrintEffect( effect eEffect );

void PrintEffectsOnObject( object oObject );

void main( string sTag )

{

object oObject = GetTarget( sTag );

PrettyDebug( "gr_print_effects: printing effects on " + GetName( oObject ) + " (Tag:" + GetTag( oObject ) + ")" );

PrintEffectsOnObject( oObject );

}

void PrintEffect( effect eEffect )

{

PrettyMessage( " ** Creator : " + GetName( GetEffectCreator( eEffect ) ) + " (Tag:" + GetTag( GetEffectCreator( eEffect ) ) + ")" );

PrettyMessage( " ** Duration: " + IntToString( GetEffectDurationType( eEffect ) ) );

PrettyMessage( " ** SpellId : " + IntToString( GetEffectSpellId( eEffect ) ) );

PrettyMessage( " ** Type : " + IntToString( GetEffectType( eEffect ) ) );

PrettyMessage( " ** SubType : " + IntToString( GetEffectSubType( eEffect ) ) );

}

void PrintEffectsOnObject( object oObject )

{

string sName = GetName( oObject );

string sTag = GetTag( oObject );

effect eEffect = GetFirstEffect( oObject );

int n = 1;

while ( GetIsEffectValid( eEffect ) == TRUE )

{

PrettyDebug( "Effect #" + IntToString( n ) + " on " + sName + " (Tag:" + sTag + ")" );

PrintEffect( eEffect );

n = n + 1;

eEffect = GetNextEffect( oObject );

}

}

//gr_report

/*

info on target

*/

//ChazM 6/28/06

// ChazM 8/23/06 - added hitpoints

// BMA-OEI 8/30/06 - added plotflag, immortal

#include "ginc_param_const"

#include "x0_i0_position"

#include "ginc_event_handlers"

void main(string sTarget)

{

object oTarget = GetTarget(sTarget);

PrettyDebug("----------- Report ------------------");

PrettyDebug("Target Name: " + GetName(oTarget));

PrettyDebug(" Hit Points: " + IntToString(GetCurrentHitPoints(oTarget)) + " of " + IntToString(GetMaxHitPoints(oTarget)) );

PrettyDebug(" Commandable = " + IntToString(GetCommandable(oTarget)));

PrettyDebug(" PossessionBlocked = " + IntToString( GetIsCompanionPossessionBlocked(oTarget) ) );

//PrettyDebug(" Destroyable = Who knows?");

PrettyDebug(" Plot Flag = " + IntToString(GetPlotFlag(oTarget)));

PrettyDebug(" Immortal = " + IntToString(GetImmortal(oTarget)));

PrettyDebug(GetName(oTarget) + " is currently in:");

PrettyDebug(" Module: " + GetName(GetModule()) + " / Module Tag: " + GetTag(GetModule()) );

PrettyDebug(" Area Name: " + GetName(GetArea(oTarget)) + " / Area Tag: " + GetTag(GetArea(oTarget)) );

PrettyDebug(" Position: " + VectorToString(GetPosition(oTarget)) );

PrettyDebug(" Facing: " + FloatToString(GetFacing(oTarget)) );

ReportEventHandlers(oTarget);

PrettyDebug("----------- End Report --------------");

}

#include "ginc_death"

#include "ginc_debug"

void main()

{

object oPC = OBJECT_SELF;

PrettyDebug( "gr_respawn: DEBUG - resurrecting " + GetName(oPC) + "'s faction" );

ResurrectFaction( oPC );

}

// gr_restart

/*

Restarts the module. Assumes module name is the file name.

This script for use with the dm_runscript console command

*/

// ChazM 11/6/05

void main()

{

string sModuleName = GetName(GetModule());

StartNewModule(sModuleName);

}

// gr_roster_reset

// Resets all roster members in-game to average PC level

#include "ginc_debug"

#include "ginc_misc"

void main()

{

int nXP = GetPCAverageXP();

string sRM = GetFirstRosterMember();

object oRM;

while ( sRM != "" )

{

oRM = GetObjectFromRosterName( sRM );

if ( GetIsObjectValid( oRM ) == TRUE )

{

PrettyMessage( "gr_roster_reset: " + GetName( oRM ) + " reset with " + IntToString( nXP ) + " xp." );

ResetCreatureLevelForXP( oRM, nXP, TRUE );

ForceRest( oRM );

}

sRM = GetNextRosterMember();

}

}

// DEBUG SCRIPT - REPORT TAGS

// DBR

//#include "ginc_debug"

void TRIterate(location lOrigin, int i)

{

if (i>27)

return;

object oObj=GetNearestObjectToLocation(OBJECT_TYPE_ALL,lOrigin,++i);

while ((GetTag(oObj)=="blergblerg")||(GetObjectType(oObj)==OBJECT_TYPE_CREATURE))

oObj=GetNearestObjectToLocation(OBJECT_TYPE_ALL,lOrigin,++i);

if (!GetIsObjectValid(oObj))

return;

//PrettyMessage("-"+GetTag(oObj));

//object oYeller = CreateObject(OBJECT_TYPE_CREATURE,"n_duncan",GetLocation(oObj),FALSE,"blergblerg");

//SetScriptHidden(oYeller,TRUE);

AssignCommand(OBJECT_SELF,SpeakString(GetTag(oObj),TALKVOLUME_SHOUT));

ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectNWN2SpecialEffectFile("sp_fire_hit"),oObj,1.2f);

//DelayCommand(7.0f,DestroyObject(oYeller));

DelayCommand(1.0f,TRIterate(lOrigin,i+1));

}

void main()

{

int i=0;

AssignCommand(OBJECT_SELF,TRIterate(GetLocation(OBJECT_SELF),0));

object oC=GetNearestObject(OBJECT_TYPE_CREATURE,OBJECT_SELF,++i);

while (GetIsObjectValid(oC))

{

AssignCommand(oC,SpeakString(GetTag(oC)));

oC=GetNearestObject(OBJECT_TYPE_CREATURE,OBJECT_SELF,++i);

}

}

// gr_where_am_i

/*

Reports current location

This script for use with the dm_runscript console command

*/

// ChazM 11/13/05

#include "ginc_debug"

#include "x0_i0_position"

// dfdsa

void main()

{

PrettyDebug(GetName(OBJECT_SELF) + " is currently in:");

PrettyDebug(" Module: " + GetName(GetModule()) + " / Module Tag: " + GetTag(GetModule()) );

PrettyDebug(" Area Name: " + GetName(GetArea(OBJECT_SELF)) + " / Area Tag: " + GetTag(GetArea(OBJECT_SELF)) );

PrettyDebug(" Position: " + VectorToString(GetPosition(OBJECT_SELF)) );

PrettyDebug(" Facing: " + FloatToString(GetFacing(OBJECT_SELF)) );

}

Global Trigger

// gtr_block_trigger

/*

Used on enter of a trigger to block the player from entering and jump them to a nearby waypoint.

Note that conversations should consist of one-line barkstrings only.

*/

// Tevans 1/24/06 - Created script and trigger

#include "ginc_debug"

#include "ginc_param_const"

void main ()

{

object oEntering = GetEnteringObject();

if ( !GetIsPC(oEntering) ) // if the entering object is not a PC, bail out

return;

// Get the trigger's local variables

string sWP = GetLocalString( OBJECT_SELF, "Waypoint" );

string sVar = GetLocalString( OBJECT_SELF, "Variable" );

string sConv = GetLocalString( OBJECT_SELF, "Conversation" );

string sSpeaker = GetLocalString( OBJECT_SELF, "Speaker" );

int bBarkstring = GetLocalInt( OBJECT_SELF, "PlayBarkstring" );

if ( !GetGlobalInt(sVar) )

{

// The global flag for prohibiting entry into the trigger is off; bail out

PrettyError( "Variable " + sVar + " is FALSE" );

return;

}

object oWP = GetTarget( sWP );

if ( !GetIsObjectValid(oWP) )

{

// The provided waypoint tag doesn't match a valid object; bail out

PrettyError( "Waypoint " + sWP + " is INVALID" );

return;

}

AssignCommand( oEntering, FadeToBlack(OBJECT_SELF, FADE_SPEED_FASTEST) );

AssignCommand( oEntering, ClearAllActions() );

DelayCommand( FADE_SPEED_FASTEST / 3.0f, AssignCommand(oEntering, JumpToObject( oWP )) );

DelayCommand( FADE_SPEED_FASTEST * 1.5f, AssignCommand(oEntering, FadeFromBlack( OBJECT_SELF )) );

if ( sSpeaker == "" && bBarkstring)

{

AssignCommand( oEntering, SpeakStringByStrRef(113518) ); // see dialog.tlk for entry 113518

}

else if (sSpeaker == "" && sConv == "")

return;

else

{

int bPrivateConversation = FALSE;

int bPlayHello = FALSE;

int bIgnoreStartDistance = TRUE;

int bDisableCutsceneBars = FALSE;

object oSpeaker = GetTarget( sSpeaker );

if ( !GetIsObjectValid(oSpeaker) )

{

PrettyError( "Speaker " + sSpeaker + " is INVALID. Using PC" );

oSpeaker = oEntering;

}

AssignCommand( oSpeaker, ActionStartConversation(oEntering,

sConv,

bPrivateConversation,

bPlayHello,

bIgnoreStartDistance,

bDisableCutsceneBars) );

}

}

// gtr_murder_en

//

// Kills creature with tag "sCreatureToMurder" when PC steps on this.

//

// EPF 7/12/05

#include "ginc_misc"

void main()

{

string sCreatureToMurder = GetLocalString(OBJECT_SELF, "sCreatureToMurder");

object oCreatureToMurder = GetTarget(sCreatureToMurder);

PrintString("Murder trigger: Murdering " + GetTag(oCreatureToMurder));

if(GetIsObjectValid(oCreatureToMurder))

{

//leave the corpse

AssignCommand(oCreatureToMurder, SetIsDestroyable(FALSE,FALSE,TRUE));

ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oCreatureToMurder);

}

}

//::///////////////////////////////////////////////////////////////////////////

//::

//:: gtr_pc_tran_clic.nss

//::

//:: Use this script as a trigger's OnClick event handler to ensure that the

//:: trigger is only tripped by a PC. This is the default OnClick handler for

//:: the global PC-Only Area Transition Trigger.

//::

//::///////////////////////////////////////////////////////////////////////////

//::

//:: Created by: Brian Fox

//:: Created on: 8/19/05

//::

//::///////////////////////////////////////////////////////////////////////////

// BMA-OEI 6/24/06 - Change to use AttemptAreaTransition()

#include "ginc_transition"

void main()

{

object oClicker = GetClickingObject();

if ( GetIsPC( oClicker ) == FALSE ) return;

object oTarget = GetTransitionTarget( OBJECT_SELF );

SetAreaTransitionBMP( AREA_TRANSITION_RANDOM );

AttemptAreaTransition( oClicker, oTarget );

}

// gtr_speak_node

/*

Speak Trigger OnEnter handler to initiate a conversation.

See DoSpeakTrigger() in ginc_trigger for list of variables that can be set.

For custom conditions, modify , save as a new script and attach to trigger's OnEnter.

Suggested name: XX_trsn_xxx

*/

// ChazM 6/25/05 - split functions into include

// BMA-OEI 3/6/06 - formated script

#include "ginc_trigger"

void main ()

{

object oPC = GetEnteringObject();

if (StandardSpeakTriggerConditions(oPC) == FALSE)

{

return;

}

//if ( == FALSE)

//{

// return;

//}

DoSpeakTrigger(oPC);

}

Graphical User Interace

// gui_bhvr_a_casting_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_CASTING_OFF);

}

// gui_bhvr_a_casting_overkill

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_CASTING_OVERKILL);

}

// gui_bhvr_a_casting_power

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_CASTING_POWER);

}

// gui_bhvr_a_casting_scaled

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_CASTING_SCALED);

}

// gui_bhvr_a_combat_mode_use_off.nss

/*

Combat Mode Use All Off Behavior script for the character sheet behavior sub-panel

*/

// BMA-OEI 10/12/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll( STR_REF_BEHAVIOR_COMBAT_MODE_USE_OFF );

}

// gui_bhvr_a_combat_mode_use_on.nss

/*

Combat Mode Use All On Behavior script for the character sheet behavior sub-panel

*/

// BMA-OEI 10/12/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll( STR_REF_BEHAVIOR_COMBAT_MODE_USE_ON );

}

// gui_bhvr_a_def_master_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_DEF_MASTER_OFF);

}

// gui_bhvr_a_def_master_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_DEF_MASTER_ON);

}

// gui_bhvr_a_disarm_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_DISARM_TRAPS_OFF);

}

// gui_bhvr_a_disarm_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_DISARM_TRAPS_ON);

}

// gui_bhvr_a_dispel_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_DISPEL_OFF);

}

// gui_bhvr_a_dispel_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_DISPEL_ON);

}

// gui_bhvr_a_feat_use_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/8/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_FEAT_USE_OFF);

}

// gui_bhvr_a_feat_use_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/8/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_FEAT_USE_ON);

}

// gui_bhvr_a_follownear.nss

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_FOLLOWDIST_FAR);

}

// gui_bhvr_a_follownear.nss

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_FOLLOWDIST_MED);

}

// gui_bhvr_a_follownear.nss

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_FOLLOWDIST_NEAR);

}

// gui_bhvr_a_item_use_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/7/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_ITEM_USE_OFF);

}

// gui_bhvr_a_item_use_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/7/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_ITEM_USE_ON);

}

// gui_bhvr_a_puppet_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/9/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_PUPPET_OFF);

}

// gui_bhvr_a_puppet_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/9/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_PUPPET_ON);

}

// gui_bhvr_a_retry_locks_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_RETRY_LOCKS_OFF);

}

// gui_bhvr_a_retry_locks_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_RETRY_LOCKS_ON);

}

// gui_bhvr_a_stealth_none

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_STEALTH_MODE_NONE);

}

// gui_bhvr_a_stealth_perm

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_STEALTH_MODE_PERM);

}

// gui_bhvr_a_stealth_temp

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/4/06

#include "gui_bhvr_inc"

void main()

{

SetBehaviorAll(STR_REF_BEHAVIOR_STEALTH_MODE_TEMP);

}

// gui_bhvr_casting_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_CASTING_OFF, iExamined);

}

// gui_bhvr_casting_overkill

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 7/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_CASTING_OVERKILL, iExamined);

}

// gui_bhvr_casting_power

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 7/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_CASTING_POWER, iExamined);

}

// gui_bhvr_casting_scaled

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 7/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_CASTING_SCALED, iExamined);

}

// gui_bhvr_combat_mode_use_off.nss

/*

Combat Mode Use Off Behavior script for the character sheet behavior sub-panel

*/

// BMA-OEI 10/12/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_COMBAT_MODE_USE_OFF, iExamined);

}

// gui_bhvr_combat_mode_use_on.nss

/*

Combat Mode Use On Behavior script for the character sheet behavior sub-panel

*/

// BMA-OEI 10/12/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_COMBAT_MODE_USE_ON, iExamined);

}

// gui_bhvr_def_master_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_DEF_MASTER_OFF, iExamined);

}

// gui_bhvr_def_master_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_DEF_MASTER_ON, iExamined);

}

// gui_bhvr_disarm_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_DISARM_TRAPS_OFF, iExamined);

}

// gui_bhvr_disarm_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_DISARM_TRAPS_ON, iExamined);

}

// gui_bhvr_dispel_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_DISPEL_OFF, iExamined);

}

// gui_bhvr_dispel_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_DISPEL_ON, iExamined);

}

// gui_bhvr_feat_use_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/8/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_FEAT_USE_OFF, iExamined);

}

// gui_bhvr_feat_use_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/8/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_FEAT_USE_ON, iExamined);

}

//::///////////////////////////////////////////////

//:: Behavior Screen - Follow Distance: Far

//:: gui_bhvr_followfar.nss

//:: Created By: Brock Heinz - OEI

//:: Created On: 03/29/06

//:://////////////////////////////////////////////

// ChazM 4/26/06 - use SetBehavior()

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_FOLLOWDIST_FAR, iExamined);

}

//::///////////////////////////////////////////////

//:: Behavior Screen - Follow Distance: Medium

//:: gui_bhvr_followmed.nss

//:: Created By: Brock Heinz - OEI

//:: Created On: 03/29/06

//:://////////////////////////////////////////////

// ChazM 4/26/06 - use SetBehavior()

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_FOLLOWDIST_MED, iExamined);

}

//::///////////////////////////////////////////////

//:: Behavior Screen - Follow Distance: Near

//:: gui_bhvr_follownear.nss

//:: Created By: Brock Heinz - OEI

//:: Created On: 03/29/06

//:://////////////////////////////////////////////

// ChazM 4/26/06 - use SetBehavior()

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_FOLLOWDIST_NEAR, iExamined);

}

// gui_bhvr_inc

/*

include file for the GUI Behavior related scripts:

gui_bhvr_follownear

gui_bhvr_followmed

gui_bhvr_followfar

gui_bhvr_def_master_on

gui_bhvr_def_master_off

gui_bhvr_retry_locks_on

gui_bhvr_retry_locks_off

gui_bhvr_stealth_none

gui_bhvr_stealth_perm

gui_bhvr_stealth_temp

gui_bhvr_disarm_on

gui_bhvr_disarm_off

gui_bhvr_dispel_on

gui_bhvr_dispel_off

gui_bhvr_casting_overkill

gui_bhvr_casting_power

gui_bhvr_casting_scaled

gui_bhvr_casting_off

gui_bhvr_item_use_on

gui_bhvr_item_use_off

gui_bhvr_feat_use_on

gui_bhvr_feat_use_off

gui_bhvr_combat_mode_use_on

gui_bhvr_combat_mod_use_off

gui_bhvr_a_follownear

gui_bhvr_a_followmed

gui_bhvr_a_followfar

gui_bhvr_a_def_master_on

gui_bhvr_a_def_master_off

gui_bhvr_a_retry_locks_on

gui_bhvr_a_retry_locks_off

gui_bhvr_a_stealth_none

gui_bhvr_a_stealth_perm

gui_bhvr_a_stealth_temp

gui_bhvr_a_disarm_on

gui_bhvr_a_disarm_off

gui_bhvr_a_dispel_on

gui_bhvr_a_dispel_off

gui_bhvr_a_casting_overkill

gui_bhvr_a_casting_power

gui_bhvr_a_casting_scaled

gui_bhvr_a_casting_off

gui_bhvr_a_item_use_on

gui_bhvr_a_item_use_off

gui_bhvr_a_feat_use_on

gui_bhvr_a_feat_use_off

gui_bhvr_a_combat_mode_use_on

gui_bhvr_a_combat_mod_use_off

*/

// ChazM 4/26/06

// ChazM 5/25/06 - script now runs on player owned character - functions modified to reference currently controlled character

// ChazM 5/26/06 - removed debugs

// ChazM 7/26/06 - Added casting_overkill, casting_power, casting_scaled, removed casting_on

// ChazM 8/4/06 - Added support for full party controls (all buttons)

// ChazM 8/7/06 - Added support for item use

// ChazM 8/8/06 - Added support for ability/feat use

// ChazM 8/9/06 - Added support for puppet mode

// BMA-OEI 10/12/06 - Added support for combat mode use (N2_COMBAT_MODE_USE_DISABLED)

// ChazM 11/9/06 - Examined Creature update

//void main(){}

#include "x0_i0_assoc"

#include "ginc_debug"

#include "x0_i0_talent"

#include "ginc_math"

const string SCREEN_CHARACTER = "SCREEN_CHARACTER";

const string SCREEN_CREATUREEXAMINE = "SCREEN_CREATUREEXAMINE";

const string BEHAVIORDESC_TEXT = "BEHAVIORDESC_TEXT";

const string BEHAVIOR_FOLLOWDIST_NEAR = "BEHAVIOR_FOLLOWDIST_STATE_BUTTON_NEAR";

const string BEHAVIOR_FOLLOWDIST_MED = "BEHAVIOR_FOLLOWDIST_STATE_BUTTON_MED";

const string BEHAVIOR_FOLLOWDIST_FAR = "BEHAVIOR_FOLLOWDIST_STATE_BUTTON_FAR";

const string BEHAVIOR_DEF_MASTER_ON = "BEHAVIOR_DEF_MASTER_STATE_BUTTON_ON";

const string BEHAVIOR_DEF_MASTER_OFF = "BEHAVIOR_DEF_MASTER_STATE_BUTTON_OFF";

const string BEHAVIOR_RETRY_LOCKS_ON = "BEHAVIOR_RETRY_LOCKS_STATE_BUTTON_ON";

const string BEHAVIOR_RETRY_LOCKS_OFF = "BEHAVIOR_RETRY_LOCKS_STATE_BUTTON_OFF";

const string BEHAVIOR_STEALTH_MODE_NONE = "BEHAVIOR_STEALTH_MODE_STATE_BUTTON_NONE"; // 0

const string BEHAVIOR_STEALTH_MODE_PERM = "BEHAVIOR_STEALTH_MODE_STATE_BUTTON_PERM"; // 1

const string BEHAVIOR_STEALTH_MODE_TEMP = "BEHAVIOR_STEALTH_MODE_STATE_BUTTON_TEMP"; // 2

const string BEHAVIOR_DISARM_TRAPS_ON = "BEHAVIOR_DISARM_STATE_BUTTON_ON";

const string BEHAVIOR_DISARM_TRAPS_OFF = "BEHAVIOR_DISARM_STATE_BUTTON_OFF";

const string BEHAVIOR_DISPEL_ON = "BEHAVIOR_DISPEL_STATE_BUTTON_ON";

const string BEHAVIOR_DISPEL_OFF = "BEHAVIOR_DISPEL_STATE_BUTTON_OFF";

//const string BEHAVIOR_CASTING_ON = "BEHAVIOR_CASTING_STATE_BUTTON_ON";

const string BEHAVIOR_CASTING_OFF = "BEHAVIOR_CASTING_STATE_BUTTON_OFF";

const string BEHAVIOR_CASTING_OVERKILL = "BEHAVIOR_CASTING_STATE_BUTTON_OVERKILL";

const string BEHAVIOR_CASTING_POWER = "BEHAVIOR_CASTING_STATE_BUTTON_POWER";

const string BEHAVIOR_CASTING_SCALED = "BEHAVIOR_CASTING_STATE_BUTTON_SCALED";

const string BEHAVIOR_ITEM_USE_ON = "BEHAVIOR_ITEM_USE_STATE_BUTTON_ON";

const string BEHAVIOR_ITEM_USE_OFF = "BEHAVIOR_ITEM_USE_STATE_BUTTON_OFF";

const string BEHAVIOR_FEAT_USE_ON = "BEHAVIOR_FEAT_USE_STATE_BUTTON_ON";

const string BEHAVIOR_FEAT_USE_OFF = "BEHAVIOR_FEAT_USE_STATE_BUTTON_OFF";

const string BEHAVIOR_PUPPET_ON = "BEHAVIOR_PUPPET_STATE_BUTTON_ON";

const string BEHAVIOR_PUPPET_OFF = "BEHAVIOR_PUPPET_STATE_BUTTON_OFF";

const string BEHAVIOR_COMBAT_MODE_USE_ON = "BEHAVIOR_COMBAT_MODE_USE_STATE_BUTTON_ON";

const string BEHAVIOR_COMBAT_MODE_USE_OFF = "BEHAVIOR_COMBAT_MODE_USE_STATE_BUTTON_OFF";

// these str refs double as identifiers for SetBehavior function, so do not set as -1, or make multiple values equal.

const int STR_REF_BEHAVIOR_FOLLOWDIST_NEAR = 179925;

const int STR_REF_BEHAVIOR_FOLLOWDIST_MED = 179926;

const int STR_REF_BEHAVIOR_FOLLOWDIST_FAR = 179927;

const int STR_REF_BEHAVIOR_DEF_MASTER_ON = 179928;

const int STR_REF_BEHAVIOR_DEF_MASTER_OFF = 179929;

const int STR_REF_BEHAVIOR_RETRY_LOCKS_ON = 179930;

const int STR_REF_BEHAVIOR_RETRY_LOCKS_OFF = 179931;

const int STR_REF_BEHAVIOR_STEALTH_MODE_NONE = 179932;

const int STR_REF_BEHAVIOR_STEALTH_MODE_PERM = 179933;

const int STR_REF_BEHAVIOR_STEALTH_MODE_TEMP = 179934;

const int STR_REF_BEHAVIOR_DISARM_TRAPS_ON = 179936;

const int STR_REF_BEHAVIOR_DISARM_TRAPS_OFF = 179937;

const int STR_REF_BEHAVIOR_DISPEL_ON = 179938;

const int STR_REF_BEHAVIOR_DISPEL_OFF = 179939;

//const int STR_REF_BEHAVIOR_CASTING_ON = 179940;

const int STR_REF_BEHAVIOR_CASTING_OFF = 179941;

const int STR_REF_BEHAVIOR_CASTING_OVERKILL = 182915;

const int STR_REF_BEHAVIOR_CASTING_POWER = 182914;

const int STR_REF_BEHAVIOR_CASTING_SCALED = 182913;

const int STR_REF_BEHAVIOR_ITEM_USE_ON = 183071;

const int STR_REF_BEHAVIOR_ITEM_USE_OFF = 183070;

const int STR_REF_BEHAVIOR_FEAT_USE_ON = 183216;

const int STR_REF_BEHAVIOR_FEAT_USE_OFF = 183215;

const int STR_REF_BEHAVIOR_PUPPET_ON = 183222;

const int STR_REF_BEHAVIOR_PUPPET_OFF = 183223;

const int STR_REF_BEHAVIOR_COMBAT_MODE_USE_ON = 184645;

const int STR_REF_BEHAVIOR_COMBAT_MODE_USE_OFF = 184646;

//void main(){}

////////////////////////////////////

// Prototypes

////////////////////////////////////

void SetBehavior(int iStrRef, int iExamined);

void SetBehaviorAll(int iStrRef); // doesn't support examined character sheets!

void SetBehaviorOnObject(object oSelf, int iStrRef);

void GuiBehaviorUpdate (int iExamined);

void GuiBehaviorInit(object oPlayerObject, object oTargetObject, string sScreen);

////////////////////////////////////

// Functions

////////////////////////////////////

// Set Behavior on all companions in the party and on this player's controlled character.

void SetBehaviorAll(int iStrRef)

{

object oPC = OBJECT_SELF;

//PrettyMessage("OBJECT_SELF = " + GetName(OBJECT_SELF));

// object oOwnedChar = GetOwnedCharacter(oPC); // OBJECT_SELF is the owned char, and this function will return ""

int i = 1;

//PrettyMessage("oOwnedChar = " + GetName(oOwnedChar));

object oPartyMember = GetFirstFactionMember(oPC, FALSE);

// We stop when there are no more valid PC's in the party.

while(GetIsObjectValid(oPartyMember) == TRUE)

{

//PrettyMessage("SetBehaviorAll: Party char # " + IntToString(i) + " = " + GetName(oPartyMember));

i++;

if (GetIsRosterMember(oPartyMember) || (oPartyMember == oPC))

{

SetBehaviorOnObject(oPartyMember, iStrRef);

}

oPartyMember = GetNextFactionMember(oPC, FALSE);

}

//SetBehavior(iStrRef);

object oPlayerObject = GetControlledCharacter(OBJECT_SELF);

object oTargetObject = oPlayerObject;

string sScreen = SCREEN_CHARACTER;

SetGUIObjectText(oPlayerObject, sScreen, BEHAVIORDESC_TEXT, iStrRef, "" );

GuiBehaviorInit(oPlayerObject, oTargetObject, sScreen);

}

// Set Behavior on currently controlled character

void SetBehavior(int iStrRef, int iExamined)

{

object oPlayerObject = GetControlledCharacter(OBJECT_SELF);

object oTargetObject;

string sScreen;

if (iExamined == 0) // looking at our own character sheet

{

oTargetObject = oPlayerObject;

sScreen = SCREEN_CHARACTER;

}

else // looking at an examined character sheet

{

oTargetObject = GetPlayerCreatureExamineTarget(oPlayerObject);

sScreen = SCREEN_CREATUREEXAMINE;

}

SetBehaviorOnObject(oTargetObject, iStrRef);

SetGUIObjectText(oPlayerObject, sScreen, BEHAVIORDESC_TEXT, iStrRef, "" );

GuiBehaviorInit(oPlayerObject, oTargetObject, sScreen);

}

// Set Behavior on object oSelf

// oSelf - object to be acted upon

// iStrRef - str ref of the description

void SetBehaviorOnObject(object oSelf, int iStrRef)

{

//object oSelf = GetControlledCharacter(OBJECT_SELF);

//PrettyMessage("SetBehaviorOnObject: " + GetName(oSelf) + " iStrRef=" + IntToString(iStrRef) );

switch (iStrRef)

{

case STR_REF_BEHAVIOR_FOLLOWDIST_NEAR:

case STR_REF_BEHAVIOR_FOLLOWDIST_MED:

case STR_REF_BEHAVIOR_FOLLOWDIST_FAR:

SetAssociateState( NW_ASC_DISTANCE_2_METERS, (iStrRef==STR_REF_BEHAVIOR_FOLLOWDIST_NEAR), oSelf );

SetAssociateState( NW_ASC_DISTANCE_4_METERS, (iStrRef==STR_REF_BEHAVIOR_FOLLOWDIST_MED), oSelf );

SetAssociateState( NW_ASC_DISTANCE_6_METERS, (iStrRef==STR_REF_BEHAVIOR_FOLLOWDIST_FAR), oSelf );

break;

case STR_REF_BEHAVIOR_DEF_MASTER_ON:

SetAssociateState(NW_ASC_MODE_DEFEND_MASTER, TRUE, oSelf);

break;

case STR_REF_BEHAVIOR_DEF_MASTER_OFF:

SetAssociateState(NW_ASC_MODE_DEFEND_MASTER, FALSE, oSelf);

break;

case STR_REF_BEHAVIOR_RETRY_LOCKS_ON:

SetAssociateState(NW_ASC_RETRY_OPEN_LOCKS, TRUE, oSelf);

break;

case STR_REF_BEHAVIOR_RETRY_LOCKS_OFF:

SetAssociateState(NW_ASC_RETRY_OPEN_LOCKS, FALSE, oSelf);

break;

case STR_REF_BEHAVIOR_STEALTH_MODE_NONE:

//ClearAllActions();

SetLocalInt(oSelf, "X2_HENCH_STEALTH_MODE", 0);

SetActionMode(oSelf, ACTION_MODE_STEALTH, FALSE);

break;

case STR_REF_BEHAVIOR_STEALTH_MODE_PERM:

ClearAllActions();

SetLocalInt(oSelf, "X2_HENCH_STEALTH_MODE", 1);

DelayCommand(1.0, SetActionMode(oSelf, ACTION_MODE_STEALTH, TRUE));

break;

case STR_REF_BEHAVIOR_STEALTH_MODE_TEMP:

ClearAllActions();

SetLocalInt(oSelf, "X2_HENCH_STEALTH_MODE", 2);

DelayCommand(1.0, SetActionMode(oSelf, ACTION_MODE_STEALTH, TRUE));

break;

case STR_REF_BEHAVIOR_DISARM_TRAPS_ON:

//PrettyMessage("SetBehavior: STR_REF_BEHAVIOR_DISARM_TRAPS_ON");

SetAssociateState(NW_ASC_DISARM_TRAPS, TRUE, oSelf);

break;

case STR_REF_BEHAVIOR_DISARM_TRAPS_OFF:

//PrettyMessage("SetBehavior: STR_REF_BEHAVIOR_DISARM_TRAPS_OFF");

SetAssociateState(NW_ASC_DISARM_TRAPS, FALSE, oSelf);

break;

case STR_REF_BEHAVIOR_DISPEL_ON:

SetLocalInt(oSelf, "X2_HENCH_DO_NOT_DISPEL", FALSE);

break;

case STR_REF_BEHAVIOR_DISPEL_OFF:

SetLocalInt(oSelf, "X2_HENCH_DO_NOT_DISPEL", TRUE);

break;

case STR_REF_BEHAVIOR_CASTING_OFF:

//PrettyMessage("SetBehavior: STR_REF_BEHAVIOR_CASTING_OFF");

SetLocalInt(oSelf, "X2_L_STOPCASTING", 10); // casting off is 10 for this

break;

case STR_REF_BEHAVIOR_CASTING_OVERKILL:

//PrettyMessage("SetBehavior: STR_REF_BEHAVIOR_CASTING_OVERKILL");

SetLocalInt(oSelf, "X2_L_STOPCASTING", 0);

SetAssociateState(NW_ASC_OVERKIll_CASTING, TRUE, oSelf);

SetAssociateState(NW_ASC_POWER_CASTING, FALSE, oSelf);

SetAssociateState(NW_ASC_SCALED_CASTING, FALSE, oSelf);

break;

case STR_REF_BEHAVIOR_CASTING_POWER:

//PrettyMessage("SetBehavior: STR_REF_BEHAVIOR_CASTING_POWER");

SetLocalInt(oSelf, "X2_L_STOPCASTING", 0); // casting on is 0 for this

SetAssociateState(NW_ASC_OVERKIll_CASTING, FALSE, oSelf);

SetAssociateState(NW_ASC_POWER_CASTING, TRUE, oSelf);

SetAssociateState(NW_ASC_SCALED_CASTING, FALSE, oSelf);

break;

case STR_REF_BEHAVIOR_CASTING_SCALED:

//PrettyMessage("SetBehavior: STR_REF_BEHAVIOR_CASTING_SCALED");

SetLocalInt(oSelf, "X2_L_STOPCASTING", 0);

SetAssociateState(NW_ASC_OVERKIll_CASTING, FALSE, oSelf);

SetAssociateState(NW_ASC_POWER_CASTING, FALSE, oSelf);

SetAssociateState(NW_ASC_SCALED_CASTING, TRUE, oSelf);

break;

// to use items we set item exclusion to false

case STR_REF_BEHAVIOR_ITEM_USE_ON:

SetLocalIntState(oSelf, N2_TALENT_EXCLUDE, TALENT_EXCLUDE_ITEM, FALSE);

break;

// to not use items we set item exclusion to true

case STR_REF_BEHAVIOR_ITEM_USE_OFF:

SetLocalIntState(oSelf, N2_TALENT_EXCLUDE, TALENT_EXCLUDE_ITEM, TRUE);

break;

// to use abilities (feats, skills, and special abilities) we set ability exclusion to false

case STR_REF_BEHAVIOR_FEAT_USE_ON:

SetLocalIntState(oSelf, N2_TALENT_EXCLUDE, TALENT_EXCLUDE_ABILITY, FALSE);

break;

// to not use abilities we set ability exclusion to true

case STR_REF_BEHAVIOR_FEAT_USE_OFF:

SetLocalIntState(oSelf, N2_TALENT_EXCLUDE, TALENT_EXCLUDE_ABILITY, TRUE);

break;

case STR_REF_BEHAVIOR_PUPPET_ON:

//PrettyMessage("SetBehavior: STR_REF_BEHAVIOR_PUPPET_ON");

SetAssociateState(NW_ASC_MODE_PUPPET, TRUE, oSelf);

break;

case STR_REF_BEHAVIOR_PUPPET_OFF:

//PrettyMessage("SetBehavior: STR_REF_BEHAVIOR_PUPPET_OFF");

SetAssociateState(NW_ASC_MODE_PUPPET, FALSE, oSelf);

break;

case STR_REF_BEHAVIOR_COMBAT_MODE_USE_ON:

SetLocalInt(oSelf, N2_COMBAT_MODE_USE_DISABLED, FALSE);

break;

case STR_REF_BEHAVIOR_COMBAT_MODE_USE_OFF:

SetLocalInt(oSelf, N2_COMBAT_MODE_USE_DISABLED, TRUE);

break;

default:

PrettyError( "gui_bhvr_inc: Behavior " + IntToString( iStrRef ) + " definition does not exist." );

break;

}

}

// this func called by gui_bhvr_update

void GuiBehaviorUpdate (int iExamined)

{

//object oSelf;

string sScreen;

object oPlayerObject = GetControlledCharacter(OBJECT_SELF);

object oTargetObject;

if (iExamined == 0) // looking at our own character sheet

{

oTargetObject = oPlayerObject;

sScreen = SCREEN_CHARACTER;

}

else // looking at an examined character sheet

{

oTargetObject = GetPlayerCreatureExamineTarget(oPlayerObject);

sScreen = SCREEN_CREATUREEXAMINE;

}

GuiBehaviorInit(oPlayerObject, oTargetObject, sScreen);

}

// set up the GUI with all the info for the selectable states

// oPlayerObject - the player object who's looking at the GUI

// oTargetObject - the object who's information is being displayed in the GUI

// sScreen - The GUI screen being looked at.

void GuiBehaviorInit(object oPlayerObject, object oTargetObject, string sScreen)

{

int iState;

//object oSelf = GetControlledCharacter(OBJECT_SELF);

//PrettyMessage("gui_bhvr_update: oSelf=" + GetName(oTargetObject) + " sScreen=" + sScreen);

// *** Follow Distance

if ( GetAssociateState( NW_ASC_DISTANCE_2_METERS, oTargetObject ) )

{

SetGUIObjectDisabled( oPlayerObject, sScreen, BEHAVIOR_FOLLOWDIST_NEAR, TRUE );

SetGUIObjectDisabled( oPlayerObject, sScreen, BEHAVIOR_FOLLOWDIST_MED, FALSE );

SetGUIObjectDisabled( oPlayerObject, sScreen, BEHAVIOR_FOLLOWDIST_FAR, FALSE );

}

else if ( GetAssociateState( NW_ASC_DISTANCE_4_METERS, oTargetObject ) )

{

SetGUIObjectDisabled( oPlayerObject, sScreen, BEHAVIOR_FOLLOWDIST_NEAR, FALSE );

SetGUIObjectDisabled( oPlayerObject, sScreen, BEHAVIOR_FOLLOWDIST_MED, TRUE );

SetGUIObjectDisabled( oPlayerObject, sScreen, BEHAVIOR_FOLLOWDIST_FAR, FALSE );

}

else if ( GetAssociateState( NW_ASC_DISTANCE_6_METERS, oTargetObject ) )

{

SetGUIObjectDisabled( oPlayerObject, sScreen, BEHAVIOR_FOLLOWDIST_NEAR, FALSE );

SetGUIObjectDisabled( oPlayerObject, sScreen, BEHAVIOR_FOLLOWDIST_MED, FALSE );

SetGUIObjectDisabled( oPlayerObject, sScreen, BEHAVIOR_FOLLOWDIST_FAR, TRUE );

}

//iState =

//SetGUIObjectDisabled( oSelf, sScreen, BEHAVIOR_FOLLOWDIST_STATE_BUTTON_NEAR, (iState==NW_ASC_DISTANCE_2_METERS) );

//SetGUIObjectDisabled( oSelf, sScreen, BEHAVIOR_FOLLOWDIST_STATE_BUTTON_MED, (iState==NW_ASC_DISTANCE_4_METERS) );

//SetGUIObjectDisabled( oSelf, sScreen, BEHAVIOR_FOLLOWDIST_STATE_BUTTON_FAR, (iState==NW_ASC_DISTANCE_6_METERS) );

// defend master mode

iState = GetAssociateState(NW_ASC_MODE_DEFEND_MASTER, oTargetObject);

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_DEF_MASTER_ON, (iState) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_DEF_MASTER_OFF, (!iState));

// retry open locks mode

iState = GetAssociateState(NW_ASC_RETRY_OPEN_LOCKS, oTargetObject);

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_RETRY_LOCKS_ON, (iState) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_RETRY_LOCKS_OFF, (!iState));

// stealthy mode

iState = GetLocalInt(oTargetObject, "X2_HENCH_STEALTH_MODE");

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_STEALTH_MODE_NONE, (iState==0) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_STEALTH_MODE_PERM, (iState==1));

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_STEALTH_MODE_TEMP, (iState==2));

// Disarm traps

iState = GetAssociateState(NW_ASC_DISARM_TRAPS, oTargetObject);

//PrettyMessage("GuiBehaviorInit(): iState =" + IntToString(iState));

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_DISARM_TRAPS_ON, (iState) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_DISARM_TRAPS_OFF, (!iState));

// Displel mode

iState = (GetLocalInt(oTargetObject, "X2_HENCH_DO_NOT_DISPEL") == FALSE);

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_DISPEL_ON, (iState) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_DISPEL_OFF, (!iState));

// Casting mode

iState = (GetLocalInt(oTargetObject, "X2_L_STOPCASTING") == 0);

//SetGUIObjectDisabled(oSelf, sScreen, BEHAVIOR_CASTING_ON, (iState) );

//SetGUIObjectDisabled(oSelf, sScreen, BEHAVIOR_CASTING_OFF, (!iState));

//PrettyMessage("GuiBehaviorInit(): iState =" + IntToString(iState));

if (iState == FALSE)

{

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_CASTING_OVERKILL, FALSE );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_CASTING_POWER, FALSE );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_CASTING_SCALED, FALSE );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_CASTING_OFF, TRUE);

}

else

{

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_CASTING_OVERKILL, GetAssociateState( NW_ASC_OVERKIll_CASTING, oTargetObject ) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_CASTING_POWER, GetAssociateState( NW_ASC_POWER_CASTING, oTargetObject ) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_CASTING_SCALED, GetAssociateState( NW_ASC_SCALED_CASTING, oTargetObject ) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_CASTING_OFF, FALSE);

}

// Use Items

//iState = (GetLocalInt(oSelf, N2_TALENT_EXCLUDE) == 0); // 1st bit is item usage

iState = (GetLocalIntState(oTargetObject, N2_TALENT_EXCLUDE, TALENT_EXCLUDE_ITEM) == FALSE);

//PrettyMessage("GuiBehaviorInit(): iState =" + IntToString(iState));

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_ITEM_USE_ON, (iState) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_ITEM_USE_OFF, (!iState));

// Use Items

iState = (GetLocalIntState(oTargetObject, N2_TALENT_EXCLUDE, TALENT_EXCLUDE_ABILITY) == FALSE);

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_FEAT_USE_ON, (iState) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_FEAT_USE_OFF, (!iState));

// Puppet Mode

iState = GetAssociateState(NW_ASC_MODE_PUPPET, oTargetObject);

//PrettyMessage("GuiBehaviorInit(): iState for " + GetName(oSelf) + " (Puppet Mode)=" + IntToString(iState));

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_PUPPET_ON, (iState) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_PUPPET_OFF, (!iState));

// Use Combat Mode

iState = (GetLocalInt(oTargetObject, N2_COMBAT_MODE_USE_DISABLED) == FALSE);

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_COMBAT_MODE_USE_ON, (iState) );

SetGUIObjectDisabled(oPlayerObject, sScreen, BEHAVIOR_COMBAT_MODE_USE_OFF, (!iState));

}

// gui_bhvr_item_use_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/7/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_ITEM_USE_OFF, iExamined);

}

// gui_bhvr_item_use_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/7/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_ITEM_USE_ON, iExamined);

}

// gui_bhvr_puppet_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/9/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_PUPPET_OFF, iExamined);

}

// gui_bhvr_puppet_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 8/9/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_PUPPET_ON, iExamined);

}

// gui_bhvr_retry_locks_off

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_RETRY_LOCKS_OFF, iExamined);

}

// gui_bhvr_retry_locks_on

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_RETRY_LOCKS_ON, iExamined);

}

// gui_bhvr_stealth_none

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_STEALTH_MODE_NONE, iExamined);

}

// gui_bhvr_stealth_perm

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_STEALTH_MODE_PERM, iExamined);

}

// gui_bhvr_stealth_temp

/*

Behavior script for the character sheet behavior sub-panel

*/

// ChazM 4/26/06

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

SetBehavior(STR_REF_BEHAVIOR_STEALTH_MODE_TEMP, iExamined);

}

//::///////////////////////////////////////////////

//:: Behavior Screen - Update

//:: gui_bhvr_update.nss

//:: Created By: Brock Heinz - OEI

//:: Created On: 03/29/06

//:://////////////////////////////////////////////

// ChazM 4/26/06 - changed to use inc file

// ChazM 11/9/06 - Examined Creature update

#include "gui_bhvr_inc"

void main(int iExamined)

{

GuiBehaviorUpdate(iExamined);

}

// gui_death_exitgame.nss

/*

Death GUI 'Exit Game' callback

*/

// BMA-OEI 6/29/06

#include "ginc_debug"

void main()

{

string sFile = "gui_death_exitgame";

PrettyDebug( sFile + ": EndGame() - TODO: confirmation dialog" );

EndGame( "" );

}

// gui_death_hidden_click.nss

/*

Hidden Death GUI 'Click' callback

*/

// BMA-OEI 6/29/06

#include "ginc_death"

void main()

{

object oPC = OBJECT_SELF;

RemoveDeathScreens( oPC );

// Check if there are any members left for PC to possess

if ( GetIsDead(oPC) == TRUE )

{

if ( GetIsPartyPossessible(oPC) == FALSE )

{

ShowProperDeathScreen( oPC );

}

}

}

// gui_death_loadgame.nss

/*

Death GUI 'Load Game' callback

*/

// BMA-OEI 6/29/06

// BMA-OEI 9/01/06: Override "Save First?" dialog in UIScene_OnAdd_CreateLoadGameList()

#include "ginc_death"

#include "ginc_gui"

void main()

{

// BMA-OEI 9/01/06: Override "Save First?" dialog in UIScene_OnAdd_CreateLoadGameList()

SetLocalGUIVariable( OBJECT_SELF, GUI_LOAD_GAME, 3, "1" );

HideDeathScreen( OBJECT_SELF );

ShowHiddenDeathScreen( OBJECT_SELF );

ShowLoadGame( OBJECT_SELF );

}

// gui_death_respawn.nss

/*

Death GUI 'Respawn' callback: wake up groggy

*/

// BMA-OEI 6/29/06

#include "ginc_death"

void main()

{

// Resurrect PC

object oPC = OBJECT_SELF;

WakeUpCreature( oPC );

RemoveDeathScreens( oPC );

// Apply Groggy penalty

effect eGroggy = EffectDazed();

//eGroggy = EffectLinkEffects( EffectSlow(), eGroggy );

ApplyEffectToObject( DURATION_TYPE_TEMPORARY, eGroggy, oPC, RoundsToSeconds( 2 ) );

}

// gui_death_respawn_self.nss

/*

NWN2 Default Death Screen 'Respawn' callback

*/

// BMA-OEI 7/20/06

// BMA-OEI 11/08/06 -- Close SCREEN_DEATH_DEFAULT

#include "ginc_death"

void main()

{

ResurrectCreature( OBJECT_SELF );

CloseGUIScreen( OBJECT_SELF, "SCREEN_DEATH_DEFAULT" );

}

// gui_death_waitforhelp.nss

/*

Death GUI 'Wait For Help' callback: displays full-screen hidden death button

*/

// BMA-OEI 08/06/06

#include "ginc_death"

void main()

{

object oPC = OBJECT_SELF;

ShowHiddenDeathScreen( oPC );

HideDeathScreen( oPC );

}

// gui_force_comp

//

// A companion is forced into the party, and the party gui is brought up.

// This is a callback script called from ka_hotspot_click_force. The function DisplayForceCompanionMessage() defines

// the companion who gets forced into the party, setting it as a global variable.

// EPF 1/10/06

// BMA-OEI 8/31/06: Delay to DisplayGuiScreen, Use OBJECT_SELF as PC

// BMA-OEI 9/17/06: If there's room, force companion into party

// BMA-OEI 9/17/06: No longer displays Party Select ( Trigger already prompts Party Select )

// BMA-OEI 10/20/06: " " Unless opened in area other than Crossroad Keep

#include "ginc_companion"

#include "ginc_gui"

void main()

{

object oPC = OBJECT_SELF;

if ( GetIsPC(oPC) == FALSE ) return;

object oFM;

string sCompanion = GetGlobalString("00_sLastForcedCompanion");

// BMA-OEI 9/17/06: If there's room, force companion into party

int nPartyLimit = GetRosterNPCPartyLimit();

int nNPCsInParty = GetNumRosterMembersInParty( oPC );

// Party Limit hit, remove selectable companions

if ( nNPCsInParty >= nPartyLimit )

{

RemoveRosterMembersFromParty( oPC, TRUE, FALSE );

nNPCsInParty = GetNumRosterMembersInParty( oPC );

}

// Free slots available, add required companion

if ( nNPCsInParty < nPartyLimit )

{

AddRosterMemberToParty( sCompanion, oPC );

SetIsRosterMemberSelectable( sCompanion, FALSE );

}

/*

AddRosterMemberToParty(sCompanion,oPC);

SetIsRosterMemberSelectable(sCompanion,FALSE);

oFM = GetFirstFactionMember(oPC,FALSE);

while(GetIsObjectValid(oFM))

{

if(GetIsRosterMember(oFM) && GetIsRosterMemberSelectable(GetRosterNameFromObject(oFM)))

{

RemoveRosterMemberFromParty(GetRosterNameFromObject(oFM),oPC);

}

oFM = GetNextFactionMember(oFM,FALSE);

}

*/

// BMA-OEI 10/20/06: Unless opened in area other than Crossroad Keep

// BMA-OEI 9/17/06: No longer displays Party Select ( Trigger already prompts screen )

// BMA-OEI 8/31/06: Delay for GUI to update w/ spawned companion

if ( GetTag( GetArea( oPC ) ) != "3070_sh_farm" )

{

DelayCommand( 0.5f, ShowPartySelect( oPC, TRUE, "", FALSE ) );

}

}

// gui_input_ok

void main( string sInput )

{

ActionSpeakString( sInput );

}

// gui_map_transition

/*

Transitions party to a waypoint set in a global variable.

*/

// EPF 8/18/06

// ChazM 8/22/06 - removed "kinc_worldmap" dependency.

//#include "kinc_worldmap"

#include "ginc_companion"

#include "ginc_transition"

//

const string LAST_DESTINATION = "00_sLastDestination";

const string LAST_MODULE = "00_sLastModule";

const string PC_CLICKER = "oLastWorldMapClicker"; //this is stored on the module not

void main()

{

string sDestination = GetGlobalString(LAST_DESTINATION);

string sModule = GetGlobalString(LAST_MODULE);

object oPC = GetLocalObject(GetModule(), PC_CLICKER);

object oDestination = GetObjectByTag(sDestination);

SetCommandable(TRUE,oPC);

ForceRestParty(oPC);

if(GetIsObjectValid(oDestination))

{

SinglePartyTransition( oPC, oDestination );

}

else

{

SaveRosterLoadModule(sModule, sDestination);

}

}

// gui_name_enchanted_item

/*

rename weapon user has just enchanted w/ the input string.

*/

// ChazM 5/24/06

// ChazM 5/31/06 Update to reflect where Item object is now stored

// ChazM 9/29/06 Just comments

#include "ginc_crafting"

void main( string sName )

{

//PrettyDebug("gui_name_enchanted_item called!");

// Item object is stored on the character which opened the GUI panel.

object oObj = OBJECT_SELF; //GetOwnedCharacter(OBJECT_SELF);

object oItem = GetLocalObject(oObj, VAR_ENCHANTED_ITEM_OBJECT);

//PrettyDebug("gui_name_enchanted_item: oObj=" + GetName(oObj) + "| oItem=" + GetName(oItem)+ "| sName=" + sName);

if ((sName != "") && (GetIsObjectValid(oItem)))

{

//PrettyDebug("setting new name!");

SetFirstName(oItem, sName);

}

// else {PrettyDebug("NOT setting new name - either name is empty string or item object is invalid."); }

DeleteLocalObject(oObj, VAR_ENCHANTED_ITEM_OBJECT);

}

Apendix

ga_alignment

ga_attack

ga_attack_target

ga_blackout

ga_camera_facing_point_party

ga_clear_comp

ga_commandable

ga_compshift

ga_conversation_self

ga_create_obj

ga_cutscene_move

ga_date_advance

ga_date_set

ga_death

ga_destroy

ga_destroy_item

ga_destroy_party_henchmen

ga_disable_scripts

ga_donothing

ga_door_close

ga_door_open

ga_effect

ga_enable_scripts

ga_end_game

ga_face_target

ga_faction_join

ga_faction_rep

ga_fade_from_black

ga_fade_to_black

ga_floating_str_ref

ga_floating_text

ga_force_exit

ga_gint_max

ga_gint_min

ga_give_feat

ga_give_gold

ga_give_inventory

ga_give_item

ga_give_item_global_int

ga_give_partial_quest_xp

ga_give_quest_xp

ga_give_xp

ga_global_float

ga_global_int

ga_global_string

ga_heal_pc

ga_henchman_add

ga_henchman_remove

ga_henchman_replace

ga_henchman_setmax

ga_journal

ga_jump

ga_jump_faction

ga_jump_party_in_formation

ga_jump_players

ga_load_mod

ga_local_float

ga_local_int

ga_local_string

ga_lock

ga_mapnote

ga_move

ga_move_exit

ga_music_battle_play

ga_music_battle_restore

ga_music_battle_save

ga_music_battle_set

ga_music_battle_stop

ga_music_play

ga_music_restore

ga_music_save

ga_music_set

ga_music_stop

ga_object_events_clear

ga_object_events_restore

ga_open_store

ga_party_add

ga_party_face_target

ga_party_freeze

ga_party_limit

ga_party_unfreeze

ga_play_animation

ga_play_custom_animation

ga_play_sound

ga_play_voice_chat

ga_reequip_all_items

ga_remember_equipped

ga_remove_comp

ga_remove_feat

ga_replace_comp

ga_reputation

ga_reset_level

ga_reset_level_by_xp

ga_restoration

ga_restore_equipped

ga_roster_add

ga_roster_add_blueprint

ga_roster_add_object

ga_roster_campaignnpc

ga_roster_despawn

ga_roster_despawn_all

ga_roster_gui_screen

ga_roster_party_add

ga_roster_party_remove

ga_roster_party_remove_all

ga_roster_rem

ga_roster_remove

ga_roster_selectable

ga_roster_spawn

ga_roster_spawn_rand_loc

ga_scripthidden

ga_setbumpstate

ga_setimmortal

ga_setplotflag

ga_setrecipes

ga_set_animation_condition

ga_set_associate_state

ga_set_gflag

ga_set_weapon_visibility

ga_set_wwp_controller

ga_sound_object_play

ga_sound_object_set_position

ga_sound_object_set_volume

ga_sound_object_stop

ga_start_convo

ga_start_mod

ga_take_gold

ga_take_item

ga_talkto

ga_time_advance

ga_time_set

ga_unequip_hands

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download