<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.cobblemon.com/index.php?action=history&amp;feed=atom&amp;title=Molang_NPC_Functions</id>
	<title>Molang NPC Functions - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cobblemon.com/index.php?action=history&amp;feed=atom&amp;title=Molang_NPC_Functions"/>
	<link rel="alternate" type="text/html" href="https://wiki.cobblemon.com/index.php?title=Molang_NPC_Functions&amp;action=history"/>
	<updated>2026-05-10T06:58:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.10</generator>
	<entry>
		<id>https://wiki.cobblemon.com/index.php?title=Molang_NPC_Functions&amp;diff=5768&amp;oldid=prev</id>
		<title>JPAKx4: Add Molang NPC Functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.cobblemon.com/index.php?title=Molang_NPC_Functions&amp;diff=5768&amp;oldid=prev"/>
		<updated>2025-04-19T22:17:55Z</updated>

		<summary type="html">&lt;p&gt;Add Molang NPC Functions&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Can also use [[Molang Entity Functions|entity functions]]. Type is &amp;lt;code&amp;gt;ObjectValue&amp;lt;NPCEntity&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable fixed-header sortable&amp;quot;&lt;br /&gt;
!Name!!Description!!Usage&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;class(): String&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns the id of the NPC as a String.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.class()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;name(): String&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns the name of the NPC.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.name()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;level(): Double&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns the level of the NPC.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.level()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;has_aspect(aspect: String): Double&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns &amp;lt;code&amp;gt;1.0&amp;lt;/code&amp;gt; if the NPC contains the &amp;lt;code&amp;gt;aspect&amp;lt;/code&amp;gt;, otherwise returns &amp;lt;code&amp;gt;0.0&amp;gt;/code&amp;gt;.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.has_aspect(&amp;#039;champion&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;face(isLeftSide: Boolean?): ObjectValue&amp;lt;ReferenceDialogueFaceProvider&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns a ObjectValue of &amp;lt;code&amp;gt;[[https://gitlab.com/cable-mc/cobblemon/-/blob/main/common/src/main/kotlin/com/cobblemon/mod/common/api/dialogue/DialogueFace.kt ReferenceDialogueFaceProvider]]&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;isLeftSide&amp;lt;/code&amp;gt; is true by default.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.face()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;in_battle(): Double&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns &amp;lt;code&amp;gt;1.0&amp;lt;/code&amp;gt; NPC is in battle, otherwise returns &amp;lt;code&amp;gt;0.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.in_battle()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;battles(): ArrayStruct&amp;lt;CHECK TYPE&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns all battles currently ongoing for this NPC.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.battles()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;stop_battles()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Stops all ongoing battles for this NPC.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.stop_battles()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;is_doing_activity(identifiers: String...): Double&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns &amp;lt;code&amp;gt;1.0&amp;lt;/code&amp;gt; if the NPC is doing any of the activities listed in the parameters, otherwise returns &amp;lt;code&amp;gt;0.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.is_doing_activity(&amp;#039;rest&amp;#039;, &amp;#039;idle&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;run_script_on_client(script: String)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|If run by a server a packet will be sent to all players in the same world as the NPC that tells the clients to run the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt;.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.run_script_on_client(&amp;#039;cobblemon:npc_battle_cooling_down&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;run_script(identifier: String): MoValue&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Runs a script from an &amp;lt;code&amp;gt;identifier&amp;lt;/code&amp;gt;. Returns the result of the script or &amp;lt;code&amp;gt;0.0&amp;lt;/code&amp;gt; if it fails.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.run_script(&amp;#039;cobblemon:npc_battle_cooling_down&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;run_action_effect(actionIdentifier: String): Double&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Runs an action effect. Returns &amp;lt;code&amp;gt;1.0&amp;lt;/code&amp;gt; if effect is found, otherwise returns &amp;lt;code&amp;gt;0.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.run_action_effect(&amp;quot;cobblemon:generic_damage&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;put_pokemon_in_healer(position: ArrayStruct&amp;lt;Int&amp;gt;): Double&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|The NPC attempts to put pokemon in a healing machine at &amp;lt;code&amp;gt;position&amp;lt;/code&amp;gt;. Returns &amp;lt;code&amp;gt;1.0&amp;lt;/code&amp;gt; if it succeeded, otherwise returns &amp;lt;code&amp;gt;0.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.put_pokemon_in_healer(t.pos)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;look_at_position(x: Double, y: Double, z: Double)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Makes the NPC look at the position of &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;z&amp;lt;/code&amp;gt;.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.look_at_position(0, 0, 0)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;environment(): MoLangEnvironment&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns the NPC&amp;#039;s environment.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.environment()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;party(): MoValue&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns an &amp;lt;code&amp;gt;ObjectValue&amp;lt;PartyStore&amp;gt;&amp;lt;/code&amp;gt; if the NPC has a party, otherwise returns &amp;lt;code&amp;gt;0.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.party()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;has_party(): Double&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns &amp;lt;code&amp;gt;1.0&amp;lt;/code&amp;gt; if NPC has a party, otherwise returns &amp;lt;code&amp;gt;0.0&amp;lt;/code&amp;gt;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.has_party()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;is_npc(): Double&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns &amp;lt;code&amp;gt;1.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.is_npc()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;can_battle(): Double&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Returns &amp;lt;code&amp;gt;1.0&amp;lt;/code&amp;gt; if NPC has a party and that party has health or if the party has &amp;lt;code&amp;gt;isStatic&amp;lt;/code&amp;gt; set to false. Otherwise returns &amp;lt;code&amp;gt;0.0&amp;lt;/code&amp;gt;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot;&amp;gt;q.npc.can_battle()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>JPAKx4</name></author>
	</entry>
</feed>