LeoRobert

Untitled

Jul 31st, 2018
2,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 328.20 KB | None | 0 0
  1. //===== Cronus Documentation ===============================
  2. //= Cronus Script Commands
  3. //===== By: ==================================================
  4. //= Cronus Dev Team
  5. //===== Description: =========================================
  6. //= A reference manual for the Cronus scripting language.
  7. //= Commands are sorted depending on their functionality.
  8. //============================================================
  9.  
  10. Este documento é um manual de referência para todos os comandos de
  11. Funções disponíveis no atual Cronus GIT. Não é um simples tutorial.
  12. Quando as pessoas lhe dizem para "Leia a documentação", eles querem dizer isso.
  13.  
  14. A informação foi adquirida principalmente através da análise de como as coisas
  15. Trabalho no código-fonte do servidor, que foi escrito por muitas pessoas
  16. Ao longo do tempo, e muitos deles não falam Inglês e nunca deixou quaisquer notas -
  17. Ou não estão disponíveis para comentários. Como tal, qualquer coisa escrita em
  18. Aqui pode não estar correto, é apenas correto para o melhor de nossos
  19. Conhecimento, que é limitado.
  20.  
  21. Este não é um lugar para te ensinar programação básica. Este documento não
  22. Ensinar programação básica por si só. É mais uma referência para aqueles
  23. Que têm pelo menos uma vaga idéia do que querem fazer e querem saber
  24. Que ferramentas eles têm disponível para fazê-lo. Tentamos mantê-lo tão simples
  25. Como viável, mas se você não entender, obter um livro claro sobre
  26. Programação em geral ajudará melhor do que gritar em torno do fórum para
  27. Socorro.
  28.  
  29. Um pouco de aprendizagem nunca causou a cabeça de ninguém para explodir.
  30.  
  31. Estrutura
  32. ---------
  33.  
  34. Os comandos e funções são listados em nenhuma ordem específica:
  35.  
  36. *Nome do comando e como chamá-lo.
  37.  
  38. Texto descritivo
  39.  
  40. Pequeno exemplo, se possível. Normalmente estará incompleto, está lá apenas
  41. Para lhe dar uma idéia de como ele funciona na prática.
  42.  
  43. Para encontrar um comando específico, use Ctrl + F, (ou qualquer tecla chamar uma pesquisa
  44. Função no que você está lendo isso com) colocar um * seguido pelo
  45. Comando, e ele deve encontrar a descrição do comando para você.
  46.  
  47. Se você encontrar alguma coisa omitida, por favor, informe-nos. :).
  48.  
  49. Sintaxe
  50. ------
  51.  
  52. Ao longo deste documento, sempre que um comando deseja um argumento, é
  53. Dado em <parênteses angulares>. Isso não significa que você deve digitar o ângulo
  54. Colchetes. :) Se um argumento de um comando é opcional, ele é dado em
  55. {Curly brackets}. Sem dúvida você viu esta convenção em algum lugar, se
  56. Você não, se acostumar, é assim que os garotos fazem isso. Se um comando
  57. Opcionalmente um número não especificado de argumentos, você verá uma lista como
  58. esta:
  59.  
  60. command <argumento>{,<argumento>...<argumento>}
  61.  
  62. Isso ainda significa que eles vão querer ser separados por vírgulas.
  63.  
  64. Onde um comando quer uma string, ela será dada em "citações", se for um
  65. Número, ele será dado sem eles. Normalmente, você pode
  66. Expressão, como um monte de funções ou operadores retornando um
  67. (Colchetes redondos) em vez da maioria dos números. Os colchetes não serão sempre
  68. Ser uma boa idéia.
  69.  
  70. Onde quer que você se refira a um mapa, use 'mapname' em vez de 'mapname.gat'.
  71.  
  72.  
  73. Script loading structure
  74. ------------------------
  75.  
  76. Os scripts são carregados pelo servidor de mapas conforme
  77. 'Conf / map-server.conf', mas no arquivo de configuração padrão
  78. Configuração, ele não carrega nenhum arquivo de script propriamente dito. Em vez disso, ele carrega
  79. O arquivo 'npc/scripts_main.conf' que contém referências a outros
  80. arquivos. Os scripts reais são carregados a partir de arquivos txt, que são ligados para cima
  81. como isso:
  82.  
  83. npc: <Caminho para um nome de arquivo>
  84.  
  85. Any line like this, invoked, ultimately, by 'map-server.conf' will load up
  86. the script contained in this file, which will make the script available.
  87. No file will get loaded twice, to prevent possible errors.
  88.  
  89. Another configuration file option of relevance is:
  90.  
  91. delnpc: <Caminho para um nome de arquivo>
  92.  
  93. Isso descarregará um nome de arquivo de script especificado da memória, que, enquanto
  94. Aparentemente inútil, às vezes pode ser necessário.
  95.  
  96. Sempre que '//' é encontrado em uma linha na leitura, tudo além
  97. Esta linha é considerada um comentário e é ignorada. Isso funciona
  98. Onde quer que você o coloque.
  99.  
  100. // Esta linha será ignorada ao processar o script.
  101.  
  102. Bloquear comentários também podem ser usados, onde você pode colocar / * e * / entre qualquer
  103. Texto que você deseja que Cronus ignore.
  104.  
  105. Exemplo:
  106. /* Esse texto,
  107.   * Não importa qual nova linha você começa
  108.   * É ignorado, até que o seguinte
  109.   * É encontrado: * /
  110.  
  111. Os asteriscos (*) na frente de cada linha são uma preferência pessoal, e é
  112. não requerido.
  113.  
  114. Ao carregar todos os arquivos, o servidor executará todos os
  115. Comandos neles. Ainda não existem variáveis neste momento, nenhum comando pode ser
  116. Chamados outros que não os indicados nesta seção. Esses comandos configuram o
  117. Estrutura básica do script do servidor - criar objetos NPC, spawn monster objects,
  118. Set map flags, etc. Nenhum código é realmente executado neste ponto, exceto
  119. eles. Os comandos de nível superior que os scripts são bastante confusos,
  120. Eles não são estruturados como você esperaria comandos, nome de comando primeiro,
  121. Mas sim, normalmente começam com um nome de mapa.
  122.  
  123. O que é mais confuso sobre os comandos de nível superior é que a maioria deles
  124. Use um símbolo de tabulação para dividir seus argumentos.
  125.  
  126. Para evitar problemas e confusão, os símbolos de tabulação são escritos como '% TAB%'
  127. Ou '<TAB>' ao longo deste documento, mesmo que isso torne o texto um pouco
  128. Menos legível. Usar um símbolo invisível para denotar argumentos é um dos
  129. Coisas ruins sobre esse idioma, mas estamos presos com ele por enquanto. :)
  130.  
  131. Aqui está uma lista de comandos de nível superior válidos:
  132.  
  133. ** Definir um map flag:
  134.  
  135. <nome do mapa>%TAB%mapflag%TAB%<flag>
  136.  
  137. Isto irá, ao carregar, definir uma bandeira de mapa especificada em um mapa que você gosta. Estes
  138. Normalmente dentro de arquivos dentro do 'npc/mapflag' e são carregados primeiro, então pelo
  139. Tempo o servidor é para cima, todos os mapas têm as bandeiras que devem ter. Mapa
  140. As bandeiras determinam o comportamento do mapa em relação a vários problemas comuns,
  141. Para uma explicação melhor, veja 'setmapflag'.
  142.  
  143. ** Criar um spawn de monstros permanentes:
  144.  
  145. <nome do mapa>,<x>,<y>,<xs>,<ys>%TAB%monster%TAB%<monstro nome>%TAB%<monstro id>,<quantidade>,<delay1>,<delay2>,<event>{,<tamanho>,<mob ai>}
  146.  
  147. Nome do mapa é o nome do mapa que os monstros irão desovar. X, Y são os
  148. Coordena onde o mob deve spawn. Se X e Y são não-zero, eles
  149. Especifique o "raio" de uma área de retângulo de spawn centrada em x, y. Colocação
  150. Zeros em vez destas coordenadas gerarão os monstros aleatoriamente. Nota
  151. Esta é apenas a zona de desova inicial, como mobs random-walk, eles são livres para
  152. Afastar-se de sua região especificada spawn.
  153.  
  154. Nome do monstro é o nome que os monstros terão na tela e não tem
  155. Relação a seus nomes em qualquer outro lugar. É o identificador da turma que
  156. , Que identifica o registro de monstros no banco de dados "mob_db.txt"
  157. Monstros Se o nome do mob é dado como "--ja--", o campo "nome japonês"
  158. Do banco de dados de monstro é usado, (que, em Cronus, realmente contém
  159. Um nome em inglês) se for "--en--", é o "nome inglês" do
  160. Monstro (que contém um nome maiúsculo usado para invocar o
  161. Monstro com um comando GM).
  162.  
  163. Quantidade é a quantidade de monstros que serão gerados quando este comando é
  164. Executada, ela é afetada pelas taxas de spawn em 'battle.conf'.
  165.  
  166. Delay1 e delay2 controlam os atrasos do respawn do monstro - o primeiro é o
  167. Tempo de respawn da base fixa, ea segunda é variância aleatória em cima da
  168. Base. Ambos os valores são dados em milissegundos (1000 = 1 segundo). Nota
  169. Que o servidor também impõe um mínimo respawn atraso de 5 segundos.
  170.  
  171. Você pode especificar um nível personalizado para usar para o mob diferente do
  172. Do banco de dados adjacente ao nível após o nome com uma vírgula. por exemplo:
  173. "Poring, 50" para um nome irá gerar um monstro com o nome Poring e nível 50.
  174.  
  175. Evento é um evento de script a ser executado quando a máfia é morta. O evento
  176. Deve estar na forma "NPCName::OnEventName" para executar e o nome do evento
  177. Deve começar com "On". Como com todos os eventos, se o NPC é um
  178. On-touch NPC, o jogador que aciona o script deve estar dentro de 'trigger'
  179. Para que o evento funcione.
  180.  
  181. Existem dois campos opcionais para tamanho de monstro e AI. O tamanho pode ser 0
  182. (Médio), 1 (pequeno) ou 2 (grande). AI pode ser 0 (padrão), 1
  183. (Ataque / amigável), 2 (esfera), 3 (flora), ou 4 (zanzou).
  184.  
  185. Alternativamente, um monstro gerado usando 'boss_monster' em vez de 'monster' pode ser
  186. Detectado no mapa com o status SC_CASH_BOSS_ALARM (usado pelo Espelho Convexo, item ID # 12214).
  187.  
  188. ** Nomes NPC
  189.  
  190. /!\ AVISO: isto aplica-se a warps, NPCs, duplicatas e lojas /!\
  191.  
  192. Nomes de NPC são um pouco especiais e são formatados desta forma:
  193.  
  194. <Nome de exibição>{::<Nome exclusivo>}
  195.  
  196. Todos os NPCs precisam ter um nome exclusivo que seja usado para identificação
  197. Finalidades. Quando você tem que identificar um NPC pelo seu nome, você deve usar
  198. <Nome exclusivo>. Se <Nome exclusivo> não for fornecido, use <Nome de exibição>
  199. ao invés.
  200.  
  201. O cliente tem uma característica especial ao exibir nomes: se o
  202. Nome contém um caractere '#', oculta essa parte do nome.
  203. Ex: se o seu NPC é nomeado 'Hunter#hunter1', ele será exibido como 'Hunter'
  204.  
  205. <Nome de exibição> deve ter no máximo 36 caracteres.
  206. <Nome exclusivo> deve ter no máximo 36 caracteres.
  207.  
  208. ** Criar um portal
  209.  
  210. <from nome do mapa>,<X>,<Y>{,<direção>}%TAB%warp%TAB%<nome>%TAB%<spanx>,<spany>,<para o mapa>,<X>,<Y>
  211.  
  212. Isto irá definir um warp NPC que irá deformar um jogador entre mapas, e
  213. Enquanto a maioria dos argumentos disso são óbvios, alguns merecem menção especial.
  214.  
  215. SpanX e SpanY tornarão a deformação sensível a um personagem que não
  216. Passo diretamente sobre ele, mas entrou em uma zona que é centrada na urdidura
  217. A partir de coordenadas e é SpanX em cada direção ao longo do eixo X e
  218. SpanY em cada sentido através do eixo Y.
  219.  
  220. Warp NPC objetos também têm um nome, porque você pode usá-lo para se referir a eles
  221. Mais tarde com 'enablenpc' / 'disablenpc'.
  222.  
  223. Enfrentar um objeto warp é irrelevante, não é usado no código e todos
  224. Os scripts atuais têm um zero lá.
  225.  
  226. ** Defina um objeto NPC.
  227.  
  228. <nome do mapa>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Nome>%TAB%<sprite>,{<code>}
  229. <nome do mapa>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Nome>%TAB%<sprite>,<triggerX>,<triggerY>,{<code>}
  230.  
  231. Isso colocará um objeto NPC em um mapa especificado na
  232. Local, e é um comando de nível superior que você usará mais no seu
  233. Scripting Os NPCs são acionados clicando neles, e / ou caminhando
  234. Na sua área de disparo, se definido. Veja abaixo.
  235.  
  236. Enfrentar é uma direção que o sprite NPC enfrentará. Nem todos os sprites NPC
  237. Imagens diferentes dependendo da direção em que você olha, então para
  238. Alguns enfrentamentos não terão sentido. Os revestimentos são contados no sentido anti-horário em
  239. Incrementos de 45 graus, onde 0 significa virado para o topo do mapa.
  240. (Então, para transformar o sprite na parte inferior do mapa, você usa o rosto 4,
  241. E para fazê-la olhar para o sudeste está enfrentando 5.)
  242.  
  243. Sprite é o identificador de sprite usado para exibir esse NPC específico. Para um
  244. Lista completa de números de sprite veja http://kalen.s79.xrea.com/npc/npce.shtml como
  245. Bem como db / const.txt.
  246. Você também pode usar a constante de identificação de um monstro em vez disso para exibir um sprite monstro
  247. Para este NPC, em npcs que têm ids de vista de mobs é encorajado a usar
  248. OnTouch eventos com um intervalo de 2,2 e com um 'fim' após o cabeçalho para evitar
  249. Bugs (para mais informações sobre porquê ver npc_click@map/npc.c). É possível usar um trabalho
  250. Sprite também, mas você deve primeiro defini-lo como um sprite monstro em 'mob_avail.txt',
  251. Uma descrição completa sobre como fazer isso não está no escopo deste manual.
  252. Um '-1' sprite fará o NPC invisível (e unchickable).
  253. Um sprite 'HIDDEN_NPC' fará um NPC que não tenha um sprite, mas é
  254. Ainda é clicável, o que é útil se você quiser fazer um objeto clicável de
  255. O terreno 3D.
  256.  
  257. TriggerX e triggerY, se for dado, definirão uma área, centrada em NPC e
  258. Abrangendo células triggerX em todas as direções em X e triggerY em
  259. Direção em Y. Andando em que área irá acionar o NPC. Se não
  260. 'OnTouch:' etiqueta especial está presente no código NPC, a execução será
  261. Início do script, caso contrário, ele será iniciado a partir do
  262. Etiqueta 'OnTouch:'. Monstros também podem acionar o NPC, embora o rótulo
  263. 'OnTouchNPC:' é usado neste caso. Se a área esquerda do jogador npc for chamada
  264. Se presente etiqueta 'OnUnTouch'.
  265.  
  266. A parte de código é o código de script que será executado sempre que o NPC for
  267. Disparado. Pode conter comandos e chamadas de função, descrições de
  268. Que compõem a maior parte deste documento. Tem de ser em colchetes,
  269. Diferentemente de outros lugares onde usamos chaves, estes NÃO significam
  270. Parâmetro opcional.
  271.  
  272. ** Defina um objeto NPC 'flutuante'.
  273.  
  274. -%TAB%script%TAB%<NPC Name>%TAB%-1,{<code>}
  275.  
  276. Isso irá definir um objeto NPC não disparável por meios normais. Isso seria
  277. Normalmente significa que é inútil uma vez que não pode fazer nada, mas há
  278. Exceções, principalmente relacionadas à execução de scripts em horários
  279. Para que esses objetos NPC flutuantes são. Mais sobre isso abaixo.
  280.  
  281. ** Defina um NPC loja / cashshop.
  282.  
  283. -%TAB%shop%TAB%<NPC Name>%TAB%<sprite>,<itemid>:<price>{,<itemid>:<price>...}
  284. <nome do mapa>,<x>,<y>,<facing>%TAB%shop%TAB%<NPC Name>%TAB%<sprite>,<itemid>:<price>{,<itemid>:<price>...}
  285.  
  286. Isso definirá um NPC de loja, que, quando acionado (que só pode ser feito
  287. Clicando) fará com que uma vitrine apareça. Nenhum código funciona
  288. Na loja NPCs e você não pode alterar os preços de outra forma do que editando o
  289. Próprio script (não existem variáveis mesmo neste ponto de scripting, por isso
  290. Nem sequer se preocupar em tentar usá-los).
  291.  
  292. O item id é o número de item no banco de dados. Se Preço
  293. É definido como -1, o 'preço de compra' dado no banco de dados do item será usado.
  294. Caso contrário, o preço que você deu será usado para este item, que é como você
  295. Criar diferentes preços para os itens em lojas diferentes.
  296.  
  297. Você pode alternativamente usar "cashshop" no lugar de "shop" para usar o Cash
  298. Shop, permitindo que você compre itens com pontos especiais (atualmente
  299. Armazenados como vars de contas em #CASHPOINTS e #KAFRAPOINTS). este
  300. Tipo de loja não lhe permitirá vender itens, você só pode comprar
  301. Itens aqui. O layout usado para definir itens de venda ainda conta, e
  302. "<Preço>" refere-se a quantos pontos serão gastos comprando-os.
  303.  
  304. ** Defina um trader NPC
  305. <nome do mapa>,<x>,<y>,<facing>%TAB%trader%TAB%<NPC Name>%TAB%<sprite>,{<code>}
  306. -%TAB%trader%TAB%<NPC Name>%TAB%-1,{<code>}
  307.  
  308. Todos os padrões que são válidos para objetos de script também são válidos para objetos do comerciante
  309. (Veja ** Definir um objeto NPC para obter mais informações).
  310. Isso definirá um NPC negociador, que pode causar uma loja, cashshop ou janela de mercado
  311. Para aparecer quando clicado ou chamado por outros meios. Ao contrário da loja / cashshop NPCs esta
  312. Tipo irá executar um código e pode alterar os itens que estão sendo vendidos ao longo do tempo sem
  313. Outros objetos NPC.
  314. Os tipos que um objeto trader podem ter são os seguintes:
  315. - NST_ZENY (0) Normal Zeny Loja (loja)
  316. - NST_CASH (1) Loja de dinheiro normal (cashshop)
  317. - NST_MARKET (2) Normal NPC Market Shop (onde os itens têm disponibilidade limitada
  318. E precisam ser reformados)
  319. - NST_CUSTOM (3) Custom Shop (qualquer moeda, item / var / etca, amostra de verificação)
  320. Salvo especificação em contrário via * tradertype, um objeto trader será definido como
  321. NST_ZENY.
  322.  
  323. Nota: NST_MARKET só está disponível com PACKETVER 20131223 ou mais recente.
  324. Consulte '12 - Comandos relacionados ao NPC Trader 'e /doc/sample/npc_trader_sample.txt para
  325. Mais informações sobre como usar este tipo de NPC.
  326.  
  327. ** Defina um warp / shop / cashshop / duplicado NPC.
  328.  
  329. warp: <nome do mapa>,<x>,<y>{,<facing>}%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<spanx>,<spany>
  330. shop/cashshop/npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite>
  331. shop/cashshop/npc: <nome do mapa>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite>
  332. npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite>,<triggerX>,<triggerY>
  333. npc: <nome do mapa>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite>,<triggerX>,<triggerY>
  334.  
  335. Isto duplicará uma warp / shop / cashshop / NPC referida por 'label'.
  336. As duplicatas de distorção herdam a localização de destino.
  337. Os duplicados da loja / caixa de pagamento herdam a lista de itens.
  338. Os duplicados de NPC herdam o código de script.
  339. O restante (nome, localização, face, sprite, área span / trigger) é
  340. Obtido a partir da definição do duplicado (não herdado).
  341.  
  342. ** Define a function object
  343.  
  344. function%TAB%script%TAB%<function name>%TAB%{<code>}
  345.  
  346. This will define a function object, callable with the 'callfunc' command
  347. (see below). This object will load on every map server separately, so you
  348. can get at it from anywhere. It's not possible to call the code in this
  349. object by anything other than the 'callfunc' script command.
  350.  
  351. The code part is the script code that will execute whenever the function
  352. is called with 'callfunc'. It has to be in curly brackets, unlike
  353. elsewhere where we use curly brackets, these do NOT signify an optional
  354. parameter.
  355.  
  356. Once an object is defined which has a 'code' field to it's definition, it
  357. contains script commands which can actually be triggered and executed.
  358.  
  359. ~ RID? GID? ~
  360.  
  361. What a RID is and why do you need to know
  362. -----------------------------------------
  363.  
  364. Most scripting commands and functions will want to request data about a
  365. character, store variables referenced to that character, send stuff to the
  366. client connected to that specific character. Whenever a script is invoked
  367. by a character, it is passed a so-called RID - this is the account ID
  368. number of a character that caused the code to execute by clicking on it,
  369. walking into it's OnTouch zone, or otherwise.
  370.  
  371. If you are only writing common NPCs, you don't need to bother with it.
  372. However, if you use functions, if you use timers, if you use clock-based
  373. script activation, you need to be aware of all cases when a script
  374. execution can be triggered without a RID attached. This will make a lot of
  375. commands and functions unusable, since they want data from a specific
  376. character, want to send stuff to a specific client, want to store
  377. variables specific to that character, and they would not know what
  378. character to work on if there's no RID.
  379.  
  380. Unless you use 'attachrid' to explicitly attach a character to the script
  381. first (see player-related commands).
  382.  
  383. Whenever we say 'invoking character', we mean 'the character who's RID is
  384. attached to the running script. The script function "playerattached" can
  385. be used to check which is the currently attached player to the script (it
  386. will return 0 if the there is no player attached or the attached player no
  387. longer is logged on to the map-server).
  388.  
  389. But what about GID?
  390. --- ---- ----- ----
  391.  
  392. GID stands for the Game ID of something, this can either be the GID of a
  393. mob obtained through the monster script command (if only summoned one),
  394. the GID of a NPC obtained through the getnpcid script command or the
  395. account ID of a character (same as its RID). Another way would be to right
  396. click on a mob, NPC or char as GM sprited char to view its GID.
  397.  
  398. Item and pet scripts
  399. --------------------
  400.  
  401. Each item in the item database has three special fields - Script,
  402. OnEquip_Script and OnUnequip_Script. The first is script code run every
  403. time a character equips the item, with the RID of the equipping character.
  404. Every time they unequip an item, all temporary bonuses given by the script
  405. commands are cleared, and all the scripts are executed once again to
  406. rebuild them. This also happens in several other situations (like upon
  407. login) but the full list is currently unknown.
  408.  
  409. OnEquip_Script is a piece of script code run whenever the item is used by
  410. a character by double-clicking on it. OnUnequip_Script runs whenever the
  411. equipment is unequipped by a character.
  412.  
  413. Not all script commands work properly in the item scripts. Where commands
  414. and functions are known to be meant specifically for use in item scripts,
  415. they are described as such.
  416.  
  417. Every pet in the pet database has a PetScript field, which determines pet
  418. behavior. It is invoked wherever a pet of the specified type is spawned
  419. (hatched from an egg, or loaded from the char server when a character who
  420. had that pet following them connects). This may occur in some other
  421. situations as well. Don't expect anything other than commands definitely
  422. marked as usable in pet scripts to work in there reliably.
  423.  
  424. Numbers
  425. -------
  426.  
  427. Beside the common decimal numbers, which are nothing special whatsoever
  428. (though do not expect to use fractions, since ALL numbers are integer in
  429. this language), the script engine also handles hexadecimal numbers, which
  430. are otherwise identical. Writing a number like '0x<hex digits>' will make
  431. it recognized as a hexadecimal value. Notice that 0x10 is equal to 16.
  432. Also notice that if you try to 'mes 0x10' it will print '16'.
  433.  
  434. Number values can't exceed the limits of an integer variable: Any number
  435. greater than INT_MAX (2147483647) or smaller than INT_MIN (-2147483648) will
  436. be capped to those values and will cause a warning to be reported.
  437.  
  438. Variables
  439. ---------
  440.  
  441. The meat of every programming language is variables - places where you
  442. store data.
  443.  
  444. In Cronus scripting language, variable names are case sensitive. Even though
  445. at the current time the script engine accepts them even with the incorrect
  446. case, it is not advised to rely on this behavior, as it may change at any
  447. time.
  448.  
  449. Variables are divided into and uniquely identified by the combination of:
  450. prefix - determines the scope and extent (or lifetime) of the variable
  451. name - an identifier consisting of '_' and alphanumeric characters
  452. postfix - determines the type of the variable: integer or string
  453.  
  454. Scope can be:
  455. global - global to all servers
  456. local - local to the server
  457. account - attached to the account of the character identified by RID
  458. character - attached to the character identified by RID
  459. npc - attached to the NPC
  460. scope - attached to the scope of the instance
  461.  
  462. Extent can be:
  463. permanent - They still exist when the server resets.
  464. temporary - They cease to exist when the server resets.
  465.  
  466. Prefix: scope and extent
  467. nothing - A permanent variable attached to the character, the default
  468. variable type.
  469. "@" - A temporary variable attached to the character.
  470. They disappear when the character logs out.
  471. "$" - A global permanent variable.
  472. They are stored in database table `mapreg`.
  473. "$@" - A global temporary variable.
  474. They are important for scripts which are called with no RID
  475. attached, that is, not triggered by a specific character object.
  476. "." - A NPC variable.
  477. They exist in the NPC and disappear when the server restarts or
  478. the NPC is reloaded. Can be accessed from inside the NPC or by
  479. calling 'getvariableofnpc'. Function objects can also have
  480. .variables which are accessible from inside the function,
  481. however 'getvariableofnpc' does NOT work on function objects.
  482. ".@" - A scope variable.
  483. They are unique to the character, script and scope. Each script
  484. execution has its own scope that ends when the script ends.
  485. Calling a function with callsub/callfunc starts a new scope,
  486. returning from the function ends it. When a scope ends, its
  487. variables are converted to values ('return .@var;' returns a
  488. value, not a reference).
  489. "'" - An instance variable.
  490. These are used with the instancing system, and are unique to
  491. each instance.
  492. "#" - A permanent local account variable.
  493. "##" - A permanent global account variable stored by the login server.
  494. The only difference you will note from normal # variables is
  495. when you have multiple char-servers connected to the same
  496. login-server. The # variables are unique to each char-server,
  497. while the ## variables are shared by all these char-servers.
  498.  
  499. Postfix: integer or string
  500. nothing - integer variable, can store positive and negative numbers, but
  501. only whole numbers (so don't expect to do any fractional math).
  502. '$' - string variable, can store text.
  503.  
  504. Examples:
  505. name - permanent character integer variable
  506. name$ - permanent character string variable
  507. @name - temporary character integer variable
  508. @name$ - temporary character string variable
  509. $name - permanent global integer variable
  510. $name$ - permanent global string variable
  511. $@name - temporary global integer variable
  512. $@name$ - temporary global string variable
  513. .name - NPC integer variable
  514. .name$ - NPC string variable
  515. .@name - scope integer variable
  516. .@name$ - scope string variable
  517. 'name - instance integer variable
  518. 'name$ - instance string variable
  519. #name - permanent local account integer variable
  520. #name$ - permanent local account string variable
  521. ##name - permanent global account integer variable
  522. ##name$ - permanent global account string variable
  523.  
  524. If a variable was never set, it is considered to equal zero for integer
  525. variables or an empty string ("", nothing between the quotes) for string
  526. variables. Once you set it to that, the variable is as good as forgotten
  527. forever, and no trace remains of it even if it was stored with character
  528. or account data.
  529.  
  530. Some variables are special, that is, they are already defined for you by
  531. the scripting engine. You can see the full list somewhere in
  532. 'db/const.txt', which is a file you should read, since it also allows you
  533. to replace lots of numbered arguments for many commands with easier to
  534. read text. The special variables most commonly used are all permanent
  535. character-based variables:
  536.  
  537. Zeny - Amount of Zeny.
  538. Hp - Current amount of hit points.
  539. MaxHp - Maximum amount of hit points.
  540. Sp - Current spell points.
  541. MaxSp - Maximum amount of spell points.
  542. StatusPoint - Amount of status points remaining.
  543. SkillPoint - Amount of skill points remaining.
  544. BaseLevel - Character's base level.
  545. JobLevel - Character's job level.
  546. BaseExp - Amount of base experience points.
  547. JobExp - Amount of job experience points.
  548. NextBaseExp - Amount of base experience points needed to reach next level.
  549. NextJobExp - Amount of job experience points needed to reach next level.
  550. Weight - Amount of weight the character currently carries.
  551. Display as in Weight/10.
  552. MaxWeight - Maximum weight the character can carry.
  553. Display as in MaxWeight/10.
  554. Sex - 0 if female, 1 if male.
  555. Class - Character's job.
  556. Upper - 0 if the character is normal class, 1 if advanced, 2 if baby.
  557. BaseClass - The character's 1-1 'normal' job, regardless of Upper value.
  558. For example, this will return Job_Acolyte for Acolyte,
  559. Priest/Monk, High Priest/Champion, and Arch Bishop/Sura.
  560. If the character has not reached a 1-1 class, it will return
  561. Job_Novice.
  562. BaseJob - The character's 'normal' job, regardless of Upper value.
  563. For example, this will return Job_Acolyte for Acolyte,
  564. Baby Acolyte, and High Acolyte.
  565. Karma - The character's karma. Karma system is not fully functional,
  566. but this doesn't mean this doesn't work at all. Not tested.
  567. Manner - The character's manner rating. Becomes negative if the
  568. player utters words forbidden through the use of
  569. 'manner.txt' client-side file.
  570.  
  571. While these behave as variables, do not always expect to just set them -
  572. it is not certain whether this will work for all of them. Whenever there
  573. is a command or a function to set something, it's usually preferable to
  574. use that instead. The notable exception is Zeny, which you can and often
  575. will address directly - setting it will make the character own this number
  576. of Zeny. If you try to set Zeny to a negative number, the script will be
  577. terminated with an error.
  578.  
  579. Assigning variables
  580. --------- ---------
  581.  
  582. Variables can be accessed and assigned values directly without the use of
  583. the built-in 'set' function. This means that variables can be accessed and
  584. modified much like other programming languages.
  585.  
  586. .@x = 100;
  587. .@x = .@y = 100;
  588.  
  589. Support for modifying variable values using 'set' is still supported (and
  590. required to exist for this method to work) so previous scripts will
  591. continue working. Its usage, though, is deprecated, and it should never be
  592. used in new scripts unless there are special reasons to do so.
  593.  
  594. When assigning values, all operator methods are supported which exist in
  595. the below 'Operators' section. For instance:
  596.  
  597. .@x += 100;
  598. .@x -= 100;
  599. .@x *= 2;
  600. .@x /= 2;
  601. .@x %= 5;
  602. .@x >>= 2;
  603. .@x <<= 2;
  604.  
  605. Will all work. For more information on available operators, see the
  606. Operators section described below. All operators listed there may be
  607. placed in-front of the '=' sign when modifying variables to perform the
  608. action as required.
  609.  
  610. Increment and decrement operators are also provided, for your convenience.
  611. Pre-increment and pre-decrement operators:
  612.  
  613. ++.@x; // same as .@x = .@x + 1
  614. --.@x; // same as .@x = .@x - 1
  615.  
  616. Post-increment and post-decrement operators:
  617.  
  618. .@x++; // similar to .@x = .@x + 1
  619. .@x--; // similar to .@x = .@x - 1
  620.  
  621. The difference between pre- and post- increment/decrement operators is that,
  622. when used in an expression, the pre- ones will be executed before evaluating
  623. the expression, while the post- ones will be executed after. For example:
  624.  
  625. .@x = 1;
  626. .@y = ++.@x; // After this line is executed, both .@y and .@x will be 2
  627. .@x = 1;
  628. .@y = .@x++; // After this line is executed, .@y will be 1, .@x will be 2
  629.  
  630. Note: The pre-increment/pre-decrement operators are, by design, faster (or at
  631. least not slower) than their respective post- equivalent.
  632.  
  633. Note:
  634.  
  635. !! Currently the scripting engine does not support directly copying array
  636. !! variables. In order to copy arrays between variables the use of
  637. !! 'copyarray' function is still required.
  638.  
  639. Strings
  640. -------
  641.  
  642. Strings are enclosed in "double quotes". To include the literal double
  643. quote symbol (") "in a string you need to escape it with a blackslash:
  644.  
  645. .@string$ = "This string contains some \"double quote\" symbols";
  646.  
  647. Arrays
  648. ------
  649.  
  650. Arrays (in Cronus at least) are essentially a set of variables going
  651. under the same name. You can tell between the specific variables of an
  652. array with an 'array index', a number of a variable in that array:
  653.  
  654. <variable name>[<array index>]
  655.  
  656. All variable types can be used as arrays.
  657.  
  658. Variables stored in this way, inside an array, are also called 'array
  659. elements'. Arrays are specifically useful for storing a set of similar
  660. data (like several item IDs for example) and then looping through it. You
  661. can address any array variable as if it was a normal variable:
  662.  
  663. .@arrayofnumbers[0] = 1;
  664.  
  665. You can use a variable (or an expression, or even a value from an another
  666. array) as array index:
  667.  
  668. .@x = 100;
  669. .@arrayofnumbers[.@x] = 10;
  670.  
  671. This will make .@arrayofnumbers[100] equal to 10.
  672.  
  673. Index numbering always starts with 0 and arrays can hold over 2 billion
  674. variables. As such, the (guaranteed) allowed values for indices are in the
  675. range 0 ~ 2147483647.
  676.  
  677. If the array index is omitted, it defaults to zero. Writing
  678. .@arrayofnumbers is perfectly equivalent to writing .@arrayofnumbers[0].
  679.  
  680. Arrays can naturally store strings:
  681.  
  682. .@menulines$[0] is the 0th element of the .@menulines$ array of strings.
  683. Notice the '$', normally denoting a string variable, before the square
  684. brackets that denotes an array index.
  685.  
  686. Variable References
  687. -------------------
  688.  
  689. //##TODO
  690.  
  691. Hard-coded constants
  692. --------------------
  693. Most of the constants defined by the scripting engine can be found in
  694. 'db/const.txt' and have the same value independently of settings that
  695. are core related, but there are constants that can be used to retrieve
  696. core information that's set when the server is compiled.
  697.  
  698. PACKETVER - Server packet version
  699. MAX_LEVEL - Maximum level
  700. MAX_STORAGE - Maximum storage items
  701. MAX_GUILD_STORAGE - Maximum guild storage items
  702. MAX_CART - Maximum cart items
  703. MAX_INVENTORY - Maximum inventory items
  704. MAX_ZENY - Maximum Zeny
  705. MAX_BG_MEMBERS - Maximum BattleGround members
  706. MAX_CHAT_USERS - Maximum Chat users
  707. MAX_REFINE - Maximum Refine level
  708.  
  709. Send targets and status options are also hard-coded and can be found
  710. in src/map/script.c::script_hardcoded_constants or in functions that
  711. currently use them.
  712.  
  713. Operators
  714. ---------
  715.  
  716. Operators are things you can do to variables and numbers. They are either
  717. the common mathematical operations or conditional operators:
  718.  
  719. + - will add two numbers. If you try to add two strings, the result will
  720. be a string glued together at the +. You can add a number to a string,
  721. and the result will be a string. No other math operators work with
  722. strings.
  723. - - will subtract two numbers.
  724. * - will multiply two numbers.
  725. / - will divide two numbers. Note that this is an integer division, i.e.
  726. 7/2 is not equal 3.5, it's equal 3.
  727. % - will give you the remainder of the division. 7%2 is equal to 1.
  728.  
  729. There are also conditional operators. This has to do with the conditional
  730. command 'if' and they are meant to return either 1 if the condition is
  731. satisfied and 0 if it isn't. That's what they call 'boolean' variables. 0
  732. means 'False'. Anything except the zero is 'True'. Odd as it is, -1 and -5
  733. and anything below zero will also be True.)
  734.  
  735. You can compare numbers to each other and you compare strings to each
  736. other, but you can not compare numbers to strings.
  737.  
  738. == - Is true if both sides are equal. For strings, it means they contain
  739. the same value.
  740. >= - True if the first value is equal to, or greater than, the second
  741. value.
  742. <= - True if the first value is equal to, or less than, the second value.
  743. > - True if the first value greater than the second value.
  744. < - True if the first value is less than the second value.
  745. != - True if the first value IS NOT equal to the second one.
  746. ~= - True if the second value (as regular expression) matches the first
  747. value. Both values must be strings. See the script function pcre_match
  748. for more details and advanced features.
  749. ~! - True if the second value (as regular expression) DOES NOT match the
  750. first value. Both values must be strings. See script function pcre_match
  751. for more details and advanced features.
  752.  
  753. Examples:
  754.  
  755. 1==1 is True.
  756. 1<2 is True while 1>2 is False.
  757. .@x>2 is True if .@x is equal to 3. But it isn't true if .@x is 2.
  758.  
  759. Only '==', '!=', '~=' and '~!' have been tested for comparing strings. Since
  760. there's no way to code a seriously complex data structure in this language,
  761. trying to sort strings by alphabet would be pointless anyway.
  762.  
  763. Comparisons can be stacked in the same condition:
  764.  
  765. && - Is True if and only if BOTH sides are true.
  766. ('1==1 && 2==2' is true. '2==1 && 1==1' is false.)
  767. || - Is True if either side of this expression is True.
  768.  
  769. 1==1 && 2==2 is True.
  770. 1==1 && 2==1 is False.
  771. 1==1 || 2==1 is True.
  772.  
  773. Logical bitwise operators work only on numbers, and they are the following:
  774.  
  775. << - Left shift.
  776. >> - Right shift.
  777. Left shift moves the binary 1(s) of a number n positions to the left,
  778. which is the same as multiplying by 2, n times.
  779. In the other hand, Right shift moves the binary 1(s) of a number n
  780. positions to the right, which is the same as dividing by 2, n times.
  781. Example:
  782. b = 2;
  783. a = b << 3;
  784. mes a;
  785. a = a >> 2;
  786. mes a;
  787. The first mes command would display 16, which is the same as:
  788. 2 x (2 x 2 x 2) = 16.
  789. The second mes command would display 4, which is the same as:
  790. 16 / 2 = 8; 8 / 2 = 4.
  791. & - And.
  792. | - Or.
  793. The bitwise operator AND (&) is used to test two values against each
  794. other, and results in setting bits which are active in both arguments.
  795. This can be used for a few things, but in Cronus this operator is
  796. usually used to create bit-masks in scripts.
  797.  
  798. The bitwise operator OR (|) sets to 1 a binary position if the binary
  799. position of one of the numbers is 1. This way a variable can hold
  800. several values we can check, known as bit-mask. A variable currently
  801. can hold up to 32 bit-masks (from position 0 to position 1). This is a
  802. cheap(skate) and easy way to avoid using arrays to store several
  803. checks that a player can have.
  804.  
  805. A bit-mask basically is (ab)using the variables bits to set various
  806. options in one variable. With the current limit in variables it is
  807. possible to store 32 different options in one variable (by using the
  808. bits on position 0 to 31).
  809.  
  810. Example(s):
  811. - Basic example of the & operator, bit example:
  812. 10 & 2 = 2
  813. Why? :
  814. 10 = 2^1 + 2^3 (2 + 8), so in bits, it would be 1010
  815. 2 = 2^1 (2), so in bits (same size) it would be 0010
  816. The & (AND) operator sets bits which are active (1) in both
  817. arguments, so in the example 1010 & 0010, only the 2^1 bit is
  818. active (1) in both. Resulting in the bit 0010, which is 2.
  819. - Basic example of creating and using a bit-mask:
  820. .@options = 2|4|16; // (note: this is the same as 2+4+16, or 22)
  821. if (.@options & 1) mes "Option 1 is activated";
  822. if (.@options & 2) mes "Option 2 is activated";
  823. if (.@options & 4) mes "Option 3 is activated";
  824. if (.@options & 8) mes "Option 4 is activated";
  825. if (.@options & 16) mes "Option 5 is activated";
  826. This would return the messages about option 2, 3 and 5 being shown
  827. (since we've set the 2,4 and 16 bit to 1).
  828. ^ - Xor.
  829. The bitwise operator XOR (eXclusive OR) sets a binary position to 0 if
  830. both numbers have the same value in the said position. On the other
  831. hand, it sets to 1 if they have different values in the said binary
  832. position. This is another way of setting and unsetting bits in
  833. bit-masks.
  834.  
  835. Example:
  836. - First let's set the quests that are currently in progress:
  837. inProgress = 1|8|16; // quest 1,8 and 16 are in progress
  838. - After playing for a bit, the player starts another quest:
  839. if( inProgress&2 == 0 ){
  840. // this will set the bit for quest 2 (inProgress has that bit set to 0)
  841. inProgress = inProgress^2;
  842. mes "Quest 2: find a newbie and be helpful to him for an hour.";
  843. close;
  844. }
  845. - After spending some time reading info on Xor's, the player finally
  846. completes quest 1:
  847. if( inProgress&1 && isComplete ) {
  848. // this will unset the bit for quest 1 (inProgress has that bit set to 1)
  849. inProgress = inProgress^1;
  850. mes "Quest 1 complete!! You unlocked the secrets of the Xor dynasty, use them wisely.";
  851. close;
  852. }
  853.  
  854. Unary operators with only with a single number, which follows the
  855. operator, and are the following:
  856.  
  857. - - Negation.
  858. The sign of the number will be reversed. If the number was positive,
  859. it will become negative and vice versa.
  860.  
  861. Example:
  862. .@myvar = 10;
  863. mes "Negative 10 is "+(-.@myvar);
  864.  
  865. ! - Logical Not.
  866. Reverses the boolean result of an expression. True will become false
  867. and false will become true.
  868.  
  869. Example:
  870. if(!callfunc("F_dosomething")) {
  871. mes "Doing something failed.";
  872. close;
  873. }
  874.  
  875. ~ - Bitwise Not.
  876. Reverses each bit in a number, also known as one's complement. Cleared
  877. bits are set, and set bits are cleared.
  878.  
  879. Example:
  880. - Ensure, that quest 2 is disabled, while keeping all other active, if
  881. they are.
  882. inProgress = inProgress&(~2);
  883. // same as set inProgress,inProgress&0xfffffffd
  884.  
  885. Ternary operators take three expressions (numbers, strings or boolean),
  886. and are the following:
  887.  
  888. ?: - Conditional operator
  889. Very useful e.g. to replace
  890.  
  891. if(Sex) mes "..."; else mes "...";
  892.  
  893. clauses with simple
  894.  
  895. mes "Welcome, " + (Sex?"Mr.":"Mrs.") + " " + strcharinfo(0);
  896.  
  897. or to replace any other simple if-else clauses. It might be worth
  898. mentioning that ?: has low priority and has to be enclosed with
  899. parenthesis in most (if not all) cases.
  900.  
  901. Operator Precedence and Associativity
  902.  
  903. Operator precedence and associativity work more or less like they do in
  904. mathematics. The rules can be summarized with the following table:
  905.  
  906. Precedence | Description | Associativity
  907. ---------------------------------------------------------------------------
  908. 1 (highest) | [] Array subscripting | None
  909. ---------------------------------------------------------------------------
  910. 2 | ++ Increment | None
  911. | -- Decrement |
  912. ---------------------------------------------------------------------------
  913. 2 | - Unary minus | Right to left
  914. | ! Logical NOT |
  915. | ~ Bitwise NOT (One's Complement) |
  916. ---------------------------------------------------------------------------
  917. 3 | * Multiplication | Left to right
  918. | / Division |
  919. | % Modulo (remainder) |
  920. ---------------------------------------------------------------------------
  921. 4 | + Addition | Left to right
  922. | - Subtraction |
  923. ---------------------------------------------------------------------------
  924. 5 | << Bitwise left shift | Left to right
  925. | >> Bitwise right shift |
  926. ---------------------------------------------------------------------------
  927. 6 | < Less than | Left to right
  928. | <= Less than or equal to |
  929. | > Greater than |
  930. | >= Greater than or equal to |
  931. ---------------------------------------------------------------------------
  932. 7 | == Equal to | Left to right
  933. | != Not equal to |
  934. | ~= Regexp match |
  935. | ~! Regexp non-match |
  936. ---------------------------------------------------------------------------
  937. 8 | & Bitwise AND | Left to right
  938. ---------------------------------------------------------------------------
  939. 9 | ^ Bitwise XOR (exclusive or) | Left to right
  940. ---------------------------------------------------------------------------
  941. 10 | | Bitwise OR (inclusive or) | Left to right
  942. ---------------------------------------------------------------------------
  943. 11 | && Logical AND | Left to right
  944. ---------------------------------------------------------------------------
  945. 12 | || Logical OR | Left to right
  946. ---------------------------------------------------------------------------
  947. 13 | ?: Ternary conditional | Right to left
  948. ---------------------------------------------------------------------------
  949. 14 | = Direct assignment | Right to left
  950. (lowest) | += Assignment by sum |
  951. | -= Assignment by difference |
  952. | *= Assignment by product |
  953. | /= Assignment by quotient |
  954. | %= Assignment by remainder |
  955. | <<= Assignment by bitwise left shift |
  956. | >>= Assignment by bitwise right shift |
  957. | &= Assignment by bitwise AND |
  958. | ^= Assignment by bitwise XOR |
  959. | |= Assignment by bitwise OR |
  960.  
  961. Operator precedence means some operators are evaluated before others. For
  962. example, in 2 + 4 * 5 , the multiplication has higher precedence so 4 * 5 is
  963. evaluated first yielding 2 + 20 == 22 and not 6 * 5 == 30 .
  964.  
  965. Operator associativity defines what happens if a sequence of the same
  966. operators is used one after another: whether the evaluator will evaluate the
  967. left operations first or the right. For example, in 8 - 4 - 2 , subtraction is
  968. left associative so the expression is evaluated left to right. 8 - 4 is
  969. evaluated first making the expression 4 - 2 == 2 and not 8 - 2 == 6 .
  970.  
  971. Labels
  972. ------
  973.  
  974. Within executable script code, some lines can be labels:
  975.  
  976. <label name>:
  977.  
  978. Labels are points of reference in your script, which can be used to route
  979. execution with 'goto' and 'menu' commands, invoked with 'doevent', 'donpcevent'
  980. and 'callsub' commands and are otherwise essential. A label's name may not be
  981. longer than 22 characters. (23rd is the ':'.) There is some confusion in the
  982. source about whether it's 22, 23 or 24 all over the place, so keeping labels
  983. under 22 characters could be wise. It may only contain alphanumeric characters
  984. and underscore. In addition to labels you name yourself, there are also some
  985. special labels which the script engine will start execution from if a special
  986. event happens:
  987.  
  988. OnClock<hour><minute>:
  989. OnMinute<minute>:
  990. OnHour<hour>:
  991. On<weekday><hour><minute>:
  992. OnDay<month><day>:
  993.  
  994. This will execute when the server clock hits the specified date or time.
  995. Hours and minutes are given in military time. ('0105' will mean 01:05 AM).
  996. Weekdays are Sun,Mon,Tue,Wed,Thu,Fri,Sat. Months are 01 to 12, days are 01
  997. to 31. Remember the zero. :)
  998.  
  999. OnInit:
  1000. OnInterIfInit:
  1001. OnInterIfInitOnce:
  1002.  
  1003. OnInit will execute every time the scripts loading is complete, including
  1004. when they are reloaded with @reloadscript command. OnInterIfInit will
  1005. execute when the map server connects to a char server, OnInterIfInitOnce
  1006. will only execute once and will not execute if the map server reconnects
  1007. to the char server later. Note that all those events will be executed upon
  1008. scripts reloading.
  1009.  
  1010. OnAgitStart:
  1011. OnAgitEnd:
  1012. OnAgitInit:
  1013. OnAgitStart2:
  1014. OnAgitEnd2:
  1015. OnAgitInit2:
  1016.  
  1017. OnAgitStart will run whenever the server shifts into WoE mode, whether it
  1018. is done with @agitstart GM command or with 'AgitStart' script command.
  1019. OnAgitEnd will do likewise for the end of WoE.
  1020.  
  1021. OnAgitInit will run when data for all castles and all guilds that hold a
  1022. castle is received by map-server from the char-server after initial
  1023. connect.
  1024.  
  1025. No RID will be attached while any of the above mentioned labels are
  1026. triggered, so no character or account-based variables will be accessible,
  1027. until you attach a RID with 'attachrid' (see below).
  1028.  
  1029. The above also applies to, the last three labels, the only difference is
  1030. that these labels are used exclusively for WoE SE, and are called
  1031. independently.
  1032.  
  1033. OnTouch:
  1034.  
  1035. This label will be executed if a trigger area is defined for the NPC
  1036. object it's in. If it isn't present, the execution will start from the
  1037. beginning of the NPC code. The RID of the triggering character object will
  1038. be attached.
  1039.  
  1040. OnTouch_:
  1041.  
  1042. Similar to OnTouch, but will only run one instance. Another character is
  1043. chosen once the triggering character leaves the area.
  1044.  
  1045. OnUnTouch:
  1046.  
  1047. This label will be executed if plater leave trigger area is defined for the NPC
  1048. object it's in. If it isn't present, nothing will happend.
  1049. The RID of the triggering character object will be attached.
  1050.  
  1051. OnPCLoginEvent:
  1052. OnPCLogoutEvent:
  1053. OnPCBaseLvUpEvent:
  1054. OnPCJobLvUpEvent:
  1055.  
  1056. It's pretty obvious when these four special labels will be invoked.
  1057.  
  1058. OnPCDieEvent:
  1059.  
  1060. This special label triggers when a player dies. The variable 'killerrid'
  1061. is set to the ID of the killer.
  1062.  
  1063. OnPCKillEvent:
  1064.  
  1065. This special label triggers when a player kills another player. The
  1066. variable 'killedrid' is set to the ID of the player killed.
  1067.  
  1068. OnNPCKillEvent:
  1069.  
  1070. This special label triggers when a player kills a monster. The variable
  1071. 'killedrid' is set to the Class of the monster killed.
  1072.  
  1073. OnPCLoadMapEvent:
  1074.  
  1075. This special label will trigger once a player steps in a map marked with
  1076. the 'loadevent' mapflag and attach its RID. The fact that this label
  1077. requires a mapflag for it to work is because, otherwise, it'd be
  1078. server-wide and trigger every time a player would change maps. Imagine the
  1079. server load with 1,000 players (oh the pain...)
  1080.  
  1081. Only the special labels which are not associated with any script command
  1082. are listed here. There are other kinds of labels which may be triggered in
  1083. a similar manner, but they are described with their associated commands.
  1084.  
  1085. OnCountFunds:
  1086.  
  1087. This special label is triggered when a player opens a trader NPC object that
  1088. is NST_CUSTOM. It is used to define different currency types to the trader via
  1089. *setcurrency. Should be used along with OnPayFunds, see /doc/sample/npc_trader_sample.txt
  1090. for more information.
  1091.  
  1092. OnPayFunds:
  1093.  
  1094. This special label is triggered when a purchase is made on a trader NPC object
  1095. that is NST_CUSTOM. Receives @price, total cost and @points, secondary input
  1096. field for cash windows. It is used to remove items that are set as currency.
  1097. Should be used along with OnCountFunds, see /doc/sample/npc_trader_sample.txt
  1098. for more information.
  1099.  
  1100. On<label name>:
  1101.  
  1102. These special labels are used with Mob scripts mostly, and script commands
  1103. that requires you to point/link a command to a mob or another NPC, giving
  1104. a label name to start from. The label name can be any of your liking, but
  1105. must be started with "On".
  1106.  
  1107. Example:
  1108.  
  1109. monster "prontera",123,42,"Poringz0rd",2341,23,"Master::OnThisMobDeath";
  1110.  
  1111. amatsu,13,152,4 script Master 767,{
  1112. mes "Hi there";
  1113. close;
  1114.  
  1115. OnThisMobDeath:
  1116. announce "Hey, "+strcharinfo(0)+" just killed a Poringz0rd!",bc_blue|bc_all;
  1117. end;
  1118. }
  1119.  
  1120. Each time you kill one, that announce will appear in blue to everyone.
  1121.  
  1122. "Global" labels
  1123.  
  1124. There's a catch with labels and doevent. If you call a label (using
  1125. doevent) and called label is in NPC that has trigger area, that label must
  1126. end with "Global" to work globally (i.e. if RID is outside of the trigger
  1127. area, which usually happens since otherwise there would be no point
  1128. calling the label with doevent, because OnTouch would do the job). For
  1129. further reference look for npc_event in npc.c.
  1130.  
  1131. Scripting commands and functions
  1132. --------------------------------
  1133.  
  1134. The commands and functions are listed here in no particular order. There's
  1135. a difference between commands and functions - commands leave no 'return
  1136. value' which might be used in a conditional statement, as a command
  1137. argument, or stored in a variable. Calling commands as if they were
  1138. functions will sometimes work, but is not advised, as this can lead to
  1139. some hard to track errors. Calling functions as if they were commands will
  1140. mess up the stack, so 'return' command will not return correctly after
  1141. this happens in a particular script.
  1142.  
  1143. All commands must end with a ';'. Actually, you may expect to have
  1144. multiple commands on one line if you properly terminate them with a ';',
  1145. but it's better if you don't, since it is not certain just whether the
  1146. scripting engine will behave nicely if you do.
  1147.  
  1148. Please note that command and function names are case sensitive.
  1149.  
  1150. -------------------------
  1151.  
  1152.  
  1153. From here on, we will have the commands sorted as followed:
  1154.  
  1155. 1 - Basic Commands
  1156. 2 - Information-Retrieving Commands
  1157. -- 2.1 - Item-Related Commands
  1158. -- 2.2 - Guild-Related Commands
  1159. 3 - Checking Commands
  1160. -- 3.1 - Checking Item-Related Commands
  1161. 4 - Player-Related Commands
  1162. -- 4.1 - Player Item-Related Commands
  1163. -- 4.2 - Guild-Related Commands
  1164. -- 4.3 - Marriage-Related Commands
  1165. 5 - Mob / NPC Related commands
  1166. -- 5.1 - Time-Related Commands
  1167. -- 5.2 - Guild-Related Commands
  1168. 6 - Other Commands
  1169. 7 - Instance-Related Commands
  1170. 8 - Quest Log Commands
  1171. 9 - Battleground Commands
  1172. 10 - Mercenary Commands
  1173. 11 - Queue Commands
  1174. 12 - NPC Trader Commands
  1175.  
  1176.  
  1177. ---------------------------------------
  1178. //=====================================
  1179. 1 - Basic Commands
  1180. //=====================================
  1181. ---------------------------------------
  1182.  
  1183. *mes "<string>"{,"<string>"..."<string>"};
  1184.  
  1185. This command will displays a box on the screen for the invoking character,
  1186. if no such box is displayed already, and will print the string specified
  1187. into that box. There is normally no 'close' or 'next' button on this box,
  1188. unless you create one with 'close' or 'next', and while it's open the
  1189. player can't do much else, so it's important to create a button later. If
  1190. the string is empty, it will show up as an empty line.
  1191.  
  1192. mes "Text that will appear in the box";
  1193.  
  1194. Inside the string you may put color codes, which will alter the color of
  1195. the text printed after them. The color codes are all '^<R><G><B>' and
  1196. contain three hexadecimal numbers representing colors as if they were HTML
  1197. colors - ^FF0000 is bright red, ^00FF00 is bright green, ^0000FF is bright
  1198. blue, ^000000 is black. ^FF00FF is a pure magenta, but it's also a color
  1199. that is considered transparent whenever the client is drawing windows on
  1200. screen, so printing text in that color will have kind of a weird effect.
  1201. Once you've set a text's color to something, you have to set it back to
  1202. black unless you want all the rest of the text be in that color:
  1203.  
  1204. mes "This is ^FF0000 red ^000000 and this is ^00FF00 green, ^000000 so.";
  1205.  
  1206. Notice that the text coloring is handled purely by the client. If you use
  1207. non-English characters, the color codes might get screwed if they stick to
  1208. letters with no intervening space. Separating them with spaces from the
  1209. letters on either side solves the problem.
  1210.  
  1211. To display multiple lines of message while only using a single mes;
  1212. command, use the script command in the following format:
  1213.  
  1214. mes "Line 1", "Line 2", "Line 3";
  1215.  
  1216. This will display 3 different lines while only consuming a single line in
  1217. the relevant script file.
  1218.  
  1219. If you're using a client from 2011-10-10aRagexe.exe onwards, you can also
  1220. use automatic navigation and open URLs in browser by using some HTML-like
  1221. labels. For example:
  1222.  
  1223. mes "go to <NAVI>[Hat Maker]<INFO>izlude,131,148,</INFO></NAVI> to make hats";
  1224.  
  1225. Will make the [Hat Maker] text clickable in the client and start a navigation
  1226. to that point.
  1227.  
  1228. mes "You can <URL>Google<INFO>http://www.google.com/</INFO></URL> anything";
  1229.  
  1230. Clicking Google will open the browser and point to Google website.
  1231.  
  1232. ---------------------------------------
  1233.  
  1234. *next;
  1235.  
  1236. This command will display a 'next' button in the message window for the
  1237. invoking character. Clicking on it will cause the window to clear and
  1238. display a new one. Used to segment NPC-talking, next is often used in
  1239. combination with 'mes' and 'close'.
  1240.  
  1241. If no window is currently on screen, one will be created, but once the
  1242. invoking character clicks on it, a warning is thrown on the server console
  1243. and the script will terminate.
  1244.  
  1245. mes "[Woman]";
  1246. mes "This would appear on the page";
  1247. next;
  1248. // This is needed since it is a new page and the top will now be blank
  1249. mes "[Woman]";
  1250. mes "This would appear on the 2nd page";
  1251.  
  1252. ---------------------------------------
  1253.  
  1254. *close;
  1255.  
  1256. This command will create a 'close' button in the message window for the
  1257. invoking character. If no window is currently on screen, the script
  1258. command 'end;' must be used. This is one of the ways to end a speech from
  1259. an NPC. Once the button is clicked, the NPC script execution will end, and
  1260. the message box will disappear.
  1261.  
  1262. mes "[Woman]";
  1263. mes "I am finished talking to you, click the close button.";
  1264. close;
  1265. mes "This command will not run at all, since the script has ended.";
  1266.  
  1267. ---------------------------------------
  1268.  
  1269. *close2;
  1270.  
  1271. This command will create a 'close' button in the message window for the
  1272. invoking character. WARNING: If no window is currently on screen, the
  1273. script execution will halt indefinitely! See 'close'. There is one
  1274. important difference, though - even though the message box will have
  1275. closed, the script execution will not stop, and commands after 'close2'
  1276. will still run, meaning an 'end' has to be used to stop the script, unless
  1277. you make it stop in some other manner.
  1278.  
  1279. mes "[Woman]";
  1280. mes "I will warp you now.";
  1281. close2;
  1282. warp "place",50,50;
  1283. end;
  1284.  
  1285. Don't expect things to run smoothly if you don't make your scripts 'end'.
  1286.  
  1287. ---------------------------------------
  1288.  
  1289. *end;
  1290.  
  1291. This command will stop the execution for this particular script.
  1292. It is required for any script not using 'mes'.
  1293.  
  1294. if (BaseLevel <= 10) {
  1295. npctalk "Look at that you are still a n00b";
  1296. end;
  1297. }
  1298. if (BaseLevel <= 20) {
  1299. npctalk "Look at that you are getting better, but still a n00b";
  1300. end;
  1301. }
  1302. if (BaseLevel <= 30) {
  1303. npctalk "Look at that you are getting there, you are almost 2nd profession now right???";
  1304. end;
  1305. }
  1306. if (BaseLevel <= 40) {
  1307. npctalk "Look at that you are almost 2nd profession";
  1308. end;
  1309. }
  1310.  
  1311. Without the use of 'end' it would travel through the ifs until the end
  1312. of the script. If you were lvl 10 or less, you would see all the speech
  1313. lines, the use of 'end' stops this, and ends the script.
  1314.  
  1315. ---------------------------------------
  1316.  
  1317. *set <variable>,<expression>;
  1318. *set(<variable>,<expression>)
  1319.  
  1320. This command will set a variable to the value that the expression results
  1321. in. This isn't the only way to set a variable directly: you can set them
  1322. much like any other programming language as stated before (refer to the
  1323. 'Assigning variables' section).
  1324.  
  1325. This command is deprecated and it shouldn't be used in new scripts, except
  1326. some special cases (mostly, set getvariableofnpc). Use direct value
  1327. assignment instead.
  1328.  
  1329. ---------------------------------------
  1330.  
  1331. *setd "<variable name>",<value>;
  1332.  
  1333. Works almost identically as set, except the variable name is identified as
  1334. a string and can thus be constructed dynamically.
  1335.  
  1336. This command is equivalent to:
  1337. set getd("variable name"),<value>;
  1338.  
  1339. Examples:
  1340.  
  1341. setd ".@var$", "Poporing";
  1342. mes .@var$; // Displays "Poporing".
  1343.  
  1344. setd ".@" + .@var$ + "123$", "Poporing is cool";
  1345. mes .@Poporing123$; // Displays "Poporing is cool".
  1346.  
  1347. ---------------------------------------
  1348.  
  1349. *getd("<variable name>")
  1350.  
  1351. Returns a reference to a variable, the name can be constructed dynamically.
  1352. Refer to 'setd' for usage.
  1353.  
  1354. This can also be used to set an array dynamically:
  1355. setarray getd(".array[0]"), 1, 2, 3, 4, 5;
  1356.  
  1357. Examples:
  1358.  
  1359. mes "The value of $varReference is: " + getd("$varRefence");
  1360. set .@i, getd("$" + "pikachu");
  1361.  
  1362. ---------------------------------------
  1363.  
  1364. *getvariableofnpc(<variable>,"<npc name>")
  1365.  
  1366. Returns a reference to a NPC variable (. prefix) from the target NPC.
  1367. This can only be used to get . variables.
  1368.  
  1369. Examples:
  1370.  
  1371. //This will return the value of .var, note that this can't be used, since
  1372. //the value isn't caught.
  1373. getvariableofnpc(.var,"TargetNPC");
  1374.  
  1375. //This will set the .v variable to the value of the TargetNPC's .var
  1376. //variable.
  1377. .v = getvariableofnpc(.var,"TargetNPC");
  1378.  
  1379. //This will set the .var variable of TargetNPC to 1.
  1380. set getvariableofnpc(.var,"TargetNPC"), 1;
  1381.  
  1382. Note: even though function objects can have .variables, getvariableofnpc
  1383. will not work on them.
  1384.  
  1385. ---------------------------------------
  1386.  
  1387. *goto <label>;
  1388.  
  1389. This command will make the script jump to a label, usually used in
  1390. conjunction with other command, such as "if", but often used on it's own.
  1391.  
  1392. ...
  1393. goto Label;
  1394. mes "This will not be seen";
  1395. Label:
  1396. mes "This will be seen";
  1397.  
  1398. Gotos are considered to be harmful and should be avoided whenever possible.
  1399.  
  1400. ---------------------------------------
  1401.  
  1402. *menu "<option_text>",<target_label>{,"<option_text>",<target_label>,...};
  1403.  
  1404. This command will create a selectable menu for the invoking character.
  1405. Only one menu can be on screen at the same time.
  1406.  
  1407. Depending on what the player picks from the menu, the script execution
  1408. will continue from the corresponding label. It's string-label pairs, not
  1409. label-string.
  1410.  
  1411. This command is deprecated and it should not be used in new scripts, as it
  1412. is likely to be removed at a later time. Please consider using select() or
  1413. prompt() instead.
  1414.  
  1415. Options can be grouped together, separated by the character ':'.
  1416.  
  1417. menu "A:B",L_Wrong,"C",L_Right;
  1418.  
  1419. It also sets a special temporary character variable @menu, which contains
  1420. the number of option the player picked. Numbering of options starts at 1.
  1421. This number is consistent with empty options and grouped options.
  1422.  
  1423. menu "A::B",L_Wrong,"",L_Impossible,"C",L_Right;
  1424. L_Wrong:
  1425. // If they click "A" or "B" they will end up here
  1426. // @menu == 1 if "A"
  1427. // @menu == 2 will never happen because the option is empty
  1428. // @menu == 3 if "B"
  1429. L_Impossible:
  1430. // Empty options are not displayed and therefore can't be selected
  1431. // this label will never be reached from the menu command
  1432. L_Right:
  1433. // If they click "C" they will end up here
  1434. // @menu == 5
  1435.  
  1436. If a label is '-', the script execution will continue right after the menu
  1437. command if that option is selected, this can be used to save you time, and
  1438. optimize big scripts.
  1439.  
  1440. menu "A::B:",-,"C",L_Right;
  1441. // If they click "A" or "B" they will end up here
  1442. // @menu == 1 if "A"
  1443. // @menu == 3 if "B"
  1444. L_Right:
  1445. // If they click "C" they will end up here
  1446. // @menu == 5
  1447.  
  1448. Both these examples will perform the exact same task.
  1449.  
  1450. If you give an empty string as a menu item, the item will not display.
  1451. This can effectively be used to script dynamic menus by using empty string
  1452. for entries that should be unavailable at that time.
  1453.  
  1454. You can do it by using arrays, but watch carefully - this trick isn't high
  1455. wizardry, but minor magic at least. You can't expect to easily duplicate
  1456. it until you understand how it works.
  1457.  
  1458. Create a temporary array of strings to contain your menu items, and
  1459. populate it with the strings that should go into the menu at this
  1460. execution, making sure not to leave any gaps. Normally, you do it with a
  1461. loop and an extra counter, like this:
  1462.  
  1463. setarray .@possiblemenuitems$[0],<list of potential menu items>;
  1464. .@j = 0; // That's the menu lines counter.
  1465.  
  1466. // We loop through the list of possible menu items.
  1467. // .@i is our loop counter.
  1468. for (.@i = 0; .@i < getarraysize(.@possiblemenuitems$); ++.@i) {
  1469. // That 'condition' is whatever condition that determines whether
  1470. // a menu item number .@i actually goes into the menu or not.
  1471.  
  1472. if (<condition>)
  1473. {
  1474. // We record the option into the list of options actually
  1475. // available.
  1476.  
  1477. set .@menulist$[.@j],.@possiblemenuitems$[.@i];
  1478.  
  1479. // We just copied the string, we do need it's number for later
  1480. // though, so we record it as well.
  1481.  
  1482. set .@menureference[.@j],.@i;
  1483.  
  1484. // Since we've just added a menu item into the list, we
  1485. // increment the menu lines counter.
  1486.  
  1487. ++.@j;
  1488. }
  1489.  
  1490. // We go on to the next possible menu item.
  1491. }
  1492.  
  1493. This will create you an array .@menulist$ which contains the text of all
  1494. items that should actually go into the menu based on your condition, and
  1495. an array .@menureference, which contains their numbers in the list of
  1496. possible menu items. Remember, arrays start with 0. There's less of them
  1497. than the possible menu items you've defined, but the menu command can
  1498. handle the empty lines - only if they are last in the list, and if it's
  1499. made this way, they are. Now comes a dirty trick:
  1500.  
  1501. // X is whatever the most menu items you expect to handle.
  1502. menu .@menulist$[0],-,.@menulist$[1],-,...,.@menulist$[<X>],-;
  1503.  
  1504. This calls up a menu of all your items. Since you didn't copy some of the
  1505. possible menu items into the list, it's end is empty and so no menu items
  1506. will show up past the end. But this menu call doesn't jump anywhere, it
  1507. just continues execution right after the menu command. (And it's a good
  1508. thing it doesn't, cause you can only explicitly define labels to jump to,
  1509. and how do you know which ones to define if you don't know beforehand
  1510. which options will end up where in your menu?)
  1511. But how do you figure out which option the user picked? Enter the @menu.
  1512.  
  1513. @menu contains the number of option that the user selected from the list,
  1514. starting with 1 for the first option. You know now which option the user
  1515. picked and which number in your real list of possible menu items it
  1516. translated to:
  1517.  
  1518. mes "You selected "+.@possiblemenuitems$[.@menureference[@menu-1]]+"!";
  1519.  
  1520. @menu is the number of option the user picked.
  1521. @menu-1 is the array index for the list of actually used menu items that
  1522. we made.
  1523. .@menureference[@menu-1] is the number of the item in the array of possible
  1524. menu items that we've saved just for this purpose.
  1525.  
  1526. And .@possiblemenuitems$[.@menureference[@menu-1]] is the string that we
  1527. used to display the menu line the user picked. (Yes, it's a handful, but
  1528. it works.)
  1529.  
  1530. You can set up a bunch of 'if (.@menureference[@menu-1]==X) goto Y'
  1531. statements to route your execution based on the line selected and still
  1532. generate a different menu every time, which is handy when you want to, for
  1533. example, make users select items in any specific order before proceeding,
  1534. or make a randomly shuffled menu.
  1535.  
  1536. Kafra code bundled with the standard distribution uses a similar
  1537. array-based menu technique for teleport lists, but it's much simpler and
  1538. doesn't use @menu, probably since that wasn't documented anywhere.
  1539.  
  1540. See also 'select', which is probably better in this particular case.
  1541. Instead of menu, you could use 'select' like this:
  1542.  
  1543. .@dummy = select(.@menulist$[0],.@menulist$[1],...,.@menulist$[<X>]);
  1544.  
  1545. For the purposes of the technique described above these two statements are
  1546. perfectly equivalent.
  1547.  
  1548. ---------------------------------------
  1549.  
  1550. *select("<option>"{,"<option>",...})
  1551. *prompt("<option>"{,"<option>",...})
  1552.  
  1553. This function is a handy replacement for 'menu' that doesn't use a complex
  1554. label structure. It will return the number of menu option picked,
  1555. starting with 1. Like 'menu', it will also set the variable @menu to
  1556. contain the option the user picked.
  1557.  
  1558. if (select("Yes:No") == 1)
  1559. mes "You said yes, I know.";
  1560.  
  1561. And like 'menu', the selected option is consistent with grouped options
  1562. and empty options.
  1563.  
  1564. 'prompt' works almost the same as select, except that when a character
  1565. clicks the Cancel button, this function will return 255 instead.
  1566.  
  1567. ---------------------------------------
  1568.  
  1569. *input(<variable>{,<min>{,<max>}})
  1570.  
  1571. This command will make an input box pop up on the client connected to the
  1572. invoking character, to allow entering of a number or a string. This has
  1573. many uses, one example would be a guessing game, also making use of the
  1574. 'rand' function:
  1575.  
  1576. mes "[Woman]";
  1577. mes "Try and guess the number I am thinking of.";
  1578. mes "The number will be between 1 and 10.";
  1579. next;
  1580. .@number = rand(1,10);
  1581. input .@guess;
  1582. if (.@guess == .@number) {
  1583. mes "[Woman]";
  1584. mes "Well done that was the number I was thinking of";
  1585. close;
  1586. } else {
  1587. mes "[Woman]";
  1588. mes "Sorry, that wasn't the number I was thinking of.";
  1589. close;
  1590. }
  1591.  
  1592. If you give the input command a string variable to put the input in, it
  1593. will allow the player to enter text. Otherwise, only numbers will be
  1594. allowed.
  1595.  
  1596. mes "[Woman]";
  1597. mes "Please say HELLO";
  1598. next;
  1599. input .@var$;
  1600. if (.@var$ == "HELLO") {
  1601. mes "[Woman]";
  1602. mes "Well done you typed it correctly";
  1603. close;
  1604. } else {
  1605. mes "[Woman]";
  1606. mes "Sorry you got it wrong";
  1607. close;
  1608. }
  1609.  
  1610. Normally you may not input a negative number with this command.
  1611. This is done to prevent exploits in badly written scripts, which would let
  1612. people, for example, put negative amounts of Zeny into a bank script and
  1613. receive free Zeny as a result.
  1614.  
  1615. The command has two optional arguments and a return value.
  1616. The default value of 'min' and 'max' can be set with 'input_min_value' and
  1617. 'input_max_value' in script.conf.
  1618. For numeric inputs the value is capped to the range [min,max]. Returns 1
  1619. if the value was higher than 'max', -1 if lower than 'min' and 0 otherwise.
  1620. For string inputs it returns 1 if the string was longer than 'max', -1 is
  1621. shorter than 'min' and 0 otherwise.
  1622.  
  1623. ---------------------------------------
  1624.  
  1625. *callfunc "<function>"{,<argument>,...<argument>};
  1626. *callfunc("<function>"{,<argument>,...<argument>})
  1627.  
  1628. This command lets you call up a function NPC. A function NPC can be called
  1629. from any script on any map server. Using the 'return' command it will come
  1630. back to the place that called it.
  1631.  
  1632. place,50,50,6%TAB%script%TAB%Woman%TAB%115,{
  1633. mes "[Woman]"
  1634. mes "Lets see if you win";
  1635. callfunc "funcNPC";
  1636. mes "Well done you have won";
  1637. close;
  1638. }
  1639. function%TAB%script%TAB%funcNPC%TAB%{
  1640. .@win = rand(2);
  1641. if (.@win == 0)
  1642. return;
  1643. mes "Sorry you lost";
  1644. end;
  1645. }
  1646.  
  1647. You can pass arguments to your function - values telling it what exactly
  1648. to do - which will be available there with getarg() (see 'getarg').
  1649. Notice that returning is not mandatory, you can end execution right there.
  1650.  
  1651. If you want to return a real value from inside your function NPC, it is
  1652. better to write it in the function form, which will also work and will
  1653. make the script generally cleaner:
  1654.  
  1655. place,50,50,6%TAB%script%TAB%Man%TAB%115,{
  1656. mes "[Man]"
  1657. mes "Gimme a number!";
  1658. next;
  1659. input .@number;
  1660. if (callfunc("OddFunc",.@number)) mes "It's Odd!";
  1661. close;
  1662. }
  1663. function%TAB%script%TAB%OddFunc%TAB%{
  1664. if (getarg(0)%2==0) return 0;// it's even
  1665. return 1;// it's odd
  1666. }
  1667.  
  1668. Alternately, user-defined functions may be called directly without the use
  1669. of the 'callfunc' script command.
  1670.  
  1671. function<TAB>script<TAB>SayHello<TAB>{
  1672. mes "Hello " + getarg(0);
  1673. return 0;
  1674. }
  1675.  
  1676. place,50,50,6<TAB>script<TAB>Man<TAB>115,{
  1677. mes "[Man]";
  1678. SayHello strcharinfo(0);
  1679. close;
  1680. }
  1681.  
  1682. Note:
  1683.  
  1684. !! A user-defined function must be declared /before/ a script attempts to
  1685. !! call it. That is to say, any functions should be placed above scripts
  1686. !! or NPCs (or loaded in a separate file first) before attempting to call
  1687. !! them directly.
  1688.  
  1689. ---------------------------------------
  1690.  
  1691. *callsub <label>{,<argument>,...<argument>};
  1692. *callsub(<label>{,<argument>,...<argument>})
  1693.  
  1694. This command will go to a specified label within the current script (do
  1695. NOT use quotes around it) coming in as if it were a 'callfunc' call, and
  1696. pass it arguments given, if any, which can be recovered there with
  1697. 'getarg'. When done there, you should use the 'return' command to go back
  1698. to the point from where this label was called. This is used when there is
  1699. a specific thing the script will do over and over, this lets you use the
  1700. same bit of code as many times as you like, to save space and time,
  1701. without creating extra NPC objects which are needed with 'callfunc'. A
  1702. label is not callable in this manner from another script.
  1703.  
  1704. Example 1: callsub for checking (if checks pass, return to script)
  1705. callsub S_CheckFull, "guild_vs2",50;
  1706. switch( rand(4) ) {
  1707. case 0: warp "guild_vs2",9,50; end;
  1708. case 1: warp "guild_vs2",49,90; end;
  1709. case 2: warp "guild_vs2",90,50; end;
  1710. case 3: warp "guild_vs2",49,9; end;
  1711. }
  1712.  
  1713. ...
  1714.  
  1715. S_CheckFull:
  1716. if (getmapusers(getarg(0)) >= getarg(1)) {
  1717. mes "I'm sorry, this arena is full. Please try again later.";
  1718. close;
  1719. }
  1720. return;
  1721.  
  1722. Example 2: callsub used repeatedly, with different arguments
  1723. // notice how the Zeny check/delete is reused, instead of copy-pasting for
  1724. // every warp.
  1725. switch(select("Abyss Lake:Amatsu Dungeon:Anthell:Ayothaya Dungeon:Beacon Island, Pharos") {
  1726. case 1: callsub S_DunWarp,"hu_fild05",192,207;
  1727. case 2: callsub S_DunWarp,"ama_in02",119,181;
  1728. case 3: callsub S_DunWarp,"moc_fild20",164,145;
  1729. case 4: callsub S_DunWarp,"ayo_fild02",279,150;
  1730. case 5: callsub S_DunWarp,"cmd_fild07",132,125;
  1731. // etc
  1732. }
  1733.  
  1734. ...
  1735.  
  1736. S_DunWarp:
  1737. // getarg(0) = "mapname"
  1738. // getarg(1) = x
  1739. // getarg(2) = y
  1740. if (Zeny >= 100) {
  1741. Zeny -= 100;
  1742. warp getarg(0),getarg(1),getarg(2);
  1743. } else {
  1744. mes "Dungeon warp costs 100 Zeny.";
  1745. }
  1746. close;
  1747.  
  1748. ---------------------------------------
  1749.  
  1750. *getarg(<index>{,<default_value>})
  1751.  
  1752. This function is used when you use the 'callsub' or 'callfunc' commands.
  1753. In the call you can specify variables that will make that call different
  1754. from another one. This function will return an argument the function or
  1755. subroutine was called with, and is the normal way to get them.
  1756. This is another thing that can let you use the same code more than once.
  1757.  
  1758. Argument numbering starts with 0, i.e. the first argument you gave is
  1759. number 0. If no such argument was given, a zero is returned.
  1760.  
  1761. place,50,50,6%TAB%script%TAB%Woman1%TAB%115,{
  1762. mes "[Woman]";
  1763. mes "Lets see if you win";
  1764. callfunc "funcNPC",2;
  1765. mes "Well done you have won";
  1766.  
  1767. ...
  1768.  
  1769. place,52,50,6%TAB%script%TAB%Woman2%TAB%115,{
  1770. mes "[Woman]";
  1771. mes "Lets see if you win";
  1772. callfunc "funcNPC",5;
  1773. mes "Well done you have won";
  1774.  
  1775. ...
  1776.  
  1777. function%TAB%script%TAB%funcNPC%TAB%{
  1778. .@win = rand(getarg(0));
  1779. if(.@win==0) return;
  1780. mes "Sorry you lost";
  1781.  
  1782. "woman1" NPC object calls the funcNPC. The argument it gives in this call
  1783. is stated as 2, so when the random number is generated by the 'rand'
  1784. function, it can only be 0 or 1. Whereas "woman2" gives 5 as the argument
  1785. number 0 when calling the function, so the random number could be 0, 1, 2,
  1786. 3 or 4, this makes "woman2" less likely to say the player won.
  1787.  
  1788. You can pass multiple arguments in a function call:
  1789.  
  1790. callfunc "funcNPC",5,4,3;
  1791.  
  1792. getarg(0) would be 5, getarg(1) would be 4 and getarg(2) would be 3.
  1793.  
  1794. Getarg also has an optional argument:
  1795. If the target argument exists, it is returned.
  1796. Otherwise, if <default_value> is present it is returned instead, if not
  1797. the script terminates immediately.
  1798.  
  1799. In previous example getarg(2,-1) would be 3 and getarg(3,-1) would be -1.
  1800.  
  1801. ---------------------------------------
  1802.  
  1803. *getargcount()
  1804.  
  1805. This function is used when you use the 'callsub' or 'callfunc' commands.
  1806. In the call you can specify arguments. This function will return the
  1807. number of arguments provided.
  1808.  
  1809. Example:
  1810. callfunc "funcNPC",5,4,3;
  1811. ...
  1812. function%TAB%script%TAB%funcNPC%TAB%{
  1813. .@count = getargcount(); // 3
  1814. ...
  1815. }
  1816.  
  1817. ---------------------------------------
  1818.  
  1819. *return {<value>};
  1820.  
  1821. This command causes the script execution to leave previously called
  1822. function with callfunc or script with callsub and return to the location,
  1823. where the call originated from. Optionally a return value can be supplied,
  1824. when the call was done using the function form.
  1825.  
  1826. Using this command outside of functions or scripts referenced by callsub
  1827. will result in error and termination of the script.
  1828.  
  1829. callfunc "<your function>";// when nothing is returned
  1830. <variable> = callfunc("<your function>");
  1831. // when a value is being returned
  1832.  
  1833. ---------------------------------------
  1834.  
  1835. *function <function name>;
  1836. *<function name>{(<argument>,...<argument>)};
  1837. *function <function name> {
  1838. <code>
  1839. }
  1840.  
  1841. This works like callfunc, and is used for cleaner and faster scripting.
  1842. The function must be defined and used within a script, and works like a
  1843. label with arguments.
  1844. Note that the name may only contain alphanumeric characters and underscore.
  1845.  
  1846. Usage:
  1847.  
  1848. 1. Declare the function.
  1849. function <function name>;
  1850. 2. Call the function anywhere within the script.
  1851. It can also return a value when used with parentheses.
  1852. <function name>;
  1853. 3. Define the function within the script.
  1854. <function name> {<code>}
  1855.  
  1856. Example:
  1857.  
  1858. prontera,154,189,4 script Item Seller 767,{
  1859. /* Function declaration */
  1860. function SF_Selling;
  1861.  
  1862. if (Zeny > 50) {
  1863. mes "Welcome!";
  1864. /* Function call */
  1865. SF_Selling;
  1866. }
  1867. else mes "You need 50z, sorry!";
  1868. close;
  1869.  
  1870. /* Function definition */
  1871. function SF_Selling {
  1872. mes "Would you like to buy a phracon for 50z?";
  1873. next;
  1874. if(select("Yes","No, thanks") == 1) {
  1875. Zeny -= 50;
  1876. getitem 1010,1;
  1877. mes "Thank you!";
  1878. }
  1879. return;
  1880. }
  1881. }
  1882.  
  1883. Example with parameters and return value:
  1884.  
  1885. prontera,150,150,0 script TestNPC 123,{
  1886. /* Function declaration */
  1887. function MyAdd;
  1888.  
  1889. mes "Enter two numbers.";
  1890. next;
  1891. input .@a;
  1892. input .@b;
  1893. /* Function call */
  1894. mes .@a+" + "+.@b+" = "+MyAdd(.@a,.@b);
  1895. close;
  1896.  
  1897. /* Function definition */
  1898. function MyAdd {
  1899. return getarg(0)+getarg(1);
  1900. }
  1901. }
  1902.  
  1903.  
  1904. ---------------------------------------
  1905.  
  1906. *is_function("<function name>")
  1907.  
  1908. This command checks whether a function exists.
  1909. It returns 1 if function is found, or 0 if it isn't.
  1910.  
  1911. Example:
  1912.  
  1913. function script try {
  1914. dothat;
  1915. }
  1916.  
  1917. - script test -1,{
  1918. .@try = is_function("try"); // 1
  1919. .@not = is_function("not"); // 0
  1920. }
  1921.  
  1922. ---------------------------------------
  1923.  
  1924. *if (<condition>) <statement>;
  1925.  
  1926. This is the basic conditional statement command, and just about the only
  1927. one available in this scripting language.
  1928.  
  1929. The condition can be any expression. All expressions resulting in a
  1930. non-zero value will be considered True, including negative values. All
  1931. expressions resulting in a zero are false.
  1932.  
  1933. If the expression results in True, the statement will be executed. If it
  1934. isn't true, nothing happens and we move on to the next line of the script.
  1935.  
  1936. if (1) mes "This will always print.";
  1937. if (0) mes "And this will never print.";
  1938. if (5) mes "This will also always print.";
  1939. if (-1) mes "Funny as it is, this will also print just fine.";
  1940.  
  1941. For more information on conditional operators see the operators section
  1942. above.
  1943. Anything that is returned by a function can be used in a condition check
  1944. without bothering to store it in a specific variable:
  1945.  
  1946. if (strcharinfo(0)=="Daniel Jackson") mes "It is true, you are Daniel!";
  1947.  
  1948. More examples of using the 'if' command in the real world:
  1949.  
  1950. Example 1:
  1951.  
  1952. .@var1 = 1;
  1953. input .@var2;
  1954. if (.@var1 == .@var2)
  1955. close;
  1956. mes "Sorry that is wrong";
  1957. close;
  1958.  
  1959. Example 2:
  1960.  
  1961. .@var1 = 1;
  1962. input .@var2;
  1963. if (.@var1 != .@var2)
  1964. mes "Sorry that is wrong";
  1965. close;
  1966.  
  1967. (Notice examples 1 and 2 have the same effect.)
  1968.  
  1969. Example 3:
  1970.  
  1971. ++.@var1;
  1972. mes "[Forgetfull Man]";
  1973. if (.@var == 1) mes "This is the first time you have talked to me";
  1974. if (.@var == 2) mes "This is the second time you have talked to me";
  1975. if (.@var == 3) mes "This is the third time you have talked to me";
  1976. if (.@var == 4) mes "This is the forth time you have talked to me, but I think I am getting amnesia, I have forgotten about you";
  1977. if (.@var == 4) .@var = 0;
  1978. close;
  1979.  
  1980. Example 4:
  1981.  
  1982. mes "[Quest Person]";
  1983. // The (AegisName) constant Apple comes from item_db, it is the item number 512.
  1984. if (countitem(Apple) >= 1) {
  1985. mes "Oh an apple, I didn't want it, I just wanted to see one";
  1986. close;
  1987. }
  1988. mes "Can you please bring me an apple?";
  1989. close;
  1990.  
  1991. Example 5: Using complex conditions.
  1992.  
  1993. mes "[Multi Checker]";
  1994. if ((queststarted == 1) && (countitem(Apple) >= 5)) {
  1995. // Executed only if the quest has been started AND You have 5 apples
  1996. mes "[Multi Checker]";
  1997. mes "Well done you have started the quest of got me 5 apples";
  1998. mes "Thank you";
  1999. queststarted = 0;
  2000. delitem Apple, 5;
  2001. close;
  2002. }
  2003. mes "Please get me 5 apples";
  2004. queststarted = 1;
  2005. close;
  2006.  
  2007. If the condition doesn't meet, it'll do the action following the else.
  2008. We can also group several actions depending on a condition, this way:
  2009.  
  2010. if (<condition) {
  2011. dothis1;
  2012. dothis2;
  2013. dothis3;
  2014. } else {
  2015. dothat1;
  2016. dothat2;
  2017. dothat3;
  2018. dothat4;
  2019. }
  2020.  
  2021. Example 6:
  2022.  
  2023. mes "[Person Checker]";
  2024. if ($name$ == "") {
  2025. mes "Please tell me someone's name";
  2026. next;
  2027. input $name$;
  2028. $name2$ = strcharinfo(0);
  2029. mes "[Person Checker]";
  2030. mes "Thank you";
  2031. close;
  2032. }
  2033. if ($name$ == strcharinfo(0)) {
  2034. mes "You are the person that " +$name2$+ " just mentioned";
  2035. mes "nice to meet you";
  2036. } else {
  2037. mes "You are not the person that " +$name2$+ " mentioned";
  2038. }
  2039. $name$ = "";
  2040. $name2$ = "";
  2041. close;
  2042.  
  2043. See 'strcharinfo' for explanation of what this function does.
  2044.  
  2045. Remember that if you plan to do several actions upon the condition being
  2046. false, and you forget to use the curly braces (the { } ), the second
  2047. action will be executed regardless the output of the condition, unless of
  2048. course, you stop the execution of the script if the condition is true
  2049. (that is, in the first grouping using a return; , and end; or a close; ).
  2050.  
  2051. Also, you can have multiple conditions nested or chained, and don't worry
  2052. about limits as to how many nested if you can have, there is no spoon ;).
  2053.  
  2054. ...
  2055. if (<condition 1>)
  2056. dothis;
  2057. else if (<condition 2>) {
  2058. dotheother;
  2059. do that;
  2060. end;
  2061. } else
  2062. do this;
  2063. ...
  2064.  
  2065. ---------------------------------------
  2066.  
  2067. *while (<condition>) <statement>;
  2068.  
  2069. This is probably the simplest and most frequently used loop structure. The
  2070. 'while' statement can be interpreted as "while <condition> is true,
  2071. perform <statement>". It is a pretest loop, meaning the conditional
  2072. expression is tested before any of the statements in the body of the loop
  2073. are performed. If the condition evaluates to false, the statement(s) in
  2074. the body of the loop is/are never executed. If the condition evaluates to
  2075. true, the statement(s) are executed, then control transfers back to the
  2076. conditional expression, which is reevaluated and the cycle continues.
  2077.  
  2078. Multiple statements can be grouped with { }, curly braces, just like with
  2079. the 'if' statement.
  2080.  
  2081. Example 1:
  2082. while (switch(select("Yes:No") == 2 ))
  2083. mes "You picked no.";
  2084.  
  2085. Example 2: multiple statements
  2086. while (switch(select("Yes:No") == 2 )) {
  2087. mes "Why did you pick no?";
  2088. mes "You should pick yes instead!";
  2089. }
  2090.  
  2091. Example 3: counter-controlled loop
  2092. .@i = 1;
  2093. while (.@i <= 5) {
  2094. mes "This line will print 5 times.";
  2095. ++.@i;
  2096. }
  2097.  
  2098. Example 4: sentinel-controlled loop
  2099. mes "Input 0 to stop";
  2100. input .@num;
  2101. while (.@num != 0) {
  2102. mes "You entered " + .@num;
  2103. input .@num;
  2104. }
  2105. close;
  2106.  
  2107. ---------------------------------------
  2108.  
  2109. *for (<variable initialization>; <condition>; <variable update>) <statement>;
  2110.  
  2111. Another pretest looping structure is the 'for' statement. It is considered
  2112. a specialized form of the 'while' statement, and is usually associated
  2113. with counter-controlled loops. Here are the steps of the 'for' statement:
  2114. the initialize statement is executed first and only once. The condition
  2115. test is performed. When the condition evaluates to false, the rest of the
  2116. for statement is skipped. When the condition evaluates to true, the body
  2117. of the loop is executed, then the update statement is executed (this
  2118. usually involves incrementing a variable). Then the condition is
  2119. reevaluated and the cycle continues.
  2120.  
  2121. Example 1:
  2122. for (.@i = 0; .@i < 5; ++.@i)
  2123. mes "This line will print 5 times.";
  2124.  
  2125. Example 2:
  2126. mes "This will print the numbers 1 - 5.";
  2127. for (.@i = 1; .@i <= 5; ++.@i)
  2128. mes .@i;
  2129.  
  2130. ---------------------------------------
  2131.  
  2132. *do { <statement>; } while (<condition>);
  2133.  
  2134. The 'do...while' is the only post-test loop structure available in this
  2135. script language. With a post-test, the statements are executed once before
  2136. the condition is tested. When the condition is true, the statement(s) are
  2137. repeated. When the condition is false, control is transferred to the
  2138. statement following the 'do...while' loop expression.
  2139.  
  2140. Example 1: sentinel-controlled loop
  2141. mes "This menu will keep appearing until you pick Cancel";
  2142. do {
  2143. .@choice = select("One:Two:Three:Cancel");
  2144. } while (.@choice != 4);
  2145.  
  2146. Example 2: counter-controlled loop
  2147. mes "This will countdown from 10 to 1.";
  2148. .@i = 10;
  2149. do {
  2150. mes .@i--;
  2151. } while (.@i > 0);
  2152.  
  2153. ---------------------------------------
  2154.  
  2155. *freeloop(<toggle>)
  2156.  
  2157. Toggling this to enabled (1) allows the script instance to bypass the
  2158. infinite loop protection, allowing your script to loop as much as it may
  2159. need. Disabling (0) may warn you if an infinite loop is detected if your
  2160. script is looping too many times.
  2161.  
  2162. Please note, once again, that this isn't a solution to all problems, and by
  2163. disabling this protection your Cronus server may become laggy or
  2164. unresponsive if the script it is used in is performing lenghty loop
  2165. operations.
  2166.  
  2167. Example:
  2168. freeloop(1); // enable script to loop freely
  2169.  
  2170. //Be aware with what you do here.
  2171. for (.@i = 0; .@i < .@bigloop; ++.@i) {
  2172. dothis;
  2173. // will sleep the script for 1ms when detect an infinity loop to
  2174. // let Cronus do what it need to do (socket, timer, process,
  2175. // etc.)
  2176. }
  2177.  
  2178. freeloop(0); // disable
  2179.  
  2180. for (.@i = 0; .@i < .@bigloop; ++.@i) {
  2181. dothis;
  2182. // throw an infinity loop error
  2183. }
  2184.  
  2185. ---------------------------------------
  2186.  
  2187. *setarray <array name>[<first value>],<value>{,<value>...<value>};
  2188.  
  2189. This command will allow you to quickly fill up an array in one go. Check
  2190. the Kafra scripts in the distribution to see this used a lot.
  2191.  
  2192. setarray .@array[0], 100, 200, 300, 400, 500, 600;
  2193.  
  2194. The index of the first element of the array to alter can be omitted if
  2195. zero. For example:
  2196.  
  2197. setarray .@array, 200, 200, 200;
  2198. setarray .@array[1], 300, 150;
  2199.  
  2200. will produce:
  2201.  
  2202. .@array[0] = 200
  2203. .@array[1] = 300
  2204. .@array[2] = 150
  2205.  
  2206. ---------------------------------------
  2207.  
  2208. *cleararray <array name>[<first value to alter>],<value>,<number of values to set>;
  2209.  
  2210. This command will change many array values at the same time to the same
  2211. value.
  2212.  
  2213. setarray .@array, 100, 200, 300, 400, 500, 600;
  2214. // This will make all 6 values 0
  2215. cleararray .@array[0], 0, 6;
  2216. // This will make array element 0 change to 245
  2217. cleararray .@array[0], 245, 1;
  2218. // This is equivalent to the above
  2219. cleararray .@array, 245, 1;
  2220. // This will make elements 1 and 2 change to 345
  2221. cleararray .@array[1], 345, 2;
  2222.  
  2223. See 'setarray'.
  2224.  
  2225. ---------------------------------------
  2226.  
  2227. *copyarray <destination array>[<first value>],<source array>[<first value>],<amount of data to copy>;
  2228.  
  2229. This command lets you quickly shuffle a lot of data between arrays, which
  2230. is in some cases invaluable.
  2231.  
  2232. setarray .@array, 100, 200, 300, 400, 500, 600;
  2233. // So we have made .@array[]
  2234. copyarray .@array2[0],.@array[2],2;
  2235.  
  2236. // Now, .@array2[0] will be equal to .@array[2] (300) and
  2237. // .@array2[1] will be equal to .@array[3].
  2238.  
  2239. So using the examples above:
  2240. .@array[0] = 100
  2241. .@array[1] = 200
  2242. .@array[2] = 300
  2243. .@array[3] = 400
  2244. .@array[4] = 500
  2245. .@array[5] = 600
  2246.  
  2247. New Array:
  2248. .@array2[0] = 300
  2249. .@array2[1] = 400
  2250. .@array2[2] = 0
  2251. .@array2[3] = 0
  2252.  
  2253. Notice that .@array[4] and .@array[5] won't be copied to the second array,
  2254. and it will return a 0.
  2255.  
  2256. ---------------------------------------
  2257.  
  2258. *deletearray <array name>[<first value>],<how much to delete>;
  2259.  
  2260. This command will delete a specified number of array elements totally from
  2261. an array, shifting all the elements beyond this towards the beginning.
  2262.  
  2263. // This will delete array element 0, and move all the other array
  2264. // elements up one place.
  2265. deletearray .@array[0],1
  2266.  
  2267. // This would delete array elements numbered 1, 2 and 3, leave element 0
  2268. // in its place, and move the other elements ups, so there are no gaps.
  2269. deletearray .@array[1],3
  2270.  
  2271. If the amount of items to delete is not specified, all elements of the
  2272. array starting from the specified one to the end, are deleted. If no
  2273. starting element is specified either, the the entire array will be
  2274. deleted.
  2275.  
  2276. // This would delete all elements of the array starting from 2, leaving
  2277. // element 0 and 1
  2278. deletearray .@array[2];
  2279.  
  2280. // This would delete all elements of the array
  2281. deletearray .@array;
  2282.  
  2283. ---------------------------------------
  2284. //=====================================
  2285. 1 - End of Basic-Related Commands
  2286. //=====================================
  2287. ---------------------------------------
  2288.  
  2289.  
  2290. ---------------------------------------
  2291. //=====================================
  2292. 2 - Information-retrieving Related Commands
  2293. //=====================================
  2294. ---------------------------------------
  2295.  
  2296. *strcharinfo(<type>)
  2297.  
  2298. This function will return either the name, party name or guild name for
  2299. the invoking character. Whatever it returns is determined by type.
  2300. (0) PC_NAME - Character's name.
  2301. (1) PC_PARTY - The name of the party they're in if any.
  2302. (2) PC_GUILD - The name of the guild they're in if any.
  2303. (3) PC_MAP - The name of the map the character is in.
  2304.  
  2305. If a character is not a member of any party or guild, an empty string will
  2306. be returned when requesting that information.
  2307.  
  2308. Note: Numbers can also be used in <type>, but their usage is disncouraged as
  2309. using only numbers reduces script readability
  2310.  
  2311. ---------------------------------------
  2312.  
  2313. *strnpcinfo(<type>)
  2314.  
  2315. This function will return the various parts of the name of the calling NPC.
  2316. Whatever it returns is determined by type.
  2317.  
  2318. 0 - The NPC's display name (visible#hidden)
  2319. 1 - The visible part of the NPC's display name
  2320. 2 - The hidden part of the NPC's display name
  2321. 3 - The NPC's unique name (::name)
  2322. 4 - The name of the map the NPC is in.
  2323.  
  2324. ---------------------------------------
  2325.  
  2326. *charid2rid(<char id>)
  2327.  
  2328. This function returns the RID of the character with the given character ID.
  2329.  
  2330. If the character is offline or doesn't exist, 0 is returned.
  2331.  
  2332. ---------------------------------------
  2333.  
  2334. *getarraysize(<array name>)
  2335.  
  2336. This function returns highest index of the array that is filled.
  2337. Notice that zeros and empty strings at the end of this array are not
  2338. counted towards this number.
  2339.  
  2340. For example:
  2341.  
  2342. setarray .@array, 100, 200, 300, 400, 500, 600;
  2343. .@arraysize = getarraysize(.@array);
  2344.  
  2345. This will make .@arraysize == 6. But if you try this:
  2346.  
  2347. setarray .@array, 100, 200, 300, 400, 500, 600, 0;
  2348. .@arraysize = getarraysize(.@array);
  2349.  
  2350. .@arraysize will still equal 6, even though you've set 7 values.
  2351.  
  2352. If you do this:
  2353.  
  2354. .@array[1000] = 1;
  2355. .@arraysize = getarraysize(.@array);
  2356.  
  2357. .@arraysize will be 1000, even though only one element has been set.
  2358.  
  2359. ---------------------------------------
  2360.  
  2361. *getelementofarray(<array name>,<index>)
  2362.  
  2363. This command retrieves the value of the element of given array at given
  2364. index. This is equivalent to using:
  2365.  
  2366. <array name>[<index>]
  2367.  
  2368. The reason for this is, that this short form is internally converted into
  2369. a call to getelementofarray, when the script is loaded.
  2370.  
  2371. Also useful when passing arrays to functions or accessing another npc's
  2372. arrays:
  2373. getelementofarray(getarg(0),<index>)
  2374. getelementofarray(getvariableofnpc(.var, "testNPC"),<index>)
  2375.  
  2376. ---------------------------------------
  2377.  
  2378. *readparam(<parameter number>)
  2379.  
  2380. This function will return the basic stats of an invoking character,
  2381. referred to by the parameter number. Instead of a number, you can use a
  2382. parameter name if it is defined in 'db/const.txt'.
  2383.  
  2384. Example parameters:
  2385.  
  2386. StatusPoint, BaseLevel, SkillPoint, Class, Upper, Zeny, Sex, Weight,
  2387. MaxWeight, JobLevel, BaseExp, JobExp, NextBaseExp, NextJobExp, Hp, MaxHp,
  2388. Sp, MaxSp, BaseJob, Karma, Manner, bVit, bDex, bAgi, bStr, bInt, bLuk
  2389.  
  2390. All of these also behave as variables, but don't expect to be able to just
  2391. 'set' them - some will not work for various internal reasons.
  2392.  
  2393. Example 1:
  2394.  
  2395. // Returns how many status points you haven't spent yet.
  2396. mes "Unused status points: "+readparam(9);
  2397.  
  2398. Using this particular information as a function call is not required.
  2399. Typing this will return the same result:
  2400.  
  2401. mes "Unused status points: "+StatusPoint;
  2402.  
  2403. Example 2:
  2404.  
  2405. You can also use this command to get stat values.
  2406.  
  2407. if (readparam(bVit) > 77)
  2408. mes "Only people with over 77 Vit are reading this!";
  2409.  
  2410. Example 3:
  2411.  
  2412. // Display your current weight
  2413. mes "Your current weight is "+( Weight/10 )+"/"+( MaxWeight/10 );
  2414.  
  2415. ---------------------------------------
  2416.  
  2417. *getcharid(<type>{,"<character name>"})
  2418.  
  2419. This function will return a unique ID number of the invoking character,
  2420. or, if a character name is specified, of that player.
  2421.  
  2422. Type is the kind of associated ID number required:
  2423.  
  2424. 0 - Character ID number.
  2425. 1 - Party ID number.
  2426. 2 - Guild ID number.
  2427. 3 - Account ID number.
  2428. 4 - Battle ground ID
  2429.  
  2430. For most purposes other than printing it, a number is better to have than
  2431. a name (people do horrifying things to their character names).
  2432.  
  2433. If the character is not in a party or not in a guild, the function will
  2434. return 0 if guild or party number is requested. If a name is specified and
  2435. the character is not found, 0 is returned.
  2436.  
  2437. If getcharid(0) returns a zero, the script got called not by a character
  2438. and doesn't have an attached RID. Note that this will cause the map server
  2439. to print "player not attached!" error messages, so it is preferred to use
  2440. "playerattached" to check for the character attached to the script.
  2441.  
  2442. if( getcharid(2) == 0 ) mes "Only members of a guild are allowed here!";
  2443.  
  2444. ---------------------------------------
  2445.  
  2446. *getnpcid(<type>{,"<npc name>"});
  2447.  
  2448. Retrieves IDs of the currently invoked NPC. If a unique npc name is given,
  2449. IDs of that NPC are retrieved instead. Type specifies what ID to retrieve
  2450. and can be one of the following:
  2451.  
  2452. 0 - Unit ID (GID)
  2453.  
  2454. If an invalid type is given or the NPC does not exist, 0 is returned.
  2455.  
  2456. ---------------------------------------
  2457.  
  2458. *getchildid()
  2459. *getmotherid()
  2460. *getfatherid()
  2461.  
  2462. These functions return the character ID of the attached player's child,
  2463. mother, mother, or father, respectively. It returns 0 if no ID is found.
  2464.  
  2465. if (getmotherid()) mes "Your mother's ID is: "+getmotherid();
  2466.  
  2467. ---------------------------------------
  2468.  
  2469. *ispartneron()
  2470.  
  2471. This function returns 1 if the invoking character's marriage partner is
  2472. currently online and 0 if they are not or if the character has no partner.
  2473.  
  2474. ---------------------------------------
  2475.  
  2476. *getpartnerid()
  2477.  
  2478. This function returns the character ID of the invoking character's
  2479. marriage partner, if any. If the invoking character is not married, it
  2480. will return 0, which is a quick way to see if they are married:
  2481.  
  2482. if (!getpartnerid()) mes "I'm not going to be your girlfriend!";
  2483. if (getpartnerid()) mes "You're married already!";
  2484.  
  2485. ---------------------------------------
  2486.  
  2487. *getpartyname(<party id>)
  2488.  
  2489. This function will return the name of a party that has the specified ID
  2490. number. If there is no such party ID, "null" will be returned.
  2491.  
  2492. Lets say the ID of a party was saved as a global variable:
  2493.  
  2494. // This would return the name of the party from the ID stored in a
  2495. // variable
  2496. mes "You're in the '"+getpartyname($@var)+"' party, I know!";
  2497.  
  2498. ---------------------------------------
  2499.  
  2500. *getpartymember <party id>{,<type>};
  2501.  
  2502. This command will find all members of a specified party and returns their
  2503. names (or character id or account id depending on the value of "type")
  2504. into an array of temporary global variables. There's actually quite a few
  2505. commands like this which will fill a special variable with data upon
  2506. execution and not do anything else.
  2507.  
  2508. Upon executing this,
  2509.  
  2510. $@partymembername$[] is a global temporary string array which contains all
  2511. the names of these party members.
  2512. (only set when type is 0 or not specified)
  2513.  
  2514. $@partymembercid[] is a global temporary number array which contains the
  2515. character id of these party members.
  2516. (only set when type is 1)
  2517.  
  2518. $@partymemberaid[] is a global temporary number array which contains the
  2519. account id of these party members.
  2520. (only set when type is 2)
  2521.  
  2522. $@partymembercount is the number of party members that were found.
  2523.  
  2524. The party members will (apparently) be found regardless of whether they
  2525. are online or offline. Note that the names come in no particular order.
  2526.  
  2527. Be sure to use $@partymembercount to go through this array, and not
  2528. 'getarraysize', because it is not cleared between runs of 'getpartymember'.
  2529. If someone with 7 party members invokes this script, the array would have
  2530. 7 elements. But if another person calls up the NPC, and he has a party of
  2531. 5, the server will not clear the array for you, overwriting the values
  2532. instead. So in addition to returning the 5 member names, the 6th and 7th
  2533. elements from the last call remain, and you will get 5+2 members, of which
  2534. the last 2 don't belong to the new guy's party. $@partymembercount will
  2535. always contain the correct number, (5) unlike 'getarraysize()' which will
  2536. return 7 in this case.
  2537.  
  2538. Example 1: list party member names
  2539.  
  2540. // get the party member names
  2541. getpartymember getcharid(1),0;
  2542.  
  2543. // It's a good idea to copy the global temporary $@partymember*****
  2544. // variables to your own scope variables because if you have pauses in
  2545. // this script (sleep, sleep2, next, close2, input, menu, select, or
  2546. // prompt), another player could click this NPC, trigger
  2547. // 'getpartymember', and overwrite the $@partymember***** variables.
  2548. .@count = $@partymembercount;
  2549. copyarray .@name$[0], $@partymembername$[0], $@partymembercount;
  2550.  
  2551. // list the party member names
  2552. for (.@i = 0; .@i < .@count; ++.@i) {
  2553. mes (.@i +1) + ". ^0000FF" + .@name$[.@i] + "^000000";
  2554. }
  2555. close;
  2556.  
  2557.  
  2558. Example 2: check party count (with a 'next' pause), before warping to event
  2559.  
  2560. .register_num = 5; // How many party members are required?
  2561.  
  2562. // get the charID and accountID of character's party members
  2563. getpartymember getcharid(1), 1;
  2564. getpartymember getcharid(1), 2;
  2565.  
  2566. if ($@partymembercount != .register_num) {
  2567. mes "Please form a party of "+ .register_num +" to continue";
  2568. close;
  2569. }
  2570.  
  2571. // loop through both and use 'isloggedin' to count online party members
  2572. for (.@i = 0; .@i < $@partymembercount; ++.@i)
  2573. if (isloggedin($@partymemberaid[.@i], $@partymembercid[.@i]))
  2574. .@count_online++;
  2575. // We search accountID & charID because a single party can have
  2576. // multiple characters from the same account. Without searching
  2577. // through the charID, if a player has 2 characters from the same
  2578. // account inside the party but only 1 char online, it would count
  2579. // their online char twice.
  2580.  
  2581. if (.@count_online != .register_num) {
  2582. mes "All your party members must be online to continue";
  2583. close;
  2584. }
  2585.  
  2586. // copy the array to prevent players cheating the system
  2587. copyarray .@partymembercid, $@partymembercid, .register_num;
  2588.  
  2589. mes "Are you ready?";
  2590. next; // careful here
  2591. select "Yes";
  2592.  
  2593. // When a script hits a next, menu, sleep or input that pauses the
  2594. // script, players can invite or /leave and make changes in their
  2595. // party. To prevent this, we call getpartymember again and compare
  2596. // with the original values.
  2597.  
  2598. getpartymember getcharid(1), 1;
  2599. if ($@partymembercount != .register_num) {
  2600. mes "You've made changes to your party !";
  2601. close;
  2602. }
  2603. for (.@i = 0; .@i < $@partymembercount; ++.@i) {
  2604. if (.@partymembercid[.@i] != $@partymembercid[.@i]) {
  2605. mes "You've made changes to your party !";
  2606. close;
  2607. }
  2608. }
  2609.  
  2610. // Finally, it's safe to start the event!
  2611. warpparty "event_map", 0,0, getcharid(1);
  2612.  
  2613. ---------------------------------------
  2614.  
  2615. *getpartyleader(<party id>{,<type>})
  2616.  
  2617. This function returns some information about the given party-id's leader.
  2618. When type is omitted, the default information retrieved is the leader's
  2619. name. Possible types are:
  2620.  
  2621. 1: Leader account id
  2622. 2: Leader character id
  2623. 3: Leader's class
  2624. 4: Leader's current nome do mapa
  2625. 5: Leader's current level as stored on the party structure (may not be
  2626. current level if leader leveled up recently).
  2627.  
  2628. If retrieval fails (leader not found or party does not exist), this
  2629. function returns "null" instead of the character name, and -1 for the
  2630. other types.
  2631.  
  2632. ---------------------------------------
  2633.  
  2634. *getlook(<type>)
  2635.  
  2636. This function will return the number for the current character look value
  2637. specified by type. See 'setlook' for valid look types.
  2638.  
  2639. This can be used to make a certain script behave differently for
  2640. characters dressed in black. :)
  2641.  
  2642. ---------------------------------------
  2643.  
  2644. *getsavepoint(<information type>)
  2645.  
  2646. This function will return information about the invoking character's save
  2647. point. You can use it to let a character swap between several recorded
  2648. save points. Available information types are:
  2649.  
  2650. 0 - nome do mapa (a string)
  2651. 1 - X coordinate
  2652. 2 - Y coordinate
  2653.  
  2654. ---------------------------------------
  2655.  
  2656. *getcharip({"<character name>"|<account id>|<char id>})
  2657.  
  2658. This function will return the IP address of the invoking character, or, if
  2659. a player is specified, of that character. A blank string is returned if no
  2660. player is attached.
  2661.  
  2662. Examples:
  2663.  
  2664. // Outputs IP address of attached player.
  2665. mes "Your IP: " + getcharip();
  2666.  
  2667. // Outputs IP address of character "Silver".
  2668. mes "Silver's IP: " + getcharip("Silver");
  2669.  
  2670. ---------------------------------------
  2671.  
  2672. *sit({"<character name>"})
  2673. *stand({"<character name>"})
  2674.  
  2675. This function will force a character to sit/stand if it is standing/sitting.
  2676. If no player is specified, the attached player will be used.
  2677.  
  2678. ---------------------------------------
  2679.  
  2680. *issit({"<character name>"})
  2681.  
  2682. This function will return a number depending on the character's sitting state.
  2683. If the character is sitting, it will return 1, otherwise (standing) it will return 0.
  2684. In case no player is specified, the function will return the state of the attached player.
  2685.  
  2686. ---------------------------------------
  2687. //=====================================
  2688. 2.1 - Item-Related Commands
  2689. //=====================================
  2690. ---------------------------------------
  2691.  
  2692. *getequipid(<equipment slot>)
  2693.  
  2694. This function returns the item ID of the item equipped in the equipment
  2695. slot specified on the invoking character. If nothing is equipped there, it
  2696. returns -1. Valid equipment slots are:
  2697.  
  2698. EQI_HEAD_TOP (1) - Upper head gear
  2699. EQI_ARMOR (2) - Armor (Where you keep your Jackets and Robes)
  2700. EQI_HAND_L (3) - What is in your Left hand.
  2701. EQI_HAND_R (4) - What is in your Right hand.
  2702. EQI_GARMENT (5) - The garment slot (Mufflers, Hoods, Manteaus)
  2703. EQI_SHOES (6) - What foot gear the player has on.
  2704. EQI_ACC_L (7) - Accessory 1.
  2705. EQI_ACC_R (8) - Accessory 2.
  2706. EQI_HEAD_MID (9) - Middle Headgear (masks and glasses)
  2707. EQI_HEAD_LOW (10) - Lower Headgear (beards, some masks)
  2708. EQI_COSTUME_HEAD_LOW (11) - Lower Costume Headgear
  2709. EQI_COSTUME_HEAD_MID (12) - Middle Costume Headgear
  2710. EQI_COSTUME_HEAD_TOP (13) - Upper Costume Headgear
  2711. EQI_COSTUME_GARMENT (14) - Costume Garment
  2712. EQI_SHADOW_ARMOR (15) - Shadow Armor
  2713. EQI_SHADOW_WEAPON (16) - Shadow Weapon
  2714. EQI_SHADOW_SHIELD (17) - Shadow Shield
  2715. EQI_SHADOW_SHOES (18) - Shadow Shoes
  2716. EQI_SHADOW_ACC_R (19) - Shadow Accessory 2
  2717. EQI_SHADOW_ACC_L (20) - Shadow Accessory 1
  2718.  
  2719. Notice that a few items occupy several equipment slots, and if the
  2720. character is wearing such an item, 'getequipid' will return it's ID number
  2721. for either slot.
  2722.  
  2723. Can be used to check if you have something equipped, or if you haven't got
  2724. something equipped:
  2725.  
  2726. if(getequipid(EQI_HEAD_TOP) == Tiara) {
  2727. mes "What a lovely Tiara you have on";
  2728. close;
  2729. }
  2730. mes "Come back when you have a Tiara on";
  2731. close;
  2732.  
  2733. You can also use it to make sure people don't pass a point before removing
  2734. an item totally from them. Let's say you don't want people to wear Legion
  2735. Plate armor, but also don't want them to equip if after the check, you
  2736. would do this:
  2737.  
  2738. if (getequipid(EQI_ARMOR) == Full_Plate_Armor || getequipid(EQI_ARMOR) == Full_Plate_Armor_) {
  2739. mes "You are wearing some Legion Plate Armor, please drop that in your stash before continuing";
  2740. close;
  2741. }
  2742. if (countitem(Full_Plate_Armor) > 0 || countitem(Full_Plate_Armor_) > 0) {
  2743. mes "You have some Legion Plate Armor in your inventory, please drop that in your stash before continuing";
  2744. close;
  2745. }
  2746. mes "I will lets you pass";
  2747. close2;
  2748. warp "place",50,50;
  2749. end;
  2750.  
  2751. ---------------------------------------
  2752.  
  2753. *getequipname(<equipment slot>)
  2754.  
  2755. Returns the jname of the item equipped in the specified equipment slot on
  2756. the invoking character, or an empty string if nothing is equipped in that
  2757. position.
  2758. Does the same thing as getitemname(getequipid()). Useful for an NPC to
  2759. state what your are wearing, or maybe saving as a string variable.
  2760. See 'getequipid' for a full list of valid equipment slots.
  2761.  
  2762. if( getequipname(EQI_HEAD_TOP) != "" )
  2763. mes "So you are wearing a "+getequipname(EQI_HEAD_TOP)+" on your head";
  2764. else
  2765. mes "You are not wearing a head gear";
  2766.  
  2767. ---------------------------------------
  2768.  
  2769. *getitemname(<item id>)
  2770.  
  2771. Given the database ID number of an item, this function will return the
  2772. text stored in the 'japanese name' field (which, in Cronus, stores an
  2773. English name the players would normally see on screen).
  2774.  
  2775. ---------------------------------------
  2776.  
  2777. *getbrokenid(<number>)
  2778.  
  2779. This function will search the invoking character's inventory for any
  2780. broken items, and will return their item ID numbers. Since the character
  2781. may have several broken items, 1 given as an argument will return the
  2782. first one found, 2 will return the second one, etc. Will return 0 if no
  2783. such item is found.
  2784.  
  2785. // Let's see if they have anything broken:
  2786. if (getbrokenid(1)==0)
  2787. mes "You don't have anything broken, quit bothering me.";
  2788. else // They do, so let's print the name of the first broken item:
  2789. mes "Oh, I see you have a broken "+getitemname(getbrokenid(1))+" here!";
  2790.  
  2791. ---------------------------------------
  2792.  
  2793. *getbrokencount()
  2794.  
  2795. This function will return the total amount of broken equipment on the
  2796. invoking character.
  2797.  
  2798. ---------------------------------------
  2799.  
  2800. *getequipisequiped(<equipment slot>)
  2801.  
  2802. This functions will return 1 if there is an equipment placed on the
  2803. specified equipment slot and 0 otherwise. For a list of equipment slots
  2804. see 'getequipid'. Function originally used by the refining NPCs:
  2805.  
  2806. if (getequipisequiped(EQI_HEAD_TOP)) {
  2807. mes "[Refiner]";
  2808. mes "That's a fine hat you are wearing there...";
  2809. close;
  2810. }
  2811. mes "[Refiner]";
  2812. mes "Do you want me to refine your dumb head?";
  2813. close;
  2814.  
  2815. ---------------------------------------
  2816.  
  2817. *getequipisenableref(<equipment slot>)
  2818.  
  2819. Will return 1 if the item equipped on the invoking character in the
  2820. specified equipment slot is refinable, and 0 if it isn't. For a list of
  2821. equipment slots see 'getequipid'.
  2822.  
  2823. if (getequipisenableref(EQI_HEAD_TOP)) {
  2824. mes "[Refiner]";
  2825. mes "Ok I can refine this";
  2826. close;
  2827. }
  2828. mes "[Refiner]";
  2829. mes "I can't refine this hat!...";
  2830. close;
  2831.  
  2832. ---------------------------------------
  2833.  
  2834. *getequiprefinerycnt(<equipment slot>)
  2835.  
  2836. Returns the current number of pluses for the item in the specified
  2837. equipment slot. For a list of equipment slots see 'getequipid'.
  2838.  
  2839. Can be used to check if you have reached a maximum refine value, default
  2840. for this is +10:
  2841.  
  2842. if(getequiprefinerycnt(EQI_HEAD_TOP) < 10)
  2843. mes "I will now upgrade your "+getequipname(EQI_HEAD_TOP);
  2844. else
  2845. mes "Sorry, it's not possible to refine hats better than +10";
  2846. close;
  2847.  
  2848. ---------------------------------------
  2849.  
  2850. *getequipweaponlv(<equipment slot>)
  2851.  
  2852. This function returns the weapon level for the weapon equipped in the
  2853. specified equipment slot on the invoking character. For a list of
  2854. equipment slots see 'getequipid'.
  2855.  
  2856. Only EQI_HAND_L and EQI_HAND_R normally make sense, since only weapons
  2857. have a weapon level. You can, however, probably, use this field for other
  2858. equippable custom items as a flag or something.
  2859.  
  2860. If no item is equipped in this slot, or if it doesn't have a weapon level
  2861. according to the database, 0 will be returned.
  2862.  
  2863. Examples:
  2864.  
  2865. // Right hand can only contain a weapon.
  2866. switch (getequipweaponlv(EQI_HAND_R)) {
  2867. case 1: mes "You are holding a lvl 1 weapon."; break;
  2868. case 2: mes "You are holding a lvl 2 weapon."; break;
  2869. case 3: mes "You are holding a lvl 3 weapon."; break;
  2870. case 4: mes "You are holding a lvl 4 weapon."; break;
  2871. case 5: mes "You are holding a lvl 5 weapon, hm, must be a custom design..."; break;
  2872. default: mes "Seems you don't have a weapon on."; break;
  2873. }
  2874.  
  2875. // Left hand can hold either a weapon or shield.
  2876. if (getequipid(EQI_HAND_R) == 0) {
  2877. mes "Seems you have nothing equipped here.";
  2878. close;
  2879. }
  2880. switch (getequipweaponlv(EQI_HAND_L)) {
  2881. case 0: mes "You are holding a shield, so it doesn't have a level."; break;
  2882. case 1: mes "You are holding a lvl 1 weapon."; break;
  2883. case 2: mes "You are holding a lvl 2 weapon."; break;
  2884. case 3: mes "You are holding a lvl 3 weapon."; break;
  2885. case 4: mes "You are holding a lvl 4 weapon."; break;
  2886. case 5: mes "You are holding a lvl 5 weapon, hm, must be a custom design..."; break;
  2887. }
  2888.  
  2889. ---------------------------------------
  2890.  
  2891. *getequippercentrefinery(<equipment slot>)
  2892.  
  2893. This function calculates and returns the percent value chance to
  2894. successfully refine the item found in the specified equipment slot of the
  2895. invoking character by +1. There is no actual formula, the success rate for
  2896. a given weapon level of a certain refine level is found in the
  2897. db/refine_db.txt file. For a list of equipment slots see 'getequipid'.
  2898.  
  2899. These values can be displayed for the player to see, or used to calculate
  2900. the random change of a refine succeeding or failing and then going through
  2901. with it (which is what the official NPC refinery scripts use it for).
  2902.  
  2903. // This will find a random number from 0 - 99 and if that is equal to or
  2904. // more than the value recovered by this command it will show a message
  2905. if (getequippercentrefinery(EQI_HAND_L) <= rand(100))
  2906. mes "Aww";
  2907.  
  2908. ---------------------------------------
  2909.  
  2910. *getareadropitem("<nome do mapa>",<x1>,<y1>,<x2>,<y2>,<item>)
  2911.  
  2912. This function will count all the items with the specified ID number lying
  2913. on the ground on the specified map within the x1/y1-x2/y2 square on it and
  2914. return that number.
  2915.  
  2916. This is the only function around where a parameter may be either a string
  2917. or a number! If it's a number, it means that only the items with that item
  2918. ID number will be counted. If it is a string, it is assumed to mean the
  2919. 'english name' field from the item database. If you give it an empty
  2920. string, or something that isn't found from the item database, it will
  2921. count items number '512' (apples).
  2922.  
  2923. ---------------------------------------
  2924.  
  2925. *getequipcardcnt(<equipment slot>)
  2926.  
  2927. This function will return the number of cards that have been compounded
  2928. onto a specific equipped item for the invoking character. See 'getequipid'
  2929. for a list of possible equipment slots.
  2930.  
  2931. ---------------------------------------
  2932.  
  2933. *getinventorylist;
  2934.  
  2935. This command sets a bunch of arrays with a complete list of whatever the
  2936. invoking character has in its inventory, including all the data needed to
  2937. recreate these items perfectly if they are destroyed. Here's what you get:
  2938.  
  2939. @inventorylist_id[] - array of item ids.
  2940. @inventorylist_amount[] - their corresponding item amounts.
  2941. @inventorylist_equip[] - will return the slot the item is equipped on, if at all.
  2942. @inventorylist_refine[] - for how much it is refined.
  2943. @inventorylist_identify[] - whether it is identified.
  2944. @inventorylist_attribute[] - whether it is broken.
  2945. @inventorylist_card1[] - These four arrays contain card data for the
  2946. @inventorylist_card2[] items. These data slots are also used to store
  2947. @inventorylist_card3[] names inscribed on the items, so you can
  2948. @inventorylist_card4[] explicitly check if the character owns an item
  2949. made by a specific craftsman.
  2950. @inventorylist_expire[] - expire time (Unix time stamp). 0 means never
  2951. expires.
  2952. @inventorylist_bound - whether it is an account bounded item or not.
  2953. @inventorylist_count - the number of items in these lists.
  2954.  
  2955. This could be handy to save/restore a character's inventory, since no
  2956. other command returns such a complete set of data, and could also be the
  2957. only way to correctly handle an NPC trader for carded and named items who
  2958. could resell them - since NPC objects cannot own items, so they have to
  2959. store item data in variables and recreate the items.
  2960.  
  2961. Notice that the variables this command generates are all temporary,
  2962. attached to the character, and integer.
  2963.  
  2964. Be sure to use @inventorylist_count to go through these arrays, and not
  2965. 'getarraysize', because the arrays are not automatically cleared between
  2966. runs of 'getinventorylist'.
  2967.  
  2968. ---------------------------------------
  2969.  
  2970. *getcartinventorylist;
  2971.  
  2972. This command sets a bunch of arrays with a complete list of whatever the
  2973. invoking character has in its cart_inventory, including all the data needed to
  2974. recreate these items perfectly if they are destroyed. Here's what you get:
  2975.  
  2976. @cartinventorylist_id[] - array of item ids.
  2977. @cartinventorylist_amount[] - their corresponding item amounts.
  2978. @cartinventorylist_refine[] - for how much it is refined.
  2979. @cartinventorylist_identify[] - whether it is identified.
  2980. @cartinventorylist_attribute[] - whether it is broken.
  2981. @cartinventorylist_card1[] - These four arrays contain card data for the
  2982. @cartinventorylist_card2[] items. These data slots are also used to store
  2983. @cartinventorylist_card3[] names inscribed on the items, so you can
  2984. @cartinventorylist_card4[] explicitly check if the character owns an item
  2985. made by a specific craftsman.
  2986. @cartinventorylist_expire[] - expire time (Unix time stamp). 0 means never
  2987. expires.
  2988. @cartinventorylist_bound - whether it is an account bounded item or not.
  2989. @cartinventorylist_count - the number of items in these lists.
  2990.  
  2991. This could be handy to save/restore a character's cart_inventory, since no
  2992. other command returns such a complete set of data, and could also be the
  2993. only way to correctly handle an NPC trader for carded and named items who
  2994. could resell them - since NPC objects cannot own items, so they have to
  2995. store item data in variables and recreate the items.
  2996.  
  2997. Notice that the variables this command generates are all temporary,
  2998. attached to the character, and integer.
  2999.  
  3000. Be sure to use @cartinventorylist_count to go through these arrays, and not
  3001. 'getarraysize', because the arrays are not automatically cleared between
  3002. runs of 'getcartinventorylist'.
  3003.  
  3004. ---------------------------------------
  3005.  
  3006. *cardscnt()
  3007.  
  3008. This function will return the number of cards inserted into the weapon
  3009. currently equipped on the invoking character.
  3010. While this function was meant for item scripts, it will work outside them:
  3011.  
  3012. if (cardscnt()==4) mes "So you've stuck four cards into that weapon, think you're cool now?";
  3013.  
  3014. ---------------------------------------
  3015.  
  3016. *getrefine()
  3017.  
  3018. This function will return the refine count of the equipment from which
  3019. the function is called. This function is intended for use in item scripts.
  3020.  
  3021. if (getrefine()==10) mes "Wow. That's a murder weapon.";
  3022.  
  3023. ---------------------------------------
  3024.  
  3025. *getnameditem(<item id>,"<name to inscribe>");
  3026. *getnameditem("<item name>","<name to inscribe>");
  3027.  
  3028. This function is equivalent to using 'getitem', however, it will not just
  3029. give the character an item object, but will also inscribe it with a
  3030. specified character's name. You may not inscribe items with arbitrary
  3031. strings, only with names of characters that actually exist. While this
  3032. isn't said anywhere specifically, apparently, named items may not have
  3033. cards in them, slots or no - these data slots are taken by the character
  3034. ID who's name is inscribed. Only one remains free and it's not quite clear
  3035. if a card may be there.
  3036.  
  3037. This function will return 1 if an item was successfully created and 0 if
  3038. it wasn't for whatever reason. Like 'getitem', this function will also
  3039. accept an 'english name' from the item database as an item name and will
  3040. return 0 if no such item exists.
  3041.  
  3042. ---------------------------------------
  3043.  
  3044. *getitemslots(<item ID>)
  3045.  
  3046. This function will look up the item with the specified ID number in the
  3047. database and return the number of slots this kind of items has - 0 if they
  3048. are not slotted. It will also be 0 for all non-equippable items,
  3049. naturally, unless someone messed up the item database. It will return -1
  3050. if there is no such item.
  3051.  
  3052. Example:
  3053.  
  3054. //.@slots now has the amount of slots of the item with ID 1205.
  3055. .@slots = getitemslots(1205);
  3056.  
  3057. ---------------------------------------
  3058.  
  3059. *getiteminfo(<item ID>,<type>)
  3060.  
  3061. This function will look up the item with the specified ID number in the
  3062. database and return the info set by TYPE argument.
  3063. It will return -1 if there is no such item.
  3064.  
  3065. Valid types are:
  3066. 0 - Buy Price; 1 - Sell Price; 2 - Item Type;
  3067. 3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc..
  3068. if = 0, then monsters don't drop it at all (rare or a quest item)
  3069. if = 10000, then this item is sold in NPC shops only
  3070. 4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range;
  3071. 10 - slot; 11 - look; 12 - elv; 13 - wlv; 14 - view id
  3072.  
  3073. If RENEWAL is defined, 15 - matk
  3074.  
  3075. Check sample in doc/sample/getiteminfo.txt
  3076.  
  3077. ---------------------------------------
  3078.  
  3079. *getequipcardid(<equipment slot>,<card slot>)
  3080.  
  3081. Returns value for equipped item slot in the indicated slot (0, 1, 2, or 3).
  3082.  
  3083. This function returns CARD ID, 255,254,-255 (for card 0, if the item is
  3084. produced). It's useful for when you want to check whether an item contains
  3085. cards or if it's signed.
  3086.  
  3087. ---------------------------------------
  3088. //=====================================
  3089. 2.1 - End of Item-Related Commands
  3090. //=====================================
  3091. ---------------------------------------
  3092.  
  3093. *getmapxy("<variable for nome do mapa>",<variable for x>,<variable for y>,<type>{,"<search string>"})
  3094.  
  3095. This function will locate a character object, NPC object or pet's
  3096. coordinates and place their coordinates into the variables specified when
  3097. calling it. It will return 0 if the search was successful, and -1 if the
  3098. parameters given were not variables or the search was not successful.
  3099.  
  3100. Type is the type of object to search for:
  3101.  
  3102. 0 - Character object
  3103. 1 - NPC object
  3104. 2 - Pet object
  3105. 3 - Monster object
  3106. 4 - Homunculus object
  3107. 5 - Mercenary object
  3108. 6 - Elemental object
  3109.  
  3110. While 3 is meant to look for a monster object, no searching will be done
  3111. if you specify type 3, and the function will always return -1.
  3112.  
  3113. The search string is optional. If it is not specified, the location of the
  3114. invoking character will always be returned for types 0 and 2, the location
  3115. of the NPC running this function for type 1.
  3116. If a search string is specified, for types 0 and 1, the character or NPC
  3117. with the specified name will be located. If type is 3, the search will
  3118. locate the current pet of the character who's name is given in the search
  3119. string, it will NOT locate a pet by name.
  3120.  
  3121. What a mess. Example, a working and tested one now:
  3122.  
  3123. prontera,164,301,3%TAB%script%TAB%Meh%TAB%730,{
  3124. mes "My name is Meh. I'm here so that Nyah can find me.";
  3125. close;
  3126. }
  3127.  
  3128. prontera,164,299,3%TAB%script%TAB%Nyah%TAB%730,{
  3129. mes "My name is Nyah.";
  3130. mes "I will now search for Meh all across the world!";
  3131. if (getmapxy(.@mapname$,.@mapx,.@mapy,1,"Meh")!=0) {
  3132. mes "I can't seem to find Meh anywhere!";
  3133. close;
  3134. }
  3135. mes "And I found him on map "+.@mapname$+" at X:"+.@mapx+" Y:"+.@mapy+" !";
  3136. close;
  3137. }
  3138.  
  3139. Notice that NPC objects disabled with 'disablenpc' will still be located.
  3140.  
  3141. ---------------------------------------
  3142.  
  3143. *getgmlevel()
  3144.  
  3145. This function will return the (GM) level of player group the account to
  3146. which the invoking character belongs. If this is somehow executed from a
  3147. console command, 99 will be returned, and 0 will be returned if the
  3148. account has no GM level.
  3149.  
  3150. This allows you to make NPC's only accessible for certain GM levels, or
  3151. behave specially when talked to by GMs.
  3152.  
  3153. if (getgmlevel()) mes "What is your command, your godhood?";
  3154. if (getgmlevel() < 99) end;
  3155.  
  3156. ---------------------------------------
  3157.  
  3158. *getgroupid()
  3159.  
  3160. This function will return the id of player group the account to which the
  3161. invoking player belongs.
  3162.  
  3163. ---------------------------------------
  3164.  
  3165. *gettimetick(<tick type>)
  3166.  
  3167. This function will return the system time in UNIX epoch time (if tick type
  3168. is 2) or the time since the start of the current day in seconds if tick
  3169. type is 1.
  3170. Passing 0 will make it return the server's tick, which is a measurement in
  3171. milliseconds used by the server's timer system. The server's tick is an
  3172. unsigned int which loops every ~50 days.
  3173.  
  3174. Just in case you don't know, UNIX epoch time is the number of seconds
  3175. elapsed since 1st of January 1970, and is useful to see, for example,
  3176. for how long the character has been online with OnPCLoginEvent and
  3177. OnPCLogoutEvent, which could allow you to make an 'online time counted for
  3178. conviction only' jail script.
  3179.  
  3180. ---------------------------------------
  3181.  
  3182. *gettime(<type>)
  3183.  
  3184. This function returns specified information about the current system time.
  3185.  
  3186. 1 - Seconds (of a minute)
  3187. 2 - Minutes (of an hour)
  3188. 3 - Hour (of a day)
  3189. 4 - Week day (0 for Sunday, 6 is Saturday)
  3190. 5 - Day of the month.
  3191. 6 - Number of the month.
  3192. 7 - Year.
  3193. 8 - Day of the year.
  3194.  
  3195. It will only return numbers.
  3196.  
  3197. if (gettime(4)==6) mes "It's a Saturday. I don't work on Saturdays.";
  3198.  
  3199. ---------------------------------------
  3200.  
  3201. *gettimestr(<format string>,<max length>)
  3202.  
  3203. This function will return a string containing time data as specified by
  3204. the format string.
  3205.  
  3206. This uses the C function 'strfmtime', which obeys special format
  3207. characters. For a full description see, for example, the description of
  3208. 'strfmtime' at http://www.delorie.com/gnu/docs/glibc/libc_437.html
  3209. All the format characters given in there should properly work.
  3210. Max length is the maximum length of a time string to generate.
  3211.  
  3212. The example given in Cronus sample scripts works like this:
  3213.  
  3214. mes gettimestr("%Y-%m/%d %H:%M:%S",21);
  3215.  
  3216. This will print a full date and time like 'YYYY-MM/DD HH:MM:SS'.
  3217.  
  3218. ---------------------------------------
  3219.  
  3220. *getusers(<type>)
  3221.  
  3222. This function will return a number of users on a map or the whole server.
  3223. What it returns is specified by Type.
  3224.  
  3225. Type can be one of the following values, which control what is returned:
  3226.  
  3227. 0 - Count of all characters on the map of the invoking character.
  3228. 1 - Count of all characters in the entire server.
  3229. 8 - Count of all characters on the map of the NPC the script is
  3230. running in.
  3231.  
  3232. ---------------------------------------
  3233.  
  3234. *getmapusers("<nome do mapa>")
  3235.  
  3236. This function will return the number of users currently located on the
  3237. specified map.
  3238.  
  3239. Currently being used in the PVP scripts to check if a PVP room is full of
  3240. not, if the number returned it equal to the maximum allowed it will not
  3241. let you enter.
  3242.  
  3243. ---------------------------------------
  3244.  
  3245. *getareausers({"<nome do mapa>",}{<x1>,<y1>,<x2>,<y2>})
  3246. *getareausers({"<nome do mapa>",}{<radius>})
  3247.  
  3248. This function will return the count of connected characters which are
  3249. located within the specified area. Area can be x1/y1-x2/y2 square,
  3250. or radius from npc position. If nome do mapa missing, used attached player map.
  3251.  
  3252. This is useful for maps that are split into many buildings, such as all
  3253. the "*_in" maps, due to all the shops and houses.
  3254.  
  3255. Examples:
  3256. // return players in area npc area on current map.
  3257. .@num = getareausers();
  3258. // return players in square (1, 1) - (10, 10)
  3259. .@num = "players: " + getareausers(1, 1, 10, 10);
  3260.  
  3261. ---------------------------------------
  3262.  
  3263. *getusersname;
  3264.  
  3265. This command will give the invoking character a list of names of the
  3266. connected characters (including themselves) into an NPC script message
  3267. window (see 'mes') paging it by 10 names as if with the 'next' command.
  3268.  
  3269. You need to put a 'close' after that yourself.
  3270.  
  3271. ---------------------------------------
  3272. //=====================================
  3273. 2.2 - Guild-Related Commands
  3274. //=====================================
  3275. ---------------------------------------
  3276.  
  3277. *getguildname(<guild id>)
  3278.  
  3279. This function returns a guild's name given an ID number. If there is no
  3280. such guild, "null" will be returned;
  3281.  
  3282. // Would print whatever guild 10007 name is.
  3283. mes "The guild "+getguildname(10007)+" are all nice people.";
  3284.  
  3285. // This will do the same as above:
  3286. .@var = 10007;
  3287. mes "We have some friends in "+getguildname(.@var)+", you know.";
  3288.  
  3289. This is used all over the WoE controlling scripts. You could also use it
  3290. for a guild-based event.
  3291.  
  3292. ---------------------------------------
  3293.  
  3294. *getguildmaster(<guild id>)
  3295.  
  3296. This function return the name of the master of the guild which has the
  3297. specified ID number. If there is no such guild, "null" will be returned.
  3298.  
  3299. // Would return the guild master of guild 10007, whatever that might be.
  3300. mes getguildmaster(10007)+" runs "+getguildname(10007);
  3301.  
  3302. Can be used to check if the character is the guild master of the specified
  3303. guild.
  3304.  
  3305. Maybe you want to make a room only guild masters can enter:
  3306.  
  3307. .@GID = getcharid(2);
  3308. if (.@GID == 0) {
  3309. mes "Sorry you are not in a guild";
  3310. close;
  3311. }
  3312. if (strcharinfo(0) == getguildmaster(.@GID)) {
  3313. mes "Welcome guild master of "+GetGuildName(.@GID);
  3314. close;
  3315. }
  3316. mes "Sorry you don't own the guild you are in";
  3317. close;
  3318.  
  3319. ---------------------------------------
  3320.  
  3321. *getguildmasterid(<guild id>)
  3322.  
  3323. This function will return the character ID number of the guild master of
  3324. the guild specified by the ID. 0 if the character is not a guild master of
  3325. any guild.
  3326.  
  3327. ---------------------------------------
  3328.  
  3329. *getcastlename("<nome do mapa>")
  3330.  
  3331. This function returns the name of the castle when given the nome do mapa for
  3332. that castle. The data is read from 'db/castle_db.txt'.
  3333.  
  3334. ---------------------------------------
  3335.  
  3336. *getcastledata("<nome do mapa>",<type of data>)
  3337. *setcastledata "<nome do mapa>",<type of data>,<value>;
  3338.  
  3339. This function returns the castle ownership information for the castle
  3340. referred to by its nome do mapa. Castle information is stored in
  3341. `guild_castle` SQL table.
  3342.  
  3343. Types of data correspond to `guild_castle` table columns:
  3344.  
  3345. 1 - `guild_id` - Guild ID.
  3346. 2 - `economy` - Castle Economy score.
  3347. 3 - `defense` - Castle Defense score.
  3348. 4 - `triggerE` - Number of times the economy was invested in today.
  3349. 5 - `triggerD` - Number of times the defense was invested in today.
  3350. 6 - `nextTime` - unused
  3351. 7 - `payTime` - unused
  3352. 8 - `createTime` - unused
  3353. 9 - `visibleC` - Is 1 if a Kafra was hired for this castle, 0 otherwise.
  3354. 10 - `visibleG0` - Is 1 if the 1st guardian is present (Soldier Guardian)
  3355. 11 - `visibleG1` - Is 1 if the 2nd guardian is present (Soldier Guardian)
  3356. 12 - `visibleG2` - Is 1 if the 3rd guardian is present (Soldier Guardian)
  3357. 13 - `visibleG3` - Is 1 if the 4th guardian is present (Archer Guardian)
  3358. 14 - `visibleG4` - Is 1 if the 5th guardian is present (Archer Guardian)
  3359. 15 - `visibleG5` - Is 1 if the 6th guardian is present (Knight Guardian)
  3360. 16 - `visibleG6` - Is 1 if the 7th guardian is present (Knight Guardian)
  3361. 17 - `visibleG7` - Is 1 if the 8th guardian is present (Knight Guardian)
  3362.  
  3363. All types of data have their meaning determined by War of Emperium
  3364. scripts, with exception of:
  3365. - `guild_id` that is always the ID of the guild that owns the castle,
  3366. - `defense` that is used in Guardians & Emperium HP calculations,
  3367. - `visibleG` that is always considered to hold guardian presence bits.
  3368.  
  3369. The 'setcastledata' command will behave identically, but instead of
  3370. returning values for the specified types of accessible data, it will alter
  3371. them and cause them to be sent to the char-server for storage.
  3372.  
  3373. Changing Guild ID or Castle Defense will trigger additional actions, like
  3374. recalculating guardians' HP.
  3375.  
  3376. ---------------------------------------
  3377.  
  3378. *getgdskilllv(<guild id>,<skill id>)
  3379. *getgdskilllv(<guild id>,"<skill name>")
  3380.  
  3381. This function returns the level of the skill <skill id> of the guild
  3382. <guild id>.
  3383. If the guild does not have that skill, 0 is returned.
  3384. If the guild does not exist, -1 is returned.
  3385. Refer to 'db/(pre-)re/skill_db.txt' for the full list of skills.
  3386. GD_* are guild skills
  3387.  
  3388. ---------------------------------------
  3389.  
  3390. *requestguildinfo <guild id>{,"<event label>"};
  3391.  
  3392. This command requests the guild data from the char server and merrily
  3393. continues with the execution. Whenever the guild information becomes
  3394. available (which happens instantly if the guild information is already in
  3395. memory, or later, if it isn't and the map server has to wait for the char
  3396. server to reply) it will run the specified event as in a 'doevent' call.
  3397.  
  3398. ---------------------------------------
  3399.  
  3400. *getmapguildusers(<mapname>,<guild id>)
  3401.  
  3402. Returns the amount of characters from the specified guild on the given map.
  3403.  
  3404. Example:
  3405.  
  3406. mes "You have "+getmapguildusers("prontera",getcharid(2))+" guild members in Prontera.";
  3407.  
  3408. ---------------------------------------
  3409.  
  3410. *getguildmember <guild id>{,<type>};
  3411.  
  3412. This command will find all members of a specified guild and returns their names
  3413. (or character id or account id depending on the value of "type") into an array
  3414. of temporary global variables.
  3415.  
  3416. Upon executing this,
  3417.  
  3418. $@guildmembername$[] is a global temporary string array which contains all the
  3419. names of these guild members.
  3420. (only set when type is 0 or not specified)
  3421.  
  3422. $@guildmembercid[] is a global temporary number array which contains the
  3423. character id of these guild members.
  3424. (only set when type is 1)
  3425.  
  3426. $@guildmemberaid[] is a global temporary number array which contains the
  3427. account id of these guild members.
  3428. (only set when type is 2)
  3429.  
  3430. $@guildmembercount is the number of guild members that were found.
  3431.  
  3432. The guild members will be found regardless of whether they are online or offline.
  3433. Note that the names come in no particular order.
  3434.  
  3435. Be sure to use $@guildmembercount to go through this array, and not
  3436. 'getarraysize', because it is not cleared between runs of 'getguildmember'.
  3437.  
  3438. For usage examples, see 'getpartymember'.
  3439.  
  3440. ---------------------------------------
  3441. //=====================================
  3442. 2.2 - End of Guild-Related Commands
  3443. //=====================================
  3444. ---------------------------------------
  3445.  
  3446. *getskilllv(<skill id>)
  3447. *getskilllv("<skill name>")
  3448.  
  3449. This function returns the level of the specified skill that the invoking
  3450. character has. If they don't have the skill, 0 will be returned. The full
  3451. list of character skills is available in 'db/(pre-)re/skill_db.txt'.
  3452.  
  3453. There are two main uses for this function, it can check whether the
  3454. character has a skill or not, and it can tell you if the level is high
  3455. enough.
  3456.  
  3457. Example 1:
  3458.  
  3459. if (getskilllv(TF_THROWSTONE)) {
  3460. // TF_THROWSTONE is defined in skill_db.txt and its value is 152
  3461. mes "You have got the skill Throw Stone";
  3462. close;
  3463. }
  3464. mes "You don't have Throw Stone";
  3465. close;
  3466.  
  3467. Example 2:
  3468.  
  3469. if (getskilllv(AL_HEAL) == 10) {
  3470. mes "Your heal lvl has been maxed";
  3471. close;
  3472. }
  3473. if (getskilllv(AL_HEAL) >= 5) {
  3474. mes "Your heal lvl is 5 or more";
  3475. close;
  3476. }
  3477. mes "You heal skill is below lvl 5";
  3478. close;
  3479.  
  3480. ---------------------------------------
  3481.  
  3482. *getskilllist;
  3483.  
  3484. This command sets a bunch of arrays with a complete list of skills the
  3485. invoking character has. Here's what you get:
  3486.  
  3487. @skilllist_id[] - skill ids.
  3488. @skilllist_lv[] - skill levels.
  3489. @skilllist_flag[] - see 'skill' for the meaning of skill flags.
  3490. @skilllist_count - number of skills in the above arrays.
  3491.  
  3492. While 'getskillv' is probably more useful for most situations, this is the
  3493. easiest way to store all the skills and make the character something else
  3494. for a while. Advanced job for a day? :) This could also be useful to see
  3495. how many skills a character has.
  3496.  
  3497. ---------------------------------------
  3498.  
  3499. *getpetinfo(<type>)
  3500.  
  3501. This function will return pet information for the pet the invoking
  3502. character currently has active. Valid types are:
  3503.  
  3504. 0 - Unique pet ID number as stored by the char server and distinguishing
  3505. it from all other pets the characters actually have. This value is
  3506. currently useless, at most you can use it to tell pets apart reliably.
  3507. 1 - Pet class number as per 'db/pet_db.txt' - will tell you what kind of
  3508. a pet it is.
  3509. 2 - Pet name. Will return "null" if there's no pet.
  3510. 3 - Pet friendly level (intimacy score). 1000 is full loyalty.
  3511. 4 - Pet hungry level. 100 is completely full.
  3512. 5 - Pet rename flag. 0 means this pet has not been named yet.
  3513.  
  3514. ---------------------------------------
  3515.  
  3516. *petstat(<flag>)
  3517.  
  3518. Returns current pet status, all are integers except name.
  3519. Returns 0 or "" if the player doesn't have pets.
  3520.  
  3521. Flags usable:
  3522. PET_CLASS
  3523. PET_NAME
  3524. PET_LEVEL
  3525. PET_HUNGRY
  3526. PET_INTIMATE
  3527.  
  3528. Example:
  3529. .@i = petstat(PET_CLASS);
  3530.  
  3531. ---------------------------------------
  3532.  
  3533. *getmonsterinfo(<mob ID>,<type>)
  3534.  
  3535. This function will look up the monster with the specified ID number in the
  3536. mob database and return the info set by TYPE argument.
  3537. It will return -1 if there is no such monster (or the type value is
  3538. invalid), or "null" if you requested the monster's name.
  3539.  
  3540. Valid types are listed in const.txt:
  3541. MOB_NAME 0
  3542. MOB_LV 1
  3543. MOB_MAXHP 2
  3544. MOB_BASEEXP 3
  3545. MOB_JOBEXP 4
  3546. MOB_ATK1 5
  3547. MOB_ATK2 6
  3548. MOB_DEF 7
  3549. MOB_MDEF 8
  3550. MOB_STR 9
  3551. MOB_AGI 10
  3552. MOB_VIT 11
  3553. MOB_INT 12
  3554. MOB_DEX 13
  3555. MOB_LUK 14
  3556. MOB_RANGE 15
  3557. MOB_RANGE2 16
  3558. MOB_RANGE3 17
  3559. MOB_SIZE 18
  3560. MOB_RACE 19
  3561. MOB_ELEMENT 20
  3562. MOB_MODE 21
  3563. MOB_MVPEXP 22
  3564.  
  3565. Check sample in doc/sample/getmonsterinfo.txt
  3566.  
  3567. ---------------------------------------
  3568.  
  3569. *addmonsterdrop(<mob id or name>, <item id>, <rate>)
  3570.  
  3571. This command will temporarily add a drop to an existing monster. If the
  3572. monster already drops the specified item, its drop rate will be updated to the
  3573. given value.
  3574.  
  3575. Both the monster and the item must be valid. Acceptable values for the drop
  3576. rate are in the range [1:10000].
  3577.  
  3578. Return value will be 1 in case of success (the item was added or its drop rate
  3579. was updated), and 0 otherwise (there were no free item drop slots).
  3580.  
  3581. Example:
  3582. // Add Poring Doll (741) to the Poring's (1002) drops, with 1% (100) rate
  3583. addmonsterdrop(1002, 741, 100);
  3584.  
  3585. ---------------------------------------
  3586.  
  3587. *delmonsterdrop(<mob id or name>, <item id>)
  3588.  
  3589. This command will temporarily remove a drop from an existing monster.
  3590.  
  3591. Both the monster and the item must be valid.
  3592.  
  3593. Return value will be 1 in case of success (the item was removed), and 0
  3594. otherwise (the monster didn't have the specified item in its drop list).
  3595.  
  3596. Example:
  3597. // Remove Jellopy (909) from the Poring's (1002) drops
  3598. delmonsterdrop(1002, 909);
  3599.  
  3600. ---------------------------------------
  3601.  
  3602. *getmobdrops(<mob id>)
  3603.  
  3604. This command will find all drops of the specified mob and return the item
  3605. IDs and drop percentages into arrays of temporary global variables.
  3606. 'getmobdrops' returns 1 if successful and 0 if the mob ID doesn't exist.
  3607.  
  3608. Upon executing this,
  3609.  
  3610. $@MobDrop_item[] is a global temporary number array which contains the
  3611. item IDs of the monster's drops.
  3612.  
  3613. $@MobDrop_rate[] is a global temporary number array which contains the
  3614. drop percentages of each item. (1 = .01%)
  3615.  
  3616. $@MobDrop_count is the number of item drops found.
  3617.  
  3618. Be sure to use $@MobDrop_count to go through the arrays, and not
  3619. 'getarraysize', because the temporary global arrays are not cleared
  3620. between runs of 'getmobdrops'. If a mob with 7 item drops is looked up,
  3621. the arrays would have 7 elements. But if another mob is looked up and it
  3622. only has 5 item drops, the server will not clear the arrays for you,
  3623. overwriting the values instead. So in addition to returning the 5 item
  3624. drops, the 6th and 7th elements from the last call remain, and you will
  3625. get 5+2 item drops, of which the last 2 don't belong to the new mob.
  3626. $@MobDrop_count will always contain the correct number (5), unlike
  3627. 'getarraysize()' which would return 7 in this case.
  3628.  
  3629. Example:
  3630.  
  3631. // get a Mob ID from the user
  3632. input .@mob_id;
  3633.  
  3634. if (getmobdrops(.@mob_id)) { // 'getmobdrops' returns 1 on success
  3635. // immediately copy global temporary variables into scope
  3636. // variables, since we don't know when 'getmobdrops' will get
  3637. // called again for another mob, overwriting your global temporary
  3638. // variables.
  3639. .@count = $@MobDrop_count;
  3640. copyarray .@item[0],$@MobDrop_item[0],.@count;
  3641. copyarray .@rate[0],$@MobDrop_rate[0],.@count;
  3642.  
  3643. mes getmonsterinfo(.@mob_id,MOB_NAME) + " - " + .@count + " drops found:";
  3644. for (.@i = 0; .@i < .@count; ++.@i) {
  3645. mes .@item[.@i] + " (" + getitemname(.@item[.@i]) + ") " + .@rate[.@i]/100 + ((.@rate[.@i]%100 < 10) ? ".0":".") + .@rate[.@i]%100 + "%";
  3646. }
  3647. } else {
  3648. mes "Unknown monster ID.";
  3649. }
  3650. close;
  3651.  
  3652. ---------------------------------------
  3653.  
  3654. *skillpointcount()
  3655.  
  3656. Returns the total amount of skill points a character possesses
  3657. (SkillPoint+SP's used in skills) This command can be used to check the
  3658. currently attached characters total amount of skill points. This means the
  3659. skill points used in skill are counted, and added to SkillPoints (number
  3660. of skill points not used).
  3661.  
  3662. Example:
  3663.  
  3664. //This will set the temp character variable @skill_points to the amount of
  3665. //skill points, and then tell the player the value.
  3666. @skill_points = skillpointcount();
  3667. mes "You have "+@skill_points+" skill points in total!";
  3668.  
  3669. //Self-explanatory... :P
  3670. if (skillpointcount() > 20)
  3671. mes "Wow, you have more then 20 Skill Points in total!";
  3672.  
  3673. This command does not count skills which are set as flag 3 (permamently
  3674. granted) (e.g. ALL_BUYING_STORE/ALL_INCCARRY).
  3675. ---------------------------------------
  3676.  
  3677. *getscrate(<effect type>,<base rate>{,<GID>})
  3678.  
  3679. This function will return the chance of a status effect affecting the
  3680. invoking character, in percent, modified by the their current defense
  3681. against said status. The 'base rate' is the base chance of the status
  3682. effect being inflicted, in percent.
  3683.  
  3684. if (rand(100) > getscrate(Eff_Blind, 50)) {
  3685. // do something
  3686. }
  3687.  
  3688. You can see the full list of available effect types you can possibly
  3689. inflict in 'db/const.txt' under 'Eff_'.
  3690.  
  3691. ---------------------------------------
  3692. //=====================================
  3693. 3 - Checking-Related Commands
  3694. //=====================================
  3695. ---------------------------------------
  3696.  
  3697. *playerattached()
  3698.  
  3699. Returns the ID of the player currently attached to the script. It will
  3700. return 0 if no one is attached, or if the attached player no longer exists
  3701. on the map server. It is wise to check for the attached player in script
  3702. functions that deal with timers as there's no guarantee the player will
  3703. still be logged on when the timer triggers. Note that the ID of a player
  3704. is actually their account ID.
  3705.  
  3706. ---------------------------------------
  3707.  
  3708. *isloggedin(<account id>{,<char id>})
  3709.  
  3710. This function returns 1 if the specified account is logged in and 0 if
  3711. they aren't. You can also pass the char_id to check for both account and
  3712. char id.
  3713.  
  3714. ---------------------------------------
  3715.  
  3716. *checkweight(<item id>,<amount>{,<item id>,<amount>,<item id>,<amount>,...});
  3717. *checkweight("<item name>",<amount>{,"<item name>",<amount>,"<item name>",<amount>,...});
  3718. *checkweight2(<id_array>,<amount_array>);
  3719.  
  3720. These functions will compute and return 1 if the total weight of the
  3721. specified number of specific items does not exceed the invoking
  3722. character's carrying capacity, and 0 otherwise. It is important to see if
  3723. a player can carry the items you expect to give them, failing to do that
  3724. may open your script up to abuse or create some very unfair errors.
  3725.  
  3726. The second function will check an array of items and amounts, and also
  3727. returns 1 on success and 0 on failure.
  3728.  
  3729. The functions, in addition to checking to see if the player is capable of
  3730. holding a set amount of items, also ensure the player has room in their
  3731. inventory for the item(s) they will be receiving.
  3732.  
  3733. Like 'getitem', this function will also accept an 'english name' from the
  3734. database as an argument.
  3735.  
  3736. Example 1:
  3737.  
  3738. if (checkweight(512,10)) {
  3739. getitem 512,10;
  3740. } else {
  3741. mes "Sorry, you cannot hold this amount of apples!";
  3742. }
  3743.  
  3744. Example 2:
  3745.  
  3746. setarray .@item[0],512,513,514;
  3747. setarray .@amount[0],10,5,5;
  3748. if (!checkweight(.@item,.@amount)) {
  3749. mes "Sorry, you cannot hold this amount of fruit!";
  3750. }
  3751.  
  3752. ---------------------------------------
  3753.  
  3754. *basicskillcheck()
  3755.  
  3756. This function will return the state of the configuration option
  3757. 'basic_skill_check' in 'battle.conf'. Returns 1 if the option is enabled
  3758. and 0 if it isn't. If the 'basic_skill_check' option is enabled, which it
  3759. is by default, characters must have a certain number of basic skill levels
  3760. to sit, request a trade, use emotions, etc. Making your script behave
  3761. differently depending on whether the characters must actually have the
  3762. skill to do all these things might in some cases be required.
  3763.  
  3764. ---------------------------------------
  3765.  
  3766. *checkoption(<option number>)
  3767. *checkoption1(<option number>)
  3768. *checkoption2(<option number>)
  3769. *setoption <option number>{,<flag>};
  3770.  
  3771. The 'setoption' series of functions check for a so-called option that is
  3772. set on the invoking character. 'Options' are used to store status
  3773. conditions and a lot of other non-permanent character data of the yes-no
  3774. kind. For most common cases, it is better to use 'checkcart',
  3775. 'checkfalcon', 'checkpeco' and other similar functions, but there are some
  3776. options which you cannot get at this way. They return 1 if the option is
  3777. set and 0 if the option is not set.
  3778.  
  3779. Option numbers valid for the first (option) version of this command are:
  3780.  
  3781. 0x000001 - Sight in effect.
  3782. 0x000002 - Hide in effect.
  3783. 0x000004 - Cloaking in effect.
  3784. 0x000008 - Cart number 1 present.
  3785. 0x000010 - Falcon present.
  3786. 0x000020 - Peco Peco present.
  3787. 0x000040 - GM Perfect Hide in effect.
  3788. 0x000080 - Cart number 2 present.
  3789. 0x000100 - Cart number 3 present.
  3790. 0x000200 - Cart number 4 present.
  3791. 0x000400 - Cart number 5 present.
  3792. 0x000800 - Orc head present.
  3793. 0x001000 - The character is wearing a wedding sprite.
  3794. 0x002000 - Ruwach is in effect.
  3795. 0x004000 - Chasewalk in effect.
  3796. 0x008000 - Flying or Xmas suit.
  3797. 0x010000 - Sighttrasher.
  3798. 0x100000 - Warg present.
  3799. 0x200000 - The character is riding a warg.
  3800.  
  3801. Option numbers valid for the second version (opt1) of this command are:
  3802.  
  3803. 1 - Petrified.
  3804. 2 - Frozen.
  3805. 3 - Stunned.
  3806. 4 - Sleeping.
  3807. 6 - Petrifying (the state where you can still walk)
  3808.  
  3809. Option numbers valid for the third version (opt2) of this command are:
  3810.  
  3811. 0x01 - Poisoned.
  3812. 0x02 - Cursed.
  3813. 0x04 - Silenced.
  3814. 0x08 - Signum Crucis (plays a howl-like sound effect, but otherwise no
  3815. visible effects are displayed)
  3816. 0x10 - Blinded.
  3817. 0x80 - Deadly poisoned.
  3818.  
  3819. Option numbers (except for opt1) are bit-masks - you can add them up to
  3820. check for several states, but the functions will return true if at least
  3821. one of them is in effect.
  3822.  
  3823. 'setoption' will set options on the invoking character. There are no
  3824. second and third versions of this command, so you can only change the
  3825. values in the first list (cloak, cart, ruwach, etc). If flag is 1 (default
  3826. when omitted), the option will be added to what the character currently
  3827. has; if 0, the option is removed.
  3828.  
  3829. This is definitely not a complete list of available option flag numbers.
  3830. Ask a core developer (or read the source: src/map/status.h) for the full
  3831. list.
  3832.  
  3833. ---------------------------------------
  3834.  
  3835. *setcart {<type>};
  3836. *checkcart()
  3837.  
  3838. If <type> is 0 this command will remove the cart from the character.
  3839. Otherwise it gives the invoking character a cart. The cart given will be
  3840. cart number <type> and will work regardless of whether the character is a
  3841. merchant class or not.
  3842. Note: the character needs to have the skill MC_PUSHCART to gain a cart.
  3843.  
  3844. The accompanying function will return 1 if the invoking character has a
  3845. cart (any kind of cart) and 0 if they don't.
  3846.  
  3847. if (checkcart()) mes "But you already have a cart!";
  3848.  
  3849. ---------------------------------------
  3850.  
  3851. *setfalcon {<flag>};
  3852. *checkfalcon()
  3853.  
  3854. If <flag> is 0 this command will remove the falcon from the character.
  3855. Otherwise it gives the invoking character a falcon. The falcon will be
  3856. there regardless of whether the character is a hunter or not. It will
  3857. (probably) not have any useful effects for non-hunters though.
  3858. Note: the character needs to have the skill HT_FALCON to gain a falcon.
  3859.  
  3860. The accompanying function will return 1 if the invoking character has a
  3861. falcon and 0 if they don't.
  3862.  
  3863. if (checkfalcon()) mes "But you already have a falcon!";
  3864.  
  3865. ---------------------------------------
  3866.  
  3867. *setmount {<flag>};
  3868. *checkmount()
  3869.  
  3870. If <flag> is MOUNT_NONE (or 0) this command will remove the mount from the
  3871. character.
  3872.  
  3873. Otherwise it gives the invoking character the desired combat mount, where
  3874. allowed by their class and skills.
  3875.  
  3876. If no flag is specified, the mount is automatically chosen according to the
  3877. character's class and skills.
  3878.  
  3879. The following flag values are accepted:
  3880.  
  3881. MOUNT_NONE:
  3882. - Dismount
  3883. MOUNT_PECO:
  3884. - PecoPeco (Knight series class)
  3885. - GrandPeco (Crusader series class)
  3886. - Gryphon (Royal Guard)
  3887. MOUNT_WUG:
  3888. - Warg (Ranger)
  3889. MOUNT_MADO:
  3890. - Mado Gear (Mechanic)
  3891. MOUNT_DRAGON:
  3892. MOUNT_DRAGON_GREEN:
  3893. MOUNT_DRAGON_BROWN:
  3894. MOUNT_DRAGON_GRAY:
  3895. MOUNT_DRAGON_BLUE:
  3896. MOUNT_DRAGON_RED:
  3897. - Dragon (Rune Knight)
  3898. if MOUNT_DRAGON is specified, a the default (green) dragon will be used.
  3899.  
  3900. Unlike 'setfalcon' and 'setcart' this will not work at all if they aren't of a
  3901. class which can ride a mount.
  3902.  
  3903. The accompanying function will return 0 if the invoking character is not on a
  3904. mount, and a non-zero value (according to the above constants) if they are.
  3905. Note: in case of dragons, the returned value will always be MOUNT_DRAGON,
  3906. regardless of color.
  3907.  
  3908. if (checkmount())
  3909. mes "Leave your mount outside! No riding mounts on the floor here!";
  3910.  
  3911. if (checkmount() == MOUNT_DRAGON)
  3912. mes "Wow, your dragon is cool! Can I pet it?";
  3913.  
  3914. ---------------------------------------
  3915.  
  3916. *setcashmount;
  3917. *hascashmount()
  3918.  
  3919. The 'setcashmount' function toggles cash mount for the invoking character.
  3920. It will return 1 if successful, 0 otherwise.
  3921.  
  3922. Note: Character must not be mounting a non-cash mount (eg. dragon, peco,
  3923. wug, etc.)
  3924.  
  3925. The accompanying function will return 1 if the invoking character has a
  3926. cash mount and 0 if they don't.
  3927.  
  3928. ---------------------------------------
  3929.  
  3930. *checkwug()
  3931.  
  3932. This function will return 1 if the invoking character has a warg and 0 if
  3933. they don't.
  3934.  
  3935. ---------------------------------------
  3936.  
  3937. *checkvending({"<Player Name>"})
  3938. *checkchatting({"<Player Name>"})
  3939.  
  3940. Checks if the player is vending or in a chatroom.
  3941. Name is optional, and defaults to the attached player if omitted.
  3942.  
  3943. Return values for 'checkvending' are
  3944. 0 = not vending
  3945. 1 = normal vending
  3946. 2 = vending using @autotrade
  3947.  
  3948. 'checkchatting' returns 1 if they are in a chat room, 0 if they are not.
  3949.  
  3950. Examples:
  3951. //This will check if Aaron is vending, and if so, put a message in
  3952. //front of the attached player saying Aaron is vending.
  3953. if (checkvending("Aaron"))
  3954. mes "Aaron is currently vending!";
  3955.  
  3956. //This will check if the attached player in a chat room or not.
  3957. if (checkchatting())
  3958. mes "You are currently in a chat room!";
  3959.  
  3960. ---------------------------------------
  3961.  
  3962. *checkidle({"<Player Name>"})
  3963.  
  3964. Returns the time, in seconds, that the specified player has been idle.
  3965. Name is optional, and defaults to the attached player if omitted.
  3966.  
  3967. ---------------------------------------
  3968.  
  3969. *agitcheck()
  3970. *agitcheck2()
  3971.  
  3972. These function will let you check whether the server is currently in WoE
  3973. mode (or WoE SE mode if the second function is called) and will return 1
  3974. if War of Emperium is on and 0 if it isn't.
  3975.  
  3976. ---------------------------------------
  3977.  
  3978. *isnight()
  3979.  
  3980. This functions will return true or false depending on whether the server is in
  3981. night mode or day mode:
  3982.  
  3983. if (!isnight()) mes "I only prowl in the night.";
  3984.  
  3985. ---------------------------------------
  3986. //=====================================
  3987. 3.1 - Checking Item-Related Commands
  3988. //=====================================
  3989. ---------------------------------------
  3990.  
  3991. *isequipped(<item id>{,<item id>{,<item id>{,<item id>}}})
  3992.  
  3993. This function will return 1 if the invoking character has all of the item
  3994. IDs given equipped (if card IDs are passed, then it checks if the cards
  3995. are inserted into slots in the equipment they are currently wearing).
  3996. Theoretically there is no limit to the number of items that may be tested
  3997. for at the same time.
  3998. If even one of the items given is not equipped, 0 will be returned.
  3999.  
  4000. // (Poring,Santa Poring,Poporing,Marin)
  4001. if (isequipped(4001,4005,4033,4196)) mes "Wow! You're wearing a full complement of possible poring cards!";
  4002. // (Poring)
  4003. if (isequipped(4001)) mes "A poring card is useful, don't you think?";
  4004. // (Earring)
  4005. if (isequipped(2622)) mes "You got a pair of nice Earring.";
  4006.  
  4007. The function was meant for item scripts to support the cards released by
  4008. Gravity in February 2005, but it will work just fine in normal NPC scripts.
  4009.  
  4010. ---------------------------------------
  4011.  
  4012. *isequippedcnt(<item id>{,<item id>{,<item id>{,<item id>}}})
  4013.  
  4014. This function is similar to 'isequipped', but instead of 1 or 0, it will
  4015. return the number of equipped items/cards in the list given that were found on the
  4016. invoking character.
  4017.  
  4018. if (isequippedcnt(4001,4005,4033,4196) == 4) mes "Finally got all four poring cards?";
  4019. if (isequippedcnt(5353,2622) == 2) mes "You equipped both Helm of Sun and Earring.";
  4020.  
  4021. ---------------------------------------
  4022.  
  4023. *checkequipedcard(<card id>)
  4024.  
  4025. This function will return 1 if the card specified by it's item ID number
  4026. is inserted into any equipment they have in their inventory, currently
  4027. equipped or not.
  4028.  
  4029. ---------------------------------------
  4030.  
  4031. *getequipisidentify(<equipment slot>)
  4032.  
  4033. This function will return 1 if an item in the specified equipment slot is
  4034. identified and 0 if it isn't. Since you can't even equip unidentified
  4035. equipment, there's a question of whether it can actually end up there, and
  4036. it will normally return 1 all the time if there is an item in this
  4037. equipment slot, which makes this script command kinda pointless.
  4038. For a list of equipment slots see 'getequipid'.
  4039.  
  4040. ---------------------------------------
  4041. //=====================================
  4042. 3.0 & 3.1 - End of Checking/Item-Related Commands
  4043. //=====================================
  4044. ---------------------------------------
  4045.  
  4046. ---------------------------------------
  4047. //=====================================
  4048. 4 - Player-Related Commands
  4049. //=====================================
  4050. ---------------------------------------
  4051.  
  4052. *attachrid(<account ID>)
  4053. *detachrid;
  4054.  
  4055. These commands allow the manipulation of the script's currently attached
  4056. player. While attachrid allows attaching of a different player by using
  4057. its account id for the parameter rid, detachrid makes the following
  4058. commands run as if the script was never invoked by a player.
  4059.  
  4060. In case, that the player cannot be attached, such as, when the player went
  4061. offline in the mean time, attachrid returns 0, otherwise 1.
  4062.  
  4063. ---------------------------------------
  4064.  
  4065. *rid2name(<rid>)
  4066.  
  4067. Converts rid to name. Note: The player/monster/NPC must be online/enabled.
  4068. Good for PCKillEvent where you can convert 'killedrid' to the name of the
  4069. player.
  4070.  
  4071. Note: rid2name may not produce correct character names since rid means
  4072. account id.
  4073. It will return the current online character of the account only.
  4074.  
  4075. ---------------------------------------
  4076.  
  4077. *message "<character name>","<message>";
  4078.  
  4079. That command will send a message to the chat window of the character
  4080. specified by name. The text will also appear above the head of that
  4081. character. It will not be seen by anyone else.
  4082.  
  4083. ---------------------------------------
  4084.  
  4085. *dispbottom "<message>"{,<color_flag>};
  4086.  
  4087. This command will send the given message into the invoking character's
  4088. chat window.
  4089.  
  4090. //Parameto opicional de cor adicionado por Slex Fire
  4091.  
  4092. Para usar uma cor, basta digitar 0x seguido do codigo hexadecimal da cor.
  4093.  
  4094. dispbottom "Esta mensagem é vermelha",0xFF0000;
  4095. Exibe a mensagem "Esta mensagem é vermelha", na cor vermelha, no jogador que está
  4096. attachado ao script.
  4097.  
  4098. ---------------------------------------
  4099.  
  4100. *showscript "<message>"{,<GID>};
  4101.  
  4102. Makes attached player or GID says a message like shouting a skill name, the message
  4103. will be seen to everyone around but not in chat window.
  4104.  
  4105. ---------------------------------------
  4106.  
  4107. *warp "<nome do mapa>",<x>,<y>{,<flag>};
  4108.  
  4109. This command will take the invoking character to the specified map, and if
  4110. wanted, specified coordinates too, but these can be random.
  4111.  
  4112. warp "place",50,55;
  4113.  
  4114. This would take them to X 50 Y 55 on the map called "place". If your X and
  4115. Y coordinates land on an unwalkable map square, it will send the warped
  4116. character to a random place. Same will happen if they are both zero:
  4117.  
  4118. warp "place",0,0;
  4119.  
  4120. Notice that while warping people to coordinates 0,0 will normally get them
  4121. into a random place, it's not certain to always be so. Darned if I know
  4122. where this is actually coded, it might be that this happens because square
  4123. 0,0 is unwalkable on all official maps. Beware if you're using custom maps.
  4124.  
  4125. There are also three special 'map names' you can use:
  4126.  
  4127. "Random" will warp the player randomly on the current map.
  4128. "Save" and "SavePoint" will warp the player back to their save point.
  4129.  
  4130. If flag parameter is set to 0, after player warped will be not stopped
  4131. currend running npc script. Running script after warp can be issue for
  4132. Gravity client if warp to other maps.
  4133.  
  4134. ---------------------------------------
  4135.  
  4136. *areawarp "<from nome do mapa>",<x1>,<y1>,<x2>,<y2>,"<to nome do mapa>",<x3>,<y3>{,<x4>,<y4>};
  4137.  
  4138. This command is similar to 'warp', however, it will not refer to the
  4139. invoking character, but instead, all characters within a specified area,
  4140. defined by the x1/y1-x2/y2 square, will be warped. Nobody outside the area
  4141. will be affected, including the activating character, if they are outside
  4142. the area.
  4143.  
  4144. areawarp "place",10,10,120,120,"place2",150,150;
  4145.  
  4146. Everyone that is in the area between X 10 Y 10 and X 120 Y 120, in a
  4147. square shape, on the map called "place", will be affected, and warped to
  4148. "place2" X 150 Y 150.
  4149.  
  4150. areawarp "place",10,10,120,120,"place2",0,0;
  4151.  
  4152. By using ,0,0; as the destination coordinates it will take all the
  4153. characters in the affected area to a random set of co-ordinates on the
  4154. "place2" map.
  4155.  
  4156. areawarp "place",10,10,120,120,"place2",150,150,200,200;
  4157.  
  4158. By using the optional x4 and y4 parameters, the destination coordinates
  4159. will be a random place within the defined x3/y3-x4/y4 square.
  4160.  
  4161. Like 'warp', areawarp will also explicitly warp characters randomly into
  4162. the current map if you give the 'to nome do mapa' as "Random".
  4163.  
  4164. See also 'warp'.
  4165.  
  4166. ---------------------------------------
  4167.  
  4168. *warpparty "<to_mapname>",<x>,<y>,<party_id>,{"<from_mapname>"};
  4169.  
  4170. Warps a party to specified map and coordinate given the party ID, which
  4171. you can get with getcharid(1). You can also request another party id given
  4172. a member's name with getcharid(1,<player_name>).
  4173.  
  4174. You can use the following "map names" for special warping behavior:
  4175. Random: All party members are randomly warped in their current map
  4176. (as if they all used a fly wing).
  4177. SavePointAll: All party members are warped to their respective save point.
  4178. SavePoint: All party members are warped to the save point of the
  4179. currently attached player (will fail if there's no player
  4180. attached).
  4181. Leader: All party members are warped to the leader's position. The
  4182. leader must be online and in the current map-server for this
  4183. to work.
  4184.  
  4185. If you specify a from_mapname, warpparty will only affect those on that
  4186. map.
  4187.  
  4188. Example:
  4189.  
  4190. mes "[Party Warper]";
  4191. mes "Here you go!";
  4192. close2;
  4193. .@id = getcharid(1);
  4194. warpparty "prontera",150,100,.@id;
  4195. close;
  4196.  
  4197. ---------------------------------------
  4198.  
  4199. *warpchar "<mapname>",<x>,<y>,<char_id>;
  4200.  
  4201. Warps another player to specified map and coordinate given the char id,
  4202. which you can get with getcharid(0,<player_name>). Obviously this is
  4203. useless if you want to warp the same player that is executing this script,
  4204. unless it's some kind of "chosen" script.
  4205.  
  4206. Example:
  4207.  
  4208. warpchar "prontera",150,100,150001;
  4209.  
  4210. ---------------------------------------
  4211.  
  4212. *warpguild "<mapname>",<x>,<y>,<guild_id>;
  4213.  
  4214. Warps a guild to specified map and coordinate given the guild id, which
  4215. you can get with getcharid(2). You can also request another guild id given
  4216. the member's name with getcharid(2,<player_name>).
  4217.  
  4218. You can use the following "map names" for special warping behavior:
  4219. Random: All guild members are randomly warped in their current map
  4220. (as if they all used a fly wing)
  4221. SavePointAll: All guild members are warped to their respective save point.
  4222. SavePoint: All guild members are warped to the save point of the
  4223. currently attached player (will fail if there's no player
  4224. attached).
  4225.  
  4226. Example:
  4227.  
  4228. warpguild "prontera",x,y,Guild_ID;
  4229.  
  4230. ---------------------------------------
  4231.  
  4232. *warppartner("<nome do mapa>",<x>,<y>);
  4233.  
  4234. This function will find the invoking character's marriage partner, if any,
  4235. and warp them to the map and coordinates given. Go kidnap that spouse. :)
  4236. It will return 1 upon success and 0 if the partner is not online, the
  4237. character is not married, or if there's no invoking character (no RID).
  4238. 0,0 will, as usual, normally translate to random coordinates.
  4239.  
  4240. ---------------------------------------
  4241.  
  4242. *savepoint "<nome do mapa>",<x>,<y>;
  4243.  
  4244. This command saves where the invoking character will return to upon
  4245. 'return to save point', if dead or in some other cases. The two versions
  4246. are equivalent. nome do mapa, X coordinate and Y coordinate should be
  4247. perfectly obvious. This ignores any and all map flags, and can make a
  4248. character respawn where no teleportation is otherwise possible.
  4249.  
  4250. savepoint "place",350,75;
  4251.  
  4252. ---------------------------------------
  4253.  
  4254. *heal <hp>,<sp>;
  4255.  
  4256. This command will heal a set amount of HP and/or SP on the invoking
  4257. character.
  4258.  
  4259. heal 30000,0; // This will heal 30,000 HP
  4260. heal 0,30000; // This will heal 30,000 SP
  4261. heal 300,300; // This will heal 300 HP and 300 SP
  4262.  
  4263. This command just alters the hit points and spell points of the invoking
  4264. character and produces no other output whatsoever.
  4265.  
  4266. ---------------------------------------
  4267.  
  4268. *itemheal <hp>,<sp>;
  4269.  
  4270. This command heals given relative amounts of HP and/or SP on the invoking
  4271. character. Unlike heal, this command is intended for use in item scripts.
  4272. It applies potion-related bonuses, such as alchemist ranking, cards,
  4273. status changes.
  4274. It also applies a sp/vit-related bonus that is calculated by:
  4275. heal = heal*[(100+STATUS*2)/100]
  4276. So if a player has 99 vit and the script is 'itemheal 5,0':
  4277. heal(hp) = 5*[(100+99*2)/100]
  4278. heal(hp) = 14,9
  4279. heal(hp) = 14
  4280. heal(sp) = 0
  4281.  
  4282. When used inside an NPC script, potion-related bonuses are omitted.
  4283.  
  4284. There is also a nice example on using this with the 'rand' function, to
  4285. give you a random amount of healing.
  4286.  
  4287. // If the player has 50 vit and no bonuses this will heal
  4288. // anything from 200 to 300 HP and 5 SP
  4289. itemheal rand(100,150),5;
  4290.  
  4291. ---------------------------------------
  4292.  
  4293. *percentheal <hp>,<sp>;
  4294.  
  4295. This command will heal the invoking character. It heals the character, but
  4296. not by a set value - it adds percent of their maximum HP/SP.
  4297.  
  4298. percentheal 100,0; // This will heal 100% HP
  4299. percentheal 0,100; // This will heal 100% SP
  4300. percentheal 50,50; // This will heal 50% HP and 50% SP
  4301.  
  4302. So the amount that this will heal will depend on the total amount of HP or
  4303. SP you have maximum. Like 'heal', this will not call up any animations or
  4304. effects.
  4305.  
  4306. ---------------------------------------
  4307.  
  4308. *recovery;
  4309.  
  4310. This command will revive and restore full HP and SP to all characters
  4311. currently connected to the server.
  4312.  
  4313. ---------------------------------------
  4314.  
  4315. *jobchange <job number>{,<upper flag>};
  4316.  
  4317. This command will change the job class of the invoking character.
  4318.  
  4319. jobchange 1; // This would change your player into a Swordman
  4320. jobchange 4002; // This would change your player into a Swordman High
  4321.  
  4322. This command does work with numbers, but you can also use job names. The
  4323. full list of job names and the numbers they correspond to can be found in
  4324. 'db/const.txt'.
  4325.  
  4326. // This would change your player into a Swordman
  4327. jobchange Job_Swordman;
  4328. // This would change your player into a Swordman High
  4329. jobchange Job_Swordman_High;
  4330.  
  4331. 'upper flag' can alternatively be used to specify the type of job one
  4332. changes to. For example, jobchange Job_Swordman,1; will change the
  4333. character to a high swordsman. The upper values are:
  4334. -1 (or when omitted): preserves the current job type.
  4335. 0: Normal/standard classes
  4336. 1: High/Advanced classes
  4337. 2: Baby classes
  4338.  
  4339. This command will also set a permanent character-based variable
  4340. 'jobchange_level' which will contain the job level at the time right
  4341. before changing jobs, which can be checked for later in scripts.
  4342.  
  4343. ---------------------------------------
  4344.  
  4345. *jobname (<job number>)
  4346.  
  4347. This command retrieves the name of the given job using the messages.conf
  4348. entries 550 to 650.
  4349.  
  4350. mes "[Kid]";
  4351. mes "I never thought I'd met a "+jobname(Class)+" here of all places.";
  4352. close;
  4353.  
  4354. ---------------------------------------
  4355.  
  4356. *eaclass ({<job number>})
  4357.  
  4358. This commands returns the "eA job-number" corresponding to the given
  4359. class, and uses the invoking player's class if none is given. The eA
  4360. job-number is also a class number system, but it's one that comes with
  4361. constants which make it easy to convert among classes. The command will
  4362. return -1 if you pass it a job number which doesn't have an eA job-number
  4363. equivalent.
  4364.  
  4365. .@eac = eaclass();
  4366. if ((.@eac&EAJ_BASEMASK) == EAJ_SWORDMAN)
  4367. mes "Your base job is Swordman.";
  4368. if (.@eac&EAJL_UPPER)
  4369. mes "You are a rebirth job.";
  4370. if ((.@eac&EAJ_UPPERMASK) == EAJ_SWORDMAN)
  4371. mes "You must be a Swordman, Baby Swordman or High Swordman.";
  4372.  
  4373. For more information on the eA Job System, see the docs/ea_job_system.txt
  4374. file.
  4375.  
  4376. ---------------------------------------
  4377. *roclass <job number> {,<gender>}
  4378.  
  4379. Does the opposite of eaclass. That is, given an eA job-number, it returns
  4380. the corresponding RO class number. A gender is required because both Bard
  4381. and Dancers share the same eA job-number (EAJ_BARDDANCER), and uses the
  4382. invoking player's gender if none is given (if no player is attached,
  4383. male will be used by default). The command will return -1 if there is no
  4384. valid class to represent the specified job (for example, if you try to get
  4385. the baby version of a Taekwon class).
  4386.  
  4387. .@eac = eaclass();
  4388. //Check if class is already rebirth
  4389. if (.@eac&EAJL_UPPER) {
  4390. mes "You look strong.";
  4391. close;
  4392. }
  4393. .@eac = roclass(.@eac|EAJL_UPPER);
  4394. //Check if class has a rebirth version
  4395. if (.@eac != -1) {
  4396. mes "Bet you can't wait to become a "+jobname(.@eac)+"!";
  4397. close;
  4398. }
  4399.  
  4400. ---------------------------------------
  4401.  
  4402. *changebase <job ID number>;
  4403.  
  4404. This command will change the appearance of the invoking character to that
  4405. of a specified job class. Nothing but appearance will change.
  4406.  
  4407. Examples:
  4408.  
  4409. /* This example is an item script in the item db */
  4410. {
  4411. Id: 2338
  4412. AegisName: "Wedding_Dress"
  4413. Name: "Wedding Dress"
  4414. Type: 5
  4415. Buy: 43000
  4416. Weight: 500
  4417. Job: 0xFFFFFFFE
  4418. Loc: 16
  4419. Script: <"
  4420. bonus bMdef,15;
  4421. changebase Job_Wedding;
  4422. ">
  4423. },
  4424.  
  4425. changebase Job_Novice; // Changes player to Novice sprite.
  4426.  
  4427. changebase Class; // Changes player back to default sprite.
  4428.  
  4429. ---------------------------------------
  4430.  
  4431. *classchange <view id>,<type>;
  4432.  
  4433. This command is very ancient, it's origins are clouded in mystery.
  4434. It will send a 'display id change' packet to everyone in the immediate
  4435. area of the NPC object, which will supposedly make the NPC look like a
  4436. different sprite, an NPC sprite ID, or a monster ID. This effect is not
  4437. stored anywhere and will not persist (Which is odd, cause it would be
  4438. relatively easy to make it do so) and most importantly, will not work at
  4439. all since this command was broken with the introduction of advanced
  4440. classes. The code is written with the assumption that the lowest sprite
  4441. IDs are the job sprites and the anything beyond them is monster and NPC
  4442. sprites, but since the advanced classes rolled in, they got the ID numbers
  4443. on the other end of the number pool where monster sprites float.
  4444.  
  4445. As a result it is currently impossible to call this command with a valid
  4446. view id. It will do nothing whatsoever if the view ID is below 4047.
  4447. Getting it to run will actually just crash the client.
  4448.  
  4449. It could be a real gem if it can be gotten to actually do what it's
  4450. supposed to do, but this will only happen in a later Git revision.
  4451.  
  4452. ---------------------------------------
  4453.  
  4454. *changesex;
  4455.  
  4456. This command will change the gender for the attached character's account.
  4457. If it was male, it will become female, if it was female, it will become
  4458. male. The change will be written to the character server, the player will
  4459. receive the message: "Need disconnection to perform change-sex request..."
  4460. and the player will be immediately kicked to the login screen. When they
  4461. log back in, they will be the opposite sex.
  4462.  
  4463. If there are any Dancer/Gypsy or Bard/Clown characters on the account,
  4464. they will also have their skills reset upon 'changesex'.
  4465.  
  4466. ---------------------------------------
  4467.  
  4468. *getexp <base xp>,<job xp>;
  4469.  
  4470. This command will give the invoking character a specified number of base
  4471. and job experience points. Should be used as a quest reward. Negative values
  4472. won't work.
  4473. Is subject to EXP bonuses and to the `quest_exp_rate` config option.
  4474.  
  4475. getexp 10000,5000;
  4476.  
  4477. You can also assign directly to the parameters defined in 'db/const.txt':
  4478.  
  4479. BaseExp += 10000;
  4480. JobExp += 5000;
  4481.  
  4482. You can also reduce the amount of experience points:
  4483.  
  4484. BaseExp -= 10000;
  4485.  
  4486. When setting the parameters directly no bonuses or config options are applied.
  4487.  
  4488. ---------------------------------------
  4489.  
  4490. *setlook <look type>,<look value>;
  4491. *changelook <look type>,<look value>;
  4492.  
  4493. 'setlook' will alter the look data for the invoking character. It is used
  4494. mainly for changing the palette used on hair and clothes: you specify
  4495. which look type you want to change, then the palette you want to use. Make
  4496. sure you specify a palette number that exists/is usable by the client you
  4497. use. 'changelook' works the same, but is only client side (it doesn't save
  4498. the look value).
  4499.  
  4500. // This will change your hair(6), so that it uses palette 8, what ever
  4501. // your palette 8 is, your hair will use that color.
  4502.  
  4503. setlook VAR_HEADPALETTE, 8;
  4504.  
  4505. // This will change your clothes(7), so they are using palette 1,
  4506. // whatever your palette 1 is, your clothes will then use that set of
  4507. // colors.
  4508.  
  4509. setlook VAR_BODYPALETTE,1;
  4510.  
  4511. Here are the possible look types:
  4512.  
  4513. 0 - LOOK_BASE Base sprite
  4514. 1 - LOOK_HAIR Hairstyle
  4515. 2 - LOOK_WEAPON Weapon
  4516. 3 - LOOK_HEAD_BOTTOM Head bottom
  4517. 4 - LOOK_HEAD_TOP Head top
  4518. 5 - LOOK_HEAD_MID Head mid
  4519. 6 - LOOK_HAIR_COLOR Hair color
  4520. 7 - LOOK_CLOTHES_COLOR Clothes color
  4521. 8 - LOOK_SHIELD Shield
  4522. 9 - LOOK_SHOES Shoes
  4523. 10 - LOOK_BODY Body(N/A)
  4524. 11 - LOOK_FLOOR FLOOR(N/A)
  4525. 12 - LOOK_ROBE Robe
  4526.  
  4527. Whatever 'shoes' means is anyone's guess, ask Gravity - the client does
  4528. nothing with this value. It still wants it from the server though, so it
  4529. is kept, but normally doesn't do a thing.
  4530.  
  4531. Only the look data for hairstyle, hair color and clothes color are saved
  4532. to the char server's database and will persist. The rest freely change as
  4533. the character puts on and removes equipment, changes maps, logs in and out
  4534. and otherwise you should not expect to set them. In fact, messing with
  4535. them is generally hazardous, do it at your own risk, it is not tested
  4536. what will this actually do - it won't cause database corruption and
  4537. probably won't cause a server crash, but it's easy to crash the client
  4538. with just about anything unusual.
  4539.  
  4540. However, it might be an easy way to quickly check for empty view IDs for
  4541. sprites, which is essential for making custom headgear.
  4542.  
  4543. Since a lot of people have different palettes for hair and clothes, it's
  4544. impossible to tell you what all the color numbers are. If you want a
  4545. serious example, there is a Stylist script inside the default Cronus
  4546. installation that you can look at: 'npc/custom/stylist.txt'
  4547.  
  4548. ---------------------------------------
  4549.  
  4550. *pushpc <direction>,<cells>;
  4551.  
  4552. This command will push the currently attached player to given direction by
  4553. given amount of square cells. Direction is the same as used when declaring
  4554. NPCs, and can be specified by using one of the DIR_* constants
  4555. (db/const.txt).
  4556.  
  4557. The knock-back is not restricted by items or map flags, only obstacles are
  4558. taken into account. If there is not enough space to perform the push (e.g.
  4559. due to a wall), the character is pushed only up to the obstacle.
  4560.  
  4561. // pushes the character 5 cells in 3 o'clock direction from it's
  4562. // current position.
  4563. pushpc DIR_EAST, 5;
  4564.  
  4565. ---------------------------------------
  4566.  
  4567. *get_version()
  4568.  
  4569. This command will return the SVN revision number or Git SHA-1 hash the
  4570. server is currently running on (depends on whether you used a SVN or Git
  4571. client for getting Cronus).
  4572.  
  4573. if ( get_version() >= 15000 )
  4574. mes "Welcome to Cronus!";
  4575.  
  4576. ---------------------------------------
  4577.  
  4578. *montransform <monster id>,<duration>{,<sc_type>{,<val1>{,<val2>{,<val3>{,<val4>}}}}};
  4579. *montransform "<monster name>",<duration>{,<sc_type>{,<val1>{,<val2>{,<val3>{,<val4>}}}}};
  4580.  
  4581. This command can transform your character into monster and you can still
  4582. use all your skills like a normal character.
  4583. Can only be removed when your killed or if you die or if duration is over.
  4584.  
  4585. for sc_type,val1,val2,val3,val4, see 'sc_start','sc_start2','sc_start4' commands.
  4586.  
  4587. ---------------------------------------
  4588. //=====================================
  4589. 4.1 - Player Item-Related Commands
  4590. //=====================================
  4591. ---------------------------------------
  4592.  
  4593. *getitem <item id>,<amount>{,<account ID>};
  4594. *getitem "<item name>",<amount>{,<account ID>};
  4595.  
  4596. This command will give a specific amount of specified items to the target
  4597. character. If the character is not online, nothing will happen.
  4598. If <account ID> is not specified, items will be created in the invoking
  4599. character inventory instead.
  4600.  
  4601. In the first and most commonly used version of this command, items are
  4602. referred to by their database ID number found in 'db/(pre-)re/item_db.txt'.
  4603.  
  4604. getitem 502,10 // The person will receive 10 apples
  4605. getitem 617,1 // The person will receive 1 Old Violet Box
  4606.  
  4607. Giving an item ID of -1 will give a specified number of random items from
  4608. the list of those that fall out of Old Blue Box. Unlike in all other
  4609. cases, these will be unidentified, if they turn out to be equipment. This
  4610. is exactly what's written in the Old Blue Box's item script.
  4611.  
  4612. Other negative IDs also correspond to other random item generating item
  4613. tables:
  4614.  
  4615. Giving an item ID of -2 will produce the effects of Old Violet Box.
  4616. Giving an item ID of -3 will produce the effects of Old Card Album.
  4617. Giving an item ID of -4 will produce the effects of Gift Box.
  4618. Giving an item ID of -5 will produce the effects of Worn Out Scroll,
  4619. which, in current Git, drops only Jellopies anyway.
  4620.  
  4621. This transaction is logged if the log script generated transactions option
  4622. is enabled.
  4623.  
  4624. You may also create an item by it's name in the 'english name' field in
  4625. the item database:
  4626.  
  4627. getitem "RED_POTION",10;
  4628.  
  4629. Which will do what you'd expect. If it can't find that name in the
  4630. database, apples will be created anyway. It is often a VERY GOOD IDEA to
  4631. use it like this.
  4632.  
  4633. This is used in pretty much all NPC scripts that have to do with items and
  4634. quite a few item scripts. For more examples check just about any official
  4635. script.
  4636.  
  4637. ---------------------------------------
  4638.  
  4639. *getitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
  4640. *getitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
  4641.  
  4642. This command will give an amount of specified items to the invoking
  4643. character. If an optional account ID is specified, and the target
  4644. character is currently online, items will be created in their inventory
  4645. instead. If they are not online, nothing will happen. It works essentially
  4646. the same as 'getitem' (it even works for negative ID numbers the same way)
  4647. but is a lot more flexible.
  4648.  
  4649. Those parameters that are different from 'getitem' are:
  4650.  
  4651. identify - Whether you want the item to be identified (1) or not (0).
  4652. refine - For how many pluses will it be refined. It will not let you
  4653. refine an item higher than the max refine.
  4654. attribute - Whether the item is broken (1) or not (0).
  4655. card1,2,3,4 - If you want a card compound to it, place the card ID number
  4656. into the specific card slot.
  4657.  
  4658. Card1-card4 values are also used to store name information for named
  4659. items, as well as the elemental property of weapons and armor. You can
  4660. create a named item in this manner, however, if you just need a named
  4661. piece of standard equipment, it is much easier to the 'getnameditem'
  4662. function instead.
  4663.  
  4664. You will need to keep these values if you want to destroy and then
  4665. perfectly recreate a named item, for this see 'getinventorylist'.
  4666.  
  4667. If you still want to try creating a named item with this command because
  4668. 'getnameditem' won't do it for you cause it's too limited, you can do it
  4669. like this. Careful, minor magic ahead.
  4670.  
  4671. // First, let's get an ID of a character who's name will be on the
  4672. // item. Only an existing character's name may be there.
  4673. // Let's assume our character is 'Adam' and find his ID.
  4674.  
  4675. .@charid = getcharid(0,"Adam");
  4676.  
  4677. // Now we split the character ID number into two portions with a
  4678. // binary shift operation. If you don't understand what this does,
  4679. // just copy it.
  4680.  
  4681. .@card3 = .@charid & 65535;
  4682. .@card4 = .@charid >> 16;
  4683.  
  4684. // If you're inscribing non-equipment, .@card1 must be 254.
  4685. // Arrows are also not equipment. :)
  4686. .@card1 = 254;
  4687.  
  4688. // For named equipment, card2 means the Star Crumbs and elemental
  4689. // crystals used to make this equipment. For everything else, it's 0.
  4690.  
  4691. .@card2 = 0;
  4692.  
  4693. // Now, let's give the character who invoked the script some
  4694. // Adam's Apples:
  4695.  
  4696. getitem2 512,1,1,0,0,.@card1,.@card2,.@card3,.@card4;
  4697.  
  4698. This wasn't tested with all possible items, so I can't give any promises,
  4699. experiment first before relying on it.
  4700.  
  4701. To create equipment, continue this example it like this:
  4702.  
  4703. // We've already have card3 and card4 loaded with correct
  4704. // values so we'll just set up card1 and card2 with data
  4705. // for an Ice Stiletto.
  4706.  
  4707. // If you're inscribing equipment, .@card1 must be 255.
  4708. .@card1 = 255;
  4709.  
  4710. // That's the number of star crumbs in a weapon.
  4711. .@sc = 2;
  4712.  
  4713. // That's the number of elemental property of the weapon.
  4714. .@ele = 1;
  4715.  
  4716. // And that's the wacky formula that makes them into
  4717. // a single number.
  4718. .@card2 = .@ele+((.@sc*5)<<8);
  4719.  
  4720. // That will make us an Adam's +2 VVS Ice Stiletto:
  4721.  
  4722. getitem2 1216,1,1,2,0,.@card1,.@card2,.@card3,.@card4;
  4723.  
  4724. Experiment with the number of star crumbs - I'm not certain just how much
  4725. will work most and what it depends on. The valid element numbers are:
  4726.  
  4727. 1 - Ice, 2 - Earth 3 - Fire 4 - Wind.
  4728.  
  4729. You can, apparently, even create duplicates of the same pet egg with this
  4730. command, creating a pet which is the same, but simultaneously exists in
  4731. two eggs, and may hatch from either, although, I'm not sure what kind of a
  4732. mess will this really cause.
  4733.  
  4734. ---------------------------------------
  4735. *getitembound <item id>,<amount>,<bound type>{,<account ID>};
  4736. *getitembound "<item name>",<amount>,<bound type>{,<account ID>};
  4737.  
  4738. This command behaves identically to 'getitem', but the items created will be
  4739. bound to the target character as specified by the bound type. All items created
  4740. in this manner cannot be dropped, sold, vended, auctioned, or mailed, and in
  4741. some cases cannot be traded or stored.
  4742.  
  4743. Valid bound types are:
  4744. 1 - Account Bound
  4745. 2 - Guild Bound
  4746. 3 - Party Bound
  4747. 4 - Character Bound
  4748.  
  4749. ---------------------------------------
  4750.  
  4751. *getitembound2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<bound type>;
  4752. *getitembound2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<bound type>;
  4753.  
  4754. This command behaves identically to 'getitem2', but the items created will be
  4755. bound to the target character as specified by the bound type. All items created
  4756. in this manner cannot be dropped, sold, vended, auctioned, or mailed, and in
  4757. some cases cannot be traded or stored.
  4758.  
  4759. For a list of bound types see 'getitembound'.
  4760.  
  4761. ---------------------------------------
  4762.  
  4763. *countbound({<bound type>})
  4764.  
  4765. This function will return the number of bounded items in the character's
  4766. inventory, and sets an array @bound_items[] containing all item IDs of the
  4767. counted items. If a bound type is specified, only those items will be counted.
  4768.  
  4769. For a list of bound types see 'getitembound'.
  4770.  
  4771. Example:
  4772. mes "You currently have "+countbound()+" bounded items.";
  4773. next;
  4774. mes "The list of bounded items include:";
  4775. for (.@i = 0; .@i < getarraysize(@bound_items); ++.@i)
  4776. mes getitemname(@bound_items[.@i]);
  4777. close;
  4778.  
  4779. ---------------------------------------
  4780.  
  4781. *checkbound(<item_id>{,<bound_type>{,<refine>{,<attribute>{,<card_1>{,<card_2>{,<card_3>{,<card_4>}}}}}}});
  4782.  
  4783. This command allows you to check whether or not the attached player has the specified bound item in their inventory.
  4784. If a bound type is not specified or a bound type of 0 is used, it will search the player's inventory for a bound item
  4785. of any type, so long as the other parameters match. In all cases, this command will return the bound type of the
  4786. item found, or 0 if the specified item was not found.
  4787.  
  4788. Valid bound types are:
  4789. 0 - All Bound types.
  4790. 1 - Account Bound
  4791. 2 - Guild Bound
  4792. 3 - Party Bound
  4793. 4 - Character Bound
  4794.  
  4795. Optional Parameters:
  4796. bound_type - checks to see if the item has the specified bound type.
  4797. refine - checks to see if the item is refined to the given number.
  4798. attribute - whether the item is broken (1) or not (0).
  4799. card 1,2,3,4 - checks to see if the specified cards are compounded on the item as well.
  4800.  
  4801. Example:
  4802. // This will check if you have a bound (any type) 1205 (Cutter).
  4803. if (checkbound(1205)) {
  4804. mes "You have a bound Cutter";
  4805. } else {
  4806. mes "You do not have a bound Cutter";
  4807. }
  4808. close;
  4809.  
  4810. // This will also check if you have a bound (any type) 1205 (Cutter).
  4811. if (checkbound(1205,0)) {
  4812. mes "You have a bound Cutter";
  4813. } else {
  4814. mes "You do not have a bound Cutter";
  4815. }
  4816. close;
  4817.  
  4818. // This will check if the player doesn't have a bound 1205 (Cutter).
  4819. if (!checkbound(1205)) {
  4820. mes "You do not have a bound Cutter";
  4821. } else {
  4822. mes "You do have a bound Cutter";
  4823. }
  4824. close;
  4825.  
  4826. // This will check if the item found, has a bound type of 2 (guild_bound)
  4827. if (checkbound(1205) == 2) {
  4828. mes "You have a guild_bound Cutter";
  4829. } else {
  4830. mes "You do not have a guild_bound Cutter.";
  4831. }
  4832. close;
  4833.  
  4834. // This will check if you have a 'guild_bound' +7 1205 (Cutter).
  4835. if (checkbound(1205, 2, 7)) {
  4836. mes "You have a +7 guild_bound Cutter.";
  4837. } else {
  4838. mes "You don't have the required item.";
  4839. }
  4840. close;
  4841. ---------------------------------------
  4842.  
  4843. *getnameditem <item id>,<character name|character ID>;
  4844. *getnameditem "<item name>",<character name|character ID>;
  4845.  
  4846. Create an item signed with the given character's name.
  4847.  
  4848. The command returns 1 when the item is created successfully, or 0 if it
  4849. fails. Failure occurs when:
  4850. - There is no player attached.
  4851. - Item name or ID is not valid.
  4852. - The given character ID/name is offline.
  4853.  
  4854. Example:
  4855.  
  4856. //This will give the currently attached player a Aaron's Apple (if Aaron
  4857. //is online).
  4858. getnameditem "Apple","Aaron";
  4859.  
  4860. //Self-explanatory (I hope).
  4861. if (getnameitem("Apple","Aaron")) {
  4862. mes "You now have a Aaron's Apple!";
  4863. }
  4864.  
  4865. ---------------------------------------
  4866.  
  4867. *rentitem <item id>,<time>;
  4868. *rentitem "<item name>",<time>;
  4869.  
  4870. Creates a rental item in the attached character's inventory. The item will
  4871. expire in <time> seconds and be automatically deleted. When receiving a
  4872. rental item, the character will receive a message in their chat window.
  4873. The character will also receive warning messages in their chat window
  4874. before the item disappears.
  4875.  
  4876. This command can not be used to rent stackable items. Rental items cannot
  4877. be dropped, traded, sold to NPCs, or placed in guild storage (i.e. trade
  4878. mask 75).
  4879. Note: 'delitem' in an NPC script can still remove rental items.
  4880.  
  4881. ---------------------------------------
  4882.  
  4883. *makeitem <item id>,<amount>,"<nome do mapa>",<X>,<Y>;
  4884. *makeitem "<item name>",<amount>,"<nome do mapa>",<X>,<Y>;
  4885.  
  4886. This command will create an item lying around on a specified map in the
  4887. specified location.
  4888.  
  4889. itemid - Found in 'db/(pre-)re/item_db.txt'
  4890. amount - Amount you want produced
  4891. nome do mapa - The nome do mapa
  4892. X - The X coordinate
  4893. Y - The Y coordinate.
  4894.  
  4895. This item will still disappear just like any other dropped item. Like
  4896. 'getitem', it also accepts an 'english name' field from the database and
  4897. creates apples if the name isn't found.
  4898. If the nome do mapa is given as "this", the map the invoking character is on
  4899. will be used.
  4900.  
  4901. ---------------------------------------
  4902.  
  4903. *cleanarea "<nome do mapa>",<x1>,<y1>,<x2>,<y2>;
  4904. *cleanmap "<nome do mapa>";
  4905.  
  4906. These commands will clear all items lying on the ground on the specified
  4907. map, either within the x1/y1-x2/y2 rectangle or across the entire map.
  4908.  
  4909. ---------------------------------------
  4910.  
  4911. *searchitem <array name>,"<item name>";
  4912.  
  4913. This command will fill the given array with the ID of items whose name
  4914. matches the given one. It returns the number of items found. For
  4915. performance reasons, the results array is limited to 10 items.
  4916.  
  4917. mes "What item are you looking for?";
  4918. input .@name$;
  4919. .@qty = searchitem(.@matches[0],.@name$);
  4920. mes "I found "+.@qty+" items:";
  4921. for (.@i = 0; .@i < .@qty; ++.@i)
  4922. //Display name (eg: "Apple[0]")
  4923. mes getitemname(.@matches[.@i])+"["+getitemslots(.@matches[.@i])+"]";
  4924.  
  4925. ---------------------------------------
  4926.  
  4927. *delitem <item id>,<amount>{,<account ID>};
  4928. *delitem "<item name>",<amount>{,<account ID>};
  4929.  
  4930. This command will remove a specified amount of items from the invoking or
  4931. target character. Like all the item commands, it uses the item ID found
  4932. inside 'db/(pre-)re/item_db.txt'.
  4933.  
  4934. delitem 502,10; // The person will lose 10 apples
  4935. delitem 617,1; // The person will lose 1 Old Violet Box
  4936.  
  4937. It is always a good idea to check if the player actually has the items
  4938. before you delete them. If you try to delete more items that the player
  4939. has, the player will lose the ones he/she has and the script will be
  4940. terminated with an error.
  4941.  
  4942. Like 'getitem' this command will also accept an 'english name' field from
  4943. the database. If the name is not found, nothing will be deleted.
  4944.  
  4945. ---------------------------------------
  4946.  
  4947. *delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
  4948. *delitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
  4949.  
  4950. This command will remove a specified amount of items from the invoking or
  4951. target character.
  4952. Check 'getitem2' to understand its expanded parameters.
  4953.  
  4954. ---------------------------------------
  4955.  
  4956. *countitem(<item id>)
  4957. *countitem("<item name>")
  4958.  
  4959. This function will return the number of items for the specified item ID
  4960. that the invoking character has in the inventory.
  4961.  
  4962. mes "[Item Checker]";
  4963. mes "Hmmm, it seems you have "+countitem(502)+" apples";
  4964. close;
  4965.  
  4966. Like 'getitem', this function will also accept an 'english name' from the
  4967. database as an argument.
  4968.  
  4969. If you want to state the number at the end of a sentence, you can do it by
  4970. adding up strings:
  4971.  
  4972. mes "[Item Checker]";
  4973. mes "Hmmm, the total number of apples you are holding is "+countitem("APPLE");
  4974. close;
  4975.  
  4976. ---------------------------------------
  4977.  
  4978. *countitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
  4979. *countitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
  4980.  
  4981. Expanded version of 'countitem' function, used for created/carded/forged
  4982. items.
  4983.  
  4984. This function will return the number of items for the specified item ID
  4985. and other parameters that the invoking character has in the inventory.
  4986. Check 'getitem2' to understand the arguments of the function.
  4987.  
  4988. ---------------------------------------
  4989.  
  4990. *groupranditem <item_id/constant>;
  4991.  
  4992. Returns the item_id of a random item picked from the item container specified. There
  4993. are different item containers and they are specified in 'db/(pre-)re/item_group.conf'.
  4994.  
  4995. Example:
  4996. getitem groupranditem 603,1;
  4997. getitem groupranditem Old_Blue_Box,1;
  4998.  
  4999. ---------------------------------------
  5000.  
  5001. *getrandgroupitem <item_id/constant>,<quantity>;
  5002.  
  5003. Similar to the above example, this command allows players to obtain the specified
  5004. quantity of a random item from the container. The different containers
  5005. are specified in 'db/(pre-)re/item_group.conf'.
  5006.  
  5007. Example:
  5008. getrandgroupitem Old_Blue_Box,1;
  5009. getrandgroupitem 603,1;
  5010.  
  5011. ---------------------------------------
  5012.  
  5013. *packageitem
  5014.  
  5015. This command has only 1 param which is optional. If the package item_id is not provided, it
  5016. will try to use the item id from the item it is being used from (if called from an item script).
  5017. It runs a item package and grants the items accordingly to the attached player.
  5018.  
  5019. Example:
  5020.  
  5021. /* This example is an item script from the item db */
  5022. {
  5023. Id: 12477
  5024. AegisName: "Gift_Bundle"
  5025. Name: "Gift Bundle"
  5026. Type: 2
  5027. Buy: 0
  5028. Script: <" packageitem(); ">
  5029. },
  5030.  
  5031. ---------------------------------------
  5032.  
  5033. *enable_items;
  5034. *disable_items;
  5035.  
  5036. These commands enable/disable changing of equipments while an NPC is
  5037. running. When disable_items is run, equipments cannot be changed during
  5038. scripts until enable_items is called or the script has terminated. To
  5039. avoid possible exploits, when disable_items is invoked, it will only
  5040. disable changing equips while running that script in particular. Note that
  5041. if a different script also calls disable_items, it will override the last
  5042. call (so you may want to call this command at the start of your script
  5043. without assuming the effect is still in effect).
  5044. If 'item_enabled_npc' option is set to Yes in 'items.conf' all NPC are
  5045. allowing changing of equipment by default except for those have been set
  5046. with 'disable_items'.
  5047.  
  5048. ---------------------------------------
  5049.  
  5050. *itemskill <skill id>,<skill level>,{flag};
  5051. *itemskill "<skill name>",<skill level>,{flag};
  5052.  
  5053. This command meant for item scripts to replicate single-use skills in
  5054. usable items. It will not work properly if there is a visible dialog
  5055. window or menu.
  5056. If the skill is self or auto-targeting, it will be used immediately.
  5057. Otherwise, a target cursor is shown.
  5058. Flag is a optional param and, when present, the command will not check for
  5059. skill requirements.
  5060.  
  5061. // When Anodyne is used, it will cast Endure (8), Level 1, as if the
  5062. // actual skill has been used from skill tree.
  5063. 605,Anodyne,Anodyne,11,2000,0,100,,,,,10477567,2,,,,,{ itemskill 8,1; },{}
  5064.  
  5065. ---------------------------------------
  5066.  
  5067. *itemeffect <item id>;
  5068. *itemeffect "<item name>";
  5069. *consumeitem is an alias of itemeffect (added for compatibility)
  5070.  
  5071. This command will run the item script of the specified item on the
  5072. invoking character. The character does not need to posess the item, and
  5073. the item will not be deleted. While this command is intended for usable
  5074. items, it will run for any item type.
  5075.  
  5076. ---------------------------------------
  5077.  
  5078. *produce <item level>;
  5079.  
  5080. This command will open a crafting window on the client connected to the
  5081. invoking character. The 'item level' is a number which determines what
  5082. kind of a crafting window will pop-up.
  5083.  
  5084. You can see the full list of such item levels in 'db/produce_db.txt' which
  5085. determines what can actually be produced. The window will not be empty
  5086. only if the invoking character can actually produce the items of that type
  5087. and has the appropriate raw materials in their inventory.
  5088.  
  5089. The success rate to produce the item is the same as the success rate of
  5090. the skill associated with the item level. If there is no skill id, the
  5091. success rate will be 50%.
  5092.  
  5093. Valid item levels are:
  5094.  
  5095. 1 - Level 1 Weapons
  5096. 2 - Level 2 Weapons
  5097. 3 - Level 3 Weapons
  5098. 21 - Blacksmith's Stones and Metals
  5099. 22 - Alchemist's Potions, Holy Water, Assassin Cross's Deadly Poison
  5100. 23 - Elemental Converters
  5101.  
  5102. ---------------------------------------
  5103.  
  5104. *cooking <dish level>;
  5105.  
  5106. This command will open a produce window on the client connected to the
  5107. invoking character. The 'dish level' is the number which determines what
  5108. kind of dish level you can produce. You can see the full list of dishes
  5109. that can be produced in 'db/produce_db.txt'.
  5110.  
  5111. The window will be shown empty if the invoking character does not have
  5112. enough of the required incredients to cook a dish.
  5113.  
  5114. Valid dish levels are:
  5115.  
  5116. 11 - Level 1 Dish
  5117. 12 - Level 2 Dish
  5118. 13 - Level 3 Dish
  5119. 14 - Level 4 Dish
  5120. 15 - Level 5 Dish
  5121. 16 - Level 6 Dish
  5122. 17 - Level 7 Dish
  5123. 18 - Level 8 Dish
  5124. 19 - Level 9 Dish
  5125. 20 - Level 10 Dish
  5126.  
  5127. Although it's required to set a dish level, it doesn't matter if you set
  5128. it to 1 and you want to cook a level 10 dish, as long as you got the
  5129. required ingredients to cook the dish the command works.
  5130.  
  5131. ---------------------------------------
  5132.  
  5133. *makerune <% success bonus>;
  5134.  
  5135. This command will open a rune crafting window on the client connected to
  5136. the invoking character. Since this command is officially used in rune
  5137. ores, a bonus success rate must be specified (which adds to the base
  5138. formula).
  5139.  
  5140. You can see the full list of runes that can be produced in
  5141. 'db/produce_db.txt'. The window will not be empty only if the invoking
  5142. character can actually produce a rune and has the appropriate raw
  5143. materials in their inventory.
  5144.  
  5145. ---------------------------------------
  5146.  
  5147. *successremovecards <equipment slot>;
  5148.  
  5149. This command will remove all cards from the item found in the specified
  5150. equipment slot of the invoking character, create new card items and give
  5151. them to the character. If any cards were removed in this manner, it will
  5152. also show a success effect.
  5153.  
  5154. ---------------------------------------
  5155.  
  5156. *failedremovecards <equipment slot>,<type>;
  5157.  
  5158. This command will remove all cards from the item found in the specified
  5159. equipment slot of the invoking character. 'type' determines what happens
  5160. to the item and the cards:
  5161.  
  5162. 0 - will destroy both the item and the cards.
  5163. 1 - will keep the item, but destroy the cards.
  5164. 2 - will keep the cards, but destroy the item.
  5165.  
  5166. Whatever the type is, it will also show a failure effect on screen.
  5167.  
  5168. ---------------------------------------
  5169.  
  5170. *repair <broken item number>;
  5171.  
  5172. This command repairs a broken piece of equipment, using the same list of
  5173. broken items as available through 'getbrokenid'.
  5174.  
  5175. The official scripts seem to use the repair command as a function instead:
  5176. 'repair(<number>)' but it returns nothing on the stack. Probably only
  5177. Valaris, who made it, can answer why is it so.
  5178.  
  5179. ---------------------------------------
  5180.  
  5181. *repairall;
  5182.  
  5183. This command repairs all broken equipment in the attached player's
  5184. inventory. A repair effect will be shown if any items are repaired, else
  5185. the command will end silently.
  5186.  
  5187. ---------------------------------------
  5188.  
  5189. *successrefitem <equipment slot>{,<upgrade_count>};
  5190.  
  5191. This command will refine an item in the specified equipment slot of the
  5192. invoking character by +1 (unless <upgrade_count> is specified).
  5193. For a list of equipment slots see 'getequipid'.
  5194. This command will also display a 'refine success'
  5195. effect on the character and put appropriate messages into their chat
  5196. window. It will also give the character fame points if a weapon reached
  5197. +10 this way, even though these will only take effect for blacksmith who
  5198. will later forge a weapon.
  5199.  
  5200. ---------------------------------------
  5201.  
  5202. *failedrefitem <equipment slot>;
  5203.  
  5204. This command will fail to refine an item in the specified equipment slot
  5205. of the invoking character. The item will be destroyed. This will also
  5206. display a 'refine failure' effect on the character and put appropriate
  5207. messages into their chat window.
  5208.  
  5209. ---------------------------------------
  5210.  
  5211. *downrefitem <equipment slot>{,<downgrade_count>};
  5212.  
  5213. This command will downgrade an item by - 1 (unless optional <downgrade_count> is provided)
  5214. in the specified equipment slot of the invoking character.
  5215. So the item will not be destroyed unlike in the
  5216. failedrefitem script command. This will also display a 'refine failure'
  5217. effect on the character and put appropriate messages into their chat
  5218. window.
  5219.  
  5220. ---------------------------------------
  5221.  
  5222. *unequip <equipment slot>;
  5223.  
  5224. This command will unequip whatever is currently equipped in the invoking
  5225. character's specified equipment slot. For a full list of possible
  5226. equipment slots see 'getequipid'.
  5227.  
  5228. If an item occupies several equipment slots, it will get unequipped from
  5229. all of them.
  5230.  
  5231. ---------------------------------------
  5232.  
  5233. *clearitem;
  5234.  
  5235. This command will destroy all items the invoking character has in their
  5236. inventory (including equipped items). It will not affect anything else,
  5237. like storage or cart.
  5238.  
  5239. ---------------------------------------
  5240.  
  5241. *equip <item id>;
  5242. *equip2 <item id>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
  5243. *autoequip <item id>,<option>;
  5244.  
  5245. These commands are to equip a equipment on the attached character.
  5246. The equip function will equip the item ID given when the player has this
  5247. item in his/her inventory, while the autoequip function will equip the
  5248. given item ID when this is looted. The option parameter of the autoequip
  5249. is 1 or 0, 1 to turn it on, and 0 to turn it off.
  5250.  
  5251. Examples:
  5252.  
  5253. //This will equip a 1104 (falchion) on the character if this is in the
  5254. //inventory.
  5255. equip 1104;
  5256.  
  5257. //This will equip a +10 1104 (falchion) on the character if this is in the
  5258. //inventory.
  5259. equip2 1104,10,0,0,0,0,0;
  5260.  
  5261. //The invoked character will now automatically equip a falchion when it's
  5262. //looted.
  5263. autoequip 1104,1;
  5264.  
  5265. //The invoked character will no longer automatically equip a falchion.
  5266. autoequip 1104,0;
  5267.  
  5268. ---------------------------------------
  5269.  
  5270. *buyingstore <slots>;
  5271.  
  5272. Invokes buying store preparation window like the skill 'Open Buying
  5273. Store', without the item requirement. Amount of slots is limited by the
  5274. server to a maximum of 5 slots by default.
  5275.  
  5276. Example:
  5277.  
  5278. // Gives the player opportunity to buy 4 different kinds of items.
  5279. buyingstore 4;
  5280.  
  5281. ---------------------------------------
  5282.  
  5283. *searchstores <uses>,<effect>;
  5284.  
  5285. Invokes the store search window, which allows to search for both vending
  5286. and buying stores. Parameter uses indicates, how many searches can be
  5287. started, before the window has to be reopened. Effect value affects what
  5288. happens when a result item is double-clicked and can be one of the
  5289. following:
  5290.  
  5291. 0 = Shows the store's position on the mini-map and highlights the shop
  5292. sign with yellow color, when the store is on same map as the
  5293. invoking player.
  5294. 1 = Directly opens the shop, regardless of distance.
  5295.  
  5296. Example:
  5297.  
  5298. // Item Universal_Catalog_Gold (10 uses, effect: open shop)
  5299. searchstores 10,1;
  5300.  
  5301. ---------------------------------------
  5302.  
  5303. *delequip <equipment slot>;
  5304.  
  5305. This command will destroy whatever is currently equipped in the invoking
  5306. character's specified equipment slot. For a full list of possible equipment
  5307. slots see 'getequipid'.
  5308.  
  5309. It is always a good idea to check if the player actually has the item you want
  5310. before you use this command. If you try to delete in a position that the player
  5311. has no gear, script will be terminated with an error.
  5312.  
  5313. ---------------------------------------
  5314. //=====================================
  5315. 4.1 - End of Player Item-Related Commands
  5316. //=====================================
  5317. ---------------------------------------
  5318.  
  5319. *openstorage;
  5320.  
  5321. This will open character's Kafra storage window on the client connected to
  5322. the invoking character. It can be used from any kind of NPC or item
  5323. script, not just limited to Kafra Staff.
  5324.  
  5325. The storage window opens regardless of whether there are open NPC dialogs
  5326. or not, but it is preferred to close the dialog before displaying the
  5327. storage window, to avoid any disruption when both windows overlap.
  5328.  
  5329. mes "I will now open your stash for you";
  5330. close2;
  5331. openstorage;
  5332. end;
  5333.  
  5334. ---------------------------------------
  5335.  
  5336. *openmail;
  5337.  
  5338. This will open a character's Mail window on the client connected to the
  5339. invoking character.
  5340.  
  5341. mes "Close this window to open your mail inbox.";
  5342. close2;
  5343. openmail;
  5344. end;
  5345.  
  5346. ---------------------------------------
  5347.  
  5348. *openauction;
  5349.  
  5350. This will open the Auction window on the client connected to the invoking
  5351. character.
  5352.  
  5353. mes "Close this window to open the Auction window.";
  5354. close2;
  5355. openauction;
  5356. end;
  5357.  
  5358. ---------------------------------------
  5359. //=====================================
  5360. 4.2 - Guild-Related Commands
  5361. //=====================================
  5362. ---------------------------------------
  5363.  
  5364. *guildopenstorage()
  5365.  
  5366. This function works the same as 'openstorage' but will open a guild
  5367. storage window instead for the guild storage of the guild the invoking
  5368. character belongs to. This is a function because it returns a value - 0 if
  5369. the guild storage was opened successfully and 1 if it wasn't. (Notice,
  5370. it's a ZERO upon success.)
  5371. Since guild storage is only accessible to one character at one time, it
  5372. may fail if another character is accessing the guild storage at the same
  5373. time.
  5374.  
  5375. This will also fail and return 2 if the attached character does not belong
  5376. to any guild.
  5377.  
  5378. ---------------------------------------
  5379.  
  5380. *guildchangegm(<guild id>,<new master's name>)
  5381.  
  5382. This function will change the Guild Master of a guild. The ID is the
  5383. guild's id, and the new guild master's name must be passed.
  5384.  
  5385. Returns 1 on success, 0 otherwise.
  5386.  
  5387. ---------------------------------------
  5388.  
  5389. *guildgetexp <amount>;
  5390.  
  5391. This will give the specified amount of guild experience points to the
  5392. guild the invoking character belongs to. It will silently fail if they do
  5393. not belong to any guild.
  5394.  
  5395. ---------------------------------------
  5396.  
  5397. *guildskill <skill id>,<level>
  5398. *guildskill "<skill name>",<level>
  5399.  
  5400. This command will bump up the specified guild skill by the specified
  5401. number of levels. This refers to the invoking character and will only work
  5402. if the invoking character is a member of a guild AND it's guild master,
  5403. otherwise no failure message will be given and no error will occur, but
  5404. nothing will happen. The full list of guild skills is available in
  5405. 'db/(pre-)re/skill_db.txt', these are all the GD_ skills at the end.
  5406. If a level higher than the maximum is given as parameter the skill will be
  5407. leveled to the maximum and not above.
  5408.  
  5409. // This would give your character's guild one level of Approval
  5410. // (GD_APPROVAL ID 10000). Notice that if you try to add two levels of
  5411. // Approval, or add Approval when the guild already has it, it will only
  5412. // have one level of Approval afterwards.
  5413. guildskill 10000,1;
  5414.  
  5415. You might want to make a quest for getting a certain guild skill, make it
  5416. hard enough that all the guild needs to help or something. Doing this for
  5417. the Glory of the Guild skill, which allows your guild to use an emblem, is
  5418. a good idea for a fun quest. (Wasting a level point on that is really
  5419. annoying :D)
  5420.  
  5421. ---------------------------------------
  5422. //=====================================
  5423. 4.2 - End of Guild-Related Commands
  5424. //=====================================
  5425. ---------------------------------------
  5426.  
  5427. *resetlvl <action type>;
  5428.  
  5429. This is a character reset command, meant mostly for rebirth script
  5430. supporting Advanced jobs, which will reset the invoking character's stats
  5431. and level depending on the action type given. Valid action types are:
  5432.  
  5433. 1 - Base level 1, Job level 1, 0 skill points, 0 base exp, 0 job exp,
  5434. wipes the status effects (only the ones settable by 'setoption'),
  5435. sets all stats to 1. If the new job is 'Novice High', give 100 status
  5436. points, give First Aid and Play Dead skills.
  5437. 2 - Base level 1, Job level 1, 0 skill points, 0 base exp, 0 job exp.
  5438. Skills and attribute values are not altered.
  5439. 3 - Base level 1, base exp 0. Nothing else is changed.
  5440. 4 - Job level 1, job exp 0. Nothing else is changed.
  5441.  
  5442. In all cases everything the character has on will be unequipped.
  5443.  
  5444. Even though it doesn't return a value, it is used as a function in the
  5445. official rebirth scripts.
  5446.  
  5447. ---------------------------------------
  5448.  
  5449. *resetstatus;
  5450.  
  5451. This is a character reset command, which will reset the stats on the
  5452. invoking character and give back all the stat points used to raise them
  5453. previously. Nothing will happen to any other numbers about the character.
  5454.  
  5455. Used in reset NPC's (duh!).
  5456.  
  5457. ---------------------------------------
  5458.  
  5459. *resetskill;
  5460.  
  5461. This command takes off all the skill points on the invoking character, so
  5462. they only have Basic Skill blanked out (lvl 0) left, and returns the
  5463. points for them to spend again. Nothing else will change but the skills.
  5464. Quest skills will also reset if 'quest_skill_reset' option is set to Yes
  5465. in 'battle.conf'. If the 'quest_skill_learn' option is set in there, the
  5466. points in the quest skills will also count towards the total.
  5467.  
  5468. Used in reset NPC's (duh!).
  5469.  
  5470. ---------------------------------------
  5471.  
  5472. *sc_start <effect type>,<ticks>,<value 1>{,<rate>,<flag>{,<GID>}};
  5473. *sc_start2 <effect type>,<ticks>,<value 1>,<value 2>{,<rate>,<flag>{,<GID>}};
  5474. *sc_start4 <effect type>,<ticks>,<value 1>,<value 2>,<value 3>,<value 4>{,<rate>,<flag>{,<GID>}};
  5475. *sc_end <effect type>{,<GID>};
  5476.  
  5477. These commands will bestow a status effect on a character.
  5478.  
  5479. The <effect type> determines which status is invoked. This can be either a number
  5480. or constant, with the common statuses (mostly negative) found in 'db/const.txt'
  5481. with the 'SC_' prefix. A full list is located in 'src/map/status.h', though
  5482. they are not currently documented.
  5483.  
  5484. The duration of the status is given in <ticks>, or milleseconds.
  5485.  
  5486. Certain status changes take an additional parameter <value 1>, which typically
  5487. modifies player stats by the given number or percentage. This differs for each
  5488. status, and is sometimes zero.
  5489.  
  5490. Optional value <rate> is the chance that the status will be invoked (10000 = 1%).
  5491. This is used primarily in item scripts. When used in an NPC script, a flag MUST
  5492. be defined for the rate to work.
  5493.  
  5494. Optional value <flag> is how the status change start will be handled (a bitmask).
  5495. SCFLAG_NONE = 0x00: No special behavior.
  5496. SCFLAG_NOAVOID = 0x01: Status change cannot be avoided.
  5497. SCFLAG_FIXEDTICK = 0x02: Tick cannot be reduced by stats (default).
  5498. SCFLAG_LOADED = 0x04: sc_data was loaded, no value will be altered.
  5499. SCFLAG_FIXEDRATE = 0x08: Rate cannot be reduced.
  5500. SCFLAG_NOICON = 0x10: Status icon (SI) won't be shown.
  5501.  
  5502. If a <GID> is given, the status change will be invoked on the specified character
  5503. instead of the one attached to the script. This can only be defined after setting
  5504. a rate and flag.
  5505.  
  5506. 'sc_start2' and 'sc_start4' allow extra parameters to be passed, and are used only
  5507. for effects that require them. The meaning of the extra values vary depending on the
  5508. effect type.
  5509.  
  5510. 'sc_end' will remove a specified status effect. If SC_ALL (-1) is given, it will
  5511. perform a complete removal of all statuses (although permanent ones will re-apply).
  5512.  
  5513. Examples:
  5514. // This will poison the invoking character for 10 minutes at 50% chance.
  5515. sc_start SC_POISON,600000,0,5000;
  5516.  
  5517. // This will bestow the effect of Level 10 Blessing.
  5518. sc_start 10,240000,10;
  5519.  
  5520. // Elemental armor defense takes the following four values:
  5521. // val1 is the first element, val2 is the resistance to the element val1.
  5522. // val3 is the second element, val4 is the resistance to the element val3.
  5523. sc_start4 SC_DefEle,60000,Ele_Fire,20,Ele_Water,-15;
  5524.  
  5525. // This will end the Freezing status for the invoking character.
  5526. sc_end SC_FREEZE;
  5527.  
  5528. Note: to use SC_NOCHAT you should alter Manner
  5529. Manner = -5; // Will mute a user for 5 minutes
  5530. Manner = 0; // Will unmute a user
  5531. Manner = 5; // Will unmute a user and prevent the next use of 'Manner'
  5532.  
  5533. ---------------------------------------
  5534.  
  5535. *getstatus <effect type>{,<type>};
  5536.  
  5537. Retrieve information about a specific status effect when called. Depending
  5538. on <type> specified the function will return different information.
  5539.  
  5540. Possible <type> values:
  5541. - 0 or undefined: whether the status is active
  5542. - 1: the val1 of the status
  5543. - 2: the val2 of the status
  5544. - 3: the val3 of the status
  5545. - 4: the val4 of the status
  5546. - 5: the amount of time in milliseconds that the status has remaining
  5547.  
  5548. If <type> is not defined or is set to 0, then the script function will
  5549. either return 1 if the status is active, or 0 if the status is not active.
  5550. If the status is not active when any of the <type> fields are provided,
  5551. this script function will always return 0.
  5552.  
  5553. ---------------------------------------
  5554.  
  5555. *skilleffect <skill id>,<number>;
  5556. *skilleffect "<skill name>",<number>;
  5557.  
  5558. This command displays visual and aural effects of given skill on currently
  5559. attached character. The number parameter is for skill whose visual effect
  5560. involves displaying of a number (healing or damaging). Note that this
  5561. command will not actually use the skill: it is intended for scripts which
  5562. simulate skill usage by the NPC, such as buffs, by setting appropriate
  5563. status and displaying the skill's effect.
  5564.  
  5565. mes "Be blessed!";
  5566. // Heal of 2000 HP
  5567. heal 2000,0;
  5568. skilleffect 28,2000;
  5569. // Blessing Level 10
  5570. sc_start 10,240000,10;
  5571. skilleffect 34,0;
  5572. // Increase AGI Level 5
  5573. sc_start 12,140000,5;
  5574. skilleffect 29,0;
  5575.  
  5576. This will heal the character with 2000 HP, buff it with Blessing Lv 10 and
  5577. Increase AGI Lv 5, and display appropriate effects.
  5578.  
  5579. ---------------------------------------
  5580.  
  5581. *npcskilleffect <skill id>,<number>,<x>,<y>;
  5582. *npcskilleffect "<skill name>",<number>,<x>,<y>;
  5583.  
  5584. This command behaves identically to 'skilleffect', however, the effect
  5585. will not be centered on the invoking character's sprite, nor on the NPC
  5586. sprite, if any, but will be centered at map coordinates given on the same
  5587. map as the invoking character.
  5588.  
  5589. ---------------------------------------
  5590.  
  5591. *specialeffect <effect number>{,<send_target>{,"<NPC Name>"}};
  5592.  
  5593. This command will display special effect with the given number, centered
  5594. on the specified NPCs coordinates, if any. For a full list of special
  5595. effect numbers known see 'doc/effect_list.txt'. Some effect numbers are
  5596. known not to work in some client releases. (Notably, rain is absent from
  5597. any client executables released after April 2005.)
  5598.  
  5599. <NPC name> parameter will display <effect number> on another NPC. If the
  5600. NPC specified does not exist, the command will do nothing. When specifying
  5601. an NPC, <send_target> must be specified when specifying an <NPC Name>,
  5602. specifying AREA will retain the default behavior of the command.
  5603.  
  5604. // this will make the NPC "John Doe#1"
  5605. // show the effect "EF_HIT1" specified by
  5606. // Jane Doe. I wonder what John did...
  5607. mes "[Jane Doe]";
  5608. mes "Well, I never!";
  5609. specialeffect EF_HIT1,AREA,"John Doe#1";
  5610. close;
  5611.  
  5612. ---------------------------------------
  5613.  
  5614. *specialeffect2 <effect number>{,<send_target>{,"<Player Name>"}};
  5615.  
  5616. This command behaves identically to the 'specialeffect', but the effect
  5617. will be centered on the invoking character's sprite.
  5618.  
  5619. <Player name> parameter will display <effect number> on another Player
  5620. than the one currently attached to the script. Like with specialeffect,
  5621. when specifying a player, <send_target> must be supplied, specifying AREA
  5622. will retain the default behavior of the command.
  5623.  
  5624. ---------------------------------------
  5625.  
  5626. *statusup <stat>;
  5627.  
  5628. This command will bump a specified stat of the invoking character up by
  5629. one permanently using status points to do so, if there aren't enough to perform
  5630. the change nothing will happen.
  5631. Stats are to be given as number, but you can use these constants to replace them:
  5632.  
  5633. bStr - Strength
  5634. bVit - Vitality
  5635. bInt - Intelligence
  5636. bAgi - Agility
  5637. bDex - Dexterity
  5638. bLuk - Luck
  5639.  
  5640. ---------------------------------------
  5641.  
  5642. *statusup2 <stat>,<amount>;
  5643.  
  5644. This command will bump a specified stat of the invoking character up by
  5645. the specified amount permanently without using status points.
  5646. Amount can be negative. See 'statusup'.
  5647.  
  5648. // This will decrease a character's Vit forever.
  5649. statusup bVit,-1;
  5650.  
  5651. ---------------------------------------
  5652.  
  5653. *bonus <bonus type>,<val1>;
  5654. *bonus2 <bonus type>,<val1>,<val2>;
  5655. *bonus3 <bonus type>,<val1>,<val2>,<val3>;
  5656. *bonus4 <bonus type>,<val1>,<val2>,<val3>,<val4>;
  5657. *bonus5 <bonus type>,<val1>,<val2>,<val3>,<val4>,<val5>;
  5658.  
  5659. These commands are meant to be used in item scripts. They will probably
  5660. work outside item scripts, but the bonus will not persist for long. They,
  5661. as expected, refer only to an invoking character.
  5662.  
  5663. You can find the full list of possible bonuses and which command to use
  5664. for each kind in 'doc/item_bonus.txt'.
  5665.  
  5666. ---------------------------------------
  5667.  
  5668. *autobonus <bonus script>,<rate>,<duration>{,<flag>,{<other script>}};
  5669. *autobonus2 <bonus script>,<rate>,<duration>{,<flag>,{<other script>}};
  5670. *autobonus3 <bonus script>,<rate>,<duration>,<skill id>,{<other script>};
  5671. *autobonus3 <bonus script>,<rate>,<duration>,"<skill name>",{<other script>};
  5672.  
  5673. These commands are meant to be used in item scripts. They will probably
  5674. work outside item scripts, but the bonus will not persist for long. They,
  5675. as expected, refer only to an invoking character.
  5676.  
  5677. What these commands do is 'attach' a script to the player which will get
  5678. executed on attack (or when attacked in the case of autobonus2).
  5679.  
  5680. Rate is the trigger rate of the script (10000 = 100%).
  5681.  
  5682. Duration is the time that the bonus will last for since the script has
  5683. triggered.
  5684.  
  5685. Skill ID/skill name the skill which will be used as trigger to start the
  5686. bonus (for autobonus3).
  5687.  
  5688. The optional argument 'flag' is used to classify the type of attack where
  5689. the script can trigger (it shares the same flags as the bAutoSpell bonus
  5690. script):
  5691.  
  5692. Range criteria:
  5693. BF_SHORT: Trigger on melee attack
  5694. BF_LONG: Trigger on ranged attack
  5695. Default: BF_SHORT+BF_LONG
  5696. Attack type criteria:
  5697. BF_WEAPON: Trigger on weapon skills
  5698. BF_MAGIC: Trigger on magic skills
  5699. BF_MISC: Trigger on misc skills
  5700. Default: BF_WEAPON
  5701. Skill criteria:
  5702. BF_NORMAL: Trigger on normal attacks
  5703. BF_SKILL: Trigger on skills
  5704. default: If the attack type is BF_WEAPON (only) BF_NORMAL is used,
  5705. otherwise BF_SKILL+BF_NORMAL is used.
  5706.  
  5707. The difference between the optional argument 'other script' and the 'bonus
  5708. script' is that, the former one triggers only when attacking (or attacked)
  5709. and the latter one runs on status calculation as well, which makes sure,
  5710. within the duration, the "bonus" that get lost on status calculation is
  5711. restored. So, 'bonus script' is technically supposed to accept "bonus"
  5712. command only. And we usually use 'other script' to show visual effects.
  5713.  
  5714. In all cases, when the script triggers, the attached player will be the
  5715. one who holds the bonus. There is currently no way of knowing within this
  5716. script who was the other character (the attacker in autobonus2, or the
  5717. target in autobonus and autobonus3).
  5718.  
  5719. //Grants a 1% chance of starting the state "all stats +10" for 10 seconds
  5720. //when using weapon or misc attacks (both melee and ranged skills) and
  5721. //shows a special effect when the bonus is active.
  5722. autobonus "{ bonus bAllStats,10; }",10,10000,BF_WEAPON|BF_MISC,"{ specialeffect2 EF_FIRESPLASHHIT; }";
  5723.  
  5724. ---------------------------------------
  5725.  
  5726. *skill <skill id>,<level>{,<flag>};
  5727. *skill "<skill name>",<level>{,<flag>};
  5728. *addtoskill <skill id>,<level>{,<flag>};
  5729. *addtoskill "<skill name>",<level>{,<flag>};
  5730.  
  5731. These commands will give the invoking character a specified skill. This is
  5732. also used for item scripts.
  5733.  
  5734. Level is obvious. Skill id is the ID number of the skill in question as
  5735. per 'db/(pre-)re/skill_db.txt'. It is not known for certain whether this
  5736. can be used to give a character a monster's skill, but you're welcome to
  5737. try with the numbers given in 'db/(pre-)re/mob_skill_db.txt'.
  5738.  
  5739. Flag is 0 if the skill is given permanently (will get written with the
  5740. character data) or 1 if it is temporary (will be lost eventually, this is
  5741. meant for card item scripts usage.). The flag parameter is optional, and
  5742. defaults to 1 in 'skill' and to 2 in 'addtoskill'.
  5743.  
  5744. Flag 2 means that the level parameter is to be interpreted as a stackable
  5745. additional bonus to the skill level. If the character did not have that
  5746. skill previously, they will now at 0+the level given.
  5747.  
  5748. // This will permanently give the character Stone Throw
  5749. // (TF_THROWSTONE,152), at level 1.
  5750. skill 152,1,0;
  5751.  
  5752. Flag 3 is the same as flag 0 in that it saves to the database. However,
  5753. these skills are ignored when any action is taken that adjusts the skill
  5754. tree (reset/job change).
  5755.  
  5756. ---------------------------------------
  5757.  
  5758. *nude;
  5759.  
  5760. This command will unequip anything equipped on the invoking character.
  5761.  
  5762. It is not required to do this when changing jobs since 'jobchange' will
  5763. unequip everything not equippable by the new job class anyway.
  5764.  
  5765. ---------------------------------------
  5766.  
  5767. *disguise <Monster ID>;
  5768. *undisguise;
  5769.  
  5770. This command disguises the current player with a monster sprite.
  5771. The disguise lasts until 'undisguise' is issued or the player logs out.
  5772.  
  5773. Example:
  5774.  
  5775. disguise 1002; // Disguise character as a Poring.
  5776. next;
  5777. undisguise; // Return to normal character sprite.
  5778.  
  5779. ---------------------------------------
  5780. //=====================================
  5781. 4.3 - Marriage-Related Commands
  5782. //=====================================
  5783. ---------------------------------------
  5784.  
  5785. *marriage("<spouse name>");
  5786.  
  5787. This function will marry two characters, the invoking character and the
  5788. one referred to by name given, together, setting them up as each other's
  5789. marriage partner. No second function call has to be issued (in current Git
  5790. at least) to make sure the marriage works both ways. The function returns
  5791. 1 upon success, or 0 if the marriage could not be completed, either
  5792. because the other character wasn't found or because one of the two
  5793. characters is already married.
  5794.  
  5795. This will do nothing else for the marriage except setting up the spouse ID
  5796. for both of these characters. No rings will be given and no effects will
  5797. be shown.
  5798.  
  5799. ---------------------------------------
  5800.  
  5801. *wedding;
  5802.  
  5803. This command will call up wedding effects - the music and confetti -
  5804. centered on the invoking character. Example can be found in the wedding
  5805. script.
  5806.  
  5807. ---------------------------------------
  5808.  
  5809. *divorce()
  5810.  
  5811. This function will "un-marry" the invoking character from whoever they
  5812. were married to. Both will no longer be each other's marriage partner,
  5813. (at least in current Git, which prevents the cases of multi-spouse
  5814. problems). It will return 1 upon success or 0 if the character was not
  5815. married at all.
  5816.  
  5817. This function will also destroy both wedding rings and send a message to
  5818. both players, telling them they are now divorced.
  5819.  
  5820. ---------------------------------------
  5821. //=====================================
  5822. 4.3 - End of Marriage-Related Commands
  5823. //=====================================
  5824. ---------------------------------------
  5825.  
  5826. *pcfollow <id>,<target id>;
  5827. *pcstopfollow <id>;
  5828.  
  5829. Makes a character follow or stop following someone. This command does the
  5830. same as the @follow command. The main difference is that @follow can use
  5831. character names, and this commands needs the Account ID for the target.
  5832.  
  5833. Examples:
  5834.  
  5835. // This will make Aaron follow Bullah, when both of these characters are
  5836. // online.
  5837. pcfollow getcharid(3,"Aaron"),getcharid(3,"Bullah");
  5838.  
  5839. // Makes Aaron stop following whoever he is following.
  5840. pcstopfollow getcharid(3,"Aaron");
  5841.  
  5842. ---------------------------------------
  5843.  
  5844. *pcblockmove <id>,<option>;
  5845.  
  5846. Prevents the given ID from moving when the option != 0, and 0 enables the
  5847. ID to move again. The ID can either be the GID of a monster/NPC or account
  5848. ID of a character, and will run for the attached player if zero is
  5849. supplied.
  5850.  
  5851. Examples:
  5852.  
  5853. // Prevents the current char from moving away.
  5854. pcblockmove getcharid(3),1;
  5855.  
  5856. // Enables the current char to move again.
  5857. pcblockmove getcharid(3),0;
  5858.  
  5859.  
  5860. ---------------------------------------
  5861. //=====================================
  5862. 4 - End of Player-Related Commands
  5863. //=====================================
  5864. ---------------------------------------
  5865.  
  5866. ---------------------------------------
  5867. //=====================================
  5868. 5 - Mob / NPC Related Commands
  5869. //=====================================
  5870. ---------------------------------------
  5871.  
  5872. *monster "<nome do mapa>",<x>,<y>,"<name to show>",<mob id>,<amount>{,"<event label>"{,<size>{,<ai>}}};
  5873. *areamonster "<nome do mapa>",<x1>,<y1>,<x2>,<y2>,"<name to show>",<mob id>,<amount>{,"<event label>"{,<size>{,<ai>}}};
  5874.  
  5875. This command will spawn a monster on the specified coordinates on the
  5876. specified map. If the script is invoked by a character, a special map
  5877. name, "this", will be recognized to mean the name of the map the invoking
  5878. character is located at. This command works fine in the item scripts.
  5879.  
  5880. The same command arguments mean the same things as described above in the
  5881. beginning of this document when talking about permanent monster spawns.
  5882. Monsters spawned in this manner will not respawn upon being killed.
  5883.  
  5884. Unlike the permanent monster spawns, if the mob id is -1, a random monster
  5885. will be picked from the entire database according to the rules configured
  5886. in the server for dead branches. This will work for all other kinds of
  5887. non-permanent monster spawns.
  5888.  
  5889. The only very special thing about this command is an event label, which is
  5890. an optional parameter. This label is written like
  5891. '<NPC object name>::<label name>' and upon the monster being killed, it
  5892. will execute the script inside of the specified NPC object starting from
  5893. the label given. The RID of the player attached at this execution will be
  5894. the RID of the killing character.
  5895.  
  5896. <size> can be:
  5897. 0 = medium (default)
  5898. 1 = small
  5899. 2 = big
  5900.  
  5901. <ai> can be:
  5902. 0 = none (default)
  5903. 1 = attack/friendly
  5904. 2 = sphere (Alchemist skill)
  5905. 3 = flora (Alchemist skill)
  5906. 4 = zanzou (Kagerou/Oboro skill)
  5907.  
  5908. monster "place",60,100,"Poring",1002,1,"NPCNAME::OnLabel";
  5909.  
  5910. The coordinates of 0,0 will spawn the monster on a random place on the
  5911. map. Both 'monster' and 'areamonster' return the GID of the monster
  5912. spawned if there was ONLY ONE monster to be spawned. This is useful for
  5913. controlling each of the spawned mobs with the unit* commands shown below.
  5914. For example:
  5915.  
  5916. // We'll make a poring which will automatically attack invoking player:
  5917. .@mobGID = monster("prontera",150,150,"Poring",PORING,1); // PORING is defined in the mob db and its value is 1002
  5918. unitattack .@mobGID, getcharid(3); // Attacker GID, attacked GID
  5919.  
  5920. The way you can get the GID of more than only one monster is looping
  5921. through all the summons to get their individual GIDs and do whatever you
  5922. want with them. For example:
  5923.  
  5924. // We want to summon .mobnumber porings which will give us a kiss
  5925. for (.@i = 0; .@i < .mobnumber; ++.@i) {
  5926. .@mobGID = monster "map",.x,.y,"Kisser Poring",PORING,1;
  5927. unitemote .@mobGID, e_kis;
  5928. }
  5929.  
  5930. Refer to the unit* commands below.
  5931.  
  5932. The 'areamonster' command works much like the 'monster' command and is not
  5933. significantly different, but spawns the monsters within a square defined
  5934. by x1/y1-x2/y2.
  5935.  
  5936. Simple monster killing script:
  5937.  
  5938. <NPC object definition. Let's assume you called him NPCNAME.>
  5939. mes "[Summon Man]";
  5940. mes "Want to start the kill?";
  5941. next;
  5942. if (select("Yes:No") != 1) {
  5943. mes "[Summon Man]";
  5944. mes "Come back later";
  5945. close;
  5946. }
  5947. monster "prontera",0,0,"Quest Poring",PORING,10,"NPCNAME::OnPoringKilled";
  5948. // By using 0,0 it will spawn them in a random place.
  5949. mes "[Summon Man]";
  5950. mes "Now go and kill all the Poring I summoned";
  5951. // He summoned ten.
  5952. close;
  5953. OnPoringKilled:
  5954. ++$poring_killed;
  5955. if ($poring_killed == 10) {
  5956. announce "Summon Man: Well done all the poring are dead",bc_self;
  5957. $poring_killed = 0;
  5958. }
  5959. end;
  5960.  
  5961. For more examples see just about any official 2-1 or 2-2 job quest script.
  5962.  
  5963. ---------------------------------------
  5964.  
  5965. *areamobuseskill "<nome do mapa>",<x>,<y>,<range>,<mob id>,<skill id>,<skill level>,<cast time>,<cancelable>,<emotion>,<target type>;
  5966. *areamobuseskill "<nome do mapa>",<x>,<y>,<range>,<mob id>,"<skill name>",<skill level>,<cast time>,<cancelable>,<emotion>,<target type>;
  5967.  
  5968. This command will make all monsters of the specified mob ID in the
  5969. specified area use the specified skill. nome do mapa, x, and y define the
  5970. center of the area, which extending <range> cells in each direction (ex: a
  5971. range of 3 would create a 7x7 square). The skill can be specified by skill
  5972. ID or name. <cast time> is in milliseconds (1000 = 1 second), and the rest
  5973. should be self-explanatory.
  5974.  
  5975. <target type> can be:
  5976. 0 = self
  5977. 1 = the mob's current target
  5978. 2 = the mob's master
  5979. 3 = random target
  5980.  
  5981. Example:
  5982.  
  5983. // spawn 1 Shining Plant in the 5x5 area centered on (155,188)
  5984. areamonster "prontera",153,186,157,190,"Shining Plant",1083,1;
  5985. // make the plant cast level 10 Cold Bolt on a random target
  5986. areamobuseskill "prontera",155,188,2,1083,"MG_COLDBOLT",10,3000,1,e_gg,3;
  5987.  
  5988. ---------------------------------------
  5989.  
  5990. *killmonster "<nome do mapa>","<event label>"{,<type>};
  5991.  
  5992. This command will kill all monsters that were spawned with 'monster' or
  5993. 'addmonster' and have a specified event label attached to them. Commonly
  5994. used to get rid of remaining quest monsters once the quest is complete.
  5995.  
  5996. If the label is given as "All", all monsters which have their respawn
  5997. times set to -1 (like all the monsters summoned with 'monster' or
  5998. 'areamonster' script command, and all monsters summoned with GM commands,
  5999. but no other ones - that is, all non-permanent monsters) on the specified
  6000. map will be killed regardless of the event label value.
  6001.  
  6002. killmonster supports an optional argument type. Using 1 for type will make
  6003. the command fire "OnMyMobDead" events from any monsters that do die as a
  6004. result of this command.
  6005.  
  6006. ---------------------------------------
  6007.  
  6008. *killmonsterall "<nome do mapa>"{,<type>};
  6009.  
  6010. This command will kill all monsters on a specified nome do mapa, regardless of
  6011. how they were spawned or what they are without triggering any event label
  6012. attached to them, unless you specify 1 for type parameter. In this case,
  6013. mob death labels will be allowed totrigger when there is no player. Any
  6014. other number for this parameter won't be recognized.
  6015.  
  6016. ---------------------------------------
  6017.  
  6018. *strmobinfo(<type>,<monster id>);
  6019.  
  6020. This function will return information about a monster record in the
  6021. database, as per 'db/(pre-)re/mob_db.txt'. Type is the kind of information
  6022. returned. Valid types are:
  6023.  
  6024. 1 - 'english name' field in the database, a string.
  6025. 2 - 'japanese name' field in the database, a string.
  6026. All other returned values are numbers:
  6027. 3 - Level.
  6028. 4 - Maximum HP.
  6029. 5 - Maximum SP.
  6030. 6 - Experience reward.
  6031. 7 - Job experience reward.
  6032.  
  6033. ---------------------------------------
  6034.  
  6035. *mobcount("<nome do mapa>","<event label>")
  6036.  
  6037. This function will count all the monsters on the specified map that have a
  6038. given event label and return the number or 0 if it can't find any.
  6039. Naturally, only monsters spawned with 'monster' and 'areamonster' script
  6040. commands can have non-empty event label.
  6041. If you pass this function an empty string for the event label, it will
  6042. return the total count of monster without event label, including
  6043. permanently spawning monsters.
  6044.  
  6045. With the dynamic mobs system enabled, where mobs are not kept in memory
  6046. for maps with no actual people playing on them, this will return a 0 for
  6047. any such map.
  6048.  
  6049. If the event label is given as "all", all monsters will be counted,
  6050. regardless of having any event label attached.
  6051.  
  6052. If the nome do mapa is given as "this", the map the invoking character is on
  6053. will be used. If the map is not found, or the invoker is not a character
  6054. while the map is "this", it will return -1.
  6055.  
  6056. ---------------------------------------
  6057.  
  6058. *clone "<nome do mapa>",<x>,<y>,"<event>",<char id>{,<master_id>{,<mode>{,<flag>,<duration>}}}
  6059.  
  6060. This command creates a monster which is a copy of another player. The
  6061. first four arguments serve the same purpose as in the monster script
  6062. command, The <char id> is the character id of the player to clone (player
  6063. must be online).
  6064. If <master id> is given, the clone will be a 'slave/minion' of it.
  6065. Master_id must be a character id of another online player.
  6066.  
  6067. The mode can be specified to determine the behavior of the clone, its
  6068. values are the same as the ones used for the mode field in the mob_db. The
  6069. default mode is aggressive, assists, can move, can attack.
  6070.  
  6071. Flag can be either zero or one currently. If zero, the clone is a normal
  6072. monster that'll target players, if one, it is considered a summoned
  6073. monster, and as such, it'll target other monsters. Defaults to zero.
  6074.  
  6075. The duration specifies how long the clone will live before it is
  6076. auto-removed. Specified in seconds, defaults to no limit (zero).
  6077.  
  6078. Returned value is the monster ID of the spawned clone. If command fails,
  6079. returned value is zero.
  6080.  
  6081. ---------------------------------------
  6082.  
  6083. *summon "Monster name",<monster id>{,<Time Out>{,"event label"}};
  6084.  
  6085. This command will summon a monster. (see also 'monster') Unlike monsters
  6086. spawned with other commands, this one will set up the monster to fight to
  6087. protect the invoking character. Monster name and mob id obey the same
  6088. rules as the one given at the beginning of this document for permanent
  6089. monster spawns with the exceptions mentioned when describing 'monster'
  6090. command.
  6091.  
  6092. The effect for the skill 'Call Homunculus' will be displayed centered on
  6093. the invoking character.
  6094.  
  6095. Timeout is the time in milliseconds the summon lives, and is set default
  6096. to 60000 (1 minute). Note that also the value 0 will set the timer to
  6097. default, and it is not possible to create a spawn that lasts forever.
  6098. If an event label is given, upon the monster being killed, the event label
  6099. will run as if by 'donpcevent'.
  6100.  
  6101. // Will summon a dead branch-style monster to fight for the character.
  6102. summon "--ja--",-1;
  6103.  
  6104. ---------------------------------------
  6105.  
  6106. *homevolution;
  6107.  
  6108. This command will try to evolve the current player's homunculus.
  6109. If it doesn't work, the /swt emotion is shown.
  6110.  
  6111. To evolve a homunculus, the invoking player must have a homunculus, the
  6112. homunculus must not be the last evolution and the homunculus must have
  6113. above 91000 intimacy with its owner.
  6114.  
  6115. ---------------------------------------
  6116.  
  6117. *gethominfo(<type>)
  6118.  
  6119. This function works as a direct counterpart of 'getpetinfo':
  6120. 0 - Homunculus unique ID
  6121. 1 - Homunculus Class
  6122. 2 - Name
  6123. 3 - Friendly level (intimacy score). 100000 is full loyalty.
  6124. 4 - Hungry level. 100 is completely full.
  6125. 5 - Rename flag. 0 means this homunculus has not been named yet.
  6126. 6 - Homunculus level
  6127.  
  6128. ---------------------------------------
  6129.  
  6130. *morphembryo;
  6131.  
  6132. This command will try to put the invoking player's Homunculus in an
  6133. uncallable state, required for mutation into a Homunculus S. The player
  6134. will also receive a Strange Embryo (ID 6415) in their inventory if
  6135. successful, which is deleted upon mutation.
  6136.  
  6137. The command will fail if the invoking player does not have an evolved
  6138. Homunculus at level 99 or above. The /swt emotion is shown upon failure.
  6139.  
  6140. Returns 1 upon success and 0 for all failures.
  6141.  
  6142. ---------------------------------------
  6143.  
  6144. *hommutate {<ID>};
  6145.  
  6146. This command will try to mutate the invoking player's Homunculus into
  6147. a Homunculus S. The Strange Embryo (ID 6415) is deleted upon success.
  6148.  
  6149. The command will fail if the invoking player does not have an evolved
  6150. Homunculus at level 99 or above, if it is not in the embryo state
  6151. (from the 'morphembryo' command), or if the invoking player does not
  6152. possess a Strange Embryo. The /swt emotion is shown upon failure.
  6153.  
  6154. If the optional parameter <ID> is set, the invoking player's Homunculus
  6155. will change into the specified Homunculus ID. Otherwise, a random Homunculus S
  6156. will be chosen. See 'db/homunculus_db.txt' for a full list of IDs.
  6157.  
  6158. Returns 1 upon success and 0 for all failures.
  6159.  
  6160. ---------------------------------------
  6161.  
  6162. *checkhomcall()
  6163.  
  6164. This function checks if the attached player's Homunculus is active,
  6165. and will return the following values:
  6166. -1: The player has no Homunculus.
  6167. 0: The player's Homunculus is active.
  6168. 1: The player's Homunculus is vaporized.
  6169. 2: The player's Homunculus is in morph state.
  6170.  
  6171. ---------------------------------------
  6172.  
  6173. *unitwalk <GID>,<x>,<y>;
  6174. *unitwalk <GID>,<target_GID>;
  6175.  
  6176. This is one command, but can be used in two ways. If only the first
  6177. argument is given, the unit whose GID is given will start walking towards
  6178. the target whose GID is given.
  6179.  
  6180. When 2 arguments are passed, the given unit will walk to the given x,y
  6181. coordinates on the map where the unit currently is.
  6182.  
  6183. Examples:
  6184.  
  6185. //Will move/walk the poring we made to the coordinates 150,150
  6186. unitwalk .GID,150,150;
  6187.  
  6188. //NPC will move towards the attached player.
  6189. unitwalk .GID,getcharid(3);//a player's GID is their account ID
  6190.  
  6191. ---------------------------------------
  6192.  
  6193. *unitkill <GID>;
  6194. *unitwarp <GID>,<Mapname>,<x>,<y>;
  6195. *unitattack <GID>,<Target ID>;
  6196. *unitstop <GID>;
  6197. *unittalk <GID>,<Text>;
  6198. *unitemote <GID>,<Emote>;
  6199.  
  6200. Okay, these commands should be fairly self explaining.
  6201. For the emotions, you can look in db/const.txt for prefixes with e_
  6202. PS: unitwarp supports a <GID> of zero, which causes the executor of the
  6203. script to be affected. This can be used with OnTouchNPC to warp monsters:
  6204.  
  6205. OnTouchNPC:
  6206. unitwarp 0,"this",-1,-1;
  6207.  
  6208. ---------------------------------------
  6209.  
  6210. *disablenpc "<NPC object name>";
  6211. *enablenpc "<NPC object name>";
  6212.  
  6213. These two commands will disable and enable, respectively, an NPC object
  6214. specified by name. The disabled NPC will disappear from sight and will no
  6215. longer be triggerable in the normal way. It is not clear whether it will
  6216. still be accessible through 'donpcevent' and other triggering commands,
  6217. but it probably will be. You can disable even warp NPCs if you know their
  6218. object names, which is an easy way to make a map only accessible through
  6219. walking half the time. Then you 'enablenpc' them back.
  6220.  
  6221. You can also use these commands to create the illusion of an NPC switching
  6222. between several locations, which is often better than actually moving the
  6223. NPC - create one NPC object with a visible and a hidden part to their
  6224. name, make a few copies, and then disable all except one.
  6225.  
  6226. ---------------------------------------
  6227.  
  6228. *hideonnpc "<NPC object name>";
  6229. *hideoffnpc "<NPC object name>";
  6230.  
  6231. These commands will make the NPC object specified display as hidden or
  6232. visible, even though not actually disabled per se. Hidden as in thief Hide
  6233. skill, but unfortunately, not detectable by Ruwach or Sight.
  6234.  
  6235. As they are now, these commands are pointless, it is suggested to use
  6236. 'disablenpc'/'enablenpc', because these two commands actually unload the
  6237. NPC sprite location and other accompanying data from memory when it is not
  6238. used. However, you can use these for some quest ideas (such as cloaking
  6239. NPCs talking while hidden then revealing... you can wonder around =P).
  6240.  
  6241. ---------------------------------------
  6242.  
  6243. *doevent "<NPC object name>::<event label>";
  6244.  
  6245. This command will start a new execution thread in a specified NPC object
  6246. at the specified label. The execution of the script running this command
  6247. will not stop, and the event called by the 'doevent' command will not run
  6248. until the invoking script has terminated. No parameters may be passed with
  6249. a doevent call.
  6250.  
  6251. The script of the NPC object invoked in this manner will run as if it's
  6252. been invoked by the RID that was active in the script that issued a
  6253. 'doevent'. As such, the command will not work if an RID is not attached.
  6254.  
  6255. place,100,100,1%TAB%script%TAB%NPC%TAB%53,{
  6256. mes "This is what you will see when you click me";
  6257. close;
  6258. OnLabel:
  6259. mes "This is what you will see if the doevent is activated";
  6260. close;
  6261. }
  6262.  
  6263. ....
  6264.  
  6265. doevent "NPC::OnLabel";
  6266.  
  6267. ---------------------------------------
  6268.  
  6269. *donpcevent "<NPC object name>::<event label>";
  6270.  
  6271. This command invokes the event label code within an another NPC or NPCs.
  6272. It starts a separate instance of execution, and the invoking NPC will
  6273. resume execution its immediately.
  6274.  
  6275. If the supplied event label has the form "NpcName::OnLabel", then only
  6276. given NPC's event label will be invoked (much like 'goto' into another
  6277. NPC). If the form is "::OnLabel" (NPC name omitted), the event code of all
  6278. NPCs with given label will be invoked, one after another. In both cases
  6279. the invoked script will run without an attached RID, whether or not the
  6280. invoking script was attached to a player. The event label name is required
  6281. to start with "On".
  6282.  
  6283. This command can be used to make other NPCs act, as if they were
  6284. responding to the invoking NPC's actions, such as using an emotion or
  6285. talking.
  6286.  
  6287. place,100,100,1%TAB%script%TAB%NPC%TAB%53,{
  6288. mes "Hey NPC2 copy what I do";
  6289. close2;
  6290. @emote = rand(1,30);
  6291. donpcevent "NPC2::OnEmote";
  6292. OnEmote:
  6293. emotion @emote;
  6294. end;
  6295. }
  6296.  
  6297. place,102,100,1%TAB%script%TAB%NPC2%TAB%53,{
  6298. mes "Hey NPC copy what I do";
  6299. close2;
  6300. @emote = rand(1,30);
  6301. donpcevent "NPC::OnEmote";
  6302. OnEmote:
  6303. emotion @emote;
  6304. end;
  6305. }
  6306.  
  6307. Whichever of the both NPCs is talked to, both will show a random emotion
  6308. at the same time.
  6309.  
  6310. Command returns 1 or 0 on success and failure.
  6311. A debug message also shows on the console when no events are triggered.
  6312.  
  6313. ---------------------------------------
  6314.  
  6315. *npctalk "<message>"{,"<npc name>"};
  6316.  
  6317. This command will display a message to the surrounding area as if the NPC
  6318. object running it was a player talking - that is, above their head and in
  6319. the chat window. The display name of the NPC will get appended in front of
  6320. the message to complete the effect.
  6321.  
  6322. // This will make everyone in the area see the NPC greet the character
  6323. // who just invoked it.
  6324. npctalk "Hello "+strcharinfo(0)+", how are you?";
  6325. npctalk "Hello "+strcharinfo(0)+", how are you?","Another_NPC_Name";
  6326.  
  6327. ---------------------------------------
  6328.  
  6329. *setnpcdisplay("<npc name>", "<display name>", <class id>, <size>)
  6330. *setnpcdisplay("<npc name>", "<display name>", <class id>)
  6331. *setnpcdisplay("<npc name>", "<display name>")
  6332. *setnpcdisplay("<npc name>", <class id>)
  6333.  
  6334. Changes the display name and/or display class of the target NPC.
  6335. Returns 0 is successful, 1 if the NPC does not exist.
  6336. Size is 0 = normal 1 = small 2 = big.
  6337.  
  6338. ---------------------------------------
  6339. //=====================================
  6340. 5.1 - Time-Related Commands
  6341. //=====================================
  6342. ---------------------------------------
  6343.  
  6344. *addtimer <ticks>,"NPC::OnLabel";
  6345. *deltimer "NPC::OnLabel";
  6346. *addtimercount "NPC::OnLabel",<ticks>;
  6347.  
  6348. These commands will create, destroy, and delay a countdown timer -
  6349. 'addtimer' to create, 'deltimer' to destroy and 'addtimercount' to delay
  6350. it by the specified number of ticks. For all three cases, the event label
  6351. given is the identifier of that timer. The timer runs on the character
  6352. object that is attached to the script, and can have multiple instances.
  6353. When the label is run, it is run as if the player that the timer runs on
  6354. has clicked the NPC.
  6355.  
  6356. When this timer runs out, a new execution thread will start in the
  6357. specified NPC object at the specified label.
  6358.  
  6359. The ticks are given in 1/1000ths of a second.
  6360.  
  6361. One more thing. These timers are stored as part of player data. If the
  6362. player logs out, all of these get immediately deleted, without executing
  6363. the script. If this behavior is undesirable, use some other timer
  6364. mechanism (like 'sleep').
  6365.  
  6366. Example:
  6367. <NPC Header> {
  6368. dispbottom "Starting a 5 second timer...";
  6369. addtimer 5000, strnpcinfo(3)+"::On5secs";
  6370. end;
  6371. On5secs:
  6372. dispbottom "5 seconds have passed!";
  6373. end;
  6374. }
  6375.  
  6376. ---------------------------------------
  6377.  
  6378. *initnpctimer { "<NPC name>" {, <Attach Flag>} } |
  6379. { "<NPC name>" | <Attach Flag> };
  6380. *stopnpctimer { "<NPC name>" {, <Detach Flag>} } |
  6381. { "<NPC name>" | <Detach Flag> };
  6382. *startnpctimer { "<NPC name>" {, <Attach Flag>} } |
  6383. { "<NPC name>" | <Attach Flag> };
  6384. *setnpctimer <tick>{,"<NPC name>"};
  6385. *getnpctimer (<type of information>{,"<NPC name>"})
  6386. *attachnpctimer {"<character name>"};
  6387. *detachnpctimer {"<NPC name>"};
  6388.  
  6389. This set of commands and functions will create and manage an NPC-based
  6390. timer. The NPC name may be omitted, in which case the calling NPC is used
  6391. as target.
  6392.  
  6393. Contrary to addtimer/deltimer commands which let you have many different
  6394. timers referencing different labels in the same NPC, each with their own
  6395. countdown, 'initnpctimer' can only have one per NPC object. But it can
  6396. trigger many labels and let you know how many were triggered already and
  6397. how many still remain.
  6398.  
  6399. This timer is counting up from 0 in ticks of 1/1000ths of a second each.
  6400. Upon creating this timer, the execution will not stop, but will happily
  6401. continue onward. The timer will then invoke new execution threads at
  6402. labels "OnTimer<time>:" in the NPC object it is attached to.
  6403.  
  6404. To create the timer, use the 'initnpctimer', which will start it running.
  6405. 'stopnpctimer' will pause the timer, without clearing the current tick,
  6406. while 'startnpctimer' will let the paused timer continue.
  6407.  
  6408. By default timers do not have a RID attached, which lets them continue
  6409. even if the player that started them logs off. To attach a RID to a timer,
  6410. you can either use the optional "attach flag" when using
  6411. 'initnpctimer/startnpctimer', or do it manually by using 'attachnpctimer'.
  6412. Likewise, the optional flag of stopnpctimer lets you detach any RID after
  6413. stopping the timer, and by using 'detachnpctimer' you can detach a RID at
  6414. any time.
  6415.  
  6416. Normally there is only a single timer per NPC, but as an exception, as
  6417. long as you attach a player to the timer, you can have multiple timers
  6418. running at once, because these will get stored on the players instead of
  6419. the NPC.
  6420. NOTE: You need to attach the RID before the timer _before_ you start it to
  6421. get a player-attached timer. Otherwise it'll stay a NPC timer (no effect).
  6422.  
  6423. If the player that is attached to the npctimer logs out, the
  6424. "OnTimerQuit:" event label of that NPC will be triggered, so you can do
  6425. the appropriate cleanup (the player is still attached when this event is
  6426. triggered).
  6427.  
  6428. The 'setnpctimer' command will explicitly set the timer to a given tick.
  6429. 'getnpctimer' provides timer information. Its parameter defines what type:
  6430.  
  6431. 0 - Will return the current tick count of the timer.
  6432. 1 - Will return 1 if there are remaining "OnTimer<ticks>:" labels in the
  6433. specified NPC waiting for execution.
  6434. 2 - Will return the number of times the timer has triggered and will
  6435. trigger an "OnTimer<tick>:" label in the specified NPC.
  6436.  
  6437. Example 1:
  6438.  
  6439. <NPC Header> {
  6440. // We need to use attachnpctimer because the mes command below
  6441. // needs RID attach
  6442. attachnpctimer;
  6443. initnpctimer;
  6444. npctalk "I cant talk right now, give me 10 seconds";
  6445. end;
  6446. OnTimer5000:
  6447. npctalk "Ok 5 seconds more";
  6448. end;
  6449. OnTimer6000:
  6450. npctalk "4";
  6451. end;
  6452. OnTimer7000:
  6453. npctalk "3";
  6454. end;
  6455. OnTimer8000:
  6456. npctalk "2";
  6457. end;
  6458. OnTimer9000:
  6459. npctalk "1";
  6460. end;
  6461. OnTimer10000:
  6462. stopnpctimer;
  6463. mes "[Man]";
  6464. mes "Ok we can talk now";
  6465. detachnpctimer;
  6466. // and remember attachnpctimer and detachnpctimer can only be used
  6467. // while the NPC timer is not running!
  6468. }
  6469.  
  6470. Example 2:
  6471.  
  6472. OnTimer15000:
  6473. npctalk "Another 15 seconds have passed.";
  6474.  
  6475. // You have to use 'initnpctimer' instead of 'setnpctimer 0'.
  6476. // This is equal to 'setnpctimer 0' + 'startnpctimer'.
  6477. // Alternatively, you can also insert another 'OnTimer15001' label
  6478. // so that the timer won't stop.
  6479. initnpctimer;
  6480. end;
  6481.  
  6482. // This OnInit label will run when the script is loaded, so that the
  6483. // timer is initialized immediately as the server starts. It is
  6484. // dropped back to 0 every time the NPC says something, so it will
  6485. // cycle continuously.
  6486. OnInit:
  6487. initnpctimer;
  6488. end;
  6489.  
  6490. Example 3:
  6491.  
  6492. mes "[Man]";
  6493. mes "I have been waiting "+(getnpctimer(0)/1000)+" seconds for you.";
  6494. // We divide the timer returned by 1000 to convert milliseconds to
  6495. // seconds.
  6496. close;
  6497.  
  6498. Example 4:
  6499.  
  6500. mes "[Man]";
  6501. mes "Ok, I will let you have 30 more seconds...";
  6502. close2;
  6503. setnpctimer (getnpctimer(0)-30000);
  6504. // Notice the 'close2'. If there were a 'next' there the timer would
  6505. // be changed only after the player pressed the 'next' button.
  6506. end;
  6507.  
  6508. ---------------------------------------
  6509.  
  6510. *sleep {<milliseconds>};
  6511. *sleep2 {<milliseconds>};
  6512. *awake "<NPC name>";
  6513.  
  6514. These commands are used to control the pause of a NPC.
  6515. sleep and sleep2 will pause the script for the given amount of
  6516. milliseconds.
  6517. Awake is used to cancel a sleep. When awake is called on a NPC it will run
  6518. as if the sleep timer ran out, and thus making the script continue. Sleep
  6519. and sleep2 basically do the same, but the main difference is that sleep
  6520. will not keep the rid, while sleep2 does.
  6521.  
  6522. Examples:
  6523. // This will pause the script for 10 seconds and ditch the RID
  6524. // (so no player is attached anymore)
  6525. sleep 10000;
  6526. // Pauses the script for 5 seconds, and continue with the RID attached.
  6527. sleep2 5000;
  6528. //Cancels any running sleep timers on the NPC 'NPC'.
  6529. awake "NPC";
  6530.  
  6531. ---------------------------------------
  6532.  
  6533. *progressbar "<color>",<seconds>;
  6534.  
  6535. This command works almost like sleep2, but displays a progress bar above
  6536. the head of the currently attached character (like cast bar). Once the
  6537. given amount of seconds passes, the script resumes. If the character moves
  6538. while the progress bar progresses, it is aborted and the script ends. The
  6539. color format is in RGB (0xRRGGBB). The color is currently ignored by the
  6540. client and appears always green.
  6541.  
  6542. ---------------------------------------
  6543. //=====================================
  6544. 5.1 - End of Time-related commands
  6545. //=====================================
  6546. ---------------------------------------
  6547.  
  6548. *announce "<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
  6549.  
  6550. This command will broadcast a message to all or most players, similar to
  6551. @kami/@kamib GM commands.
  6552.  
  6553. announce "This will be shown to everyone at all in yellow.",0;
  6554.  
  6555. The region the broadcast is heard in (target), source of the broadcast and
  6556. the color the message will come up as is determined by the flags.
  6557.  
  6558. The flag values are coded as constants in db/const.txt to make them easier
  6559. to use.
  6560.  
  6561. Target flags:
  6562. - bc_all: Broadcast message is sent server-wide (default).
  6563. - bc_map: Message is sent to everyone in the same map as the source of
  6564. the broadcast (see below).
  6565. - bc_area: Message is sent to players in the vicinity of the source.
  6566. - bc_self: Message is sent only to current player.
  6567. You cannot use more than one target flag.
  6568.  
  6569. Source flags:
  6570. - bc_pc: Broadcast source is the attached player (default).
  6571. - bc_npc: Broadcast source is the NPC, not the player attached to the
  6572. script (useful when a player is not attached or the message
  6573. should be sent to those nearby the NPC).
  6574. You cannot use more than one source flag.
  6575.  
  6576. Special flags:
  6577. - bc_yellow:Broadcast will be displayed in yellow color (default).
  6578. - bc_blue: Broadcast will be displayed in blue color.
  6579. - bc_woe: Indicates that this broadcast is 'WoE Information' that can
  6580. be disabled client-side.
  6581. Due to the way client handles broadcasts, it is impossible to set both
  6582. bc_blue and bc_woe.
  6583.  
  6584. The optional parameters allow usage of broadcasts in custom colors,
  6585. font-weights, sizes etc. If any of the optional parameters is used,
  6586. special flag is ignored. Optional parameters may not work well (or at all)
  6587. depending on a game client used.
  6588.  
  6589. The color parameter is a single number which can be in hexadecimal
  6590. notation.
  6591.  
  6592. For example:
  6593. announce "This will be shown to everyone at all in green.",bc_all,0x00FF00;
  6594. Will display a global announce in green. The color format is in RGB
  6595. (0xRRGGBB).
  6596.  
  6597. In official scripts only two font-weights (types) are used:
  6598. - normal (FW_NORMAL = 400, default),
  6599. - bold (FW_BOLD = 700).
  6600.  
  6601. Default font size is 12.
  6602.  
  6603. Using this for private messages to players is probably not that good an
  6604. idea, but it can be used instead in NPCs to "preview" an announce.
  6605.  
  6606. // This will be a private message to the player using the NPC that
  6607. // made the announcement
  6608. announce "This is my message just for you",bc_blue|bc_self;
  6609.  
  6610. // This will be shown on everyones screen that is in sight of the NPC.
  6611. announce "This is my message just for you people here",bc_npc|bc_area;
  6612.  
  6613. ---------------------------------------
  6614.  
  6615. *mapannounce "<nome do mapa>","<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}}};
  6616.  
  6617. This command will work like 'announce' but will only broadcast to
  6618. characters currently residing on the specified map. The flag and optional
  6619. parameters parameters are the same as in 'announce', but target and source
  6620. flags are ignored.
  6621.  
  6622. ---------------------------------------
  6623.  
  6624. *areaannounce "<nome do mapa>",<x1>,<y1>,<x2>,<y2>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}}};
  6625.  
  6626. This command works like 'announce' but will only broadcast to characters
  6627. residing in the specified x1/y1-x2/y2 rectangle on the map given. The
  6628. flags and optional parameters are the same as in 'announce', but target
  6629. and source flags are ignored.
  6630.  
  6631. areaannounce "prt_church",0,0,350,350,"God's in his heaven, all right with the world",0;
  6632.  
  6633. ---------------------------------------
  6634.  
  6635. *callshop "<name>",<option>;
  6636.  
  6637. These are a series of commands used to create dynamic shops.
  6638. The callshop function calls an invisible shop (view -1) as if the player
  6639. clicked on it.
  6640.  
  6641. For the options on callShop:
  6642. 0 = The normal window (buy, sell and cancel)
  6643. 1 = The buy window
  6644. 2 = The sell window
  6645.  
  6646. Example:
  6647.  
  6648. //Will call the shop named DaShop and opens the buy menu.
  6649. callshop "DaShop",1;
  6650.  
  6651.  
  6652. The shop which is called by callshop (as long as an npcshop* command is
  6653. executed from that NPC (see note 1)) will trigger the labels OnBuyItem and
  6654. OnSellitem. These labels can take over handling for relatively the buying
  6655. of items from the shop and selling the items to a shop. Via these labels
  6656. you can customize the way an item is bought or sold by a player.
  6657.  
  6658. In the OnBuyItem, two arrays are set (@bought_nameid and
  6659. @bought_quantity), which hold information about the name id (item id) sold
  6660. and the amount sold of it. Same goes for the OnSellItem label, only the
  6661. variables are named different (@sold_nameid, @sold_quantity, @sold_refine,
  6662. @sold_attribute, @sold_identify, @sold_card1, @sold_card2, @sold_card3,
  6663. @sold_card4). An example on a shop comes with Cronus, and can be found
  6664. in the doc/sample/npc_dynamic_shop.txt file.
  6665.  
  6666. This example shows how to use the labels and their set variables to create
  6667. a dynamic shop.
  6668.  
  6669. Note 1: These labels will only be triggered if a npcshop* command is
  6670. executed, this is because these commands set a special data on the shop
  6671. NPC, named master_nd in the source.
  6672. The OnSellItem and OnBuyItem are triggered in the NPC whose master_nd is
  6673. given in the shop.
  6674.  
  6675. ---------------------------------------
  6676.  
  6677. *npcshopitem "<name>",<item id>,<price>{,<item id>,<price>{,<item id>,<price>{,...}}}
  6678.  
  6679. This command lets you override the contents of an existing NPC shop or
  6680. cashshop. The current sell list will be wiped, and only the items
  6681. specified with the price specified will be for sale.
  6682.  
  6683. The function returns 1 if shop was updated successfully, or 0 if not found.
  6684.  
  6685. Note that you cannot use -1 to specify default selling price!
  6686.  
  6687. ---------------------------------------
  6688.  
  6689. *npcshopadditem "<name>",<item id>,<price>{,<item id>,<price>{,<item id>,<price>{,...}}}
  6690.  
  6691. This command will add more items at the end of the selling list for the
  6692. specified NPC shop or cashshop. If you specify an item already for sell,
  6693. that item will appear twice on the sell list.
  6694.  
  6695. The function returns 1 if shop was updated successfully, or 0 if not found.
  6696.  
  6697. Note that you cannot use -1 to specify default selling price!
  6698.  
  6699. ---------------------------------------
  6700.  
  6701. *npcshopdelitem "<name>",<item id>{,<item id>{,<item id>{,...}}}
  6702.  
  6703. This command will remove items from the specified NPC shop or cashshop.
  6704. If the item to remove exists more than once on the shop, all instances
  6705. will be removed.
  6706.  
  6707. Note that the function returns 1 even if no items were removed. The return
  6708. value is only to confirm that the shop was indeed found.
  6709.  
  6710. ---------------------------------------
  6711.  
  6712. *npcshopattach "<name>"{,<flag>}
  6713.  
  6714. This command will attach the current script to the given NPC shop.
  6715. When a script is attached to a shop, the events "OnBuyItem" and
  6716. "OnSellItem" of your script will be executed whenever a player buys/sells
  6717. from the shop. Additionally, the arrays @bought_nameid[],
  6718. @bought_quantity[] or @sold_nameid[] and @sold_quantity[] will be filled
  6719. up with the items and quantities bought/sold.
  6720.  
  6721. The optional parameter specifies whether to attach ("1") or detach ("0")
  6722. from the shop (the default is to attach). Note that detaching will detach
  6723. any NPC attached to the shop, even if it's from another script, while
  6724. attaching will override any other script that may be already attached.
  6725.  
  6726. The function returns 0 if the shop was not found, 1 otherwise.
  6727.  
  6728. ---------------------------------------
  6729.  
  6730. *waitingroom "<chatroom name>",<limit>{,<event label>,<trigger>,<required zeny>,<min lvl>,<max lvl>};
  6731.  
  6732. This command will create a chat room, owned by the NPC object running this
  6733. script and displayed above the NPC sprite.
  6734. The maximum length of a chat room name is 60 letters.
  6735.  
  6736. The limit is the maximum number of people allowed to enter the chat room.
  6737. The attached NPC is included in this count. If the optional event and
  6738. trigger parameters are given, the event label
  6739. ("<NPC object name>::<label name>") will be invoked as if with a 'doevent'
  6740. upon the number of people in the chat room reaching the given triggering
  6741. amount.
  6742.  
  6743. // The NPC will just show a box above its head that says "Hello World",
  6744. // clicking it will do nothing, since the limit is zero.
  6745. waitingroom "Hello World",0;
  6746.  
  6747. // The NPC will have a box above its head, with "Disco - Waiting Room"
  6748. // written on it, and will have 8 waiting slots. Clicking this will enter
  6749. // the chat room, where the player will be able to wait until 7 players
  6750. // accumulate. Once this happens, it will cause the NPC "Bouncer" run the
  6751. // label "OnStart".
  6752.  
  6753. waitingroom "Disco - Waiting Room",8,"Bouncer::OnStart",7;
  6754.  
  6755. // The NPC will have a box above its head, with "Party - Waiting Room"
  6756. // written on it, and will have 8 waiting slots. Clicking this will allow
  6757. // a player who has 5000 zeny and lvl 50~99 to enter the chat room, where
  6758. // the player will be able to wait until 7 players accumulate. Once this
  6759. // happens, it will cause the NPC "Bouncer" run the label "OnStart".
  6760.  
  6761. waitingroom "Party - Waiting Room",8,"Bouncer::OnStart",7,5000,50,99;
  6762.  
  6763. Creating a waiting room does not stop the execution of the script and it
  6764. will continue to the next line.
  6765.  
  6766. For more examples see the 2-1 and 2-2 job quest scripts which make
  6767. extensive use of waiting rooms.
  6768.  
  6769. ---------------------------------------
  6770.  
  6771. *delwaitingroom {"<NPC object name"};
  6772.  
  6773. This command will delete a waiting room. If no parameter is given, it will
  6774. delete a waiting room attached to the NPC object running this command, if
  6775. it is, it will delete a waiting room owned by another NPC object. This is
  6776. the only way to get rid of a waiting room, nothing else will cause it to
  6777. disappear.
  6778.  
  6779. It's not clear what happens to a waiting room if the NPC is disabled with
  6780. 'disablenpc', by the way.
  6781.  
  6782. ---------------------------------------
  6783.  
  6784. *enablewaitingroomevent {"<NPC object name>"};
  6785. *disablewaitingroomevent {"<NPC object name>"};
  6786.  
  6787. This will enable and disable triggering the waiting room event (see
  6788. 'waitingroom') respectively. Optionally giving an NPC object name will do
  6789. that for a specified NPC object. The chat room will not disappear when
  6790. triggering is disabled and enabled in this manner and players will not be
  6791. kicked out of it. Enabling a chat room event will also cause it to
  6792. immediately check whether the number of users in it exceeded the trigger
  6793. amount and trigger the event accordingly.
  6794.  
  6795. Normally, whenever a waiting room was created to make sure that only one
  6796. character is, for example, trying to pass a job quest trial, and no other
  6797. characters are present in the room to mess up the script.
  6798.  
  6799. ---------------------------------------
  6800.  
  6801. *getwaitingroomstate(<information type>{,"<NPC object name>"})
  6802.  
  6803. This function will return information about the waiting room state for the
  6804. attached waiting room or for a waiting room attached to the specified NPC
  6805. if any.
  6806.  
  6807. The valid information types are:
  6808.  
  6809. 0 - Number of users currently in the waiting room
  6810. $@chatmembers[] - list of user account_id
  6811. 1 - Maximum number of users allowed.
  6812. 2 - Will return 1 if the waiting room has a trigger set.
  6813. 0 otherwise.
  6814. 3 - Will return 1 if the waiting room is currently disabled.
  6815. 0 otherwise.
  6816. 4 - The Title of the waiting room (string)
  6817. 5 - Password of the waiting room, if any. Pointless, since there is no
  6818. way to set a password on a waiting room right now.
  6819. 16 - Event name of the waiting room (string)
  6820. 32 - Whether or not the waiting room is full.
  6821. 33 - Whether the amount of users in the waiting room is higher than the
  6822. trigger number.
  6823. 34 - Minimum Base Level to enter waiting room.
  6824. 35 - Maximum Base Level to enter waiting room.
  6825. 36 - Minimum Zeny to enter waiting room.
  6826.  
  6827.  
  6828. ---------------------------------------
  6829.  
  6830. *warpwaitingpc "<nome do mapa>",<x>,<y>{,<number of people>};
  6831.  
  6832. This command will warp the amount of characters equal to the trigger
  6833. number of the waiting room chat attached to the NPC object running this
  6834. command to the specified map and coordinates, kicking them out of the
  6835. chat. Those waiting the longest will get warped first. It can also do a
  6836. random warp on the same map ("Random" instead of nome do mapa) and warp to the
  6837. save point ("SavePoint").
  6838.  
  6839. The list of characters to warp is taken from the list of the chat room
  6840. members. Those not in the chat room will not be considered even if they
  6841. are talking to the NPC in question. If the number of people is given,
  6842. exactly this much people will be warped.
  6843.  
  6844. This command can also keep track of who just got warped. It does this by
  6845. setting special variables:
  6846.  
  6847. $@warpwaitingpc[] is an array containing the account_id numbers of the
  6848. characters who were just warped.
  6849. $@warpwaitingpcnum contains the number of the character it just warped.
  6850.  
  6851. See also 'getpartymember' for advice on what to do with those variables.
  6852.  
  6853. The obvious way of using this effectively would be to set up a waiting
  6854. room for two characters to be warped onto a random PVP map for a
  6855. one-on-one duel, for example.
  6856.  
  6857. ---------------------------------------
  6858.  
  6859. *kickwaitingroomall {"<NPC object name>"};
  6860.  
  6861. This command kicks everybody out of a specified waiting room chat.
  6862.  
  6863. ---------------------------------------
  6864.  
  6865. *setmapflagnosave "<nome do mapa>","<alternate nome do mapa>",<x>,<y>;
  6866.  
  6867. This command sets the 'nosave' flag for the specified map and also gives
  6868. an alternate respawn-upon-relogin point.
  6869.  
  6870. It does not make a map impossible to make a save point on as you would
  6871. normally think, 'savepoint' will still work. It will, however, make the
  6872. specified map kick the reconnecting players off to the alternate map given
  6873. to the coordinates specified.
  6874.  
  6875. ---------------------------------------
  6876.  
  6877. *setmapflag "<nome do mapa>",<flag>{,<val>};
  6878.  
  6879. This command marks a specified map with a map flag given. Map flags alter
  6880. the behavior of the map, you can see the list of the available ones in
  6881. 'db/const.txt' under 'mf_'.
  6882.  
  6883. The map flags alter the behavior of the map regarding teleporting
  6884. (mf_nomemo, mf_noteleport, mf_nowarp, mf_nogo), storing location when
  6885. disconnected (mf_nosave), dead branch usage (mf_nobranch), penalties upon
  6886. death (mf_nopenalty, mf_nozenypenalty), PVP behavior (mf_pvp,
  6887. mf_pvp_noparty, mf_pvp_noguild), WoE behavior (mf_gvg,mf_gvg_noparty),
  6888. ability to use skills or open up trade deals (mf_notrade, mf_novending,
  6889. mf_noskill, mf_noicewall), current weather effects (mf_snow, mf_fog,
  6890. mf_sakura, mf_leaves, mf_rain, mf_clouds, mf_fireworks) and whether night
  6891. will be in effect on this map (mf_nightenabled).
  6892.  
  6893. The val optional parameter is as the mapflags variable when one exists, it
  6894. may be a number or a string depending on the mapflag in question.
  6895.  
  6896. ---------------------------------------
  6897.  
  6898. *removemapflag "<nome do mapa>",<flag>;
  6899.  
  6900. This command removes a mapflag from a specified map.
  6901. See 'setmapflag' for a list of mapflags.
  6902.  
  6903. ---------------------------------------
  6904.  
  6905. *getmapflag("<nome do mapa>",<flag>)
  6906.  
  6907. This command checks the status of a given mapflag and returns the
  6908. mapflag's state.
  6909. 0 means OFF, and 1 means ON. See 'setmapflag' for a list of mapflags.
  6910.  
  6911. ---------------------------------------
  6912.  
  6913. *setbattleflag "<battle flag>",<value>;
  6914. *getbattleflag("<battle flag>")
  6915.  
  6916. Sets or gets the value of the given battle flag.
  6917. Battle flags are the flags found in the "battle/*.conf/" files and is also
  6918. used in Lupus' variable rates script.
  6919.  
  6920. Examples:
  6921.  
  6922. // Will set the base experience rate to 20x (2000%)
  6923. setbattleflag "base_exp_rate",2000;
  6924.  
  6925. // Will return the value of the base experience rate (when used after the
  6926. // above example, it would print 2000).
  6927. mes getbattleflag("base_exp_rate");
  6928.  
  6929. ---------------------------------------
  6930.  
  6931. *warpportal <x>,<y>,"<mapname>",<x>,<y>;
  6932.  
  6933. Creates a warp Portal as if a acolyte class character did it.
  6934. The first x and y is the place of the warp portal on the map where the NPC
  6935. is on the mapname and second x and y is the target area of the warp portal.
  6936.  
  6937. Examples:
  6938.  
  6939. // Will create a warp portal on the NPC's map at 150,150
  6940. // leading to prontera, coords 150,180.
  6941. warpportal 150,150,"prontera",150,180;
  6942.  
  6943. ---------------------------------------
  6944.  
  6945. *mapwarp "<from map>","<to map>",<x>,<y>{,<type>,<ID>};
  6946.  
  6947. This command will collect all characters located on the From map and warp
  6948. them wholesale to the same point on the To map, or randomly distribute
  6949. them there if the coordinates are zero. "Random" is understood as a
  6950. special To nome do mapa and will mean randomly shuffling everyone on the same
  6951. map.
  6952.  
  6953. Optionally, a type and ID can be specified. Available types are:
  6954.  
  6955. 0 - Everyone
  6956. 1 - Guild
  6957. 2 - Party
  6958.  
  6959. Example:
  6960.  
  6961. // Will warp all members of guild with ID 63 on map prontera to alberta.
  6962. mapwarp "prontera","alberta",150,150,1,63;
  6963.  
  6964. ---------------------------------------
  6965. //=====================================
  6966. 5.2 - Guild-Related Commands
  6967. //=====================================
  6968. ---------------------------------------
  6969.  
  6970. *maprespawnguildid "<nome do mapa>",<guild id>,<flag>;
  6971.  
  6972. This command goes through the specified map and for each player and
  6973. monster found there does stuff.
  6974.  
  6975. Flag is a bit-mask (add up numbers to get effects you want)
  6976. 1 - warp all guild members to their save points.
  6977. 2 - warp all non-guild members to their save points.
  6978. 4 - remove all monsters which are not guardian or Emperium.
  6979.  
  6980. Flag 7 will, therefore, mean 'wipe all mobs but guardians and the Emperium
  6981. and kick all characters out', which is what the official scripts do upon
  6982. castle surrender. Upon start of WoE, the scripts do 2 (warp out all people
  6983. not in the guild that owns the castle).
  6984.  
  6985. Characters not belonging to any guild will be warped out regardless of the
  6986. flag setting.
  6987.  
  6988. For examples, check the WoE scripts in the distribution.
  6989.  
  6990. ---------------------------------------
  6991.  
  6992. *agitstart;
  6993. *agitend;
  6994. *agitstart2;
  6995. *agitend2;
  6996.  
  6997. These four commands will start/end War of Emperium or War of Emperium SE.
  6998.  
  6999. This is a bit more complex than it sounds, since the commands themselves
  7000. won't actually do anything interesting, except causing all 'OnAgitStart:'
  7001. and 'OnAgitEnd:', or 'OnAgitStart2:' and 'OnAgitEnd2:' in the case of
  7002. latter two commands, events to run everywhere, respectively. They are used
  7003. as simple triggers to run a lot of complex scripts all across the server,
  7004. and they, in turn, are triggered by clock with an 'OnClock<time>:'
  7005. time-triggering label.
  7006.  
  7007. ---------------------------------------
  7008.  
  7009. *gvgon "<nome do mapa>";
  7010. *gvgoff "<nome do mapa>";
  7011.  
  7012. These commands will turn GVG mode for the specified maps on and off,
  7013. setting up appropriate map flags. In GVG mode, maps behave as if during
  7014. the time of WoE, even though WoE itself may or may not actually be in
  7015. effect.
  7016.  
  7017. ---------------------------------------
  7018.  
  7019. *flagemblem <guild id>;
  7020.  
  7021. This command only works when run by the NPC objects which have sprite id
  7022. 722, which is a 3D guild flag sprite. If it isn't, the data will change,
  7023. but nothing will be seen by anyone. If it is invoked in that manner, the
  7024. emblem of the specified guild will appear on the flag, though, if any
  7025. players are watching it at this moment, they will not see the emblem
  7026. change until they move out of sight of the flag and return.
  7027.  
  7028. This is commonly used in official guildwar scripts with a function call
  7029. which returns a guild id:
  7030.  
  7031. // This will change the emblem on the flag to that of the guild that owns
  7032. // "guildcastle"
  7033.  
  7034. flagemblem getcastledata("guildcastle",1);
  7035.  
  7036. ---------------------------------------
  7037.  
  7038. *guardian "<nome do mapa>",<x>,<y>,"<name to show>",<mob id>{,"<event label>"{,<guardian index>}};
  7039.  
  7040. This command is roughly equivalent to 'monster', but is meant to be used
  7041. with castle guardian monsters and will only work with them. It will set
  7042. the guardian characteristics up according to the castle's investment
  7043. values and otherwise set the things up that only castle guardians need.
  7044.  
  7045. Returns the id of the mob or 0 if an error occurred.
  7046. When 'guardian index' isn't supplied it produces a temporary guardian.
  7047. Temporary guardians are not saved with the castle and can't be accessed by
  7048. guardianinfo.
  7049.  
  7050. ---------------------------------------
  7051.  
  7052. *guardianinfo("<nome do mapa>", <guardian number>, <type>);
  7053.  
  7054. This function will return various info about the specified guardian, or -1
  7055. if it fails for some reason. It is primarily used in the castle manager
  7056. NPC.
  7057.  
  7058. nome do mapa and guardian number (value between 0 and 7) define the target.
  7059. Type indicates what information to return:
  7060. 0 - visibility (whether the guardian is installed or not)
  7061. 1 - max. hp
  7062. 2 - current hp
  7063.  
  7064. ---------------------------------------
  7065. //=====================================
  7066. 5.2 - End of Guild-Related Commands
  7067. //=====================================
  7068. ---------------------------------------
  7069.  
  7070. *npcspeed <speed value>;
  7071. *npcwalkto <x>,<y>;
  7072. *npcstop;
  7073.  
  7074. These commands will make the NPC object in question move around the map.
  7075. As they currently are, they are a bit buggy and are not useful for much
  7076. more than making an NPC move randomly around the map.
  7077.  
  7078. 'npcspeed' will set the NPCs walking speed to a specified value. As in the
  7079. @speed GM command, 200 is the slowest possible speed while 0 is the
  7080. fastest possible (instant motion). 100 is the default character walking
  7081. speed.
  7082. 'npcwalkto' will start the NPC sprite moving towards the specified
  7083. coordinates on the same map as it is currently on. The script proceeds
  7084. immediately after the NPC begins moving.
  7085. 'npcstop' will stop the motion.
  7086.  
  7087. While in transit, the NPC will be clickable, but invoking it will cause it
  7088. to stop moving, which will make it's coordinates different from what the
  7089. client computed based on the speed and motion coordinates. The effect is
  7090. rather unnerving.
  7091.  
  7092. Only a few NPC sprites have walking animations, and those that do, do not
  7093. get the animation invoked when moving the NPC, due to the problem in the
  7094. NPC walking code, which looks a bit silly. You might have better success
  7095. by defining a job-sprite based sprite id in 'db/mob_avail.txt' with this.
  7096.  
  7097. ---------------------------------------
  7098.  
  7099. *movenpc "<NPC name>",<x>,<y>{,<dir>};
  7100.  
  7101. This command looks like the npcwalktoxy function,but is a little different.
  7102.  
  7103. While npcwalktoxy just makes the NPC 'walk' to the coordinates given
  7104. (which sometimes gives problems if the path isn't a straight line without
  7105. objects), this command just moves the NPC. It basically warps out and in
  7106. on the current and given spot. Direction can be used to change the NPC's
  7107. facing direction.
  7108.  
  7109. Example:
  7110.  
  7111. // This will move Bugga from to the coordinates 100,20 (if those
  7112. // coordinates are legit).
  7113. movenpc "Bugga",100,20;
  7114.  
  7115. ---------------------------------------
  7116. //=====================================
  7117. 6 - Other Commands
  7118. //=====================================
  7119. ---------------------------------------
  7120.  
  7121. *debugmes "<message>";
  7122.  
  7123. This command will send the message to the server console (map-server
  7124. window). It will not be displayed anywhere else.
  7125. //
  7126. // Displays "NAME has clicked me!" in the map-server window.
  7127. debugmes strcharinfo(0)+" has clicked me!";
  7128.  
  7129. // debugmes "\033[38D\033[K ==Message== \n"; // enable colour code.
  7130. ---------------------------------------
  7131.  
  7132. *logmes "<message>";
  7133.  
  7134. This command will write the message given to the map server NPC log file,
  7135. as specified in 'conf/logs.conf'. If SQL logging is enabled, the message
  7136. will go to the 'npclog' table.
  7137.  
  7138. If logs are not enabled for NPCs, nothing will happen.
  7139.  
  7140. ---------------------------------------
  7141.  
  7142. *globalmes "<message>"{,"<NPC name>"};
  7143.  
  7144. This command will send a message to the chat window of all currently
  7145. connected characters.
  7146.  
  7147. If NPC name is specified, the message will be sent as if the sender would
  7148. be the NPC with the said name.
  7149.  
  7150. ---------------------------------------
  7151.  
  7152. *channelmes("<#channel>", "<message>");
  7153.  
  7154. This command will send a message to the specified chat channel.
  7155.  
  7156. The sent message will not include any character's names.
  7157.  
  7158. For special channels, such as #map and #ally, the attached RID's map or guild
  7159. will be used.
  7160.  
  7161. If the channel doesn't exist (or, in the case of a character-specific channel,
  7162. no RID is attached), false will be returned. In case of success, true is
  7163. returned.
  7164.  
  7165. ---------------------------------------
  7166. *rand(<number>{,<number>});
  7167.  
  7168. This function returns a number ...
  7169. (if you specify one) ... randomly positioned between 0 and the number you
  7170. specify -1.
  7171. (if you specify two) ... randomly positioned between the two numbers you
  7172. specify.
  7173.  
  7174. rand(10) would result in 0,1,2,3,4,5,6,7,8 or 9
  7175. rand(0,9) would result in 0,1,2,3,4,5,6,7,8 or 9
  7176. rand(2,5) would result in 2,3,4 or 5
  7177.  
  7178. ---------------------------------------
  7179.  
  7180. *viewpoint <action>,<x>,<y>,<point number>,<color>;
  7181.  
  7182. This command will mark places on the mini map in the client connected to
  7183. the invoking character. It uses the normal X and Y coordinates from the
  7184. main map. The colors of the marks are defined using a hexadecimal number,
  7185. same as the ones used to color text in 'mes' output, but are written as
  7186. hexadecimal numbers in C. (They look like 0x<six numbers>.)
  7187.  
  7188. Action is what you want to do with a point, 1 will set it, while 2 will
  7189. clear it. 0 will also set it, but automatically removes the point after 15
  7190. seconds.
  7191. Point number is the number of the point - you can have several. If more
  7192. than one point is drawn at the same coordinates, they will cycle, which
  7193. can be used to create flashing marks.
  7194.  
  7195. // This command will show a mark at coordinates X 30 Y 40, is mark
  7196. // number 1, and will be red.
  7197.  
  7198. viewpoint 1,30,40,1,0xFF0000;
  7199.  
  7200. This will create three points:
  7201.  
  7202. viewpoint 1,30,40,1,0xFF0000;
  7203. viewpoint 1,35,45,2,0xFF0000;
  7204. viewpoint 1,40,50,3,0xFF0000;
  7205.  
  7206. And this is how you remove them:
  7207.  
  7208. viewpoint 2,30,40,1,0xFF0000;
  7209. viewpoint 2,35,45,2,0xFF0000;
  7210. viewpoint 2,40,50,3,0xFF0000;
  7211.  
  7212. The client determines what it does with the points entirely, the server
  7213. keeps no memory of where the points are set whatsoever.
  7214.  
  7215. ---------------------------------------
  7216.  
  7217. *cutin "<filename>",<position>;
  7218.  
  7219. This command will display a picture, usually an NPC illustration, also
  7220. called cutin, for the currently attached client. The position parameter
  7221. determines the placement of the illustration and takes following values:
  7222.  
  7223. 0 - bottom left corner
  7224. 1 - bottom middle
  7225. 2 - bottom right corner
  7226. 3 - middle of screen in a movable window with an empty title bar
  7227. 4 - middle of screen without the window header, but still movable
  7228.  
  7229. The picture is read from data\texture\유저인터페이스\illust, from both the
  7230. GRF archive and data folder, and is required to be a bitmap. The file
  7231. extension .bmp can be omitted. Magenta color (#ff00ff) is considered
  7232. transparent. There is no limit placed on the size of the illustrations
  7233. by the client, although loading of large pictures (about 700x700 and
  7234. larger) causes the client to freeze shortly (lag). Typically the size is
  7235. about 320x480. New illustrations can be added by just putting the new file
  7236. into the location above.
  7237.  
  7238. The client is able to display only one cutin at the same time and each new
  7239. one will cause the old one to disappear. To delete the currently displayed
  7240. illustration without displaying a new one, an empty file name and position
  7241. 255 must be used.
  7242.  
  7243. // Displays the Comodo Kafra illustration in lower right corner.
  7244. cutin "kafra_07",2;
  7245.  
  7246. // Typical way to end a script, which displayed an illustration during a
  7247. // dialog with a player.
  7248. mes "See you.";
  7249. close2;
  7250. cutin "",255;
  7251. end;
  7252.  
  7253. ---------------------------------------
  7254.  
  7255. *pet <pet id>;
  7256.  
  7257. This command is used in all the item scripts for taming items. Running
  7258. this command will make the pet catching cursor appear on the client
  7259. connected to the invoking character, usable on the monsters with the
  7260. specified pet ID number. It will still work outside an item script.
  7261.  
  7262. A full list of pet IDs can be found inside 'db/pet_db.txt'
  7263.  
  7264. ---------------------------------------
  7265.  
  7266. *emotion <emotion number>{,<target>{,"<target name>"}};
  7267.  
  7268. This command makes an object display an emotion sprite above their own as
  7269. if they were doing that emotion. For a full list of emotion numbers, see
  7270. 'db/const.txt' under 'e_'. The not so obvious ones are 'e_what' (a
  7271. question mark) and 'e_gasp' (the exclamation mark).
  7272.  
  7273. The optional target parameter specifies who will get the emotion on top of
  7274. their head. If 0 (default if omitted), the NPC in current use will show
  7275. the emotion, if 1, the player that is running the script will display it.
  7276.  
  7277. Target name parameter allows to display emotion on top of other NPC/PC
  7278. without event labels. If specified name is not found, command does nothing.
  7279.  
  7280. ---------------------------------------
  7281.  
  7282. *misceffect <effect number>;
  7283.  
  7284. This command, if run from an NPC object that has a sprite, will call up a
  7285. specified effect number, centered on the NPC sprite. If the running code
  7286. does not have an object ID (a 'floating' NPC) or is not running from an
  7287. NPC object at all (an item script) the effect will be centered on the
  7288. character who's RID got attached to the script, if any. For usable item
  7289. scripts, this command will create an effect centered on the player using
  7290. the item.
  7291.  
  7292. A full list of known effects is found in 'doc/effect_list.txt'. The list
  7293. of those that actually work may differ greatly between client versions.
  7294.  
  7295. ---------------------------------------
  7296.  
  7297. *soundeffect "<effect filename>",<type>;
  7298. *soundeffectall "<effect filename>",<type>{,"<nome do mapa>"}{,<x0>,<y0>,<x1>,<y1>};
  7299.  
  7300. These two commands will play a sound effect to either the invoking
  7301. character only ('soundeffect') or multiple characters ('soundeffectall').
  7302. If the running code does not have an object ID (a 'floating' NPC) or is
  7303. not running from an NPC object at all (an item script) the sound will be
  7304. centered on the character who's RID got attached to the script, if any.
  7305. If it does, it will be centered on that object. (an NPC sprite)
  7306.  
  7307. Effect filename is the filename in a GRF. It must have the .wav extension.
  7308.  
  7309. It's not quite certain what the 'type' actually does, it is sent to the
  7310. client directly. It probably determines which directory to play the effect
  7311. from. It's certain that giving 0 for the number will play sound files from
  7312. '\data\wav\', but where the other numbers will read from is unclear.
  7313.  
  7314. The sound files themselves must be in the PCM format, and file names
  7315. should also have a maximum length of 23 characters including the .wav
  7316. extension:
  7317.  
  7318. soundeffect "1234567890123456789.wav", 0; // will play the soundeffect
  7319. soundeffect "12345678901234567890.wav", 0; // throws gravity error
  7320.  
  7321. You can add your own effects this way, naturally.
  7322.  
  7323. ---------------------------------------
  7324.  
  7325. *playbgm "<BGM filename>";
  7326. *playbgmall "<BGM filename>"{,"<nome do mapa>"{,<x0>,<y0>,<x1>,<y1>}};
  7327.  
  7328. These two commands will play a Background Music to either the invoking
  7329. character only ('playbgm') or multiple characters ('playbgmall').
  7330.  
  7331. BGM filename is the filename in /BGM/ folder. It has to be in .mp3
  7332. extension, but it's not required to specify the extension in the script.
  7333.  
  7334. If coordinates are omitted, BGM will be broadcasted on the entire map. If
  7335. the nome do mapa is also omitted the BGM will be played for the entire server.
  7336.  
  7337. You can add your own BGMs this way, naturally.
  7338.  
  7339. ---------------------------------------
  7340.  
  7341. *pvpon "<nome do mapa>";
  7342. *pvpoff "<nome do mapa>";
  7343.  
  7344. These commands will turn PVP mode for the specified maps on and off.
  7345. Beside setting the flags referred to in 'setmapflag', 'pvpon' will also
  7346. create a PVP timer and ranking as will @pvpon GM command do.
  7347.  
  7348. ---------------------------------------
  7349.  
  7350. *atcommand "<command>";
  7351.  
  7352. This command will run the given command line exactly as if it was typed in
  7353. from the keyboard by the player connected to the invoking character, and
  7354. that character belonged to an account which had GM level 99.
  7355.  
  7356. // This will ask the invoker for a character name and then use the
  7357. // '@nuke' GM command on them, killing them mercilessly.
  7358. input .@player$;
  7359. atcommand "@nuke "+.@player$;
  7360.  
  7361. This command has a lot of good uses, I am sure you can have some fun with
  7362. this one.
  7363.  
  7364. ---------------------------------------
  7365.  
  7366. *charcommand "<command>";
  7367.  
  7368. This command will run the given command line exactly as if it was typed in
  7369. from the keyboard from a character that belonged to an account which had
  7370. GM level 99.
  7371.  
  7372. The commands can also run without an attached rid.
  7373.  
  7374. // This would do the same as above, but now
  7375. // it doesn't need a player attached by default.
  7376. charcommand "#option 0 0 0 Roy";
  7377.  
  7378. ---------------------------------------
  7379.  
  7380. *bindatcmd "command","<NPC object name>::<event label>"{,<group level>,<group level char>,<log>};
  7381.  
  7382. This command will bind a NPC event label to an atcommand. Upon execution
  7383. of the atcommand, the user will invoke the NPC event label. Each atcommand
  7384. is only allowed one binding. If you rebind, it will override the original
  7385. binding. If group level is provided, only users of that group level or
  7386. above will be able to access the command, if not provided, everyone will
  7387. be able to access the command.
  7388. "group level char" is the minimum group level required for the label to be
  7389. used on others like a char command would, e.g. "#command "target" params",
  7390. when not provided, "group level char" defaults to 99.
  7391. "log" whether to log the usages of this command with the atcommand log
  7392. (1 = log, 0 = no log), default is to not log.
  7393.  
  7394. The following variables are set upon execution:
  7395. .@atcmd_command$ = The name of the @command used.
  7396. .@atcmd_parameters$[] = Array containing the given parameters,
  7397. starting from an index of 0.
  7398. .@atcmd_numparameters = The number of parameters defined.
  7399.  
  7400. Parameters are split on spaces. Multiple spaces aren't grouped together, and
  7401. will create multiple (empty) arguments.
  7402. Any leading spaces before the first parameter will be omitted.
  7403.  
  7404. Usage example:
  7405.  
  7406. When a user types the command "@test", an angel effect will be shown.
  7407.  
  7408. - script atcmd_example -1,{
  7409. OnInit:
  7410. bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
  7411. end;
  7412. OnAtcommand:
  7413. specialeffect2 338;
  7414. end;
  7415. }
  7416.  
  7417. Parameter splitting example:
  7418. @mycommand
  7419. .@atcmd_numparameters -> 0
  7420. .@atcmd_parameters$ -> { }
  7421. @mycommand<space><space>
  7422. .@atcmd_numparameters -> 0
  7423. .@atcmd_parameters$ -> { }
  7424. @mycommand<space>foo
  7425. .@atcmd_numparameters -> 1
  7426. .@atcmd_parameters$ -> { "foo" }
  7427. @mycommand<space><space>foo
  7428. .@atcmd_numparameters -> 1
  7429. .@atcmd_parameters$ -> { "foo" }
  7430. @mycommand<space>foo<space>bar
  7431. .@atcmd_numparameters -> 2
  7432. .@atcmd_parameters$ -> { "foo", "bar" }
  7433. @mycommand<space>foo<space><space>bar
  7434. .@atcmd_numparameters -> 3
  7435. .@atcmd_parameters$ -> { "foo", "", "bar" }
  7436. @mycommand<space>foo<space>
  7437. .@atcmd_numparameters -> 2
  7438. .@atcmd_parameters$ -> { "foo", "" }
  7439. @mycommand<space>foo<space><space>
  7440. .@atcmd_numparameters -> 3
  7441. .@atcmd_parameters$ -> { "foo", "", "" }
  7442.  
  7443. The called event label needs to take care of joining arguments together, in
  7444. case it expects spaces. For example:
  7445.  
  7446. - script atcmd_example -1,{
  7447. OnInit:
  7448. bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
  7449. end;
  7450. OnAtcommand:
  7451. // This command expects a character name (that may contain spaces) as
  7452. // the only parameter.
  7453. .@name$ = "";
  7454. for (.@i = 0; .@i < .@atcmd_numparameters; ++.@i) {
  7455. .@name$ += (.@i > 0 ? " " : "") + .@atcmd_parameters$[.@i];
  7456. }
  7457. dispbottom("The specified name is: '" + .@name$ + "'");
  7458. end;
  7459. }
  7460.  
  7461. ---------------------------------------
  7462.  
  7463. *unbindatcmd "command";
  7464.  
  7465. This command will unbind a NPC event label from an atcommand.
  7466.  
  7467. ---------------------------------------
  7468.  
  7469. *useatcmd "command";
  7470.  
  7471. This command will execute an atcommand binding on the attached RID from a
  7472. script. The three .@atcmd_***** variables will NOT be set when invoking
  7473. scripts-atcommands this way.
  7474.  
  7475. ---------------------------------------
  7476.  
  7477. *unitskilluseid <GID>,<skill id>,<skill lvl>{,<target id>};
  7478. *unitskilluseid <GID>,"<skill name>",<skill lvl>{,<target id>};
  7479. *unitskillusepos <GID>,<skill id>,<skill lvl>,<x>,<y>;
  7480. *unitskillusepos <GID>,"<skill name>",<skill lvl>,<x>,<y>;
  7481.  
  7482. This is the replacement of the older commands, these use the same values
  7483. for GID as the other unit* commands (See 'GID').
  7484.  
  7485. Skill ID is the ID of the skill, skill level is the level of the skill.
  7486. For the position, the x and y are given in the unitskillusepos.
  7487.  
  7488. ---------------------------------------
  7489.  
  7490. *npcskill <skill id>,<skill lvl>,<stat point>,<NPC level>;
  7491. *npcskill "<skill name>",<skill lvl>,<stat point>,<NPC level>;
  7492.  
  7493. This command causes the attached NPC object to cast a skill on the
  7494. attached player. The skill will have no cast time or cooldown. The player
  7495. must be within the default skill range or the command will fail silently.
  7496.  
  7497. The "stat point" parameter temporarily sets all NPC stats to the given
  7498. value, and "NPC level" is the temporary level of the NPC (used in some
  7499. skills). Neither value can be greater than the max level defined in
  7500. config, and will not work properly if the NPC has a mob sprite.
  7501.  
  7502. // Casts Level 10 Heal on the attached player, calculated with
  7503. // all stats 99 and base level 60.
  7504. npcskill "AL_HEAL",10,99,60;
  7505.  
  7506. ---------------------------------------
  7507.  
  7508. *setnpcdistance <distance>
  7509.  
  7510. This command can reduce distance from where npc can be clicked.
  7511. Usefull to use from OnInit event.
  7512.  
  7513. // Set distance to one tile on server load
  7514. OnInit:
  7515. setnpcdistance 1;
  7516.  
  7517. ---------------------------------------
  7518.  
  7519. *getnpcdir {<name>};
  7520.  
  7521. Return current npc direction for parameter "name" or for attached npc
  7522. if it missing. If name missing and not attached npc, return -1.
  7523.  
  7524. Example:
  7525. .@dir = getnpcdir();
  7526.  
  7527. ---------------------------------------
  7528.  
  7529. *setnpcdir {<name>,} <direction>;
  7530.  
  7531. Set npc direction. If npc name missing, will be used attached npc.
  7532.  
  7533. Example:
  7534. setnpcdir 2;
  7535.  
  7536. ---------------------------------------
  7537.  
  7538. *getnpcclass {<name>};
  7539.  
  7540. Return npc class/sprite id for npc with given name or for attached npc.
  7541. If name missing and no attached npc, return -1.
  7542.  
  7543. Example:
  7544. .@class = getnpcclass();
  7545.  
  7546. ---------------------------------------
  7547.  
  7548. *day;
  7549. *night;
  7550.  
  7551. These two commands will switch the entire server between day and night
  7552. mode respectively. If your server is set to cycle between day and night by
  7553. configuration, it will eventually return to that cycle.
  7554.  
  7555. Example:
  7556.  
  7557. - script DayNight -1,{
  7558. OnClock0600:
  7559. day;
  7560. end;
  7561. OnInit:
  7562. // setting correct mode upon server start-up
  7563. if(gettime(3)>=6 && gettime(3)<18) end;
  7564. OnClock1800:
  7565. night;
  7566. end;
  7567. }
  7568.  
  7569. This script allows to emulate the day/night cycle as the server does, but
  7570. also allows triggering additional effects upon change, like announces,
  7571. gifts, etc.
  7572. The day/night cycle set by configuration should be disabled when this
  7573. script is used.
  7574.  
  7575. ---------------------------------------
  7576.  
  7577. *pcre_match("<string>","<regex>");
  7578.  
  7579. This command is only available if the server is compiled with regular
  7580. expressions library enabled.
  7581.  
  7582. The string <string> will be searched for a match to the regular expression
  7583. <regex>, and the number of matches will be returned.
  7584.  
  7585. An alternative way to invoke this command is to use the operators '~=' or '~!'.
  7586. The operator '~=' is exactly the same as pcre_match, while the operator '~!'
  7587. will return 1 if no matches were found, or 0 if at least a match was found.
  7588.  
  7589. if (pcre_match("string", "regex")) mes "There was a match.";
  7590. if ("string" ~= "regex") mes "There was a match.";
  7591. if ("string" ~! "regex") mes "There were no matches.";
  7592.  
  7593. You can find more usage examples in the test script npc/custom/test.txt.
  7594.  
  7595. Using regular expressions is high wizardry. But with this high wizardry
  7596. comes unparalleled power of text manipulation. For an explanation of what
  7597. a regular expression pattern is, see a few web pages:
  7598.  
  7599. http://www.regular-expressions.info/
  7600. http://www.weitz.de/regex-coach/
  7601.  
  7602. Additionally, the following temporary variables will be filled (unless the
  7603. command is invoked as '~!'):
  7604.  
  7605. - $@regexmatchcount: The number of matches detected, including any
  7606. parenthesized capture-groups.
  7607. - $@regexmatch$[0]: The part of <string> That matched the full <regex> pattern.
  7608. - $@regexmatch$[1 .. $@regexmatchcount]: The parts of <string> that matched
  7609. each of the parenthesized capture-groups in <pattern>.
  7610.  
  7611. A capture group is a part of a regex enclosed in (parentheses) in order to
  7612. store in a variable the part of the expression that was matched by that part of
  7613. the regex. For more details, see the links above, as this is not intended to be
  7614. a regex tutorial.
  7615.  
  7616. ---------------------------------------
  7617.  
  7618. *defpattern <set number>,"<regular expression pattern>","<event label>";
  7619. *activatepset <set number>;
  7620. *deactivatepset <set number>;
  7621. *deletepset <set number>;
  7622.  
  7623. This set of commands is only available if the server is compiled with
  7624. regular expressions library enabled.
  7625.  
  7626. They will make the NPC object listen for text spoken publicly by players
  7627. and match it against regular expression patterns, then trigger labels
  7628. associated with these regular expression patterns.
  7629.  
  7630. Patterns are organized into sets, which are referred to by a set number.
  7631. You can have multiple sets patterns, and multiple patterns may be active
  7632. at once. Numbers for pattern sets start at 1.
  7633.  
  7634. 'defpattern' will associate a given regular expression pattern with an
  7635. event label. This event will be triggered whenever something a player says
  7636. is matched by this regular expression pattern, if the pattern is currently
  7637. active.
  7638.  
  7639. 'activatepset' will make the pattern set specified active. An active
  7640. pattern will enable triggering labels defined with 'defpattern', which
  7641. will not happen by default.
  7642. 'deactivatepset' will deactivate a specified pattern set. Giving -1 as a
  7643. pattern set number in this case will deactivate all pattern sets defined.
  7644.  
  7645. 'deletepset' will delete a pattern set from memory, so you can create a
  7646. new pattern set in its place.
  7647.  
  7648. For an example of this in use, see doc/sample/npc_test_pcre.txt
  7649.  
  7650. With this you could, for example, automatically punish players for asking
  7651. for Zeny in public places, or alternatively, automatically give them Zeny
  7652. instead if they want it so much.
  7653.  
  7654. ---------------------------------------
  7655.  
  7656. *pow(<number>,<power>)
  7657.  
  7658. Returns the result of the calculation.
  7659.  
  7660. Example:
  7661. .@i = pow(2,3); // .@i will be 8
  7662.  
  7663. ---------------------------------------
  7664.  
  7665. *log10(<number>)
  7666.  
  7667. Returns log base 10 of the number.
  7668.  
  7669. Note: The value is truncated to integer.
  7670.  
  7671. Example:
  7672. .@i = log10(100); // .@i will be 2
  7673.  
  7674. ---------------------------------------
  7675.  
  7676. *sqrt(<number>)
  7677.  
  7678. Returns square-root of number.
  7679.  
  7680. Note: The value is truncated to integer.
  7681.  
  7682. Example:
  7683. .@i = sqrt(25); // .@i will be 5
  7684.  
  7685. ---------------------------------------
  7686.  
  7687. *distance(<x0>,<y0>,<x1>,<y1>)
  7688.  
  7689. Returns distance between 2 points.
  7690.  
  7691. Note: When Cronus is configured to use circular areas, the Euclidean distance
  7692. is returned, otherwise the Chebyshev distance. The value is truncated to
  7693. integer.
  7694.  
  7695. Example:
  7696. .@i = distance(100,200,101,202);
  7697.  
  7698. ---------------------------------------
  7699.  
  7700. *min(<number>{,<number>...<number>})
  7701. *max(<number>{,<number>...<number>})
  7702.  
  7703. Returns the smallest (or biggest) from the set of given numbers.
  7704.  
  7705. Example:
  7706. .@minimum = min(1, -6, -2, 8, 2); // .@minimum will be equal to -6
  7707. .@maximum = max(0, 5, 10, 4); // .@maximum will be equal to 10
  7708. .@level = min(BaseLevel, 70); // .@level will be the character's base level, capped to 70
  7709.  
  7710. ---------------------------------------
  7711.  
  7712. *md5("<string>")
  7713.  
  7714. Returns the md5 checksum of a number or string.
  7715.  
  7716. Example:
  7717. mes md5(12345);
  7718. mes md5("12345"); // Will both display 827ccb0eea8a706c4c34a16891f84e7b
  7719. mes md5("qwerty");// Will display d8578edf8458ce06fbc5bb76a58c5ca4
  7720.  
  7721. ---------------------------------------
  7722.  
  7723. *query_sql("your MySQL query"{, <array variable>{, <array variable>{, ...}}});
  7724. *query_logsql("your MySQL query"{, <array variable>{, <array variable>{, ...}}});
  7725.  
  7726. Executes an SQL query. A 'select' query can fill array variables with up
  7727. to 128 rows of values, and will return the number of rows (the array size).
  7728.  
  7729. Note that 'query_sql' runs on the main database while 'query_logsql' runs
  7730. on the log database.
  7731.  
  7732. Example:
  7733. .@nb = query_sql("select name,fame from `char` ORDER BY fame DESC LIMIT 5", .@name$, .@fame);
  7734. mes "Hall Of Fame: TOP5";
  7735. mes "1."+.@name$[0]+"("+.@fame[0]+")"; // Will return a person with the biggest fame value.
  7736. mes "2."+.@name$[1]+"("+.@fame[1]+")";
  7737. mes "3."+.@name$[2]+"("+.@fame[2]+")";
  7738. mes "4."+.@name$[3]+"("+.@fame[3]+")";
  7739. mes "5."+.@name$[4]+"("+.@fame[4]+")";
  7740.  
  7741. ---------------------------------------
  7742.  
  7743. *escape_sql(<value>)
  7744.  
  7745. Converts the value to a string and escapes special characters so that it's
  7746. safe to use in query_sql(). Returns the escaped form of the given value.
  7747.  
  7748. Example:
  7749. .@str$ = "John's Laptop";
  7750. .@esc_str$ = escape_sql(.@name$); // Escaped string: John\'s Laptop
  7751.  
  7752. ---------------------------------------
  7753.  
  7754. *setiteminfo(<item id>,<type>,<value>)
  7755.  
  7756. This function will set some value of an item.
  7757. Returns the new value on success, or -1 on fail (item_id not found or
  7758. invalid type).
  7759.  
  7760. Valid types are:
  7761. 0 - Buy Price; 1 - Sell Price; 2 - Item Type;
  7762. 3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc..
  7763. if = 0, then monsters don't drop it at all (rare or a quest item)
  7764. if = 10000, then this item is sold in NPC shops only
  7765. 4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range;
  7766. 10 - slot; 11 - look; 12 - elv; 13 - wlv; 14 - view id
  7767.  
  7768. Example:
  7769.  
  7770. setiteminfo Stone, 6, 9990; // Stone now weighs 999.0
  7771.  
  7772. ---------------------------------------
  7773.  
  7774. *setitemscript(<item id>,<"{ new item script }">{,<type>});
  7775.  
  7776. Set a new script bonus to the Item. Very useful for game events.
  7777. You can remove an item's itemscript by leaving the itemscript argument
  7778. empty. Returns 1 on success, or 0 on fail (item_id not found or new item
  7779. script is invalid).
  7780. Type can optionally be used indicates which script to set (default is 0):
  7781. 0 - Script
  7782. 1 - OnEquip_Script
  7783. 2 - OnUnequip_Script
  7784.  
  7785. Example:
  7786.  
  7787. setitemscript Silver_Ring_, "{ if(isequipped(2236)==0)end; if(getskilllv(26)){skill 40,1;}else{skill 26,1+isequipped(2636);} }";
  7788. setitemscript Silver_Ring_, "";
  7789.  
  7790. ---------------------------------------
  7791.  
  7792. *atoi("<string>")
  7793. *axtoi("<string>")
  7794. *strtol("string", base)
  7795.  
  7796. These commands are used to convert strings to numbers. 'atoi' will
  7797. interpret given string as a decimal number (base 10), while 'axtoi'
  7798. interprets strings as hexadecimal numbers (base 16). 'strtol' lets
  7799. the user specify a base (valid range is between 2 and 36 inclusive,
  7800. or the special value0, which means auto-detection).
  7801.  
  7802. The atoi and strtol functions conform to the C functions with the same
  7803. names, and axtoi is the same as strtol, with a base of 16. Results are
  7804. clamped to signed 32 bit int range (INT_MIN ~ INT_MAX)
  7805.  
  7806. Example:
  7807.  
  7808. .@var = atoi("11"); // Sets .@var to 11
  7809. .@var = axtoi("FF"); // Sets .@var to 255
  7810. mes axtoi("11"); // Displays 17 (1 = 1, 10 = 16)
  7811. .@var = strtol("11", 10); // Sets .@var to 11 (11 base 10)
  7812. .@var = strtol("11", 16); // Sets .@var to 17 (11 base 16)
  7813. .@var = strtol("11", 0); // Sets .@var to 11 (11 base 10, auto-detected)
  7814. .@var = strtol("0x11", 0); // Sets .@var to 17 (11 base 16, auto-detected because of the "0x" prefix)
  7815. .@var = strtol("011", 0); // Sets .@var to 9 (11 base 8, auto-detected because of the "0" prefix)
  7816. .@var = strtol("11", 2); // Sets .@var to 3 (binary 11)
  7817.  
  7818. ---------------------------------------
  7819.  
  7820. *compare("<string>","<substring>")
  7821.  
  7822. This command returns 1 or 0 when the substring is in the main string (1)
  7823. or not (0). This command is not case sensitive.
  7824.  
  7825. Examples:
  7826.  
  7827. //dothis; will be executed ('Bloody Murderer' contains 'Blood').
  7828. if (compare("Bloody Murderer","Blood"))
  7829. dothis;
  7830. //dothat; will not be executed ('Blood butterfly' does not contain 'Bloody').
  7831. if (compare("Blood Butterfly","Bloody"))
  7832. dothat;
  7833.  
  7834. ---------------------------------------
  7835.  
  7836. *strcmp("<string>","<string>")
  7837.  
  7838. This command compares two strings and is similar to strcmp in C.
  7839.  
  7840. Return Values:
  7841. >0 : String 1 > String 2
  7842. 0 : Strings are equal
  7843. <0 : String 1 < String 2
  7844.  
  7845. Examples:
  7846. .@a = strcmp("abcdef","ABCDEF");
  7847. if (.@a > 0){
  7848. mes ".@a is greater than 0."; //Output is this.
  7849. }else{
  7850. mes ".@a is less or equal to 0";
  7851. }
  7852.  
  7853. ---------------------------------------
  7854.  
  7855. *getstrlen("<string>")
  7856.  
  7857. This function will return the length of the string given as an argument.
  7858. It is useful to check if anything input by the player exceeds name length
  7859. limits and other length limits and asking them to try to input something
  7860. else.
  7861.  
  7862. ---------------------------------------
  7863.  
  7864. *charisalpha("<string>",<position>)
  7865.  
  7866. This function will return 1 if the character number Position in the given
  7867. string is a letter, 0 if it isn't a letter but a digit or a space.
  7868. The first letter is position 0.
  7869.  
  7870. ---------------------------------------
  7871.  
  7872. *charat(<string>,<index>)
  7873.  
  7874. Returns char at specified index. If index is out of range, returns an
  7875. empty string.
  7876.  
  7877. Example:
  7878.  
  7879. charat("This is a string", 10); //returns "s"
  7880.  
  7881. ---------------------------------------
  7882.  
  7883. *setchar(<string>,<char>,<index>)
  7884.  
  7885. Returns the original string with the char at the specified index set to
  7886. the specified char. If index is out of range, the original string will be
  7887. returned. Only the 1st char in the <char> parameter will be used.
  7888.  
  7889. Example:
  7890.  
  7891. setchar("Cat", "B", 0); //returns "Bat"
  7892.  
  7893. ---------------------------------------
  7894.  
  7895. *insertchar(<string>,<char>,<index>)
  7896.  
  7897. Returns the original string with the specified char inserted at the
  7898. specified index. If index is out of range, the char will be inserted on
  7899. the end of the string that it is closest. Only the 1st char in the <char>
  7900. parameter will be used.
  7901.  
  7902. Example:
  7903.  
  7904. insertchar("laughter", "s", 0); //returns "slaughter"
  7905.  
  7906. ---------------------------------------
  7907.  
  7908. *delchar(<string>,<index>)
  7909.  
  7910. Returns the original string with the char at the specified index removed.
  7911. If index is out of range, original string will be returned.
  7912.  
  7913. Example:
  7914.  
  7915. delchar("Diet", 3); //returns "Die"
  7916.  
  7917. ---------------------------------------
  7918.  
  7919. *strtoupper(<string>)
  7920. *strtolower(<string>)
  7921.  
  7922. Returns the specified string in it's uppercase/lowercase form.
  7923. All non-alpha characters will be preserved.
  7924.  
  7925. Example:
  7926.  
  7927. strtoupper("The duck is blue!!"); //returns "THE DUCK IS BLUE!!"
  7928.  
  7929. ---------------------------------------
  7930.  
  7931. *charisupper(<string>,<index>)
  7932. *charislower(<string>,<index>)
  7933.  
  7934. Returns 1 if character at specified index of specified string is
  7935. uppercase for 'charisupper' or lowercase for 'charislower'. Otherwise, 0.
  7936. Characters not of the alphabelt will return 0.
  7937.  
  7938. Example:
  7939.  
  7940. charisupper("Cronus", 0); //returns 1
  7941.  
  7942. ---------------------------------------
  7943.  
  7944. *substr(<string>,<start_index>,<end_index>)
  7945.  
  7946. Returns the sub-string of the specified string inclusively between the set
  7947. indexes. If indexes are out of range, or the start index is after the end
  7948. index, an empty string will be returned.
  7949.  
  7950. Example:
  7951.  
  7952. substr("foobar", 3, 5); //returns "bar"
  7953.  
  7954. ---------------------------------------
  7955.  
  7956. *explode(<dest_array>,<string>,<delimiter>)
  7957.  
  7958. Breaks a string up into substrings based on the specified delimiter.
  7959. Substrings will be stored within the specified string array. Only the 1st
  7960. char of the delimiter parameter will be used. If an empty string is passed
  7961. as a delimiter, the string will be placed in the array in its original
  7962. form, without any changes.
  7963.  
  7964. Example:
  7965.  
  7966. explode(.@my_array$, "Explode:Test:1965:red:PIE", ":");
  7967. //.@my_array$ contents will be...
  7968. //.@my_array$[0]: "Explode"
  7969. //.@my_array$[1]: "Test"
  7970. //.@my_array$[2]: "1965"
  7971. //.@my_array$[3]: "red"
  7972. //.@my_array$[4]: "PIE"
  7973.  
  7974. ---------------------------------------
  7975.  
  7976. *implode(<string_array>{,<glue>})
  7977.  
  7978. Combines all substrings within the specified string array into a single
  7979. string. If the glue parameter is specified, it will be inserted inbetween
  7980. each substring.
  7981.  
  7982. Example:
  7983. setarray .@my_array$[0], "This", "is", "a", "test";
  7984. implode(.@my_array$, " "); //returns "This is a test"
  7985.  
  7986. ---------------------------------------
  7987.  
  7988. *sprintf(<format>{,param{,param{,...}}})
  7989.  
  7990. C style sprintf. The resulting string is returned same as in PHP. All C
  7991. format specifiers are supported except %n. For more info check sprintf
  7992. function at www.cplusplus.com
  7993. Number of params is only limited by Cronus' script engine.
  7994.  
  7995. Example:
  7996. .@format$ = "The %s contains %d monkeys";
  7997. dispbottom(sprintf(.@format$, "zoo", 5));
  7998. //prints "The zoo contains 5 monkeys"
  7999.  
  8000. dispbottom(sprintf(.@format$, "barrel", 82));
  8001. //prints "The barrel contains 82 monkeys"
  8002.  
  8003. ---------------------------------------
  8004.  
  8005. *sscanf(<string>,<format>{,param{,param{,...}}})
  8006.  
  8007. C style sscanf. All C format specifiers are supported.
  8008. More info: sscanf @ www.cplusplus.com. The number of params is only
  8009. limited by Cronus' script engine.
  8010.  
  8011. Example:
  8012. sscanf("This is a test: 42 foobar", "This is a test: %d %s", .@num, .@str$);
  8013. dispbottom(.@num + " " + .@str$); //prints "42 foobar"
  8014.  
  8015. ---------------------------------------
  8016.  
  8017. *strpos(<haystack>,<needle>{,<offset>})
  8018.  
  8019. PHP style strpos. Finds a substring (needle) within a string (haystack).
  8020. The offset parameter indicates the index of the string to start searching.
  8021. Returns index of substring on successful search, else -1.
  8022. Comparison is case sensitive.
  8023.  
  8024. Example:
  8025. strpos("foobar", "bar", 0); //returns 3
  8026. strpos("foobarfoo", "foo", 0); //returns 0
  8027. strpos("foobarfoo", "foo", 1); //returns 6
  8028.  
  8029. ---------------------------------------
  8030.  
  8031. *replacestr(<input>, <search>, <replace>{, <usecase>{, <count>}})
  8032.  
  8033. Replaces all instances of a search string in the input with the specified
  8034. replacement string. By default is case sensitive unless <usecase> is set
  8035. to 0. If specified it will only replace as many instances as specified
  8036. in the count parameter.
  8037.  
  8038. Example:
  8039. replacestr("testing tester", "test", "dash"); //returns "dashing dasher"
  8040. replacestr("Donkey", "don", "mon", 0); //returns "monkey"
  8041. replacestr("test test test test test", "test", "yay", 0, 3); //returns "yay yay yay test test"
  8042.  
  8043. ---------------------------------------
  8044.  
  8045. *countstr(<input>, <search>{, <usecase>})
  8046.  
  8047. Counts all instances of a search string in the input. By default is case
  8048. sensitive unless <usecase> is set to 0.
  8049.  
  8050. Example:
  8051. countstr("test test test Test", "test"); //returns 3
  8052. countstr("cake Cake", "Cake", 0); //returns 2
  8053.  
  8054. ---------------------------------------
  8055.  
  8056. *setfont <font>;
  8057.  
  8058. This command sets the current RO client interface font to one of the fonts
  8059. stored in data\*.eot by using an ID of the font. When the ID of the
  8060. currently used font is used, default interface font is used again.
  8061.  
  8062. 0 - Default
  8063. 1 - RixLoveangel
  8064. 2 - RixSquirrel
  8065. 3 - NHCgogo
  8066. 4 - RixDiary
  8067. 5 - RixMiniHeart
  8068. 6 - RixFreshman
  8069. 7 - RixKid
  8070. 8 - RixMagic
  8071. 9 - RixJJangu
  8072.  
  8073. ---------------------------------------
  8074.  
  8075. *showdigit <value>{,<type>};
  8076.  
  8077. Displays given numeric 'value' in large digital clock font on top of the
  8078. screen. The optional parameter 'type' specifies visual aspects of the
  8079. "clock" and can be one of the following values:
  8080.  
  8081. 0 - Displays the value for 5 seconds (default).
  8082. 1 - Incremental counter (1 tick/second).
  8083. 2 - Decremental counter (1 tick/second). Does not stop at zero, but
  8084. overflows.
  8085. 3 - Decremental counter (1 tick/second). Two digits only, stops at
  8086. zero.
  8087.  
  8088. For type 1 and 2 the start value is set by using negative number of the
  8089. one intended to set (ex. -10 starts the counter at 10 seconds). Except for
  8090. type 3 the value is interpreted as seconds and formatted as time in days,
  8091. hours, minutes and seconds. Note, that the official script command does
  8092. not have the optional parameter.
  8093.  
  8094. // displays 23:59:59 for 5 seconds
  8095. showdigit 86399;
  8096.  
  8097. // counter that starts at 60 and runs for 60 seconds
  8098. showdigit 60,3;
  8099.  
  8100. ---------------------------------------
  8101.  
  8102. * The Pet AI commands
  8103.  
  8104. These commands will only work if the invoking character has a pet, and are
  8105. meant to be executed from pet scripts. They will modify the pet AI
  8106. decision-making for the current pet of the invoking character, and will
  8107. NOT have any independent effect by themselves, which is why only one of
  8108. them each may be in effect at any time for a specific pet. A pet may
  8109. have 'petloot', 'petskillbonus', 'petskillattack' and 'petskillsupport' at the
  8110. same time.
  8111.  
  8112. *petskillbonus <bonus type>,<value>,<duration>,<delay>;
  8113.  
  8114. This command will make the pet give a bonus to the owner's stat (bonus
  8115. type - bInt,bVit,bDex,bAgi,bLuk,bStr,bSpeedRate - for a full list, see the
  8116. values starting with 'b' in 'db/const.txt').
  8117.  
  8118. *petrecovery <status type>,<delay>;
  8119.  
  8120. This command will make the pet cure a specified status condition. The
  8121. curing actions will occur once every <delay> seconds. For a full list of
  8122. status conditions that can be cured, see the list of 'SC_' status
  8123. condition constants in 'db/const.txt'
  8124.  
  8125. *petloot <max items>;
  8126.  
  8127. This command will turn on pet looting, with a maximum number of items to
  8128. loot specified. Pet will store items and return them when the maximum is
  8129. reached or when pet performance is activated.
  8130.  
  8131. *petskillsupport <skill id>,<skill level>,<delay>,<percent hp>,<percent sp>;
  8132. *petskillsupport "<skill name>",<skill level>,<delay>,<percent hp>,<percent sp>;
  8133.  
  8134. This will make the pet use a specified support skill on the owner whenever
  8135. the HP and SP are below the given percent values, with a specified delay
  8136. time between activations. The skill numbers are as per
  8137. 'db/(pre-)re/skill_db.txt'.
  8138. It's not quite certain who's stats will be used for the skills cast, the
  8139. character's or the pets. Probably, Skotlex can answer that question.
  8140.  
  8141. *petskillattack <skill id>,<damage>,<number of attacks>,<rate>,<bonusrate>;
  8142. *petskillattack "<skill name>",<damage>,<number of attacks>,<rate>,<bonusrate>;
  8143.  
  8144. This command will make the pet cast an attack skill on the enemy the pet's
  8145. owner is currently fighting. Skill IDs and levels are as per 'petskillsupport'.
  8146. If <number of attacks> is specified different than 0, it will make the pet cast
  8147. the skill with a fixed amount of damage inflicted and the specified number of
  8148. attacks. A value of zero uses the skill's defaults.
  8149.  
  8150. All commands with delays and durations will only make the behavior active
  8151. for the specified duration of seconds, with a delay of the specified
  8152. number of seconds between activations. Rates are a chance of the effect
  8153. occurring and are given in percent. 'bonusrate' is added to the normal
  8154. rate if the pet intimacy is at the maximum possible.
  8155.  
  8156. The behavior modified with the above mentioned commands will only be
  8157. exhibited if the pet is loyal and appropriate configuration options are
  8158. set in 'battle.conf'.
  8159.  
  8160. Pet scripts in the database normally run whenever a pet of that type
  8161. hatches from the egg. Other commands usable in item scripts (see 'bonus')
  8162. will also happily run from pet scripts. Apparently, the pet-specific
  8163. commands will also work in NPC scripts and modify the behavior of the
  8164. current pet up until the pet is hatched again. (Which will also occur when
  8165. the character is logged in again with the pet still out of the egg.) It is
  8166. not certain for how long the effect of such command running from an NPC
  8167. script will eventually persist, but apparently, it is possible to usefully
  8168. employ them in usable item scripts to create pet buffing items.
  8169.  
  8170. Nobody tried this before, so you're essentially on your own here.
  8171.  
  8172. ---------------------------------------
  8173.  
  8174. *bpet;
  8175.  
  8176. This command opens up a pet hatching window on the client connected to the
  8177. invoking character. It is used in item script for the pet incubators and
  8178. will let the player hatch an owned egg. If the character has no eggs, it
  8179. will just open up an empty incubator window.
  8180. This is still usable outside item scripts.
  8181.  
  8182. ---------------------------------------
  8183.  
  8184. *makepet <pet id>;
  8185.  
  8186. This command will create a pet egg and put it in the invoking character's
  8187. inventory. The kind of pet is specified by pet ID numbers listed in
  8188. 'db/pet_db.txt'. The egg is created exactly as if the character just
  8189. successfully caught a pet in the normal way.
  8190.  
  8191. // This will make you a poring:
  8192. makepet 1002;
  8193.  
  8194. Notice that you absolutely have to create pet eggs with this command. If
  8195. you try to give a pet egg with 'getitem', pet data will not be created by
  8196. the char server and the egg will disappear when anyone tries to hatch it.
  8197.  
  8198. ---------------------------------------
  8199.  
  8200. *homshuffle;
  8201.  
  8202. This will recalculate the homunculus stats according to its level, of the
  8203. current invoking character.
  8204.  
  8205. ---------------------------------------
  8206.  
  8207. *setcell "<nome do mapa>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>;
  8208.  
  8209. Each map cell has several 'flags' that specify the properties of that cell.
  8210. These include terrain properties (walkability, shootability, presence of
  8211. water), skills (basilica, land protector, ...) and other (NPC nearby, no
  8212. vending, ...).
  8213. Each of these can be 'on' or 'off'. Together they define a cell's behavior.
  8214.  
  8215. This command lets you alter these flags for all map cells in the specified
  8216. (x1,y1)-(x2,y2) rectangle.
  8217. 'type' defines which flag to modify. Possible options include cell_walkable,
  8218. cell_shootable, cell_basilica. For a full list, see const.txt.
  8219. 'flag' can be 0 or 1 (0:clear flag, 1:set flag).
  8220.  
  8221. Example:
  8222.  
  8223. setcell "arena",0,0,300,300,cell_basilica,1;
  8224. setcell "arena",140,140,160,160,cell_basilica,0;
  8225. setcell "arena",135,135,165,165,cell_walkable,0;
  8226. setcell "arena",140,140,160,160,cell_walkable,1;
  8227.  
  8228. This will add a makeshift ring into the center of the map. The ring will
  8229. be surrounded by a 5-cell wide 'gap' to prevent interference from outside,
  8230. and the rest of the map will be marked as 'basilica', preventing observers
  8231. from casting any offensive skills or fighting among themselves. Note that
  8232. the wall will not be shown nor known client-side, which may cause movement
  8233. problems.
  8234.  
  8235. Another example:
  8236.  
  8237. OnBarricadeDeploy:
  8238. setcell "schg_cas05",114,51,125,51,cell_walkable,0;
  8239. end;
  8240. OnBarricadeBreak:
  8241. setcell "schg_cas05",114,51,125,51,cell_walkable,1;
  8242. end;
  8243.  
  8244. This could be a part of the WoE:SE script, where attackers are not allowed
  8245. to proceed until all barricades are destroyed. This script would place and
  8246. remove a nonwalkable row of cells after the barricade mobs.
  8247.  
  8248. ---------------------------------------
  8249.  
  8250. *checkcell ("<nome do mapa>",<x>,<y>,<type>);
  8251.  
  8252. This command will return 1 or 0, depending on whether the specified cell
  8253. has the 'type' flag set or not. There are various types to check, all
  8254. mimicking the server's cell_chk enumeration. The types can be found in
  8255. db/const.txt.
  8256.  
  8257. The meaning of the individual types can be confusing, so here's an
  8258. overview:
  8259. - cell_chkwall/water/cliff
  8260. these check directly for the 'terrain component' of the specified cell
  8261. - cell_chkpass/reach/nopass/noreach
  8262. passable = not wall & not cliff, reachable = passable
  8263. wrt. no-stacking mod
  8264. - cell_chknpc/basilica/landprotector/novending/nochat
  8265. these check for specific dynamic flags (name indicates what they do)
  8266.  
  8267. Example:
  8268.  
  8269. mes "Pick a destination map.";
  8270. input .@map$;
  8271. mes "Alright, now give me the coordinates.";
  8272. input .@x;
  8273. input .@y;
  8274. if( !checkcell(.@map$,.@x,.@y,cell_chkpass) )
  8275. {
  8276. mes "Can't warp you there, sorry!";
  8277. close;
  8278. }
  8279. else
  8280. {
  8281. mes "Ok, get ready...";
  8282. close2;
  8283. warp .@map$, .@x, .@y;
  8284. end;
  8285. }
  8286.  
  8287. ---------------------------------------
  8288.  
  8289. *setwall "<nome do mapa>",<x>,<y>,<size>,<dir>,<shootable>,"<name>";
  8290. *delwall "<name>";
  8291.  
  8292. Creates an invisible wall, an array of "setcell" starting from x,y and
  8293. doing a line of the given size in the given direction. The difference with
  8294. setcell is this one update client part too to avoid the glitch problem.
  8295. Directions are the same as NPC sprite facing directions: 0=north,
  8296. 1=northwest, 2=west, etc.
  8297.  
  8298. ---------------------------------------
  8299.  
  8300. *readbook <book id>,<page>;
  8301.  
  8302. This will open a book item at the specified page.
  8303.  
  8304. ---------------------------------------
  8305. //=====================================
  8306. 7 - Instance-Related Commands
  8307. //=====================================
  8308. ---------------------------------------
  8309.  
  8310. *instance_create("<instance name>",<owner id>{,<optional owner_type>});
  8311.  
  8312. Create an instance using the name "<instance name>" for the <owner_id> of
  8313. owner_type (when not provided, defaults to IOT_PARTY). Most instance_*
  8314. commands are used in conjunction with this command and depend on the
  8315. ID this command returns.
  8316.  
  8317. Example:
  8318. // Store the Party ID of the invoking character.
  8319. .@party_id = getcharid(1);
  8320.  
  8321. // Attempt to create an instance using that party ID.
  8322. .@id = instance_create("Endless Tower", .@party_id);
  8323. if (.@id == -1) { // Invalid type - not used anymore
  8324. ...
  8325. } else if (.@id == -2) { // Invalid Party ID
  8326. ...
  8327. } else if (.@id == -3) { // No free instances (MAX_INSTANCE exceeded)
  8328. ...
  8329. } else if (.@id == -4) { // Already exists
  8330. ...
  8331. } else (.@id < 0) { // Unspecified error while queuing instance.
  8332. ...
  8333. }
  8334.  
  8335. ---------------------------------------
  8336.  
  8337. *instance_destroy {<instance id>};
  8338.  
  8339. Destroys instance with the ID <instance id>. If no ID is specified, the
  8340. instance the script is attached to is used. If in the end no instance_id,
  8341. is found the command halts the script execution.
  8342.  
  8343. ---------------------------------------
  8344.  
  8345. *instance_attachmap("<nome do mapa>",<instance id>{,<use base name>{,"<new nome do mapa>"}});
  8346.  
  8347. Attaches the map "<nome do mapa>" to the instance specified with
  8348. <instance id>. The optional parameter specifies, whether a map requires
  8349. emulation for instancing (1) or not (0 = default). if use base name is specified,
  8350. and "<new nome do mapa>" too the server will instance the map under the "<new nome do mapa>",
  8351. name.
  8352.  
  8353. Returns the resulting nome do mapa on success or an empty string on failure.
  8354.  
  8355. Example:
  8356. instance_attachmap("prontera", .@instance_id,1,"via");
  8357. ^ the above creates a instance (or clone) of prontera, on a map called "via"
  8358.  
  8359. ---------------------------------------
  8360.  
  8361. *instance_detachmap "<nome do mapa>"{,<instance id>};
  8362.  
  8363. Detach the map "<nome do mapa>" to the instance with the <instance id>. If no
  8364. ID is specified, the instance the script is attached to is used. If in the
  8365. end no instance_id is found the command halts the script execution.
  8366.  
  8367. ---------------------------------------
  8368.  
  8369. *instance_init <instance id>;
  8370.  
  8371. Initializes the instance given by <instance id>. This copies all NPCs from
  8372. the source maps to the instanced maps.
  8373.  
  8374. ---------------------------------------
  8375.  
  8376. *instance_announce <instance id>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
  8377.  
  8378. Works like announce, but has the <instance id> parameter. If instance id
  8379. is -1, the instance the script is attached to is used. If in the
  8380. end no instance_id is found the command halts the script execution.
  8381.  
  8382. ---------------------------------------
  8383.  
  8384. *instance_attach <instance id>;
  8385.  
  8386. Attaches the current script to the instance given by <instance id>.
  8387.  
  8388. ---------------------------------------
  8389.  
  8390. *instance_npcname("<npc name>"{,<instance id>});
  8391.  
  8392. Retrieves the unique name given to a copy of an NPC given by "<npc name>"
  8393. in an instance specified <instance id>. If no ID is specified, the
  8394. instance the script is attached to is used. If in the end no instance_id,
  8395. is found the command halts the script execution.
  8396.  
  8397. ---------------------------------------
  8398.  
  8399. *has_instance("<nome do mapa>"{,<instance id>});
  8400.  
  8401. Checks whether or not the given map belongs to specified instance. If no
  8402. ID is specified, the instance the script is attached to is used. If the
  8403. script is not attached to an instance, it'll try to check whether the,
  8404. player attached to the script possesses an instance with a map matching
  8405. "<nome do mapa>". If in the end no instance_id is found the command halts the,
  8406. script execution.
  8407.  
  8408. Returns name of the instanced map on success, otherwise an empty string.
  8409.  
  8410. ---------------------------------------
  8411.  
  8412. *has_instance2("<nome do mapa>");
  8413.  
  8414. Same as has_instance, with exception it returns the instance id of the map,
  8415. as long as the user is assigned to a instance containing that map.
  8416. It will return -1 upon failure, valid instance ids are >= 0.
  8417.  
  8418. ---------------------------------------
  8419.  
  8420. *instance_id();
  8421.  
  8422. Retrieves the instance id of the script it is being run on.
  8423.  
  8424. ---------------------------------------
  8425.  
  8426. *instance_warpall "<nome do mapa>",<x>,<y>{,<instance id>};
  8427.  
  8428. Warps all players in the instance <instance id> to <nome do mapa> at given
  8429. coordinates. If no ID is specified, the instance the script is attached to
  8430. is used. If in the end no instance_id is found the command halts the,
  8431. script execution.
  8432.  
  8433. ---------------------------------------
  8434.  
  8435. *instance_set_timeout <alive timeout>,<idle timeout>{,<instance id>};
  8436.  
  8437. Sets the timeout values for an instance given by <instance id>. If no ID
  8438. is specified, the instance the script is attached to is used. If in the end,
  8439. no instance_id is found the command halts the script execution.
  8440.  
  8441. Parameter <alive timeout> specifies the total amount of time the instance
  8442. will exist. Parameter <idle timeout> specifies how long players have, when
  8443. they are outside of the instance, until it is destroyed.
  8444.  
  8445. Both timeout values are in seconds.
  8446.  
  8447. ---------------------------------------
  8448.  
  8449. *instance_check_party(<party id>{,<amount>{,<min>{,<max>}}});
  8450.  
  8451. This function checks if a party meets certain requirements, returning 1 if
  8452. all conditions are met and 0 otherwise. It will only check online
  8453. characters.
  8454.  
  8455. amount - number of online party members (default is 1).
  8456. min - minimum level of all characters in the party (default is 1).
  8457. max - maximum level of all characters in the party (default is max
  8458. level in conf).
  8459.  
  8460. Example:
  8461.  
  8462. if (instance_check_party(getcharid(1),2,2,149)) {
  8463. mes "Your party meets the Memorial Dungeon requirements.",
  8464. mes "All online members are between levels 1-150 and at least two are online.";
  8465. close;
  8466. } else {
  8467. mes "Sorry, your party does not meet the requirements.";
  8468. close;
  8469. }
  8470.  
  8471. ---------------------------------------
  8472.  
  8473. *instance_check_guild(<guild_id>{,<amount>{,<min>{,<max>}}});
  8474.  
  8475. This function checks if a guild meets certain requirements, returning 1 if
  8476. all conditions are met and 0 otherwise. it will only check online characters.
  8477.  
  8478. amount - number of online guild members (default is 1).
  8479. min - minimum level of all characters in the guild (default is 1).
  8480. max - maximum level of all characters in the guild (default is max level in conf).
  8481.  
  8482. Example:
  8483. if (instance_check_guild(getcharid(2), 2, 1, 150)) {
  8484. mes "Your guild meets the Memorial Dungeon requirements.",
  8485. mes "All online members are between levels 1-150 and at least two are online.";
  8486. close;
  8487. } else {
  8488. mes "Sorry, your guild does not meet the requirements.";
  8489. close;
  8490. }
  8491.  
  8492. ---------------------------------------
  8493. *instance_set_respawn(<map_name>,<x>,<y>{,<instance_id>});
  8494.  
  8495. Updates the 'reload spawn' position of a instance,
  8496. that is where players in the instance are sent to upon @reloadscript,
  8497. uses the npc instance (if any) when instance_id is not provided,
  8498. handy to update a instance's progress so that when/if @reloadscript happens
  8499. the damage to the players progress is reduced.
  8500. It is most effective when used with instance variables (which are @reloadscript persistent)
  8501.  
  8502. If a player warps into a instance before this command has been used,
  8503. it will use the player's warp destination as the initial respawn point,
  8504. it can of course be modified by using this script command at any point.
  8505.  
  8506. ---------------------------------------
  8507. *instance_mapname("<nome do mapa>"{,<instance id>})
  8508.  
  8509. Returns the unique name of the instanced map. If no instance ID is specified,
  8510. the instance the script is attached to is used. If the script is not attached to
  8511. an instance, the instance of the currently attached player's party is used. If
  8512. that fails, the command returns an empty string instead.
  8513.  
  8514.  
  8515. ---------------------------------------
  8516. //=====================================
  8517. 7 - End of Instance-Related Commands
  8518. //=====================================
  8519. ---------------------------------------
  8520.  
  8521.  
  8522. ---------------------------------------
  8523. //=====================================
  8524. 8 - Quest Log-Related Commands
  8525. //=====================================
  8526. ---------------------------------------
  8527.  
  8528. *questinfo <Quest ID>, <Icon> {, <Map Mark Color>{, <Job Class>}};
  8529.  
  8530. This is esentially a combination of questprogress and showevent. Use this only
  8531. in an OnInit label. For the Quest ID, specify the quest ID that you want
  8532. checked if it has been started yet.
  8533.  
  8534. For Icon, use one of the following:
  8535.  
  8536. No Icon : QTYPE_NONE
  8537. ! Quest Icon : QTYPE_QUEST
  8538. ? Quest Icon : QTYPE_QUEST2
  8539. ! Job Icon : QTYPE_JOB
  8540. ? Job Icon : QTYPE_JOB2
  8541. ! Event Icon : QTYPE_EVENT
  8542. ? Event Icon : QTYPE_EVENT2
  8543. Warg : QTYPE_WARG
  8544. Warg Face : QTYPE_WARG2 (Only for packetver >= 20120410)
  8545.  
  8546. Map Mark Color, when used, creates a mark in the user's mini map on the position of the NPC,
  8547. the available color values are:
  8548.  
  8549. 0 - No Marker
  8550. 1 - Yellow Marker
  8551. 2 - Green Marker
  8552. 3 - Purple Marker
  8553.  
  8554. When a user shows up on a map, each NPC is checked for questinfo that has been set.
  8555. If questinfo is present, it will check if the quest has been started, if it has not, the bubble will appear.
  8556.  
  8557. Optionally, you can also specify a Job Class if the quest bubble should only appear for a certain class.
  8558.  
  8559. Example
  8560. izlude,100,100,4 script Test 844,{
  8561. mes "[Test]";
  8562. mes "Hello World.";
  8563. close;
  8564.  
  8565. OnInit:
  8566. questinfo 1001, QTYPE_QUEST, 0, Job_Novice;
  8567. end;
  8568. }
  8569.  
  8570. ---------------------------------------
  8571.  
  8572. *setquest <ID>;
  8573.  
  8574. Place quest of <ID> in the users quest log, the state of which is "active".
  8575.  
  8576. If *questinfo is set, and the same ID is specified here, the icon will be cleared when the quest is set.
  8577.  
  8578. ---------------------------------------
  8579.  
  8580. *completequest <ID>{,<ID2>};
  8581.  
  8582. Change the state for the given quest <ID> to "complete" and remove from
  8583. the users quest log.
  8584.  
  8585. If a second quest id of greater value is specified, all quests between the two
  8586. will be completed.
  8587.  
  8588. ---------------------------------------
  8589.  
  8590. *erasequest <ID>{,<ID2>};
  8591.  
  8592. Remove the quest of the given <ID> from the user's quest log.
  8593.  
  8594. If a second quest id of greater value is specified, all quests between the two
  8595. will be erased.
  8596.  
  8597. ---------------------------------------
  8598.  
  8599. *changequest <ID>,<ID2>;
  8600.  
  8601. Remove quest of the given <ID> from the user's quest log.
  8602. Add quest of the <ID2> to the the quest log, and the state is "active".
  8603.  
  8604. ---------------------------------------
  8605.  
  8606. *questprogress(<ID>{,PLAYTIME|HUNTING})
  8607.  
  8608. If no additional argument supplied, return the state of the quest:
  8609. 0 = Quest not started (not in quest log)
  8610. 1 = Quest has been given
  8611. 2 = Quest completed
  8612.  
  8613. If parameter 'PLAYTIME' is supplied:
  8614. 0 = Quest not started (not in quest log)
  8615. 1 = The time limit has not yet been reached
  8616. 2 = The time limit has been reached
  8617.  
  8618. If parameter 'HUNTING' is supplied:
  8619. 0 = Quest not started (not in quest log)
  8620. 1 = Player hasn't killed all of the target monsters
  8621. 2 = Player has killed all of the target monsters
  8622.  
  8623. ---------------------------------------
  8624.  
  8625. *questactive(<ID>)
  8626.  
  8627. Check whether the given quest is in its active state.
  8628.  
  8629. Returns true if the quest is active, false otherwise (quest not started,
  8630. inactive or completed)
  8631.  
  8632. ---------------------------------------
  8633.  
  8634. *showevent <icon>{,<mark color>}
  8635.  
  8636. Show an emotion on top of a NPC, and optionally,
  8637. a colored mark in the mini-map like "viewpoint".
  8638. This is used to indicate that a NPC has a quest or an event to
  8639. a certain player.
  8640.  
  8641. Available Icons:
  8642.  
  8643. Remove Icon : QTYPE_NONE
  8644. ! Quest Icon : QTYPE_QUEST
  8645. ? Quest Icon : QTYPE_QUEST2
  8646. ! Job Icon : QTYPE_JOB
  8647. ? Job Icon : QTYPE_JOB2
  8648. ! Event Icon : QTYPE_EVENT
  8649. ? Event Icon : QTYPE_EVENT2
  8650. Warg : QTYPE_WARG
  8651. Warg Face : QTYPE_WARG2 (Only for packetver >= 20120410)
  8652.  
  8653. Mark Color:
  8654. 0 - No Mark
  8655. 1 - Yellow Mark
  8656. 2 - Green Mark
  8657. 3 - Purple Mark
  8658.  
  8659. ---------------------------------------
  8660. //=====================================
  8661. 8 - End of Quest Log-Related Commands
  8662. //=====================================
  8663. ---------------------------------------
  8664.  
  8665.  
  8666. ---------------------------------------
  8667. //=====================================
  8668. 9 - Battlegrounds-Related Commands
  8669. //=====================================
  8670. ---------------------------------------
  8671.  
  8672. *waitingroom2bg_single(<battle group>,"<mapname>",<x>,<y>,"<npc name>");
  8673.  
  8674. Adds the first waiting player from the chat room of given NPC to an
  8675. existing battleground group and warps it to specified coordinates on given
  8676. map.
  8677.  
  8678. ---------------------------------------
  8679.  
  8680. *waitingroom2bg("<mapname>",<x>,<y>,"<On Quit Event>","<On Death Event>"{,"<npc name>"});
  8681.  
  8682. <Mapname> and X Y coordinates refer to where the "respawn" base is, where
  8683. the player group will respawn when they die.
  8684. <On Quit Event> refers to an NPC label that attaches to the character and
  8685. is run when they relog.
  8686. <On Death Event> refers to an NPC label that attaches to the character and
  8687. is run when they die. Can be "" for empty.
  8688.  
  8689. Unlike the prior command, the latter will attach a GROUP in a waiting room
  8690. to the battleground, and sets the array $@arenamembers[0] where 0 holds
  8691. the IDs of the first group, and 1 holds the IDs of the second.
  8692.  
  8693. If the option parameter is left out, the waiting room of the current NPC
  8694. is used.
  8695.  
  8696. Example:
  8697. // Battle Group will be referred to as $@KvM01BG_id1, and when they
  8698. // die, respawn at bat_c01,52,129.
  8699. $@KvM01BG_id1 = waitingroom2bg("bat_c01",52,129,"KvM01_BG::OnGuillaumeQuit","KvM01_BG::OnGuillaumeDie");
  8700. end;
  8701.  
  8702. ----------------------------------------
  8703.  
  8704. *bg_team_setxy <Battle Group ID>,<x>,<y>;
  8705.  
  8706. Update the respawn point of the given battle group to x, y on the same
  8707. map. The <Battle Group ID> can be retrieved using getcharid(4).
  8708.  
  8709. Example:
  8710. bg_team_setxy getcharid(4),56,212;
  8711. mapannounce "bat_a01", "Group [1] has taken the work shop, and will now respawn there.",bc_map,0xFFCE00;
  8712. end;
  8713.  
  8714. ----------------------------------------
  8715.  
  8716. *bg_warp <Battle Group>,"<Mapname>",<x>,<y>;
  8717.  
  8718. Similar to warp command.
  8719. Place all members of <Battle Group> at <mapname> at x y.
  8720.  
  8721. Example:
  8722. //place the battle group one for Tierra Gorge at starting position.
  8723. bg_warp $@TierraBG1_id1,"bat_a01",352,342;
  8724. end;
  8725.  
  8726. ----------------------------------------
  8727.  
  8728. *bg_monster <Battle Group>,"<nome do mapa>",<x>,<y>,"<name to show>",<mob id>,"<event label>";
  8729. *bg_monster(<Battle Group>,"<nome do mapa>",<x>,<y>,"<name to show>",<mob id>,"<event label>");
  8730.  
  8731. Similar to monster script command.
  8732. Spawn a monster with allegiance to the given battle group.
  8733. Does not allow for the summoning of multiple monsters.
  8734. Monsters are similar to that in War of Emperium, in that the specified
  8735. Battle group is considered friendly.
  8736.  
  8737. Example:
  8738. // It can be used in two different ways.
  8739. bg_monster $@TierraBG1_id2,"bat_a01",167,50,"Food Depot",OBJ_B,"Feed Depot#1::OnMyMobDead";
  8740. end;
  8741.  
  8742. // Alternatively, you can set an ID for the monster using "set".
  8743. // This becomes useful when used with the command below.
  8744. $@Guardian_3 = bg_monster($@TierraBG1_id2,"bat_a01",268,204,"Guardian",B_S_GUARDIAN,"NPCNAME::OnMyMobDead");
  8745. end;
  8746.  
  8747. ----------------------------------------
  8748.  
  8749. *bg_monster_set_team <GID>,<Battle Group>;
  8750.  
  8751. This command will change the allegiance if a monster in a battle ground.
  8752. GID can be set when spawning the monster via the bg_monster command.
  8753.  
  8754. Example:
  8755.  
  8756. end;
  8757.  
  8758. OnEnable:
  8759. mapannounce "A guardian has been summoned for Battle Group 2!",bc_map,0xFFCE00;
  8760. set $@Guardian, bg_monster($@BG_2,"bat_a01",268,204,"Guardian",B_S_GUARDIAN,"NPCNAME::OnMyMobDead");
  8761. initnpctimer;
  8762. end;
  8763.  
  8764. OnTimer1000:
  8765. stopnpctimer;
  8766. mapannounce "Erm, sorry about that! This monster was meant for Battle Group 1.",bc_map,0xFFCE00;
  8767. bg_monster_set_team $@Guardian, $@BG_1;
  8768. end;
  8769.  
  8770. ----------------------------------------
  8771.  
  8772. *bg_leave;
  8773.  
  8774. Removes attached player from their Battle Group.
  8775.  
  8776. ----------------------------------------
  8777.  
  8778. *bg_destroy <Batte Group>;
  8779.  
  8780. As the name says, destroys the battle group created for that battle ground.
  8781.  
  8782. ----------------------------------------
  8783.  
  8784. *areapercentheal "<mapname>",<x1>,<y1>,<x2>,<y2>,<hp>,<sp>;
  8785.  
  8786. Not exactly limited to battleground use, this will restore HP/SP in a
  8787. defined area at a percentage.
  8788.  
  8789. Example:
  8790. areapercentheal "bat_a01",52,208,61,217,100,100;
  8791. end;
  8792.  
  8793. ----------------------------------------
  8794.  
  8795. *bg_get_data(<Battle Group>,<type>);
  8796.  
  8797. Retrieves data related to given battle group. Type can be one of the
  8798. following:
  8799.  
  8800. 0 - Amount of players currently belonging to the group.
  8801.  
  8802. ----------------------------------------
  8803.  
  8804. *bg_getareausers(<battle group>,<nome do mapa>,<x0>,<y0>,<x1>,<y1>);
  8805.  
  8806. Retrieves amount of players belonging to given battle group on given map
  8807. within an specified rectangular area.
  8808.  
  8809. ----------------------------------------
  8810.  
  8811. *bg_updatescore "<mapname>",<Guillaume Score>,<Croix Score>;
  8812.  
  8813. This command will force the update of the displayed scoreboard.
  8814. It is only usable when the map is defined as a Type 2 Battleground:
  8815. mapflag%TAB%<mapname>%TAB%battleground%TAB%2
  8816.  
  8817. ---------------------------------------
  8818. //=====================================
  8819. 9 - End of Battlegrounds-Related Commands
  8820. //=====================================
  8821. ---------------------------------------
  8822.  
  8823.  
  8824. ---------------------------------------
  8825. //=====================================
  8826. 10 - Mercenary Commands
  8827. //=====================================
  8828. ---------------------------------------
  8829.  
  8830. *mercenary_create <class>,<contract time>;
  8831.  
  8832. This command summons a mercenary of given class, for given amount of time
  8833. in milliseconds. Typically used in item scripts of mercenary scrolls.
  8834.  
  8835. ----------------------------------------
  8836.  
  8837. *mercenary_heal <hp>,<sp>;
  8838.  
  8839. This command works like 'heal', but affects the mercenary of the currently
  8840. attached character.
  8841.  
  8842. ----------------------------------------
  8843.  
  8844. *mercenary_sc_start <type>,<tick>,<val1>;
  8845.  
  8846. This command works like 'sc_start', but affects the mercenary of the
  8847. currently attached character.
  8848.  
  8849. ----------------------------------------
  8850.  
  8851. *mercenary_get_calls(<guild>);
  8852. *mercenary_set_calls <guild>,<value>;
  8853.  
  8854. Sets or gets the mercenary calls value for given guild for currently
  8855. attached character. Guild can be one or the following constants:
  8856.  
  8857. ARCH_MERC_GUILD
  8858. SPEAR_MERC_GUILD
  8859. SWORD_MERC_GUILD
  8860.  
  8861. ----------------------------------------
  8862.  
  8863. *mercenary_get_faith(<guild>);
  8864. *mercenary_set_faith <guild>,<value>;
  8865.  
  8866. Sets or gets the mercenary faith value for given guild for currently
  8867. attached character. Guild can be one or the following constants:
  8868.  
  8869. ARCH_MERC_GUILD
  8870. SPEAR_MERC_GUILD
  8871. SWORD_MERC_GUILD
  8872.  
  8873. ---------------------------------------
  8874.  
  8875. *getmercinfo(<type>{,<char id>});
  8876.  
  8877. Retrieves information about mercenary of the currently attached character.
  8878. If char id is given, the information of that character is retrieved
  8879. instead. Type specifies what information to retrieve and can be one of the
  8880. following:
  8881.  
  8882. 0 - Database ID
  8883. 1 - Class
  8884. 2 - Name
  8885. 3 - Faith value for this mercenary's guild, if any
  8886. 4 - Calls value for this mercenary's guild, if any
  8887. 5 - Kill count
  8888. 6 - Remaining life time in msec
  8889. 7 - Level
  8890.  
  8891. If the character does not have a mercenary, the command returns ""
  8892. for name and 0 for all other types.
  8893.  
  8894. ---------------------------------------
  8895. //=====================================
  8896. 10 - End of Mercenary-Related Commands
  8897. //=====================================
  8898. ---------------------------------------
  8899.  
  8900.  
  8901. ---------------------------------------
  8902. //=====================================
  8903. 11 - Queue-Related Commands
  8904. //=====================================
  8905. ---------------------------------------
  8906.  
  8907. *queue();
  8908.  
  8909. Creates a new queue instance and returns the created queue id.
  8910.  
  8911. ---------------------------------------
  8912.  
  8913. *queuesize(<queue_id>);
  8914.  
  8915. Returns the amount of entries in the queue instance of <queue_id>.
  8916.  
  8917. ---------------------------------------
  8918.  
  8919. *queueadd(<queue_id>,<var_id>);
  8920.  
  8921. Adds <var_id> to queue of <queue_id>, returning 1 if <var_id> is already
  8922. present in the queue, otherwise returning 0.
  8923.  
  8924. ---------------------------------------
  8925.  
  8926. *queueremove(<queue_id>,<var_id>);
  8927.  
  8928. Removes <var_id> from queue of <queue_id>, returning 1 if <var_id> is not
  8929. present in the queue, otherwise returning 0.
  8930.  
  8931. ---------------------------------------
  8932.  
  8933. *queueopt(<queue_id>,<optionType>,{Optional <option val>});
  8934.  
  8935. Modifies <queue_id>'s <optionType>. When <option val> is not present
  8936. <optionType> is removed from <queue_id>. When present it modifies
  8937. <queue_id>'s <optionType> with the new <option val> value.
  8938.  
  8939. Currently 3 options are available:
  8940. HQO_OnDeath (1), HQO_OnLogout (2), HQO_OnMapChange (3)
  8941.  
  8942. Note: The constant names are not final.
  8943.  
  8944. Example:
  8945. queueopt(.@queue_id,0,"MyNPC::MyOnQueueMemberDeathEventName");
  8946.  
  8947. ---------------------------------------
  8948.  
  8949. *queuedel(<queue_id>);
  8950.  
  8951. Deletes <queue_id> and returns 1 when <queue_id> is not found, otherwise
  8952. 0 is returned.
  8953.  
  8954. ---------------------------------------
  8955.  
  8956. *queueiterator(<queue_id>);
  8957.  
  8958. Creates a new queue iterator instance.
  8959. A queue iterator is not a reference to a queue's actual members, it copies
  8960. the queues members when initialized, this way you can loop through them
  8961. even if you remove them from the queue.
  8962.  
  8963. ---------------------------------------
  8964.  
  8965. *qicheck(<queue_iterator_id>);
  8966. checks whether there is a next member in the iterator's queue, 1 when
  8967. it does, 0 otherwise.
  8968.  
  8969. ---------------------------------------
  8970.  
  8971. *qiget(<queue_iterator_id>);
  8972.  
  8973. obtains the next member in the iterator's queue, returns the next member's
  8974. id or 0 when it doesnt exist.
  8975.  
  8976. Example:
  8977. for (.@elem = qiget(.@queue_iterator_id); qicheck(.@queue_iterator_id); .@elem = qiget(.@queue_iterator_id)) {
  8978. //Do something
  8979. }
  8980.  
  8981. ---------------------------------------
  8982.  
  8983. *qiclear(<queue_iterator_id>);
  8984.  
  8985. Deletes a queue iterator from memory and returns 1 when it fails,
  8986. otherwise 0 is returned.
  8987.  
  8988. ---------------------------------------
  8989. //=====================================
  8990. 11 - End of Queue-Related Commands
  8991. //=====================================
  8992. ---------------------------------------
  8993.  
  8994. ---------------------------------------
  8995. //=====================================
  8996. 12 - NPC Trader-Related Commands
  8997. //=====================================
  8998. Commands that control NPC Trader Shops
  8999. See /doc/sample/npc_trader_sample.txt
  9000. ---------------------------------------
  9001.  
  9002. *openshop({NPC_Name});
  9003.  
  9004. opens the trader shop from the currently-attached npc unless,
  9005. when the optional NPC_Name param is used.
  9006.  
  9007. ---------------------------------------
  9008.  
  9009. *sellitem <Item_ID>{,<price>{,<qty>}};
  9010.  
  9011. adds (or modifies) <Item_ID> data to the shop,
  9012. when <price> is not provided (or when it is -1) itemdb default is used.
  9013. qty is only necessary for NST_MARKET trader types.
  9014.  
  9015. when <Item_ID> is already in the shop,
  9016. the previous data (price/qty), is overwritten with the new.
  9017.  
  9018. ---------------------------------------
  9019.  
  9020. *stopselling <Item_ID>;
  9021.  
  9022. attempts to remove <Item_ID> from the current shop list.
  9023.  
  9024. ---------------------------------------
  9025.  
  9026. *setcurrency <Val1>{,<Val2>};
  9027.  
  9028. updates the currently attached player shop funds,
  9029. to be used within a "OnCountFunds" event of a NST_CUSTOM trader type.
  9030.  
  9031. <Val1> is the value used in the *Cash* Points field
  9032. <Val2> is the value used in the Kafra Points field
  9033.  
  9034. ---------------------------------------
  9035.  
  9036. *tradertype(<Type>);
  9037.  
  9038. Modifies the npc trader type, item list is cleared upon modifiying the value.
  9039. By default, all npcs staart with tradertype(NST_ZENY);
  9040.  
  9041. - NST_ZENY (0) Normal Zeny Shop
  9042. - NST_CASH (1) Normal Cash Shop
  9043. - NST_MARKET (2) Normal NPC Market Shop (where items have limited availability and need to be refurbished)
  9044. - NST_CUSTOM (3) Custom Shop (any currency, item/var/etca, check sample)
  9045.  
  9046. ---------------------------------------
  9047.  
  9048. *purchaseok();
  9049.  
  9050. Signs that the transaction (on a NST_CUSTOM trader) has been successful,
  9051. to be used within a "OnPayFunds" event of a NST_CUSTOM trader.
  9052.  
  9053. ---------------------------------------
  9054.  
  9055. *shopcount(<Item_ID>);
  9056.  
  9057. Returns the amount of still-available <Item_ID> in the shop (on a NST_MARKET trader).
  9058.  
  9059. ----------------------------------------------------
  9060. // Equipe Cronus Dev. Comandos
  9061.  
  9062. *areakill "<mapa>",<x1>,<y1>,<x2>,<y2>{,<tipo>};
  9063.  
  9064. Esse comando funciona é semelhante a outros comandos de AREA, ele serve para matar o que estiver na área determinada,
  9065. conforme o <tipo> que for indicado. O <tipo> é um parêmetro opcional, caso seja omitido o valor será 'zero'.
  9066. Os tipos são: 0= Jogador, 1= Monstro, 2= Ambos. Este comando não precisa estar attachado para funcionar.
  9067.  
  9068. areakill "prt_fild08",100,110,110,120,1;
  9069.  
  9070. Todos os monstros na área entre X 100 Y 110 e X 110 e Y 120, em uma área
  9071. quadrada, no mapa "prt_fild08", vão ser mortos.
  9072.  
  9073. areakill "prontera",150,150,180,180;
  9074.  
  9075. Todos os jogadores na área entre X 150 Y 150 e X 180 e Y 180, em uma área
  9076. quadrada, no mapa "prontera", vão ser mortos.
  9077.  
  9078. areakill "izlude",80,50,100,80,2;
  9079.  
  9080. Todos os jogadores e monstros na área entre X 80 Y 50 e X 100 e Y 80, em uma área
  9081. quadrada, no mapa "izlude", vão ser mortos.
  9082.  
  9083. ----------------------------------------------------
  9084.  
  9085. *OnPCUseSkillEvent:
  9086.  
  9087. Se trata de uma label que é ativada quando o personagem usa uma Skill(habilidade), possibilitando "qualquer" ação,
  9088. quando esta, for executada.
  9089.  
  9090. "A imaginação é o limite!"
  9091.  
  9092. Juntamente com essa label, temos as variáveis especiais:
  9093.  
  9094. lskillid = Variável que contém a ID da skill atualmente executada.
  9095. lskilldest$ = Variável que contém o nome da última skill usada no alvo.
  9096. lskilldest = Variável que contém o ID da última skill usada no alvo.
  9097.  
  9098. Dessa forma você poderá comparar as skills. Sendo possível obter o controle de qualquer skill dentro de uma condição.
  9099.  
  9100. Simples exemplo de uso:
  9101.  
  9102. - script OnPCUseSkillEvent_EXEMPLO -1,{
  9103.  
  9104. OnPCUseSkillEvent:
  9105. if(lskillid == 5) // 5 é o id da skill Golpe Fulminante
  9106. {
  9107. mes "Você executou a skill Golpe Fulminante!";
  9108. close;
  9109. }
  9110.  
  9111. else
  9112. {
  9113. mes "Você não executou a skill Golpe Fulminante!";
  9114. close;
  9115. }
  9116.  
  9117. }
  9118.  
  9119. ----------------------------------------------------
Add Comment
Please, Sign In to add comment