· 8 years ago · Jul 31, 2018, 03:44 PM
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
10Este documento é um manual de referência para todos os comandos de
11Funções disponÃveis no atual Cronus GIT. Não é um simples tutorial.
12Quando as pessoas lhe dizem para "Leia a documentação", eles querem dizer isso.
13
14A informação foi adquirida principalmente através da análise de como as coisas
15Trabalho no código-fonte do servidor, que foi escrito por muitas pessoas
16Ao longo do tempo, e muitos deles não falam Inglês e nunca deixou quaisquer notas -
17Ou não estão disponÃveis para comentários. Como tal, qualquer coisa escrita em
18Aqui pode não estar correto, é apenas correto para o melhor de nossos
19Conhecimento, que é limitado.
20
21Este não é um lugar para te ensinar programação básica. Este documento não
22Ensinar programação básica por si só. É mais uma referência para aqueles
23Que têm pelo menos uma vaga idéia do que querem fazer e querem saber
24Que ferramentas eles têm disponÃvel para fazê-lo. Tentamos mantê-lo tão simples
25Como viável, mas se você não entender, obter um livro claro sobre
26Programação em geral ajudará melhor do que gritar em torno do fórum para
27Socorro.
28
29Um pouco de aprendizagem nunca causou a cabeça de ninguém para explodir.
30
31Estrutura
32---------
33
34Os comandos e funções são listados em nenhuma ordem especÃfica:
35
36*Nome do comando e como chamá-lo.
37
38Texto 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
43Para encontrar um comando especÃfico, use Ctrl + F, (ou qualquer tecla chamar uma pesquisa
44Função no que você está lendo isso com) colocar um * seguido pelo
45Comando, e ele deve encontrar a descrição do comando para você.
46
47Se você encontrar alguma coisa omitida, por favor, informe-nos. :).
48
49Sintaxe
50------
51
52Ao longo deste documento, sempre que um comando deseja um argumento, é
53Dado em <parênteses angulares>. Isso não significa que você deve digitar o ângulo
54Colchetes. :) 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
56Você não, se acostumar, é assim que os garotos fazem isso. Se um comando
57Opcionalmente um número não especificado de argumentos, você verá uma lista como
58esta:
59
60command <argumento>{,<argumento>...<argumento>}
61
62Isso ainda significa que eles vão querer ser separados por vÃrgulas.
63
64Onde um comando quer uma string, ela será dada em "citações", se for um
65Número, ele será dado sem eles. Normalmente, você pode
66Expressã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
68Ser uma boa idéia.
69
70Onde quer que você se refira a um mapa, use 'mapname' em vez de 'mapname.gat'.
71
72
73Script loading structure
74------------------------
75
76Os scripts são carregados pelo servidor de mapas conforme
77'Conf / map-server.conf', mas no arquivo de configuração padrão
78Configuração, ele não carrega nenhum arquivo de script propriamente dito. Em vez disso, ele carrega
79O arquivo 'npc/scripts_main.conf' que contém referências a outros
80arquivos. Os scripts reais são carregados a partir de arquivos txt, que são ligados para cima
81como isso:
82
83npc: <Caminho para um nome de arquivo>
84
85Any line like this, invoked, ultimately, by 'map-server.conf' will load up
86the script contained in this file, which will make the script available.
87No file will get loaded twice, to prevent possible errors.
88
89Another configuration file option of relevance is:
90
91delnpc: <Caminho para um nome de arquivo>
92
93Isso descarregará um nome de arquivo de script especificado da memória, que, enquanto
94Aparentemente inútil, às vezes pode ser necessário.
95
96Sempre que '//' é encontrado em uma linha na leitura, tudo além
97Esta linha é considerada um comentário e é ignorada. Isso funciona
98Onde quer que você o coloque.
99
100// Esta linha será ignorada ao processar o script.
101
102Bloquear comentários também podem ser usados, onde você pode colocar / * e * / entre qualquer
103Texto que você deseja que Cronus ignore.
104
105Exemplo:
106/* Esse texto,
107 * Não importa qual nova linha você começa
108 * É ignorado, até que o seguinte
109 * É encontrado: * /
110
111Os asteriscos (*) na frente de cada linha são uma preferência pessoal, e é
112não requerido.
113
114Ao carregar todos os arquivos, o servidor executará todos os
115Comandos neles. Ainda não existem variáveis neste momento, nenhum comando pode ser
116Chamados outros que não os indicados nesta seção. Esses comandos configuram o
117Estrutura básica do script do servidor - criar objetos NPC, spawn monster objects,
118Set map flags, etc. Nenhum código é realmente executado neste ponto, exceto
119eles. Os comandos de nÃvel superior que os scripts são bastante confusos,
120Eles não são estruturados como você esperaria comandos, nome de comando primeiro,
121Mas sim, normalmente começam com um nome de mapa.
122
123O que é mais confuso sobre os comandos de nÃvel superior é que a maioria deles
124Use um sÃmbolo de tabulação para dividir seus argumentos.
125
126Para evitar problemas e confusão, os sÃmbolos de tabulação são escritos como '% TAB%'
127Ou '<TAB>' ao longo deste documento, mesmo que isso torne o texto um pouco
128Menos legÃvel. Usar um sÃmbolo invisÃvel para denotar argumentos é um dos
129Coisas ruins sobre esse idioma, mas estamos presos com ele por enquanto. :)
130
131Aqui 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
137Isto irá, ao carregar, definir uma bandeira de mapa especificada em um mapa que você gosta. Estes
138Normalmente dentro de arquivos dentro do 'npc/mapflag' e são carregados primeiro, então pelo
139Tempo o servidor é para cima, todos os mapas têm as bandeiras que devem ter. Mapa
140As bandeiras determinam o comportamento do mapa em relação a vários problemas comuns,
141Para 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
147Nome do mapa é o nome do mapa que os monstros irão desovar. X, Y são os
148Coordena onde o mob deve spawn. Se X e Y são não-zero, eles
149Especifique o "raio" de uma área de retângulo de spawn centrada em x, y. Colocação
150Zeros em vez destas coordenadas gerarão os monstros aleatoriamente. Nota
151Esta é apenas a zona de desova inicial, como mobs random-walk, eles são livres para
152Afastar-se de sua região especificada spawn.
153
154Nome do monstro é o nome que os monstros terão na tela e não tem
155Relaçã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"
157Monstros Se o nome do mob é dado como "--ja--", o campo "nome japonês"
158Do banco de dados de monstro é usado, (que, em Cronus, realmente contém
159Um nome em inglês) se for "--en--", é o "nome inglês" do
160Monstro (que contém um nome maiúsculo usado para invocar o
161Monstro com um comando GM).
162
163Quantidade é a quantidade de monstros que serão gerados quando este comando é
164Executada, ela é afetada pelas taxas de spawn em 'battle.conf'.
165
166Delay1 e delay2 controlam os atrasos do respawn do monstro - o primeiro é o
167Tempo de respawn da base fixa, ea segunda é variância aleatória em cima da
168Base. Ambos os valores são dados em milissegundos (1000 = 1 segundo). Nota
169Que o servidor também impõe um mÃnimo respawn atraso de 5 segundos.
170
171Você pode especificar um nÃvel personalizado para usar para o mob diferente do
172Do 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
175Evento é um evento de script a ser executado quando a máfia é morta. O evento
176Deve estar na forma "NPCName::OnEventName" para executar e o nome do evento
177Deve começar com "On". Como com todos os eventos, se o NPC é um
178On-touch NPC, o jogador que aciona o script deve estar dentro de 'trigger'
179Para que o evento funcione.
180
181Existem 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
185Alternativamente, um monstro gerado usando 'boss_monster' em vez de 'monster' pode ser
186Detectado 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
192Nomes de NPC são um pouco especiais e são formatados desta forma:
193
194<Nome de exibição>{::<Nome exclusivo>}
195
196Todos os NPCs precisam ter um nome exclusivo que seja usado para identificação
197Finalidades. 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>
199ao invés.
200
201O cliente tem uma caracterÃstica especial ao exibir nomes: se o
202Nome contém um caractere '#', oculta essa parte do nome.
203Ex: 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
212Isto irá definir um warp NPC que irá deformar um jogador entre mapas, e
213Enquanto a maioria dos argumentos disso são óbvios, alguns merecem menção especial.
214
215SpanX e SpanY tornarão a deformação sensÃvel a um personagem que não
216Passo diretamente sobre ele, mas entrou em uma zona que é centrada na urdidura
217A partir de coordenadas e é SpanX em cada direção ao longo do eixo X e
218SpanY em cada sentido através do eixo Y.
219
220Warp NPC objetos também têm um nome, porque você pode usá-lo para se referir a eles
221Mais tarde com 'enablenpc' / 'disablenpc'.
222
223Enfrentar um objeto warp é irrelevante, não é usado no código e todos
224Os 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
231Isso colocará um objeto NPC em um mapa especificado na
232Local, e é um comando de nÃvel superior que você usará mais no seu
233Scripting Os NPCs são acionados clicando neles, e / ou caminhando
234Na sua área de disparo, se definido. Veja abaixo.
235
236Enfrentar é uma direção que o sprite NPC enfrentará. Nem todos os sprites NPC
237Imagens diferentes dependendo da direção em que você olha, então para
238Alguns enfrentamentos não terão sentido. Os revestimentos são contados no sentido anti-horário em
239Incrementos 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,
241E para fazê-la olhar para o sudeste está enfrentando 5.)
242
243Sprite é o identificador de sprite usado para exibir esse NPC especÃfico. Para um
244Lista completa de números de sprite veja http://kalen.s79.xrea.com/npc/npce.shtml como
245Bem como db / const.txt.
246Você também pode usar a constante de identificação de um monstro em vez disso para exibir um sprite monstro
247Para este NPC, em npcs que têm ids de vista de mobs é encorajado a usar
248OnTouch eventos com um intervalo de 2,2 e com um 'fim' após o cabeçalho para evitar
249Bugs (para mais informações sobre porquê ver npc_click@map/npc.c). É possÃvel usar um trabalho
250Sprite também, mas você deve primeiro defini-lo como um sprite monstro em 'mob_avail.txt',
251Uma descrição completa sobre como fazer isso não está no escopo deste manual.
252Um '-1' sprite fará o NPC invisÃvel (e unchickable).
253Um sprite 'HIDDEN_NPC' fará um NPC que não tenha um sprite, mas é
254Ainda é clicável, o que é útil se você quiser fazer um objeto clicável de
255O terreno 3D.
256
257TriggerX e triggerY, se for dado, definirão uma área, centrada em NPC e
258Abrangendo células triggerX em todas as direções em X e triggerY em
259Direçã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á
261InÃcio do script, caso contrário, ele será iniciado a partir do
262Etiqueta '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
264Se presente etiqueta 'OnUnTouch'.
265
266A parte de código é o código de script que será executado sempre que o NPC for
267Disparado. Pode conter comandos e chamadas de função, descrições de
268Que compõem a maior parte deste documento. Tem de ser em colchetes,
269Diferentemente de outros lugares onde usamos chaves, estes NÃO significam
270Parâmetro opcional.
271
272** Defina um objeto NPC 'flutuante'.
273
274-%TAB%script%TAB%<NPC Name>%TAB%-1,{<code>}
275
276Isso irá definir um objeto NPC não disparável por meios normais. Isso seria
277Normalmente significa que é inútil uma vez que não pode fazer nada, mas há
278Exceções, principalmente relacionadas à execução de scripts em horários
279Para 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
286Isso definirá um NPC de loja, que, quando acionado (que só pode ser feito
287Clicando) fará com que uma vitrine apareça. Nenhum código funciona
288Na loja NPCs e você não pode alterar os preços de outra forma do que editando o
289Próprio script (não existem variáveis mesmo neste ponto de scripting, por isso
290Nem sequer se preocupar em tentar usá-los).
291
292O 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.
294Caso contrário, o preço que você deu será usado para este item, que é como você
295Criar diferentes preços para os itens em lojas diferentes.
296
297Você pode alternativamente usar "cashshop" no lugar de "shop" para usar o Cash
298Shop, permitindo que você compre itens com pontos especiais (atualmente
299Armazenados como vars de contas em #CASHPOINTS e #KAFRAPOINTS). este
300Tipo de loja não lhe permitirá vender itens, você só pode comprar
301Itens 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
308Todos 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).
310Isso definirá um NPC negociador, que pode causar uma loja, cashshop ou janela de mercado
311Para aparecer quando clicado ou chamado por outros meios. Ao contrário da loja / cashshop NPCs esta
312Tipo irá executar um código e pode alterar os itens que estão sendo vendidos ao longo do tempo sem
313Outros objetos NPC.
314Os 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
318E precisam ser reformados)
319- NST_CUSTOM (3) Custom Shop (qualquer moeda, item / var / etca, amostra de verificação)
320Salvo especificação em contrário via * tradertype, um objeto trader será definido como
321NST_ZENY.
322
323Nota: NST_MARKET só está disponÃvel com PACKETVER 20131223 ou mais recente.
324Consulte '12 - Comandos relacionados ao NPC Trader 'e /doc/sample/npc_trader_sample.txt para
325Mais informações sobre como usar este tipo de NPC.
326
327** Defina um warp / shop / cashshop / duplicado NPC.
328
329warp: <nome do mapa>,<x>,<y>{,<facing>}%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<spanx>,<spany>
330shop/cashshop/npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite>
331shop/cashshop/npc: <nome do mapa>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite>
332npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite>,<triggerX>,<triggerY>
333npc: <nome do mapa>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite>,<triggerX>,<triggerY>
334
335Isto duplicará uma warp / shop / cashshop / NPC referida por 'label'.
336As duplicatas de distorção herdam a localização de destino.
337Os duplicados da loja / caixa de pagamento herdam a lista de itens.
338Os duplicados de NPC herdam o código de script.
339O restante (nome, localização, face, sprite, área span / trigger) é
340Obtido a partir da definição do duplicado (não herdado).
341
342** Define a function object
343
344function%TAB%script%TAB%<function name>%TAB%{<code>}
345
346This will define a function object, callable with the 'callfunc' command
347(see below). This object will load on every map server separately, so you
348can get at it from anywhere. It's not possible to call the code in this
349object by anything other than the 'callfunc' script command.
350
351The code part is the script code that will execute whenever the function
352is called with 'callfunc'. It has to be in curly brackets, unlike
353elsewhere where we use curly brackets, these do NOT signify an optional
354parameter.
355
356Once an object is defined which has a 'code' field to it's definition, it
357contains script commands which can actually be triggered and executed.
358
359~ RID? GID? ~
360
361What a RID is and why do you need to know
362-----------------------------------------
363
364Most scripting commands and functions will want to request data about a
365character, store variables referenced to that character, send stuff to the
366client connected to that specific character. Whenever a script is invoked
367by a character, it is passed a so-called RID - this is the account ID
368number of a character that caused the code to execute by clicking on it,
369walking into it's OnTouch zone, or otherwise.
370
371If you are only writing common NPCs, you don't need to bother with it.
372However, if you use functions, if you use timers, if you use clock-based
373script activation, you need to be aware of all cases when a script
374execution can be triggered without a RID attached. This will make a lot of
375commands and functions unusable, since they want data from a specific
376character, want to send stuff to a specific client, want to store
377variables specific to that character, and they would not know what
378character to work on if there's no RID.
379
380Unless you use 'attachrid' to explicitly attach a character to the script
381first (see player-related commands).
382
383Whenever we say 'invoking character', we mean 'the character who's RID is
384attached to the running script. The script function "playerattached" can
385be used to check which is the currently attached player to the script (it
386will return 0 if the there is no player attached or the attached player no
387longer is logged on to the map-server).
388
389But what about GID?
390--- ---- ----- ----
391
392GID stands for the Game ID of something, this can either be the GID of a
393mob obtained through the monster script command (if only summoned one),
394the GID of a NPC obtained through the getnpcid script command or the
395account ID of a character (same as its RID). Another way would be to right
396click on a mob, NPC or char as GM sprited char to view its GID.
397
398Item and pet scripts
399--------------------
400
401Each item in the item database has three special fields - Script,
402OnEquip_Script and OnUnequip_Script. The first is script code run every
403time a character equips the item, with the RID of the equipping character.
404Every time they unequip an item, all temporary bonuses given by the script
405commands are cleared, and all the scripts are executed once again to
406rebuild them. This also happens in several other situations (like upon
407login) but the full list is currently unknown.
408
409OnEquip_Script is a piece of script code run whenever the item is used by
410a character by double-clicking on it. OnUnequip_Script runs whenever the
411equipment is unequipped by a character.
412
413Not all script commands work properly in the item scripts. Where commands
414and functions are known to be meant specifically for use in item scripts,
415they are described as such.
416
417Every pet in the pet database has a PetScript field, which determines pet
418behavior. 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
420had that pet following them connects). This may occur in some other
421situations as well. Don't expect anything other than commands definitely
422marked as usable in pet scripts to work in there reliably.
423
424Numbers
425-------
426
427Beside the common decimal numbers, which are nothing special whatsoever
428(though do not expect to use fractions, since ALL numbers are integer in
429this language), the script engine also handles hexadecimal numbers, which
430are otherwise identical. Writing a number like '0x<hex digits>' will make
431it recognized as a hexadecimal value. Notice that 0x10 is equal to 16.
432Also notice that if you try to 'mes 0x10' it will print '16'.
433
434Number values can't exceed the limits of an integer variable: Any number
435greater than INT_MAX (2147483647) or smaller than INT_MIN (-2147483648) will
436be capped to those values and will cause a warning to be reported.
437
438Variables
439---------
440
441The meat of every programming language is variables - places where you
442store data.
443
444In Cronus scripting language, variable names are case sensitive. Even though
445at the current time the script engine accepts them even with the incorrect
446case, it is not advised to rely on this behavior, as it may change at any
447time.
448
449Variables are divided into and uniquely identified by the combination of:
450prefix - determines the scope and extent (or lifetime) of the variable
451name - an identifier consisting of '_' and alphanumeric characters
452postfix - determines the type of the variable: integer or string
453
454Scope can be:
455global - global to all servers
456local - local to the server
457account - attached to the account of the character identified by RID
458character - attached to the character identified by RID
459npc - attached to the NPC
460scope - attached to the scope of the instance
461
462Extent can be:
463permanent - They still exist when the server resets.
464temporary - They cease to exist when the server resets.
465
466Prefix: scope and extent
467nothing - 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
499Postfix: integer or string
500nothing - 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
504Examples:
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
524If a variable was never set, it is considered to equal zero for integer
525variables or an empty string ("", nothing between the quotes) for string
526variables. Once you set it to that, the variable is as good as forgotten
527forever, and no trace remains of it even if it was stored with character
528or account data.
529
530Some variables are special, that is, they are already defined for you by
531the 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
533to replace lots of numbered arguments for many commands with easier to
534read text. The special variables most commonly used are all permanent
535character-based variables:
536
537Zeny - Amount of Zeny.
538Hp - Current amount of hit points.
539MaxHp - Maximum amount of hit points.
540Sp - Current spell points.
541MaxSp - Maximum amount of spell points.
542StatusPoint - Amount of status points remaining.
543SkillPoint - Amount of skill points remaining.
544BaseLevel - Character's base level.
545JobLevel - Character's job level.
546BaseExp - Amount of base experience points.
547JobExp - Amount of job experience points.
548NextBaseExp - Amount of base experience points needed to reach next level.
549NextJobExp - Amount of job experience points needed to reach next level.
550Weight - Amount of weight the character currently carries.
551 Display as in Weight/10.
552MaxWeight - Maximum weight the character can carry.
553 Display as in MaxWeight/10.
554Sex - 0 if female, 1 if male.
555Class - Character's job.
556Upper - 0 if the character is normal class, 1 if advanced, 2 if baby.
557BaseClass - 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.
562BaseJob - 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.
565Karma - The character's karma. Karma system is not fully functional,
566 but this doesn't mean this doesn't work at all. Not tested.
567Manner - 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
571While these behave as variables, do not always expect to just set them -
572it is not certain whether this will work for all of them. Whenever there
573is a command or a function to set something, it's usually preferable to
574use that instead. The notable exception is Zeny, which you can and often
575will address directly - setting it will make the character own this number
576of Zeny. If you try to set Zeny to a negative number, the script will be
577terminated with an error.
578
579Assigning variables
580--------- ---------
581
582Variables can be accessed and assigned values directly without the use of
583the built-in 'set' function. This means that variables can be accessed and
584modified much like other programming languages.
585
586 .@x = 100;
587 .@x = .@y = 100;
588
589Support for modifying variable values using 'set' is still supported (and
590required to exist for this method to work) so previous scripts will
591continue working. Its usage, though, is deprecated, and it should never be
592used in new scripts unless there are special reasons to do so.
593
594When assigning values, all operator methods are supported which exist in
595the 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
605Will all work. For more information on available operators, see the
606Operators section described below. All operators listed there may be
607placed in-front of the '=' sign when modifying variables to perform the
608action as required.
609
610Increment and decrement operators are also provided, for your convenience.
611Pre-increment and pre-decrement operators:
612
613 ++.@x; // same as .@x = .@x + 1
614 --.@x; // same as .@x = .@x - 1
615
616Post-increment and post-decrement operators:
617
618 .@x++; // similar to .@x = .@x + 1
619 .@x--; // similar to .@x = .@x - 1
620
621The difference between pre- and post- increment/decrement operators is that,
622when used in an expression, the pre- ones will be executed before evaluating
623the 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
630Note: The pre-increment/pre-decrement operators are, by design, faster (or at
631least not slower) than their respective post- equivalent.
632
633Note:
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
639Strings
640-------
641
642Strings are enclosed in "double quotes". To include the literal double
643quote symbol (") "in a string you need to escape it with a blackslash:
644
645 .@string$ = "This string contains some \"double quote\" symbols";
646
647Arrays
648------
649
650Arrays (in Cronus at least) are essentially a set of variables going
651under the same name. You can tell between the specific variables of an
652array with an 'array index', a number of a variable in that array:
653
654<variable name>[<array index>]
655
656All variable types can be used as arrays.
657
658Variables stored in this way, inside an array, are also called 'array
659elements'. Arrays are specifically useful for storing a set of similar
660data (like several item IDs for example) and then looping through it. You
661can address any array variable as if it was a normal variable:
662
663 .@arrayofnumbers[0] = 1;
664
665You can use a variable (or an expression, or even a value from an another
666array) as array index:
667
668 .@x = 100;
669 .@arrayofnumbers[.@x] = 10;
670
671This will make .@arrayofnumbers[100] equal to 10.
672
673Index numbering always starts with 0 and arrays can hold over 2 billion
674variables. As such, the (guaranteed) allowed values for indices are in the
675range 0 ~ 2147483647.
676
677If the array index is omitted, it defaults to zero. Writing
678.@arrayofnumbers is perfectly equivalent to writing .@arrayofnumbers[0].
679
680Arrays can naturally store strings:
681
682.@menulines$[0] is the 0th element of the .@menulines$ array of strings.
683Notice the '$', normally denoting a string variable, before the square
684brackets that denotes an array index.
685
686Variable References
687-------------------
688
689//##TODO
690
691Hard-coded constants
692--------------------
693Most 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
695are core related, but there are constants that can be used to retrieve
696core information that's set when the server is compiled.
697
698PACKETVER - Server packet version
699MAX_LEVEL - Maximum level
700MAX_STORAGE - Maximum storage items
701MAX_GUILD_STORAGE - Maximum guild storage items
702MAX_CART - Maximum cart items
703MAX_INVENTORY - Maximum inventory items
704MAX_ZENY - Maximum Zeny
705MAX_BG_MEMBERS - Maximum BattleGround members
706MAX_CHAT_USERS - Maximum Chat users
707MAX_REFINE - Maximum Refine level
708
709Send targets and status options are also hard-coded and can be found
710in src/map/script.c::script_hardcoded_constants or in functions that
711currently use them.
712
713Operators
714---------
715
716Operators are things you can do to variables and numbers. They are either
717the 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
729There are also conditional operators. This has to do with the conditional
730command 'if' and they are meant to return either 1 if the condition is
731satisfied and 0 if it isn't. That's what they call 'boolean' variables. 0
732means 'False'. Anything except the zero is 'True'. Odd as it is, -1 and -5
733and anything below zero will also be True.)
734
735You can compare numbers to each other and you compare strings to each
736other, 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
753Examples:
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
759Only '==', '!=', '~=' and '~!' have been tested for comparing strings. Since
760there's no way to code a seriously complex data structure in this language,
761trying to sort strings by alphabet would be pointless anyway.
762
763Comparisons 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
773Logical 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
854Unary operators with only with a single number, which follows the
855operator, 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
885Ternary operators take three expressions (numbers, strings or boolean),
886and 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
901Operator Precedence and Associativity
902
903Operator precedence and associativity work more or less like they do in
904mathematics. The rules can be summarized with the following table:
905
906Precedence | Description | Associativity
907---------------------------------------------------------------------------
9081 (highest) | [] Array subscripting | None
909---------------------------------------------------------------------------
9102 | ++ Increment | None
911 | -- Decrement |
912---------------------------------------------------------------------------
9132 | - Unary minus | Right to left
914 | ! Logical NOT |
915 | ~ Bitwise NOT (One's Complement) |
916---------------------------------------------------------------------------
9173 | * Multiplication | Left to right
918 | / Division |
919 | % Modulo (remainder) |
920---------------------------------------------------------------------------
9214 | + Addition | Left to right
922 | - Subtraction |
923---------------------------------------------------------------------------
9245 | << Bitwise left shift | Left to right
925 | >> Bitwise right shift |
926---------------------------------------------------------------------------
9276 | < Less than | Left to right
928 | <= Less than or equal to |
929 | > Greater than |
930 | >= Greater than or equal to |
931---------------------------------------------------------------------------
9327 | == Equal to | Left to right
933 | != Not equal to |
934 | ~= Regexp match |
935 | ~! Regexp non-match |
936---------------------------------------------------------------------------
9378 | & Bitwise AND | Left to right
938---------------------------------------------------------------------------
9399 | ^ Bitwise XOR (exclusive or) | Left to right
940---------------------------------------------------------------------------
94110 | | Bitwise OR (inclusive or) | Left to right
942---------------------------------------------------------------------------
94311 | && Logical AND | Left to right
944---------------------------------------------------------------------------
94512 | || Logical OR | Left to right
946---------------------------------------------------------------------------
94713 | ?: Ternary conditional | Right to left
948---------------------------------------------------------------------------
94914 | = 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
961Operator precedence means some operators are evaluated before others. For
962example, in 2 + 4 * 5 , the multiplication has higher precedence so 4 * 5 is
963evaluated first yielding 2 + 20 == 22 and not 6 * 5 == 30 .
964
965Operator associativity defines what happens if a sequence of the same
966operators is used one after another: whether the evaluator will evaluate the
967left operations first or the right. For example, in 8 - 4 - 2 , subtraction is
968left associative so the expression is evaluated left to right. 8 - 4 is
969evaluated first making the expression 4 - 2 == 2 and not 8 - 2 == 6 .
970
971Labels
972------
973
974Within executable script code, some lines can be labels:
975
976<label name>:
977
978Labels are points of reference in your script, which can be used to route
979execution with 'goto' and 'menu' commands, invoked with 'doevent', 'donpcevent'
980and 'callsub' commands and are otherwise essential. A label's name may not be
981longer than 22 characters. (23rd is the ':'.) There is some confusion in the
982source about whether it's 22, 23 or 24 all over the place, so keeping labels
983under 22 characters could be wise. It may only contain alphanumeric characters
984and underscore. In addition to labels you name yourself, there are also some
985special labels which the script engine will start execution from if a special
986event happens:
987
988OnClock<hour><minute>:
989OnMinute<minute>:
990OnHour<hour>:
991On<weekday><hour><minute>:
992OnDay<month><day>:
993
994This will execute when the server clock hits the specified date or time.
995Hours and minutes are given in military time. ('0105' will mean 01:05 AM).
996Weekdays are Sun,Mon,Tue,Wed,Thu,Fri,Sat. Months are 01 to 12, days are 01
997to 31. Remember the zero. :)
998
999OnInit:
1000OnInterIfInit:
1001OnInterIfInitOnce:
1002
1003OnInit will execute every time the scripts loading is complete, including
1004when they are reloaded with @reloadscript command. OnInterIfInit will
1005execute when the map server connects to a char server, OnInterIfInitOnce
1006will only execute once and will not execute if the map server reconnects
1007to the char server later. Note that all those events will be executed upon
1008scripts reloading.
1009
1010OnAgitStart:
1011OnAgitEnd:
1012OnAgitInit:
1013OnAgitStart2:
1014OnAgitEnd2:
1015OnAgitInit2:
1016
1017OnAgitStart will run whenever the server shifts into WoE mode, whether it
1018is done with @agitstart GM command or with 'AgitStart' script command.
1019OnAgitEnd will do likewise for the end of WoE.
1020
1021OnAgitInit will run when data for all castles and all guilds that hold a
1022castle is received by map-server from the char-server after initial
1023connect.
1024
1025No RID will be attached while any of the above mentioned labels are
1026triggered, so no character or account-based variables will be accessible,
1027until you attach a RID with 'attachrid' (see below).
1028
1029The above also applies to, the last three labels, the only difference is
1030that these labels are used exclusively for WoE SE, and are called
1031independently.
1032
1033OnTouch:
1034
1035This label will be executed if a trigger area is defined for the NPC
1036object it's in. If it isn't present, the execution will start from the
1037beginning of the NPC code. The RID of the triggering character object will
1038be attached.
1039
1040OnTouch_:
1041
1042Similar to OnTouch, but will only run one instance. Another character is
1043chosen once the triggering character leaves the area.
1044
1045OnUnTouch:
1046
1047This label will be executed if plater leave trigger area is defined for the NPC
1048object it's in. If it isn't present, nothing will happend.
1049The RID of the triggering character object will be attached.
1050
1051OnPCLoginEvent:
1052OnPCLogoutEvent:
1053OnPCBaseLvUpEvent:
1054OnPCJobLvUpEvent:
1055
1056It's pretty obvious when these four special labels will be invoked.
1057
1058OnPCDieEvent:
1059
1060This special label triggers when a player dies. The variable 'killerrid'
1061is set to the ID of the killer.
1062
1063OnPCKillEvent:
1064
1065This special label triggers when a player kills another player. The
1066variable 'killedrid' is set to the ID of the player killed.
1067
1068OnNPCKillEvent:
1069
1070This special label triggers when a player kills a monster. The variable
1071'killedrid' is set to the Class of the monster killed.
1072
1073OnPCLoadMapEvent:
1074
1075This special label will trigger once a player steps in a map marked with
1076the 'loadevent' mapflag and attach its RID. The fact that this label
1077requires a mapflag for it to work is because, otherwise, it'd be
1078server-wide and trigger every time a player would change maps. Imagine the
1079server load with 1,000 players (oh the pain...)
1080
1081Only the special labels which are not associated with any script command
1082are listed here. There are other kinds of labels which may be triggered in
1083a similar manner, but they are described with their associated commands.
1084
1085OnCountFunds:
1086
1087This special label is triggered when a player opens a trader NPC object that
1088is 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
1090for more information.
1091
1092OnPayFunds:
1093
1094This special label is triggered when a purchase is made on a trader NPC object
1095that is NST_CUSTOM. Receives @price, total cost and @points, secondary input
1096field for cash windows. It is used to remove items that are set as currency.
1097Should be used along with OnCountFunds, see /doc/sample/npc_trader_sample.txt
1098for more information.
1099
1100On<label name>:
1101
1102These special labels are used with Mob scripts mostly, and script commands
1103that requires you to point/link a command to a mob or another NPC, giving
1104a label name to start from. The label name can be any of your liking, but
1105must be started with "On".
1106
1107Example:
1108
1109monster "prontera",123,42,"Poringz0rd",2341,23,"Master::OnThisMobDeath";
1110
1111amatsu,13,152,4 script Master 767,{
1112 mes "Hi there";
1113 close;
1114
1115OnThisMobDeath:
1116 announce "Hey, "+strcharinfo(0)+" just killed a Poringz0rd!",bc_blue|bc_all;
1117 end;
1118}
1119
1120Each time you kill one, that announce will appear in blue to everyone.
1121
1122"Global" labels
1123
1124There's a catch with labels and doevent. If you call a label (using
1125doevent) and called label is in NPC that has trigger area, that label must
1126end with "Global" to work globally (i.e. if RID is outside of the trigger
1127area, which usually happens since otherwise there would be no point
1128calling the label with doevent, because OnTouch would do the job). For
1129further reference look for npc_event in npc.c.
1130
1131Scripting commands and functions
1132--------------------------------
1133
1134The commands and functions are listed here in no particular order. There's
1135a difference between commands and functions - commands leave no 'return
1136value' which might be used in a conditional statement, as a command
1137argument, or stored in a variable. Calling commands as if they were
1138functions will sometimes work, but is not advised, as this can lead to
1139some hard to track errors. Calling functions as if they were commands will
1140mess up the stack, so 'return' command will not return correctly after
1141this happens in a particular script.
1142
1143All commands must end with a ';'. Actually, you may expect to have
1144multiple commands on one line if you properly terminate them with a ';',
1145but it's better if you don't, since it is not certain just whether the
1146scripting engine will behave nicely if you do.
1147
1148Please note that command and function names are case sensitive.
1149
1150-------------------------
1151
1152
1153From here on, we will have the commands sorted as followed:
1154
11551 - Basic Commands
11562 - Information-Retrieving Commands
1157 -- 2.1 - Item-Related Commands
1158 -- 2.2 - Guild-Related Commands
11593 - Checking Commands
1160 -- 3.1 - Checking Item-Related Commands
11614 - Player-Related Commands
1162 -- 4.1 - Player Item-Related Commands
1163 -- 4.2 - Guild-Related Commands
1164 -- 4.3 - Marriage-Related Commands
11655 - Mob / NPC Related commands
1166 -- 5.1 - Time-Related Commands
1167 -- 5.2 - Guild-Related Commands
11686 - Other Commands
11697 - Instance-Related Commands
11708 - Quest Log Commands
11719 - Battleground Commands
117210 - Mercenary Commands
117311 - Queue Commands
117412 - NPC Trader Commands
1175
1176
1177---------------------------------------
1178//=====================================
11791 - Basic Commands
1180//=====================================
1181---------------------------------------
1182
1183*mes "<string>"{,"<string>"..."<string>"};
1184
1185This command will displays a box on the screen for the invoking character,
1186if no such box is displayed already, and will print the string specified
1187into that box. There is normally no 'close' or 'next' button on this box,
1188unless you create one with 'close' or 'next', and while it's open the
1189player can't do much else, so it's important to create a button later. If
1190the string is empty, it will show up as an empty line.
1191
1192 mes "Text that will appear in the box";
1193
1194Inside the string you may put color codes, which will alter the color of
1195the text printed after them. The color codes are all '^<R><G><B>' and
1196contain three hexadecimal numbers representing colors as if they were HTML
1197colors - ^FF0000 is bright red, ^00FF00 is bright green, ^0000FF is bright
1198blue, ^000000 is black. ^FF00FF is a pure magenta, but it's also a color
1199that is considered transparent whenever the client is drawing windows on
1200screen, so printing text in that color will have kind of a weird effect.
1201Once you've set a text's color to something, you have to set it back to
1202black 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
1206Notice that the text coloring is handled purely by the client. If you use
1207non-English characters, the color codes might get screwed if they stick to
1208letters with no intervening space. Separating them with spaces from the
1209letters on either side solves the problem.
1210
1211To display multiple lines of message while only using a single mes;
1212command, use the script command in the following format:
1213
1214 mes "Line 1", "Line 2", "Line 3";
1215
1216This will display 3 different lines while only consuming a single line in
1217the relevant script file.
1218
1219If you're using a client from 2011-10-10aRagexe.exe onwards, you can also
1220use automatic navigation and open URLs in browser by using some HTML-like
1221labels. For example:
1222
1223 mes "go to <NAVI>[Hat Maker]<INFO>izlude,131,148,</INFO></NAVI> to make hats";
1224
1225Will make the [Hat Maker] text clickable in the client and start a navigation
1226to that point.
1227
1228 mes "You can <URL>Google<INFO>http://www.google.com/</INFO></URL> anything";
1229
1230Clicking Google will open the browser and point to Google website.
1231
1232---------------------------------------
1233
1234*next;
1235
1236This command will display a 'next' button in the message window for the
1237invoking character. Clicking on it will cause the window to clear and
1238display a new one. Used to segment NPC-talking, next is often used in
1239combination with 'mes' and 'close'.
1240
1241If no window is currently on screen, one will be created, but once the
1242invoking character clicks on it, a warning is thrown on the server console
1243and 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
1256This command will create a 'close' button in the message window for the
1257invoking character. If no window is currently on screen, the script
1258command 'end;' must be used. This is one of the ways to end a speech from
1259an NPC. Once the button is clicked, the NPC script execution will end, and
1260the 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
1271This command will create a 'close' button in the message window for the
1272invoking character. WARNING: If no window is currently on screen, the
1273script execution will halt indefinitely! See 'close'. There is one
1274important difference, though - even though the message box will have
1275closed, the script execution will not stop, and commands after 'close2'
1276will still run, meaning an 'end' has to be used to stop the script, unless
1277you 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
1285Don't expect things to run smoothly if you don't make your scripts 'end'.
1286
1287---------------------------------------
1288
1289*end;
1290
1291This command will stop the execution for this particular script.
1292It 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
1311Without the use of 'end' it would travel through the ifs until the end
1312of the script. If you were lvl 10 or less, you would see all the speech
1313lines, the use of 'end' stops this, and ends the script.
1314
1315---------------------------------------
1316
1317*set <variable>,<expression>;
1318*set(<variable>,<expression>)
1319
1320This command will set a variable to the value that the expression results
1321in. This isn't the only way to set a variable directly: you can set them
1322much like any other programming language as stated before (refer to the
1323'Assigning variables' section).
1324
1325This command is deprecated and it shouldn't be used in new scripts, except
1326some special cases (mostly, set getvariableofnpc). Use direct value
1327assignment instead.
1328
1329---------------------------------------
1330
1331*setd "<variable name>",<value>;
1332
1333Works almost identically as set, except the variable name is identified as
1334a string and can thus be constructed dynamically.
1335
1336This command is equivalent to:
1337 set getd("variable name"),<value>;
1338
1339Examples:
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
1351Returns a reference to a variable, the name can be constructed dynamically.
1352Refer to 'setd' for usage.
1353
1354This can also be used to set an array dynamically:
1355 setarray getd(".array[0]"), 1, 2, 3, 4, 5;
1356
1357Examples:
1358
1359 mes "The value of $varReference is: " + getd("$varRefence");
1360 set .@i, getd("$" + "pikachu");
1361
1362---------------------------------------
1363
1364*getvariableofnpc(<variable>,"<npc name>")
1365
1366Returns a reference to a NPC variable (. prefix) from the target NPC.
1367This can only be used to get . variables.
1368
1369Examples:
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
1382Note: even though function objects can have .variables, getvariableofnpc
1383will not work on them.
1384
1385---------------------------------------
1386
1387*goto <label>;
1388
1389This command will make the script jump to a label, usually used in
1390conjunction 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";
1395Label:
1396 mes "This will be seen";
1397
1398Gotos 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
1404This command will create a selectable menu for the invoking character.
1405Only one menu can be on screen at the same time.
1406
1407Depending on what the player picks from the menu, the script execution
1408will continue from the corresponding label. It's string-label pairs, not
1409label-string.
1410
1411This command is deprecated and it should not be used in new scripts, as it
1412is likely to be removed at a later time. Please consider using select() or
1413prompt() instead.
1414
1415Options can be grouped together, separated by the character ':'.
1416
1417 menu "A:B",L_Wrong,"C",L_Right;
1418
1419It also sets a special temporary character variable @menu, which contains
1420the number of option the player picked. Numbering of options starts at 1.
1421This 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
1436If a label is '-', the script execution will continue right after the menu
1437command if that option is selected, this can be used to save you time, and
1438optimize 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
1448Both these examples will perform the exact same task.
1449
1450If you give an empty string as a menu item, the item will not display.
1451This can effectively be used to script dynamic menus by using empty string
1452for entries that should be unavailable at that time.
1453
1454You can do it by using arrays, but watch carefully - this trick isn't high
1455wizardry, but minor magic at least. You can't expect to easily duplicate
1456it until you understand how it works.
1457
1458Create a temporary array of strings to contain your menu items, and
1459populate it with the strings that should go into the menu at this
1460execution, making sure not to leave any gaps. Normally, you do it with a
1461loop 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
1493This will create you an array .@menulist$ which contains the text of all
1494items that should actually go into the menu based on your condition, and
1495an array .@menureference, which contains their numbers in the list of
1496possible menu items. Remember, arrays start with 0. There's less of them
1497than the possible menu items you've defined, but the menu command can
1498handle the empty lines - only if they are last in the list, and if it's
1499made 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
1504This calls up a menu of all your items. Since you didn't copy some of the
1505possible menu items into the list, it's end is empty and so no menu items
1506will show up past the end. But this menu call doesn't jump anywhere, it
1507just continues execution right after the menu command. (And it's a good
1508thing it doesn't, cause you can only explicitly define labels to jump to,
1509and how do you know which ones to define if you don't know beforehand
1510which options will end up where in your menu?)
1511But 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,
1514starting with 1 for the first option. You know now which option the user
1515picked and which number in your real list of possible menu items it
1516translated 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
1522we made.
1523.@menureference[@menu-1] is the number of the item in the array of possible
1524menu items that we've saved just for this purpose.
1525
1526And .@possiblemenuitems$[.@menureference[@menu-1]] is the string that we
1527used to display the menu line the user picked. (Yes, it's a handful, but
1528it works.)
1529
1530You can set up a bunch of 'if (.@menureference[@menu-1]==X) goto Y'
1531statements to route your execution based on the line selected and still
1532generate a different menu every time, which is handy when you want to, for
1533example, make users select items in any specific order before proceeding,
1534or make a randomly shuffled menu.
1535
1536Kafra code bundled with the standard distribution uses a similar
1537array-based menu technique for teleport lists, but it's much simpler and
1538doesn't use @menu, probably since that wasn't documented anywhere.
1539
1540See also 'select', which is probably better in this particular case.
1541Instead of menu, you could use 'select' like this:
1542
1543 .@dummy = select(.@menulist$[0],.@menulist$[1],...,.@menulist$[<X>]);
1544
1545For the purposes of the technique described above these two statements are
1546perfectly equivalent.
1547
1548---------------------------------------
1549
1550*select("<option>"{,"<option>",...})
1551*prompt("<option>"{,"<option>",...})
1552
1553This function is a handy replacement for 'menu' that doesn't use a complex
1554label structure. It will return the number of menu option picked,
1555starting with 1. Like 'menu', it will also set the variable @menu to
1556contain the option the user picked.
1557
1558 if (select("Yes:No") == 1)
1559 mes "You said yes, I know.";
1560
1561And like 'menu', the selected option is consistent with grouped options
1562and empty options.
1563
1564'prompt' works almost the same as select, except that when a character
1565clicks the Cancel button, this function will return 255 instead.
1566
1567---------------------------------------
1568
1569*input(<variable>{,<min>{,<max>}})
1570
1571This command will make an input box pop up on the client connected to the
1572invoking character, to allow entering of a number or a string. This has
1573many 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
1592If you give the input command a string variable to put the input in, it
1593will allow the player to enter text. Otherwise, only numbers will be
1594allowed.
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
1610Normally you may not input a negative number with this command.
1611This is done to prevent exploits in badly written scripts, which would let
1612people, for example, put negative amounts of Zeny into a bank script and
1613receive free Zeny as a result.
1614
1615The command has two optional arguments and a return value.
1616The default value of 'min' and 'max' can be set with 'input_min_value' and
1617'input_max_value' in script.conf.
1618For numeric inputs the value is capped to the range [min,max]. Returns 1
1619if the value was higher than 'max', -1 if lower than 'min' and 0 otherwise.
1620For string inputs it returns 1 if the string was longer than 'max', -1 is
1621shorter than 'min' and 0 otherwise.
1622
1623---------------------------------------
1624
1625*callfunc "<function>"{,<argument>,...<argument>};
1626*callfunc("<function>"{,<argument>,...<argument>})
1627
1628This command lets you call up a function NPC. A function NPC can be called
1629from any script on any map server. Using the 'return' command it will come
1630back 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
1647You can pass arguments to your function - values telling it what exactly
1648to do - which will be available there with getarg() (see 'getarg').
1649Notice that returning is not mandatory, you can end execution right there.
1650
1651If you want to return a real value from inside your function NPC, it is
1652better to write it in the function form, which will also work and will
1653make 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
1668Alternately, user-defined functions may be called directly without the use
1669of 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
1682Note:
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
1694This command will go to a specified label within the current script (do
1695NOT use quotes around it) coming in as if it were a 'callfunc' call, and
1696pass 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
1698to the point from where this label was called. This is used when there is
1699a specific thing the script will do over and over, this lets you use the
1700same bit of code as many times as you like, to save space and time,
1701without creating extra NPC objects which are needed with 'callfunc'. A
1702label is not callable in this manner from another script.
1703
1704Example 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
1715S_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
1722Example 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
1736S_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
1752This function is used when you use the 'callsub' or 'callfunc' commands.
1753In the call you can specify variables that will make that call different
1754from another one. This function will return an argument the function or
1755subroutine was called with, and is the normal way to get them.
1756This is another thing that can let you use the same code more than once.
1757
1758Argument numbering starts with 0, i.e. the first argument you gave is
1759number 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
1783is stated as 2, so when the random number is generated by the 'rand'
1784function, it can only be 0 or 1. Whereas "woman2" gives 5 as the argument
1785number 0 when calling the function, so the random number could be 0, 1, 2,
17863 or 4, this makes "woman2" less likely to say the player won.
1787
1788You can pass multiple arguments in a function call:
1789
1790 callfunc "funcNPC",5,4,3;
1791
1792getarg(0) would be 5, getarg(1) would be 4 and getarg(2) would be 3.
1793
1794Getarg also has an optional argument:
1795If the target argument exists, it is returned.
1796Otherwise, if <default_value> is present it is returned instead, if not
1797the script terminates immediately.
1798
1799In previous example getarg(2,-1) would be 3 and getarg(3,-1) would be -1.
1800
1801---------------------------------------
1802
1803*getargcount()
1804
1805This function is used when you use the 'callsub' or 'callfunc' commands.
1806In the call you can specify arguments. This function will return the
1807number of arguments provided.
1808
1809Example:
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
1821This command causes the script execution to leave previously called
1822function with callfunc or script with callsub and return to the location,
1823where the call originated from. Optionally a return value can be supplied,
1824when the call was done using the function form.
1825
1826Using this command outside of functions or scripts referenced by callsub
1827will 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
1841This works like callfunc, and is used for cleaner and faster scripting.
1842The function must be defined and used within a script, and works like a
1843label with arguments.
1844Note that the name may only contain alphanumeric characters and underscore.
1845
1846Usage:
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
1856Example:
1857
1858prontera,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
1883Example with parameters and return value:
1884
1885prontera,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
1908This command checks whether a function exists.
1909It returns 1 if function is found, or 0 if it isn't.
1910
1911Example:
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
1926This is the basic conditional statement command, and just about the only
1927one available in this scripting language.
1928
1929The condition can be any expression. All expressions resulting in a
1930non-zero value will be considered True, including negative values. All
1931expressions resulting in a zero are false.
1932
1933If the expression results in True, the statement will be executed. If it
1934isn'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
1941For more information on conditional operators see the operators section
1942above.
1943Anything that is returned by a function can be used in a condition check
1944without bothering to store it in a specific variable:
1945
1946 if (strcharinfo(0)=="Daniel Jackson") mes "It is true, you are Daniel!";
1947
1948More examples of using the 'if' command in the real world:
1949
1950Example 1:
1951
1952 .@var1 = 1;
1953 input .@var2;
1954 if (.@var1 == .@var2)
1955 close;
1956 mes "Sorry that is wrong";
1957 close;
1958
1959Example 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
1969Example 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
1980Example 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
1991Example 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
2007If the condition doesn't meet, it'll do the action following the else.
2008We can also group several actions depending on a condition, this way:
2009
2010if (<condition) {
2011 dothis1;
2012 dothis2;
2013 dothis3;
2014} else {
2015 dothat1;
2016 dothat2;
2017 dothat3;
2018 dothat4;
2019}
2020
2021Example 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
2043See 'strcharinfo' for explanation of what this function does.
2044
2045Remember that if you plan to do several actions upon the condition being
2046false, and you forget to use the curly braces (the { } ), the second
2047action will be executed regardless the output of the condition, unless of
2048course, 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
2051Also, you can have multiple conditions nested or chained, and don't worry
2052about limits as to how many nested if you can have, there is no spoon ;).
2053
2054...
2055if (<condition 1>)
2056 dothis;
2057else if (<condition 2>) {
2058 dotheother;
2059 do that;
2060 end;
2061} else
2062 do this;
2063...
2064
2065---------------------------------------
2066
2067*while (<condition>) <statement>;
2068
2069This is probably the simplest and most frequently used loop structure. The
2070'while' statement can be interpreted as "while <condition> is true,
2071perform <statement>". It is a pretest loop, meaning the conditional
2072expression is tested before any of the statements in the body of the loop
2073are performed. If the condition evaluates to false, the statement(s) in
2074the body of the loop is/are never executed. If the condition evaluates to
2075true, the statement(s) are executed, then control transfers back to the
2076conditional expression, which is reevaluated and the cycle continues.
2077
2078Multiple statements can be grouped with { }, curly braces, just like with
2079the 'if' statement.
2080
2081Example 1:
2082 while (switch(select("Yes:No") == 2 ))
2083 mes "You picked no.";
2084
2085Example 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
2091Example 3: counter-controlled loop
2092 .@i = 1;
2093 while (.@i <= 5) {
2094 mes "This line will print 5 times.";
2095 ++.@i;
2096 }
2097
2098Example 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
2111Another pretest looping structure is the 'for' statement. It is considered
2112a specialized form of the 'while' statement, and is usually associated
2113with counter-controlled loops. Here are the steps of the 'for' statement:
2114the initialize statement is executed first and only once. The condition
2115test is performed. When the condition evaluates to false, the rest of the
2116for statement is skipped. When the condition evaluates to true, the body
2117of the loop is executed, then the update statement is executed (this
2118usually involves incrementing a variable). Then the condition is
2119reevaluated and the cycle continues.
2120
2121Example 1:
2122 for (.@i = 0; .@i < 5; ++.@i)
2123 mes "This line will print 5 times.";
2124
2125Example 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
2134The 'do...while' is the only post-test loop structure available in this
2135script language. With a post-test, the statements are executed once before
2136the condition is tested. When the condition is true, the statement(s) are
2137repeated. When the condition is false, control is transferred to the
2138statement following the 'do...while' loop expression.
2139
2140Example 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
2146Example 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
2157Toggling this to enabled (1) allows the script instance to bypass the
2158infinite loop protection, allowing your script to loop as much as it may
2159need. Disabling (0) may warn you if an infinite loop is detected if your
2160script is looping too many times.
2161
2162Please note, once again, that this isn't a solution to all problems, and by
2163disabling this protection your Cronus server may become laggy or
2164unresponsive if the script it is used in is performing lenghty loop
2165operations.
2166
2167Example:
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
2189This command will allow you to quickly fill up an array in one go. Check
2190the Kafra scripts in the distribution to see this used a lot.
2191
2192 setarray .@array[0], 100, 200, 300, 400, 500, 600;
2193
2194The index of the first element of the array to alter can be omitted if
2195zero. For example:
2196
2197 setarray .@array, 200, 200, 200;
2198 setarray .@array[1], 300, 150;
2199
2200will 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
2210This command will change many array values at the same time to the same
2211value.
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
2223See 'setarray'.
2224
2225---------------------------------------
2226
2227*copyarray <destination array>[<first value>],<source array>[<first value>],<amount of data to copy>;
2228
2229This command lets you quickly shuffle a lot of data between arrays, which
2230is 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
2239So 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
2247New Array:
2248 .@array2[0] = 300
2249 .@array2[1] = 400
2250 .@array2[2] = 0
2251 .@array2[3] = 0
2252
2253Notice that .@array[4] and .@array[5] won't be copied to the second array,
2254and it will return a 0.
2255
2256---------------------------------------
2257
2258*deletearray <array name>[<first value>],<how much to delete>;
2259
2260This command will delete a specified number of array elements totally from
2261an 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
2271If the amount of items to delete is not specified, all elements of the
2272array starting from the specified one to the end, are deleted. If no
2273starting element is specified either, the the entire array will be
2274deleted.
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//=====================================
22851 - End of Basic-Related Commands
2286//=====================================
2287---------------------------------------
2288
2289
2290---------------------------------------
2291//=====================================
22922 - Information-retrieving Related Commands
2293//=====================================
2294---------------------------------------
2295
2296*strcharinfo(<type>)
2297
2298This function will return either the name, party name or guild name for
2299the 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
2305If a character is not a member of any party or guild, an empty string will
2306be returned when requesting that information.
2307
2308Note: Numbers can also be used in <type>, but their usage is disncouraged as
2309using only numbers reduces script readability
2310
2311---------------------------------------
2312
2313*strnpcinfo(<type>)
2314
2315This function will return the various parts of the name of the calling NPC.
2316Whatever 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
2328This function returns the RID of the character with the given character ID.
2329
2330If the character is offline or doesn't exist, 0 is returned.
2331
2332---------------------------------------
2333
2334*getarraysize(<array name>)
2335
2336This function returns highest index of the array that is filled.
2337Notice that zeros and empty strings at the end of this array are not
2338counted towards this number.
2339
2340For example:
2341
2342 setarray .@array, 100, 200, 300, 400, 500, 600;
2343 .@arraysize = getarraysize(.@array);
2344
2345This 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
2352If 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
2363This command retrieves the value of the element of given array at given
2364index. This is equivalent to using:
2365
2366 <array name>[<index>]
2367
2368The reason for this is, that this short form is internally converted into
2369a call to getelementofarray, when the script is loaded.
2370
2371Also useful when passing arrays to functions or accessing another npc's
2372arrays:
2373 getelementofarray(getarg(0),<index>)
2374 getelementofarray(getvariableofnpc(.var, "testNPC"),<index>)
2375
2376---------------------------------------
2377
2378*readparam(<parameter number>)
2379
2380This function will return the basic stats of an invoking character,
2381referred to by the parameter number. Instead of a number, you can use a
2382parameter name if it is defined in 'db/const.txt'.
2383
2384Example parameters:
2385
2386StatusPoint, BaseLevel, SkillPoint, Class, Upper, Zeny, Sex, Weight,
2387MaxWeight, JobLevel, BaseExp, JobExp, NextBaseExp, NextJobExp, Hp, MaxHp,
2388Sp, MaxSp, BaseJob, Karma, Manner, bVit, bDex, bAgi, bStr, bInt, bLuk
2389
2390All 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
2393Example 1:
2394
2395 // Returns how many status points you haven't spent yet.
2396 mes "Unused status points: "+readparam(9);
2397
2398Using this particular information as a function call is not required.
2399Typing this will return the same result:
2400
2401 mes "Unused status points: "+StatusPoint;
2402
2403Example 2:
2404
2405You 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
2410Example 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
2419This function will return a unique ID number of the invoking character,
2420or, if a character name is specified, of that player.
2421
2422Type 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
2430For most purposes other than printing it, a number is better to have than
2431a name (people do horrifying things to their character names).
2432
2433If the character is not in a party or not in a guild, the function will
2434return 0 if guild or party number is requested. If a name is specified and
2435the character is not found, 0 is returned.
2436
2437If getcharid(0) returns a zero, the script got called not by a character
2438and doesn't have an attached RID. Note that this will cause the map server
2439to print "player not attached!" error messages, so it is preferred to use
2440"playerattached" to check for the character attached to the script.
2441
2442if( getcharid(2) == 0 ) mes "Only members of a guild are allowed here!";
2443
2444---------------------------------------
2445
2446*getnpcid(<type>{,"<npc name>"});
2447
2448Retrieves IDs of the currently invoked NPC. If a unique npc name is given,
2449IDs of that NPC are retrieved instead. Type specifies what ID to retrieve
2450and can be one of the following:
2451
2452 0 - Unit ID (GID)
2453
2454If an invalid type is given or the NPC does not exist, 0 is returned.
2455
2456---------------------------------------
2457
2458*getchildid()
2459*getmotherid()
2460*getfatherid()
2461
2462These functions return the character ID of the attached player's child,
2463mother, 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
2471This function returns 1 if the invoking character's marriage partner is
2472currently online and 0 if they are not or if the character has no partner.
2473
2474---------------------------------------
2475
2476*getpartnerid()
2477
2478This function returns the character ID of the invoking character's
2479marriage partner, if any. If the invoking character is not married, it
2480will 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
2489This function will return the name of a party that has the specified ID
2490number. If there is no such party ID, "null" will be returned.
2491
2492Lets 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
2502This command will find all members of a specified party and returns their
2503names (or character id or account id depending on the value of "type")
2504into an array of temporary global variables. There's actually quite a few
2505commands like this which will fill a special variable with data upon
2506execution and not do anything else.
2507
2508Upon 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
2524The party members will (apparently) be found regardless of whether they
2525are online or offline. Note that the names come in no particular order.
2526
2527Be sure to use $@partymembercount to go through this array, and not
2528'getarraysize', because it is not cleared between runs of 'getpartymember'.
2529If someone with 7 party members invokes this script, the array would have
25307 elements. But if another person calls up the NPC, and he has a party of
25315, the server will not clear the array for you, overwriting the values
2532instead. So in addition to returning the 5 member names, the 6th and 7th
2533elements from the last call remain, and you will get 5+2 members, of which
2534the last 2 don't belong to the new guy's party. $@partymembercount will
2535always contain the correct number, (5) unlike 'getarraysize()' which will
2536return 7 in this case.
2537
2538Example 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
2558Example 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
2617This function returns some information about the given party-id's leader.
2618When type is omitted, the default information retrieved is the leader's
2619name. 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
2628If retrieval fails (leader not found or party does not exist), this
2629function returns "null" instead of the character name, and -1 for the
2630other types.
2631
2632---------------------------------------
2633
2634*getlook(<type>)
2635
2636This function will return the number for the current character look value
2637specified by type. See 'setlook' for valid look types.
2638
2639This can be used to make a certain script behave differently for
2640characters dressed in black. :)
2641
2642---------------------------------------
2643
2644*getsavepoint(<information type>)
2645
2646This function will return information about the invoking character's save
2647point. You can use it to let a character swap between several recorded
2648save 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
2658This function will return the IP address of the invoking character, or, if
2659a player is specified, of that character. A blank string is returned if no
2660player is attached.
2661
2662Examples:
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
2675This function will force a character to sit/stand if it is standing/sitting.
2676If no player is specified, the attached player will be used.
2677
2678---------------------------------------
2679
2680*issit({"<character name>"})
2681
2682This function will return a number depending on the character's sitting state.
2683If the character is sitting, it will return 1, otherwise (standing) it will return 0.
2684In case no player is specified, the function will return the state of the attached player.
2685
2686---------------------------------------
2687//=====================================
26882.1 - Item-Related Commands
2689//=====================================
2690---------------------------------------
2691
2692*getequipid(<equipment slot>)
2693
2694This function returns the item ID of the item equipped in the equipment
2695slot specified on the invoking character. If nothing is equipped there, it
2696returns -1. Valid equipment slots are:
2697
2698EQI_HEAD_TOP (1) - Upper head gear
2699EQI_ARMOR (2) - Armor (Where you keep your Jackets and Robes)
2700EQI_HAND_L (3) - What is in your Left hand.
2701EQI_HAND_R (4) - What is in your Right hand.
2702EQI_GARMENT (5) - The garment slot (Mufflers, Hoods, Manteaus)
2703EQI_SHOES (6) - What foot gear the player has on.
2704EQI_ACC_L (7) - Accessory 1.
2705EQI_ACC_R (8) - Accessory 2.
2706EQI_HEAD_MID (9) - Middle Headgear (masks and glasses)
2707EQI_HEAD_LOW (10) - Lower Headgear (beards, some masks)
2708EQI_COSTUME_HEAD_LOW (11) - Lower Costume Headgear
2709EQI_COSTUME_HEAD_MID (12) - Middle Costume Headgear
2710EQI_COSTUME_HEAD_TOP (13) - Upper Costume Headgear
2711EQI_COSTUME_GARMENT (14) - Costume Garment
2712EQI_SHADOW_ARMOR (15) - Shadow Armor
2713EQI_SHADOW_WEAPON (16) - Shadow Weapon
2714EQI_SHADOW_SHIELD (17) - Shadow Shield
2715EQI_SHADOW_SHOES (18) - Shadow Shoes
2716EQI_SHADOW_ACC_R (19) - Shadow Accessory 2
2717EQI_SHADOW_ACC_L (20) - Shadow Accessory 1
2718
2719Notice that a few items occupy several equipment slots, and if the
2720character is wearing such an item, 'getequipid' will return it's ID number
2721for either slot.
2722
2723Can be used to check if you have something equipped, or if you haven't got
2724something 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
2733You can also use it to make sure people don't pass a point before removing
2734an item totally from them. Let's say you don't want people to wear Legion
2735Plate armor, but also don't want them to equip if after the check, you
2736would 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
2755Returns the jname of the item equipped in the specified equipment slot on
2756the invoking character, or an empty string if nothing is equipped in that
2757position.
2758Does the same thing as getitemname(getequipid()). Useful for an NPC to
2759state what your are wearing, or maybe saving as a string variable.
2760See '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
2771Given the database ID number of an item, this function will return the
2772text stored in the 'japanese name' field (which, in Cronus, stores an
2773English name the players would normally see on screen).
2774
2775---------------------------------------
2776
2777*getbrokenid(<number>)
2778
2779This function will search the invoking character's inventory for any
2780broken items, and will return their item ID numbers. Since the character
2781may have several broken items, 1 given as an argument will return the
2782first one found, 2 will return the second one, etc. Will return 0 if no
2783such 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
2795This function will return the total amount of broken equipment on the
2796invoking character.
2797
2798---------------------------------------
2799
2800*getequipisequiped(<equipment slot>)
2801
2802This functions will return 1 if there is an equipment placed on the
2803specified equipment slot and 0 otherwise. For a list of equipment slots
2804see '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
2819Will return 1 if the item equipped on the invoking character in the
2820specified equipment slot is refinable, and 0 if it isn't. For a list of
2821equipment 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
2836Returns the current number of pluses for the item in the specified
2837equipment slot. For a list of equipment slots see 'getequipid'.
2838
2839Can be used to check if you have reached a maximum refine value, default
2840for 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
2852This function returns the weapon level for the weapon equipped in the
2853specified equipment slot on the invoking character. For a list of
2854equipment slots see 'getequipid'.
2855
2856Only EQI_HAND_L and EQI_HAND_R normally make sense, since only weapons
2857have a weapon level. You can, however, probably, use this field for other
2858equippable custom items as a flag or something.
2859
2860If no item is equipped in this slot, or if it doesn't have a weapon level
2861according to the database, 0 will be returned.
2862
2863Examples:
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
2893This function calculates and returns the percent value chance to
2894successfully refine the item found in the specified equipment slot of the
2895invoking character by +1. There is no actual formula, the success rate for
2896a given weapon level of a certain refine level is found in the
2897db/refine_db.txt file. For a list of equipment slots see 'getequipid'.
2898
2899These values can be displayed for the player to see, or used to calculate
2900the random change of a refine succeeding or failing and then going through
2901with 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
2912This function will count all the items with the specified ID number lying
2913on the ground on the specified map within the x1/y1-x2/y2 square on it and
2914return that number.
2915
2916This is the only function around where a parameter may be either a string
2917or a number! If it's a number, it means that only the items with that item
2918ID 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
2920string, or something that isn't found from the item database, it will
2921count items number '512' (apples).
2922
2923---------------------------------------
2924
2925*getequipcardcnt(<equipment slot>)
2926
2927This function will return the number of cards that have been compounded
2928onto a specific equipped item for the invoking character. See 'getequipid'
2929for a list of possible equipment slots.
2930
2931---------------------------------------
2932
2933*getinventorylist;
2934
2935This command sets a bunch of arrays with a complete list of whatever the
2936invoking character has in its inventory, including all the data needed to
2937recreate 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
2955This could be handy to save/restore a character's inventory, since no
2956other command returns such a complete set of data, and could also be the
2957only way to correctly handle an NPC trader for carded and named items who
2958could resell them - since NPC objects cannot own items, so they have to
2959store item data in variables and recreate the items.
2960
2961Notice that the variables this command generates are all temporary,
2962attached to the character, and integer.
2963
2964Be sure to use @inventorylist_count to go through these arrays, and not
2965'getarraysize', because the arrays are not automatically cleared between
2966runs of 'getinventorylist'.
2967
2968---------------------------------------
2969
2970*getcartinventorylist;
2971
2972This command sets a bunch of arrays with a complete list of whatever the
2973invoking character has in its cart_inventory, including all the data needed to
2974recreate 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
2991This could be handy to save/restore a character's cart_inventory, since no
2992other command returns such a complete set of data, and could also be the
2993only way to correctly handle an NPC trader for carded and named items who
2994could resell them - since NPC objects cannot own items, so they have to
2995store item data in variables and recreate the items.
2996
2997Notice that the variables this command generates are all temporary,
2998attached to the character, and integer.
2999
3000Be sure to use @cartinventorylist_count to go through these arrays, and not
3001'getarraysize', because the arrays are not automatically cleared between
3002runs of 'getcartinventorylist'.
3003
3004---------------------------------------
3005
3006*cardscnt()
3007
3008This function will return the number of cards inserted into the weapon
3009currently equipped on the invoking character.
3010While 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
3018This function will return the refine count of the equipment from which
3019the 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
3028This function is equivalent to using 'getitem', however, it will not just
3029give the character an item object, but will also inscribe it with a
3030specified character's name. You may not inscribe items with arbitrary
3031strings, only with names of characters that actually exist. While this
3032isn't said anywhere specifically, apparently, named items may not have
3033cards in them, slots or no - these data slots are taken by the character
3034ID who's name is inscribed. Only one remains free and it's not quite clear
3035if a card may be there.
3036
3037This function will return 1 if an item was successfully created and 0 if
3038it wasn't for whatever reason. Like 'getitem', this function will also
3039accept an 'english name' from the item database as an item name and will
3040return 0 if no such item exists.
3041
3042---------------------------------------
3043
3044*getitemslots(<item ID>)
3045
3046This function will look up the item with the specified ID number in the
3047database and return the number of slots this kind of items has - 0 if they
3048are not slotted. It will also be 0 for all non-equippable items,
3049naturally, unless someone messed up the item database. It will return -1
3050if there is no such item.
3051
3052Example:
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
3061This function will look up the item with the specified ID number in the
3062database and return the info set by TYPE argument.
3063It will return -1 if there is no such item.
3064
3065Valid 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
3075Check sample in doc/sample/getiteminfo.txt
3076
3077---------------------------------------
3078
3079*getequipcardid(<equipment slot>,<card slot>)
3080
3081Returns value for equipped item slot in the indicated slot (0, 1, 2, or 3).
3082
3083This function returns CARD ID, 255,254,-255 (for card 0, if the item is
3084produced). It's useful for when you want to check whether an item contains
3085cards or if it's signed.
3086
3087---------------------------------------
3088//=====================================
30892.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
3095This function will locate a character object, NPC object or pet's
3096coordinates and place their coordinates into the variables specified when
3097calling it. It will return 0 if the search was successful, and -1 if the
3098parameters given were not variables or the search was not successful.
3099
3100Type 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
3110While 3 is meant to look for a monster object, no searching will be done
3111if you specify type 3, and the function will always return -1.
3112
3113The search string is optional. If it is not specified, the location of the
3114invoking character will always be returned for types 0 and 2, the location
3115of the NPC running this function for type 1.
3116If a search string is specified, for types 0 and 1, the character or NPC
3117with the specified name will be located. If type is 3, the search will
3118locate the current pet of the character who's name is given in the search
3119string, it will NOT locate a pet by name.
3120
3121What 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
3139Notice that NPC objects disabled with 'disablenpc' will still be located.
3140
3141---------------------------------------
3142
3143*getgmlevel()
3144
3145This function will return the (GM) level of player group the account to
3146which the invoking character belongs. If this is somehow executed from a
3147console command, 99 will be returned, and 0 will be returned if the
3148account has no GM level.
3149
3150This allows you to make NPC's only accessible for certain GM levels, or
3151behave 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
3160This function will return the id of player group the account to which the
3161invoking player belongs.
3162
3163---------------------------------------
3164
3165*gettimetick(<tick type>)
3166
3167This function will return the system time in UNIX epoch time (if tick type
3168is 2) or the time since the start of the current day in seconds if tick
3169type is 1.
3170Passing 0 will make it return the server's tick, which is a measurement in
3171milliseconds used by the server's timer system. The server's tick is an
3172unsigned int which loops every ~50 days.
3173
3174Just in case you don't know, UNIX epoch time is the number of seconds
3175elapsed since 1st of January 1970, and is useful to see, for example,
3176for how long the character has been online with OnPCLoginEvent and
3177OnPCLogoutEvent, which could allow you to make an 'online time counted for
3178conviction only' jail script.
3179
3180---------------------------------------
3181
3182*gettime(<type>)
3183
3184This function returns specified information about the current system time.
3185
31861 - Seconds (of a minute)
31872 - Minutes (of an hour)
31883 - Hour (of a day)
31894 - Week day (0 for Sunday, 6 is Saturday)
31905 - Day of the month.
31916 - Number of the month.
31927 - Year.
31938 - Day of the year.
3194
3195It 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
3203This function will return a string containing time data as specified by
3204the format string.
3205
3206This uses the C function 'strfmtime', which obeys special format
3207characters. For a full description see, for example, the description of
3208'strfmtime' at http://www.delorie.com/gnu/docs/glibc/libc_437.html
3209All the format characters given in there should properly work.
3210Max length is the maximum length of a time string to generate.
3211
3212The example given in Cronus sample scripts works like this:
3213
3214 mes gettimestr("%Y-%m/%d %H:%M:%S",21);
3215
3216This will print a full date and time like 'YYYY-MM/DD HH:MM:SS'.
3217
3218---------------------------------------
3219
3220*getusers(<type>)
3221
3222This function will return a number of users on a map or the whole server.
3223What it returns is specified by Type.
3224
3225Type 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
3236This function will return the number of users currently located on the
3237specified map.
3238
3239Currently being used in the PVP scripts to check if a PVP room is full of
3240not, if the number returned it equal to the maximum allowed it will not
3241let you enter.
3242
3243---------------------------------------
3244
3245*getareausers({"<nome do mapa>",}{<x1>,<y1>,<x2>,<y2>})
3246*getareausers({"<nome do mapa>",}{<radius>})
3247
3248This function will return the count of connected characters which are
3249located within the specified area. Area can be x1/y1-x2/y2 square,
3250or radius from npc position. If nome do mapa missing, used attached player map.
3251
3252This is useful for maps that are split into many buildings, such as all
3253the "*_in" maps, due to all the shops and houses.
3254
3255Examples:
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
3265This command will give the invoking character a list of names of the
3266connected characters (including themselves) into an NPC script message
3267window (see 'mes') paging it by 10 names as if with the 'next' command.
3268
3269You need to put a 'close' after that yourself.
3270
3271---------------------------------------
3272//=====================================
32732.2 - Guild-Related Commands
3274//=====================================
3275---------------------------------------
3276
3277*getguildname(<guild id>)
3278
3279This function returns a guild's name given an ID number. If there is no
3280such 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
3289This is used all over the WoE controlling scripts. You could also use it
3290for a guild-based event.
3291
3292---------------------------------------
3293
3294*getguildmaster(<guild id>)
3295
3296This function return the name of the master of the guild which has the
3297specified 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
3302Can be used to check if the character is the guild master of the specified
3303guild.
3304
3305Maybe 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
3323This function will return the character ID number of the guild master of
3324the guild specified by the ID. 0 if the character is not a guild master of
3325any guild.
3326
3327---------------------------------------
3328
3329*getcastlename("<nome do mapa>")
3330
3331This function returns the name of the castle when given the nome do mapa for
3332that 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
3339This function returns the castle ownership information for the castle
3340referred to by its nome do mapa. Castle information is stored in
3341`guild_castle` SQL table.
3342
3343Types 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.
335410 - `visibleG0` - Is 1 if the 1st guardian is present (Soldier Guardian)
335511 - `visibleG1` - Is 1 if the 2nd guardian is present (Soldier Guardian)
335612 - `visibleG2` - Is 1 if the 3rd guardian is present (Soldier Guardian)
335713 - `visibleG3` - Is 1 if the 4th guardian is present (Archer Guardian)
335814 - `visibleG4` - Is 1 if the 5th guardian is present (Archer Guardian)
335915 - `visibleG5` - Is 1 if the 6th guardian is present (Knight Guardian)
336016 - `visibleG6` - Is 1 if the 7th guardian is present (Knight Guardian)
336117 - `visibleG7` - Is 1 if the 8th guardian is present (Knight Guardian)
3362
3363All types of data have their meaning determined by War of Emperium
3364scripts, 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
3369The 'setcastledata' command will behave identically, but instead of
3370returning values for the specified types of accessible data, it will alter
3371them and cause them to be sent to the char-server for storage.
3372
3373Changing Guild ID or Castle Defense will trigger additional actions, like
3374recalculating guardians' HP.
3375
3376---------------------------------------
3377
3378*getgdskilllv(<guild id>,<skill id>)
3379*getgdskilllv(<guild id>,"<skill name>")
3380
3381This function returns the level of the skill <skill id> of the guild
3382<guild id>.
3383If the guild does not have that skill, 0 is returned.
3384If the guild does not exist, -1 is returned.
3385Refer to 'db/(pre-)re/skill_db.txt' for the full list of skills.
3386GD_* are guild skills
3387
3388---------------------------------------
3389
3390*requestguildinfo <guild id>{,"<event label>"};
3391
3392This command requests the guild data from the char server and merrily
3393continues with the execution. Whenever the guild information becomes
3394available (which happens instantly if the guild information is already in
3395memory, or later, if it isn't and the map server has to wait for the char
3396server to reply) it will run the specified event as in a 'doevent' call.
3397
3398---------------------------------------
3399
3400*getmapguildusers(<mapname>,<guild id>)
3401
3402Returns the amount of characters from the specified guild on the given map.
3403
3404Example:
3405
3406mes "You have "+getmapguildusers("prontera",getcharid(2))+" guild members in Prontera.";
3407
3408---------------------------------------
3409
3410*getguildmember <guild id>{,<type>};
3411
3412This 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
3414of temporary global variables.
3415
3416Upon 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
3432The guild members will be found regardless of whether they are online or offline.
3433Note that the names come in no particular order.
3434
3435Be sure to use $@guildmembercount to go through this array, and not
3436'getarraysize', because it is not cleared between runs of 'getguildmember'.
3437
3438For usage examples, see 'getpartymember'.
3439
3440---------------------------------------
3441//=====================================
34422.2 - End of Guild-Related Commands
3443//=====================================
3444---------------------------------------
3445
3446*getskilllv(<skill id>)
3447*getskilllv("<skill name>")
3448
3449This function returns the level of the specified skill that the invoking
3450character has. If they don't have the skill, 0 will be returned. The full
3451list of character skills is available in 'db/(pre-)re/skill_db.txt'.
3452
3453There are two main uses for this function, it can check whether the
3454character has a skill or not, and it can tell you if the level is high
3455enough.
3456
3457Example 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
3467Example 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
3484This command sets a bunch of arrays with a complete list of skills the
3485invoking 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
3492While 'getskillv' is probably more useful for most situations, this is the
3493easiest way to store all the skills and make the character something else
3494for a while. Advanced job for a day? :) This could also be useful to see
3495how many skills a character has.
3496
3497---------------------------------------
3498
3499*getpetinfo(<type>)
3500
3501This function will return pet information for the pet the invoking
3502character 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
3518Returns current pet status, all are integers except name.
3519Returns 0 or "" if the player doesn't have pets.
3520
3521Flags usable:
3522PET_CLASS
3523PET_NAME
3524PET_LEVEL
3525PET_HUNGRY
3526PET_INTIMATE
3527
3528Example:
3529 .@i = petstat(PET_CLASS);
3530
3531---------------------------------------
3532
3533*getmonsterinfo(<mob ID>,<type>)
3534
3535This function will look up the monster with the specified ID number in the
3536mob database and return the info set by TYPE argument.
3537It will return -1 if there is no such monster (or the type value is
3538invalid), or "null" if you requested the monster's name.
3539
3540Valid 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
3565Check sample in doc/sample/getmonsterinfo.txt
3566
3567---------------------------------------
3568
3569*addmonsterdrop(<mob id or name>, <item id>, <rate>)
3570
3571This command will temporarily add a drop to an existing monster. If the
3572monster already drops the specified item, its drop rate will be updated to the
3573given value.
3574
3575Both the monster and the item must be valid. Acceptable values for the drop
3576rate are in the range [1:10000].
3577
3578Return value will be 1 in case of success (the item was added or its drop rate
3579was updated), and 0 otherwise (there were no free item drop slots).
3580
3581Example:
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
3589This command will temporarily remove a drop from an existing monster.
3590
3591Both the monster and the item must be valid.
3592
3593Return value will be 1 in case of success (the item was removed), and 0
3594otherwise (the monster didn't have the specified item in its drop list).
3595
3596Example:
3597 // Remove Jellopy (909) from the Poring's (1002) drops
3598 delmonsterdrop(1002, 909);
3599
3600---------------------------------------
3601
3602*getmobdrops(<mob id>)
3603
3604This command will find all drops of the specified mob and return the item
3605IDs 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
3608Upon 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
3618Be sure to use $@MobDrop_count to go through the arrays, and not
3619'getarraysize', because the temporary global arrays are not cleared
3620between runs of 'getmobdrops'. If a mob with 7 item drops is looked up,
3621the arrays would have 7 elements. But if another mob is looked up and it
3622only has 5 item drops, the server will not clear the arrays for you,
3623overwriting the values instead. So in addition to returning the 5 item
3624drops, the 6th and 7th elements from the last call remain, and you will
3625get 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
3629Example:
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
3656Returns the total amount of skill points a character possesses
3657(SkillPoint+SP's used in skills) This command can be used to check the
3658currently attached characters total amount of skill points. This means the
3659skill points used in skill are counted, and added to SkillPoints (number
3660of skill points not used).
3661
3662Example:
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
3673This command does not count skills which are set as flag 3 (permamently
3674granted) (e.g. ALL_BUYING_STORE/ALL_INCCARRY).
3675---------------------------------------
3676
3677*getscrate(<effect type>,<base rate>{,<GID>})
3678
3679This function will return the chance of a status effect affecting the
3680invoking character, in percent, modified by the their current defense
3681against said status. The 'base rate' is the base chance of the status
3682effect being inflicted, in percent.
3683
3684 if (rand(100) > getscrate(Eff_Blind, 50)) {
3685 // do something
3686 }
3687
3688You can see the full list of available effect types you can possibly
3689inflict in 'db/const.txt' under 'Eff_'.
3690
3691---------------------------------------
3692//=====================================
36933 - Checking-Related Commands
3694//=====================================
3695---------------------------------------
3696
3697*playerattached()
3698
3699Returns the ID of the player currently attached to the script. It will
3700return 0 if no one is attached, or if the attached player no longer exists
3701on the map server. It is wise to check for the attached player in script
3702functions that deal with timers as there's no guarantee the player will
3703still be logged on when the timer triggers. Note that the ID of a player
3704is actually their account ID.
3705
3706---------------------------------------
3707
3708*isloggedin(<account id>{,<char id>})
3709
3710This function returns 1 if the specified account is logged in and 0 if
3711they aren't. You can also pass the char_id to check for both account and
3712char 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
3720These functions will compute and return 1 if the total weight of the
3721specified number of specific items does not exceed the invoking
3722character's carrying capacity, and 0 otherwise. It is important to see if
3723a player can carry the items you expect to give them, failing to do that
3724may open your script up to abuse or create some very unfair errors.
3725
3726The second function will check an array of items and amounts, and also
3727returns 1 on success and 0 on failure.
3728
3729The functions, in addition to checking to see if the player is capable of
3730holding a set amount of items, also ensure the player has room in their
3731inventory for the item(s) they will be receiving.
3732
3733Like 'getitem', this function will also accept an 'english name' from the
3734database as an argument.
3735
3736Example 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
3744Example 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
3756This function will return the state of the configuration option
3757'basic_skill_check' in 'battle.conf'. Returns 1 if the option is enabled
3758and 0 if it isn't. If the 'basic_skill_check' option is enabled, which it
3759is by default, characters must have a certain number of basic skill levels
3760to sit, request a trade, use emotions, etc. Making your script behave
3761differently depending on whether the characters must actually have the
3762skill 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
3771The 'setoption' series of functions check for a so-called option that is
3772set on the invoking character. 'Options' are used to store status
3773conditions and a lot of other non-permanent character data of the yes-no
3774kind. For most common cases, it is better to use 'checkcart',
3775'checkfalcon', 'checkpeco' and other similar functions, but there are some
3776options which you cannot get at this way. They return 1 if the option is
3777set and 0 if the option is not set.
3778
3779Option numbers valid for the first (option) version of this command are:
3780
37810x000001 - Sight in effect.
37820x000002 - Hide in effect.
37830x000004 - Cloaking in effect.
37840x000008 - Cart number 1 present.
37850x000010 - Falcon present.
37860x000020 - Peco Peco present.
37870x000040 - GM Perfect Hide in effect.
37880x000080 - Cart number 2 present.
37890x000100 - Cart number 3 present.
37900x000200 - Cart number 4 present.
37910x000400 - Cart number 5 present.
37920x000800 - Orc head present.
37930x001000 - The character is wearing a wedding sprite.
37940x002000 - Ruwach is in effect.
37950x004000 - Chasewalk in effect.
37960x008000 - Flying or Xmas suit.
37970x010000 - Sighttrasher.
37980x100000 - Warg present.
37990x200000 - The character is riding a warg.
3800
3801Option numbers valid for the second version (opt1) of this command are:
3802
38031 - Petrified.
38042 - Frozen.
38053 - Stunned.
38064 - Sleeping.
38076 - Petrifying (the state where you can still walk)
3808
3809Option numbers valid for the third version (opt2) of this command are:
3810
38110x01 - Poisoned.
38120x02 - Cursed.
38130x04 - Silenced.
38140x08 - Signum Crucis (plays a howl-like sound effect, but otherwise no
3815 visible effects are displayed)
38160x10 - Blinded.
38170x80 - Deadly poisoned.
3818
3819Option numbers (except for opt1) are bit-masks - you can add them up to
3820check for several states, but the functions will return true if at least
3821one of them is in effect.
3822
3823'setoption' will set options on the invoking character. There are no
3824second and third versions of this command, so you can only change the
3825values in the first list (cloak, cart, ruwach, etc). If flag is 1 (default
3826when omitted), the option will be added to what the character currently
3827has; if 0, the option is removed.
3828
3829This is definitely not a complete list of available option flag numbers.
3830Ask a core developer (or read the source: src/map/status.h) for the full
3831list.
3832
3833---------------------------------------
3834
3835*setcart {<type>};
3836*checkcart()
3837
3838If <type> is 0 this command will remove the cart from the character.
3839Otherwise it gives the invoking character a cart. The cart given will be
3840cart number <type> and will work regardless of whether the character is a
3841merchant class or not.
3842Note: the character needs to have the skill MC_PUSHCART to gain a cart.
3843
3844The accompanying function will return 1 if the invoking character has a
3845cart (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
3854If <flag> is 0 this command will remove the falcon from the character.
3855Otherwise it gives the invoking character a falcon. The falcon will be
3856there regardless of whether the character is a hunter or not. It will
3857(probably) not have any useful effects for non-hunters though.
3858Note: the character needs to have the skill HT_FALCON to gain a falcon.
3859
3860The accompanying function will return 1 if the invoking character has a
3861falcon 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
3870If <flag> is MOUNT_NONE (or 0) this command will remove the mount from the
3871character.
3872
3873Otherwise it gives the invoking character the desired combat mount, where
3874allowed by their class and skills.
3875
3876If no flag is specified, the mount is automatically chosen according to the
3877character's class and skills.
3878
3879The 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
3900Unlike 'setfalcon' and 'setcart' this will not work at all if they aren't of a
3901class which can ride a mount.
3902
3903The accompanying function will return 0 if the invoking character is not on a
3904mount, and a non-zero value (according to the above constants) if they are.
3905Note: in case of dragons, the returned value will always be MOUNT_DRAGON,
3906regardless 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
3919The 'setcashmount' function toggles cash mount for the invoking character.
3920It will return 1 if successful, 0 otherwise.
3921
3922Note: Character must not be mounting a non-cash mount (eg. dragon, peco,
3923 wug, etc.)
3924
3925The accompanying function will return 1 if the invoking character has a
3926cash mount and 0 if they don't.
3927
3928---------------------------------------
3929
3930*checkwug()
3931
3932This function will return 1 if the invoking character has a warg and 0 if
3933they don't.
3934
3935---------------------------------------
3936
3937*checkvending({"<Player Name>"})
3938*checkchatting({"<Player Name>"})
3939
3940Checks if the player is vending or in a chatroom.
3941Name is optional, and defaults to the attached player if omitted.
3942
3943Return 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
3950Examples:
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
3964Returns the time, in seconds, that the specified player has been idle.
3965Name is optional, and defaults to the attached player if omitted.
3966
3967---------------------------------------
3968
3969*agitcheck()
3970*agitcheck2()
3971
3972These function will let you check whether the server is currently in WoE
3973mode (or WoE SE mode if the second function is called) and will return 1
3974if War of Emperium is on and 0 if it isn't.
3975
3976---------------------------------------
3977
3978*isnight()
3979
3980This functions will return true or false depending on whether the server is in
3981night mode or day mode:
3982
3983 if (!isnight()) mes "I only prowl in the night.";
3984
3985---------------------------------------
3986//=====================================
39873.1 - Checking Item-Related Commands
3988//=====================================
3989---------------------------------------
3990
3991*isequipped(<item id>{,<item id>{,<item id>{,<item id>}}})
3992
3993This function will return 1 if the invoking character has all of the item
3994IDs given equipped (if card IDs are passed, then it checks if the cards
3995are inserted into slots in the equipment they are currently wearing).
3996Theoretically there is no limit to the number of items that may be tested
3997for at the same time.
3998If 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
4007The function was meant for item scripts to support the cards released by
4008Gravity 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
4014This function is similar to 'isequipped', but instead of 1 or 0, it will
4015return the number of equipped items/cards in the list given that were found on the
4016invoking 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
4025This function will return 1 if the card specified by it's item ID number
4026is inserted into any equipment they have in their inventory, currently
4027equipped or not.
4028
4029---------------------------------------
4030
4031*getequipisidentify(<equipment slot>)
4032
4033This function will return 1 if an item in the specified equipment slot is
4034identified and 0 if it isn't. Since you can't even equip unidentified
4035equipment, there's a question of whether it can actually end up there, and
4036it will normally return 1 all the time if there is an item in this
4037equipment slot, which makes this script command kinda pointless.
4038For a list of equipment slots see 'getequipid'.
4039
4040---------------------------------------
4041//=====================================
40423.0 & 3.1 - End of Checking/Item-Related Commands
4043//=====================================
4044---------------------------------------
4045
4046---------------------------------------
4047//=====================================
40484 - Player-Related Commands
4049//=====================================
4050---------------------------------------
4051
4052*attachrid(<account ID>)
4053*detachrid;
4054
4055These commands allow the manipulation of the script's currently attached
4056player. While attachrid allows attaching of a different player by using
4057its account id for the parameter rid, detachrid makes the following
4058commands run as if the script was never invoked by a player.
4059
4060In case, that the player cannot be attached, such as, when the player went
4061offline in the mean time, attachrid returns 0, otherwise 1.
4062
4063---------------------------------------
4064
4065*rid2name(<rid>)
4066
4067Converts rid to name. Note: The player/monster/NPC must be online/enabled.
4068Good for PCKillEvent where you can convert 'killedrid' to the name of the
4069player.
4070
4071Note: 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
4079That command will send a message to the chat window of the character
4080specified by name. The text will also appear above the head of that
4081character. It will not be seen by anyone else.
4082
4083---------------------------------------
4084
4085*dispbottom "<message>"{,<color_flag>};
4086
4087This command will send the given message into the invoking character's
4088chat window.
4089
4090//Parameto opicional de cor adicionado por Slex Fire
4091
4092Para usar uma cor, basta digitar 0x seguido do codigo hexadecimal da cor.
4093
4094 dispbottom "Esta mensagem é vermelha",0xFF0000;
4095Exibe a mensagem "Esta mensagem é vermelha", na cor vermelha, no jogador que está
4096attachado ao script.
4097
4098---------------------------------------
4099
4100*showscript "<message>"{,<GID>};
4101
4102Makes attached player or GID says a message like shouting a skill name, the message
4103will be seen to everyone around but not in chat window.
4104
4105---------------------------------------
4106
4107*warp "<nome do mapa>",<x>,<y>{,<flag>};
4108
4109This command will take the invoking character to the specified map, and if
4110wanted, specified coordinates too, but these can be random.
4111
4112 warp "place",50,55;
4113
4114This would take them to X 50 Y 55 on the map called "place". If your X and
4115Y coordinates land on an unwalkable map square, it will send the warped
4116character to a random place. Same will happen if they are both zero:
4117
4118 warp "place",0,0;
4119
4120Notice that while warping people to coordinates 0,0 will normally get them
4121into a random place, it's not certain to always be so. Darned if I know
4122where this is actually coded, it might be that this happens because square
41230,0 is unwalkable on all official maps. Beware if you're using custom maps.
4124
4125There 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
4130If flag parameter is set to 0, after player warped will be not stopped
4131currend running npc script. Running script after warp can be issue for
4132Gravity 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
4138This command is similar to 'warp', however, it will not refer to the
4139invoking character, but instead, all characters within a specified area,
4140defined by the x1/y1-x2/y2 square, will be warped. Nobody outside the area
4141will be affected, including the activating character, if they are outside
4142the area.
4143
4144 areawarp "place",10,10,120,120,"place2",150,150;
4145
4146Everyone that is in the area between X 10 Y 10 and X 120 Y 120, in a
4147square 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
4152By using ,0,0; as the destination coordinates it will take all the
4153characters 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
4158By using the optional x4 and y4 parameters, the destination coordinates
4159will be a random place within the defined x3/y3-x4/y4 square.
4160
4161Like 'warp', areawarp will also explicitly warp characters randomly into
4162the current map if you give the 'to nome do mapa' as "Random".
4163
4164See also 'warp'.
4165
4166---------------------------------------
4167
4168*warpparty "<to_mapname>",<x>,<y>,<party_id>,{"<from_mapname>"};
4169
4170Warps a party to specified map and coordinate given the party ID, which
4171you can get with getcharid(1). You can also request another party id given
4172a member's name with getcharid(1,<player_name>).
4173
4174You can use the following "map names" for special warping behavior:
4175Random: All party members are randomly warped in their current map
4176 (as if they all used a fly wing).
4177SavePointAll: All party members are warped to their respective save point.
4178SavePoint: All party members are warped to the save point of the
4179 currently attached player (will fail if there's no player
4180 attached).
4181Leader: 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
4185If you specify a from_mapname, warpparty will only affect those on that
4186map.
4187
4188Example:
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
4201Warps another player to specified map and coordinate given the char id,
4202which you can get with getcharid(0,<player_name>). Obviously this is
4203useless if you want to warp the same player that is executing this script,
4204unless it's some kind of "chosen" script.
4205
4206Example:
4207
4208warpchar "prontera",150,100,150001;
4209
4210---------------------------------------
4211
4212*warpguild "<mapname>",<x>,<y>,<guild_id>;
4213
4214Warps a guild to specified map and coordinate given the guild id, which
4215you can get with getcharid(2). You can also request another guild id given
4216the member's name with getcharid(2,<player_name>).
4217
4218You can use the following "map names" for special warping behavior:
4219Random: All guild members are randomly warped in their current map
4220 (as if they all used a fly wing)
4221SavePointAll: All guild members are warped to their respective save point.
4222SavePoint: 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
4226Example:
4227
4228warpguild "prontera",x,y,Guild_ID;
4229
4230---------------------------------------
4231
4232*warppartner("<nome do mapa>",<x>,<y>);
4233
4234This function will find the invoking character's marriage partner, if any,
4235and warp them to the map and coordinates given. Go kidnap that spouse. :)
4236It will return 1 upon success and 0 if the partner is not online, the
4237character is not married, or if there's no invoking character (no RID).
42380,0 will, as usual, normally translate to random coordinates.
4239
4240---------------------------------------
4241
4242*savepoint "<nome do mapa>",<x>,<y>;
4243
4244This 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
4246are equivalent. nome do mapa, X coordinate and Y coordinate should be
4247perfectly obvious. This ignores any and all map flags, and can make a
4248character respawn where no teleportation is otherwise possible.
4249
4250 savepoint "place",350,75;
4251
4252---------------------------------------
4253
4254*heal <hp>,<sp>;
4255
4256This command will heal a set amount of HP and/or SP on the invoking
4257character.
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
4263This command just alters the hit points and spell points of the invoking
4264character and produces no other output whatsoever.
4265
4266---------------------------------------
4267
4268*itemheal <hp>,<sp>;
4269
4270This command heals given relative amounts of HP and/or SP on the invoking
4271character. Unlike heal, this command is intended for use in item scripts.
4272It applies potion-related bonuses, such as alchemist ranking, cards,
4273status changes.
4274It also applies a sp/vit-related bonus that is calculated by:
4275 heal = heal*[(100+STATUS*2)/100]
4276So 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
4282When used inside an NPC script, potion-related bonuses are omitted.
4283
4284There is also a nice example on using this with the 'rand' function, to
4285give 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
4295This command will heal the invoking character. It heals the character, but
4296not 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
4302So the amount that this will heal will depend on the total amount of HP or
4303SP you have maximum. Like 'heal', this will not call up any animations or
4304effects.
4305
4306---------------------------------------
4307
4308*recovery;
4309
4310This command will revive and restore full HP and SP to all characters
4311currently connected to the server.
4312
4313---------------------------------------
4314
4315*jobchange <job number>{,<upper flag>};
4316
4317This 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
4322This command does work with numbers, but you can also use job names. The
4323full 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
4332changes to. For example, jobchange Job_Swordman,1; will change the
4333character to a high swordsman. The upper values are:
4334-1 (or when omitted): preserves the current job type.
43350: Normal/standard classes
43361: High/Advanced classes
43372: Baby classes
4338
4339This command will also set a permanent character-based variable
4340'jobchange_level' which will contain the job level at the time right
4341before changing jobs, which can be checked for later in scripts.
4342
4343---------------------------------------
4344
4345*jobname (<job number>)
4346
4347This command retrieves the name of the given job using the messages.conf
4348entries 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
4358This commands returns the "eA job-number" corresponding to the given
4359class, and uses the invoking player's class if none is given. The eA
4360job-number is also a class number system, but it's one that comes with
4361constants which make it easy to convert among classes. The command will
4362return -1 if you pass it a job number which doesn't have an eA job-number
4363equivalent.
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
4373For more information on the eA Job System, see the docs/ea_job_system.txt
4374file.
4375
4376---------------------------------------
4377*roclass <job number> {,<gender>}
4378
4379Does the opposite of eaclass. That is, given an eA job-number, it returns
4380the corresponding RO class number. A gender is required because both Bard
4381and Dancers share the same eA job-number (EAJ_BARDDANCER), and uses the
4382invoking player's gender if none is given (if no player is attached,
4383male will be used by default). The command will return -1 if there is no
4384valid class to represent the specified job (for example, if you try to get
4385the 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
4404This command will change the appearance of the invoking character to that
4405of a specified job class. Nothing but appearance will change.
4406
4407Examples:
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
4425changebase Job_Novice; // Changes player to Novice sprite.
4426
4427changebase Class; // Changes player back to default sprite.
4428
4429---------------------------------------
4430
4431*classchange <view id>,<type>;
4432
4433This command is very ancient, it's origins are clouded in mystery.
4434It will send a 'display id change' packet to everyone in the immediate
4435area of the NPC object, which will supposedly make the NPC look like a
4436different sprite, an NPC sprite ID, or a monster ID. This effect is not
4437stored anywhere and will not persist (Which is odd, cause it would be
4438relatively easy to make it do so) and most importantly, will not work at
4439all since this command was broken with the introduction of advanced
4440classes. The code is written with the assumption that the lowest sprite
4441IDs are the job sprites and the anything beyond them is monster and NPC
4442sprites, but since the advanced classes rolled in, they got the ID numbers
4443on the other end of the number pool where monster sprites float.
4444
4445As a result it is currently impossible to call this command with a valid
4446view id. It will do nothing whatsoever if the view ID is below 4047.
4447Getting it to run will actually just crash the client.
4448
4449It could be a real gem if it can be gotten to actually do what it's
4450supposed to do, but this will only happen in a later Git revision.
4451
4452---------------------------------------
4453
4454*changesex;
4455
4456This command will change the gender for the attached character's account.
4457If it was male, it will become female, if it was female, it will become
4458male. The change will be written to the character server, the player will
4459receive the message: "Need disconnection to perform change-sex request..."
4460and the player will be immediately kicked to the login screen. When they
4461log back in, they will be the opposite sex.
4462
4463If there are any Dancer/Gypsy or Bard/Clown characters on the account,
4464they will also have their skills reset upon 'changesex'.
4465
4466---------------------------------------
4467
4468*getexp <base xp>,<job xp>;
4469
4470This command will give the invoking character a specified number of base
4471and job experience points. Should be used as a quest reward. Negative values
4472won't work.
4473Is subject to EXP bonuses and to the `quest_exp_rate` config option.
4474
4475 getexp 10000,5000;
4476
4477You can also assign directly to the parameters defined in 'db/const.txt':
4478
4479 BaseExp += 10000;
4480 JobExp += 5000;
4481
4482You can also reduce the amount of experience points:
4483
4484 BaseExp -= 10000;
4485
4486When 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
4494mainly for changing the palette used on hair and clothes: you specify
4495which look type you want to change, then the palette you want to use. Make
4496sure you specify a palette number that exists/is usable by the client you
4497use. 'changelook' works the same, but is only client side (it doesn't save
4498the 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
4511Here 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
4527Whatever 'shoes' means is anyone's guess, ask Gravity - the client does
4528nothing with this value. It still wants it from the server though, so it
4529is kept, but normally doesn't do a thing.
4530
4531Only the look data for hairstyle, hair color and clothes color are saved
4532to the char server's database and will persist. The rest freely change as
4533the character puts on and removes equipment, changes maps, logs in and out
4534and otherwise you should not expect to set them. In fact, messing with
4535them is generally hazardous, do it at your own risk, it is not tested
4536what will this actually do - it won't cause database corruption and
4537probably won't cause a server crash, but it's easy to crash the client
4538with just about anything unusual.
4539
4540However, it might be an easy way to quickly check for empty view IDs for
4541sprites, which is essential for making custom headgear.
4542
4543Since a lot of people have different palettes for hair and clothes, it's
4544impossible to tell you what all the color numbers are. If you want a
4545serious example, there is a Stylist script inside the default Cronus
4546installation that you can look at: 'npc/custom/stylist.txt'
4547
4548---------------------------------------
4549
4550*pushpc <direction>,<cells>;
4551
4552This command will push the currently attached player to given direction by
4553given amount of square cells. Direction is the same as used when declaring
4554NPCs, and can be specified by using one of the DIR_* constants
4555(db/const.txt).
4556
4557The knock-back is not restricted by items or map flags, only obstacles are
4558taken into account. If there is not enough space to perform the push (e.g.
4559due 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
4569This command will return the SVN revision number or Git SHA-1 hash the
4570server is currently running on (depends on whether you used a SVN or Git
4571client 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
4581This command can transform your character into monster and you can still
4582use all your skills like a normal character.
4583Can only be removed when your killed or if you die or if duration is over.
4584
4585for sc_type,val1,val2,val3,val4, see 'sc_start','sc_start2','sc_start4' commands.
4586
4587---------------------------------------
4588//=====================================
45894.1 - Player Item-Related Commands
4590//=====================================
4591---------------------------------------
4592
4593*getitem <item id>,<amount>{,<account ID>};
4594*getitem "<item name>",<amount>{,<account ID>};
4595
4596This command will give a specific amount of specified items to the target
4597character. If the character is not online, nothing will happen.
4598If <account ID> is not specified, items will be created in the invoking
4599character inventory instead.
4600
4601In the first and most commonly used version of this command, items are
4602referred 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
4607Giving an item ID of -1 will give a specified number of random items from
4608the list of those that fall out of Old Blue Box. Unlike in all other
4609cases, these will be unidentified, if they turn out to be equipment. This
4610is exactly what's written in the Old Blue Box's item script.
4611
4612Other negative IDs also correspond to other random item generating item
4613tables:
4614
4615Giving an item ID of -2 will produce the effects of Old Violet Box.
4616Giving an item ID of -3 will produce the effects of Old Card Album.
4617Giving an item ID of -4 will produce the effects of Gift Box.
4618Giving an item ID of -5 will produce the effects of Worn Out Scroll,
4619which, in current Git, drops only Jellopies anyway.
4620
4621This transaction is logged if the log script generated transactions option
4622is enabled.
4623
4624You may also create an item by it's name in the 'english name' field in
4625the item database:
4626
4627 getitem "RED_POTION",10;
4628
4629Which will do what you'd expect. If it can't find that name in the
4630database, apples will be created anyway. It is often a VERY GOOD IDEA to
4631use it like this.
4632
4633This is used in pretty much all NPC scripts that have to do with items and
4634quite a few item scripts. For more examples check just about any official
4635script.
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
4642This command will give an amount of specified items to the invoking
4643character. If an optional account ID is specified, and the target
4644character is currently online, items will be created in their inventory
4645instead. If they are not online, nothing will happen. It works essentially
4646the same as 'getitem' (it even works for negative ID numbers the same way)
4647but is a lot more flexible.
4648
4649Those parameters that are different from 'getitem' are:
4650
4651identify - Whether you want the item to be identified (1) or not (0).
4652refine - For how many pluses will it be refined. It will not let you
4653 refine an item higher than the max refine.
4654attribute - Whether the item is broken (1) or not (0).
4655card1,2,3,4 - If you want a card compound to it, place the card ID number
4656 into the specific card slot.
4657
4658Card1-card4 values are also used to store name information for named
4659items, as well as the elemental property of weapons and armor. You can
4660create a named item in this manner, however, if you just need a named
4661piece of standard equipment, it is much easier to the 'getnameditem'
4662function instead.
4663
4664You will need to keep these values if you want to destroy and then
4665perfectly recreate a named item, for this see 'getinventorylist'.
4666
4667If 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
4669like 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
4698This wasn't tested with all possible items, so I can't give any promises,
4699experiment first before relying on it.
4700
4701To 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
4724Experiment with the number of star crumbs - I'm not certain just how much
4725will work most and what it depends on. The valid element numbers are:
4726
4727 1 - Ice, 2 - Earth 3 - Fire 4 - Wind.
4728
4729You can, apparently, even create duplicates of the same pet egg with this
4730command, creating a pet which is the same, but simultaneously exists in
4731two eggs, and may hatch from either, although, I'm not sure what kind of a
4732mess 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
4738This command behaves identically to 'getitem', but the items created will be
4739bound to the target character as specified by the bound type. All items created
4740in this manner cannot be dropped, sold, vended, auctioned, or mailed, and in
4741some cases cannot be traded or stored.
4742
4743Valid 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
4754This command behaves identically to 'getitem2', but the items created will be
4755bound to the target character as specified by the bound type. All items created
4756in this manner cannot be dropped, sold, vended, auctioned, or mailed, and in
4757some cases cannot be traded or stored.
4758
4759For a list of bound types see 'getitembound'.
4760
4761---------------------------------------
4762
4763*countbound({<bound type>})
4764
4765This function will return the number of bounded items in the character's
4766inventory, and sets an array @bound_items[] containing all item IDs of the
4767counted items. If a bound type is specified, only those items will be counted.
4768
4769For a list of bound types see 'getitembound'.
4770
4771Example:
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
4783This command allows you to check whether or not the attached player has the specified bound item in their inventory.
4784If 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
4785of any type, so long as the other parameters match. In all cases, this command will return the bound type of the
4786item found, or 0 if the specified item was not found.
4787
4788Valid 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
4795Optional 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
4801Example:
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
4846Create an item signed with the given character's name.
4847
4848The command returns 1 when the item is created successfully, or 0 if it
4849fails. 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
4854Example:
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
4870Creates a rental item in the attached character's inventory. The item will
4871expire in <time> seconds and be automatically deleted. When receiving a
4872rental item, the character will receive a message in their chat window.
4873The character will also receive warning messages in their chat window
4874before the item disappears.
4875
4876This command can not be used to rent stackable items. Rental items cannot
4877be dropped, traded, sold to NPCs, or placed in guild storage (i.e. trade
4878mask 75).
4879Note: '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
4886This command will create an item lying around on a specified map in the
4887specified 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
4895This item will still disappear just like any other dropped item. Like
4896'getitem', it also accepts an 'english name' field from the database and
4897creates apples if the name isn't found.
4898If the nome do mapa is given as "this", the map the invoking character is on
4899will be used.
4900
4901---------------------------------------
4902
4903*cleanarea "<nome do mapa>",<x1>,<y1>,<x2>,<y2>;
4904*cleanmap "<nome do mapa>";
4905
4906These commands will clear all items lying on the ground on the specified
4907map, either within the x1/y1-x2/y2 rectangle or across the entire map.
4908
4909---------------------------------------
4910
4911*searchitem <array name>,"<item name>";
4912
4913This command will fill the given array with the ID of items whose name
4914matches the given one. It returns the number of items found. For
4915performance 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
4930This command will remove a specified amount of items from the invoking or
4931target character. Like all the item commands, it uses the item ID found
4932inside '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
4937It is always a good idea to check if the player actually has the items
4938before you delete them. If you try to delete more items that the player
4939has, the player will lose the ones he/she has and the script will be
4940terminated with an error.
4941
4942Like 'getitem' this command will also accept an 'english name' field from
4943the 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
4950This command will remove a specified amount of items from the invoking or
4951target character.
4952Check 'getitem2' to understand its expanded parameters.
4953
4954---------------------------------------
4955
4956*countitem(<item id>)
4957*countitem("<item name>")
4958
4959This function will return the number of items for the specified item ID
4960that 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
4966Like 'getitem', this function will also accept an 'english name' from the
4967database as an argument.
4968
4969If you want to state the number at the end of a sentence, you can do it by
4970adding 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
4981Expanded version of 'countitem' function, used for created/carded/forged
4982items.
4983
4984This function will return the number of items for the specified item ID
4985and other parameters that the invoking character has in the inventory.
4986Check 'getitem2' to understand the arguments of the function.
4987
4988---------------------------------------
4989
4990*groupranditem <item_id/constant>;
4991
4992Returns the item_id of a random item picked from the item container specified. There
4993are different item containers and they are specified in 'db/(pre-)re/item_group.conf'.
4994
4995Example:
4996 getitem groupranditem 603,1;
4997 getitem groupranditem Old_Blue_Box,1;
4998
4999---------------------------------------
5000
5001*getrandgroupitem <item_id/constant>,<quantity>;
5002
5003Similar to the above example, this command allows players to obtain the specified
5004quantity of a random item from the container. The different containers
5005are specified in 'db/(pre-)re/item_group.conf'.
5006
5007Example:
5008 getrandgroupitem Old_Blue_Box,1;
5009 getrandgroupitem 603,1;
5010
5011---------------------------------------
5012
5013*packageitem
5014
5015This command has only 1 param which is optional. If the package item_id is not provided, it
5016will try to use the item id from the item it is being used from (if called from an item script).
5017It runs a item package and grants the items accordingly to the attached player.
5018
5019Example:
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
5036These commands enable/disable changing of equipments while an NPC is
5037running. When disable_items is run, equipments cannot be changed during
5038scripts until enable_items is called or the script has terminated. To
5039avoid possible exploits, when disable_items is invoked, it will only
5040disable changing equips while running that script in particular. Note that
5041if a different script also calls disable_items, it will override the last
5042call (so you may want to call this command at the start of your script
5043without assuming the effect is still in effect).
5044If 'item_enabled_npc' option is set to Yes in 'items.conf' all NPC are
5045allowing changing of equipment by default except for those have been set
5046with 'disable_items'.
5047
5048---------------------------------------
5049
5050*itemskill <skill id>,<skill level>,{flag};
5051*itemskill "<skill name>",<skill level>,{flag};
5052
5053This command meant for item scripts to replicate single-use skills in
5054usable items. It will not work properly if there is a visible dialog
5055window or menu.
5056If the skill is self or auto-targeting, it will be used immediately.
5057Otherwise, a target cursor is shown.
5058Flag is a optional param and, when present, the command will not check for
5059skill 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.
5063605,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
5071This command will run the item script of the specified item on the
5072invoking character. The character does not need to posess the item, and
5073the item will not be deleted. While this command is intended for usable
5074items, it will run for any item type.
5075
5076---------------------------------------
5077
5078*produce <item level>;
5079
5080This command will open a crafting window on the client connected to the
5081invoking character. The 'item level' is a number which determines what
5082kind of a crafting window will pop-up.
5083
5084You can see the full list of such item levels in 'db/produce_db.txt' which
5085determines what can actually be produced. The window will not be empty
5086only if the invoking character can actually produce the items of that type
5087and has the appropriate raw materials in their inventory.
5088
5089The success rate to produce the item is the same as the success rate of
5090the skill associated with the item level. If there is no skill id, the
5091success rate will be 50%.
5092
5093Valid 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
5106This command will open a produce window on the client connected to the
5107invoking character. The 'dish level' is the number which determines what
5108kind of dish level you can produce. You can see the full list of dishes
5109that can be produced in 'db/produce_db.txt'.
5110
5111The window will be shown empty if the invoking character does not have
5112enough of the required incredients to cook a dish.
5113
5114Valid dish levels are:
5115
511611 - Level 1 Dish
511712 - Level 2 Dish
511813 - Level 3 Dish
511914 - Level 4 Dish
512015 - Level 5 Dish
512116 - Level 6 Dish
512217 - Level 7 Dish
512318 - Level 8 Dish
512419 - Level 9 Dish
512520 - Level 10 Dish
5126
5127Although it's required to set a dish level, it doesn't matter if you set
5128it to 1 and you want to cook a level 10 dish, as long as you got the
5129required ingredients to cook the dish the command works.
5130
5131---------------------------------------
5132
5133*makerune <% success bonus>;
5134
5135This command will open a rune crafting window on the client connected to
5136the invoking character. Since this command is officially used in rune
5137ores, a bonus success rate must be specified (which adds to the base
5138formula).
5139
5140You 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
5142character can actually produce a rune and has the appropriate raw
5143materials in their inventory.
5144
5145---------------------------------------
5146
5147*successremovecards <equipment slot>;
5148
5149This command will remove all cards from the item found in the specified
5150equipment slot of the invoking character, create new card items and give
5151them to the character. If any cards were removed in this manner, it will
5152also show a success effect.
5153
5154---------------------------------------
5155
5156*failedremovecards <equipment slot>,<type>;
5157
5158This command will remove all cards from the item found in the specified
5159equipment slot of the invoking character. 'type' determines what happens
5160to 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
5166Whatever the type is, it will also show a failure effect on screen.
5167
5168---------------------------------------
5169
5170*repair <broken item number>;
5171
5172This command repairs a broken piece of equipment, using the same list of
5173broken items as available through 'getbrokenid'.
5174
5175The official scripts seem to use the repair command as a function instead:
5176'repair(<number>)' but it returns nothing on the stack. Probably only
5177Valaris, who made it, can answer why is it so.
5178
5179---------------------------------------
5180
5181*repairall;
5182
5183This command repairs all broken equipment in the attached player's
5184inventory. A repair effect will be shown if any items are repaired, else
5185the command will end silently.
5186
5187---------------------------------------
5188
5189*successrefitem <equipment slot>{,<upgrade_count>};
5190
5191This command will refine an item in the specified equipment slot of the
5192invoking character by +1 (unless <upgrade_count> is specified).
5193For a list of equipment slots see 'getequipid'.
5194This command will also display a 'refine success'
5195effect on the character and put appropriate messages into their chat
5196window. 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
5198will later forge a weapon.
5199
5200---------------------------------------
5201
5202*failedrefitem <equipment slot>;
5203
5204This command will fail to refine an item in the specified equipment slot
5205of the invoking character. The item will be destroyed. This will also
5206display a 'refine failure' effect on the character and put appropriate
5207messages into their chat window.
5208
5209---------------------------------------
5210
5211*downrefitem <equipment slot>{,<downgrade_count>};
5212
5213This command will downgrade an item by - 1 (unless optional <downgrade_count> is provided)
5214in the specified equipment slot of the invoking character.
5215So the item will not be destroyed unlike in the
5216failedrefitem script command. This will also display a 'refine failure'
5217effect on the character and put appropriate messages into their chat
5218window.
5219
5220---------------------------------------
5221
5222*unequip <equipment slot>;
5223
5224This command will unequip whatever is currently equipped in the invoking
5225character's specified equipment slot. For a full list of possible
5226equipment slots see 'getequipid'.
5227
5228If an item occupies several equipment slots, it will get unequipped from
5229all of them.
5230
5231---------------------------------------
5232
5233*clearitem;
5234
5235This command will destroy all items the invoking character has in their
5236inventory (including equipped items). It will not affect anything else,
5237like 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
5245These commands are to equip a equipment on the attached character.
5246The equip function will equip the item ID given when the player has this
5247item in his/her inventory, while the autoequip function will equip the
5248given item ID when this is looted. The option parameter of the autoequip
5249is 1 or 0, 1 to turn it on, and 0 to turn it off.
5250
5251Examples:
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
5272Invokes buying store preparation window like the skill 'Open Buying
5273Store', without the item requirement. Amount of slots is limited by the
5274server to a maximum of 5 slots by default.
5275
5276Example:
5277
5278 // Gives the player opportunity to buy 4 different kinds of items.
5279 buyingstore 4;
5280
5281---------------------------------------
5282
5283*searchstores <uses>,<effect>;
5284
5285Invokes the store search window, which allows to search for both vending
5286and buying stores. Parameter uses indicates, how many searches can be
5287started, before the window has to be reopened. Effect value affects what
5288happens when a result item is double-clicked and can be one of the
5289following:
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
5296Example:
5297
5298 // Item Universal_Catalog_Gold (10 uses, effect: open shop)
5299 searchstores 10,1;
5300
5301---------------------------------------
5302
5303*delequip <equipment slot>;
5304
5305This command will destroy whatever is currently equipped in the invoking
5306character's specified equipment slot. For a full list of possible equipment
5307slots see 'getequipid'.
5308
5309It is always a good idea to check if the player actually has the item you want
5310before you use this command. If you try to delete in a position that the player
5311has no gear, script will be terminated with an error.
5312
5313---------------------------------------
5314//=====================================
53154.1 - End of Player Item-Related Commands
5316//=====================================
5317---------------------------------------
5318
5319*openstorage;
5320
5321This will open character's Kafra storage window on the client connected to
5322the invoking character. It can be used from any kind of NPC or item
5323script, not just limited to Kafra Staff.
5324
5325The storage window opens regardless of whether there are open NPC dialogs
5326or not, but it is preferred to close the dialog before displaying the
5327storage 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
5338This will open a character's Mail window on the client connected to the
5339invoking character.
5340
5341 mes "Close this window to open your mail inbox.";
5342 close2;
5343 openmail;
5344 end;
5345
5346---------------------------------------
5347
5348*openauction;
5349
5350This will open the Auction window on the client connected to the invoking
5351character.
5352
5353 mes "Close this window to open the Auction window.";
5354 close2;
5355 openauction;
5356 end;
5357
5358---------------------------------------
5359//=====================================
53604.2 - Guild-Related Commands
5361//=====================================
5362---------------------------------------
5363
5364*guildopenstorage()
5365
5366This function works the same as 'openstorage' but will open a guild
5367storage window instead for the guild storage of the guild the invoking
5368character belongs to. This is a function because it returns a value - 0 if
5369the guild storage was opened successfully and 1 if it wasn't. (Notice,
5370it's a ZERO upon success.)
5371Since guild storage is only accessible to one character at one time, it
5372may fail if another character is accessing the guild storage at the same
5373time.
5374
5375This will also fail and return 2 if the attached character does not belong
5376to any guild.
5377
5378---------------------------------------
5379
5380*guildchangegm(<guild id>,<new master's name>)
5381
5382This function will change the Guild Master of a guild. The ID is the
5383guild's id, and the new guild master's name must be passed.
5384
5385Returns 1 on success, 0 otherwise.
5386
5387---------------------------------------
5388
5389*guildgetexp <amount>;
5390
5391This will give the specified amount of guild experience points to the
5392guild the invoking character belongs to. It will silently fail if they do
5393not belong to any guild.
5394
5395---------------------------------------
5396
5397*guildskill <skill id>,<level>
5398*guildskill "<skill name>",<level>
5399
5400This command will bump up the specified guild skill by the specified
5401number of levels. This refers to the invoking character and will only work
5402if the invoking character is a member of a guild AND it's guild master,
5403otherwise no failure message will be given and no error will occur, but
5404nothing 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.
5406If a level higher than the maximum is given as parameter the skill will be
5407leveled 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
5415You might want to make a quest for getting a certain guild skill, make it
5416hard enough that all the guild needs to help or something. Doing this for
5417the Glory of the Guild skill, which allows your guild to use an emblem, is
5418a good idea for a fun quest. (Wasting a level point on that is really
5419annoying :D)
5420
5421---------------------------------------
5422//=====================================
54234.2 - End of Guild-Related Commands
5424//=====================================
5425---------------------------------------
5426
5427*resetlvl <action type>;
5428
5429This is a character reset command, meant mostly for rebirth script
5430supporting Advanced jobs, which will reset the invoking character's stats
5431and 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
5442In all cases everything the character has on will be unequipped.
5443
5444Even though it doesn't return a value, it is used as a function in the
5445official rebirth scripts.
5446
5447---------------------------------------
5448
5449*resetstatus;
5450
5451This is a character reset command, which will reset the stats on the
5452invoking character and give back all the stat points used to raise them
5453previously. Nothing will happen to any other numbers about the character.
5454
5455Used in reset NPC's (duh!).
5456
5457---------------------------------------
5458
5459*resetskill;
5460
5461This command takes off all the skill points on the invoking character, so
5462they only have Basic Skill blanked out (lvl 0) left, and returns the
5463points for them to spend again. Nothing else will change but the skills.
5464Quest skills will also reset if 'quest_skill_reset' option is set to Yes
5465in 'battle.conf'. If the 'quest_skill_learn' option is set in there, the
5466points in the quest skills will also count towards the total.
5467
5468Used 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
5477These commands will bestow a status effect on a character.
5478
5479The <effect type> determines which status is invoked. This can be either a number
5480or constant, with the common statuses (mostly negative) found in 'db/const.txt'
5481with the 'SC_' prefix. A full list is located in 'src/map/status.h', though
5482they are not currently documented.
5483
5484The duration of the status is given in <ticks>, or milleseconds.
5485
5486Certain status changes take an additional parameter <value 1>, which typically
5487modifies player stats by the given number or percentage. This differs for each
5488status, and is sometimes zero.
5489
5490Optional value <rate> is the chance that the status will be invoked (10000 = 1%).
5491This is used primarily in item scripts. When used in an NPC script, a flag MUST
5492be defined for the rate to work.
5493
5494Optional 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
5502If a <GID> is given, the status change will be invoked on the specified character
5503instead of the one attached to the script. This can only be defined after setting
5504a rate and flag.
5505
5506'sc_start2' and 'sc_start4' allow extra parameters to be passed, and are used only
5507for effects that require them. The meaning of the extra values vary depending on the
5508effect type.
5509
5510'sc_end' will remove a specified status effect. If SC_ALL (-1) is given, it will
5511perform a complete removal of all statuses (although permanent ones will re-apply).
5512
5513Examples:
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
5528Note: 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
5537Retrieve information about a specific status effect when called. Depending
5538on <type> specified the function will return different information.
5539
5540Possible <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
5548If <type> is not defined or is set to 0, then the script function will
5549either return 1 if the status is active, or 0 if the status is not active.
5550If the status is not active when any of the <type> fields are provided,
5551this script function will always return 0.
5552
5553---------------------------------------
5554
5555*skilleffect <skill id>,<number>;
5556*skilleffect "<skill name>",<number>;
5557
5558This command displays visual and aural effects of given skill on currently
5559attached character. The number parameter is for skill whose visual effect
5560involves displaying of a number (healing or damaging). Note that this
5561command will not actually use the skill: it is intended for scripts which
5562simulate skill usage by the NPC, such as buffs, by setting appropriate
5563status 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
5576This will heal the character with 2000 HP, buff it with Blessing Lv 10 and
5577Increase 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
5584This command behaves identically to 'skilleffect', however, the effect
5585will not be centered on the invoking character's sprite, nor on the NPC
5586sprite, if any, but will be centered at map coordinates given on the same
5587map as the invoking character.
5588
5589---------------------------------------
5590
5591*specialeffect <effect number>{,<send_target>{,"<NPC Name>"}};
5592
5593This command will display special effect with the given number, centered
5594on the specified NPCs coordinates, if any. For a full list of special
5595effect numbers known see 'doc/effect_list.txt'. Some effect numbers are
5596known not to work in some client releases. (Notably, rain is absent from
5597any client executables released after April 2005.)
5598
5599<NPC name> parameter will display <effect number> on another NPC. If the
5600NPC specified does not exist, the command will do nothing. When specifying
5601an NPC, <send_target> must be specified when specifying an <NPC Name>,
5602specifying 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
5616This command behaves identically to the 'specialeffect', but the effect
5617will be centered on the invoking character's sprite.
5618
5619<Player name> parameter will display <effect number> on another Player
5620than the one currently attached to the script. Like with specialeffect,
5621when specifying a player, <send_target> must be supplied, specifying AREA
5622will retain the default behavior of the command.
5623
5624---------------------------------------
5625
5626*statusup <stat>;
5627
5628This command will bump a specified stat of the invoking character up by
5629one permanently using status points to do so, if there aren't enough to perform
5630the change nothing will happen.
5631Stats are to be given as number, but you can use these constants to replace them:
5632
5633bStr - Strength
5634bVit - Vitality
5635bInt - Intelligence
5636bAgi - Agility
5637bDex - Dexterity
5638bLuk - Luck
5639
5640---------------------------------------
5641
5642*statusup2 <stat>,<amount>;
5643
5644This command will bump a specified stat of the invoking character up by
5645the specified amount permanently without using status points.
5646Amount 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
5659These commands are meant to be used in item scripts. They will probably
5660work outside item scripts, but the bonus will not persist for long. They,
5661as expected, refer only to an invoking character.
5662
5663You can find the full list of possible bonuses and which command to use
5664for 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
5673These commands are meant to be used in item scripts. They will probably
5674work outside item scripts, but the bonus will not persist for long. They,
5675as expected, refer only to an invoking character.
5676
5677What these commands do is 'attach' a script to the player which will get
5678executed on attack (or when attacked in the case of autobonus2).
5679
5680Rate is the trigger rate of the script (10000 = 100%).
5681
5682Duration is the time that the bonus will last for since the script has
5683triggered.
5684
5685Skill ID/skill name the skill which will be used as trigger to start the
5686bonus (for autobonus3).
5687
5688The optional argument 'flag' is used to classify the type of attack where
5689the script can trigger (it shares the same flags as the bAutoSpell bonus
5690script):
5691
5692Range criteria:
5693 BF_SHORT: Trigger on melee attack
5694 BF_LONG: Trigger on ranged attack
5695 Default: BF_SHORT+BF_LONG
5696Attack 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
5701Skill 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
5707The difference between the optional argument 'other script' and the 'bonus
5708script' is that, the former one triggers only when attacking (or attacked)
5709and the latter one runs on status calculation as well, which makes sure,
5710within the duration, the "bonus" that get lost on status calculation is
5711restored. So, 'bonus script' is technically supposed to accept "bonus"
5712command only. And we usually use 'other script' to show visual effects.
5713
5714In all cases, when the script triggers, the attached player will be the
5715one who holds the bonus. There is currently no way of knowing within this
5716script who was the other character (the attacker in autobonus2, or the
5717target 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
5731These commands will give the invoking character a specified skill. This is
5732also used for item scripts.
5733
5734Level is obvious. Skill id is the ID number of the skill in question as
5735per 'db/(pre-)re/skill_db.txt'. It is not known for certain whether this
5736can be used to give a character a monster's skill, but you're welcome to
5737try with the numbers given in 'db/(pre-)re/mob_skill_db.txt'.
5738
5739Flag is 0 if the skill is given permanently (will get written with the
5740character data) or 1 if it is temporary (will be lost eventually, this is
5741meant for card item scripts usage.). The flag parameter is optional, and
5742defaults to 1 in 'skill' and to 2 in 'addtoskill'.
5743
5744Flag 2 means that the level parameter is to be interpreted as a stackable
5745additional bonus to the skill level. If the character did not have that
5746skill 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
5752Flag 3 is the same as flag 0 in that it saves to the database. However,
5753these skills are ignored when any action is taken that adjusts the skill
5754tree (reset/job change).
5755
5756---------------------------------------
5757
5758*nude;
5759
5760This command will unequip anything equipped on the invoking character.
5761
5762It is not required to do this when changing jobs since 'jobchange' will
5763unequip everything not equippable by the new job class anyway.
5764
5765---------------------------------------
5766
5767*disguise <Monster ID>;
5768*undisguise;
5769
5770This command disguises the current player with a monster sprite.
5771The disguise lasts until 'undisguise' is issued or the player logs out.
5772
5773Example:
5774
5775disguise 1002; // Disguise character as a Poring.
5776next;
5777undisguise; // Return to normal character sprite.
5778
5779---------------------------------------
5780//=====================================
57814.3 - Marriage-Related Commands
5782//=====================================
5783---------------------------------------
5784
5785*marriage("<spouse name>");
5786
5787This function will marry two characters, the invoking character and the
5788one referred to by name given, together, setting them up as each other's
5789marriage partner. No second function call has to be issued (in current Git
5790at least) to make sure the marriage works both ways. The function returns
57911 upon success, or 0 if the marriage could not be completed, either
5792because the other character wasn't found or because one of the two
5793characters is already married.
5794
5795This will do nothing else for the marriage except setting up the spouse ID
5796for both of these characters. No rings will be given and no effects will
5797be shown.
5798
5799---------------------------------------
5800
5801*wedding;
5802
5803This command will call up wedding effects - the music and confetti -
5804centered on the invoking character. Example can be found in the wedding
5805script.
5806
5807---------------------------------------
5808
5809*divorce()
5810
5811This function will "un-marry" the invoking character from whoever they
5812were 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
5814problems). It will return 1 upon success or 0 if the character was not
5815married at all.
5816
5817This function will also destroy both wedding rings and send a message to
5818both players, telling them they are now divorced.
5819
5820---------------------------------------
5821//=====================================
58224.3 - End of Marriage-Related Commands
5823//=====================================
5824---------------------------------------
5825
5826*pcfollow <id>,<target id>;
5827*pcstopfollow <id>;
5828
5829Makes a character follow or stop following someone. This command does the
5830same as the @follow command. The main difference is that @follow can use
5831character names, and this commands needs the Account ID for the target.
5832
5833Examples:
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
5846Prevents the given ID from moving when the option != 0, and 0 enables the
5847ID to move again. The ID can either be the GID of a monster/NPC or account
5848ID of a character, and will run for the attached player if zero is
5849supplied.
5850
5851Examples:
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//=====================================
58624 - End of Player-Related Commands
5863//=====================================
5864---------------------------------------
5865
5866---------------------------------------
5867//=====================================
58685 - 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
5875This command will spawn a monster on the specified coordinates on the
5876specified map. If the script is invoked by a character, a special map
5877name, "this", will be recognized to mean the name of the map the invoking
5878character is located at. This command works fine in the item scripts.
5879
5880The same command arguments mean the same things as described above in the
5881beginning of this document when talking about permanent monster spawns.
5882Monsters spawned in this manner will not respawn upon being killed.
5883
5884Unlike the permanent monster spawns, if the mob id is -1, a random monster
5885will be picked from the entire database according to the rules configured
5886in the server for dead branches. This will work for all other kinds of
5887non-permanent monster spawns.
5888
5889The only very special thing about this command is an event label, which is
5890an optional parameter. This label is written like
5891'<NPC object name>::<label name>' and upon the monster being killed, it
5892will execute the script inside of the specified NPC object starting from
5893the label given. The RID of the player attached at this execution will be
5894the 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
5910The coordinates of 0,0 will spawn the monster on a random place on the
5911map. Both 'monster' and 'areamonster' return the GID of the monster
5912spawned if there was ONLY ONE monster to be spawned. This is useful for
5913controlling each of the spawned mobs with the unit* commands shown below.
5914For 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
5920The way you can get the GID of more than only one monster is looping
5921through all the summons to get their individual GIDs and do whatever you
5922want 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
5930Refer to the unit* commands below.
5931
5932The 'areamonster' command works much like the 'monster' command and is not
5933significantly different, but spawns the monsters within a square defined
5934by x1/y1-x2/y2.
5935
5936Simple 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
5961For 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
5968This command will make all monsters of the specified mob ID in the
5969specified area use the specified skill. nome do mapa, x, and y define the
5970center of the area, which extending <range> cells in each direction (ex: a
5971range of 3 would create a 7x7 square). The skill can be specified by skill
5972ID or name. <cast time> is in milliseconds (1000 = 1 second), and the rest
5973should 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
5981Example:
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
5992This command will kill all monsters that were spawned with 'monster' or
5993'addmonster' and have a specified event label attached to them. Commonly
5994used to get rid of remaining quest monsters once the quest is complete.
5995
5996If the label is given as "All", all monsters which have their respawn
5997times set to -1 (like all the monsters summoned with 'monster' or
5998'areamonster' script command, and all monsters summoned with GM commands,
5999but no other ones - that is, all non-permanent monsters) on the specified
6000map will be killed regardless of the event label value.
6001
6002killmonster supports an optional argument type. Using 1 for type will make
6003the command fire "OnMyMobDead" events from any monsters that do die as a
6004result of this command.
6005
6006---------------------------------------
6007
6008*killmonsterall "<nome do mapa>"{,<type>};
6009
6010This command will kill all monsters on a specified nome do mapa, regardless of
6011how they were spawned or what they are without triggering any event label
6012attached to them, unless you specify 1 for type parameter. In this case,
6013mob death labels will be allowed totrigger when there is no player. Any
6014other number for this parameter won't be recognized.
6015
6016---------------------------------------
6017
6018*strmobinfo(<type>,<monster id>);
6019
6020This function will return information about a monster record in the
6021database, as per 'db/(pre-)re/mob_db.txt'. Type is the kind of information
6022returned. 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
6037This function will count all the monsters on the specified map that have a
6038given event label and return the number or 0 if it can't find any.
6039Naturally, only monsters spawned with 'monster' and 'areamonster' script
6040commands can have non-empty event label.
6041If you pass this function an empty string for the event label, it will
6042return the total count of monster without event label, including
6043permanently spawning monsters.
6044
6045With the dynamic mobs system enabled, where mobs are not kept in memory
6046for maps with no actual people playing on them, this will return a 0 for
6047any such map.
6048
6049If the event label is given as "all", all monsters will be counted,
6050regardless of having any event label attached.
6051
6052If the nome do mapa is given as "this", the map the invoking character is on
6053will be used. If the map is not found, or the invoker is not a character
6054while 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
6060This command creates a monster which is a copy of another player. The
6061first four arguments serve the same purpose as in the monster script
6062command, The <char id> is the character id of the player to clone (player
6063must be online).
6064If <master id> is given, the clone will be a 'slave/minion' of it.
6065Master_id must be a character id of another online player.
6066
6067The mode can be specified to determine the behavior of the clone, its
6068values are the same as the ones used for the mode field in the mob_db. The
6069default mode is aggressive, assists, can move, can attack.
6070
6071Flag can be either zero or one currently. If zero, the clone is a normal
6072monster that'll target players, if one, it is considered a summoned
6073monster, and as such, it'll target other monsters. Defaults to zero.
6074
6075The duration specifies how long the clone will live before it is
6076auto-removed. Specified in seconds, defaults to no limit (zero).
6077
6078Returned value is the monster ID of the spawned clone. If command fails,
6079returned value is zero.
6080
6081---------------------------------------
6082
6083*summon "Monster name",<monster id>{,<Time Out>{,"event label"}};
6084
6085This command will summon a monster. (see also 'monster') Unlike monsters
6086spawned with other commands, this one will set up the monster to fight to
6087protect the invoking character. Monster name and mob id obey the same
6088rules as the one given at the beginning of this document for permanent
6089monster spawns with the exceptions mentioned when describing 'monster'
6090command.
6091
6092The effect for the skill 'Call Homunculus' will be displayed centered on
6093the invoking character.
6094
6095Timeout is the time in milliseconds the summon lives, and is set default
6096to 60000 (1 minute). Note that also the value 0 will set the timer to
6097default, and it is not possible to create a spawn that lasts forever.
6098If an event label is given, upon the monster being killed, the event label
6099will run as if by 'donpcevent'.
6100
6101// Will summon a dead branch-style monster to fight for the character.
6102summon "--ja--",-1;
6103
6104---------------------------------------
6105
6106*homevolution;
6107
6108This command will try to evolve the current player's homunculus.
6109If it doesn't work, the /swt emotion is shown.
6110
6111To evolve a homunculus, the invoking player must have a homunculus, the
6112homunculus must not be the last evolution and the homunculus must have
6113above 91000 intimacy with its owner.
6114
6115---------------------------------------
6116
6117*gethominfo(<type>)
6118
6119This 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
6132This command will try to put the invoking player's Homunculus in an
6133uncallable state, required for mutation into a Homunculus S. The player
6134will also receive a Strange Embryo (ID 6415) in their inventory if
6135successful, which is deleted upon mutation.
6136
6137The command will fail if the invoking player does not have an evolved
6138Homunculus at level 99 or above. The /swt emotion is shown upon failure.
6139
6140Returns 1 upon success and 0 for all failures.
6141
6142---------------------------------------
6143
6144*hommutate {<ID>};
6145
6146This command will try to mutate the invoking player's Homunculus into
6147a Homunculus S. The Strange Embryo (ID 6415) is deleted upon success.
6148
6149The command will fail if the invoking player does not have an evolved
6150Homunculus 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
6152possess a Strange Embryo. The /swt emotion is shown upon failure.
6153
6154If the optional parameter <ID> is set, the invoking player's Homunculus
6155will change into the specified Homunculus ID. Otherwise, a random Homunculus S
6156will be chosen. See 'db/homunculus_db.txt' for a full list of IDs.
6157
6158Returns 1 upon success and 0 for all failures.
6159
6160---------------------------------------
6161
6162*checkhomcall()
6163
6164This function checks if the attached player's Homunculus is active,
6165and 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
6176This is one command, but can be used in two ways. If only the first
6177argument is given, the unit whose GID is given will start walking towards
6178the target whose GID is given.
6179
6180When 2 arguments are passed, the given unit will walk to the given x,y
6181coordinates on the map where the unit currently is.
6182
6183Examples:
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
6200Okay, these commands should be fairly self explaining.
6201For the emotions, you can look in db/const.txt for prefixes with e_
6202PS: unitwarp supports a <GID> of zero, which causes the executor of the
6203script to be affected. This can be used with OnTouchNPC to warp monsters:
6204
6205OnTouchNPC:
6206 unitwarp 0,"this",-1,-1;
6207
6208---------------------------------------
6209
6210*disablenpc "<NPC object name>";
6211*enablenpc "<NPC object name>";
6212
6213These two commands will disable and enable, respectively, an NPC object
6214specified by name. The disabled NPC will disappear from sight and will no
6215longer be triggerable in the normal way. It is not clear whether it will
6216still be accessible through 'donpcevent' and other triggering commands,
6217but it probably will be. You can disable even warp NPCs if you know their
6218object names, which is an easy way to make a map only accessible through
6219walking half the time. Then you 'enablenpc' them back.
6220
6221You can also use these commands to create the illusion of an NPC switching
6222between several locations, which is often better than actually moving the
6223NPC - create one NPC object with a visible and a hidden part to their
6224name, make a few copies, and then disable all except one.
6225
6226---------------------------------------
6227
6228*hideonnpc "<NPC object name>";
6229*hideoffnpc "<NPC object name>";
6230
6231These commands will make the NPC object specified display as hidden or
6232visible, even though not actually disabled per se. Hidden as in thief Hide
6233skill, but unfortunately, not detectable by Ruwach or Sight.
6234
6235As they are now, these commands are pointless, it is suggested to use
6236'disablenpc'/'enablenpc', because these two commands actually unload the
6237NPC sprite location and other accompanying data from memory when it is not
6238used. However, you can use these for some quest ideas (such as cloaking
6239NPCs talking while hidden then revealing... you can wonder around =P).
6240
6241---------------------------------------
6242
6243*doevent "<NPC object name>::<event label>";
6244
6245This command will start a new execution thread in a specified NPC object
6246at the specified label. The execution of the script running this command
6247will not stop, and the event called by the 'doevent' command will not run
6248until the invoking script has terminated. No parameters may be passed with
6249a doevent call.
6250
6251The script of the NPC object invoked in this manner will run as if it's
6252been 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
6271This command invokes the event label code within an another NPC or NPCs.
6272It starts a separate instance of execution, and the invoking NPC will
6273resume execution its immediately.
6274
6275If the supplied event label has the form "NpcName::OnLabel", then only
6276given NPC's event label will be invoked (much like 'goto' into another
6277NPC). If the form is "::OnLabel" (NPC name omitted), the event code of all
6278NPCs with given label will be invoked, one after another. In both cases
6279the invoked script will run without an attached RID, whether or not the
6280invoking script was attached to a player. The event label name is required
6281to start with "On".
6282
6283This command can be used to make other NPCs act, as if they were
6284responding to the invoking NPC's actions, such as using an emotion or
6285talking.
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
6307Whichever of the both NPCs is talked to, both will show a random emotion
6308at the same time.
6309
6310Command returns 1 or 0 on success and failure.
6311A debug message also shows on the console when no events are triggered.
6312
6313---------------------------------------
6314
6315*npctalk "<message>"{,"<npc name>"};
6316
6317This command will display a message to the surrounding area as if the NPC
6318object running it was a player talking - that is, above their head and in
6319the chat window. The display name of the NPC will get appended in front of
6320the 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
6334Changes the display name and/or display class of the target NPC.
6335Returns 0 is successful, 1 if the NPC does not exist.
6336Size is 0 = normal 1 = small 2 = big.
6337
6338---------------------------------------
6339//=====================================
63405.1 - Time-Related Commands
6341//=====================================
6342---------------------------------------
6343
6344*addtimer <ticks>,"NPC::OnLabel";
6345*deltimer "NPC::OnLabel";
6346*addtimercount "NPC::OnLabel",<ticks>;
6347
6348These commands will create, destroy, and delay a countdown timer -
6349'addtimer' to create, 'deltimer' to destroy and 'addtimercount' to delay
6350it by the specified number of ticks. For all three cases, the event label
6351given is the identifier of that timer. The timer runs on the character
6352object that is attached to the script, and can have multiple instances.
6353When the label is run, it is run as if the player that the timer runs on
6354has clicked the NPC.
6355
6356When this timer runs out, a new execution thread will start in the
6357specified NPC object at the specified label.
6358
6359The ticks are given in 1/1000ths of a second.
6360
6361One more thing. These timers are stored as part of player data. If the
6362player logs out, all of these get immediately deleted, without executing
6363the script. If this behavior is undesirable, use some other timer
6364mechanism (like 'sleep').
6365
6366Example:
6367<NPC Header> {
6368 dispbottom "Starting a 5 second timer...";
6369 addtimer 5000, strnpcinfo(3)+"::On5secs";
6370 end;
6371On5secs:
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
6389This set of commands and functions will create and manage an NPC-based
6390timer. The NPC name may be omitted, in which case the calling NPC is used
6391as target.
6392
6393Contrary to addtimer/deltimer commands which let you have many different
6394timers referencing different labels in the same NPC, each with their own
6395countdown, 'initnpctimer' can only have one per NPC object. But it can
6396trigger many labels and let you know how many were triggered already and
6397how many still remain.
6398
6399This timer is counting up from 0 in ticks of 1/1000ths of a second each.
6400Upon creating this timer, the execution will not stop, but will happily
6401continue onward. The timer will then invoke new execution threads at
6402labels "OnTimer<time>:" in the NPC object it is attached to.
6403
6404To create the timer, use the 'initnpctimer', which will start it running.
6405'stopnpctimer' will pause the timer, without clearing the current tick,
6406while 'startnpctimer' will let the paused timer continue.
6407
6408By default timers do not have a RID attached, which lets them continue
6409even if the player that started them logs off. To attach a RID to a timer,
6410you can either use the optional "attach flag" when using
6411'initnpctimer/startnpctimer', or do it manually by using 'attachnpctimer'.
6412Likewise, the optional flag of stopnpctimer lets you detach any RID after
6413stopping the timer, and by using 'detachnpctimer' you can detach a RID at
6414any time.
6415
6416Normally there is only a single timer per NPC, but as an exception, as
6417long as you attach a player to the timer, you can have multiple timers
6418running at once, because these will get stored on the players instead of
6419the NPC.
6420NOTE: You need to attach the RID before the timer _before_ you start it to
6421get a player-attached timer. Otherwise it'll stay a NPC timer (no effect).
6422
6423If 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
6425the appropriate cleanup (the player is still attached when this event is
6426triggered).
6427
6428The '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
6437Example 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
6470Example 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
6490Example 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
6498Example 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
6514These commands are used to control the pause of a NPC.
6515sleep and sleep2 will pause the script for the given amount of
6516milliseconds.
6517Awake is used to cancel a sleep. When awake is called on a NPC it will run
6518as if the sleep timer ran out, and thus making the script continue. Sleep
6519and sleep2 basically do the same, but the main difference is that sleep
6520will not keep the rid, while sleep2 does.
6521
6522Examples:
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
6535This command works almost like sleep2, but displays a progress bar above
6536the head of the currently attached character (like cast bar). Once the
6537given amount of seconds passes, the script resumes. If the character moves
6538while the progress bar progresses, it is aborted and the script ends. The
6539color format is in RGB (0xRRGGBB). The color is currently ignored by the
6540client and appears always green.
6541
6542---------------------------------------
6543//=====================================
65445.1 - End of Time-related commands
6545//=====================================
6546---------------------------------------
6547
6548*announce "<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
6549
6550This 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
6555The region the broadcast is heard in (target), source of the broadcast and
6556the color the message will come up as is determined by the flags.
6557
6558The flag values are coded as constants in db/const.txt to make them easier
6559to use.
6560
6561Target 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.
6567You cannot use more than one target flag.
6568
6569Source 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).
6574You cannot use more than one source flag.
6575
6576Special 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.
6581Due to the way client handles broadcasts, it is impossible to set both
6582bc_blue and bc_woe.
6583
6584The optional parameters allow usage of broadcasts in custom colors,
6585font-weights, sizes etc. If any of the optional parameters is used,
6586special flag is ignored. Optional parameters may not work well (or at all)
6587depending on a game client used.
6588
6589The color parameter is a single number which can be in hexadecimal
6590notation.
6591
6592For example:
6593 announce "This will be shown to everyone at all in green.",bc_all,0x00FF00;
6594Will display a global announce in green. The color format is in RGB
6595(0xRRGGBB).
6596
6597In official scripts only two font-weights (types) are used:
6598 - normal (FW_NORMAL = 400, default),
6599 - bold (FW_BOLD = 700).
6600
6601Default font size is 12.
6602
6603Using this for private messages to players is probably not that good an
6604idea, 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
6617This command will work like 'announce' but will only broadcast to
6618characters currently residing on the specified map. The flag and optional
6619parameters parameters are the same as in 'announce', but target and source
6620flags are ignored.
6621
6622---------------------------------------
6623
6624*areaannounce "<nome do mapa>",<x1>,<y1>,<x2>,<y2>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}}};
6625
6626This command works like 'announce' but will only broadcast to characters
6627residing in the specified x1/y1-x2/y2 rectangle on the map given. The
6628flags and optional parameters are the same as in 'announce', but target
6629and 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
6637These are a series of commands used to create dynamic shops.
6638The callshop function calls an invisible shop (view -1) as if the player
6639clicked on it.
6640
6641For the options on callShop:
6642 0 = The normal window (buy, sell and cancel)
6643 1 = The buy window
6644 2 = The sell window
6645
6646Example:
6647
6648//Will call the shop named DaShop and opens the buy menu.
6649callshop "DaShop",1;
6650
6651
6652The shop which is called by callshop (as long as an npcshop* command is
6653executed from that NPC (see note 1)) will trigger the labels OnBuyItem and
6654OnSellitem. These labels can take over handling for relatively the buying
6655of items from the shop and selling the items to a shop. Via these labels
6656you can customize the way an item is bought or sold by a player.
6657
6658In the OnBuyItem, two arrays are set (@bought_nameid and
6659@bought_quantity), which hold information about the name id (item id) sold
6660and the amount sold of it. Same goes for the OnSellItem label, only the
6661variables 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
6664in the doc/sample/npc_dynamic_shop.txt file.
6665
6666This example shows how to use the labels and their set variables to create
6667a dynamic shop.
6668
6669Note 1: These labels will only be triggered if a npcshop* command is
6670executed, this is because these commands set a special data on the shop
6671NPC, named master_nd in the source.
6672The OnSellItem and OnBuyItem are triggered in the NPC whose master_nd is
6673given in the shop.
6674
6675---------------------------------------
6676
6677*npcshopitem "<name>",<item id>,<price>{,<item id>,<price>{,<item id>,<price>{,...}}}
6678
6679This command lets you override the contents of an existing NPC shop or
6680cashshop. The current sell list will be wiped, and only the items
6681specified with the price specified will be for sale.
6682
6683The function returns 1 if shop was updated successfully, or 0 if not found.
6684
6685Note 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
6691This command will add more items at the end of the selling list for the
6692specified NPC shop or cashshop. If you specify an item already for sell,
6693that item will appear twice on the sell list.
6694
6695The function returns 1 if shop was updated successfully, or 0 if not found.
6696
6697Note that you cannot use -1 to specify default selling price!
6698
6699---------------------------------------
6700
6701*npcshopdelitem "<name>",<item id>{,<item id>{,<item id>{,...}}}
6702
6703This command will remove items from the specified NPC shop or cashshop.
6704If the item to remove exists more than once on the shop, all instances
6705will be removed.
6706
6707Note that the function returns 1 even if no items were removed. The return
6708value is only to confirm that the shop was indeed found.
6709
6710---------------------------------------
6711
6712*npcshopattach "<name>"{,<flag>}
6713
6714This command will attach the current script to the given NPC shop.
6715When a script is attached to a shop, the events "OnBuyItem" and
6716"OnSellItem" of your script will be executed whenever a player buys/sells
6717from the shop. Additionally, the arrays @bought_nameid[],
6718@bought_quantity[] or @sold_nameid[] and @sold_quantity[] will be filled
6719up with the items and quantities bought/sold.
6720
6721The optional parameter specifies whether to attach ("1") or detach ("0")
6722from the shop (the default is to attach). Note that detaching will detach
6723any NPC attached to the shop, even if it's from another script, while
6724attaching will override any other script that may be already attached.
6725
6726The 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
6732This command will create a chat room, owned by the NPC object running this
6733script and displayed above the NPC sprite.
6734The maximum length of a chat room name is 60 letters.
6735
6736The limit is the maximum number of people allowed to enter the chat room.
6737The attached NPC is included in this count. If the optional event and
6738trigger parameters are given, the event label
6739("<NPC object name>::<label name>") will be invoked as if with a 'doevent'
6740upon the number of people in the chat room reaching the given triggering
6741amount.
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
6763Creating a waiting room does not stop the execution of the script and it
6764will continue to the next line.
6765
6766For more examples see the 2-1 and 2-2 job quest scripts which make
6767extensive use of waiting rooms.
6768
6769---------------------------------------
6770
6771*delwaitingroom {"<NPC object name"};
6772
6773This command will delete a waiting room. If no parameter is given, it will
6774delete a waiting room attached to the NPC object running this command, if
6775it is, it will delete a waiting room owned by another NPC object. This is
6776the only way to get rid of a waiting room, nothing else will cause it to
6777disappear.
6778
6779It'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
6787This will enable and disable triggering the waiting room event (see
6788'waitingroom') respectively. Optionally giving an NPC object name will do
6789that for a specified NPC object. The chat room will not disappear when
6790triggering is disabled and enabled in this manner and players will not be
6791kicked out of it. Enabling a chat room event will also cause it to
6792immediately check whether the number of users in it exceeded the trigger
6793amount and trigger the event accordingly.
6794
6795Normally, whenever a waiting room was created to make sure that only one
6796character is, for example, trying to pass a job quest trial, and no other
6797characters are present in the room to mess up the script.
6798
6799---------------------------------------
6800
6801*getwaitingroomstate(<information type>{,"<NPC object name>"})
6802
6803This function will return information about the waiting room state for the
6804attached waiting room or for a waiting room attached to the specified NPC
6805if any.
6806
6807The 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
6832This command will warp the amount of characters equal to the trigger
6833number of the waiting room chat attached to the NPC object running this
6834command to the specified map and coordinates, kicking them out of the
6835chat. Those waiting the longest will get warped first. It can also do a
6836random warp on the same map ("Random" instead of nome do mapa) and warp to the
6837save point ("SavePoint").
6838
6839The list of characters to warp is taken from the list of the chat room
6840members. Those not in the chat room will not be considered even if they
6841are talking to the NPC in question. If the number of people is given,
6842exactly this much people will be warped.
6843
6844This command can also keep track of who just got warped. It does this by
6845setting 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
6851See also 'getpartymember' for advice on what to do with those variables.
6852
6853The obvious way of using this effectively would be to set up a waiting
6854room for two characters to be warped onto a random PVP map for a
6855one-on-one duel, for example.
6856
6857---------------------------------------
6858
6859*kickwaitingroomall {"<NPC object name>"};
6860
6861This 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
6867This command sets the 'nosave' flag for the specified map and also gives
6868an alternate respawn-upon-relogin point.
6869
6870It does not make a map impossible to make a save point on as you would
6871normally think, 'savepoint' will still work. It will, however, make the
6872specified map kick the reconnecting players off to the alternate map given
6873to the coordinates specified.
6874
6875---------------------------------------
6876
6877*setmapflag "<nome do mapa>",<flag>{,<val>};
6878
6879This command marks a specified map with a map flag given. Map flags alter
6880the behavior of the map, you can see the list of the available ones in
6881'db/const.txt' under 'mf_'.
6882
6883The map flags alter the behavior of the map regarding teleporting
6884(mf_nomemo, mf_noteleport, mf_nowarp, mf_nogo), storing location when
6885disconnected (mf_nosave), dead branch usage (mf_nobranch), penalties upon
6886death (mf_nopenalty, mf_nozenypenalty), PVP behavior (mf_pvp,
6887mf_pvp_noparty, mf_pvp_noguild), WoE behavior (mf_gvg,mf_gvg_noparty),
6888ability to use skills or open up trade deals (mf_notrade, mf_novending,
6889mf_noskill, mf_noicewall), current weather effects (mf_snow, mf_fog,
6890mf_sakura, mf_leaves, mf_rain, mf_clouds, mf_fireworks) and whether night
6891will be in effect on this map (mf_nightenabled).
6892
6893The val optional parameter is as the mapflags variable when one exists, it
6894may be a number or a string depending on the mapflag in question.
6895
6896---------------------------------------
6897
6898*removemapflag "<nome do mapa>",<flag>;
6899
6900This command removes a mapflag from a specified map.
6901See 'setmapflag' for a list of mapflags.
6902
6903---------------------------------------
6904
6905*getmapflag("<nome do mapa>",<flag>)
6906
6907This command checks the status of a given mapflag and returns the
6908mapflag's state.
69090 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
6916Sets or gets the value of the given battle flag.
6917Battle flags are the flags found in the "battle/*.conf/" files and is also
6918used in Lupus' variable rates script.
6919
6920Examples:
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
6933Creates a warp Portal as if a acolyte class character did it.
6934The first x and y is the place of the warp portal on the map where the NPC
6935is on the mapname and second x and y is the target area of the warp portal.
6936
6937Examples:
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
6947This command will collect all characters located on the From map and warp
6948them wholesale to the same point on the To map, or randomly distribute
6949them there if the coordinates are zero. "Random" is understood as a
6950special To nome do mapa and will mean randomly shuffling everyone on the same
6951map.
6952
6953Optionally, a type and ID can be specified. Available types are:
6954
6955 0 - Everyone
6956 1 - Guild
6957 2 - Party
6958
6959Example:
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//=====================================
69665.2 - Guild-Related Commands
6967//=====================================
6968---------------------------------------
6969
6970*maprespawnguildid "<nome do mapa>",<guild id>,<flag>;
6971
6972This command goes through the specified map and for each player and
6973monster found there does stuff.
6974
6975Flag 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
6980Flag 7 will, therefore, mean 'wipe all mobs but guardians and the Emperium
6981and kick all characters out', which is what the official scripts do upon
6982castle surrender. Upon start of WoE, the scripts do 2 (warp out all people
6983not in the guild that owns the castle).
6984
6985Characters not belonging to any guild will be warped out regardless of the
6986flag setting.
6987
6988For examples, check the WoE scripts in the distribution.
6989
6990---------------------------------------
6991
6992*agitstart;
6993*agitend;
6994*agitstart2;
6995*agitend2;
6996
6997These four commands will start/end War of Emperium or War of Emperium SE.
6998
6999This is a bit more complex than it sounds, since the commands themselves
7000won't actually do anything interesting, except causing all 'OnAgitStart:'
7001and 'OnAgitEnd:', or 'OnAgitStart2:' and 'OnAgitEnd2:' in the case of
7002latter two commands, events to run everywhere, respectively. They are used
7003as simple triggers to run a lot of complex scripts all across the server,
7004and they, in turn, are triggered by clock with an 'OnClock<time>:'
7005time-triggering label.
7006
7007---------------------------------------
7008
7009*gvgon "<nome do mapa>";
7010*gvgoff "<nome do mapa>";
7011
7012These commands will turn GVG mode for the specified maps on and off,
7013setting up appropriate map flags. In GVG mode, maps behave as if during
7014the time of WoE, even though WoE itself may or may not actually be in
7015effect.
7016
7017---------------------------------------
7018
7019*flagemblem <guild id>;
7020
7021This command only works when run by the NPC objects which have sprite id
7022722, which is a 3D guild flag sprite. If it isn't, the data will change,
7023but nothing will be seen by anyone. If it is invoked in that manner, the
7024emblem of the specified guild will appear on the flag, though, if any
7025players are watching it at this moment, they will not see the emblem
7026change until they move out of sight of the flag and return.
7027
7028This is commonly used in official guildwar scripts with a function call
7029which 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
7040This command is roughly equivalent to 'monster', but is meant to be used
7041with castle guardian monsters and will only work with them. It will set
7042the guardian characteristics up according to the castle's investment
7043values and otherwise set the things up that only castle guardians need.
7044
7045Returns the id of the mob or 0 if an error occurred.
7046When 'guardian index' isn't supplied it produces a temporary guardian.
7047Temporary guardians are not saved with the castle and can't be accessed by
7048guardianinfo.
7049
7050---------------------------------------
7051
7052*guardianinfo("<nome do mapa>", <guardian number>, <type>);
7053
7054This function will return various info about the specified guardian, or -1
7055if it fails for some reason. It is primarily used in the castle manager
7056NPC.
7057
7058nome do mapa and guardian number (value between 0 and 7) define the target.
7059Type 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//=====================================
70665.2 - End of Guild-Related Commands
7067//=====================================
7068---------------------------------------
7069
7070*npcspeed <speed value>;
7071*npcwalkto <x>,<y>;
7072*npcstop;
7073
7074These commands will make the NPC object in question move around the map.
7075As they currently are, they are a bit buggy and are not useful for much
7076more 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
7080fastest possible (instant motion). 100 is the default character walking
7081speed.
7082'npcwalkto' will start the NPC sprite moving towards the specified
7083coordinates on the same map as it is currently on. The script proceeds
7084immediately after the NPC begins moving.
7085'npcstop' will stop the motion.
7086
7087While in transit, the NPC will be clickable, but invoking it will cause it
7088to stop moving, which will make it's coordinates different from what the
7089client computed based on the speed and motion coordinates. The effect is
7090rather unnerving.
7091
7092Only a few NPC sprites have walking animations, and those that do, do not
7093get the animation invoked when moving the NPC, due to the problem in the
7094NPC walking code, which looks a bit silly. You might have better success
7095by 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
7101This command looks like the npcwalktoxy function,but is a little different.
7102
7103While npcwalktoxy just makes the NPC 'walk' to the coordinates given
7104(which sometimes gives problems if the path isn't a straight line without
7105objects), this command just moves the NPC. It basically warps out and in
7106on the current and given spot. Direction can be used to change the NPC's
7107facing direction.
7108
7109Example:
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//=====================================
71176 - Other Commands
7118//=====================================
7119---------------------------------------
7120
7121*debugmes "<message>";
7122
7123This command will send the message to the server console (map-server
7124window). 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
7134This command will write the message given to the map server NPC log file,
7135as specified in 'conf/logs.conf'. If SQL logging is enabled, the message
7136will go to the 'npclog' table.
7137
7138If logs are not enabled for NPCs, nothing will happen.
7139
7140---------------------------------------
7141
7142*globalmes "<message>"{,"<NPC name>"};
7143
7144This command will send a message to the chat window of all currently
7145connected characters.
7146
7147If NPC name is specified, the message will be sent as if the sender would
7148be the NPC with the said name.
7149
7150---------------------------------------
7151
7152*channelmes("<#channel>", "<message>");
7153
7154This command will send a message to the specified chat channel.
7155
7156The sent message will not include any character's names.
7157
7158For special channels, such as #map and #ally, the attached RID's map or guild
7159will be used.
7160
7161If the channel doesn't exist (or, in the case of a character-specific channel,
7162no RID is attached), false will be returned. In case of success, true is
7163returned.
7164
7165---------------------------------------
7166*rand(<number>{,<number>});
7167
7168This 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
7174rand(10) would result in 0,1,2,3,4,5,6,7,8 or 9
7175rand(0,9) would result in 0,1,2,3,4,5,6,7,8 or 9
7176rand(2,5) would result in 2,3,4 or 5
7177
7178---------------------------------------
7179
7180*viewpoint <action>,<x>,<y>,<point number>,<color>;
7181
7182This command will mark places on the mini map in the client connected to
7183the invoking character. It uses the normal X and Y coordinates from the
7184main map. The colors of the marks are defined using a hexadecimal number,
7185same as the ones used to color text in 'mes' output, but are written as
7186hexadecimal numbers in C. (They look like 0x<six numbers>.)
7187
7188Action is what you want to do with a point, 1 will set it, while 2 will
7189clear it. 0 will also set it, but automatically removes the point after 15
7190seconds.
7191Point number is the number of the point - you can have several. If more
7192than one point is drawn at the same coordinates, they will cycle, which
7193can 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
7200This 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
7206And 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
7212The client determines what it does with the points entirely, the server
7213keeps no memory of where the points are set whatsoever.
7214
7215---------------------------------------
7216
7217*cutin "<filename>",<position>;
7218
7219This command will display a picture, usually an NPC illustration, also
7220called cutin, for the currently attached client. The position parameter
7221determines 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
7229The picture is read from data\texture\유저ì¸Ä°ÃŽ˜ì´ìФ\illust, from both the
7230GRF archive and data folder, and is required to be a bitmap. The file
7231extension .bmp can be omitted. Magenta color (#ff00ff) is considered
7232transparent. There is no limit placed on the size of the illustrations
7233by the client, although loading of large pictures (about 700x700 and
7234larger) causes the client to freeze shortly (lag). Typically the size is
7235about 320x480. New illustrations can be added by just putting the new file
7236into the location above.
7237
7238The client is able to display only one cutin at the same time and each new
7239one will cause the old one to disappear. To delete the currently displayed
7240illustration without displaying a new one, an empty file name and position
7241255 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
7257This command is used in all the item scripts for taming items. Running
7258this command will make the pet catching cursor appear on the client
7259connected to the invoking character, usable on the monsters with the
7260specified pet ID number. It will still work outside an item script.
7261
7262A full list of pet IDs can be found inside 'db/pet_db.txt'
7263
7264---------------------------------------
7265
7266*emotion <emotion number>{,<target>{,"<target name>"}};
7267
7268This command makes an object display an emotion sprite above their own as
7269if 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
7271question mark) and 'e_gasp' (the exclamation mark).
7272
7273The optional target parameter specifies who will get the emotion on top of
7274their head. If 0 (default if omitted), the NPC in current use will show
7275the emotion, if 1, the player that is running the script will display it.
7276
7277Target name parameter allows to display emotion on top of other NPC/PC
7278without event labels. If specified name is not found, command does nothing.
7279
7280---------------------------------------
7281
7282*misceffect <effect number>;
7283
7284This command, if run from an NPC object that has a sprite, will call up a
7285specified effect number, centered on the NPC sprite. If the running code
7286does not have an object ID (a 'floating' NPC) or is not running from an
7287NPC object at all (an item script) the effect will be centered on the
7288character who's RID got attached to the script, if any. For usable item
7289scripts, this command will create an effect centered on the player using
7290the item.
7291
7292A full list of known effects is found in 'doc/effect_list.txt'. The list
7293of 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
7300These two commands will play a sound effect to either the invoking
7301character only ('soundeffect') or multiple characters ('soundeffectall').
7302If the running code does not have an object ID (a 'floating' NPC) or is
7303not running from an NPC object at all (an item script) the sound will be
7304centered on the character who's RID got attached to the script, if any.
7305If it does, it will be centered on that object. (an NPC sprite)
7306
7307Effect filename is the filename in a GRF. It must have the .wav extension.
7308
7309It's not quite certain what the 'type' actually does, it is sent to the
7310client directly. It probably determines which directory to play the effect
7311from. 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
7314The sound files themselves must be in the PCM format, and file names
7315should also have a maximum length of 23 characters including the .wav
7316extension:
7317
7318soundeffect "1234567890123456789.wav", 0; // will play the soundeffect
7319soundeffect "12345678901234567890.wav", 0; // throws gravity error
7320
7321You 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
7328These two commands will play a Background Music to either the invoking
7329character only ('playbgm') or multiple characters ('playbgmall').
7330
7331BGM filename is the filename in /BGM/ folder. It has to be in .mp3
7332extension, but it's not required to specify the extension in the script.
7333
7334If coordinates are omitted, BGM will be broadcasted on the entire map. If
7335the nome do mapa is also omitted the BGM will be played for the entire server.
7336
7337You can add your own BGMs this way, naturally.
7338
7339---------------------------------------
7340
7341*pvpon "<nome do mapa>";
7342*pvpoff "<nome do mapa>";
7343
7344These commands will turn PVP mode for the specified maps on and off.
7345Beside setting the flags referred to in 'setmapflag', 'pvpon' will also
7346create a PVP timer and ranking as will @pvpon GM command do.
7347
7348---------------------------------------
7349
7350*atcommand "<command>";
7351
7352This command will run the given command line exactly as if it was typed in
7353from the keyboard by the player connected to the invoking character, and
7354that 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
7361This command has a lot of good uses, I am sure you can have some fun with
7362this one.
7363
7364---------------------------------------
7365
7366*charcommand "<command>";
7367
7368This command will run the given command line exactly as if it was typed in
7369from the keyboard from a character that belonged to an account which had
7370GM level 99.
7371
7372The 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
7382This command will bind a NPC event label to an atcommand. Upon execution
7383of the atcommand, the user will invoke the NPC event label. Each atcommand
7384is only allowed one binding. If you rebind, it will override the original
7385binding. If group level is provided, only users of that group level or
7386above will be able to access the command, if not provided, everyone will
7387be able to access the command.
7388"group level char" is the minimum group level required for the label to be
7389used on others like a char command would, e.g. "#command "target" params",
7390when 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
7394The 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
7400Parameters are split on spaces. Multiple spaces aren't grouped together, and
7401will create multiple (empty) arguments.
7402Any leading spaces before the first parameter will be omitted.
7403
7404Usage example:
7405
7406When a user types the command "@test", an angel effect will be shown.
7407
7408- script atcmd_example -1,{
7409OnInit:
7410 bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
7411 end;
7412OnAtcommand:
7413 specialeffect2 338;
7414 end;
7415}
7416
7417Parameter 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
7443The called event label needs to take care of joining arguments together, in
7444case it expects spaces. For example:
7445
7446- script atcmd_example -1,{
7447OnInit:
7448 bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
7449 end;
7450OnAtcommand:
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
7465This command will unbind a NPC event label from an atcommand.
7466
7467---------------------------------------
7468
7469*useatcmd "command";
7470
7471This command will execute an atcommand binding on the attached RID from a
7472script. The three .@atcmd_***** variables will NOT be set when invoking
7473scripts-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
7482This is the replacement of the older commands, these use the same values
7483for GID as the other unit* commands (See 'GID').
7484
7485Skill ID is the ID of the skill, skill level is the level of the skill.
7486For 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
7493This command causes the attached NPC object to cast a skill on the
7494attached player. The skill will have no cast time or cooldown. The player
7495must be within the default skill range or the command will fail silently.
7496
7497The "stat point" parameter temporarily sets all NPC stats to the given
7498value, and "NPC level" is the temporary level of the NPC (used in some
7499skills). Neither value can be greater than the max level defined in
7500config, 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
7510This command can reduce distance from where npc can be clicked.
7511Usefull 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
7521Return current npc direction for parameter "name" or for attached npc
7522if it missing. If name missing and not attached npc, return -1.
7523
7524Example:
7525 .@dir = getnpcdir();
7526
7527---------------------------------------
7528
7529*setnpcdir {<name>,} <direction>;
7530
7531Set npc direction. If npc name missing, will be used attached npc.
7532
7533Example:
7534 setnpcdir 2;
7535
7536---------------------------------------
7537
7538*getnpcclass {<name>};
7539
7540Return npc class/sprite id for npc with given name or for attached npc.
7541If name missing and no attached npc, return -1.
7542
7543Example:
7544 .@class = getnpcclass();
7545
7546---------------------------------------
7547
7548*day;
7549*night;
7550
7551These two commands will switch the entire server between day and night
7552mode respectively. If your server is set to cycle between day and night by
7553configuration, it will eventually return to that cycle.
7554
7555Example:
7556
7557- script DayNight -1,{
7558OnClock0600:
7559 day;
7560 end;
7561OnInit:
7562 // setting correct mode upon server start-up
7563 if(gettime(3)>=6 && gettime(3)<18) end;
7564OnClock1800:
7565 night;
7566 end;
7567}
7568
7569This script allows to emulate the day/night cycle as the server does, but
7570also allows triggering additional effects upon change, like announces,
7571gifts, etc.
7572The day/night cycle set by configuration should be disabled when this
7573script is used.
7574
7575---------------------------------------
7576
7577*pcre_match("<string>","<regex>");
7578
7579This command is only available if the server is compiled with regular
7580expressions library enabled.
7581
7582The string <string> will be searched for a match to the regular expression
7583<regex>, and the number of matches will be returned.
7584
7585An alternative way to invoke this command is to use the operators '~=' or '~!'.
7586The operator '~=' is exactly the same as pcre_match, while the operator '~!'
7587will 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
7593You can find more usage examples in the test script npc/custom/test.txt.
7594
7595Using regular expressions is high wizardry. But with this high wizardry
7596comes unparalleled power of text manipulation. For an explanation of what
7597a regular expression pattern is, see a few web pages:
7598
7599http://www.regular-expressions.info/
7600http://www.weitz.de/regex-coach/
7601
7602Additionally, the following temporary variables will be filled (unless the
7603command 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
7611A capture group is a part of a regex enclosed in (parentheses) in order to
7612store in a variable the part of the expression that was matched by that part of
7613the regex. For more details, see the links above, as this is not intended to be
7614a 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
7623This set of commands is only available if the server is compiled with
7624regular expressions library enabled.
7625
7626They will make the NPC object listen for text spoken publicly by players
7627and match it against regular expression patterns, then trigger labels
7628associated with these regular expression patterns.
7629
7630Patterns are organized into sets, which are referred to by a set number.
7631You can have multiple sets patterns, and multiple patterns may be active
7632at once. Numbers for pattern sets start at 1.
7633
7634'defpattern' will associate a given regular expression pattern with an
7635event label. This event will be triggered whenever something a player says
7636is matched by this regular expression pattern, if the pattern is currently
7637active.
7638
7639'activatepset' will make the pattern set specified active. An active
7640pattern will enable triggering labels defined with 'defpattern', which
7641will not happen by default.
7642'deactivatepset' will deactivate a specified pattern set. Giving -1 as a
7643pattern 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
7646new pattern set in its place.
7647
7648For an example of this in use, see doc/sample/npc_test_pcre.txt
7649
7650With this you could, for example, automatically punish players for asking
7651for Zeny in public places, or alternatively, automatically give them Zeny
7652instead if they want it so much.
7653
7654---------------------------------------
7655
7656*pow(<number>,<power>)
7657
7658Returns the result of the calculation.
7659
7660Example:
7661 .@i = pow(2,3); // .@i will be 8
7662
7663---------------------------------------
7664
7665*log10(<number>)
7666
7667Returns log base 10 of the number.
7668
7669Note: The value is truncated to integer.
7670
7671Example:
7672 .@i = log10(100); // .@i will be 2
7673
7674---------------------------------------
7675
7676*sqrt(<number>)
7677
7678Returns square-root of number.
7679
7680Note: The value is truncated to integer.
7681
7682Example:
7683 .@i = sqrt(25); // .@i will be 5
7684
7685---------------------------------------
7686
7687*distance(<x0>,<y0>,<x1>,<y1>)
7688
7689Returns distance between 2 points.
7690
7691Note: When Cronus is configured to use circular areas, the Euclidean distance
7692is returned, otherwise the Chebyshev distance. The value is truncated to
7693integer.
7694
7695Example:
7696 .@i = distance(100,200,101,202);
7697
7698---------------------------------------
7699
7700*min(<number>{,<number>...<number>})
7701*max(<number>{,<number>...<number>})
7702
7703Returns the smallest (or biggest) from the set of given numbers.
7704
7705Example:
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
7714Returns the md5 checksum of a number or string.
7715
7716Example:
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
7726Executes an SQL query. A 'select' query can fill array variables with up
7727to 128 rows of values, and will return the number of rows (the array size).
7728
7729Note that 'query_sql' runs on the main database while 'query_logsql' runs
7730on the log database.
7731
7732Example:
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
7745Converts the value to a string and escapes special characters so that it's
7746safe to use in query_sql(). Returns the escaped form of the given value.
7747
7748Example:
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
7756This function will set some value of an item.
7757Returns the new value on success, or -1 on fail (item_id not found or
7758invalid type).
7759
7760Valid 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
7768Example:
7769
7770setiteminfo Stone, 6, 9990; // Stone now weighs 999.0
7771
7772---------------------------------------
7773
7774*setitemscript(<item id>,<"{ new item script }">{,<type>});
7775
7776Set a new script bonus to the Item. Very useful for game events.
7777You can remove an item's itemscript by leaving the itemscript argument
7778empty. Returns 1 on success, or 0 on fail (item_id not found or new item
7779script is invalid).
7780Type can optionally be used indicates which script to set (default is 0):
7781 0 - Script
7782 1 - OnEquip_Script
7783 2 - OnUnequip_Script
7784
7785Example:
7786
7787setitemscript Silver_Ring_, "{ if(isequipped(2236)==0)end; if(getskilllv(26)){skill 40,1;}else{skill 26,1+isequipped(2636);} }";
7788setitemscript Silver_Ring_, "";
7789
7790---------------------------------------
7791
7792*atoi("<string>")
7793*axtoi("<string>")
7794*strtol("string", base)
7795
7796These commands are used to convert strings to numbers. 'atoi' will
7797interpret given string as a decimal number (base 10), while 'axtoi'
7798interprets strings as hexadecimal numbers (base 16). 'strtol' lets
7799the user specify a base (valid range is between 2 and 36 inclusive,
7800or the special value0, which means auto-detection).
7801
7802The atoi and strtol functions conform to the C functions with the same
7803names, and axtoi is the same as strtol, with a base of 16. Results are
7804clamped to signed 32 bit int range (INT_MIN ~ INT_MAX)
7805
7806Example:
7807
7808.@var = atoi("11"); // Sets .@var to 11
7809.@var = axtoi("FF"); // Sets .@var to 255
7810mes 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
7822This command returns 1 or 0 when the substring is in the main string (1)
7823or not (0). This command is not case sensitive.
7824
7825Examples:
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
7838This command compares two strings and is similar to strcmp in C.
7839
7840Return Values:
7841 >0 : String 1 > String 2
7842 0 : Strings are equal
7843 <0 : String 1 < String 2
7844
7845Examples:
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
7857This function will return the length of the string given as an argument.
7858It is useful to check if anything input by the player exceeds name length
7859limits and other length limits and asking them to try to input something
7860else.
7861
7862---------------------------------------
7863
7864*charisalpha("<string>",<position>)
7865
7866This function will return 1 if the character number Position in the given
7867string is a letter, 0 if it isn't a letter but a digit or a space.
7868The first letter is position 0.
7869
7870---------------------------------------
7871
7872*charat(<string>,<index>)
7873
7874Returns char at specified index. If index is out of range, returns an
7875empty string.
7876
7877Example:
7878
7879 charat("This is a string", 10); //returns "s"
7880
7881---------------------------------------
7882
7883*setchar(<string>,<char>,<index>)
7884
7885Returns the original string with the char at the specified index set to
7886the specified char. If index is out of range, the original string will be
7887returned. Only the 1st char in the <char> parameter will be used.
7888
7889Example:
7890
7891 setchar("Cat", "B", 0); //returns "Bat"
7892
7893---------------------------------------
7894
7895*insertchar(<string>,<char>,<index>)
7896
7897Returns the original string with the specified char inserted at the
7898specified index. If index is out of range, the char will be inserted on
7899the end of the string that it is closest. Only the 1st char in the <char>
7900parameter will be used.
7901
7902Example:
7903
7904 insertchar("laughter", "s", 0); //returns "slaughter"
7905
7906---------------------------------------
7907
7908*delchar(<string>,<index>)
7909
7910Returns the original string with the char at the specified index removed.
7911If index is out of range, original string will be returned.
7912
7913Example:
7914
7915 delchar("Diet", 3); //returns "Die"
7916
7917---------------------------------------
7918
7919*strtoupper(<string>)
7920*strtolower(<string>)
7921
7922Returns the specified string in it's uppercase/lowercase form.
7923All non-alpha characters will be preserved.
7924
7925Example:
7926
7927 strtoupper("The duck is blue!!"); //returns "THE DUCK IS BLUE!!"
7928
7929---------------------------------------
7930
7931*charisupper(<string>,<index>)
7932*charislower(<string>,<index>)
7933
7934Returns 1 if character at specified index of specified string is
7935uppercase for 'charisupper' or lowercase for 'charislower'. Otherwise, 0.
7936Characters not of the alphabelt will return 0.
7937
7938Example:
7939
7940 charisupper("Cronus", 0); //returns 1
7941
7942---------------------------------------
7943
7944*substr(<string>,<start_index>,<end_index>)
7945
7946Returns the sub-string of the specified string inclusively between the set
7947indexes. If indexes are out of range, or the start index is after the end
7948index, an empty string will be returned.
7949
7950Example:
7951
7952 substr("foobar", 3, 5); //returns "bar"
7953
7954---------------------------------------
7955
7956*explode(<dest_array>,<string>,<delimiter>)
7957
7958Breaks a string up into substrings based on the specified delimiter.
7959Substrings will be stored within the specified string array. Only the 1st
7960char of the delimiter parameter will be used. If an empty string is passed
7961as a delimiter, the string will be placed in the array in its original
7962form, without any changes.
7963
7964Example:
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
7978Combines all substrings within the specified string array into a single
7979string. If the glue parameter is specified, it will be inserted inbetween
7980each substring.
7981
7982Example:
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
7990C style sprintf. The resulting string is returned same as in PHP. All C
7991format specifiers are supported except %n. For more info check sprintf
7992function at www.cplusplus.com
7993Number of params is only limited by Cronus' script engine.
7994
7995Example:
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
8007C style sscanf. All C format specifiers are supported.
8008More info: sscanf @ www.cplusplus.com. The number of params is only
8009limited by Cronus' script engine.
8010
8011Example:
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
8019PHP style strpos. Finds a substring (needle) within a string (haystack).
8020The offset parameter indicates the index of the string to start searching.
8021Returns index of substring on successful search, else -1.
8022Comparison is case sensitive.
8023
8024Example:
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
8033Replaces all instances of a search string in the input with the specified
8034replacement string. By default is case sensitive unless <usecase> is set
8035to 0. If specified it will only replace as many instances as specified
8036in the count parameter.
8037
8038Example:
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
8047Counts all instances of a search string in the input. By default is case
8048sensitive unless <usecase> is set to 0.
8049
8050Example:
8051 countstr("test test test Test", "test"); //returns 3
8052 countstr("cake Cake", "Cake", 0); //returns 2
8053
8054---------------------------------------
8055
8056*setfont <font>;
8057
8058This command sets the current RO client interface font to one of the fonts
8059stored in data\*.eot by using an ID of the font. When the ID of the
8060currently 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
8077Displays given numeric 'value' in large digital clock font on top of the
8078screen. 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
8088For type 1 and 2 the start value is set by using negative number of the
8089one intended to set (ex. -10 starts the counter at 10 seconds). Except for
8090type 3 the value is interpreted as seconds and formatted as time in days,
8091hours, minutes and seconds. Note, that the official script command does
8092not 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
8104These commands will only work if the invoking character has a pet, and are
8105meant to be executed from pet scripts. They will modify the pet AI
8106decision-making for the current pet of the invoking character, and will
8107NOT have any independent effect by themselves, which is why only one of
8108them each may be in effect at any time for a specific pet. A pet may
8109have 'petloot', 'petskillbonus', 'petskillattack' and 'petskillsupport' at the
8110same time.
8111
8112*petskillbonus <bonus type>,<value>,<duration>,<delay>;
8113
8114This command will make the pet give a bonus to the owner's stat (bonus
8115type - bInt,bVit,bDex,bAgi,bLuk,bStr,bSpeedRate - for a full list, see the
8116values starting with 'b' in 'db/const.txt').
8117
8118*petrecovery <status type>,<delay>;
8119
8120This command will make the pet cure a specified status condition. The
8121curing actions will occur once every <delay> seconds. For a full list of
8122status conditions that can be cured, see the list of 'SC_' status
8123condition constants in 'db/const.txt'
8124
8125*petloot <max items>;
8126
8127This command will turn on pet looting, with a maximum number of items to
8128loot specified. Pet will store items and return them when the maximum is
8129reached 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
8134This will make the pet use a specified support skill on the owner whenever
8135the HP and SP are below the given percent values, with a specified delay
8136time between activations. The skill numbers are as per
8137'db/(pre-)re/skill_db.txt'.
8138It's not quite certain who's stats will be used for the skills cast, the
8139character'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
8144This command will make the pet cast an attack skill on the enemy the pet's
8145owner is currently fighting. Skill IDs and levels are as per 'petskillsupport'.
8146If <number of attacks> is specified different than 0, it will make the pet cast
8147the skill with a fixed amount of damage inflicted and the specified number of
8148attacks. A value of zero uses the skill's defaults.
8149
8150All commands with delays and durations will only make the behavior active
8151for the specified duration of seconds, with a delay of the specified
8152number of seconds between activations. Rates are a chance of the effect
8153occurring and are given in percent. 'bonusrate' is added to the normal
8154rate if the pet intimacy is at the maximum possible.
8155
8156The behavior modified with the above mentioned commands will only be
8157exhibited if the pet is loyal and appropriate configuration options are
8158set in 'battle.conf'.
8159
8160Pet scripts in the database normally run whenever a pet of that type
8161hatches from the egg. Other commands usable in item scripts (see 'bonus')
8162will also happily run from pet scripts. Apparently, the pet-specific
8163commands will also work in NPC scripts and modify the behavior of the
8164current pet up until the pet is hatched again. (Which will also occur when
8165the character is logged in again with the pet still out of the egg.) It is
8166not certain for how long the effect of such command running from an NPC
8167script will eventually persist, but apparently, it is possible to usefully
8168employ them in usable item scripts to create pet buffing items.
8169
8170Nobody tried this before, so you're essentially on your own here.
8171
8172---------------------------------------
8173
8174*bpet;
8175
8176This command opens up a pet hatching window on the client connected to the
8177invoking character. It is used in item script for the pet incubators and
8178will let the player hatch an owned egg. If the character has no eggs, it
8179will just open up an empty incubator window.
8180This is still usable outside item scripts.
8181
8182---------------------------------------
8183
8184*makepet <pet id>;
8185
8186This command will create a pet egg and put it in the invoking character's
8187inventory. 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
8189successfully caught a pet in the normal way.
8190
8191 // This will make you a poring:
8192 makepet 1002;
8193
8194Notice that you absolutely have to create pet eggs with this command. If
8195you try to give a pet egg with 'getitem', pet data will not be created by
8196the char server and the egg will disappear when anyone tries to hatch it.
8197
8198---------------------------------------
8199
8200*homshuffle;
8201
8202This will recalculate the homunculus stats according to its level, of the
8203current invoking character.
8204
8205---------------------------------------
8206
8207*setcell "<nome do mapa>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>;
8208
8209Each map cell has several 'flags' that specify the properties of that cell.
8210These include terrain properties (walkability, shootability, presence of
8211water), skills (basilica, land protector, ...) and other (NPC nearby, no
8212vending, ...).
8213Each of these can be 'on' or 'off'. Together they define a cell's behavior.
8214
8215This 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,
8218cell_shootable, cell_basilica. For a full list, see const.txt.
8219'flag' can be 0 or 1 (0:clear flag, 1:set flag).
8220
8221Example:
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
8228This will add a makeshift ring into the center of the map. The ring will
8229be surrounded by a 5-cell wide 'gap' to prevent interference from outside,
8230and the rest of the map will be marked as 'basilica', preventing observers
8231from casting any offensive skills or fighting among themselves. Note that
8232the wall will not be shown nor known client-side, which may cause movement
8233problems.
8234
8235Another example:
8236
8237OnBarricadeDeploy:
8238 setcell "schg_cas05",114,51,125,51,cell_walkable,0;
8239 end;
8240OnBarricadeBreak:
8241 setcell "schg_cas05",114,51,125,51,cell_walkable,1;
8242 end;
8243
8244This could be a part of the WoE:SE script, where attackers are not allowed
8245to proceed until all barricades are destroyed. This script would place and
8246remove a nonwalkable row of cells after the barricade mobs.
8247
8248---------------------------------------
8249
8250*checkcell ("<nome do mapa>",<x>,<y>,<type>);
8251
8252This command will return 1 or 0, depending on whether the specified cell
8253has the 'type' flag set or not. There are various types to check, all
8254mimicking the server's cell_chk enumeration. The types can be found in
8255db/const.txt.
8256
8257The meaning of the individual types can be confusing, so here's an
8258overview:
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
8267Example:
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
8292Creates an invisible wall, an array of "setcell" starting from x,y and
8293doing a line of the given size in the given direction. The difference with
8294setcell is this one update client part too to avoid the glitch problem.
8295Directions are the same as NPC sprite facing directions: 0=north,
82961=northwest, 2=west, etc.
8297
8298---------------------------------------
8299
8300*readbook <book id>,<page>;
8301
8302This will open a book item at the specified page.
8303
8304---------------------------------------
8305//=====================================
83067 - Instance-Related Commands
8307//=====================================
8308---------------------------------------
8309
8310*instance_create("<instance name>",<owner id>{,<optional owner_type>});
8311
8312Create an instance using the name "<instance name>" for the <owner_id> of
8313owner_type (when not provided, defaults to IOT_PARTY). Most instance_*
8314commands are used in conjunction with this command and depend on the
8315ID this command returns.
8316
8317Example:
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
8339Destroys instance with the ID <instance id>. If no ID is specified, the
8340instance the script is attached to is used. If in the end no instance_id,
8341is 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
8347Attaches the map "<nome do mapa>" to the instance specified with
8348<instance id>. The optional parameter specifies, whether a map requires
8349emulation for instancing (1) or not (0 = default). if use base name is specified,
8350and "<new nome do mapa>" too the server will instance the map under the "<new nome do mapa>",
8351name.
8352
8353Returns the resulting nome do mapa on success or an empty string on failure.
8354
8355Example:
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
8363Detach the map "<nome do mapa>" to the instance with the <instance id>. If no
8364ID is specified, the instance the script is attached to is used. If in the
8365end no instance_id is found the command halts the script execution.
8366
8367---------------------------------------
8368
8369*instance_init <instance id>;
8370
8371Initializes the instance given by <instance id>. This copies all NPCs from
8372the source maps to the instanced maps.
8373
8374---------------------------------------
8375
8376*instance_announce <instance id>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
8377
8378Works like announce, but has the <instance id> parameter. If instance id
8379is -1, the instance the script is attached to is used. If in the
8380end no instance_id is found the command halts the script execution.
8381
8382---------------------------------------
8383
8384*instance_attach <instance id>;
8385
8386Attaches the current script to the instance given by <instance id>.
8387
8388---------------------------------------
8389
8390*instance_npcname("<npc name>"{,<instance id>});
8391
8392Retrieves the unique name given to a copy of an NPC given by "<npc name>"
8393in an instance specified <instance id>. If no ID is specified, the
8394instance the script is attached to is used. If in the end no instance_id,
8395is found the command halts the script execution.
8396
8397---------------------------------------
8398
8399*has_instance("<nome do mapa>"{,<instance id>});
8400
8401Checks whether or not the given map belongs to specified instance. If no
8402ID is specified, the instance the script is attached to is used. If the
8403script is not attached to an instance, it'll try to check whether the,
8404player 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,
8406script execution.
8407
8408Returns name of the instanced map on success, otherwise an empty string.
8409
8410---------------------------------------
8411
8412*has_instance2("<nome do mapa>");
8413
8414Same as has_instance, with exception it returns the instance id of the map,
8415as long as the user is assigned to a instance containing that map.
8416It will return -1 upon failure, valid instance ids are >= 0.
8417
8418---------------------------------------
8419
8420*instance_id();
8421
8422Retrieves 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
8428Warps all players in the instance <instance id> to <nome do mapa> at given
8429coordinates. If no ID is specified, the instance the script is attached to
8430is used. If in the end no instance_id is found the command halts the,
8431script execution.
8432
8433---------------------------------------
8434
8435*instance_set_timeout <alive timeout>,<idle timeout>{,<instance id>};
8436
8437Sets the timeout values for an instance given by <instance id>. If no ID
8438is specified, the instance the script is attached to is used. If in the end,
8439no instance_id is found the command halts the script execution.
8440
8441Parameter <alive timeout> specifies the total amount of time the instance
8442will exist. Parameter <idle timeout> specifies how long players have, when
8443they are outside of the instance, until it is destroyed.
8444
8445Both timeout values are in seconds.
8446
8447---------------------------------------
8448
8449*instance_check_party(<party id>{,<amount>{,<min>{,<max>}}});
8450
8451This function checks if a party meets certain requirements, returning 1 if
8452all conditions are met and 0 otherwise. It will only check online
8453characters.
8454
8455amount - number of online party members (default is 1).
8456min - minimum level of all characters in the party (default is 1).
8457max - maximum level of all characters in the party (default is max
8458 level in conf).
8459
8460Example:
8461
8462if (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
8475This function checks if a guild meets certain requirements, returning 1 if
8476all conditions are met and 0 otherwise. it will only check online characters.
8477
8478amount - number of online guild members (default is 1).
8479min - minimum level of all characters in the guild (default is 1).
8480max - maximum level of all characters in the guild (default is max level in conf).
8481
8482Example:
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
8495Updates the 'reload spawn' position of a instance,
8496that is where players in the instance are sent to upon @reloadscript,
8497uses the npc instance (if any) when instance_id is not provided,
8498handy to update a instance's progress so that when/if @reloadscript happens
8499the damage to the players progress is reduced.
8500It is most effective when used with instance variables (which are @reloadscript persistent)
8501
8502If a player warps into a instance before this command has been used,
8503it will use the player's warp destination as the initial respawn point,
8504it can of course be modified by using this script command at any point.
8505
8506---------------------------------------
8507*instance_mapname("<nome do mapa>"{,<instance id>})
8508
8509Returns the unique name of the instanced map. If no instance ID is specified,
8510the instance the script is attached to is used. If the script is not attached to
8511an instance, the instance of the currently attached player's party is used. If
8512that fails, the command returns an empty string instead.
8513
8514
8515---------------------------------------
8516//=====================================
85177 - End of Instance-Related Commands
8518//=====================================
8519---------------------------------------
8520
8521
8522---------------------------------------
8523//=====================================
85248 - Quest Log-Related Commands
8525//=====================================
8526---------------------------------------
8527
8528*questinfo <Quest ID>, <Icon> {, <Map Mark Color>{, <Job Class>}};
8529
8530This is esentially a combination of questprogress and showevent. Use this only
8531in an OnInit label. For the Quest ID, specify the quest ID that you want
8532checked if it has been started yet.
8533
8534For Icon, use one of the following:
8535
8536No 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
8543Warg : QTYPE_WARG
8544Warg Face : QTYPE_WARG2 (Only for packetver >= 20120410)
8545
8546Map Mark Color, when used, creates a mark in the user's mini map on the position of the NPC,
8547the available color values are:
8548
85490 - No Marker
85501 - Yellow Marker
85512 - Green Marker
85523 - Purple Marker
8553
8554When a user shows up on a map, each NPC is checked for questinfo that has been set.
8555If questinfo is present, it will check if the quest has been started, if it has not, the bubble will appear.
8556
8557Optionally, you can also specify a Job Class if the quest bubble should only appear for a certain class.
8558
8559Example
8560izlude,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
8574Place quest of <ID> in the users quest log, the state of which is "active".
8575
8576If *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
8582Change the state for the given quest <ID> to "complete" and remove from
8583the users quest log.
8584
8585If a second quest id of greater value is specified, all quests between the two
8586will be completed.
8587
8588---------------------------------------
8589
8590*erasequest <ID>{,<ID2>};
8591
8592Remove the quest of the given <ID> from the user's quest log.
8593
8594If a second quest id of greater value is specified, all quests between the two
8595will be erased.
8596
8597---------------------------------------
8598
8599*changequest <ID>,<ID2>;
8600
8601Remove quest of the given <ID> from the user's quest log.
8602Add quest of the <ID2> to the the quest log, and the state is "active".
8603
8604---------------------------------------
8605
8606*questprogress(<ID>{,PLAYTIME|HUNTING})
8607
8608If 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
8613If 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
8618If 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
8627Check whether the given quest is in its active state.
8628
8629Returns true if the quest is active, false otherwise (quest not started,
8630inactive or completed)
8631
8632---------------------------------------
8633
8634*showevent <icon>{,<mark color>}
8635
8636Show an emotion on top of a NPC, and optionally,
8637a colored mark in the mini-map like "viewpoint".
8638This is used to indicate that a NPC has a quest or an event to
8639a certain player.
8640
8641Available Icons:
8642
8643Remove 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
8650Warg : QTYPE_WARG
8651Warg Face : QTYPE_WARG2 (Only for packetver >= 20120410)
8652
8653Mark Color:
86540 - No Mark
86551 - Yellow Mark
86562 - Green Mark
86573 - Purple Mark
8658
8659---------------------------------------
8660//=====================================
86618 - End of Quest Log-Related Commands
8662//=====================================
8663---------------------------------------
8664
8665
8666---------------------------------------
8667//=====================================
86689 - Battlegrounds-Related Commands
8669//=====================================
8670---------------------------------------
8671
8672*waitingroom2bg_single(<battle group>,"<mapname>",<x>,<y>,"<npc name>");
8673
8674Adds the first waiting player from the chat room of given NPC to an
8675existing battleground group and warps it to specified coordinates on given
8676map.
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
8683the player group will respawn when they die.
8684<On Quit Event> refers to an NPC label that attaches to the character and
8685is run when they relog.
8686<On Death Event> refers to an NPC label that attaches to the character and
8687is run when they die. Can be "" for empty.
8688
8689Unlike the prior command, the latter will attach a GROUP in a waiting room
8690to the battleground, and sets the array $@arenamembers[0] where 0 holds
8691the IDs of the first group, and 1 holds the IDs of the second.
8692
8693If the option parameter is left out, the waiting room of the current NPC
8694is used.
8695
8696Example:
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
8706Update the respawn point of the given battle group to x, y on the same
8707map. The <Battle Group ID> can be retrieved using getcharid(4).
8708
8709Example:
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
8718Similar to warp command.
8719Place all members of <Battle Group> at <mapname> at x y.
8720
8721Example:
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
8731Similar to monster script command.
8732Spawn a monster with allegiance to the given battle group.
8733Does not allow for the summoning of multiple monsters.
8734Monsters are similar to that in War of Emperium, in that the specified
8735Battle group is considered friendly.
8736
8737Example:
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
8751This command will change the allegiance if a monster in a battle ground.
8752GID can be set when spawning the monster via the bg_monster command.
8753
8754Example:
8755
8756 end;
8757
8758OnEnable:
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
8764OnTimer1000:
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
8774Removes attached player from their Battle Group.
8775
8776----------------------------------------
8777
8778*bg_destroy <Batte Group>;
8779
8780As 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
8786Not exactly limited to battleground use, this will restore HP/SP in a
8787defined area at a percentage.
8788
8789Example:
8790 areapercentheal "bat_a01",52,208,61,217,100,100;
8791 end;
8792
8793----------------------------------------
8794
8795*bg_get_data(<Battle Group>,<type>);
8796
8797Retrieves data related to given battle group. Type can be one of the
8798following:
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
8806Retrieves amount of players belonging to given battle group on given map
8807within an specified rectangular area.
8808
8809----------------------------------------
8810
8811*bg_updatescore "<mapname>",<Guillaume Score>,<Croix Score>;
8812
8813This command will force the update of the displayed scoreboard.
8814It is only usable when the map is defined as a Type 2 Battleground:
8815mapflag%TAB%<mapname>%TAB%battleground%TAB%2
8816
8817---------------------------------------
8818//=====================================
88199 - End of Battlegrounds-Related Commands
8820//=====================================
8821---------------------------------------
8822
8823
8824---------------------------------------
8825//=====================================
882610 - Mercenary Commands
8827//=====================================
8828---------------------------------------
8829
8830*mercenary_create <class>,<contract time>;
8831
8832This command summons a mercenary of given class, for given amount of time
8833in milliseconds. Typically used in item scripts of mercenary scrolls.
8834
8835----------------------------------------
8836
8837*mercenary_heal <hp>,<sp>;
8838
8839This command works like 'heal', but affects the mercenary of the currently
8840attached character.
8841
8842----------------------------------------
8843
8844*mercenary_sc_start <type>,<tick>,<val1>;
8845
8846This command works like 'sc_start', but affects the mercenary of the
8847currently attached character.
8848
8849----------------------------------------
8850
8851*mercenary_get_calls(<guild>);
8852*mercenary_set_calls <guild>,<value>;
8853
8854Sets or gets the mercenary calls value for given guild for currently
8855attached 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
8866Sets or gets the mercenary faith value for given guild for currently
8867attached 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
8877Retrieves information about mercenary of the currently attached character.
8878If char id is given, the information of that character is retrieved
8879instead. Type specifies what information to retrieve and can be one of the
8880following:
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
8891If the character does not have a mercenary, the command returns ""
8892for name and 0 for all other types.
8893
8894---------------------------------------
8895//=====================================
889610 - End of Mercenary-Related Commands
8897//=====================================
8898---------------------------------------
8899
8900
8901---------------------------------------
8902//=====================================
890311 - Queue-Related Commands
8904//=====================================
8905---------------------------------------
8906
8907*queue();
8908
8909Creates a new queue instance and returns the created queue id.
8910
8911---------------------------------------
8912
8913*queuesize(<queue_id>);
8914
8915Returns the amount of entries in the queue instance of <queue_id>.
8916
8917---------------------------------------
8918
8919*queueadd(<queue_id>,<var_id>);
8920
8921Adds <var_id> to queue of <queue_id>, returning 1 if <var_id> is already
8922present in the queue, otherwise returning 0.
8923
8924---------------------------------------
8925
8926*queueremove(<queue_id>,<var_id>);
8927
8928Removes <var_id> from queue of <queue_id>, returning 1 if <var_id> is not
8929present in the queue, otherwise returning 0.
8930
8931---------------------------------------
8932
8933*queueopt(<queue_id>,<optionType>,{Optional <option val>});
8934
8935Modifies <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
8939Currently 3 options are available:
8940HQO_OnDeath (1), HQO_OnLogout (2), HQO_OnMapChange (3)
8941
8942Note: The constant names are not final.
8943
8944Example:
8945 queueopt(.@queue_id,0,"MyNPC::MyOnQueueMemberDeathEventName");
8946
8947---------------------------------------
8948
8949*queuedel(<queue_id>);
8950
8951Deletes <queue_id> and returns 1 when <queue_id> is not found, otherwise
89520 is returned.
8953
8954---------------------------------------
8955
8956*queueiterator(<queue_id>);
8957
8958Creates a new queue iterator instance.
8959A queue iterator is not a reference to a queue's actual members, it copies
8960the queues members when initialized, this way you can loop through them
8961even if you remove them from the queue.
8962
8963---------------------------------------
8964
8965*qicheck(<queue_iterator_id>);
8966checks whether there is a next member in the iterator's queue, 1 when
8967it does, 0 otherwise.
8968
8969---------------------------------------
8970
8971*qiget(<queue_iterator_id>);
8972
8973obtains the next member in the iterator's queue, returns the next member's
8974id or 0 when it doesnt exist.
8975
8976Example:
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
8985Deletes a queue iterator from memory and returns 1 when it fails,
8986otherwise 0 is returned.
8987
8988---------------------------------------
8989//=====================================
899011 - End of Queue-Related Commands
8991//=====================================
8992---------------------------------------
8993
8994---------------------------------------
8995//=====================================
899612 - NPC Trader-Related Commands
8997//=====================================
8998Commands that control NPC Trader Shops
8999See /doc/sample/npc_trader_sample.txt
9000---------------------------------------
9001
9002*openshop({NPC_Name});
9003
9004opens the trader shop from the currently-attached npc unless,
9005when the optional NPC_Name param is used.
9006
9007---------------------------------------
9008
9009*sellitem <Item_ID>{,<price>{,<qty>}};
9010
9011adds (or modifies) <Item_ID> data to the shop,
9012when <price> is not provided (or when it is -1) itemdb default is used.
9013qty is only necessary for NST_MARKET trader types.
9014
9015when <Item_ID> is already in the shop,
9016the previous data (price/qty), is overwritten with the new.
9017
9018---------------------------------------
9019
9020*stopselling <Item_ID>;
9021
9022attempts to remove <Item_ID> from the current shop list.
9023
9024---------------------------------------
9025
9026*setcurrency <Val1>{,<Val2>};
9027
9028updates the currently attached player shop funds,
9029to 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
9038Modifies the npc trader type, item list is cleared upon modifiying the value.
9039By 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
9050Signs that the transaction (on a NST_CUSTOM trader) has been successful,
9051to be used within a "OnPayFunds" event of a NST_CUSTOM trader.
9052
9053---------------------------------------
9054
9055*shopcount(<Item_ID>);
9056
9057Returns 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
9064Esse comando funciona é semelhante a outros comandos de AREA, ele serve para matar o que estiver na área determinada,
9065conforme o <tipo> que for indicado. O <tipo> é um parêmetro opcional, caso seja omitido o valor será 'zero'.
9066Os 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
9070Todos os monstros na área entre X 100 Y 110 e X 110 e Y 120, em uma área
9071quadrada, no mapa "prt_fild08", vão ser mortos.
9072
9073 areakill "prontera",150,150,180,180;
9074
9075Todos os jogadores na área entre X 150 Y 150 e X 180 e Y 180, em uma área
9076quadrada, no mapa "prontera", vão ser mortos.
9077
9078 areakill "izlude",80,50,100,80,2;
9079
9080Todos os jogadores e monstros na área entre X 80 Y 50 e X 100 e Y 80, em uma área
9081quadrada, no mapa "izlude", vão ser mortos.
9082
9083----------------------------------------------------
9084
9085*OnPCUseSkillEvent:
9086
9087Se trata de uma label que é ativada quando o personagem usa uma Skill(habilidade), possibilitando "qualquer" ação,
9088quando esta, for executada.
9089
9090"A imaginação é o limite!"
9091
9092Juntamente 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
9098Dessa forma você poderá comparar as skills. Sendo possÃvel obter o controle de qualquer skill dentro de uma condição.
9099
9100Simples exemplo de uso:
9101
9102- script OnPCUseSkillEvent_EXEMPLO -1,{
9103
9104OnPCUseSkillEvent:
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----------------------------------------------------