x2_am_inc

Generic system for town life and encapsulates all 'townie' behavior.

Constants

NameValueBrief Description
DISTANCE_OBJECT_TALK10.0Distance that objects will request works.
DISTANCE_TALKHUB4.0
EVENT_IAMTHEHUNTER5003Tells hunter to broadcast its hunter message every second.
EVENT_IT_SHOUTS5001
EVENT_NEEDMOREPATRONS5000Event number when one HUB asks another for extra patrons.
EVENT_NOTIT_SHOUTS5002
fDelayBetweenBarmaidAskingForDrinks60.0
FPATRONDELAY40.0Delay between patrons spawning in when others leave.
JOB_BARMAID1000JOB: Will wander around a room and serve drinks to NPCs and PCs.
JOB_BLACKSMITH1001JOB: Moves around room.
JOB_FRIEND1006
JOB_GUARD11002JOB: Patrols. Will occasionally interrogate people on the street.
JOB_GUARD21009JOB: Stationary Guard. Should do nothing but stand there.
JOB_HUNTER1008Same job as JOB_WANDER but used to differentiate them.
JOB_PATRON1003JOB: Wanders.
Will let self be drawn into conversations.
Will occasionally leave and return later with more gold.
JOB_TAG_IT1005
JOB_TAG_NOTIT1004
JOB_WANDER1007Same job as JOB_HUNTER but used to differentiate them.
LEISURE_THRESHHOLD100This is the number when NPCs will stop using Leisure objects.
LISTEN_GOAWAY995Stray dog goes away if told to.
LISTEN_IAMNOTIT996If I am not it, I tell it this, so it comes and gets me.
LISTEN_MOVETOTOWNHUB999Listen pattern to get people moving towards a town hub.
LISTEN_SOMEONEISIT998IT shouts this every heartbeat.
LISTEN_IHUNTYOU997Hunters say this to scare prey.
PLOT_COST_ALE1
PLOT_COST_SPIRITS5
PLOT_COST_WINE10
TASK_LEISURE_READBOOK1003Read a book if not busy.
TASK_LEISURE_SIT1004Sit on the chair.
TASK_WORK_ANVIL1001Objects may request anviling.
TASK_WORK_CLEANING1000Objects may request cleaning.
TASK_WORK_LAMPPOST1002Lampposts want to be turned on/off.

Functions

NameBrief Description
AskPatronToLeaveMakes patron leave randomly, or if another hub asks for him.
BarmaidMakeDrinkInternal function. NPC will drink from a bottle or player will be given the specified template. Can only be run from a conversation.
BarmaidMakeDrunkLoses a few points of intelligence.
CreateCritterInternal function. Creates a creature at a specific location and tells it to move to a different location. Also creates gold on the creature.
CreateRatCreates a rat (called by Rat 'see baddy' and Garbage scripts).
CreatureValidForHubUseCreatures true if this is an acceptable creature for use in the conversation hub.
DecrementLeisureCertain objects increase a character's Leisure rating. Once this rating gets above the LEISURE_THRESHHOLD they do not want to do leisure things anymore.
DoJobMain performing a job function for creatures.
FaceMakes one object face another object.
GetAmbientBusyReturns TRUE if the ambient is currently working on a task assigned by a placeable object(s).
GetInTransitionReturns TRUE if the character is in transition.
GetJobReturns the Job that this NPC should perform.
GetLeisureCertain objects increase a character's Leisure rating. Once this rating gets above the LEISURE_THRESHHOLD they do not want to do leisure things anymore.
GetReadyOnly returns TRUE if the object is ready to be given more actions or to be interrupted.

Set "X2_G_LEAVEMEALONE" on characters that don't want to be bugged by tasks or jobs.
GoToRandomPersonAndInitWill go up to a valid bar patron (not associates).
HeadTurnInternal function. Called from objects when NPC's leisure is too high to want to use object.
IncrementLeisureCertain objects increase a character's Leisure rating. Once this rating gets above the LEISURE_THRESHHOLD they do not want to do leisure things anymore.
IsAtJobReturns TRUE if the NPC is in their 'at work' area.

This is a variable set on the Area with the Tag of the NPC.

If the tag is 10, it means the NPC is at work.
JobBarPatronBar patron job task.

The Bar patron will wander if not near a 'CONVERSATION HUB'.

Will leave if run low on gold.

Door he leaves by will recreate him in an arbitrary amount of time.
NoPlayerInAreaReturns TRUE if there is no player in the area. This function has to be run from an object.
PlayerSeenReturns TRUE if a player can be seen.
PlayRandomImmobileAnimationPlays a random animation.
RequestAsks the appropriate creature to perform a LEISURE or WORK task.

The object MUST be the nearest object to be able to comply with the request.

This will only take place if the NPC is of the appropriate job, close enough, not involved in conversation and not currently busy performing another task.
SetAmbientBusySets ambient on.
SetInTransitionTransit is set when the character is walking between areas like the barmaid going home during the day.
SetJobDefines why this NPC exists. Called from the spawn in script.
SetupInn1DrinkPricesInternal function. Sets up the drink prices for an Inn.


  author: Mistress, contributor: Graewerld