<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.herc.ws/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.herc.ws/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pan</id>
		<title>Hercules Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.herc.ws/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pan"/>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Special:Contributions/Pan"/>
		<updated>2026-05-02T21:25:59Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.21.11</generator>

	<entry>
		<id>https://wiki.herc.ws/wiki/OnTouch</id>
		<title>OnTouch</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/OnTouch"/>
				<updated>2014-01-17T18:42:01Z</updated>
		
		<summary type="html">&lt;p&gt;Pan: OnTouch npc event&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Syntax=&lt;br /&gt;
 Map,X,Y,facing%tab%script%tab%NPCName%TABID,&amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt;,&amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt;,{CODE}&lt;br /&gt;
 &lt;br /&gt;
 OnTouch:&lt;br /&gt;
 OnTouchNPC:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=Description=&lt;br /&gt;
Defines an area that when walked into will trigger one of two event labels depending on block type (BL_MOB or BL_PC)&lt;br /&gt;
==Calculating spawned area==&lt;br /&gt;
[[File:Ontouch.jpg|thumbnail|A 7*7 area spawned by X:3 Y:3]]&lt;br /&gt;
These triggers will define an area, centered on the NPC and spanning &amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt; cells in every direction across X coordinate axis and &amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt; cells in every direction across Y coordinate axis. Thus each one will have N*2 cells, where N is &amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt;, plus the one that the NPC is.&amp;lt;br&amp;gt;&lt;br /&gt;
Unlike in arithmetics X and Y will also be taken into account when calculating the area that will trigger the NPC. There are four quadrants, each with &amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt;*&amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt; cells plus both axes.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;u&amp;gt;Note that each coordinate is a &amp;lt;b&amp;gt;cell&amp;lt;/b&amp;gt; and does not represent map coordinates!&amp;lt;/u&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 4*(x*y) + 2*x + 2*y + 1&lt;br /&gt;
A simple way to measure the area of any polygon that will be covered by OnTouch is &amp;lt;u&amp;gt;(&amp;lt;i&amp;gt;triggerX&amp;lt;/i&amp;gt;*2+1)*(&amp;lt;i&amp;gt;triggerY&amp;lt;/i&amp;gt;*2+1)&amp;lt;/u&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Trick''': Using &amp;quot;end;&amp;quot; at the beginning of the script stops players from executing the script by clicking on the NPC, so they can only execute it if they walk into the specified area.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==Event labels==&lt;br /&gt;
Two event labels are defined and each one handles one of two block types BL_PC or BL_MOB &amp;lt;i&amp;gt;id est&amp;lt;/i&amp;gt; a player or a mob.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 OnTouch:&lt;br /&gt;
Handles player types (BL_PC)&lt;br /&gt;
 OnTouchNPC:&lt;br /&gt;
Handles mob types (BL_MOB)&amp;lt;br&amp;gt;&lt;br /&gt;
If no trigger label is defined the code will execute from the beginning of the script, the same way that it would if someone clicked on the NPC.&lt;br /&gt;
==Example==&lt;br /&gt;
 prontera,147,153,3	script	Mary	71,3,3,{&lt;br /&gt;
 	end;&lt;br /&gt;
 &lt;br /&gt;
 OnTouch:&lt;br /&gt;
 	mes &amp;quot;[Mary]&amp;quot;;&lt;br /&gt;
 	mes &amp;quot;Have you seen my lamb?&amp;quot;;&lt;br /&gt;
 	close;&lt;br /&gt;
 OnTouchNPC: // NO ONE IS ATTACHED!&lt;br /&gt;
 	announce &amp;quot;A mob passed here&amp;quot;,bc_blue|bc_all;&lt;br /&gt;
 	end;&lt;br /&gt;
 }&lt;br /&gt;
This script will spawn 3 cells in each direction plus a cell in the center.&lt;br /&gt;
 4*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;+2*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;+2*&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;+1 = 49&lt;br /&gt;
Or&lt;br /&gt;
 (&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;*2+1) * (&amp;lt;u&amp;gt;3&amp;lt;/u&amp;gt;*2+1) =&lt;br /&gt;
 7*7 = 49&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Command]]&lt;/div&gt;</summary>
		<author><name>Pan</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/File:Ontouch.jpg</id>
		<title>File:Ontouch.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/File:Ontouch.jpg"/>
				<updated>2014-01-17T17:55:06Z</updated>
		
		<summary type="html">&lt;p&gt;Pan: OnTouch representing a 7*7 area&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OnTouch representing a 7*7 area&lt;/div&gt;</summary>
		<author><name>Pan</name></author>	</entry>

	<entry>
		<id>https://wiki.herc.ws/wiki/Adding_New_Mapflag</id>
		<title>Adding New Mapflag</title>
		<link rel="alternate" type="text/html" href="https://wiki.herc.ws/wiki/Adding_New_Mapflag"/>
				<updated>2013-12-25T09:05:37Z</updated>
		
		<summary type="html">&lt;p&gt;Pan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When scripting, or creating custom automated events, you may wish to add your own custom mapflags. In order to do so, you'll need to complete some source edits. This article will explain how.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This article was originally created by [http://www.eathena.ws/board/index.php?showuser=273955 TecnoCronus] on the eAthena forums.&lt;br /&gt;
&lt;br /&gt;
== Adding your mapflag ==&lt;br /&gt;
&lt;br /&gt;
=== Open /src/map/map.h ===&lt;br /&gt;
----&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 unsigned src4instance : 1; // To flag this map when it's used as a src map for instances&lt;br /&gt;
&lt;br /&gt;
'''Add below:'''&lt;br /&gt;
 unsigned mymapflag : 1;&lt;br /&gt;
&lt;br /&gt;
=== Open /src/map/map.c ===&lt;br /&gt;
----&lt;br /&gt;
'''Find:'''&lt;br /&gt;
    } else if (!strcmpi(flag,&amp;quot;nocashshop&amp;quot;)) {&lt;br /&gt;
        if( state &amp;amp;&amp;amp; map-&amp;gt;list[m].flag.nocashshop )&lt;br /&gt;
            ;/* nothing to do */&lt;br /&gt;
        else {&lt;br /&gt;
            if( state )&lt;br /&gt;
                map_zone_mf_cache_add(m,&amp;quot;nocashshop\toff&amp;quot;);&lt;br /&gt;
            else if( map-&amp;gt;list[m].flag.nocashshop )&lt;br /&gt;
                map_zone_mf_cache_add(m,&amp;quot;nocashshop&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
'''Add below:'''&lt;br /&gt;
  else if( !strcmpi(flag,&amp;quot;mymapflag&amp;quot;)) {&lt;br /&gt;
        if( state &amp;amp;&amp;amp; map-&amp;gt;list[m].flag.mymapflag )&lt;br /&gt;
            ; /* nothing to do */&lt;br /&gt;
        else {&lt;br /&gt;
            if( state )&lt;br /&gt;
                map_zone_mf_cache_add(m,&amp;quot;mymapflag\toff&amp;quot;);&lt;br /&gt;
            else if( map-&amp;gt;list[m].flag.mymapflag )&lt;br /&gt;
                map_zone_mf_cache_add(m,&amp;quot;mymapflag&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== Open /src/map/script.h ===&lt;br /&gt;
----&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 MF_NOCASHSHOP&lt;br /&gt;
&lt;br /&gt;
'''Replace with:'''&lt;br /&gt;
 MF_NOCASHSHOP,&lt;br /&gt;
 MF_MYMAPFLAG&lt;br /&gt;
&lt;br /&gt;
=== Open /src/map/script.c ===&lt;br /&gt;
----&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 case MF_GUILDLOCK:        script_pushint(st,map[m].flag.guildlock); break;&lt;br /&gt;
&lt;br /&gt;
'''Below add:'''&lt;br /&gt;
 case MF_MYMAPFLAG:        script_pushint(st,map[m].flag.mymapflag); break;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 case MF_GUILDLOCK:     map[m].flag.guildlock=1; break;&lt;br /&gt;
&lt;br /&gt;
'''Below add:'''&lt;br /&gt;
 case MF_MYMAPFLAG:     map[m].flag.mymapflag=1; break;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 case MF_GUILDLOCK:     map[m].flag.guildlock=0; break;&lt;br /&gt;
&lt;br /&gt;
'''Below add:'''&lt;br /&gt;
 case MF_MYMAPFLAG:     map[m].flag.mymapflag=0; break;&lt;br /&gt;
&lt;br /&gt;
=== Open /src/map/npc.c ===&lt;br /&gt;
----&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 else if (!strcmpi(w3,&amp;quot;guildlock&amp;quot;))&lt;br /&gt;
 	map[m].flag.guildlock=state;&lt;br /&gt;
&lt;br /&gt;
'''Below add:'''&lt;br /&gt;
 else if (!strcmpi(w3,&amp;quot;mymapflag&amp;quot;))&lt;br /&gt;
 	map[m].flag.mymapflag=state;&lt;br /&gt;
&lt;br /&gt;
=== Open /db/const.txt ===&lt;br /&gt;
----&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 mf_guildlock&amp;lt;tab&amp;gt;45&lt;br /&gt;
&lt;br /&gt;
'''Below add:'''&lt;br /&gt;
 mf_mymapflag&amp;lt;tab&amp;gt;46&lt;br /&gt;
&lt;br /&gt;
== Listing your mapflag in atcommands ==&lt;br /&gt;
&lt;br /&gt;
=== Open /src/map/atcommand.c ===&lt;br /&gt;
----&lt;br /&gt;
'''Find:'''&lt;br /&gt;
    if (map-&amp;gt;list[m_id].flag.nomemo)&lt;br /&gt;
        strcat(atcmd_output, msg_txt(1064)); // NoMemo |&lt;br /&gt;
&lt;br /&gt;
'''Below add:'''&lt;br /&gt;
    if (map-&amp;gt;list[m_id].flag.mymapflag)&lt;br /&gt;
        strcat(atcmd_output, &amp;quot;mymapflag |&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 CHECKFLAG(nocashshop);&lt;br /&gt;
&lt;br /&gt;
'''Below add:'''&lt;br /&gt;
 CHECKFLAG(mymapflag);&lt;br /&gt;
&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 SETFLAG(nocashshop);&lt;br /&gt;
&lt;br /&gt;
'''Below add:'''&lt;br /&gt;
 SETFLAG(mymapflag);&lt;br /&gt;
&lt;br /&gt;
'''Find:'''&lt;br /&gt;
 clif-&amp;gt;message(sd-&amp;gt;fd,&amp;quot;guildlock, src4instance, notomb, nocashshop&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Replace it with:'''&lt;br /&gt;
 clif-&amp;gt;message(sd-&amp;gt;fd,&amp;quot;guildlock, src4instance, notomb, nocashshop, mymapflag&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
Recompile and you can now set &amp;quot;mymapflag&amp;quot; to any value. Remember, you can rename the mapflag to whatever, and later use the flag option anywhere else in your source code.&lt;br /&gt;
&lt;br /&gt;
[[Category:Source Snippets]]&lt;/div&gt;</summary>
		<author><name>Pan</name></author>	</entry>

	</feed>