{"id":1910,"date":"2024-04-05T13:50:19","date_gmt":"2024-04-05T12:50:19","guid":{"rendered":"https:\/\/www.katsbits.com\/site\/?p=1910"},"modified":"2024-04-05T13:50:19","modified_gmt":"2024-04-05T12:50:19","slug":"npc-basics","status":"publish","type":"post","link":"https:\/\/www.katsbits.com\/site\/npc-basics\/","title":{"rendered":"RtCW NPC basics &#8211; why are AI stupid?"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.katsbits.com\/site\/npc-basics\/#NPCs_Are_Not_Stupid\" >NPC&#8217;s Are Not Stupid<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.katsbits.com\/site\/npc-basics\/#Dumbing_Down_NPCs\" >Dumbing Down NPCs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.katsbits.com\/site\/npc-basics\/#NPC_%E2%80%98Alertness_and_%E2%80%98Field_of_View_Attributes\" >NPC &#8216;Alertness&#8217; and &#8216;Field of View&#8217; Attributes<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>Making single player levels for Return to Castle Wolfenstein, or indeed any game that makes use of Non-player Characters (NPC&#8217;s), can be frustrating and difficult at the best of times. However, depending on the options available to the level or scripting designer there are ways to mitigate some of the problems that arise as a result of using NPC&#8217;s.<\/p>\n<p>The following explains how understanding two core mechanics of most AI, that is their &#8216;<b>distance awareness<\/b>&#8216; and &#8216;<b>all-round vision<\/b>&#8216; can be used to control their behaviour, making NPC&#8217;s and the situations within which they can be used, more controllable.<\/p>\n<blockquote>\n<p><b>Design note<\/b>: that although the following concerns editing Return to Castle Wolfenstein by way of explanation, the general principles should be applicable to any game where NPC&#8217;s can be controlled to finer degrees by altering settings that expose their respective &#8216;personalities&#8217; (the properties and parameters controlling their reactions and responses to in-game and\/or triggered events<\/p>\n<\/blockquote>\n<h3><span class=\"ez-toc-section\" id=\"NPCs_Are_Not_Stupid\"><\/span>NPC&#8217;s Are Not Stupid<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To answer the question posed in the heading; NPC&#8217;s are not really &quot;stupid&quot;  but they <i>can<\/i> certainly be a real nuisance to work with at times. Having them react to the player, but not so aggressively they appear to be psychic or apparently pre-emptive, can take some cajoling, especially when they should be performing various actions whilst &#8216;waiting&#8217; for the player &#8211;  a patrol, butt scratch or some other ambient action that provides context and an reason for the NPC to be where it is in the first place. It&#8217;s this latter aspect of working with NPC&#8217;s that can take a long time to work out,  tweaking and adjusting different settings to mitigate issues whilst trying to avoid making them &#8216;stupid&#8217;.<\/p>\n<p> As an example of this the default &#8216;sensitivity&#8217; (how reactive the character is to its environment) for an <b>NPC in Return to Castle Wolfenstein<\/b> is <b>16,000 game units<\/b> &#8211; as measured using Radiant level editor. A typical room might be 256 units high by 512 units wide\/deep, so the NPC&#8217;s default alertness value represents an extremely large active area of engagement in comparison (shown below). This disparity, between room\/level size and alertness distance, typically equates to NPC&#8217;s inadvertently triggering events prematurely, if those are ambient NPC actions (patrol, butt scratch etc.), the player will rarely see them because they (the player) is spotted long beforehand and the function cancelled or over-ridden by a reactive property (&quot;attack&quot; for example). The upshot of this is a wasted event script.<\/p>\n<div class=\"content_images\"><a href=\"https:\/\/www.katsbits.com\/images\/tutorials\/rtcw-sp-editing\/ai-alertness-attribute-16000.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.katsbits.com\/images\/tutorials\/rtcw-sp-editing\/ai-alertness-attribute-16000_med.png\" alt=\"Comparative size versus distance of NPC to its &quot;alertness&quot; attribute\" width=\"740\" height=\"129\" border=\"0\" title=\"Comparative size versus distance of NPC to its &quot;alertness&quot; attribute\" \/><\/a><\/p>\n<p>Default &#8216;alertness&#8217; distance of a typical NPC in RtCW set at 16,000 game units &#8211; NPC editing entity and some basic brush volumes show comparative size versus distance &#8211; the teeny-tiny red spot on the left stands next to a 128, 256 and 512 unit cube on a ground plain stretching out 16,000+ units to the far right<\/p>\n<\/p><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Dumbing_Down_NPCs\"><\/span>Dumbing Down NPCs<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Where triggered events are needed this overt sensitivity can be fixed by making the NPC &#8216;dumb&#8217; or &#8216;blind&#8217;. Whilst this is usually a simple matter of changing an &quot;attribute&quot; value, the inherent problem with this often has the player being able to walk right up to the NPC and literally kick them in the butt to no effect or avail!.     To avoid this what tends to be necessary is a combination of making the NPC &#8216;blind&#8217; and &#8216;deaf&#8217; on spawn (non-reactive) so some sort of default action can be triggered, then as part of that sequence, changing the AI&#8217;s properties to better suit the environment within which it&#8217;s located. <\/p>\n<p>For example, if an AI is placed into a small 512 x 512 room and never required to leave, its sensitivity can be reduced without necessarily effecting other attributes that might otherwise negatively impact its reactions to the players presence once in the same room. The trick, if it can be called that, is in trying to achieve a balance between the NPC not triggering too early &#8211; whilst the player is in another room for example, and\/or unless there are compounding events triggering the NPC to changes its status (to become &quot;alert&quot;) &#8211; and at the same time reacting reasonably to the player during interaction. For Return to Castle Wolfenstein single player editing this is typically done using the &quot;<b>alertness<\/b>&quot; and &quot;<b>field of view<\/b>&quot; attributes properties.<\/p>\n<div class=\"content_images\"><a href=\"https:\/\/www.katsbits.com\/images\/tutorials\/rtcw-sp-editing\/npc-not-see-player.jpg\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.katsbits.com\/images\/tutorials\/rtcw-sp-editing\/npc-not-see-player_med.jpg\" alt=\"NPC in RtCW not reacting to players presence (simulatation using &quot;notarget&quot;)\" width=\"740\" height=\"432\" border=\"0\" title=\"NPC in RtCW not reacting to players presence (simulatation using &quot;notarget&quot;)\" \/><\/a><\/p>\n<p>Using the &quot;<b>notarget<\/b>&quot; developer code in RtCW an Infantry soldier is simulated being blind to the players presence standing behind due to its <b>attributes<\/b> properties being set to low, or more likely, the result of compounding instructions needed so a particular function can be performed without the AI being triggered to early<\/p>\n<\/p><\/div>\n<h3><span class=\"ez-toc-section\" id=\"NPC_%E2%80%98Alertness_and_%E2%80%98Field_of_View_Attributes\"><\/span>NPC &#8216;Alertness&#8217; and &#8216;Field of View&#8217; Attributes<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>For most NPC&#8217;s in RtCW the two basic properties, or &quot;<b>attributes<\/b>&quot; to give them their proper descriptor, that control a characters sensitivity are the aforementioned &quot;<b>alertness<\/b>&quot;, and &quot;<b>field of view<\/b>&quot; (FOV); the former determines distance (as previously described); the latter an &#8216;arc of attention&#8217;, i.e. a radius around itself of which its aware. Whilst the default alertness distance is 16,000 editor units, if that were to be directed at a narrower FOV, 60&deg; for example (the default is 240&deg;), it would result in an AI that could see a long way but within a restricted view, a &#8216;sniper&#8217; type character. Similarly, a short &#8216;alertness&#8217; distance (2048 units) with full fov (360&deg; or close to it) results in a &#8216;watch tower&#8217; guard with unrestricted views all around.<\/p>\n<div class=\"content_images\"><a href=\"https:\/\/www.katsbits.com\/images\/tutorials\/rtcw-sp-editing\/ai-fov-radius-240.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.katsbits.com\/images\/tutorials\/rtcw-sp-editing\/ai-fov-radius-240_med.png\" alt=\"An NPC's &quot;alertness&quot; attribute versus its &quot;field of view&quot; (all round vision)\" width=\"740\" height=\"416\" border=\"0\" title=\"An NPC's &quot;alertness&quot; attribute versus its &quot;field of view&quot; (all round vision)\" \/><\/a><\/p>\n<p>Understanding an NPC&#8217;s &quot;Field of View&quot; (FOV) can mean reducing how reactive an AI might be to its environment absent problems typically associated with having to keep or use a large area of &quot;alertness&quot;<\/p>\n<\/p><\/div>\n<p>Understanding this it means that an NPC can be controlled to a certain extent to prevent it from triggering or reacting too early<br \/>\n      whilst allowing for any actions or events to play out until the NPC is directly confronted by the player. This is not to say it works all the time, it&#8217;s a compromise that may result in &#8216;deaf\/blind AI&#8217;s in certain circumstances, but this is needed if the player is to be engaged in the game environment. Else one might as well spawn the AI in a duck pond for easy shooting.<\/p>\n<div class=\"content_images\"><a href=\"https:\/\/www.katsbits.com\/images\/tutorials\/rtcw-sp-editing\/ai-distance-alertness-radius.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.katsbits.com\/images\/tutorials\/rtcw-sp-editing\/ai-distance-alertness-radius_med.png\" alt=\"How changing an NPC's FOV and &quot;alertness&quot; can be used to achieve workable AI\" width=\"740\" height=\"416\" border=\"0\" title=\"How changing an NPC's FOV and &quot;alertness&quot; can be used to achieve workable AI\" \/><\/a><\/p>\n<p>Changing the &quot;alertness&quot; and &quot;fov&quot; values of NPC&#8217;s to alter the characteristics and general behaviour of AI and how they react to in-game events &#8211; a narrow FOV can mean the AI tends to focus directly on events directly in front like a sentry, or all around like a patrolling guard; different settings being used to create different behavioural characteristics<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1911,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[485,487,328,106,109,108,486,23],"class_list":["post-1910","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-ai","tag-attribute","tag-entities","tag-gtkradiant","tag-level-design","tag-level-editing","tag-npc","tag-rtcw"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/posts\/1910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/comments?post=1910"}],"version-history":[{"count":1,"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/posts\/1910\/revisions"}],"predecessor-version":[{"id":1914,"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/posts\/1910\/revisions\/1914"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/media\/1911"}],"wp:attachment":[{"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/media?parent=1910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/categories?post=1910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.katsbits.com\/site\/wp-json\/wp\/v2\/tags?post=1910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}