<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Initnpctimer</title><link>https://sourceforge.net/p/hercules/wiki/Initnpctimer/</link><description>Recent changes to Initnpctimer</description><atom:link href="https://sourceforge.net/p/hercules/wiki/Initnpctimer/feed" rel="self"/><language>en</language><lastBuildDate>Mon, 20 Feb 2023 05:01:52 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/hercules/wiki/Initnpctimer/feed" rel="self" type="application/rss+xml"/><item><title>Initnpctimer modified by Brynner</title><link>https://sourceforge.net/p/hercules/wiki/Initnpctimer/</link><description>&lt;div class="markdown_content"&gt;&lt;div class="toc"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#syntax"&gt;Syntax&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#description"&gt;Description&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#parameters"&gt;Parameters&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#attach-flag"&gt;Attach Flag&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#npc-name"&gt;NPC Name&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#examples"&gt;Examples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h2 id="syntax"&gt;Syntax&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class="alink" href="/p/hercules/wiki/Initnpctimer/"&gt;[Initnpctimer]&lt;/a&gt; {&amp;lt;attach flag&amp;gt;}; &lt;/li&gt;
&lt;li&gt;&lt;a class="alink" href="/p/hercules/wiki/Initnpctimer/"&gt;[Initnpctimer]&lt;/a&gt; {"&amp;lt;NPC name&amp;gt;"}; &lt;/li&gt;
&lt;li&gt;&lt;a class="alink" href="/p/hercules/wiki/Initnpctimer/"&gt;[Initnpctimer]&lt;/a&gt; {"&amp;lt;NPC name&amp;gt;"{, &amp;lt;attach flag&amp;gt;}}; &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="description"&gt;Description&lt;/h2&gt;
&lt;p&gt;This script command will begin an NPC-attached timer on the running or&lt;br/&gt;
specified NPC. The timer will run internally in the NPC and is not attached to&lt;br/&gt;
any player, so will continue to run even when there are no players logged on.&lt;br/&gt;
It is important to note that an NPC can only run a single timer on itself at&lt;br/&gt;
any given time. In order to process multiple timers, the script would have to&lt;br/&gt;
use player based timers such as &lt;a class="alink" href="/p/hercules/wiki/Addtimer/"&gt;[Addtimer]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The timer runs in milliseconds (1/1000th of a second) from 0, and calling this&lt;br/&gt;
script command will begin a new timer (if a timer is not already running on&lt;br/&gt;
the NPC) or reset the current timer on the NPC. To completely stop the NPC&lt;br/&gt;
timer, the script command &lt;span&gt;[Stopnpctimer]&lt;/span&gt; must be called, and to resume the&lt;br/&gt;
timer (without resetting the current tick) the script command&lt;br/&gt;
&lt;span&gt;[Startnpctimer]&lt;/span&gt; must be called.&lt;/p&gt;
&lt;p&gt;The script can access a timer event by creating a label matching the format&lt;br/&gt;
"OnTimer&amp;lt;tick&amp;gt;:" where the &amp;lt;tick&amp;gt; is replaced with a millisecond value to&lt;br/&gt;
occur on. The NPC timer does not reset automatically once reaching one of&lt;br/&gt;
these labels, therefore it is possible to multiple labels with incremented&lt;br/&gt;
&amp;lt;tick&amp;gt; values to handle the same NPC timer (see &lt;a class="" href="../Examples"&gt;#Examples&lt;/a&gt;).&lt;/p&gt;
&lt;h2 id="parameters"&gt;Parameters&lt;/h2&gt;
&lt;h3 id="attach-flag"&gt;Attach Flag&lt;/h3&gt;
&lt;p&gt;The flag value determines whether a player should be directly associated with&lt;br/&gt;
this NPC timer. When flag is specified (a value of 1) the script will attach&lt;br/&gt;
the player who is currently attached to the script, to the timer. If no player&lt;br/&gt;
is attached to the script when this flag is specified, then the&lt;br/&gt;
&lt;a class="alink" href="/p/hercules/wiki/Initnpctimer/"&gt;[Initnpctimer]&lt;/a&gt; call will fail.&lt;/p&gt;
&lt;p&gt;If a player is successfully attached to the NPC timer, and logs out of the&lt;br/&gt;
game, then the event label "OnTimerQuit:" will run on the NPC (the player will&lt;br/&gt;
still be logged in at this point) to allow cleaning up and handling of the&lt;br/&gt;
timer.&lt;/p&gt;
&lt;h3 id="npc-name"&gt;NPC Name&lt;/h3&gt;
&lt;p&gt;If specified, the call to &lt;a class="alink" href="/p/hercules/wiki/Initnpctimer/"&gt;[Initnpctimer]&lt;/a&gt; will not apply to the current&lt;br/&gt;
running script but will take effect on the NPC which exists with the passed&lt;br/&gt;
NPC name. If an NPC could not be found with this name then the&lt;br/&gt;
&lt;a class="alink" href="/p/hercules/wiki/Initnpctimer/"&gt;[Initnpctimer]&lt;/a&gt; call will fail.&lt;/p&gt;
&lt;h2 id="examples"&gt;Examples&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Announce every 1 second (resetting the timer after every 1000 milliseconds) &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;initnpctimer&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;span&gt;[OnTimer]&lt;/span&gt;1000:&lt;br/&gt;
&lt;a class="alink" href="/p/hercules/wiki/Announce/"&gt;[Announce]&lt;/a&gt; "1 second has passed!", bc_all|bc_npc;&lt;br/&gt;
    initnpctimer;&lt;br/&gt;
&lt;a class="alink" href="/p/hercules/wiki/End/"&gt;[End]&lt;/a&gt;;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Announce at 5 and 10 seconds (stopping the timer once 10000 milliseconds is reached) &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;initnpctimer&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;span&gt;[OnTimer]&lt;/span&gt;5000:&lt;br/&gt;
&lt;a class="alink" href="/p/hercules/wiki/Announce/"&gt;[Announce]&lt;/a&gt; "5 seconds have passed!", bc_all|bc_npc;&lt;br/&gt;
&lt;a class="alink" href="/p/hercules/wiki/End/"&gt;[End]&lt;/a&gt;;&lt;/p&gt;
&lt;p&gt;OnTimer10000:&lt;br/&gt;
    announce "10 seconds have passed!!", bc_all|bc_npc;&lt;br/&gt;
&lt;span&gt;[Stopnpctimer]&lt;/span&gt;;&lt;br/&gt;
    end;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Perform an event on a player every 60 seconds (resetting the timer after every 60000 milliseconds) &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;initnpctimer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;span&gt;[OnTimer]&lt;/span&gt;60000:&lt;br/&gt;
&lt;span&gt;[Percentheal]&lt;/span&gt; 10, 0;&lt;br/&gt;
&lt;span&gt;[Message]&lt;/span&gt; &lt;a class="" href="../0"&gt;Strcharinfo&lt;/a&gt;, "You were healed 10% HP!";&lt;br/&gt;
    initnpctimer 1;&lt;br/&gt;
&lt;a class="alink" href="/p/hercules/wiki/End/"&gt;[End]&lt;/a&gt;;&lt;/p&gt;
&lt;p&gt;OnTimerQuit:&lt;br/&gt;
&lt;span&gt;[Stopnpctimer]&lt;/span&gt;;&lt;br/&gt;
&lt;a class="alink" href="/p/hercules/wiki/End/"&gt;[End]&lt;/a&gt;;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;[Category:Script Command]&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Brynner</dc:creator><pubDate>Mon, 20 Feb 2023 05:01:52 -0000</pubDate><guid>https://sourceforge.netc3a1ee8a44eeb0273a55962e277c611d892d18e0</guid></item></channel></rss>