<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://te4.org/w/index.php?action=history&amp;feed=atom&amp;title=T4_Modules_Howto_Guide%2FAI</id>
		<title>T4 Modules Howto Guide/AI - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://te4.org/w/index.php?action=history&amp;feed=atom&amp;title=T4_Modules_Howto_Guide%2FAI"/>
		<link rel="alternate" type="text/html" href="https://te4.org/w/index.php?title=T4_Modules_Howto_Guide/AI&amp;action=history"/>
		<updated>2026-05-08T07:26:21Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>https://te4.org/w/index.php?title=T4_Modules_Howto_Guide/AI&amp;diff=9631&amp;oldid=prev</id>
		<title>Zireael: start an article on AI</title>
		<link rel="alternate" type="text/html" href="https://te4.org/w/index.php?title=T4_Modules_Howto_Guide/AI&amp;diff=9631&amp;oldid=prev"/>
				<updated>2015-03-28T19:52:44Z</updated>
		
		<summary type="html">&lt;p&gt;start an article on AI&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Your [[NPCs]] need an AI to act. Fortunately for you, the AI class already defines everything that is needed, see the table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Part !! Explanation&lt;br /&gt;
|-&lt;br /&gt;
| name || the name that the self:runAI() function will call&lt;br /&gt;
|-&lt;br /&gt;
| function(self) || Where you put what the AI does&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Even better, your new AI can call another new AI (or one of the preexisting ones).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
newAI(&amp;quot;morale_flee&amp;quot;, function(self)&lt;br /&gt;
    if self.morale_life then&lt;br /&gt;
	      if self.life &amp;lt; self.morale_life then&lt;br /&gt;
		     if not self.energy.used then self:runAI(&amp;quot;flee_dmap&amp;quot;) end&lt;br /&gt;
	      end&lt;br /&gt;
    end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now if you call self:runAI(&amp;quot;morale_flee&amp;quot;) - preferably in another AI definition such as &amp;quot;dumb_talented_simple&amp;quot; (or your &amp;quot;newfangled_AI&amp;quot;) and '''NOT''' in NPC.lua - your creatures will flee if reduced below their morale_life value.&lt;br /&gt;
&lt;br /&gt;
Go back to [[T4 Modules Howto Guide]]&lt;/div&gt;</summary>
		<author><name>Zireael</name></author>	</entry>

	</feed>