
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ftl13.com/w/index.php?action=history&amp;feed=atom&amp;title=Guide_to_snpc</id>
	<title>Guide to snpc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ftl13.com/w/index.php?action=history&amp;feed=atom&amp;title=Guide_to_snpc"/>
	<link rel="alternate" type="text/html" href="https://ftl13.com/w/index.php?title=Guide_to_snpc&amp;action=history"/>
	<updated>2026-05-16T01:53:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://ftl13.com/w/index.php?title=Guide_to_snpc&amp;diff=1069&amp;oldid=prev</id>
		<title>Monster860: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://ftl13.com/w/index.php?title=Guide_to_snpc&amp;diff=1069&amp;oldid=prev"/>
		<updated>2016-07-24T19:25:29Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Writing a SNPC module==&lt;br /&gt;
Writing a module for an SNPC is easy, but several things need to be kept in mind for optimum process:&lt;br /&gt;
*Modules are processed in a linear, but staggered fashion (from left to right in the /list/functions).&lt;br /&gt;
*Modules use sleep(1) to run them, and thus they are queued behind each other in the execution time.&lt;br /&gt;
*Modules that interrupt normal function, or edit NPC vars, should use isNotFunc() as the first proc, else strange problems will occur.&lt;br /&gt;
&lt;br /&gt;
==Item Handling==&lt;br /&gt;
Item handling (such as keeping hands free, putting in bags etc) should be mostly done by the main loop, so it is safe to just call take_to_slot(/obj/item), and the NPC does the rest.&lt;br /&gt;
&lt;br /&gt;
==Existing Modules==&lt;br /&gt;
It has several pre-made modules, which are as follows:&lt;br /&gt;
* Nearbyscan: keeps a list of nearby mobs.&lt;br /&gt;
* Combat: handles all the default combat actions.&lt;br /&gt;
* Doorscan: keeps a list of nearby doors.&lt;br /&gt;
* Shitcurity: handles using handcuffs on people.&lt;br /&gt;
* Chatter: handles bot responses and random chatter.&lt;br /&gt;
&lt;br /&gt;
==NPC traits==&lt;br /&gt;
NPCs can be &amp;quot;varied&amp;quot; from each other in several ways:&lt;br /&gt;
* The five &amp;quot;trait&amp;quot; vars, which are set from 1 - 100, used as prob(trait):&lt;br /&gt;
* Robustness: Determines how often they should perform a robust action (hit right, break things)&lt;br /&gt;
* Smartness: Usually used as a negative (!prob(smartness)), indicates how often they should do &amp;quot;smart&amp;quot; things, like use an object or speak.&lt;br /&gt;
* Attitude: Determines how often they will retaliate and/or fight things.&lt;br /&gt;
* Slyness: Determines how often they will do &amp;quot;illegal&amp;quot; actions, ie stealing.&lt;br /&gt;
* Greytide: A 1/0 bool, Overrides most behaviour and causes the NPC to act like a &amp;quot;greytider&amp;quot;, breaking things and hurting people.&lt;br /&gt;
&lt;br /&gt;
==NPC base functions==&lt;br /&gt;
Accessing NPC base functions and controlling them:&lt;br /&gt;
*Overall, the NPC uses the var &amp;quot;interest&amp;quot; to determine how long they have been doing something, if interest peaks under certain amounts, the NPC will shift to doing something else. Interest goes up while the &amp;quot;doing&amp;quot;	var is not equal 0 (has bitflags assigned).&lt;br /&gt;
*NPCs keep track of their ID and their PDA using the MYID and MYPDA variables. These are direct references to the items, and can be used to activate, unlock/lock, and do all things both would do in general.&lt;br /&gt;
*NPCs also keep track of what is their hands in a &amp;quot;smart&amp;quot; way. The variables &amp;quot;main_hand&amp;quot; and &amp;quot;other_hand&amp;quot; reference the l_hand and r_hand of the NPC, but are shifted (and can be forced using enforce_hands()) when then NPC drops items, changes items etc, to make sure there is always something in the main_hand. The var &amp;quot;update_hands&amp;quot; can be set to 1 to force a recheck of hands (such as when picking items up)&lt;br /&gt;
*NPCs have two variables, TARGET and LAST_TARGET, which are used primarly for combat recognition. Setting TARGET to anything other than null will cause the Combat module to attempt to fight that target. LAST_TARGET is the last var TARGET has been set to. Additionally, the var &amp;quot;retal_target&amp;quot; refers to the last person to attack the NPC.&lt;br /&gt;
*NPCs have a custom travel proc, tryWalk(var/turf), which will attempt to walk them to the target. In cases where you want to force them to walk (such as sidestepping in combat, dancing etc), use walk2derpless(var/target) directly.&lt;br /&gt;
*Most interaction that NPCs do with the world should use target_filter(var/target) and denied_filter(var/denied) to check if they are valid targets.&lt;br /&gt;
&lt;br /&gt;
===Doing Var===&lt;br /&gt;
*The &amp;quot;doing&amp;quot; var has three distinct flags that are checked and changed for what the NPC is doing.&lt;br /&gt;
** INTERACTING: defines that an NPC is interacting with something.&lt;br /&gt;
** FIGHTING: defines that an NPC is in combat.&lt;br /&gt;
** TRAVEL: defines that an NPC is moving from one location to another.&lt;br /&gt;
** &amp;quot;doing&amp;quot; is a bitflag and can be changed with doing |= flag to add a flag, or doing = ~doing&amp;amp;flag to remove 	one.&lt;br /&gt;
&lt;br /&gt;
==Designing a module==&lt;br /&gt;
*Modules should not interrupt the flow of other modules, nor should they try to take precidence. Treat modules 	as an extra &amp;quot;task&amp;quot; for the NPC, Like crafting an item or opening a door.&lt;br /&gt;
**Modules handling Inventory items should make use of take_to_slot(var/obj) and insert_into_backpack() to do automated handling of item and hands.	&lt;br /&gt;
*Once a module is created, add it to the var/list/functions and it will be automatically executed.&lt;br /&gt;
&lt;br /&gt;
==Misc variable==&lt;br /&gt;
*Several Variables exist for ease of use, these include:&lt;br /&gt;
** MAX_RANGE_FIND and MIN_RANGE_FIND are the Max/Min range an NPC searches for things.&lt;br /&gt;
** FUZZY_CHANCE_HIGH and FUZZY_CHANCE LOW are the high and low for a lot of NPC probability that isn&amp;#039;t trait related roll.&lt;br /&gt;
** CHANCE_TALK is the probability the NPC will say things.&lt;br /&gt;
** TRAIT_* are bitflags that can be used to give the NPC special checks, such as always	stealing things (TRAIT_THIEVING) or never fighting (TRAIT_FRIENDLY)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Contribution guides}}&lt;br /&gt;
[[Category:Game Resources]] [[Category:Guides]]&lt;/div&gt;</summary>
		<author><name>Monster860</name></author>
	</entry>
</feed>