Just Curious - Why is x2_plc_used_sit not in the Lexicon?

To be frank, I didn’t even know that script existed before I found out about it in an ancient thread from the old nwn.bioware.com forums via the wayback machine. I couldn’t find mention of it in either the online or offline lexicon so I checked in the NwN1 Standard Assets downloads and sure enough, that function (x2_plc_used_sit) is there. While I agree that it is an extremely simple function, I have seen so many questions about making characters sit in chairs over the years that I would have thought x2_plc_used_sit would be included in the lexicon. How simple? Here is the extracted function -

//::///////////////////////////////////////////////
//:: OnUse: Sit
//:: x2_plc_used_sit
//:: Copyright (c) 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*

    Simple script to make the creature using a
    placeable sit on it

*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-09-18
//:://////////////////////////////////////////////

void main()
{

  object oChair = OBJECT_SELF;
  if(!GetIsObjectValid(GetSittingCreature(oChair)))
  {
    AssignCommand(GetLastUsedBy(), ActionSit(oChair));
  }

}

I’m not having a go at anyone, just curious is all.

TR

Probably because it’s a script and not a function. There are a few hundred of them in the game, many are generally useful like this one, but a bunch are plot specific. There used to be a list, probably similar to what you linked :slight_smile:

A new section in the lexicon with that list? I don’t think the offline one is maintained though.

1 Like

This. But I understand @Tarot_Redhand’s sentiment here. This script has just one universal purpose and is ready be dropped into any game. Since the less scripts are in the module the better, using such built-ins is recommended (also for educational reason).

Having a Lexicon category for “useful vanilla assets” would be definitely useful.

3 Likes

I thumbs up this idea, too. I can never remember the “make placeable start conversation on use” or the various conv node conditions when I need them.

3 Likes

I can never find those conv utils either (or at least the script that sets “talked to this object” var - does it even exist?), however

has somewhat easy-to-guess name, so for the record: x0_startconv (there is also nw_startconv for those who like to converse with themselves). And a bonus for @Tarot_Redhand: x2_plc_used_act which properly triggers lever animation states (super useful, but the variable is hardcoded instead of being included from somewhere).

It’s funny but I tend to think that people know about this stuff. There’s all sorts of useful scripts in there that I dug about to find back when I did development for PWs in an environment were size mattered, as it were. Unfortunately, brain being what it is, I’ve managed to forget most of them but that particular one stuck.

There’s one there somewhere that makes an NPC that just spawned automatically sit in a chair with a given tag too, nw_sitting I think. One that opens the nearest merchant rather than a specific one, though this may be better known. All sorts of little gems.

There’s also one that makes creatures/NPCs walk about randomly immediately after spawning in too (x2_spn_rndwalk). On the plus side all the 200+ starting conditional scripts are named in this download on here. That was the same list as the one that I converted to pdf and included in this.

Makes you wonder what else is out there.

That one is in the standard assets download too (gotta love Agent Ransack for finding stuff quick). Being in both compiled and uncompiled it looks easy enough to edit to use a different variable in a custom version of that script.

TR

1 Like

This is a very nice resource - all we need now is it’s brother with action scripts. While there are more conditionals available, using it I managed to solve this:

So again, for the record: check if met - x0_d2_notmet.nss, set if met - x0_d1_meet.nss (there is no vanilla “unmeet” script).

I’m thinking of converting all scripts with main/StartingConditional into one large PDF or HTML page (or maybe just all?), so we can easily search through it for the needed functionality (which can be usually quickly guesses based on docstring). Not to mention the ability to see highlighted syntax.

2 Likes

An appendix to the Lexicon or something similar would be really helpful. Speaking for myself, many times it’s easier to just write the script than to go searching for an existing script. If I had an easy to find and read resource, I’d be much more likely to use an existing script instead.

Well, it kinda sucks.

I’ve found that same script many times when googling “NWN sittable chair” or something similar and always ended up on the same old forum post somewhere with this script.

And I never use it anymore. It doesn’t even tell you “that seat is taken” if someone else is sitting there and I have no idea how it treats NPCs coded to interact with the chair.

The fact that EE has been released means there’s an influx of new builders coming in and for their sake compiling a list of basic scripts already present within the game might be a good idea. But even a noob like me doesn’t use that particular script.

FYI, if you change the tag of a placeable to NW_INTERACTIVE (I think thats it) any NPC you put X2_L_SPAWN_USE_AMBIENT (int) = 1 on its variables will interact with it.

There is another script called nw_d2_sitting you can place on an NPC’s on spawn that is designed to make the NPC sit on the nearest chair who’s tag is NW_CHAIR. Not so useful I guess if you want the NPC to be able to do more, but there’s always splicing it into another onspawn

Here, look at this STUFF I skimmed off the interwebs: (sorry if its too long)

x2_o2_dead : OnDeath of placeable. Drops craft
item.
x2_plc_used_act : OnUsed. Makes placeable play it’s
animation when used by PC.
x2_plc_used_opn : OnUsed. Makes
placeable open/close when used by PC.
x2_plc_used_pray: OnUsed.
PC is made to pray at placeable.
x2_plc_used_sit : OnUsed of
chairs etc. PC can sit in it.
x2_spn_ambanim : OnSpawn of NPC.
Mobile ambient animations.
x2_spn_dead : OnSpawn of NPC. Instant
death. Can also be used in ActionTaken to kill NPC.
x2_spn_drop_rw
: OnSpawn of NPC. Drop in and randomwalk.
x2_spn_dropin :
OnSpawn of NPC. Drop in.
x2_spn_heartbeat: OnSpawn of NPC. To
be used with UserDefined heartbeat events.
x2_spn_hervorehb:
OnSpawn of herbivore NPC. Heartbeat event is also set.
x2_spn_ondeath
: OnSpawn of NPC. OnDeath event is set.
x2_spn_perceive : OnSpawn
of NPC. OnPerception event is set.
x2_spn_rndwalk : OnSpawn of
NPC. Walks about randomly.
x1_openstore : Opens the nearest
store, with normal appraise check.
x1_openstorefav : Opens the
nearest store, with favorable appraise check.
x2_act_coolitem :
OnPerception of boss. Boss gets cool weapon in hand. (Kill him to get
it.)
x2_am_bookread : OnHeartbeat of bookshelf. NPCs will go
over and “read”.
x2_am_conv : OnConversation for

x0_o2_pickup : OnUsed of placeable.
Destroys it and creates an item with same resref + “_i”
in
the PC’s inventory.
x0_o2_raise_dead: OnEnter of a trigger.
Resurrects the nearest corpse. See x0_c2_spwn_corp
x0_o2_use_chair
: OnUsed of chairs etc. PC can sit in chair.
x0_o2_use_portal:
OnUsed of portal. Teleports party to WP tagged “DST” +
“tag_of_portal”.
x0_o2_use_tdoor : OnUsed of trapdoor.
Teleports party to WP tagged “DST” +
“tag_of_trapdoor”.
x0_o2_use_wdoor : OnUsed of walldoor.
Teleports party to WP tagged “DST” +
“tag_of_walldoor”.
x0_speakoneliner: OnUsed of
placeable. Makes it speak it’s oneliner conv.
x0_startconv :
OnUsed of placeable. It starts conversation with user.
x0_d1_go_hostile: Attack on conv end. Sets own faction to
hostile, clears plot/immortal flags.
x0_d1_heal_pc : Heals PC and
associates. Almost exact copy of nw_d1_templeheal.
x0_d1_stor_open
: Opens the nearest store, with normal appraise
checks.
x0_d1_g2_cheer :
following scripts, can be put in various script slots:
ActionTaken,
x0_d1_g2_cheer2 : OnPerceived, OnConversation,
OnPhysicalAttacked, used with ExecuteScript

x0_d1_g2_cheer3 : from
a trigger etc. Make sure the NPCs have different
voicesets.
x0_d1_g2_goodby :
x0_d1_g2_healme :
x0_d1_g2_hello
:
x0_d1_g2_help :
x0_d1_g2_laugh :
x0_d1_g2_no
:
x0_d1_g2_talkto :
x0_d1_g2_threat :
x0_d1_g2_yes
nw_g0_convdoor : OnUsed of door. Starts
conversation with PC.
nw_g0_convplac : OnUsed of placeable. Starts
conversation with PC.
nw_g0_transition: The default transition
script on doors.
nw_o0_testanim : For testing which animations a
creature can do. Put in OnHeartbeat.
nw_o2_gargoyle : Onheartbeat
of placeable. Turns it into a gargoyle if PC is close
enough.
nw_o2_skeleton : OnHeartbeat of placeable. Turns it
into a skeleton if PC is close enough.
nw_o2_torchonoff:
OnHeartbeat of placeable. Turns animation on at day/off at
night.
nw_o2_zombie : OnHeartbeat of placeable. Turns it
into a zombie if PC is close enough.
nw_walk_wp : The default
CurrentFile Normal/Aborted script. Makes NPC walk waypoints.

x0_c2_attack_all: Attack on conv end. Makes faction hostile and
shouts “NW_ATTACK_MY_TARGET”.
x0_c2_attack_one: Attack
on conv end. Makes self hostile and shouts
“NW_ATTACK_MY_TARGET”.
x0_c2_dth_cdecay: OnDeath of NPC.
Leaves decorative corpse that decays. Treasure after
decayed.
x0_c2_dth_cdecor: OnDeath of NPC. Leaves a decorative
corpse that will never decay.
x0_c2_dth_craise: OnDeath of NPC.
Leaves a decorative corpse that can be resurrected.
x0_c2_dth_cselec:
OnDeath of NPC. Leaves a decorative corpse whose name can be
seen.
x0_c2_dth_explod: OnDeath of NPC. The NPC explodes on death
(fireball).
x0_c2_dth_loot : OnDeath of NPC. Leaves a
decorative corpse that can be looted.
x0_c2_dth_lootdc:
OnDeath of NPC. Leaves a lootable corpse that decays after a
while.
x0_c2_dth_poisn : OnDeath of NPC. The NPC explodes on
death (poison cloud).
x0_c2_go_hostile: Attack on conv end.
Sets own faction to hostile, and clears plot flag.
x0_c2_hbt_def :
Alternative OnHeartbeat for NPCs.
x0_c2_per_def : Alternative
Onperception for NPCs.
x0_c2_spl_def : Alternative OnSpellCastAt
for NPCs.

x0_c2_spwn_corp : OnSpawn of NPC.
Spawn as a “decorative” corpse.
x0_c2_spwn_cowrd:
OnSpawn of NPC. Cowardly combat tactics.
x0_c2_spwn_cres :
OnSpawn of NPC. Spawn as a corpse that can be raised from the
dead.
x0_c2_spwn_lhigh: OnSpawn of NPC. Spawn as a corpse that can
be looted, with high treasure.
x0_c2_spwn_llow : OnSpawn of NPC.
Spawn as a corpse that can be looted, with low
treasure.
x0_c2_spwn_lmed : OnSpawn of NPC. Spawn as a corpse that
can be looted, with medium treasure.
x0_c2_spwn_loot : OnSpawn of
NPC. Spawn as a corpse that can be looted.
x0_c2_spwn_luni :
OnSpawn of NPC. Spawn as a corpse that can be looted, with unique
treasure.
x0_c2_spwn_rang : OnSpawn of NPC. Ranged combat
tactics.
x0_d1_attack_all: Attack on conv end. Makes faction
hostile and shouts “NW_ATTACK_MY_TARGET”.
x0_d1_attack_one:
Attack on conv end. Makes self hostile and shouts
“NW_ATTACK_MY_TARGET”.
x0_d1_deekfaint : ActionTaken in
conversation. Makes NPC “faint”.
nw_ch_acgs9 : Giant
Spider animal companion on spawn
nw_ch_action13 : Henchman joins,
gives personal item
nw_ch_action17 : Henchman level
up
nw_d1_attonend : Attack on end of conversation (faction
hostile)
nw_d1_attonend02: Attack on end of conversation (only
speaker hostile)
nw_d1_attonend4 : Attack nearest
PC
nw_d1_attonendpl: Plot character attacks (PC certain
death)
guards
nw_c2_stnkbtdie : Stink Beetle on death
nw_c2_vampire7
: OnDeath - turn vampire into gaseous form
nw_c2_vampireg9 :
Gaseous form OnSpawn
nw_c2_vampiregd : Gaseous form
userdef
nw_c2_wnattack2 : On Perceive, if I see enemy, then
attack
nw_c2_wnattack4 : On Dialogue, attack if friend cries for
help
nw_c2_wnattack5 : On Attacked, if by friend or enemy, warn,
else attack
nw_c2_wnattack8 : OnDisturbed, warn, then
attack
nw_c2_wnattack9 : OnSpawn, set location and listen for help
cries
nw_c2_wnattackd : Warn and attack userdef
nw_c2_wnshout5
: On attacked, warn and summon helper
nw_c2_wnshout8 : On
attacked, warn, then make faction hostile
nw_c2_lycan_9 : OnSpawn, attacked
uncommented
nw_c2_lycat_d : Werecat UserDef
nw_c2_lyrat_d :
Wererat UserDef
nw_c2_lywolf_d : Werewolf UserDef
nw_c2_nodieflee
: Jump to safe location, returns after 5 sec.
nw_c2_omnivore :
OnSpawn, omnivore
nw_c2_patrol1 : Ambient guard heartbeat, mutters
to himself
nw_c2_dimdoor : Random Dimension Door combat
effect
nw_c2_dimdoors : OnSpawn, Ambient Anim. &
EndOfCombatRound uncommented
nw_c2_dropin9 : OnSpawn, Appear Anim
uncommented
nw_c2_gargoyle : Gargoyle heartbeat
nw_c2_gated :
Gated demon heartbeat
nw_c2_gatedbad : OnSpawn, self destruct
after 60 sec.
nw_c2_herbivore : OnSpawn,
herbivore
nw_02_onoff : Turns the light object’s
animation and light on/off
nw_c2_amb_target: Ambient Attack
placeables
nw_c2_assvict1 : OnSpawn: Perceive & Damaged
uncommented
nw_c2_bat9 : OnSpawn: Herbivore, Spawn In
animation
nw_c2_bossdie : Boss death script, spawns
treasure
nw_c2_bossspawn : Boss OnSpawn, enables Fast
Buff

1 Like

A useful looking library that I found by accident that is in the lexicon is x0_i0_transport -

//:://////////////////////////////////////////////////
//:: X0_I0_TRANSPORT
//:: Copyright (c) 2002 Floodgate Entertainment
//:://////////////////////////////////////////////////
/*

Functions for making creatures travel/transport to new locations.

 */
//:://////////////////////////////////////////////////
//:: Created By: Naomi Novik
//:: Created On: 09/12/2002
//:://////////////////////////////////////////////////

/**********************************************************************
 * CONSTANTS
 **********************************************************************/


/**********************************************************************
 * FUNCTION PROTOTYPES
 **********************************************************************/


// Target goes to specified destination object intelligently.
// If location is in same area, walk (or run) there.
// If location is in different area, walk (or run) to
//     most appropriate door, area transition, or waypoint, 
//     then jump.
// If either of these fail, jump after fDelay seconds.
void TravelToObject(object oDest, object oTarget=OBJECT_SELF, int bRun=FALSE, float fDelay=10.0);

// Target goes to specified location intelligently. See
// TravelToObject for description.
void TravelToLocation(location lDest, object oTarget=OBJECT_SELF, int bRun=FALSE, float fDelay=10.0);

// Find nearest exit to target (either door or waypoint).
object GetNearestExit(object oTarget=OBJECT_SELF);

// Find best exit based on desired target area
object GetBestExit(object oTarget=OBJECT_SELF, object oTargetArea=OBJECT_INVALID);

// Transport a player and his/her associates to a waypoint.
// This does NOT transport the rest of the player's party,
// only their henchman, summoned, dominated, etc.
void TransportToWaypoint(object oPC, object oWaypoint);

// Transport a player and his/her associates to a location.
// This does NOT transport the rest of the player's party,
// only their henchman, summoned, dominated, etc.
void TransportToLocation(object oPC, location oLoc);

// Transport an entire party to a waypoint
void TransportAllToWaypoint(object oPC, object oWay);

// Transport an entire party to a location
void TransportAllToLocation(object oPC, location lLoc);

TR

1 Like