NASC — Reference

link color:FunctionsObjectsEventsEnums

QUESTS AND QUEST MEMOS (Quest / Memo)

26 functions

HaveMemoGLOBAL🟢 high

is the quest taken

The most frequent check in the whole group: does the character cCreature have an active memo of the given quest nQuestId (identifier from [quest_pch]). The function belongs to the global object (gg). Returns one (@TRUE) if the quest is taken, and zero if not.

Signature

HaveMemo( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — whom we check.
nQuestId (int) — the quest.
    values — from the [quest_pch] dictionary

Example

if ( HaveMemo( talker, @the_wishing_potion ) == 0 ) {

Usage example

if ( HaveMemo( target, @relics_of_the_old_empire ) == 1 ) {
    random1_list.SetInfo( 0, target );
}

GetMemoStateGLOBAL🟢 high

read the quest stage

Reads the numeric state of a quest — what SetMemoState wrote — for character cCreature and quest nQuestId (from [quest_pch]). The function belongs to the global object (gg). If there is no memo, it usually returns zero.

Signature

GetMemoState( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — the player.
nQuestId (int) — the quest.
    values — from the [quest_pch] dictionary

Example

i0 = GetMemoState( talker, @supplier_of_reagents );

Usage example

if ( HaveMemo( talker, @succession_to_the_legend_shillien_saint ) == 1 && talker.occupation == @shillien_elder && GetMemoState( talker, @succession_to_the_legend_shillien_saint ) == 14 && OwnItemCount( talker, @q_resonance_amulet6_29 ) == 0 && myself.i_quest0 == 1 && myself.sm.param2 == talker.dbid ) {
    ShowPage( talker, "abyss_maiden_elcardia_q0098_0110.htm" );
}

GetMemoStateExGLOBAL🟢 high

read a value from an additional slot

Reads the value from additional slot nSlot of the state of quest nQuestId (from [quest_pch]) for character cCreature — the counterpart of SetMemoStateEx. The function belongs to the global object (gg); the slot index is in the range 0…3.

Signature

GetMemoStateEx( CSharedCreatureData cCreature, int nQuestId, int nSlot )

Parameters

cCreature (CSharedCreatureData) — the player.
nQuestId (int) — the quest.
    values — from the [quest_pch] dictionary
nSlot (int) — slot index 03.

Example

i2 = GetMemoStateEx( talker, @gourd_event, 1 );

Usage example

i0 = GetMemoStateEx( talker, @seductive_whispers, 1 );
if ( i0 < 0 ) { i0 = 0; }

GetDailyQuestFlagGLOBAL🟢 high

check the daily quest flag

Checks the completion mark of the daily quest nQuestId (from [quest_pch]) for character cCreature. The function belongs to the global object (gg). The flag is automatically reset once a day early in the morning, after which the quest becomes available again.

Signature

GetDailyQuestFlag( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — the player.
nQuestId (int) — the daily quest.
    values — from the [quest_pch] dictionary

Example

if (GetDailyQuestFlag(talker, @daily_queen_ant) == 1)

Usage example

if (HaveMemo(talker, @proof_of_valrakas_hunting) == @FALSE && GetDailyQuestFlag(talker, @proof_of_valrakas_hunting) == @TRUE && OwnItemCount(talker, @q_floating_stone) >= 1 && talker.level >= 84) {
    ShowPage(talker, "watcher_valakas_klein_q0907_05.htm");
}

SetDailyQuestFlagGLOBAL🟢 high

set the daily quest flag

Marks that character cCreature has completed the daily quest nQuestId (from [quest_pch]). The counterpart of GetDailyQuestFlag; the flag is automatically reset once a day early in the morning, after which the quest becomes available again.

Signature

SetDailyQuestFlag( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — the creature that gets the daily quest completion flag
nQuestId (int) — identifier of the daily quest from the [quest_pch] dictionary
    values — from the [quest_pch] dictionary

Example

SetDailyQuestFlag(talker, @promise);

Usage example

else {
    SetDailyQuestFlag( talker, @daily_fall_of_the_dragon );
    CastBuffForQuestReward( talker, CHECK_SKILL );
    ShowPage( talker, "nevit_s_herald003.htm" );
}

SetMemoNPC🟢 high

grant (register) a quest

Creates a quest memo record on the character (argument cCreature, usually talker) — effectively grants the quest and registers it as active. The second argument nQuestId is the quest identifier from the [quest_pch] dictionary. The quest state is then managed by SetMemoState/GetMemoState; the purpose of the return value is unconfirmed.

Signature

SetMemo( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — who receives the quest (usually talker).
nQuestId  (int) — quest identifier (@...).
    values — from the [quest_pch] dictionary

Example

SetMemo( c1, @blood_offering );

Usage example

if ( HaveMemo( talker, @gourd_event ) == 0 ) {
    SetMemo( talker, @gourd_event );
}

RemoveMemoNPC🟢 high

remove a quest

Deletes the quest memo from character cCreature: the quest was completed or abandoned. The second argument nQuestId is a quest from [quest_pch]. After the call, HaveMemo for this quest starts returning zero; the purpose of the return value is unconfirmed.

Signature

RemoveMemo( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — whose quest is removed.
nQuestId  (int) — quest.
    values — from the [quest_pch] dictionary

Example

RemoveMemo( c1, @blood_offering );

Usage example

if ( i2 < 1262221261 ) {
    RemoveMemo( talker, @gourd_event );
}

GetMemoCountNPC🟢 high

how many quests the player has

Returns the number of active memos (quests taken simultaneously) on character cCreature. Used as a safeguard against overflow: a new quest is granted only if the player has fewer than the maximum allowed.

Signature

GetMemoCount( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — whose quests are counted.

Example

if ( GetMemoCount( talker ) < @MAX_QUEST_NUM ) {

Usage example

if ( GetMemoCount( talker ) >= 25 ) {
    ShowPage( talker, "fullquest.htm" );
    return;
}

SetMemoStateNPC🟢 high

write the quest stage

Writes the numeric state (stage) of a quest: for character cCreature and quest nQuestId (from [quest_pch]) it sets the value nState. The semantics of the number are entirely defined by the quest script itself — in some places it is 1, 2, 3, in others tens or even tens of thousands; the value can be assigned directly or incremented after reading the previous one.

Signature

SetMemoState( CSharedCreatureData cCreature, int nQuestId, int nState )

Parameters

cCreature (CSharedCreatureData) — player.
nQuestId  (int) — quest.
    values — from the [quest_pch] dictionary
nState    (int) — new state/stage.

Example

SetMemoState( c1, @testimony_of_trust, 3 );

Usage example

if ( reply == 71 && HaveMemo( talker, @in_the_name_of_evil_part2 ) == 1 && GetMemoState( talker, @in_the_name_of_evil_part2 ) == 407 && GetOneTimeQuestFlag( talker, @in_the_name_of_evil_part2 ) == 0 ) {
    SetMemoState( talker, @in_the_name_of_evil_part2, 408 );
    ShowPage( talker, "asama_q0126_26.htm" );
}

SetMemoStateExNPC🟢 high

write a value to an additional slot

Writes the value nState into the additional slot nSlot of the state of quest nQuestId (from [quest_pch]) for character cCreature. Unlike SetMemoState, which has a single main state, it provides several independent numeric cells addressed by slot number (indices 0…3 — four cells per quest).

Signature

SetMemoStateEx( CSharedCreatureData cCreature, int nQuestId, int nSlot, int nState )

Parameters

cCreature (CSharedCreatureData) — player.
nQuestId  (int) — quest.
    values — from the [quest_pch] dictionary
nSlot     (int) — slot index 03 (4 cells per quest: 0→nState, 1→nState2, 2→nState3, 3→nState4). Confirmed by the source code.
nState    (int) — value for the slot.

Example

SetMemoStateEx( talker, @four_goblets, 2, i0 );

Usage example

if ( ( i0 % 10 ) == 0 ) {
    SetMemoStateEx( talker, @resurrection_of_old_manager, 1, ( i0 + 1 ) );
}

SetFlagJournalNPC🟢 high

update the journal step

Changes the quest step visible to the player in the quest window: for character cCreature and quest nQuestId (from [quest_pch]) it sets the displayed step number nStep. This is the quest's "storefront", whereas SetMemoState is its internal machinery; the two calls often stand side by side and operate on the same number, but sometimes the internal state and the displayed step deliberately diverge.

Signature

SetFlagJournal( CSharedCreatureData cCreature, int nQuestId, int nStep )

Parameters

cCreature (CSharedCreatureData) — player.
nQuestId (int) — quest.
    values — from the [quest_pch] dictionary
nStep (int) — step number to display.

Example

SetFlagJournal( c1, @testimony_of_life, 5 );

Usage example

if ( OwnItemCount( c1, @ol_mahum_runestone ) >= 1 && OwnItemCount( c1, @turek_runestone ) >= 1 && OwnItemCount( c1, @turak_bugbear_runestone ) >= 1 ) {
    SetFlagJournal( c1, @trial_of_the_seeker, 5 );
    ShowQuestMark( c1, @trial_of_the_seeker );
}

ShowQuestMarkNPC🟢 high

quest mark

Shows player cCreature a quest indicator — the familiar quest-received mark effect for a specific quest nQuestId (from [quest_pch]). Usually called right after granting the memo.

Signature

ShowQuestMark( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — player.
nQuestId (int) — quest.
    values — from the [quest_pch] dictionary

Example

ShowQuestMark( c1, @testimony_of_life );

ShowQuestionMarkNPC🟢 high

question mark

Shows player cCreature a quest mark above the head. The second argument nQuestId is a quest identifier from [quest_pch]: the mark shown is that of this specific quest. In scripts it is written as a raw number (a value from [quest_pch]) rather than an @-name, so at first it looks like an abstract "code"; verification confirmed these numbers match quest IDs (small 1…32 — the classic range, large 10021…10650 — the extended and custom range).
Related event: a click on the "?" arrives as the QUESTION_MARK_CLICKED(talker, question_id) event (see NASC_HANDLERS).

Signature

ShowQuestionMark( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — player.
nQuestId  (int) — quest whose mark to show.
    values — from the [quest_pch] dictionary

Example

ShowQuestionMark(talker, 26);

Usage example

if ( i3 == 3 ) {
    ShowQuestionMark( talker, 5 );
    SoundEffect( talker, "ItemSound.quest_tutorial" );
}

ShowQuestionMark2NPC🟢 high

extended quest mark (hypothesis)

A delayed variant of ShowQuestionMark: shows the quest mark not immediately, but after a given delay. Per the decompiled code, the engine sets a timer (CShowQuestionMarkTimer) and, when it fires, shows the mark of quest nQuestId above the creature's head. The first numeric argument is a quest ID from [quest_pch] (as in ShowQuestionMark), the second is the delay in SECONDS (converted internally to ms: nDelay·1000). No live calls found in the scripts.
Related event: a click on the "?" arrives as the QUESTION_MARK_CLICKED(talker, question_id) event (see NASC_HANDLERS).

Signature

ShowQuestionMark2( CSharedCreatureData cCreature, int nQuestId, int nDelay )

Parameters

    cCreature (CSharedCreatureData) — creature to which the question mark is shown
    nQuestId  (int) — quest identifier from the [quest_pch] dictionary
    nDelay    (int) — delay in seconds before showing the mark (the engine sets a timer for nDelay·1000 ms). Confirmed by the decompiled code.

Example (illustrative):

    ShowQuestionMark2( talker, nQuestId, nDelay );

ShowQuestPageNPC🟢 high

quest html page

Shows player cCreature a dialog html page (argument sHtmlName — name of the html file) bound to a specific quest nQuestId (from [quest_pch]). Essentially this is ShowPage, but with the quest specified, so the window opens in the correct quest context.

Signature

ShowQuestPage( CSharedCreatureData cCreature, string sHtmlName, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — player.
sHtmlName (string) — html file name.
nQuestId  (int) — quest.
    values — from the [quest_pch] dictionary

Example

ShowQuestPage(talker, "arujien_q0002_00.htm", @what_women_want);

Usage example

if ( GetMemoCount( talker ) < @MAX_QUEST_NUM ) {
    ShowQuestPage( talker, "blacksmith_wilbert_q0663_01.htm", @seductive_whispers );
} else {
    ShowPage( talker, "fullquest.htm" );
}

ShowQuestFHTMLNPC🟢 high

quest page from an html object

Does the same as ShowQuestPage, but the page is not taken from a ready-made file — it is assembled on the fly as a CFHTML object (argument fhtml). The third argument nQuestId is a quest from [quest_pch]. No direct calls found in the collection.

Signature

ShowQuestFHTML( CSharedCreatureData cCreature, CFHTML fhtml, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — player.
fhtml     (CFHTML) — dynamic html object.
nQuestId  (int) — quest.
    values — from the [quest_pch] dictionary

Example

ShowQuestFHTML( talker, fhtml0, @black_swan );

ShowQuestInfoListNPC🟢 high

NPC quest list

Opens for player cCreature the quest list or quest window of this NPC — a listing of available quests. No direct calls found in the collection.

Signature

ShowQuestInfoList( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — player.

Example

ShowQuestInfoList(talker);

SetCurrentQuestIDNPC🟢 high

assign the "current quest"

Declares which quest nQuestId (from [quest_pch]) is considered current in this handling: after the call, subsequent quest actions of the NPC apply to that quest. Usually placed at the very start of processing the player's dialog choice; the purpose of the return value is unconfirmed.

Signature

SetCurrentQuestID( int nQuestId )

Parameters

nQuestId (int) — quest to make "current".
    values — from the [quest_pch] dictionary

Example

SetCurrentQuestID( @q_mimirs_elixir );

Usage example

if ( _from_choice == 0 || ( HaveMemo( talker, @find_sir_windawood ) == 0 && GetOneTimeQuestFlag( talker, @find_sir_windawood ) == 1 ) ) {
    SetCurrentQuestID( @find_sir_windawood );
    ShowPage( talker, "finishedquest.htm" );
}

CheckAndSetTransactMemoNPC🟢 high

double-grant protection

An atomic transaction "lock" for character cCreature: in a single action it checks whether an operation is already in progress for this player and immediately sets the busy flag. Returns @TRUE if it is safe to proceed (the lock was successfully acquired), and @FALSE if a grant is already being performed — in that case the script aborts and the reward is not given out twice. Its counterpart ResetTransactMemo releases the lock (commits the transaction) after the operation completes successfully.

Signature

CheckAndSetTransactMemo( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — player.

Example

if ( CheckAndSetTransactMemo( talker ) == @FALSE ) { return; }

Usage example

if ( CheckAndSetTransactMemo( talker ) ) {
    GiveItem1( talker, @q_adventure_coupon1, 1 );
    SetOneTimeQuestFlag( talker, @207, 1 );
    ShowPage( talker, fnCoupon1Ok );
}

TriggerCompleteQuestNPC🟢 high

complete a quest asynchronously

Queues an atomic server task that asynchronously marks quest nQuestId (from [quest_pch]) as completed for character cCreature. Unlike the manual combination of RemoveMemo plus SetOneTimeQuestFlag, it is executed by the engine as a single transaction — without races, updating all server-side bookkeeping of quest completion.

Signature

TriggerCompleteQuest( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — player.
nQuestId (int) — quest.

Example

TriggerCompleteQuest(target, @tiat);

GetAccountQuestCompleteCountNPC🟢 high

per-account completion counter

Reads the completion counter of quest nQuestId (from [quest_pch]) for the game account of character c, rather than for the individual character. Used for "once per account" limits — for a reward or quest that cannot be completed again by another character of the same account.

Signature

GetAccountQuestCompleteCount( CSharedCreatureData c, int nQuestId )

Parameters

    c (CSharedCreatureData) — player (their account is used).
    nQuestId (int) — quest.

Example (illustrative):

    GetAccountQuestCompleteCount( talker, nQuestId );

IncrementAccountQuestCompleteCountNPC🟢 high

increment the per-account completion counter

Increments the completion counter of quest nQuestId (from [quest_pch]) for the game account of character c. Counterpart of GetAccountQuestCompleteCount; serves for "once per account" limits.

Signature

IncrementAccountQuestCompleteCount( CSharedCreatureData c, int nQuestId )

Parameters

    c (CSharedCreatureData) — creature whose game account gets the quest completion counter incremented
    nQuestId (int) — quest identifier from the [quest_pch] dictionary

Example (illustrative):

    IncrementAccountQuestCompleteCount( talker, nQuestId );

GetOneTimeQuestFlagNPC🟢 high

check a one-time event flag

Reads the flag of a one-time quest or event for character cCreature — a mark that they have already done something unrepeatable. The second argument nFlagId is resolved through [quest_pch] (in scripts it also appears as a number). Returns one if already done, zero otherwise; often placed right after a HaveMemo check, to distinguish "quest not taken yet" from "quest already completed at some point".

Signature

GetOneTimeQuestFlag( CSharedCreatureData cCreature, int nFlagId )

Parameters

cCreature (CSharedCreatureData) — player.
nFlagId   (int) — identifier of the one-time quest/event.
    values — from the [quest_pch] dictionary

Example

if ( GetOneTimeQuestFlag( talker, @in_the_name_of_evil_part1 ) == 0 ) {

Usage example

if ( HaveMemo( talker, @in_the_name_of_evil_part2 ) == 0 && talker.level >= 77 && GetOneTimeQuestFlag( talker, @in_the_name_of_evil_part1 ) != 0 && GetOneTimeQuestFlag( talker, @in_the_name_of_evil_part2 ) == 0 ) {
    ShowPage( talker, "asama_q0126_05.htm" );
}

SetOneTimeQuestFlagNPC🟢 high

set a one-time event flag

Sets or clears the flag of a one-time quest/event for character cCreature: argument nFlagId (from [quest_pch]) specifies the event, and nValue equal to 1 marks it as done while 0 removes the mark. Counterpart of GetOneTimeQuestFlag.

Signature

SetOneTimeQuestFlag( CSharedCreatureData cCreature, int nFlagId, int nValue )

Parameters

cCreature (CSharedCreatureData) — player.
nFlagId   (int) — identifier of the one-time quest/event.
    values — from the [quest_pch] dictionary
nValue    (int) — 1 — done, 0 — reset.

Example

SetOneTimeQuestFlag( talker, @blood_fiend, 1 );

Usage example

if ( i1 > 0 ) {
    SetOneTimeQuestFlag( c0, i1, 0 );
}

CastBuffForQuestReward2NPC🟢 high

buff as a reward

Applies a buff to character cCreature (often myself.sm) as a quest reward or effect, specifying the skill by its name-identifier nSkillNameId from the [skill_pch] dictionary. This is a "service" cast: it does not depend on the desire queue or combat restrictions, so it fires guaranteed.

Signature

CastBuffForQuestReward2( CSharedCreatureData cCreature, int skillname_id )

Parameters

cCreature (CSharedCreatureData) — buff target (often myself.sm).
skillname_id (int) — skill/buff (@s_...).

Example

CastBuffForQuestReward2( talker, @s_wind_walk2);

Usage example

if ( i5 <= 0 && Rand( 100 ) < LongRangeGuardRate ) {
    CastBuffForQuestReward2( myself.sm, @s_npc_ultimate_defence3 );
}

CastBuffForQuestRewardNPC🟢 high

buff as a reward (older variant)

An older variant of CastBuffForQuestReward2 — applies a reward buff to character cCreature. The second argument is a buff skill from the [skill_pch] dictionary (in calls @s_npc_haste1, @s_npc_ultimate_defence3 or a local variable Buff holding such an id).

Signature

CastBuffForQuestReward( CSharedCreatureData cCreature, int nSkillNameId )

Parameters

cCreature    (CSharedCreatureData) — buff target.
nSkillNameId (int) — skill/buff (@s_...).
    values — from the [skill_pch] dictionary

Example

CastBuffForQuestReward( talker, @s_npc_haste1 );

Usage example

if ( DistFromMe( c0 ) <= 75 ) {
    CastBuffForQuestReward( c0, Buff );
}

ITEMS (Item)

18 functions

OwnItemCountGLOBAL🟢 high

total count of items of a class on a creature

Returns the total number of items of class nItemClassId (from [item_pch]) that creature c (usually talker) has. Enchant level and augmentation are ignored — all instances are counted. The basic way to check for a quest item or find out the amount of adena.

Signature

OwnItemCount( CSharedCreatureData c, int nItemClassId )

Parameters

c (CSharedCreatureData) — whose items we count (usually talker).
nItemClassId (int) — item class (@adena, @official_letter…).
    values — from the [item_pch] dictionary

Example

i1 = OwnItemCount( talker, @q_watching_eyes );

Usage example

if ( HaveMemo( talker, @succession_to_the_legend_shillien_saint ) == 1 && talker.occupation == @shillien_elder && GetMemoState( talker, @succession_to_the_legend_shillien_saint ) == 14 && OwnItemCount( talker, @q_resonance_amulet6_29 ) == 0 && myself.i_quest0 == 1 && myself.sm.param2 == talker.dbid ) {
    ShowPage( talker, "abyss_maiden_elcardia_q0098_0110.htm" );
}

OwnItemCount2GLOBAL🟢 high

item count taking augmentation into account

Same as OwnItemCount, but with an extra flag bFindAugment: for creature c it counts the number of items of class nItemClassId (from [item_pch]), and with bFindAugment = 1 the count takes augmentation into account, while with 0 the function behaves like a regular OwnItemCount.

Signature

OwnItemCount2( CSharedCreatureData c, int nItemClassId, int bFindAugment )

Parameters

    c (CSharedCreatureData) — whose items we count.
    nItemClassId (int) — item class.
    bFindAugment (int) — take augmentation into account (0/1).

Example (illustrative):

    OwnItemCount2( talker, nItemClassId, bFindAugment );

OwnItemCountEx2GLOBAL🟢 high

count filtered by enchant level and augmentation

The most complete counter: for creature c it counts items of class nItemClassId (from [item_pch]), filtering simultaneously by enchant level nEnchantLevel and by augmentation (bFindAugment, 0/1). Combines the capabilities of OwnItemCountEx and OwnItemCount2.

Signature

OwnItemCountEx2( CSharedCreatureData c, int nItemClassId, int nEnchantLevel, int bFindAugment )

Parameters

    c (CSharedCreatureData) — whose items we count.
    nItemClassId (int) — item class.
    nEnchantLevel (int) — required enchant level.
    bFindAugment (int) — take augmentation into account (0/1).

Example (illustrative):

    OwnItemCountEx2( talker, nItemClassId, nEnchantLevel, bFindAugment );

OwnItemEnchantCountGLOBAL🟢 high

enchant level of an owned item

Returns the enchant level of the item of class nItemClassId (from [item_pch]) owned by creature c — NOT the number of pieces (the name is misleading). If the item is absent, returns 0. If the player has several matching instances with different enchant levels, the function returns the enchant level of the LAST one found while traversing the inventory (not the maximum and not the sum) — do not rely on this; the check is intended for a single item.

Signature

OwnItemEnchantCount( CSharedCreatureData cCreature, int nItemClassId )

Parameters

cCreature    (CSharedCreatureData) — whose inventory we look at.
nItemClassId (int) — item class.
    values — from the [item_pch] dictionary

Example

i0 = OwnItemEnchantCount(talker, @ev_fake_dualblunt);
i0 = OwnItemEnchantCount( talker, talker.equiped_weapon_class_id );
i0 = OwnItemEnchantCount( talker, yogy_staff );

GetItemCollectableGLOBAL🟢 high

are there spoil items ready to collect

Returns 1 if creature cCreature has spoil items ready to collect, otherwise 0. Essentially this is a check of whether the loot on a spoiled mob can be swept (collected) right now.

Signature

GetItemCollectable( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature being checked (a mob with spoil).

Example

if (GetItemCollectable(myself.sm) == @TRUE)

Usage example

if ( GetItemCollectable( myself.sm ) == 1 ) {
    if ( Rand( 5 ) < 2 ) {
        CreateOnePrivateEx( @dragon_knight_5, "dragon_knight_5", 0, 0, FloatToInt( myself.sm.x ), FloatToInt( myself.sm.y ), FloatToInt( myself.sm.z ), 0, 1000, GetIndexFromCreature( myself.top_desire_target ), 0 );
    }
} else
if ( Rand( 5 ) < 1 ) {
    CreateOnePrivateEx( @dragon_knight_5, "dragon_knight_5", 0, 0, FloatToInt( myself.sm.x ), FloatToInt( myself.sm.y ), FloatToInt( myself.sm.z ), 0, 1000, GetIndexFromCreature( myself.top_desire_target ), 0 );
}

OwnItemCountExNPC🟢 high

count items with a specific enchant level

Counts the number of items of class nItemClassId (from [item_pch]) owned by creature c, but only with the specific enchant level nEnchantLevel. Handy when the enchanted version of the item is what matters. Returns the number of matching instances.

Signature

OwnItemCountEx( CSharedCreatureData cCreature, int nItemClassId, int nEnchantLevel )

Parameters

cCreature     (CSharedCreatureData) — whose items are counted.
nItemClassId  (int) — item class.
    values — from the [item_pch] dictionary
nEnchantLevel (int) — required enchant level.

Example

if (IsInCategory(@third_class_group, talker.occupation) == 1 && OwnItemCountEx(talker, 5708, GetSSQRoundNumber()) > 0) {

Usage example

if ( IsInCategory( @third_class_group, talker.occupation ) == 1 && OwnItemCountEx( talker, @the_lord_of_manor_s_agreement, GetSSQRoundNumber( ) ) > 0 ) {
    ShowPage( talker, szName + "_" + QUEST_ID + "_07.htm" );
}

GiveItem1NPC🟢 high

give an item into the inventory

Gives creature c (usually talker or target) nCount pieces of item nItemClassId (from [item_pch]) without enchant. The most common way to hand over a quest item or reward. If nCount is computed and comes out as 0, the item is effectively not given.

Signature

GiveItem1( CSharedCreatureData cCreature, int nItemClassId, int64 nCount )

Parameters

cCreature    (CSharedCreatureData) — who receives it (usually talker/target).
nItemClassId (int) — item class.
    values — from the [item_pch] dictionary
nCount       (int64) — count.

Example

GiveItem1( talker, @q_info_urz, 1 );

Usage example

if ( i1 == 3 ) {
    GiveItem1( c1, @demon_s_gloves_fabric, 1 );
}

GiveItemExNPC🟢 high

give an item with a given enchant level

Like GiveItem1, but gives creature c nCount pieces of item nItemClassId (from [item_pch]) with the specified enchant level nEnchantLevel. Used for reward items with a fixed or random enchant level.

Signature

GiveItemEx( CSharedCreatureData cCreature, int nItemClassId, int nEnchantLevel, int64 nCount )

Parameters

cCreature     (CSharedCreatureData) — who receives it.
nItemClassId  (int) — item class.
    values — from the [item_pch] dictionary
nEnchantLevel (int) — enchant level of the given item.
nCount        (int64) — count.

Example

GiveItemEx( talker, @br_xmas_shirts, 6, 1 );

Usage example

if ( OwnItemCount( talker, @br_xmas_wpn_ticket_normal ) > 0 ) {
    GiveItemEx( talker, i1, 4 + Rand( 13 ), 1 );
    DeleteItem1( talker, @br_xmas_wpn_ticket_normal , 1 );
    ShowPage( talker, "br_xmas_wannabe_santa2024.htm" );
} else {
    ShowPage( talker, "br_xmas_wannabe_santa2023.htm" );
}

GiveEventItemNPC🟢 high

atomic item exchange within an event

Performs an exchange in a single action: takes from pTarget (usually talker) nReqAmount pieces of item nReqItemId (from [item_pch], e.g. @adena) and in return gives nGiveAmount pieces of item nGiveItemId (also from [item_pch]). The nId argument specifies the event identifier or category, and nTimeLimit is the time limit in hours on the temporary item given out. There is an extended version, GiveEventItem2, that for a single payment gives two different items at once.

Signature

GiveEventItem( CSharedCreatureData pTarget, int nReqItemId, int64 nReqAmount, int nGiveItemId, int64 nGiveAmount, int nId, int nTimeLimit )

Parameters

pTarget (CSharedCreatureData) — to whom / from whom (usually talker).
nReqItemId (int) — what to take (the payment, e.g. @adena).
    values — from the [item_pch] dictionary
nReqAmount (int64) — how much to take.
nGiveItemId (int) — what to give.
    values — from the [item_pch] dictionary
nGiveAmount (int64) — how much to give.
nId (int) — event id/category.
nTimeLimit (int) — lifetime of the given item (hours).

Example

GiveEventItem( talker, @adena, 500, search_scroll, 1, 0, 12 );

Usage example

if ( reply == 1 ) {
    GiveEventItem( talker, @adena, 1, event_present_skill, 1, 0, 20 );
}

DeleteItem1NPC🟢 high

take an item from a creature

Deletes (confiscates) from creature c nCount pieces of item nItemClassId (from [item_pch]). A common trick is to take all instances by passing OwnItemCount of the same item as the count. Used when completing quests (to collect quest items) and for payments (to deduct adena).

Signature

DeleteItem1( CSharedCreatureData cCreature, int nItemClassId, int64 nCount )

Parameters

cCreature    (CSharedCreatureData) — from whom to take.
nItemClassId (int) — item class.
    values — from the [item_pch] dictionary
nCount       (int64) — how many to take.

Example

DeleteItem1( talker, @lunargent, 1 );

Usage example

if ( OwnItemCount( talker, @adena ) >= GetCookie( talker, "AgitDecoFee" ) ) {
    DeleteItem1( talker, @adena, GetCookie( talker, "AgitDecoFee" ) );
    ShowPage( talker, fnAfterSetDeco );
} else {
    ShowPage( talker, fnNotEnoughAdena );
}

DeleteItemExNPC🟢 high

take an item with a specific enchant level

Deletes from creature c nCount pieces of item nItemClassId (from [item_pch]) with the specific enchant level nEnchantLevel — targeted removal of the enchanted version, counterpart of OwnItemCountEx. The argument order was inferred by analogy with GiveItemEx and OwnItemCountEx.

Signature

DeleteItemEx( CSharedCreatureData cCreature, int nItemClassId, int nEnchantLevel, int64 nCount )

Parameters

    cCreature     (CSharedCreatureData) — from whom to take.
    nItemClassId  (int) — item class.
        values — from the [item_pch] dictionary
    nEnchantLevel (int) — enchant level.
    nCount        (int64) — how many to take.

Example (illustrative):

    DeleteItemEx( talker, nItemClassId, nEnchantLevel, nCount );

DropItem1NPC🟢 high

drop an item on the ground

Drops item nItemClassId (from [item_pch]) in quantity nCount on the ground near the NPC so that creature c — the drop owner — can pick it up. Unlike GiveItem1, which puts the thing directly into the inventory, here the item appears on the ground. Often used by bosses and summons to hand a reward to the summoner (myself.sm).

Signature

DropItem1( CSharedCreatureData cCreature, int nItemClassId, int64 nCount )

Parameters

cCreature    (CSharedCreatureData) — drop owner (who can pick it up).
nItemClassId (int) — item class.
    values — from the [item_pch] dictionary
nCount       (int64) — count.

Example

DropItem1(myself.sm, @key_of_controller, 1);

Usage example

if (Rand(100) < 50) {
    DropItem1(myself.sm, 8192, 1);
}

DropItem2NPC🟢 high

drop an item with an explicit owner

Like DropItem1, but with an explicit drop-owner id nOwnerId — who is allowed to pick up item nItemClassId (from [item_pch]) in quantity nCount. In raids, the summoner's identifier is passed there so that the drop goes to a specific player rather than to anyone.

Signature

DropItem2( CSharedCreatureData cCreature, int nItemClassId, int64 nCount, int nOwnerId )

Parameters

cCreature    (CSharedCreatureData) — creature that is the drop context.
nItemClassId (int) — item class.
    values — from the [item_pch] dictionary
nCount       (int64) — count.
nOwnerId     (int) — owner id (who can pick it up).

Example

DropItem2( c1, @crystal_a, 4, myself.sm.summoner_id );

Usage example

if ( i1 == 0 ) {
    DropItem2( myself.sm, @green_soul_crystal_12, 1, myself.sm.summoner_id );
}

DropItemsNPC🟢 high

drop from the NPC's configured drop lists

Initiates a drop of items from the NPC's own preconfigured drop lists (defined in the mob's data), rather than a single specific item. The nDropListMask argument is a bit mask selecting which drop sets to use (bits are combined), and pDropOwner specifies who gets the loot.

Signature

DropItems( int nDropListMask, CSharedCreatureData pDropOwner )

Parameters

    nDropListMask (int) — drop-list bit mask.
    pDropOwner (CSharedCreatureData) — drop owner.

Example (illustrative):

    DropItems( nDropListMask, talker );

GetItemDataNPC🟢 high

get an item descriptor

Returns the descriptor object (CSharedItemData) of an item of class nItemClassId (from [item_pch]) owned by creature c — for subsequent access to its fields or for passing to other functions. In scripts it is often called right after giving the item, to work with the specific instance.

Signature

GetItemData( CSharedCreatureData cCreature, int nItemClassId )

Parameters

cCreature    (CSharedCreatureData) — whose item is fetched.
nItemClassId (int) — item class.
    values — from the [item_pch] dictionary

Example

GetItemData(talker, @baby_cougar_chime);

Usage example

item0 = GetItemData( talker, @manacles_of_redemption );
if ( item0 ) {
    DestroyPet( talker, item0.dbid, item0.pet_level );
}

UseItemNPC🟢 high

make the NPC use an item

Presumably makes the NPC use the item specified by the single argument. The exact domain of the argument is unconfirmed (inventory index vs. item class), no direct calls found in the collection, so the behavior is described with caution.

Signature

UseItem( int nItem )

Parameters

    nItem (int) — item the NPC uses (inventory index or item class, domain unconfirmed — 0 calls)

Example (illustrative):

    UseItem( nItem );

UseCategoryItemNPC🟢 high

use an item from a category

Presumably makes the NPC use an item from the category specified by the single argument. Behavior unconfirmed, no calls in the collection.

Signature

UseCategoryItem( int nCategory )

Parameters

    nCategory (int) — item category from which the NPC uses an item (purpose unconfirmed — 0 calls)

Example (illustrative):

    UseCategoryItem( nCategory );

EquipItemNPC🟢 high

equip an item on the NPC

Makes the NPC equip an item: the single argument nItemClassId is resolved through [item_pch], i.e. it is an item class. No direct calls found in the collection.

Signature

EquipItem( int nItemClassId )

Parameters

nItemClassId (int) — class of the item to equip.
    values — from the [item_pch] dictionary

Example

EquipItem(@npc_invisi_1hs);

Usage example

if (timer_id == 1525007) {
    EquipItem(OHS_Weapon1);
}

Inventory

4 functions

GetInventoryInfoNPC🟢 high

numeric inventory metric of a creature

Returns a numeric inventory metric of creature cCreature — which one is selected by the second argument nInfoType (@IPT_*): @IPT_CURRENT_SLOT_COUNT/@IPT_MAX_SLOT_COUNT (used/maximum slots), @IPT_CURRENT_WEIGHT/@IPT_MAX_CARRY_WEIGHT (current/maximum weight), @IPT_CURRENT_QUEST_SCOUNT/@IPT_MAX_QUEST_SCOUNT (quest slots). The classic use is checking free space and overweight before handing out a reward.

Signature

GetInventoryInfo( CSharedCreatureData cCreature, int Type )

Parameters

cCreature (CSharedCreatureData) — creature whose inventory metric is requested
Type (int) — which inventory metric to return
    Constants from [manual_pch] are used:
        @IPT_CURRENT_SLOT_COUNT   (0) — inventory slots currently used
        @IPT_MAX_SLOT_COUNT       (1) — maximum inventory slots
        @IPT_CURRENT_WEIGHT       (2) — current carried weight
        @IPT_MAX_CARRY_WEIGHT     (3) — maximum carry weight
        @IPT_CURRENT_QUEST_SCOUNT (4) — quest slots currently used
        @IPT_MAX_QUEST_SCOUNT     (5) — maximum quest slots

Example

if ( GetInventoryInfo( talker, @IPT_CURRENT_SLOT_COUNT ) >= ( GetInventoryInfo( talker, @IPT_MAX_SLOT_COUNT ) * 0.800000 ) || GetInventoryInfo( talker, @IPT_CURRENT_WEIGHT ) >= ( GetInventoryInfo( talker, @IPT_MAX_CARRY_WEIGHT ) * 0.800000 ) ) {

Usage example

if ( GetInventoryInfo( talker, @IPT_CURRENT_SLOT_COUNT ) >= ( GetInventoryInfo( talker, @IPT_MAX_SLOT_COUNT ) * 0.800000 ) || GetInventoryInfo( talker, @IPT_CURRENT_WEIGHT ) >= ( GetInventoryInfo( talker, @IPT_MAX_CARRY_WEIGHT ) * 0.800000 ) ) {
    ShowSystemMessage( talker, 1118 );
    return;
}

UseSoulShotNPC🟢 high

the NPC uses soulshots

The NPC uses soulshots (a physical attack boost) for nCount charges.

Signature

UseSoulShot( int nCount )

Parameters

nCount (int) — the number of soulshot charges used (in calls 10, 20, the variable SoulShot).

Example

UseSoulShot( SoulShot );
UseSoulShot( 20 );
UseSoulShot(10);

UseSpiritShotNPC🟢 high

the NPC uses spiritshots

The NPC uses spiritshots (a magic attack boost). Per the L2NPC decompile
(CNPC::UseSpiritShot_489FE0) the engine sends the server a packet opcode 113, where the shot type is hardcoded
(=1, spiritshot), and the first argument is the number of charges; two more arguments are named in scripts
SpeedBonus/HealBonus and are passed together with the use.

Signature

UseSpiritShot( int nCount, int nSpeedBonus, int nHealBonus )

Parameters

nCount (int) — the number of spiritshot charges used (in calls 20, the variable SpiritShot).
nSpeedBonus (int) — the use-speed bonus (in scripts SpeedBonus/SpiritShotSpeedBonus).
nHealBonus (int) — the restore bonus (in scripts HealBonus/SpiritShotHealBonus).

Example

UseSpiritShot( SpiritShot, SpeedBonus, HealBonus );
UseSpiritShot( SpiritShot, SpiritShotSpeedBonus, SpiritShotHealBonus );
UseSpiritShot( 20, SpeedBonus, HealBonus );

IsSpoiledNPC🟢 high

is spoil applied to the NPC

Returns whether this NPC is already spoiled (whether spoil is applied): 1 or 0.

Signature

IsSpoiled(  )

Parameters

(none — the function is called without arguments)

Example

if ( Rand( 100 ) < 50 && c1.occupation == @scavenger && IsSpoiled( ) == 1 ) {

Usage example

if ( Rand( 100 ) < 50 && c1.occupation == @scavenger && IsSpoiled( ) == 1 ) {
    i0 = ( i0 + 1 );
}

Skills, abnormals and buffs (Skill / Abnormal)

27 functions

Skill_GetAbnormalLevelGLOBAL🟢 high

level of the effect a skill applies

Returns the level of the effect that a skill applies. Paired with GetAbnormalLevel(creature, Skill_GetAbnormalType(s)) it lets you determine whether this buff is already on the target at full strength (if the current level is not lower than the skill's level — the buff is present). This is exactly how buffers gray out the buttons of already-granted buffs. The argument nSkillId is a skill from [skill_pch].

Signature

Skill_GetAbnormalLevel( int nSkillId )

Parameters

nSkillId (int) — the skill.
    values — from the [skill_pch] dictionary

Example

if (GetAbnormalLevel(talker, Skill_GetAbnormalType(buff1)) >= Skill_GetAbnormalLevel(buff1)) { FHTML_SetStr(fhtml0, "bypass_buff1", _blank); FHTML_SetFStr(fhtml0, "button_type1", 36810606, _blank, _blank, _blank, _blank, _blank); }

Usage example

if (GetAbnormalLevel(talker, Skill_GetAbnormalType(buff1)) >= Skill_GetAbnormalLevel(buff1)) { FHTML_SetStr(fhtml0, "bypass_buff1", _blank); FHTML_SetFStr(fhtml0, "button_type1", 36810606, _blank, _blank, _blank, _blank, _blank); }
else { FHTML_SetStr(fhtml0, "bypass_buff1", "bypass -h menu_select?ask=-301&reply=1"); FHTML_SetFStr(fhtml0, "button_type1", 36810605, _blank, _blank, _blank, _blank, _blank); }

Skill_IsMagicGLOBAL🟢 high

is the skill magical or physical

Reports whether a skill is magical (1) or physical (0). Based on this attribute the AI picks a counter-effect: against physical it uses a shield slam, against magic — a silence, and so on. The argument nSkillId is a skill from [skill_pch].

Signature

Skill_IsMagic( int nSkillId )

Parameters

nSkillId (int) — the skill.
    values — from the [skill_pch] dictionary

Example

if (Skill_IsMagic(Skill01_ID) == 0 && (GetAbnormalLevel(myself.sm, Skill_GetAbnormalType(@s_shield_slam1)) > 0 || GetAbnormalLevel(myself.sm, Skill_GetAbnormalType(@s_curse_of_doom1)) > 0))

SetSkillAllGLOBAL🟢 high

grant all skills

Grants a creature all skills at once — a debug/service command. According to the decompile it sends
the server an asynchronous command (like IsToggleSkillOnOff — not an immediate request). Returns no
result to the script. The argument c is who receives them; if c is empty, does nothing.

Signature

SetSkillAll( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature that is granted all skills

Example

SetSkillAll(talker);

Usage example

if( reply == 1 ) {
    SetSkillAll( talker );
}

GetAbnormalLevelGLOBAL🟢 high

detector of states on a creature

Returns the current level of an effect of the given type on a creature: if the effect is absent,
the result is negative (in practice checked as "less than or equal to zero"), and if the
effect is present — its level is greater than zero. Takes a creature (c, CSharedCreatureData,
no namespace) and the effect type (nAbnormalType, int, no namespace), which is almost
always obtained right there via Skill_GetAbnormalType. This is how you check whether a stun is
already on the target, whether it is poisoned, and whether the needed buff is on the player at full strength.

Signature

GetAbnormalLevel( CSharedCreatureData cCreature, int nAbnormalType )

Parameters

cCreature     (CSharedCreatureData) — whom we check.
nAbnormalType (int) — effect type (usually Skill_GetAbnormalType(s)).

Example

i0 = GetAbnormalLevel( myself.sm, Skill_GetAbnormalType( @s_stun_attack11 ) );

Usage example

i1 = GetAbnormalLevel( myself.sm, Skill_GetAbnormalType( @s_npc_paralyze1 ) );
if ( i0 <= 0 && i1 <= 0 ) {
    if ( Rand( 100 ) < SoulShotRate ) { UseSoulShot( SoulShot ); }
}

Skill_GetConsumeMPNPC🟢 high

skill mana cost

Returns how much mana (MP) casting the given skill will cost. The AI uses this to check whether the NPC has enough mana to use it. The nSkillId argument is a skill from [skill_pch]; almost always checked together with the HP cost and the reuse delay.

Signature

Skill_GetConsumeMP( int nSkillId )

Parameters

nSkillId (int) — skill.
    values — from the [skill_pch] dictionary

Example

if ( Skill_GetConsumeMP( DDMagic1 ) < myself.sm.mp && Skill_GetConsumeHP( DDMagic1 ) < myself.sm.hp ) {

Usage example

if ( Skill_GetConsumeMP( SetCurse ) < myself.sm.mp && Skill_GetConsumeHP( SetCurse ) < myself.sm.hp && Skill_InReuseDelay( SetCurse ) == 0 ) {
    AddUseSkillDesire( attacker, SetCurse, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 1000000 );
}

Skill_GetConsumeHPNPC🟢 high

skill health cost

Returns how much health (HP) the cast will cost — for skills that consume health. A full analog of Skill_GetConsumeMP and checked in the same combination. The nSkillId argument is a skill from [skill_pch].

Signature

Skill_GetConsumeHP( int nSkillId )

Parameters

nSkillId (int) — skill.
    values — from the [skill_pch] dictionary

Example

if ( Skill_GetConsumeMP( DDMagic1 ) < myself.sm.mp && Skill_GetConsumeHP( DDMagic1 ) < myself.sm.hp ) {

Usage example

if ( Skill_GetConsumeMP( SetCurse ) < myself.sm.mp && Skill_GetConsumeHP( SetCurse ) < myself.sm.hp && Skill_InReuseDelay( SetCurse ) == 0 ) {
    AddUseSkillDesire( attacker, SetCurse, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 1000000 );
}

Skill_InReuseDelayNPC🟢 high

reuse-delay check

Reports whether the skill is on reuse delay: zero means it is ready to use, non-zero means it is still on cooldown. The nSkillId argument is a skill from [skill_pch]. Together with the mana and health cost checks it forms the classic condition "enough resources and cooldown elapsed".

Signature

Skill_InReuseDelay( int nSkillId )

Parameters

nSkillId (int) — skill.
    values — from the [skill_pch] dictionary

Example

if ( Skill_InReuseDelay( DDMagic1 ) == 0 ) {

Usage example

if ( Skill_GetConsumeMP( SetCurse ) < myself.sm.mp && Skill_GetConsumeHP( SetCurse ) < myself.sm.hp && Skill_InReuseDelay( SetCurse ) == 0 ) {
    AddUseSkillDesire( attacker, SetCurse, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 1000000 );
}

Skill_GetAbnormalTypeNPC🟢 high

type of the applied effect

Returns the abnormal type of the effect the skill applies — the key by which the presence of the effect on a creature is then queried via GetAbnormalLevel(creature, type). This is how the AI understands whether a stun, poison, or buff is already on the target. The nSkillId argument is a skill from [skill_pch].

Signature

Skill_GetAbnormalType( int nSkillId )

Parameters

nSkillId (int) — skill.
    values — from the [skill_pch] dictionary

Example

i0 = GetAbnormalLevel( myself.sm, Skill_GetAbnormalType( @s_stun_attack11 ) );

Usage example

if ( GetAbnormalLevel( myself.sm, Skill_GetAbnormalType( @s_antaras_regen4 ) ) < 14 ) {
    AddUseSkillDesire( myself.sm, @s_antaras_regen4, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 4000000 );
}

Skill_GetEffectPointNPC🟢 high

weight (strength) of the skill effect

Returns the nominal "effect strength" of a skill. In handlers reacting to someone else's cast, the NPC uses this value to compute how much aggro to add to the caster: the more powerful the skill used against it, the higher the priority of a counterattack. The nSkillId argument is a skill from [skill_pch] (usually skill_name_id, i.e. what was used against the NPC).

Signature

Skill_GetEffectPoint( int nSkillId )

Parameters

nSkillId (int) — skill (usually skill_name_id — what was used against the NPC).
    values — from the [skill_pch] dictionary

Example

i0 = Skill_GetEffectPoint(skill_name_id);
f1 = Skill_GetEffectPoint(skill_name_id);
i1 = Skill_GetEffectPoint(skill_name_id);

Usage example

if ( Skill_GetEffectPoint( skill_name_id ) > 0 ) {
    AddAttackDesire( speller, @AMT_STAND, ( ( ( Skill_GetEffectPoint( skill_name_id ) / myself.sm.max_hp ) / 0.050000 ) * 150 ) );
}

Skill_GetTargetTypeNPC🟢 high

skill target type

Returns the skill's target type — an integer enumeration of about two dozen values (self, single target, enemy, own party, corpse, ground point, etc.). The nSkillId argument is a skill from [skill_pch]. The table of types is covered in the structural documentation.

Signature

Skill_GetTargetType( int nSkillId )

Parameters

    nSkillId (int) — skill.
        values — from the [skill_pch] dictionary

Example (illustrative):

    Skill_GetTargetType( nSkillId );

Skill_HaveAttributeNPC🟢 high

whether a skill has an element

Checks whether the skill has the given element (fire, water, wind, earth, holy, dark — or "no element") and returns a presence flag (1/0). The nSkillId argument is a skill from [skill_pch], nAttribute is the element code. The table of element codes is covered in the structural documentation.

Signature

Skill_HaveAttribute( int nSkillId, int nAttribute )

Parameters

nSkillId   (int) — skill.
    values — from the [skill_pch] dictionary
nAttribute (int) — element code (enum AttributeTypeEnum, see below).

Example

if (skill_name_id > 0 && Skill_HaveAttribute(skill_name_id, 0) && Rand(100) < 70 && InMyTerritory(attacker)) {

UseSkillNPC🟢 high

immediate skill cast on a target

Makes the NPC immediately use a skill on the specified target. Unlike AddUseSkillDesire, which merely adds a desire to the queue, UseSkill fires right now — so it is used by buffers handing the player a batch of buffs in a row, and for service casts on itself or on the summoner. The c argument is the target, nSkillId is a skill from [skill_pch].

Signature

UseSkill( CSharedCreatureData cCreature, int nSkillId )

Parameters

cCreature (CSharedCreatureData) — skill target.
nSkillId  (int) — skill.
    values — from the [skill_pch] dictionary

Example

UseSkill( talker, @s_golden_pig_haste );

Usage example

if (script_event_arg1 == 18952) {
    UseSkill(myself.sm, SelfBuff);
}

UseCategorySkillNPC🟢 high

cast a skill from a category

Makes the NPC use one skill from the given category (a set of
skills) on the specified creature. Instead of a specific skill you name the category number, and the needed skill from it
is selected automatically and cast on the target. Returns an integer — a result flag
(whether the cast fired or not); use the return value if you need to know whether the skill was applied.
The category is given as a number (the skill-set number). The returned integer is a result flag
(whether the skill was applied or not), as with its counterpart UseCategoryItem.

Signature

UseCategorySkill( CSharedCreatureData cCreature, int nCategory )

Parameters

    cCreature (CSharedCreatureData) — on whom to use the skill (cast target).
    nCategory (int) — number of the category (skill set) the skill is taken from.

Example (illustrative):

    i0 = UseCategorySkill( talker, nCategory );

FastBuffNPC🟢 high

quick buff by direct identifier

A "quick buff" — a service way for NPC buffers to grant a skill by direct identifier and level with a positional index (apparently a slot in the buff list). No direct calls found in the scripts; the argument order is taken from the signature. Arguments: nIndex — index/slot, nSkillID — skill (direct id), nSkillLevel — level.

Signature

FastBuff( int nIndex, int nSkillID, int nSkillLevel )

Parameters

    nIndex (int) — buff index/slot.
    nSkillID (int) — skill (direct id).
    nSkillLevel (int) — skill level.

Example (illustrative):

    FastBuff( nIndex, nSkillID, nSkillLevel );

GetPledgeSkillLevelNPC🟢 high

clan skill level

Returns the level of clan (pledge) skills of a creature and often serves as a gating condition in clan quests and dialogs — for example, access opens only when the clan-skill level is at least four. The c argument is whom to check (usually talker).

Signature

GetPledgeSkillLevel( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — whom to check (usually talker).

Example

i0 = GetPledgeSkillLevel(talker);

Usage example

if ( GetPledgeSkillLevel( myself.c_ai0 ) < pledge_lv_req ) {
    return;
}

DeleteAcquireSkillsNPC🟢 high

delete learned skills

Deletes a creature's learned skills of the specified category (subclass reset, transformations, etc.).
The second argument is the skill category SkillAcquireType (per the server source), from the
manual_pch dictionary as @..._skill_acquire.

Signature

DeleteAcquireSkills( CSharedCreatureData c, int nAcquireType )

Parameters

c (CSharedCreatureData) — whose skills to delete.
nAcquireType (int) — skill category (engine enum SkillAcquireType):
    -1 none, 0 regular, 1 fishing, 2 clan, 3 clan sub-unit skills,
    4 transformations, 5 subclass, 6 gathering, 7 Bishop-share, 8 Elder-share,
    9 SilenElder-share, 10..24 extended sets, 25 fishing (non-dwarf),
    26 premium account, 27 academy member, 28..33 racial (human/elf/dark-elf/orc/dwarf/kamael),
    34 alchemy. The tail numbers shift per chronicle (manual_pch [*_skill_acquire]).

Example

DeleteAcquireSkills(talker, @subjob_skill_acquire);

IsToggleSkillOnOffNPC🟢 high

toggle skill state

Relates to toggle skills — checking or toggling the on/off state of a skill on the target. The return type in the signature is void (despite the Is... name), which is ambiguous; no direct calls. The pTarget argument is whose skill, nSkillUid is the toggle skill from [skill_pch].

Signature

IsToggleSkillOnOff( CSharedCreatureData pTarget, int nSkillUid )

Parameters

pTarget (CSharedCreatureData) — whose.
nSkillUid (int) — toggle skill.
    values — from the [skill_pch] dictionary

Example

IsToggleSkillOnOff(myself.sm, @s_i_orfen_speed);
IsToggleSkillOnOff(myself.sm, @s_echimus_ultimate_shield1);

ShowSkillListNPC🟢 high

learnable skill list window

Opens for the player a window listing the skills they can learn from this NPC teacher.
The skill list is selected by the player's own class and level — you do not need to enumerate it.
The first argument is who gets the window (usually talker). The second is the name of your own HTML page for the window:
in all real calls it is empty ("" or _blank), in which case the standard class skill list
window opens. Specifying your own page name only makes sense if you want to show
your own styled page instead of the standard one.

Signature

ShowSkillList( CSharedCreatureData c, string sListName )

Parameters

c (CSharedCreatureData) — who gets the window (usually talker).
sListName (string) — name of your own HTML page for the window; empty ("" / _blank) — the standard
    class skill list window.

Example

ShowSkillList( talker, "" );
ShowSkillList( talker, _blank );

Usage example

if ( IsInCategory( @dwarf_bounty_class, talker.occupation ) ) {
    ShowSkillList( talker, "" );
} else {
    ShowPage( talker, fnClassMismatch );
}

ShowEtcSkillListNPC🟢 high

list of other skills

Opens for the player a window listing "other" skills — not the regular class skills, but a separate set:
clan skills, clan sub-unit skills, transformations, subclass, etc. Which exact set the window
shows is determined by the second argument — the type of skill set to learn. In real calls this is either
a named constant (e.g. @pledge_skill_acquire — clan skills) or the same number directly
(3 — clan sub-unit skills). The third argument is the name of your own HTML page for the window: in calls it is
empty ("" / _blank), in which case the standard window for the set opens. A custom page name is given
only for custom window styling.

Signature

ShowEtcSkillList( CSharedCreatureData c, int nAcquireType, string sListName )

Parameters

c (CSharedCreatureData) — who gets the window (usually talker).
nAcquireType (int) — type of skill set to learn (which list to show):
    -1 none, 0 regular, 1 fishing, 2 clan, 3 clan sub-unit skills,
    4 transformations, 5 subclass, 6 gathering, 7 Bishop-share, 8 Elder-share,
    9 SilenElder-share, 10..24 extended, 25 fishing (non-dwarf), 26 premium,
    27 academy member, 28..33 racial, 34 alchemy. In scripts written as a constant
    (@pledge_skill_acquire, @subjob_skill_acquire) or a number. The tail numbers
    shift per chronicle — check against manual_pch [*_skill_acquire].
sListName (string) — name of your own HTML page for the window; empty ("" / _blank) — standard window.

Example

ShowEtcSkillList( talker, @subjob_skill_acquire, "" );

Usage example

if ( reply == 0 ) {
    ShowEtcSkillList( talker, skill_acquire, "" );
}

ShowEnchantSkillListNPC🟢 high

skill enchant window

Opens the skill enchant window for the player. This is a purely presentational command (the engine sends
the client a window-open packet; returns nothing). The engine fills in the player's slots itself; the numeric
script arguments are forwarded to the client as window fields. The first argument c is who gets the window,
the second is a numeric window parameter. Related windows of the same nature: ShowEnchantSkillListDrawer,
ShowEnchantSkillMessage, ShowGrowSkillMessage/…2 (they differ in packet code and field count).

Signature

ShowEnchantSkillList( CSharedCreatureData c, int nEnchantType )

Parameters

c (CSharedCreatureData) — who gets the window (usually talker).
nEnchantType (int) — enchant mode (engine enum SkillEnchantType):
    0 regular enchant, 1 safe, 2 enchant reset (untrain), 3 route change.

Example

ShowEnchantSkillList( talker, state );
ShowEnchantSkillList(talker, action_id);

Usage example

if ( talker.level > 75 ) {
    ShowEnchantSkillList( talker, state );
} else {
    ShowPage( talker, fnLevelMismatch );
}

ShowEnchantSkillListDrawerNPC🟢 high

enchant list panel

Expands for the player the enchant panel for a specific selected skill — the expanded list
of options that appears when the player clicks a skill in the enchant window. In scripts it is called
from the click handler of that window: two values arrive there — which skill the player selected
(skill_name_id) and what they want to do with it (action_id, the enchant kind) — and you simply pass
them here. Usually conditions are checked before expanding the panel (for example, that the player is not
transformed), and only then this function is called.

Signature

ShowEnchantSkillListDrawer( CSharedCreatureData c, int nSkillUid, int nEnchantType )

Parameters

c (CSharedCreatureData) — who gets the panel (usually talker).
nSkillUid (int) — which skill is being enchanted; in scripts this is skill_name_id, coming from
    the skill-selection event in the enchant window (a value from the [skill_pch] dictionary).
nEnchantType (int) — what is done with the skill (enchant kind); in scripts this is action_id from the
    same event. Values:
    0 regular enchant, 1 safe, 2 enchant reset, 3 route change.

Example

ShowEnchantSkillListDrawer(talker, skill_name_id, action_id);

ShowEnchantSkillMessageNPC🟢 high

skill enchant message

Shows the player a short hint message about skill enchanting — what exactly the selected
enchant operation will give for the selected skill. In scripts it is called right after the player selects
a skill in the enchant window: the handler receives which skill they selected (skill_name_id) and which kind
of enchant they want (action_id), and you pass them here so the player sees an explanatory message before
confirming.

Signature

ShowEnchantSkillMessage( CSharedCreatureData c, int nSkillUid, int nEnchantType )

Parameters

c (CSharedCreatureData) — who gets the message (usually talker).
nSkillUid (int) — which skill the message is about; in scripts this is skill_name_id, coming from
    the skill-selection event in the enchant window (a value from the [skill_pch] dictionary).
nEnchantType (int) — which enchant kind the message is about; in scripts this is action_id from the same
    event. Values:
    0 regular enchant, 1 safe, 2 enchant reset, 3 route change.

Example

ShowEnchantSkillMessage(talker, skill_name_id, action_id);

ShowGrowSkillMessageNPC🟢 high

skill growth message

Shows the player a hint message that a skill can be "grown" — its level raised
at an NPC teacher. The first argument is who gets it (usually talker), the second is which
skill the message is about (skill_name_id). The third is the name of your own HTML page for the window: in real calls it is
empty ("" / _blank), in which case the standard message is shown. This function is often called
for regular skills, while for "other" ones (clan, etc.) — its relative ShowGrowEtcSkillMessage,
choosing between them by set type.

Signature

ShowGrowSkillMessage( CSharedCreatureData c, int nSkillUid, string sListName )

Parameters

c (CSharedCreatureData) — who gets it (usually talker).
nSkillUid (int) — which skill the message is about; in scripts this is skill_name_id (a value from
    the [skill_pch] dictionary).
sListName (string) — name of your own HTML page for the window; empty ("" / _blank) — standard
    message.

Example

ShowGrowSkillMessage( talker, skill_name_id, "" );
ShowGrowSkillMessage(talker, skill_name_id, _blank);

Usage example

if (i0 == 0) {
    ShowGrowSkillMessage(talker, skill_name_id, _blank);
} else
if (i0 >= 1) {
    ShowGrowEtcSkillMessage(talker, skill_name_id, i0, _blank);
}

ShowGrowSkillMessage2NPC🟢 high

extended skill growth message

An extended variant of ShowGrowSkillMessage: shows the player the same skill "growth" message,
but takes two additional numeric arguments between the skill and the window page name. The
server does not interpret these two numbers — it inserts them into the message text, and the client renders it (by
meaning they are skill growth parameters, e.g. levels). The first argument is who gets it,
the last is the name of your own HTML page for the window (empty — standard message). If the two
additional numbers are not needed, use the regular ShowGrowSkillMessage.

Signature

ShowGrowSkillMessage2( CSharedCreatureData c, int nSkillUid, int nParam1, int nParam2, string sListName )

Parameters

    c (CSharedCreatureData) — who gets it (usually talker).
    nSkillUid (int) — which skill the message is about (a value from the [skill_pch] dictionary).
    nParam1 (int) — numeric field of the growth message (inserted by the client; by meaning — a skill growth parameter, e.g. a level).
    nParam2 (int) — second such numeric field of the message (inserted by the client).
    sListName (string) — name of your own HTML page for the window; empty ("") — standard message.

Example (illustrative):

    ShowGrowSkillMessage2( talker, nSkillUid, nParam1, nParam2, "" );

ShowGrowEtcSkillMessageNPC🟢 high

message about the growth of an "other" skill

The same skill "growth" message as ShowGrowSkillMessage, but for "other" skills —
not ordinary class skills, but a separate set (clan skills, clan sub-unit skills, etc.).
Therefore there is an additional argument here — the type of the skill set to which the growing
skill belongs. In scripts this function and ShowGrowSkillMessage are usually placed in a branch: if the skill is
from the ordinary set — ShowGrowSkillMessage is called, if from the other one — this one, passing the set
type. The last argument is the name of your own HTML page for the window (empty — the standard message).

Signature

ShowGrowEtcSkillMessage( CSharedCreatureData c, int nSkillUid, int nAcquireType, string sListName )

Parameters

c (CSharedCreatureData) — whom to show (usually talker).
nSkillUid (int) — about which skill the message is; in scripts this is skill_name_id (a value from
    the [skill_pch] dictionary).
nAcquireType (int) — the type of the skill set to which the growing skill belongs:
    -1 none, 0 ordinary, 1 fishing, 2 clan, 3 clan sub-unit skills, 4 transformations,
    5 subclass, 6 collection, 7 Bishop-share, 8 Elder-share, 9 SilenElder-share, 10..24 extended,
    25 fishing (non-dwarf), 26 premium, 27 academic, 28..33 racial, 34 alchemy.
    In scripts they write it as a constant (@pledge_skill_acquire) or a number. The tail numbers
    shift by chronicle — verify against manual_pch [*_skill_acquire].
sListName (string) — the name of your own HTML page for the window; empty ("" / _blank) — the standard
    message.

Example

ShowGrowEtcSkillMessage(talker, skill_name_id, @pledge_skill_acquire, _blank);

Usage example

if (i0 >= 1) {
    ShowGrowEtcSkillMessage(talker, skill_name_id, i0, _blank);
}

DispelNPC🟢 high

remove an effect from a creature

Removes from a creature an effect of the specified type — the reverse action to GetAbnormalLevel.
Takes a creature (c, CSharedCreatureData, no namespace) and the effect type
(nAbnormalType, int, no namespace), which, as before, is usually taken from a skill
via Skill_GetAbnormalType. With this an NPC drops, for example, its own temporary
protective buff before a battle-phase change.

Signature

Dispel( CSharedCreatureData c, int nAbnormalType )

Parameters

c (CSharedCreatureData) — from whom to remove the effect.
nAbnormalType (int) — the abnormal effect type (usually Skill_GetAbnormalType(@skill);
    an open set of types from skilldata.txt, there is no fixed enum).

Example

Dispel(myself.sm, Skill_GetAbnormalType(@s_trance1));

Usage example

if ( ( ( ( talker.transformID == 260 ) || ( talker.transformID == 8 ) ) ) || ( talker.transformID == 9 ) ) {
    Dispel( talker, Skill_GetAbnormalType( @s_flying_form_shooting1 ) );
}

CastBuffForAgitManagerNPC🟢 high

buffs of the clan hall manager

Applies one buff to a creature — the skill given by the second argument — with mana consumption by the
NPC manager. There is no fixed set: exactly the skill that was passed is cast, and a "series" of
clan hall buffs is done by several calls in a row. Takes a creature (usually talker) and
the buff skill. An important clarification about "large numbers": a value like 284557314 is NOT a separate
server id, but an ordinary [skill_pch] constant written as a number (the packing "skill id << 16 |
level": 284557314 = skill 4342, level 2). That is, the symbolic @-form and this number are
one and the same. If a creature is not passed, the function logs an error and does nothing. Functions close in meaning that give a
buff as a quest reward — CastBuffForQuestReward and its second version — are described in the
quests group.

Signature

CastBuffForAgitManager( CSharedCreatureData c, int nSkill )

Parameters

c (CSharedCreatureData) — whom to buff (usually talker).
nSkill (int) — the buff skill (in scripts — a direct id, the packing id<<16|level).
    the values are from the [skill_pch] dictionary

Example

CastBuffForAgitManager(talker, reply);

TIMERS (Timer)

7 functions

AddTimerExGLOBAL🟢 high

set a one-shot timer

Schedules a one-shot firing: after nTimeout milliseconds the engine will call
TIMER_FIRED_EX with the given identifier nTimerId. Arguments: nTimerId (an arbitrary
id, which the handler will also receive) and nTimeout (the delay until firing, ms), both without
namespace; returns nothing. To make a timer periodic, it is usually
restarted from inside the TIMER_FIRED_EX handler itself, calling the function again with the same id. Available
both on ordinary NPCs and on spawners — with the same meaning.
Related event: the timer is caught by the TIMER_FIRED_EX(timer_id) event; on a maker — ON_TIMER (see NASC_HANDLERS).

Signature

AddTimerEx( int nTimerId, int nTimeout )

Parameters

nTimerId (int) — an arbitrary id (which `TIMER_FIRED_EX` will also receive).
nTimeout (int) — the delay until firing, ms.

Example

AddTimerEx( 1, 7000 );

Usage example

if ( MoveAroundSocial > 0 || MoveAroundSocial1 > 0 ) {
    AddTimerEx( 1671, 10000 );
}

RegToRespawnTimerMAKER🟢 high

register in the respawn timer

Registers a spawn define in the respawn timer (spawner mechanics): after
an NPC dies, it schedules its reappearance. The nRespawnTime argument is the absolute
moment of revival (no namespace); returns an integer. Belongs to the spawn-define
class, not to an ordinary NPC.

Signature

RegToRespawnTimer( int nRespawnTime )

Parameters

nRespawnTime (int) — the absolute respawn moment = death_time + respawn_time of the spawn
                     define (the creature's death time plus the revival interval from loaded_def).

Example

def0.RegToRespawnTimer(i0);

AtomicAddTimerExNPC🟢 high

atomic timer scheduling with duplicate protection

An "atomic" timer scheduling bound to creature c: sets the timer only
if no such timer exists yet, and returns a success flag (presumably TRUE if
set, FALSE if it already existed). Arguments: c (the creature owning the timer,
CSharedCreatureData), nTimerId (timer id) and nTimeout (delay, ms), all without a
namespace. In essence this is a protective "lock" for timers.
Related event: the timer is caught by the TIMER_FIRED_EX(timer_id) event (see NASC_HANDLERS).

Signature

AtomicAddTimerEx( CSharedCreatureData c, int nTimerId, int nTimeout )

Parameters

    c (CSharedCreatureData) — the creature owning the timer.
    nTimerId (int) — timer id (an arbitrary number chosen by the script).
    nTimeout (int) — delay, ms.

Example (illustrative):

    AtomicAddTimerEx( talker, nTimerId, nTimeout );

BlockTimerNPC🟢 high

suspend a timer

Suspends (blocks) the timer with the given identifier — its firings stop
reaching TIMER_FIRED_EX. Argument: nTimerId (id of the timer being blocked, no
namespace); returns nothing. Used to temporarily disable periodic
logic (for example, during a special combat phase) or to silence a group of timers at once.

Signature

BlockTimer( int nTimerId )

Parameters

nTimerId (int) — id of the timer being blocked.

Example

BlockTimer(1001);

Usage example

if ( myself.i_ai2 == 0 ) {
    BlockTimer( CHECK_TIME_ANNOUNCE );
    myself.i_ai2 = 1;
    AddTimerEx( CHECK_TIME_ANNOUNCE2, ( 1 * 100 ) );
}

UnblockTimerNPC🟢 high

remove a timer block

Removes the block imposed by BlockTimer — the timer works again. Argument:
nTimerId (id of the timer being unblocked, no namespace); returns nothing. Usually
paired with BlockTimer: switched off for the duration of a phase — switched back on.

Signature

UnblockTimer( int nTimerId )

Parameters

nTimerId (int) — id of the timer being unblocked.

Example

UnblockTimer(1001);

SetTimerPeriodNPC🟢 high

set the system timer period (ms)

Sets the period of the NPC's periodic system timer — how often the engine invokes
the regular handler. Argument: nPeriodMs (tick period in milliseconds); returns
nothing. Affects the frequency of regular AI logic (1800 ms in the calls).

Signature

SetTimerPeriod( int nPeriodMs )

Parameters

nPeriodMs (int) — tick period, ms (1800 in the calls).

Example

SetTimerPeriod(1800);

SetTimerPeriodByTickNPC🟢 high

set the system timer period (ticks)

Same as SetTimerPeriod, but the period is specified in server ticks rather than
milliseconds. Argument: nPeriod (period in server ticks, no namespace); returns
nothing. The meaning is inferred from the name; no direct calls were extracted.

Signature

SetTimerPeriodByTick( int nPeriodTicks )

Parameters

    nPeriodTicks (int) — tick period, in server ticks.


Example (illustrative):

    SetTimerPeriodByTick( nPeriodTicks );

DESIRES (DESIRE)

32 functions

AddAttackDesireNPC🟢 high

"I want to attack this creature"

The most basic combat desire. The character starts hitting the specified creature
with an ordinary attack and holds on to that target as long as the desire remains foremost in the queue.

It takes three things: whom to attack (a creature — usually the one who just
hit the NPC), how to move while doing so (the nMoveType parameter), and how strongly
this is wanted (the weight).

The nMoveType values are covered below, in the "Parameters" section. Sometimes instead of a
constant there is the expression IsWalkedNpc, which itself computes 0 or 1.
Related event: on completion — ATTACK_FINISHED(target), on failure — ATTACK_INTERRUPTED (see NASC_HANDLERS).

Signature

AddAttackDesire( CSharedCreatureData cCreature, int nMoveType, float fDesireValue )

Parameters

    cCreature (CSharedCreatureData) — the attack target (a creature). Usually attacker, creature, c0, target.master.
    nMoveType (int) — the way of moving toward the target while performing the desire
        Constants from [manual_pch] are used:
            @AMT_STAND          (0) — attack in place, without closing in
            @AMT_MOVE_TO_TARGET (1) — approach the target closely and attack (pursue)
    fDesireValue (float) — the desire's priority (the higher — the sooner it is fulfilled).

Example. A monster took a hit and rushes at its offender:

    AddAttackDesire( attacker, @AMT_MOVE_TO_TARGET, 2000 );

Here `attacker` is the assailant, `@AMT_MOVE_TO_TARGET` is "pursue", 2000 is the weight.

The same technique with a different targetfor example, a helper rushes at the owner's target:

    AddAttackDesire( c0, @AMT_MOVE_TO_TARGET, 500 );

Usage example

if ( creature.karma > 0 ) {
    AddAttackDesire( creature, @AMT_MOVE_TO_TARGET, 1500 );
}

AddAttackDesireExNPC🟢 high

attack a target specified by identifier

The same as AddAttackDesire, but with two differences. First, the target
is specified not by a creature reference but by its numeric object-id (usually
obtained in advance by functions like GetObjectID). Second, there appears a force
flag nForce — judging by scripts, it makes the desire fire more
forcefully (the value 1 is found in combat files; the exact meaning is deferred to questions).
Related event: on completion — ATTACK_FINISHED(target), on failure — ATTACK_INTERRUPTED (see NASC_HANDLERS).

Signature

AddAttackDesireEx( int nTargetObjectId, int nMoveType, int nForce, float fDesireValue )

Parameters

nTargetObjectId (int) — the object-id of the target (for example, i0, the result of GetObjectID/GetCreatureID).
nMoveType (int) — the way of moving toward the target while performing the desire
    Constants from [manual_pch] are used:
        @AMT_STAND          (0) — attack in place, without closing in
        @AMT_MOVE_TO_TARGET (1) — approach the target closely and attack (pursue)
nForce (int) — the force flag: 1 = fulfill the desire bypassing checks (range, mana, etc.); 0 = with checks.
fDesireValue (float) — the desire's priority.

Example

    AddAttackDesireEx( i0, @AMT_MOVE_TO_TARGET, 1, 100 );

Attack the creature with identifier i0, pursuing it, in forced
mode, with weight 100.

Usage example

if ( Rand( 100 ) < 30 ) {
    AddAttackDesireEx( i0, @AMT_MOVE_TO_TARGET, 1, 100 );
}

AddUseSkillDesireNPC🟢 high

"I want to use a skill"

One of the most frequent desires. Makes the character use a skill on a chosen
target. You need to specify the target, the skill identifier, its nature (offensive or
supporting), the way of moving, and the weight.

It is important to understand the "skill nature + target" pairing. If the skill is offensive
(@ST_ATTACK), the target is an enemy; if supporting (@ST_HEAL) — an ally or
the character itself (myself.sm — the owner).

The skill_type and nMoveType values are covered below, in the "Parameters" section; the same
two sets are used by all functions of the AddUseSkillDesire family (including
the Ex variants and AddUseOneTimeSkillDesire).
Related event: start — USE_SKILL_STARTED, completion — USE_SKILL_FINISHED(target, skill_name_id, success), failure — USE_SKILL_INTERRUPTED (see NASC_HANDLERS).

Signature

AddUseSkillDesire( CSharedCreatureData cCreature, int nSkillNameID, int skill_type, int nMoveType, float fDesireValue )

Parameters

    cCreature (CSharedCreatureData) — the skill target (an enemy for an attack, an ally/myself.sm for healing).
    nSkillNameID (int) — the skill ID (@s_*).
        the values are from the [skill_pch] dictionary
    skill_type (int) — the skill nature: offensive (on an enemy) or supporting (on an ally/self)
        Constants from [manual_pch] are used:
            @ST_ATTACK (0) — an offensive skill — used on an enemy
            @ST_HEAL   (1) — support: heal/buff — on an ally or on self
    nMoveType (int) — the way of moving toward the target while performing the desire
        Constants from [manual_pch] are used:
            @AMT_STAND          (0) — attack in place, without closing in
            @AMT_MOVE_TO_TARGET (1) — approach the target closely and attack (pursue)
    fDesireValue (float) — the desire's priority.

Example of an offensive skill. An NPC casts a curse of fear on the attacker,
without moving from its spot, with maximum priority:

    AddUseSkillDesire(attacker, @s_curse_fear_chance30, @ST_ATTACK, @AMT_STAND, 1000000000);

Example of support. A summoned creature heals/empowers its owner, having approached
it more closely:

    AddUseSkillDesire(myself.sm, SpecialSkill, @ST_HEAL, @AMT_MOVE_TO_TARGET, 1000000);

Usage example

if ( Skill_GetConsumeMP( SetCurse ) < myself.sm.mp && Skill_GetConsumeHP( SetCurse ) < myself.sm.hp && Skill_InReuseDelay( SetCurse ) == 0 ) {
    AddUseSkillDesire( attacker, SetCurse, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 1000000 );
}

AddUseSkillDesireExNPC🟢 high

use a skill (extended variant)

A development of AddUseSkillDesire for finer cases. The target is specified by
object-id, and two additional parameters are added: the force flag
nForce and the desire flag nDesireFlag (in scripts it is almost always 0; the set of its
possible values is clarified in questions).
Related event: start — USE_SKILL_STARTED, completion — USE_SKILL_FINISHED(target, skill_name_id, success), failure — USE_SKILL_INTERRUPTED (see NASC_HANDLERS).

Signature

AddUseSkillDesireEx( int nTargetObjectId, int nSkillNameID, int skill_type, int nMoveType, int nForce, float fDesireValue, int nDesireFlag )

Parameters

    nTargetObjectId (int) — the object-id of the target.
    nSkillNameID (int) — the skill ID.
        the values are from the [skill_pch] dictionary
    skill_type (int) — the skill nature: offensive (on an enemy) or supporting (on an ally/self)
        Constants from [manual_pch] are used:
            @ST_ATTACK (0) — an offensive skill — used on an enemy
            @ST_HEAL   (1) — support: heal/buff — on an ally or on self
    nMoveType (int) — the way of moving toward the target while performing the desire
        Constants from [manual_pch] are used:
            @AMT_STAND          (0) — attack in place, without closing in
            @AMT_MOVE_TO_TARGET (1) — approach the target closely and attack (pursue)
    nForce (int) — the force flag (1 = bypassing range/mana checks).
    fDesireValue (float) — the desire's priority.
    nDesireFlag (int) — the bit flag of the desire's "non-replaceability" (in scripts usually 0). There are "non-replaceability" bits: for a skill desire (one-time, non-removable) and for an attack desire (absolute).

Example — a summoner distributes skills on the owner's target:

    AddUseSkillDesireEx(myself.sm.master.target_id, step0_skill01, @ST_ATTACK, reply, ask, 1000000, 0);

The target is what the summoner's owner is attacking; the move type and force flag
are taken from the variables reply and ask, the weight is a million, the additional flag is 0.

Usage example

if ( Skill_GetConsumeMP( DDMagic ) < myself.sm.mp && Skill_GetConsumeHP( DDMagic ) < myself.sm.hp && Skill_InReuseDelay( DDMagic ) == 0 ) {
    AddUseSkillDesireEx( myself.sm.id, DDMagic, 0, reply, ask, 1000000, 0 );
}

AddMoveToDesireNPC🟢 high

"I want to reach a point on the map"

Sends the character to a specific world point with the given coordinates X, Y, Z.
Most often this is how NPCs are returned "home", to their spawn spot, after a fight
has ended.
Related event: on arrival — MOVE_TO_FINISHED(x, y, z), on failure — MOVE_TO_INTERRUPTED (see NASC_HANDLERS).

Signature

AddMoveToDesire( int nX, int nY, int nZ, float fDesire )

Parameters

    nX      (int) — the X coordinate of the destination point the character goes to
    nY      (int) — the Y coordinate of the destination point the character goes to
    nZ      (int) — the Z coordinate of the destination point the character is sent to
    fDesire (float) — the weight (priority) of the desire to go to the specified point

Example — return to the spawn point:

    AddMoveToDesire( myself.start_x, myself.start_y, myself.start_z, 30 );

The coordinates are taken from start_x/start_y/start_z saved at birth, the weight is
small (30) — this is a calm background return that any combat desire will easily override.

Usage example

if ( timer_id == 2001 ) {
    AddMoveToDesire( ( Dest_X + Rand( 400 ) ), ( Dest_Y + Rand( 400 ) ), Dest_Z, 5 );
}

AddFleeDesireNPC🟢 high

"I want to flee"

The character starts fleeing from the specified creature. A typical scenario —
a cowardly monster or a wounded NPC with little health.
Related event: on completion — FLEE_FINISHED(target), on failure — FLEE_INTERRUPTED (see NASC_HANDLERS).

Signature

AddFleeDesire( CSharedCreatureData cCreature, float fDesire )

Parameters

cCreature (CSharedCreatureData) — the creature the character flees from
fDesire   (float) — the weight (priority) of the desire to flee

Example

    AddFleeDesire(creature, 1000000);

Flee from `creature` with high priority, so that the desire confidently overrides
the desire to fight.

Usage example

if ( myself.i_ai2 == 1 ) {
    AddFleeDesire( attacker, 5000 );
}

AddFollowDesireNPC🟢 high

"I want to follow someone"

Makes the character stay close to the specified creature and walk after it.
Often used by minions who follow their boss (myself.boss).
Related event: on completion — FOLLOW_FINISHED(target), on failure — FOLLOW_INTERRUPTED (see NASC_HANDLERS).

Signature

AddFollowDesire( CSharedCreatureData cCreature, float fDesire )

Parameters

cCreature (CSharedCreatureData) — the creature the character follows and stays close to
fDesire (float) — the weight (priority) of the desire to follow the specified creature

Example

    AddFollowDesire(myself.boss, 5);

A small weight (5) is appropriate here: following is a calm background behavior
that will yield to a fight at any moment.

Usage example

if ( creature.is_pc == 1 && Rand( 100 ) < 50 ) {
    AddFollowDesire( creature, 100 );
}

AddMoveAroundDesireNPC🟢 high

"I want to wander nearby"

A light "idle" behavior: the character does not stand like a post, but moves slightly in
the vicinity. The first parameter sets the duration/interval of wandering (in scripts
usually 5–10), the second — the weight.
Related event: on completion — MOVE_AROUND_FINISHED, on failure — MOVE_AROUND_INTERRUPTED (see NASC_HANDLERS).

Signature

AddMoveAroundDesire( int time, float fDesire )

Parameters

    time (int) — the duration/interval of wandering in the vicinity (usually 510)
    fDesire (float) — the weight (priority) of the desire to move slightly in the vicinity

Example of a peaceful NPC:

    AddMoveAroundDesire(5, 5);

Usage example

if ( IsWalkedNpc == 1 ) {
    AddMoveAroundDesire( 5, 5 );
}

RemoveDesireNPC🟢 high

remove desires of one type

Removes from the queue all desires of the given type. The single argument is the
desire type code (the PhysicalState/PSTATE enumeration). A stable core, the same in all
chronicles: 0 — idle, 1 — wander, 2 — stand empty, 3 — attack, 4 — pursue,
5 — flee, 6 — pick up an item, 7 — follow, 8 — decay, 9 — walk waypoints,
10 — use a skill, 11 — go to a point, 12 — social action. Codes above 12
(approach the target, super point, etc.) are numbered differently in different chronicles — the exact
table by chronicle is given in the structural NASC_FUNCTIONS.md. In practice, only codes from the
stable core are found in scripts: for example, RemoveDesire(11) removes all
"go to coordinates" desires. The same set of codes is used by GetTopDesireValue.

Signature

RemoveDesire( int nDesireType )

Parameters

nDesireType (int) — the desire type code (PhysicalState/PSTATE): 0 idle · 1 wander · 2 stand ·
    3 attack · 4 pursue · 5 flee · 6 pick up item · 7 follow · 8 decay ·
    9 walk waypoints · 10 use skill · 11 go to point · 12 social action. Codes >12
    are numbered differently in different versions (the full table — in NASC_FUNCTIONS.md).

Example

RemoveDesire(11);

RemoveAllDesireNPC🟢 high

erase all desires

Completely clears the desire queue — the character "forgets" what it was going to do.
Convenient to call before changing an AI state, so that the old behavior does not interfere
with the new one.

RemoveAllDesire();

Signature

RemoveAllDesire(  )

Parameters

(none — the function is called without arguments)

Usage example

if ( myself.sm.db_value == 0 ) {
    RemoveAllDesire( );
}

AddMoveToTargetDesireNPC🟢 high

approach a target to the needed distance

Unlike AddMoveToDesire, which leads the character to a stationary point with
coordinates, this function brings it closer to a moving target and keeps a given
distance. The target is specified by identifier, followed by the desired distance, a
service flag (in scripts usually 0), and the weight.

AddMoveToTargetDesire(h1.creature.id, 150, 0, 1000);

Approach the creature h1.creature to 150 units.
Related event: on arrival — MOVE_TO_FINISHED, on failure — MOVE_TO_INTERRUPTED (see NASC_HANDLERS).

Signature

AddMoveToTargetDesire( int nTargetObjectId, int nDistance, int nDesireFlag, float fDesire )

Parameters

nTargetObjectId (int) — the identifier of the moving target the character approaches
nDistance (int) — the desired distance kept from the target
nDesireFlag (int) — a service mode flag (in scripts usually 0)
fDesire (float) — the weight (priority) of the desire to approach the moving target and keep the distance

Usage example

if (IsNullCreature(myself.c_ai0) == 0) {
    AddMoveToTargetDesire(myself.c_ai0.id, 150, 0, 10000);
}

AddChaseDesireNPC🟢 high

chase a creature

Combat chasing: the character runs after the specified creature. Takes the target and
the weight. In meaning it is close to the "follow + attack" pairing, but this is a separate
standalone chase desire.
Related event: on completion — CHASE_FINISHED, on failure — CHASE_INTERRUPTED (see NASC_HANDLERS).

Signature

AddChaseDesire( CSharedCreatureData cCreature, float fDesire )

Parameters

    cCreature (CSharedCreatureData) — the creature the combat chase (pursuit) is conducted after
    fDesire   (float) — the weight (priority) of the desire to chase the target

Example (illustrative):

    AddChaseDesire( talker, 0.0 );

AddFleeDesireExNPC🟢 high

flee to a given distance

The same fleeing as AddFleeDesire, only now you can directly specify to what
distance to run off. Convenient when you need not just to "escape", but to bounce off to a
specific distance and, for example, start shooting from afar.

AddFleeDesireEx( attacker, 300, 100000 );

Run off from the attacker by 300 units with high priority.
Related event: on completion — FLEE_FINISHED(target), on failure — FLEE_INTERRUPTED (see NASC_HANDLERS).

Signature

AddFleeDesireEx( CSharedCreatureData cCreature, int nDistance, float fDesire )

Parameters

cCreature (CSharedCreatureData) — the creature the character runs off from
nDistance (int) — the distance to run off from the creature
fDesire   (float) — the weight (priority) of the desire to flee to the given distance

Usage example

if ( private == myself.boss ) {
    AddFleeDesireEx( private, 500, 10000000 );
}

AddFollowDesire2NPC🟢 high

follow "in formation", in place relative to an ally

Advanced following. A plain AddFollowDesire just trails after the target, while here
you can set the exact place next to it: at what distance to keep and at what
angle to stand. The angle is measured in degrees — 0 is in front, 90 to the right, 180
behind, 270 to the left; for convenience there are ready names eAFD2_DEGREE_FRONT, _RIGHT,
_BACK, _LEFT. The follow type chooses the way of holding position: by distance and
angle (eAFD2_FT_DIST_AND_DEGREE) or by axis offset (eAFD2_FT_XY_GAP).

AddFollowDesire2(myself.c_ai0, 9, @eAFD2_FT_DIST_AND_DEGREE, 250, @eAFD2_DEGREE_FRONT);

Keep 250 units strictly in front of the ally. This is how retinues and
escort formations are built.
Related event: on completion — FOLLOW_FINISHED(target), on failure — FOLLOW_INTERRUPTED (see NASC_HANDLERS).

Signature

AddFollowDesire2( CSharedCreatureData cCreature, float value, int follow_type, int dist, int angle )

Parameters

cCreature (CSharedCreatureData) — the creature the character follows, taking a position beside it
value (float) — the desire weight (following priority)
follow_type (int) — the position-holding type: by distance and angle or by axis offset
dist (int) — the distance to keep from the target while following
angle (int) — the position angle relative to the target in degrees (0 in front, 90 right, 180 behind, 270 left); the constants `eAFD2_DEGREE_FRONT`/`_RIGHT`/`_BACK`/`_LEFT` can be used

Usage example

if ( IsNullCreature( myself.boss ) == 0 ) {
    AddFollowDesire2( myself.boss, 100, 1, ( 150 + Rand( 150 ) ), ( 90 + Rand( 180 ) ) );
}

AddPetDefaultDesire_FollowNPC🟢 high

a pet's default behavior

Sets a pet's basic "background" desire — to follow its owner. Takes
only the weight. This is that very habit of a tamed beast to walk after its owner when it
is given no other commands.

AddPetDefaultDesire_Follow(20.000000);
Related event: on completion — FOLLOW_FINISHED(target) (see NASC_HANDLERS).

Signature

AddPetDefaultDesire_Follow( float fDesire )

Parameters

fDesire (float) — the weight (priority) of the pet's background desire to follow its owner

Example

AddPetDefaultDesire_Follow(20.0);

AddMoveAroundLimitedDesireNPC🟢 high

wander, but not far

Like AddMoveAroundDesire, only the wandering is limited by a radius — the character does not
go farther than the specified distance from the original point. Three parameters:
duration, weight, and the limiting radius.

AddMoveAroundLimitedDesire(500, 250, 250);

Wander within 250 units.
Related event: on completion — MOVE_AROUND_FINISHED (see NASC_HANDLERS).

Signature

AddMoveAroundLimitedDesire( int time, float fDesire, int nDistance )

Parameters

time (int) — the duration/interval of wandering
fDesire (float) — the weight (priority) of the desire to wander in the vicinity
nDistance (int) — the limiting radius of distance from the original point while wandering

Example

AddMoveAroundLimitedDesire(5, 5, 0);

AddMoveSuperPointDesireNPC🟢 high

patrol along a route

A "super point" is a patrol route predefined in the data. The function
sends the character to walk along such a route: you need to specify its name, the traversal
method, and the weight. The variant with a two at the end adds one more mode flag.

AddMoveSuperPointDesire( SuperPointName, SuperPointMethod, SuperPointDesire );
AddMoveSuperPointDesire2( SuperPointName, SuperPointMethod, SuperPointDesire, 1 );

Example

AddMoveSuperPointDesire("iz_aq_antaras01", @MoveSuperPoint_FollowRail, 100);

AddMoveFreewayDesireNPC🟢 high

movement along a "freeway" (a route by number)

A close relative of the super point, but the route is specified not by name but by a numeric
identifier. This is how, for example, caravans and vehicles are driven along fixed
roads.

AddMoveFreewayDesire( FreewayID, FreewayMethod, 50 );
Related event: on arrival at nodes — NODE_ARRIVED (see NASC_HANDLERS).

Signature

AddMoveFreewayDesire( int nFreewayID, int nFreewayMethod, float fDesire )

Parameters

nFreewayID     (int) — the numeric identifier of the freeway route the character moves along.
nFreewayMethod (int) — the traversal method of the route. Known value: @MoveFreeway_Loop = 1
                       (loop the route). In one and the same call @MoveFreeway_Loop and 1
                       are interchangeable — hence the constant's value. The script may pass
                       its own variable FreewayMethod.
fDesire        (float) — the weight (priority) of the desire to move along the route (50 / 100 / 99999 in calls).

Usage example

if ( FreewayID > -1 && FreewayDesire > 0 ) {
    AddMoveFreewayDesire( FreewayID, FreewayMethod, FreewayDesire );
}

AddMoveToWayPointDesireNPC🟢 high

traverse a list of waypoints

Here the route is passed directly as two lists: the coordinates of the waypoints and
the delays at each of them. The character goes from point to point, stopping for the
given time. The third argument is the number of route traversals (1 = one pass,
a counter variable sets the number of repeats), the fourth — the desire weight.

AddMoveToWayPointDesire( WayPoints, WayPointDelays, 1, 10 );
Related event: on completion — MOVE_TO_WAY_POINT_FINISHED, at nodes — NODE_ARRIVED (see NASC_HANDLERS).

Signature

AddMoveToWayPointDesire( WayPointsType WayPoints, WayPointDelaysType WayPointDelays, int nRepeat, float fDesire )

Parameters

WayPoints      (WayPointsType) — the list of the route's waypoint coordinates.
WayPointDelays (WayPointDelaysType) — the list of delays (stop times) at each point.
nRepeat        (int) — the number of route traversals: 1 = one pass; a counter variable (e.g. myself.i_ai1)
                       sets the needed number of traversal repeats.
fDesire        (float) — the weight (priority) of the desire to walk the points (= 10 in calls).

Usage example

if ( myself.i_ai1 > 0 ) {
    AddMoveToWayPointDesire( WayPoints, WayPointDelays, myself.i_ai1, 10 );
} else {
    AddMoveToWayPointDesire( WayPoints, WayPointDelays, 1, 10 );
}

AddMoveFormationDesireNPC🟢 high

movement in a formation

Gives the NPC the desire to move not on its own, but as part of a formation — this is how a group
of mobs moves in a single order, holding places relative to each other. The key arguments are the group
number and the formation number: in live calls the NPC receives its GroupID (twice) and FormationID,
and it is these that bind it to the other members of the formation (in the script these are class parameters,
by default -1). The last argument is the weight (priority) of the desire, as with all Add*Desire: the
higher it is, the more insistently the NPC holds the formation. Notably, the weight is changed by situation — on
appearance a high one is set (2000), and after arrival at the next waypoint a low one (50),
so that the formation does not override other actions. The formation number references the formation definition from formationinfo.txt (which order exactly to hold).
The first (string) argument is the name of the "super point" (a named route); in calls it is empty.

Signature

AddMoveFormationDesire( string sSuperPoint, int nFreewayId, int nEffectId, int nGroupId1, int nGroupId2, int nFormationId, int nDesireFlag, float fDesire )

Parameters

sSuperPoint (string) — the name of the "super point" (a named movement route); in calls an empty string.
nFreewayId  (int) — the id of the "freeway" (a movement route/road); in calls constantly 35.
nEffectId   (int) — the id of the movement effect; in calls constantly 1.
nGroupId1   (int) — the first formation group (in calls GroupID) — binds members of one formation.
nGroupId2   (int) — the second formation group (in calls the same GroupID).
nFormationId (int) — the formation number from formationinfo.txt — which order exactly to hold.
nDesireFlag (int) — the desire flags; in calls constantly 1.
fDesire     (float) — the weight (priority) of the desire to hold the formation; in calls 2000 on appearance and 50 in transit.

Example

AddMoveFormationDesire("", 35, 1, GroupID, GroupID, FormationID, 1, 50);

AddDoNothingDesireNPC🟢 high

stand and do nothing

Sometimes the most correct behavior is to freeze. This function holds the character in
inaction for the given time. The first parameter is the duration, the second — the weight.

AddDoNothingDesire( 40, 30 );

Signature

AddDoNothingDesire( int nDuration, float fDesire )

Parameters

nDuration (int) — the duration of inaction (how long to stand without actions)
fDesire   (float) — the weight (priority) of the desire to do nothing

Usage example

if ( x == myself.start_x && y == myself.start_y && z == myself.start_z ) {
    AddDoNothingDesire( 40, 30 );
}

AddDecayingDesireNPC🟢 high

start dissolving (post-mortem disappearance)

"Decaying" in Lineage is the stage when the corpse of a killed creature decays and
disappears. The function adds the desire to enter this state; the single
parameter is the weight. Applied when the script itself decides to remove the character from the scene.
Related event: on completion — DECAYING_FINISHED, on failure — DECAYING_INTERRUPTED (see NASC_HANDLERS).

Signature

AddDecayingDesire( float fDesire )

Parameters

    fDesire (float) — the weight (priority) of the desire to enter the corpse-decay state.

Example (illustrative):

    AddDecayingDesire( 0.0 );

AddEffectActionDesireNPC🟢 high (confirmed by engine sources)

play a gesture/animation

The desire to play a social action — a bow, gesture, emote — directed at the
specified creature (most often at itself, myself.sm: "a gesture into the void").
The action number chooses the specific animation of the NPC's model (1, 2, 3 … — the first,
second, third social gesture: the client's Social animations). The duration is given
IN MILLISECONDS — which is why in scripts it is often written as the expression
(N * 1000) / 30: this is the conversion of N animation frames at 30 frames per second into
milliseconds. The variant with a two adds as a fifth argument a second duration
(also ms).

This is a "background" desire with a low weight: the typical pairing is a periodic timer
that checks that the NPC is standing idle (myself.p_state, see NASC_LANGUAGE), and with
a chance plays a gesture.

Signature

AddEffectActionDesire( CSharedCreatureData cCreature, int nEffectID, int nEffectDuration, float fDesire )
AddEffectActionDesire2( CSharedCreatureData cCreature, int nEffectID, int nEffectDuration, float fDesire, int nEffectDuration2 )

Parameters

cCreature (CSharedCreatureData) — whom the gesture is directed at (usually myself.sm).
nEffectID (int) — the social action/animation number (1, 2, 3 …; the set of gestures
    is determined by the model of the specific NPC).
nEffectDuration (int) — the gesture's duration, milliseconds; the notation
    (N * 1000) / 30 — the conversion of N frames (30 fps) to ms.
fDesire (float) — the weight (priority) of the desire; for background gestures usually small (50).
nEffectDuration2 (int, only in AddEffectActionDesire2) — the second duration, ms.

Example

AddEffectActionDesire(myself.sm, 3, (MoveAroundSocial * 1000) / 30, 50);
AddEffectActionDesire2(myself.sm, 4, 1500, 10000000, 5000);

Usage example

    EventHandler TIMER_FIRED_EX( timer_id )
    {
        if (timer_id == 1671) {
            if (  ( myself.sm.hp > (myself.sm.max_hp * 0.400000) )  &&  ( myself.sm.alive != 0 )  &&  ( myself.p_state != 3 )  ) {
                if (MoveAroundSocial > 0 || MoveAroundSocial1 > 0) {
                    if (MoveAroundSocial > 0 && Rand(100) < 40) {
                        AddEffectActionDesire( myself.sm, 3, ((MoveAroundSocial * 1000) / 30), 50 );
                    } else
                    if (MoveAroundSocial1 > 0 && Rand(100) < 40) {
                        AddEffectActionDesire( myself.sm, 2, ((MoveAroundSocial1 * 1000) / 30), 50 );
                    }
                }
            }
            AddTimerEx(1671, 10000);
        }
        super;
    }

A peaceful townsperson, once every 10 seconds, if alive, healthy, and not walking (p_state != 3, that is,
not @ACT_MOVE), with a 40% chance plays one of two configured gestures; the duration is
set by a class parameter in frames and converted to milliseconds.

AddGetItemDesireNPC🟢 high

pick up an item from the ground

The desire to pick up a lying item. The basic version takes the item itself
(a CSharedItemData object), and the Ex version — its numeric object index. The second
parameter, as usual, is the desire weight.

Where this index comes from is an important question. It arrives from the SEE_ITEM event,
which fires when the NPC notices items lying nearby. The first argument
of this handler is item_index_list, the list of seen items (of type
CItemIndexList). The list has two methods: GetSize gives the number of items, and
GetItemIndex(n) — the object index of the n-th item (it is exactly this that is passed to
AddGetItemDesireEx; this same index can be compared with @-identifiers of items
from [item_pch]). A typical handler looks like this:

EventHandler SEE_ITEM( item_index_list, i0, i1, i2 )
{
i0 = item_index_list.GetSize( ); // how many items are nearby
for( i1 = 0; i1 < i0; ++i1 ) {
AddGetItemDesireEx( item_index_list.GetItemIndex( i1 ), ( 10000 - i1 ) );
}
}

The NPC wants to pick up all the seen items, and for the first ones in the list the weight is higher
(10000 - i1) — it will grab them earlier. Here i0, i1, i2 are the local scratch
variables declared right in the handler header (integers, by the i prefix).
Close in meaning are the function LookItem (make the NPC react to an item) and
the event GET_ITEM_FINISHED, which fires when the pickup is completed.
Related event: on completion — GET_ITEM_FINISHED(item, success), on failure — GET_ITEM_INTERRUPTED; items — from SEE_ITEM (see NASC_HANDLERS).

Example (illustrative):

AddGetItemDesire();

AddUseOneTimeSkillDesireNPC🟢 high

use a skill once

A full analog of AddUseSkillDesire with all the same parameters (target, skill, its
nature, way of moving, weight), but the desire fires once: the character
uses the skill one time and removes the desire, rather than trying to repeat it.
Related event: start — USE_SKILL_STARTED, completion — USE_SKILL_FINISHED, failure — USE_SKILL_INTERRUPTED (see NASC_HANDLERS).

Signature

AddUseOneTimeSkillDesire( CSharedCreatureData cCreature, int nSkillNameID, int skill_type, int nMoveType, float fDesireValue )

Parameters

    cCreature    (CSharedCreatureData) — the target creature on which the skill is used once
    nSkillNameID (int) — the identifier of the skill being used ([skill_pch])
    skill_type   (int) — the skill nature: offensive (on an enemy) or supporting (on an ally/self)
        Constants from [manual_pch] are used:
            @ST_ATTACK (0) — an offensive skill — used on an enemy
            @ST_HEAL   (1) — support: heal/buff — on an ally or on self
    nMoveType    (int) — the way of moving toward the target while performing the desire
        Constants from [manual_pch] are used:
            @AMT_STAND          (0) — attack in place, without closing in
            @AMT_MOVE_TO_TARGET (1) — approach the target closely and attack (pursue)
    fDesireValue (float) — the weight (priority) of the one-time desire to use the skill

Example (illustrative):

    AddUseOneTimeSkillDesire( talker, nSkillNameID, skill_type, nMoveType, 0.0 );

AddUseSkillDesireExByActionNPC🟢 high

a skill bound to a player action

An extension of AddUseSkillDesireEx: the identifier of a client action is added to the
usual set of parameters. That is, the use of the skill can be bound to a
specific action on the part of the client/player (for example, a button press).
Related event: start — USE_SKILL_STARTED, completion — USE_SKILL_FINISHED, failure — USE_SKILL_INTERRUPTED (see NASC_HANDLERS).

Signature

AddUseSkillDesireExByAction( int nTargetObjectId, int nSkillNameID, int skill_type, int nMoveType, int nForce, float fDesireValue, int nDesireFlag, int nClientActionId )

Parameters

nTargetObjectId (int) — the identifier of the target creature on which the skill is used
nSkillNameID (int) — the identifier of the skill being used
skill_type (int) — the skill nature: offensive (on an enemy) or supporting (on an ally/self)
    Constants from [manual_pch] are used:
        @ST_ATTACK (0) — an offensive skill — used on an enemy
        @ST_HEAL   (1) — support: heal/buff — on an ally or on self
nMoveType (int) — the way of moving toward the target while performing the desire
    Constants from [manual_pch] are used:
        @AMT_STAND          (0) — attack in place, without closing in
        @AMT_MOVE_TO_TARGET (1) — approach the target closely and attack (pursue)
nForce (int) — the flag/degree of forced skill use
fDesireValue (float) — the weight (priority) of the desire to use the skill
nDesireFlag (int) — a service desire flag (usually 0)
nClientActionId (int) — the identifier of the client action with which the skill use is associated

Usage example

if (step_skill_target01 == 2 && myself.master.alive > 0) {
    AddUseSkillDesireExByAction(myself.master.id, step_skill01, @ST_ATTACK, reply, ask, 1000000, 0, action_id);
}

RandomizeAttackDesireNPC🟢 high

randomly change target

Shuffles the attack priorities, making the character choose a target anew, more or
less at random from those who anger it. Very beloved in boss scripts: thanks to
it, a raid monster unpredictably switches between players.

RandomizeAttackDesire();

Signature

RandomizeAttackDesire(  )

Parameters

(none — the function is called without arguments)

Usage example

if ( Rand( 3 ) < 1 ) {
    RandomizeAttackDesire( );
}

GetTopDesireValueNPC🟢 high

learn the weight of the highest-priority desire

Returns the weight of the top desire of the given type (the same type code as RemoveDesire:
3 — attack, 11 — movement, etc.; and 19 = "the top among all types whatsoever"). The main
technique for its use is to place a new desire guaranteed first: the current
maximum is taken and a large number is added to it.

AddUseSkillDesire( myself.sm, @s_devastated_recall, @ST_HEAL, @AMT_MOVE_TO_TARGET,
( GetTopDesireValue( 3 ) + 10000000000 ) );

Here 3 is the "attack" type: the weight of the top attack desire is taken and a skill is placed with
priority "the current maximum plus ten billion", that is, it will be fulfilled
before everything else.

Signature

GetTopDesireValue( int nDesireType )

Parameters

    nDesireType (int) — the desire type code whose top weight is to be obtained (for example 3 — attack, 11 — movement, 19 — the top among all types)

Example (illustrative):

    GetTopDesireValue( nDesireType );

RemoveAttackDesireNPC🟢 high

stop attacking a specific target

Removes the desire to hit exactly one specified (by identifier) target, without touching
all the other behavior.

RemoveAttackDesire(attacker.id);

Signature

RemoveAttackDesire( int nTargetObjectId )

Parameters

nTargetObjectId (int) — the identifier of the target whose "hit" desire is to be removed

Usage example

if ( myself.top_desire_target.is_pc == 0 ) {
    RemoveAttackDesire( myself.boss.id );
}

RemoveAllAttackDesireNPC🟢 high

stop all attacks

Removes all combat desires at once, but leaves the peaceful ones — movement, following, and
the rest. This is how it differs from RemoveAllDesire, which erases absolutely everything.

RemoveAllAttackDesire();

Signature

RemoveAllAttackDesire(  )

Parameters

(none — the function is called without arguments)

Usage example

if ( myself.p_state != 3 && myself.p_state != 10 ) {
    RemoveAllAttackDesire( );
}

RemoveAbsoluteDesireNPC🟢 high

remove an "absolute" desire

There are special desires with an absolute, unoverridable priority. This function
removes such a desire. It returns something as a number, but the meaning of the return is not yet
established.

RemoveAbsoluteDesire();

Signature

RemoveAbsoluteDesire(  )

Parameters

(none — the function is called without arguments)

Example

RemoveAbsoluteDesire();

ReportDesireNPC🟢 high

a service dump of the queue state

Appears to be a debug function that reports (writes to the log) the current
contents of the desire queue. There are no live calls in the scripts, so it is classed under
questions.

Signature

ReportDesire(  )

Parameters

(none — the function is called without arguments)

Example

ReportDesire( );

AGGRO AND HATE LIST (Hate / Aggro)

11 functions

AddHateInfoNPC🟢 high

change hate toward a creature

Changes the hate of the specified creature (CSharedCreatureData) by the given amount and creates
a record in the hate list if one did not exist yet. The amount is usually computed as a weight multiplied
by an event factor (damage, skill use, helping an ally); it can also be negative when
hate needs to be reduced. Per the L2NPC decompile (CNPC::AddHateInfo → HateInfoList::Add_46B410) the third
argument is stored in the record field HateInfo.m_nMapId (map id; always 0 in scripts), and the fourth
and fifth are named modes from manual_pch controlling the addition of a new record and the update
of an existing one. Returns nothing.

Signature

AddHateInfo( CSharedCreatureData c, int nHateValue, int nMapId, int nAddMode, int nUpdateMode )

Parameters

c (CSharedCreatureData) — whose hate to change.
nHateValue (int) — amount of the hate change (can be negative).
nMapId (int) — map id in the hate record (HateInfo.m_nMapId); always 0 in the calls.
nAddMode (int) — mode for adding a NEW target (manual_pch):
    @AHI_ADD_VALUE (1) — add the record even when the list is full;
    @AHI_SET_VALUE (0) — respect the list capacity.
nUpdateMode (int) — mode for an ALREADY existing target (manual_pch):
    @AHI_DEL_UPDATE (1) — add the amount to the current hate (accumulate);
    @AHI_IGNORE (0) — replace the value, no accumulation.

Example

AddHateInfo( c0, 300, 0, 1, 1 );

Usage example

if ( creature.is_pc != 0 || IsInCategory( @summon_npc_group, creature.class_id ) ) {
    AddHateInfo( creature, ( 7 * 100 ), 0, 1, 1 );
}

GetMaxHateInfoNPC🟢 high

record with maximum hate

Returns the CHateInfo record with the greatest hate — the NPC's main target. The single argument from
manual_pch is not a "rank" but an indication of which metric to search the maximum by. The target is used
via the creature field of the obtained record.

Signature

GetMaxHateInfo( int nValueType )

Parameters

nValueType (int) — which metric to search the maximum by (manual_pch):
    @GMXHI_HATE_VALUE (0) — by permanent hate (the usual variant);
    @GMXHI_TEMP_VALUE (1) — by the temporary value.

Example

h0 = GetMaxHateInfo(0);

Usage example

h0 = GetMaxHateInfo(0);
if (IsNullHateInfo(h0) == @FALSE)
{
    if (IsNullCreature(h0.creature) == @FALSE)
    {
        MakeAttackEvent(h0.creature, 100, 0);
    }
}

GetHateInfoCountNPC🟢 high

number of records in the list

Returns the number of records in the hate list, no arguments. A result equal to zero means the NPC currently hates no one (no aggro); such a check is a common way to detect the absence of aggro before starting combat logic or to determine that we are facing the first aggressor.

Signature

GetHateInfoCount(  )

Parameters

(none — the function is called without arguments)

Example

i0 = GetHateInfoCount();
i1 = GetHateInfoCount();
i10 = GetHateInfoCount();

Usage example

if ( GetHateInfoCount( ) == 0 && i0 == 1 ) {
    AddHateInfo( creature, 300, 0, 1, 1 );
} else {
    AddHateInfo( creature, 100, 0, 1, 1 );
}

GetHateInfoByCreatureNPC🟢 high

record for a specific creature

Returns the CHateInfo hate record for a specific creature (CSharedCreatureData), to find out whether it is in the list and how much it is hated. The result is validated via IsNullHateInfo.

Signature

GetHateInfoByCreature( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — which creature to look up the record by.

Example

h0 = GetHateInfoByCreature(c0);

Usage example

h0 = GetHateInfoByCreature( speller );
if ( IsNullHateInfo( h0 ) == 1 ) {
    AddHateInfo( speller, 1, 0, 1, 1 );
}

GetHateInfoByIndexNPC🟢 high

record by position in the list

Returns the CHateInfo record by its ordinal position (nIndex) in the hate list. Used to iterate over all targets by their positions.

Signature

GetHateInfoByIndex( int nIndex )

Parameters

nIndex (int) — ordinal position (index) of the record in the hate list.

Example

h1 = GetHateInfoByIndex(i1);

Usage example

h0 = GetHateInfoByIndex( i0 );
if ( IsNullCreature( h0.creature ) == 0 && IsInCategory( @tanker_group, h0.creature.occupation ) != 1 && Maker_GetNpcCount( ) < 100 && DistFromMe( h0.creature ) <= 8000 ) {
    CreateOnePrivateEx( @valakas_lavasaurus, "ai_boss07_cannon", 0, 0, FloatToInt( h0.creature.x ) + Rand( 100 ), FloatToInt( h0.creature.y ) + Rand( 100 ), FloatToInt( h0.creature.z ), 0, h0.creature.id, 0, 0 );
}

GetNthHateInfoNPC🟢 high

n-th record with sorting applied

Returns the n-th CHateInfo record taking the sort criterion and traversal direction into account. The first argument sets the sort criterion (by hate value, ascending; other values are not implemented by the engine), the second — the ordinal number of the record in the sorted list, the third — the traversal direction: from the beginning or from the end of the list (for example, to take the most hated one when sorted ascending).

Signature

GetNthHateInfo( int nSortType, int nIndex, int nDirect )

Parameters

nSortType (int) — criterion for sorting the hate list before selection (for example, by hate value)
nIndex (int) — ordinal number of the record in the sorted list
nDirect (int) — traversal direction: from the beginning or from the end of the list

Example

h0 = GetNthHateInfo(@GNHI_HATE_VALUE, Rand(9) + 1, @GNHI_ORDER_DOWN);

Usage example

h0 = GetNthHateInfo(@GNHI_HATE_VALUE, Rand(9) + 1, @GNHI_ORDER_DOWN);
if (IsNullHateInfo(h0) == @FALSE)
{
    if (IsNullCreature(h0.creature) == @FALSE)
    {
        AddUseSkillDesire(h0.creature, Death_Clack, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 10000000);
    }
}

GetAvgHateValueNPC🟢 high

average hate across the list

Returns the average hate across the whole list, no arguments. Useful for mass-reset or normalization logic — for example, to add hate to everyone relative to the average.

Signature

GetAvgHateValue(  )

Parameters

(none — the function is called without arguments)

Example

GetAvgHateValue( );

RemoveHateInfoByCreatureNPC🟢 high

forget a specific target

Removes the specified creature (CSharedCreatureData) from the hate list — the NPC "forgets" this target. Used when resetting aggro on a specific player, for example after a teleport, death or leaving the zone. Returns nothing.

Signature

RemoveHateInfoByCreature( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — who to remove from the hate list.

Example

RemoveHateInfoByCreature(c0);

Usage example

if ( IsNullCreature( c0 ) == 0 && DistFromMe( c0 ) > 12000 ) {
    RemoveHateInfoByCreature( c0 );
}

RemoveAllHateInfoIFNPC🟢 high

mass removal by condition

Removes from the hate list all records matching a given condition. The condition is specified by a named constant from [manual_pch]: remove invalid (dead or vanished) targets, clear the entire list, remove those who moved farther than a given distance, or those whose hate is below a threshold. For conditions with a number, the second argument specifies the distance or hate threshold itself; for the "all" and "invalid" conditions it is zero. Returns nothing.

Signature

RemoveAllHateInfoIF( int nCondition, int nThreshold )

Parameters

nCondition (int) — removal condition
    Constants from [manual_pch] are used:
        @COND_ALL                (0) — all records of the list
        @COND_IS_INVALID         (1) — invalid records (target is invalid/gone)
        @COND_HAS_HATE_LESS_THAN (2) — records with hate below the given threshold
        @COND_IS_FAR_AWAY        (3) — records of targets that are too far away
nThreshold (int) — threshold: distance (for @COND_IS_FAR_AWAY) or hate value
    (for @COND_HAS_HATE_LESS_THAN); equals 0 for @COND_ALL / @COND_IS_INVALID.

Example

RemoveAllHateInfoIF(@COND_ALL, 0);

Usage example

if ( ( creature.level + 15 ) < myself.sm.level ) {
    RemoveAllHateInfoIF( 0, 0 );
    if ( creature.is_pc != 0 || IsInCategory( @summon_npc_group, creature.class_id ) ) {
        AddHateInfo( creature, ( 7 * 100 ), 0, 1, 1 );
    }
}

SetMaxHateListSizeNPC🟢 high

list size limit

Sets the maximum size of the hate list — how many targets the NPC remembers at once. Takes the maximum number of records; usually configured at NPC initialization. Returns nothing.

Signature

SetMaxHateListSize( int nMaxSize )

Parameters

nMaxSize (int) — maximum number of records (targets) the NPC remembers in the hate list.

Example

SetMaxHateListSize(1);

SetHateInfoListIndexNPC🟢 high

current cursor in the list

Sets the current index-cursor in the hate list for sequential traversal of records. Takes the cursor position; the exact meaning is not fully confirmed. Returns nothing.

Signature

SetHateInfoListIndex( int nIndex )

Parameters

nIndex (int) — current cursor position in the hate list for sequential traversal

Example

SetHateInfoListIndex( 1 );

Usage example

for( i0 = 0; i0 < 4; ++i0 ) {
    SetHateInfoListIndex( i0 );
    SetMaxHateListSize( 200 );
}

NPC behavior & parameters (Behavior / Params)

35 functions

AllocCodeInfoListGLOBAL🟢 high

create an accumulator list of options

Creates an empty accumulator list (CCodeInfoList) for the random-selection mechanism: options are put into it via SetInfo, then RandomSelectOne pulls one at random. Used in the logic of picking a random target/line/branch.

Signature

AllocCodeInfoList(  )

Parameters

(none — the function is called without arguments)

Example

always_list = AllocCodeInfoList( );
random1_list = AllocCodeInfoList( );

SetInfoGLOBAL🟢 high

put an option into a selection list

Adds to the accumulator list (created by AllocCodeInfoList) a pair "code + creature": nCode is the option identifier, cCreature is the associated creature (for example, a target candidate).

Signature

SetInfo( int nCode, CSharedCreatureData cCreature )

Parameters

nCode     (int) — the code identifier of the option in the accumulator list
cCreature (CSharedCreatureData) — the creature associated with the code

Example

random1_list.SetInfo( 0, target );

RandomSelectOneGLOBAL🟢 high

randomly pull one option from the list

Randomly picks and returns one element from the accumulator list previously filled via SetInfo. Completes the pairing AllocCodeInfoList -> SetInfo -> RandomSelectOne.

Signature

RandomSelectOne(  )

Parameters

(none — the function is called without arguments)

Example

code_info = random1_list.RandomSelectOne( );

GetNPCFromIDGLOBAL🟢 high

find an NPC by object-id

Returns an NPC by its object-id (nObjectId), which is often stored in param*/variables. The result is checked via IsNull* before accessing fields.

Signature

GetNPCFromID( int nObjectId )

Parameters

nObjectId (int) — the object-id of the NPC being searched

Example

npc0 = GetNPCFromID( myself.sm.param3 );
npc0 = GetNPCFromID( c0.id );
npc0 = GetNPCFromID( myself.sm.param1 );

Usage example

npc0 = GetNPCFromID( myself.sm.param3 );
if ( IsNull( npc0 ) == 0 ) {
    npc0.i_quest0 = 0;
}

IncreaseAPGLOBAL🟢 high

credit arena/fame points (AP)

Credits the player c with nAP arena/fame points (AP).

Signature

IncreaseAP( CSharedCreatureData c, int nAP )

Parameters

c (CSharedCreatureData) — the player credited with arena/fame points
nAP (int) — the number of AP points credited

Example

IncreaseAP(talker, 6);
IncreaseAP( talker, 5 );
IncreaseAP( talker, 8 );
IncreaseAP( talker, 10 );

SetNpcParamGLOBAL🟢 high

set a runtime parameter of an NPC

Sets a runtime parameter of the NPC c (a vital/combat coefficient): nVcpType is the type (@VCP_*), dValue is the value (float).

Signature

SetNpcParam( CSharedCreatureData cCreature, int nVcpType, float dValue )

Parameters

cCreature (CSharedCreatureData) — the NPC whose runtime parameter is set
nVcpType (int) — the choice of the parameter type being set
    a value from the @VCP_* family — creature properties (HP, MP, stats, attack/defense, etc.); the full list is in [manual_pch]
dValue (float) — the new parameter value

Example

SetNpcParam( myself.sm, @VCP_HP, myself.sm.max_hp * 0.2 );

Usage example

if ( myself.sm.flag == @SCE_FRINTESSA_SPAWN_DEMON_FINAL ) {
    SetNpcParam( myself.sm, @VCP_HP, myself.sm.max_hp * 0.2 );
    return;
}

GetValueGLOBAL🟢 high

read an atomic value

Reads an atomic value (a counter with thread-safe access, CAtomicValue).

Signature

GetValue(  )

Parameters

(none — the function is called without arguments)

Example

if ( myself.av_quest0.GetValue( ) != 1 ) {

Usage example

if ( myself.av_quest0.GetValue( ) != 1 ) {
    myself.i_quest0 = 0;
}

GetPchValueGLOBAL🟢 high

resolve a pch-constant's value by name

Resolves a pch-constant's value by its name string sName (dynamic access to the @-dictionary).

Signature

GetPchValue( string name )

Parameters

name (string) — the name of the `@`-constant whose value is to be obtained

Example

if ( GetPchValue( "client_hf" ) == 1 ) {

Usage example

if ( GetPchValue( "client_hf" ) == 1 ) {
    ShowBuySell( talker, SellList0, BuyList0, -50 );
} else {
    Sell( talker, SellList0, ShopName, fnBuy, _blank, _blank );
}

IsSameStringGLOBAL🟢 high

compare two strings

Compares two strings s1 and s2: returns 1 if equal, otherwise 0.

Signature

IsSameString( string s1, string s2 )

Parameters

s1 (string) — the first string being compared
s2 (string) — the second string being compared

Example

if ( IsSameString( DoorName, "altar_door_controller_basic_default" ) == 0 ) {

Usage example

if ( IsSameString( DoorName, "altar_door_controller_basic_default" ) == 0 ) {
    Castle_GateOpenClose2( DoorName, 0 );
}

IntToFStrGLOBAL🟢 high

a number to a string for substitution into phrases

Converts a number n to a string for substitution into phrases (FString).

Signature

IntToFStr( int64 nNum )

Parameters

nNum (int64) — the number converted to a string for substitution into phrases

Example

ChangeFStrNickName(myself.sm, 1801100, IntToFStr(i1));

GetCurrentTickNPC🟢 high

current server time in ticks

Returns the current server time in ticks (milliseconds of the server timer). Used for measuring intervals: remember the tick, later compare the difference (cooldowns, phase timings, dialog anti-spam).

Signature

GetCurrentTick(  )

Parameters

(none — the function is called without arguments)

Example

if ( ( GetCurrentTick( ) - talker.quest_last_reward_time ) > 1 ) {

Usage example

i0 = GetCurrentTick( );
if ( i0 > ( myself.i_quest1 + 5 ) ) {
    if ( IsNullCreature( myself.top_desire_target ) == 0 ) {
        if ( Skill_GetConsumeMP( Hold ) < myself.sm.mp && Skill_GetConsumeHP( Hold ) < myself.sm.hp && Skill_InReuseDelay( Hold ) == 0 ) {
            AddUseSkillDesire( myself.top_desire_target, Hold, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 1000000 );
        }
    }
}

GetTickNPC🟢 high

current server time in ticks

Same as GetCurrentTick: returns the current server time in ticks for measuring intervals between events.

Signature

GetTick(  )

Parameters

(none — the function is called without arguments)

Example

myself.i_ai1 = GetTick( );

Usage example

if ( ( GetTick( ) - myself.i_ai1 ) > ( ( 5 * 60 ) * 1000 ) ) {
    myself.i_ai3 = 0;
    BroadcastScriptEvent( 1000, 0, 300 );
}

GetLastAttackerNPC🟢 high

the last one who attacked the NPC

Returns the handle of the creature that last dealt damage to this NPC (for retaliation reactions). Check the result via IsNull* before accessing its fields.

Signature

GetLastAttacker(  )

Parameters

(none — the function is called without arguments)

Example

c1 = GetLastAttacker( );
c0 = GetLastAttacker( );
target = GetLastAttacker( );
c2 = GetLastAttacker();

Usage example

c1 = GetLastAttacker( );
if ( c1.master ) { c1 = c1.master; }

GetMasterUserNPC🟢 high

player-owner of a summoned NPC

For a summoned/summon NPC, returns the handle of the owning player. Check the result via IsNull* before accessing its fields.

Signature

GetMasterUser(  )

Parameters

    (none — the function is called without arguments)

Example: no direct calls in our scripts.

LookNeighborNPC🟢 high

look around, trigger perception of neighbors

Makes the NPC "look around": triggers neighbor perception events within radius nRadius (often before searching for targets).

Signature

LookNeighbor( int nRadius )

Parameters

nRadius (int) — radius for looking around at neighbors (in calls, e.g., 300).

Example

if ( AttackLowLevel == 1 ) { LookNeighbor( 300 ); }

ChangeMoveTypeNPC🟢 high

change movement manner

Changes the NPC's movement manner: nMoveType = @MT_SLOW (0, walking) or @MT_FAST (1, running).

Signature

ChangeMoveType( int nMoveType )

Parameters

nMoveType (int) — way of moving to the target when executing a desire
    Constants from [manual_pch] are used:
        @AMT_STAND          (0) — attack in place, without closing in
        @AMT_MOVE_TO_TARGET (1) — close in on the target and attack (pursue)

Example

ChangeMoveType(@MT_FAST);
ChangeMoveType( 1 );
ChangeMoveType( 0 );
ChangeMoveType(@MT_SLOW);

Usage example

if ( IsNullCreature( c0 ) == 0 ) {
    ChangeMoveType( 1 );
    AddMoveToDesire( FloatToInt( c0.x ), FloatToInt( c0.y ), FloatToInt( c0.z ), 10000000 );
}

ChangeMoveType2NPC🟢 high

change movement manner forcibly

Same as ChangeMoveType, plus bForce: when 1, the change is applied forcibly, bypassing checks.

Signature

ChangeMoveType2( int nMoveType, int bForce )

Parameters

nMoveType (int) — way of moving to the target when executing a desire
    Constants from [manual_pch] are used:
        @AMT_STAND          (0) — attack in place, without closing in
        @AMT_MOVE_TO_TARGET (1) — close in on the target and attack (pursue)
bForce (int) — flag for forced change bypassing checks (1 — forced)

Example

ChangeMoveType2(@MT_FAST, 1);
ChangeMoveType2( 0, 1 );
ChangeMoveType2( 1, 1 );
ChangeMoveType2(@MT_SLOW, 1);

FixMoveTypeNPC🟢 high

lock/unlock the movement type

Locks or unlocks the NPC's current movement type: bBlock = 1 forbids changing it, 0 allows it.

Signature

FixMoveType( int bBlock )

Parameters

bBlock (int) — lock flag: 1 — forbid changing the movement type, 0 — allow

Example

FixMoveType(1);

StopMoveNPC🟢 high

stop movement immediately

Immediately stops the NPC's movement.

Signature

StopMove(  )

Parameters

(none — the function is called without arguments)

Example

StopMove( );

Usage example

if ( myself.sm.in_peacezone != 0 ) {
    StopMove( );
    RemoveAllDesire( );
    RemoveAllHateInfoIF( 0, 0 );
    InstantTeleport( myself.sm, myself.start_x, myself.start_y, myself.start_z );
    return;
}

SetVisibleNPC🟢 high

show/hide the NPC

Shows or hides the NPC: bVisible = @FALSE (0) makes it invisible, @TRUE (1) — visible.

Signature

SetVisible( int bVisible )

Parameters

bVisible (int) — NPC visibility: @TRUE (1) — show, @FALSE (0) — hide.

Example

SetVisible(@FALSE);

Usage example

if ( GetSSQStatus( ) != @SS_SEAL_EFFECT && GetSSQStatus( ) != @SS_ACCOUNTING ) {
    SetVisible( 0 );
}

ChangeNPCStateNPC🟢 high

change the NPC's visual state

Changes the visual state/animation mode of NPC c to nState.

Signature

ChangeNPCState( CSharedCreatureData pCreatureShared, int nState )

Parameters

pCreatureShared (CSharedCreatureData) — the creature itself whose visual state is changed (usually `myself.sm`)
nState (int) — number of the new animation state/display mode

Example

ChangeNPCState(myself.sm, 1);

Usage example

if ( timer_id == OFF_TIMER ) {
    ChangeNPCState( myself.sm, 2 );
}

ChangeStatusNPC🟢 high

change the NPC's combat status/mode

Changes the NPC's displayed status — name visibility and whether it can be targeted.

Signature

ChangeStatus( int nStatus )

Parameters

nStatus (int) — new NPC status (manual_pch):
    @NAME_INVISIBLE (0) — hide the name; @NAME_VISIBLE (1) — show the name;
    @TARGET_DISABLE (2) — forbid targeting; @TARGET_ENABLE (3) — allow targeting.

Example

ChangeStatus(@TARGET_DISABLE);

ChangeDirNPC🟢 high

turn the NPC toward a target

Turns the NPC toward target nTargetId at angle nAngle; the first argument is the creature itself (usually myself.sm).

Signature

ChangeDir( CSharedCreatureData pCreatureShared, int nTargetId, int nAngle )

Parameters

pCreatureShared (CSharedCreatureData) — the creature itself being turned (usually `myself.sm`)
nTargetId (int) — identifier of the target toward which the NPC is turned
nAngle (int) — turn angle relative to the target

Example

ChangeDir(myself.sm, c0.id, 0);

Usage example

if ( FloatToInt( myself.sm.x ) == myself.start_x && myself.start_y == FloatToInt( myself.sm.y ) ) {
    ChangeDir( myself.sm, 0, direction );
} else {
    InstantTeleport( myself.sm, myself.start_x, myself.start_y, myself.start_z );
}

SuicideNPC🟢 high

the NPC dies instantly

The NPC instantly "dies" without specifying a culprit.

Signature

Suicide(  )

Parameters

(none — the function is called without arguments)

Example

Suicide( );

Usage example

if ( skill_name_id == SelfExplosion ) {
    Suicide( );
}

SuicideByNPC🟢 high

the NPC dies with a culprit specified

Same as Suicide, but specifies the culprit c (for logging/drop).

Signature

SuicideBy( CSharedCreatureData c )

Parameters

c (CSharedCreatureData) — creature responsible for the death (recorded in the log/counted for drop)

Example

SuicideBy( myself.c_ai0 );

PlayAnimationNPC🟢 high

play an NPC animation/social action

Plays an NPC animation/social action for surrounding players. Per the L2NPC decompile (CNPC::PlayAnimation_49348C)
both numbers go to clients in a packet with opcode 144 "cddd": the first is the animation number, the second is the
display radius (in scripts the variable is called FreewayPlayAniRange; in calls 600, 5000).

Signature

PlayAnimation( int nAnimId, int nRange )

Parameters

nAnimId (int) — number/identifier of the animation or social action to play (in calls 0..4).
nRange (int) — radius for showing the animation to those around (in calls 600, 5000).

Example

PlayAnimation(script_event_arg3, FreewayPlayAniRange);

Usage example

if (timer_id == PHASE_ANI) {
    PlayAnimation(4, 600);
}

GetMyDirectionNPC🟢 high

the NPC's current heading

Returns the NPC's current heading (facing direction); units are the same as GetDirection.

Signature

GetMyDirection(  )

Parameters

(none — the function is called without arguments)

Example

CreateOnePrivateEx(corpse, ai_corpse, 0, 0, FloatToInt(myself.sm.x), FloatToInt(myself.sm.y), FloatToInt(myself.sm.z), GetMyDirection(), GetIndexFromCreature(myself.sm), GetIndexFromCreature(myself.c_ai1), 0);

IsInThisTerritoryNPC🟢 high

whether the NPC is in a named territory

Returns 1 if the NPC is within the named territory sName, otherwise 0.

Signature

IsInThisTerritory( string sName )

Parameters

sName (string) — name of the named territory to check (e.g. "25_15_frintessa_NoCharge01").

Example

if ( IsInThisTerritory( "25_15_frintessa_NoCharge01" ) == 1 ) {

Usage example

if ( IsInThisTerritory( "25_15_frintessa_NoCharge01" ) == 1 ) {
    if ( IsNullCreature( c2 ) == 0 ) {
        AddUseSkillDesire( c2, DashAllVer1, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 10000 );
    }
}

IsInCombatModeNPC🟢 high

is the creature in combat mode

Returns whether the creature c is in combat mode (compared with @FALSE/@TRUE).

Signature

IsInCombatMode( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature whose combat mode is checked

Example

if (i0 > 15 && IsInCombatMode(myself.sm) == @FALSE)

Usage example

if ( IsInCombatMode( myself.sm ) == 0 ) {
    return;
}

IsBossNPC🟢 high

is the NPC a boss

Returns whether the NPC itself is a boss (compared with @FALSE/@TRUE).

Signature

IsBoss(  )

Parameters

(none — the function is called without arguments)

Example

if (IsBoss() == @FALSE)

Usage example

if ( IsBoss( ) == 0 ) {
    AddAttackDesire( speller, @AMT_MOVE_TO_TARGET, desire );
}

IsMyBossAliveNPC🟢 high

is "my" boss alive

For a minion returns whether its boss is alive (compared with @FALSE/@TRUE).

Signature

IsMyBossAlive(  )

Parameters

(none — the function is called without arguments)

Example

if (IsMyBossAlive() == @FALSE)

Usage example

if ( IsMyBossAlive( ) == 0 ) {
    Despawn( );
}

GetIdleTimeNPC🟢 high

how long the creature has been idle

Returns how long the creature c has been idle (without actions).

Signature

GetIdleTime( CSharedCreatureData c )

Parameters

c (CSharedCreatureData) — the creature whose idle time is requested

Example

if (creature.is_pc == 1 && GetIdleTime(creature) > 60)

Usage example

if (creature.is_pc == 1 && GetIdleTime(creature) > 60)
    {
        InstantTeleport(creature, 35118, 147753, -3528);
    }

SetDieEventNPC🟢 high

configure the NPC's death event

Enables/disables the broadcast of a creature's death event to the surroundings. Per the L2NPC decompile
(CNPC::SetDieEvent_496C38) the second argument is a boolean flag (stored as c!=0), the third — the broadcast
radius, limited by the engine to ≤ 2048 (otherwise the log "Too long distance to broadcast").

Signature

SetDieEvent( CSharedCreatureData c, int bEnable, int nBroadcastDist )

Parameters

c (CSharedCreatureData) — the creature for which the death-event broadcast is configured.
bEnable (int) — enable (1) or disable (0) the death-event broadcast.
nBroadcastDist (int) — the event broadcast radius, ≤ 2048 (in calls 2000; more — rejected with an error to the log).

Example

SetDieEvent( creature, 1, 2000 );
SetDieEvent( target, 1, 2000 );
SetDieEvent(attacker, 1, 2000);

Usage example

if ( IsNullCreature( creature ) == 0 && creature.is_pc == 1 ) {
    SetDieEvent( creature, 1, 2000 );
}

IncrementParamNPC🟢 high

change a character's parameter

Changes the character c's parameter by the amount nValue. nParam — @PARAM_*: EXP=0, SP=1, INT=2, STR=3, CON=4, MEN=5, DEX=6, WIT=7, LEVEL=8, PKCOUNT=9.

Signature

IncrementParam( CSharedCreatureData c, int nParam, int64 nValue )

Parameters

c (CSharedCreatureData) — the character whose parameter is changed.
nParam (int) — the choice of the character parameter being changed
    Constants from [manual_pch] are used:
        @PARAM_EXP              (0) — experience (EXP)
        @PARAM_SP               (1) — skill points (SP)
        @PARAM_INT              (2) — Intelligence (INT)
        @PARAM_STR              (3) — Strength (STR)
        @PARAM_CON              (4) — Constitution (CON)
        @PARAM_MEN              (5) — Mentality (MEN)
        @PARAM_DEX              (6) — Dexterity (DEX)
        @PARAM_WIT              (7) — Wit (WIT)
        @PARAM_LEVEL            (8) — level
        @PARAM_PKCOUNT          (9) — the player kill counter (PK)
        @PARAM_KARMA            (13) — karma
        @PARAM_SKILL_MULTIPLIER (65536) — the skill multiplier
nValue (int64) — the amount of the parameter change (signed).

Example

IncrementParam( talker, @PARAM_EXP, 2299404 * QuestExpRate );

Usage example

if ( DeleteItem1( talker, @adena, 650000 ) ) {
    IncrementParam( talker, @PARAM_SP, -30000 );
    PledgeLevelUp( talker, 1 );
}

GetAIParameterNPC🟢 high

read a creature's AI parameter

Reads the creature c's AI parameter by its type nType.

Signature

GetAIParameter( CSharedCreatureData c, int Type )

Parameters

c (CSharedCreatureData) — the creature whose AI parameter is read
Type (int) — which inventory metric to return
    Constants from [manual_pch] are used:
        @IPT_CURRENT_SLOT_COUNT   (0) — inventory slots currently occupied
        @IPT_MAX_SLOT_COUNT       (1) — maximum inventory slots
        @IPT_CURRENT_WEIGHT       (2) — current carried weight
        @IPT_MAX_CARRY_WEIGHT     (3) — maximum carry weight
        @IPT_CURRENT_QUEST_SCOUNT (4) — quest slots currently occupied
        @IPT_MAX_QUEST_SCOUNT     (5) — maximum quest slots

Example

i0 = GetAIParameter(myself.c_ai0, 3);

COMBAT, BEHAVIOR, WORLD OBJECTS AND UI MESSAGES (Combat / WorldTrap / AirShip / UI)

40 functions

SendUIEventGLOBAL🟢 high

send a UI event

Sends an interface event nMode to the player talker (CSharedCreatureData) with numeric parameters nArg1, nArg2 and strings sArg3..10; used for time counters, progress bars, etc. A method of the global object (CGlobalObject), no return value.

Signature

SendUIEvent( CSharedCreatureData cCreature, int nMode, int nArg1, int nArg2, string sArg1, string sArg2, string sArg3, string sArg4, string sArg5, string sArg6 )

Parameters

cCreature (CSharedCreatureData) — the recipient player of the interface event
nMode     (int) — the mode (type) of the interface event
nArg1     (int) — numeric parameter 1 of the event
nArg2     (int) — numeric parameter 2 of the event
sArg1     (string) — string parameter 1
sArg2     (string) — string parameter 2
sArg3     (string) — string parameter 3
sArg4     (string) — string parameter 4
sArg5     (string) — string parameter 5
sArg6     (string) — string parameter 6

Example

SendUIEvent( talker, 0, 0, 0, "0", "0", "0", "", "0", "0" );

Usage example

if ( talker.flag == 125 ) {
    SendUIEvent( talker, 0, 0, 0, "0", "60", "0", "Elapsed", "0", "0" );
}

SendUIEventFStrGLOBAL🟢 high

a UI event with an FString

The same as SendUIEvent, but with FString-formatting support (nFstringId — the phrase ID for insertion and additional strings sArg11..15). A method of the global object (CGlobalObject), no return value.

Signature

SendUIEventFStr( CSharedCreatureData cCreature, int nArg1, int nArg2, int nArg3, string pStr1, string pStr2, string pStr3, string pStr4, string pStr5, int nArg4, string pStr6, string pStr7, string pStr8, string pStr9, string pStr10 )

Parameters

cCreature (CSharedCreatureData) — the recipient player of the interface event
nArg1 (int) — the mode (type) of the interface event
nArg2 (int) — numeric parameter 1 of the event
nArg3 (int) — numeric parameter 2 of the event
pStr1 (string) — string parameter 1
pStr2 (string) — string parameter 2
pStr3 (string) — string parameter 3
pStr4 (string) — string parameter 4
pStr5 (string) — string parameter 5
nArg4 (int) — the identifier of the FString phrase for insertion
pStr6 (string) — additional string parameter 1
pStr7 (string) — additional string parameter 2
pStr8 (string) — additional string parameter 3
pStr9 (string) — additional string parameter 4
pStr10 (string) — additional string parameter 5

Example

SendUIEventFStr(target, 2, 0, 0, p_sNoTimer, IntToStr(myself.av_ai0.GetValue()), IntToStr(inst_duration), p_sPercent, "0", p_iTitleUI, _blank, _blank, _blank, _blank, _blank);

Usage example

if (myself.sm.flag == 2) {
    SendUIEventFStr(target, 2, 0, 0, p_sNoTimer, IntToStr(myself.av_ai0.GetValue()), IntToStr(inst_duration), p_sPercent, "0", p_iTitleUI, _blank, _blank, _blank, _blank, _blank);
} else {
    SendUIEventFStr(target, 5, 0, 0, p_sNoTimer, IntToStr(myself.av_ai0.GetValue()), IntToStr(inst_duration), p_sPercent, "0", p_iTitleUI, _blank, _blank, _blank, _blank, _blank);
}

ShowMsgInTerritoryGLOBAL🟢 high

a message in a territory

Announces the system message nSysMsgId to all players in the named territory sAnnounceArea with the zone object nZoneObjId. A method of the global object (CGlobalObject), no return value.

Signature

ShowMsgInTerritory( int nInZoneObjectId, string pwsAnnounceAreaName, int nSysMsgId )

Parameters

nInZoneObjectId (int) — the identifier of the zone object in which the message is announced
pwsAnnounceAreaName (string) — the name of the territory for the announcement
nSysMsgId (int) — the identifier of the system message

Example

ShowMsgInTerritory(0, AnnounceZone, systemmsgId);
ShowMsgInTerritory( 0, AnonceZone, 8377 );
ShowMsgInTerritory(0, AnonceZone, 8380);
ShowMsgInTerritory(0, AnonceZone, 8381);

ShowFStrMsgInTerritory2GLOBAL🟢 high

an FString message in a territory

The same as ShowMsgInTerritory, but with FString-formatting by nFstringId and substitution of up to 5 strings sStr1..5. A method of the global object (CGlobalObject), no return value.

Signature

ShowFStrMsgInTerritory2( int nInZoneObjectId, string pwsAnnounceAreaName, int nFstringId, string Str1, string Str2, string Str3, string Str4, string Str5 )

Parameters

nInZoneObjectId (int) — the identifier of the zone object in which the message is announced
pwsAnnounceAreaName (string) — the name of the territory for the announcement
nFstringId (int) — the identifier of the FString phrase for formatting
Str1 (string) — substitution string 1
Str2 (string) — substitution string 2
Str3 (string) — substitution string 3
Str4 (string) — substitution string 4
Str5 (string) — substitution string 5

Example

ShowFStrMsgInTerritory2(0, "25_15_frintezza_announce01", 1010643, IntToStr(myself.av_ai1.GetValue()), _blank, _blank, _blank, _blank);

GetAcquireExpRateBossGLOBAL🟢 high

the experience multiplier from a boss

Returns the experience multiplier for a character of level nLevel when killing a boss (usually less than 1 for high levels). A method of the global object (CGlobalObject), returns a float.

Signature

GetAcquireExpRateBoss( int nLevel )

Parameters

nLevel (int) — the character level for which the experience multiplier from a boss is returned

Example

i0 = FloatToInt(InstanceBossGetExp * GetAcquireExpRateBoss(target.level) * f0);

AddPCSocialGLOBAL🟢 high

a social action to a player

Performs the social action nSocialAction (dance, greeting, war cry, etc.) for the character with index nUserIndex. A method of the global object (CGlobalObject), no return value.

Signature

AddPCSocial( int nUserIndex, int nSocialAction )

Parameters

nUserIndex    (int) — the index of the performing character. Taken from GetIndexFromCreature(talker).
nSocialAction (int) — the type of social gesture. This is a @SAT_* constant (set in manual_pch);
                      a raw number is equivalent to the constant (in calls 3 == @SAT_VICTORY):

in code                       number smysl
@SAT_GREET                    2      greeting
@SAT_VICTORY                  3      victory gesture
@SAT_ADVANCE                  4      "advance"
@SAT_NO                       5      "no"
@SAT_YES                      6      "yes"
@SAT_BOW                      7      bow
@SAT_UNAWARE                  8      bewilderment
@SAT_WAITINGA                 9      waiting
@SAT_LAUGH                    10     laugh
@SAT_APPLAUS                  11     applause
@SAT_DANCE                    12     dance
@SAT_SAD                      13     sadness
@SAT_LEVEL_UP                 15     level-up effect
@SAT_HERO                     16     hero effect
@SAT_CURSED_WEAPON_LEVEL_UP   17     cursed weapon level-up

Actually found in scripts: @SAT_VICTORY/3 (widely), @SAT_BOW/7. The other values are
from the general list of gestures, available via the same function.

Example

AddPCSocial( GetIndexFromCreature(talker), @SAT_VICTORY );   // the player plays the victory gesture (same as 3)

CanAttackNPC🟢 high

check whether an attack is possible

Checks whether the NPC can attack the creature target (CSharedCreatureData); returns 1 if the attack is possible, 0 if it is blocked (immunity, peace zone, ghost, etc.). Creature method (CNPC).

Signature

CanAttack( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the attack target for which the NPC's ability to attack is checked

Example

if (CanAttack(myself.top_desire_target) == @TRUE)

Usage example

if ( CanAttack( attacker ) == 1 ) {
    MakeAttackEvent( attacker, ( damage / 2 ), 0 );
}

IsAttackableNPC🟢 high

check whether the target is attackable

Checks whether the target (CSharedCreatureData) can be hit — whether it exists on the map, is not hidden, is not in a special state; returns 1 if the target is attackable. Creature method (CNPC).

Signature

IsAttackable( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the target checked for being available to hit

Example

if (attacker.is_pc == @FALSE && ((attacker.npc_class_id != 1033609 && attacker.npc_class_id != 1033611 && attacker.npc_class_id != 1033613 && attacker.npc_class_id != 1033615 && attacker.npc_class_id != 1033618 && attacker.npc_class_id != 1033617 && attacker.npc_class_id != 1033798) && (attacker.npc_class_id != 1033620 && attacker.npc_class_id != 1033622 && attacker.npc_class_id != 1033624 && attacker.npc_class_id != 1033626 && attacker.npc_class_id != 1033629 && attacker.npc_class_id != 1033628 && attacker.npc_class_id != 1033799) && (attacker.npc_class_id != 1033631 && attacker.npc_class_id != 1033633 && attacker.npc_class_id != @hayuk_cartia_95_02 && attacker.npc_class_id != @elliyah_cartia_95_02 && attacker.npc_class_id != @elliyah_guard_95_01 && attacker.npc_class_id != @alice_cartia_95_02 && attacker.npc_class_id != @cartia_95_mirror) && attacker.npc_class_id != @soldier_cartia_85_01 && attacker.npc_class_id != @soldier_cartia_90_01 && attacker.npc_class_id != @soldier_cartia_95_01 && attacker.npc_class_id != @prisoner_cartia_85_01 && attacker.npc_class_id != @prisoner_cartia_90_01 && attacker.npc_class_id != @prisoner_cartia_95_01) && IsInCategory(@summon_npc_group, attacker.npc_class_id) == @FALSE && IsAttackable(attacker) == 1)

Usage example

if (IsAttackable(myself.sm) == @TRUE)
{
    SetAttackable(myself.sm, @FALSE);
}

SetAttackableNPC🟢 high

make a target attackable or unattackable

Sets or clears the attackable flag on the creature target (CSharedCreatureData): bFlag @TRUE/1 — attackable, @FALSE/0 — unattackable; usually applied to myself.sm for the NPC itself. Creature method (CNPC), no return value.

Signature

SetAttackable( CSharedCreatureData pCreatureShared, int nAttackable )

Parameters

pCreatureShared (CSharedCreatureData) — the creature whose attackable flag is set (usually the NPC itself via `myself.sm`)
nAttackable (int) — flag: `@TRUE`/1 — make attackable, `@FALSE`/0 — remove attackability

Example

SetAttackable(myself.sm, @FALSE);
SetAttackable(myself.sm, @TRUE);
SetAttackable( myself.sm, 0 );
SetAttackable( myself.sm, 1 );

Usage example

if ( attacker.is_pc == @TRUE && skill_name_id == @s_prominence11 ) {
    SetAttackable(myself.sm, @FALSE);
    Say("Now is NOT Attackable!");
}

GetPathfindFailCountNPC🟢 high

pathfinding failure counter

Returns the number of consecutive failures when computing the NPC's path; reset to zero on successful movement. Creature method (CNPC), no arguments.

Signature

GetPathfindFailCount(  )

Parameters

(none — the function is called without arguments)

Example

if (GetPathfindFailCount() > 10 && speller == myself.top_desire_target && FloatToInt(myself.sm.hp) != FloatToInt(myself.sm.max_hp)) {

Usage example

if (GetPathfindFailCount() > 10 && speller == myself.top_desire_target && FloatToInt(myself.sm.hp) != FloatToInt(myself.sm.max_hp)) {
    InstantTeleport(myself.sm, FloatToInt(speller.x), FloatToInt(speller.y), FloatToInt(speller.z));
}

GetWayPointDelayNPC🟢 high

delay at a route waypoint

Returns the delay time at the route node with index nIndex from the wayPoints array (waypointdelaystype). Creature method (CNPC), returns int.

Signature

GetWayPointDelay( WayPointDelaysType aWayPoints, int nIndex )

Parameters

aWayPoints (WayPointDelaysType) — the array of route node (waypoint) delays the value is taken from.
nIndex (int) — the index of the route node whose delay is returned.

Example

AddTimerEx( 100001, ( GetWayPointDelay( WayPointDelays, way_point_index ) * 1000 ) );

ChangeStopTypeNPC🟢 high

change stop type

Changes the NPC's behavior when stopped: nType (0 — stands and listens, 1 — active mode), nTimeout — time in milliseconds. Creature method (CNPC), no return value.

Signature

ChangeStopType( int nType, int nTimeout )

Parameters

nType (int) — stop behavior type: 0 — stands and listens, 1 — active mode.
nTimeout (int) — duration of the mode, milliseconds (30000 in calls).

Example

ChangeStopType(0, 30000);
ChangeStopType(1, 30000);

Usage example

if (myself.sm.stop_mode == 1) {
    ChangeStopType(0, 30000);
} else {
    ChangeStopType(1, 30000);
}

GetOverhitBonusNPC🟢 high

overhit bonus

Returns the "overhit" coefficient for a creature — how much stronger the last hit on it
was compared to what was needed for it to die. This is a fractional number: 1 means a normal
finishing blow with no excess, and greater than 1 means the creature was finished off with a
surplus (the bigger the excess, the higher the value). In scripts it is compared against
thresholds: > 1 — whether there was an overhit at all, >= 1.2 — whether the overhit was
strong enough to count a bonus or mark. There is a single argument — the creature whose
overhit is checked (usually myself.sm, i.e. the NPC that was killed). Returns a fractional
value (float).

Signature

GetOverhitBonus( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature whose overhit coefficient is checked (usually `myself.sm`).

Example

if (GetOverhitBonus(myself.sm) > 1)

Usage example

if (GetOverhitBonus(myself.sm) >= 1.200000) {
    SetMemoStateEx(last_attacker, 458, 2, GetMemoStateEx(last_attacker, 458, 2) + 1);
}

UnequipWeaponNPC🟢 high

remove weapon

Removes the NPC's main weapon; used when changing combat tactics. Creature method (CNPC), no arguments and no return value.

Signature

UnequipWeapon(  )

Parameters

(none — the function is called without arguments)

Example

UnequipWeapon();

Usage example

if (timer_id == CHANGE_TIMER) {
    UnequipWeapon();
}

SetEnchantOfWeaponNPC🟢 high

set weapon enchant level

Sets the enchant level of the NPC's weapon to nEnchantLevel (0, 10, 15, etc.). Creature method (CNPC), no return value.

Signature

SetEnchantOfWeapon( int nEnchantLevel )

Parameters

nEnchantLevel (int) — enchant level of the NPC's weapon (0, 10, 15 in calls).

Example

SetEnchantOfWeapon( 15 );
SetEnchantOfWeapon( 10 );
SetEnchantOfWeapon( 0 );

IsWeaponEquippedInHandNPC🟢 high

weapon in hand

Checks whether the creature target (CSharedCreatureData) has a weapon equipped in hand; returns 1 if it does, 0 if unarmed. Creature method (CNPC).

Signature

IsWeaponEquippedInHand( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature checked for having a weapon in hand

Example

if ( creature.is_pc == @TRUE && IsWeaponEquippedInHand( creature ) == 1 ) {

Usage example

if ( creature.is_pc == @TRUE && IsWeaponEquippedInHand( creature ) == 1 ) {
    if ( Skill_GetConsumeMP( Skill02_ID ) < myself.sm.mp && Skill_GetConsumeHP( Skill02_ID ) < myself.sm.hp && Skill_InReuseDelay( Skill02_ID ) == 0 ) {
        AddUseSkillDesire( creature, Skill02_ID, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 1000000 );
    }
    myself.c_ai0 = creature;
}

SetAbilityItemDropNPC🟢 high

control item drop

Controls the flag for dropping items when the NPC is killed: nFlag @FALSE/0 — no drop, 1 — drop enabled. Creature method (CNPC), no return value.

Signature

SetAbilityItemDrop( int nCanDrop )

Parameters

nCanDrop (int) — item drop flag on kill: `@FALSE`/0 — no drop, 1 — drop enabled

Example

SetAbilityItemDrop( 0 );
SetAbilityItemDrop(@FALSE);
SetAbilityItemDrop( 1 );

Usage example

if (IsInCategory(@beastfarm_beast, last_attacker.class_id) == 1) {
    SetAbilityItemDrop(0);
}

IsStackableItemExNPC🟢 high

item stackability

Checks whether the item with index nItemIndex can be combined into a stack; returns 1 if it is stackable.

Signature

IsStackableItemEx( int nItemIndex )

Parameters

nItemIndex (int) — the item index (usually from item_index_list.GetItemIndex) whose stackability is checked.

Example

if ( IsStackableItemEx( item_index_list.GetItemIndex( i1 ) ) ) {

Usage example

if ( IsStackableItemEx( item_index_list.GetItemIndex( i1 ) ) ) {
    AddGetItemDesireEx( item_index_list.GetItemIndex( i1 ), ( 10000 - i1 ) );
}

ChangeUserTalkTargetNPC🟢 high

change dialog target

Transfers the NPC's dialog focus to the creature npc (CSharedCreatureData); used in scripts with multiple NPCs to change the speaker. No return value.

Signature

ChangeUserTalkTarget( CSharedCreatureData pCreatureShared )

Parameters

pCreatureShared (CSharedCreatureData) — the creature (NPC) the dialog focus is transferred to

Example

ChangeUserTalkTarget( creature );
ChangeUserTalkTarget( myself.c_ai0 );
ChangeUserTalkTarget(talker);

IsAliveNPC🟢 high

check whether a creature is alive

Checks whether the creature (CCreature) is alive; returns 1 if alive, 0 if dead or in spirit form. Built-in method of the CCreature type.

Signature

IsAlive( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature checked for being alive

Example

if ( IsAlive( creature ) == @FALSE || ( creature.is_pc == 0 && IsInCategory( @summon_npc_group, creature.class_id ) == 0 ) ) {

Usage example

if ( IsAlive( creature ) == @FALSE || ( creature.is_pc == 0 && IsInCategory( @summon_npc_group, creature.class_id ) == 0 ) ) {
    return;
}

HotSpotChangeStateNPC🟢 high

change hotspot state

Switches the state of an interactive zone (Hotspot) at coordinates (nX, nY, nZ): nState 0, 1, 2 — different states (active, inactive, invisible, etc.). No return value.

Signature

HotSpotChangeState( int nState, int nX, int nY, int nZ )

Parameters

nState (int) — new zone state: 0, 1, 2 — active/inactive/invisible, etc.
nX (int) — X coordinate of the interactive zone
nY (int) — Y coordinate of the interactive zone
nZ (int) — Z coordinate of the interactive zone

Example

HotSpotChangeState(0, 90067, -110007, 1032);

ChangeZoneInfoNPC🟢 high

change a creature's zone attribute

Marks a specific creature with a zone mode — sets or clears an attribute on it
tied to a special zone (in calls this is @ZONEINFO_FREYA, the Freya battle zone). The first argument
is who it is set on (in scripts, a player from the hate list or an instant zone participant), the second is which
particular zone attribute, the third is the value of that attribute (1 or 2 in calls). By usage context the
values differ: one is set on participants while they are in the zone, the other (2) — right before
the creature is thrown out of the zone by teleporting it outside. The values nArg1 (zone attribute type,
@ZONEINFO_FREYA in calls) and nArg2 are passed to the client as a "zone effect", which the client
renders — so the exact interpretation of nArg2 (1/2 in calls) is left to the client side.
Returns nothing.

Signature

ChangeZoneInfo( CSharedCreatureData cCreature, int nArg1, int nArg2 )

Parameters

cCreature (CSharedCreatureData) — the creature whose zone attribute is changed (in calls — a player in the Freya zone).
nArg1 (int) — which zone attribute to change; in calls the constant @ZONEINFO_FREYA.
nArg2 (int) — the attribute value (1 or 2 in calls); by context 2 is used when removing the creature from the zone, 1while it is inside it.

Example

ChangeZoneInfo(creature, @ZONEINFO_FREYA, 2);

IsStaticObjectIDNPC🟢 high

check whether an ID is static

Checks whether nId is the identifier of a static object on the map; returns 1 if static. Creature method (CNPC).

Signature

IsStaticObjectID( int nId )

Parameters

nId (int) — the identifier checked for belonging to a static object.

Example

if (IsStaticObjectID(i0)) {

Usage example

if ( IsStaticObjectID( i0 ) ) {
    Say( MakeFString( 1110073, "", "", "", "", "" ) );
    return;
}

GetStaticObjectFromIDNPC🟢 high

get a static object by ID

Returns the static object structure (CSharedStaticObjectData) for identifier nId; used for interacting with static meshes and decorations. Creature method (CNPC).

Signature

GetStaticObjectFromID( int nId )

Parameters

nId (int) — the identifier of the static object whose structure is needed.

Example

so0 = GetStaticObjectFromID(i0);

Usage example

so0 = GetStaticObjectFromID( i0 );
if ( StaticObjectDistFromMe( so0 ) >= 2500 ) { SayFStr( 1110074, _blank, _blank, _blank, _blank, _blank ); } else
{
    if ( Skill_InReuseDelay( DDMagic ) ) { SayFStr( 1010551, _blank, _blank, _blank, _blank, _blank );  }
    if ( Skill_GetConsumeMP( DDMagic ) < myself.sm.mp && Skill_GetConsumeHP( DDMagic ) < myself.sm.hp && Skill_InReuseDelay( DDMagic ) == 0 ) {
        AddUseSkillDesireExByAction(i0, DDMagic, 0, reply, ask, 1000000, 0, action_id);
    }
}

SetStaticMeshStatusNPC🟢 high

change mesh status

Sets the parameters of the static mesh sMeshName on the object (CSharedCreatureData): bTargetable 0/1 — whether it can be targeted, nMeshIndex — mesh index in the list. No return value.

Signature

SetStaticMeshStatus( CSharedCreatureData object, string sMeshName, int bTargetable, int nMeshIndex )

Parameters

object (CSharedCreatureData) — the object on which the static mesh is configured.
sMeshName (string) — static mesh name.
bTargetable (int) — targeting flag: 0 — cannot be targeted, 1 — can be.
nMeshIndex (int) — mesh index in the list.

Example

SetStaticMeshStatus( c0, MeshName, targetable, mesh_index );
SetStaticMeshStatus( myself.c_ai0, MeshName, targetable, 0 );

Usage example

if ( mesh_index > -1 ) {
    SetStaticMeshStatus( myself.c_ai0, MeshName, targetable, 0 );
}

SetWorldTrapVisibleByClassIdNPC🟢 high

show or hide a trap

Controls the visibility of a world trap by class nClassId: nVisibleFlag 0/1 — hidden/visible; also used to switch trap states. No return value.

Signature

SetWorldTrapVisibleByClassId( int nClassId, int nVisibleFlag )

Parameters

nClassId (int) — the class of the world trap whose visibility is changed (usually myself.sm.class_id).
nVisibleFlag (int) — visibility flag: 0 — hidden, 1 — visible.

Example

SetWorldTrapVisibleByClassId(myself.sm.class_id, show_detected);

Usage example

if (IsDetected == 1) {
    SetWorldTrapVisibleByClassId(myself.sm.class_id, show_detected);
}

DefuseWorldTrapByClassIdNPC🟢 high

defuse a trap

Defuses a world trap by nTrapId and nClassId; the trap loses its ability to trigger. No return value.

Signature

DefuseWorldTrapByClassId( int nTrapId, int nClassId )

Parameters

nTrapId (int) — the identifier of the trap to defuse (usually myself.sm.id).
nClassId (int) — the class of the world trap (usually myself.sm.class_id).

Example

DefuseWorldTrapByClassId(myself.sm.id, myself.sm.class_id);

Usage example

if ( skill_name_id == trap_skill ) {
    DefuseWorldTrapByClassId( myself.sm.id, myself.sm.class_id );
}

ActivateWorldTrapByClassIdNPC🟢 high

activate a trap

Activates a world trap by nTrapId and nClassId; the trap becomes ready to trigger when its trigger is entered. No return value.

Signature

ActivateWorldTrapByClassId( int nTrapId, int nClassId )

Parameters

nTrapId (int) — the identifier of the trap to activate (usually myself.sm.id).
nClassId (int) — the class of the world trap (usually myself.sm.class_id).

Example

ActivateWorldTrapByClassId(myself.sm.id, myself.sm.class_id);

Usage example

if ( script_event_arg1 == 12550 ) {
    ActivateWorldTrapByClassId( myself.sm.id, myself.sm.class_id );
}

RegisterAsAirportManagerNPC🟢 high

register an airport manager

Registers the NPC as an airport manager: nAirportId, nPlatformId, nAirportType (0 — regular, 1 — premium, etc.); returns a result code (int).

Signature

RegisterAsAirportManager( int nAirportId, int nPlatformId, int nAirportType )

Parameters

nAirportId (int) — airport identifier.
nPlatformId (int) — platform identifier.
nAirportType (int) — airport type (0 — regular, 1 — premium, etc.; 1 in calls).

Example

myself.i_ai1 = RegisterAsAirportManager(airport_ID, platform_ID, 1);

GetOnAirShipNPC🟢 high

board a player onto an airship

Places the player talker (CSharedCreatureData) onto the airship platform (checks for available space and a ticket). No return value.

Signature

GetOnAirShip( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player placed onto the airship platform

Example

GetOnAirShip(talker);

Usage example

if (talker.yongma_type == 0) {
    GetOnAirShip(talker);
} else {
    ShowSystemMessage(talker, 2258);
}

BuyAirShipNPC🟢 high

buy a ship ticket

Sells the player talker (CSharedCreatureData) a ticket for ship nShipId (deducts adena, puts the ticket in the inventory). No return value.

Signature

BuyAirShip( CSharedCreatureData c, int nShipId )

Parameters

c (CSharedCreatureData) — the player buying the ship ticket.
nShipId (int) — the identifier of the ship the ticket is sold for (2 in calls).

Example

BuyAirShip(talker, 2);

Usage example

if (OwnItemCount( talker, AirshipConfirm ) > 0) {
    BuyAirShip(talker, 2);
} else {
    ShowSystemMessageStr(talker, MakeFString(1800277, "", "", "", "", ""));
}

SummonAirShipNPC🟢 high

summon a ship to the platform

Summons an airship to the airport platform for the player talker (CSharedCreatureData).
Argument order follows the real calls (SummonAirShip(talker, airport_ID, platform_ID)):
first the airport id, then the platform id. No return value.

Signature

SummonAirShip( CSharedCreatureData c, int nAirportId, int nPlatformId )

Parameters

c (CSharedCreatureData) — the player for whom the airship is summoned.
nAirportId (int) — airport identifier (airport_ID in calls).
nPlatformId (int) — identifier of the summoning platform (platform_ID in calls).

Example

SummonAirShip(talker, airport_ID, platform_ID);
SummonAirShip( talker, AIRPORT_ID, PLATFORM_ID );

Usage example

if (OwnItemCount( talker, EnergyStone ) >= 5) {
    SummonAirShip(talker, airport_ID, platform_ID);
} else {
    ShowSystemMessageStr(talker, MakeFString(1800250, "", "", "", "", ""));
}

IsOccupiedPlatformNPC🟢 high

check whether the platform is occupied

Checks whether platform nPlatformId is occupied by a player or a ship; returns 1 if occupied.

Signature

IsOccupiedPlatform( int nPlatformId )

Parameters

nPlatformId (int) — the identifier of the platform whose occupancy is checked (myself.i_ai1 in calls).

Example

if (IsOccupiedPlatform(myself.i_ai1) == @FALSE)

RegisterTeleporterTypeNPC🟢 high

register a teleporter type

Registers teleporter type nType with cost nCost; used for different groups of destinations (RaidBoss, Dungeon, etc.). Creature method (CNPC), no return value.

Signature

RegisterTeleporterType( int nType, int nCost )

Parameters

nType (int) — teleporter type / destination group (1, 3 in calls).
nCost (int) — teleport cost (0, 40 in calls).

Example

RegisterTeleporterType(1, 0);

Usage example

if ( UseFreeTeleportBfr40lv == 1 ) {
    RegisterTeleporterType( 3, 40 );
}

ShowTelPosListPageNPC🟢 high

show teleport list

Shows the player talker (CSharedCreatureData) the list of available destinations posList (TelPosList) — usually special lists such as RaidBossList20_29. Creature method (CNPC), no return value.

Signature

ShowTelPosListPage( CSharedCreatureData c, CTelPosList posList )

Parameters

c (CSharedCreatureData) — the player the destination list is shown to.
posList (CTelPosList) — the destination list to display (e.g. RaidBossList20_29).

Example

ShowTelPosListPage( talker, RaidBossList20_29 );

SendPostNPC🟢 high

send a letter with items

Sends a letter to player nUserId with subject sTitle and body sMsg (usually via MakeFString), an adena amount nTradeMoney and up to 9 items (ID and quantity pairs); the letter arrives in the mailbox. Creature method (CNPC), no return value.

Signature

SendPost( int nUserDbId, string sTitle, string sMsg, int nTradeMoney, int nItemId1, int nItemAmount1, int nItemId2, int nItemAmount2, int nItemId3, int nItemAmount3, int nItemId4, int nItemAmount4, int nItemId5, int nItemAmount5, int nItemId6, int nItemAmount6, int nItemId7, int nItemAmount7, int nItemId8, int nItemAmount8, int nItemId9, int nItemAmount9 )

Parameters

nUserDbId (int) — database identifier of the recipient player
sTitle (string) — letter subject
sMsg (string) — letter body (usually via `MakeFString`)
nTradeMoney (int) — amount of attached adena
nItemId1 (int) — identifier of attached item 1
nItemAmount1 (int) — quantity of attached item 1
nItemId2 (int) — identifier of attached item 2
nItemAmount2 (int) — quantity of attached item 2
nItemId3 (int) — identifier of attached item 3
nItemAmount3 (int) — quantity of attached item 3
nItemId4 (int) — identifier of attached item 4
nItemAmount4 (int) — quantity of attached item 4
nItemId5 (int) — identifier of attached item 5
nItemAmount5 (int) — quantity of attached item 5
nItemId6 (int) — identifier of attached item 6
nItemAmount6 (int) — quantity of attached item 6
nItemId7 (int) — identifier of attached item 7
nItemAmount7 (int) — quantity of attached item 7
nItemId8 (int) — identifier of attached item 8
nItemAmount8 (int) — quantity of attached item 8
nItemId9 (int) — identifier of attached item 9
nItemAmount9 (int) — quantity of attached item 9

Example

case @kamaloka_29_d_boss: { SendPost(target.dbid, MakeFString(3681150, _blank, _blank, _blank, _blank, _blank), MakeFString(3681151, MakeFString(3681162, _blank, _blank, _blank, _blank, _blank), _blank, _blank, _blank, _blank), 0, inst_reward_bow_29, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; }

ShowSysMsgToParty2NPC🟢 high

system message to a party

Shows system message nSysMsgId to all members of the party (CSharedPartyData) with parameter substitution; nParamCount — number of parameters, then nParam1..4 and nValue. Creature method (CNPC), no return value.

Signature

ShowSysMsgToParty2( CSharedPartyData party, int nSysMsgId, int nParamCount, int nParam1, int nParam2, int nParam3, int nParam4 )

Parameters

party (CSharedPartyData) — the party all of whose members are shown the message.
nSysMsgId (int) — system message identifier.
nParamCount (int) — number of substitution parameters passed.
nParam1 (int) — substitution parameter 1.
nParam2 (int) — substitution parameter 2.
nParam3 (int) — substitution parameter 3.
nParam4 (int) — substitution parameter 4 / value.

Example

ShowSysMsgToParty2(party0, 2, 1381, 3, 5901, 1, i1);

ShowVariationMakeWindowNPC🟢 high

variation creation window

Opens the item variation (augmentation) creation interface for the player talker (CSharedCreatureData). Creature method (CNPC), no return value.

Signature

ShowVariationMakeWindow( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player for whom the variation (augmentation) creation window is opened

Example

ShowVariationMakeWindow(talker);

Usage example

if (reply == 100) {
    ShowVariationMakeWindow(talker);
} else
if (reply == 200) {
    ShowVariationCancelWindow(talker);
}

ShowVariationCancelWindowNPC🟢 high

variation cancel window

Opens for the player talker (CSharedCreatureData) the interface for removing a variation from an item. Creature method (CNPC), no return value.

Signature

ShowVariationCancelWindow( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player for whom the variation removal window is opened

Example

ShowVariationCancelWindow(talker);

Usage example

if (reply == 200) {
    ShowVariationCancelWindow(talker);
}

ShowBaseAttributeCancelWindowNPC🟢 high

base attribute cancel window

Opens for the player talker (CSharedCreatureData) the interface for removing an item's base attribute. No return value.

Signature

ShowBaseAttributeCancelWindow( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player for whom the base attribute removal window is opened

Example

ShowBaseAttributeCancelWindow(talker);

Usage example

if (reply == 611) {
    ShowBaseAttributeCancelWindow(talker);
}

NPC CREATION (NPC-create)

12 functions

CreatePrivatesNPC🟢 high

summon a whole group of subordinates

Spawns a whole group of subordinates by the set name sGroupName, predefined
in the NPC data. Takes one argument — a string with the set name (often the variable
Privates), no namespace. Returns nothing. The most frequent way to summon a
retinue or a wave of minions in a single call.

Signature

CreatePrivates( string sGroupName )

Parameters

sGroupName (string) — the name of the subordinate set from the NPC data (often the variable Privates).

Example

CreatePrivates(Privates);

Usage example

if ( myself.sm.param1 == 4 ) {
    CreatePrivates( Privates1 );
}

CreateOnePrivateNPC🟢 high

create one subordinate near the creator

Creates one subordinate NPC of the given class near the creator, without explicit
coordinates. Takes the NPC class nNpcClassId from [npc_pch], the AI name/type sName,
as well as nWeightPoint (spawn point/weight) and nRespawnTime (auto-respawn period) —
the latter two, unlike in the Ex version, are NOT user param slots, which is seen
from the named calls with the fields weight_point and respawn_time. Returns nothing.
Related event: on the created NPC, CREATED(reply) fires (see NASC_HANDLERS).

Signature

CreateOnePrivate( int nNpcClassId, string sName, int nWeightPoint, int nRespawnTime )

Parameters

nNpcClassId (int) — the class of the created NPC.
    the values are from the [npc_pch] dictionary
sName (string) — the AI name/type of the created NPC.
nWeightPoint (int) — the spawn point/weight (private.weight_point; often 0).
nRespawnTime (int) — the auto-respawn period, sec (private.respawn_time, 300, 280+Rand(40); 0=no respawn).

Example

CreateOnePrivate( @grima, "grima", 0, 1 );

Usage example

if ( private != myself.sm && private.respawn_time != 0 ) {
    CreateOnePrivate( private.npc_class_id, private.ai, private.weight_point, private.respawn_time );
}

CreateOneAnotherNPC🟢 high

create one independent NPC by coordinates

Creates one independent NPC of the given class at the exact coordinates x, y, z
(not subordinate to the creator). Takes the NPC class nNpcClassId from [npc_pch], the AI name/type
sName, and three integer coordinates. Returns nothing. Used when
you need to place a mob or object at a specific spot in the world.

Signature

CreateOneAnother( int npc_class_id, string npc_name, int x, int y, int z )

Parameters

npc_class_id (int) — the class of the created NPC.
    the values are from the [npc_pch] dictionary
npc_name (string) — the AI name/type.
x (int) — the X coordinate.
y (int) — the Y coordinate.
z (int) — the Z coordinate.

Example

CreateOneAnother(@ow_kegor, "ow_kegor", 114650, -114522, -11205);

Usage example

if ( Rand( 1200 ) < 1 ) {
    CreateOneAnother( @sia_champion_group, "sia_champion_group", pos0.x, pos0.y, pos0.z );
}

CreateOnePrivateNearUserNPC🟢 high

a subordinate near the specified player

Creates a subordinate NPC (private) near the specified player, rather than near the creator itself.
The NPC's spawn point is chosen not rigidly: it takes the player's location as the center and moves away from it by a
random distance within the given radius, in a random direction. The resulting point it
checks for passability (an NPC cannot be placed in a wall or underground) and on failure tries
another; the ready NPC it turns to face the player. Therefore two identical calls will give
subordinates in different spots around the player — this is convenient for "near the player" event spawns
(gifts, helpers, traps), when exact coordinates do not matter, what matters is proximity to the person.

The first argument is the player-center. The second — which NPC to create (a code from [npc_pch]). The third —
the behavior name/type (AI) of the newborn. The fourth — the subordinate's "weight": the higher it is, the more
actively the private draws enemies onto itself and the more it weighs in the target-priority calculations (usually the
creator's own weight is passed, myself.sm.weight_point). The last three numbers control placement
around the player; in a live call it is 1, 90, 60, and one of them sets the radius of the random scatter
from the player in world units. Returns nothing.
Related event: on the created NPC, CREATED fires (see NASC_HANDLERS).

Signature

CreateOnePrivateNearUser( CSharedCreatureData cUser, int nNpcClassId, string sName, int nWeightPoint, int nParam4, int nParam5, int nParam6 )

Parameters

cUser (CSharedCreatureData) — the player around whom the subordinate appears (its location is the scatter center).
nNpcClassId (int) — which NPC to create; a code from the [npc_pch] dictionary.
sName (string) — the behavior name/type (AI) of the created NPC.
nWeightPoint (int) — the subordinate's "weight" in the aggro/target-priority calculations; usually `myself.sm.weight_point`.
nParam4 (int) — a placement parameter (1 in the call).
nParam5 (int) — a placement parameter (90 in the call); sets the radius of the random scatter around the player in world units.
nParam6 (int) — a placement parameter (60 in the call).

Example

CreateOnePrivateNearUser( talker, @br_santa_white_gift, "br_santa_white_gift", myself.sm.weight_point, 1, 90, 60 );

Usage example

if ( IsNullCreature( talker ) == 0 ) {
    CreateOnePrivateNearUser( talker, @br_santa_white_gift, "br_santa_white_gift", myself.sm.weight_point, 1, 90, 60 );
}

CreateOnePrivateExNPC🟢 high

a full subordinate spawn with coordinates, rotation, and parameters

A full spawn of one subordinate: the NPC class nNpcClassId from [npc_pch], the AI type
sAiType, the spawn point nWeightPoint, the delay nDelaySec, the exact coordinates x, y, z,
the rotation nHeading (client units, often as the product of an angle by 182), and three
user parameters nUser1..nUser3. Returns the result (the index/identifier of the
created creature). The decoding of the two middle numbers — per the L2NPC decompile
(CNPC::CreateOnePrivateEx_4B7D90): the engine sets AddTimer(obj, 1000*nDelaySec, 0),
i.e. the 4th argument is the spawn delay in seconds; the 3rd argument is placed into the spawn-point
field (in calls literally private.weight_point is found, as with CreateOnePrivate).
The last three numbers are arbitrary user slots: the engine places them into the created
creature, and it reads them as myself.sm.param1/param2/param3, while other scripts — as
param1/param2/param3 of this creature; there the owner or target index, dbid,
a tag, coordinates are stored — the meaning is set by the script itself.
Related event: on the created NPC, CREATED(reply) fires (see NASC_HANDLERS).

Signature

CreateOnePrivateEx( int nNpcClassId, string sAiType, int nWeightPoint, int nDelaySec, int x, int y, int z, int nHeading, int nUser1, int nUser2, int nUser3 )

Parameters

nNpcClassId (int) — the NPC class.
    the values are from the [npc_pch] dictionary
sAiType (string) — the AI-type name (e.g. myself.sm.ai, "HelpHeroAI").
nWeightPoint (int) — the spawn point/weight (in calls 0, 10, private.weight_point).
nDelaySec (int) — the spawn delay in seconds (engine: AddTimer(1000*nDelaySec);
    0 = immediately; 5, Rand(5), 20, 30+Rand(60) are found).
x (int) — the X coordinate (FloatToInt(...)).
y (int) — the Y coordinate.
z (int) — the Z coordinate.
nHeading (int) — the rotation (client units; i0*182, 32768=180°, full circle 65536).
nUser1 (int) — user data → created.param1.
nUser2 (int) — user data → created.param2.
nUser3 (int) — user data → created.param3.

Example

CreateOnePrivateEx( @mikhail, "mikhail", 10, 5, 178304, -17712, -2194, 32768, 0, 0, 0 );

Usage example

if ( HavePet == 1 ) {
    CreateOnePrivateEx( silhouette, ai_type, 0, 0, FloatToInt( ( myself.sm.x + 10 ) ), FloatToInt( ( myself.sm.y + 10 ) ), FloatToInt( myself.sm.z ), 0, 0, 0, 0 );
}

CreateOnePrivateInzoneExNPC🟢 high

spawn a subordinate inside an instant zone

Does the same as CreateOnePrivateEx, but the spawn happens inside an instant zone:
the last, twelfth argument nZoneId — the zone/instance id — is added. Per the L2NPC decompile
(CNPC::CreateOnePrivateInzoneEx_4B7BE4) the argument layout matches Ex:
the same AddTimer(obj, 1000*nDelaySec, 0) (the 4th argument is the delay in seconds), the 3rd —
the spawn point; the three numbers before the zone are the user slots nUser1..nUser3 (placed
into the created creature as param1/param2/param3). Returns the index of the created creature.
Related event: on the created NPC, CREATED(reply) fires (see NASC_HANDLERS).

Signature

CreateOnePrivateInzoneEx( int nNpcClassId, string sAiType, int nWeightPoint, int nDelaySec, int x, int y, int z, int nHeading, int nUser1, int nUser2, int nUser3, int nZoneId )

Parameters

nNpcClassId (int) — the class of the created NPC.
    the values are from the [npc_pch] dictionary
sAiType (string) — the AI-type name of the created NPC.
nWeightPoint (int) — the spawn point/weight (in calls usually 0).
nDelaySec (int) — the spawn delay in seconds (engine: AddTimer(1000*nDelaySec); 0 = immediately).
x (int) — the X coordinate of the spawn point.
y (int) — the Y coordinate of the spawn point.
z (int) — the Z coordinate of the spawn point.
nHeading (int) — the rotation (client units; 32768=180°, full circle 65536).
nUser1 (int) — user data → created.param1.
nUser2 (int) — user data → created.param2.
nUser3 (int) — user data → created.param3.
nZoneId (int) — the zone/instance id of the spawn (usually InstantZone_GetId()).

Example

CreateOnePrivateInzoneEx(i1, "warriors_of_rest", 0, 0, 55672, -252728, -6760, 0, 0, 2, 0, InstantZone_GetId());

Usage example

if ( timer_id == 1001 ) {
    CreateOnePrivateInzoneEx( @portrait_spirit_winged, "ai_boss08_portrait_spirit_winged", 0, 0, SpawnPosX, SpawnPosY, SpawnPosZ, SpawnAngle, 0, 0, 0, InstantZone_GetId( ) );
}

CreatePetNPC🟢 high

create a pet for a player from a summon item

Creates a pet for the owner cOwner from the summon item nItemClassId (a whistle or
ocarina) with the appearance/class of the NPC nNpcClassId and the given level. The fourth argument —
the pet's level: in real calls this is talker.level or the numbers 1, 15, 24, 25, 26,
55, matching the hatchling's level. Returns nothing. Used by NPC pet-breeders
when "activating" a hatchling from a purchased ticket.

Signature

CreatePet( CSharedCreatureData cOwner, int nItemClassId, int nNpcClassId, int nLevel )

Parameters

cOwner (CSharedCreatureData) — the future owner of the pet.
nItemClassId (int) — the pet summon item.
    the values are from the [item_pch] dictionary
nNpcClassId (int) — the class/appearance of the pet.
    the values are from the [npc_pch] dictionary
nLevel (int) — the level of the created pet (in calls talker.level or 1/15/24/25/26/55).

Example

CreatePet( talker, @wolf_collar, @pet_wolf_a, 15 );

Usage example

if ( i0 < 75 ) {
    CreatePet( talker, @dragonflute_of_star, @hatchling_of_star, 35 );
} else {
    CreatePet( talker, @dragonflute_of_twilight, @hatchling_of_twilight, 35 );
}

CreateSubPledgeNPC🟢 high

create a clan sub-unit

Creates a sub-unit (royal guard / knight) for the player's clan. The clan is taken from the passed
creature. The operation is asynchronous: L2NPC assembles an atomic-job, the server (AtomicCreateSubPledge::Do →
CDB::RequestCreateSubPledgeByNpc) invokes the creation of the sub-unit in the DB. By the signature of the server
function, its third parameter has the type enum PledgeType — this is nType. It immediately returns zero;
the actual result arrives as a separate event. If the creature has no clan, the task is not created.

Signature

CreateSubPledge( CSharedCreatureData c, int nType, int nParam, string sName )

Parameters

c (CSharedCreatureData) — the creature for whose clan the sub-unit is created.
nType (int) — the sub-unit type (enum PledgeType, confirmed by the server function's signature):
    100 royal guard 1, 200 royal guard 2, 1001/1002 knight 1/2, 2001/2002 knight 3/4.
nParam (int) — an additional creation parameter, passed to the DB request for creating the sub-unit (DB packet opcode 247).
sName (string) — the name of the sub-unit (up to 24 characters).

Example

CreateSubPledge(talker, i0, i1, s0);

CreateSubJobNPC🟢 high

create a subclass (a second profession)

Sets up a subclass for the player — a second profession he can switch to. The first
argument is the player himself, the second — which profession to open (its class_id). The result arrives not
immediately: in response to the addition of a subclass, the player receives the SUBJOB_CREATED event, in which it is
checked whether it succeeded (for example, whether the subclass limit is not exceeded, whether the class fits). In
the conditions before the call they usually look at the player's current profession and already-existing subclasses,
so as not to open a forbidden or duplicating combination.

Signature

CreateSubJob( CSharedCreatureData c, int nClassId )

Parameters

c (CSharedCreatureData) — the creature for whom the subclass (second profession) is created.
nClassId (int) — the class id of the created profession (occupation from [class_pch];
    in calls @berserker and the numbers 2, 12, 13, 14, 16, 17, 20, 21, 23, 24 — these are the profession's class_id).

Example

CreateSubJob( talker, @berserker );

Usage example

    if ( i0 != 12 && i0 != 94 && i2 != 12 && i2 != 94 && i4 != 12 && i4 != 94 && i6 == -1 && ( IsInCategory( @third_class_group, i0 ) || IsInCategory( @fourth_class_group, i0 ) ) ) {
        CreateSubJob( talker, 12 );
    }

Related event: the server's response arrives as the SUBJOB_CREATED event (see NASC_HANDLERS).

CreateAcademyNPC🟢 high

create a clan academy

Creates a clan academy for the player's clan with the specified name (up to 24 characters).
Asynchronous (an internal task): returns one if the task was placed, and zero
if a creature was not passed. The clan is taken from the creature.

Signature

CreateAcademy( CSharedCreatureData c, string sName )

Parameters

c (CSharedCreatureData) — the creature for whose clan the academy is created.
sName (string) — the academy name (up to 24 characters).

Example

CreateAcademy(talker, s0);

CreatePVPMatchNPC🟢 high

initiate a PvP match

Creates/starts a PvP match in the slot with the given number. The number must be from 0 to 8
(otherwise the engine logs an error and does nothing). Sends the server the command
to create the match of this slot. Returns nothing.

Signature

CreatePVPMatch( int nMatchSlot )

Parameters

nMatchSlot (int) — the match slot index, 0..8 (otherwise the engine logs an error and does nothing).

Example

CreatePVPMatch( i0 );
CreatePVPMatch(nType);

CreateBingoBoardNPC🟢 high

create a bingo game board

Creates a square bingo board (minigame) with side nBoardSize for a player. Per the L2NPC decompile
(User::CreateBingoBoard_5B4CEC) the second argument is the board's side length: the engine builds
nBoardSize×nBoardSize cells and rejects EVEN values (the side must be odd);
in calls 3 is passed → a 3×3 board (9 cells). If the player is not found or the side is even —
returns zero.

Signature

CreateBingoBoard( CSharedCreatureData c, int nBoardSize )

Parameters

c (CSharedCreatureData) — the player for whom the bingo board is created.
nBoardSize (int) — the side length of the square board (odd; the board is nBoardSize²);
    in calls 3 (a 3×3 board). The engine rejects even values.

Example

CreateBingoBoard(talker, 3);

FINDING AND GETTING CREATURES (Target-finding)

75 functions

GetCreatureFromIndexGLOBAL🟢 high

creature by session index

Returns a creature by its session index nIndex — the creature's temporary slot in server memory, valid while the creature is "alive" in the world. Single argument: nIndex (int, no namespace; −1 = none). Belongs to gg; if the index is invalid, an "empty" creature is returned, so the result is checked via IsNullCreature, or the index itself is compared against −1 beforehand.

Signature

GetCreatureFromIndex( int nIndex )

Parameters

nIndex (int) — session index of the creature (−1 = none).

Example

c0 = GetCreatureFromIndex( i0 );

Usage example

c1 = GetCreatureFromIndex( i1 );
if ( IsNullCreature( c1 ) == 0 ) { SendScriptEvent( c1, GetIndexFromCreature( myself.sm ), 0 ); }

GetCreatureFromIDGLOBAL🟢 high

creature by permanent ID

Returns a creature by its permanent object ID nID — the same one stored in the creature's id field. Single argument: nID (int, no namespace). Belongs to gg; the ID is more reliable than the index and convenient for storing in lists and instance "rooms", and on a miss the function returns an "empty" creature (check with IsNullCreature).

Signature

GetCreatureFromID( int nID )

Parameters

nID (int) — permanent ID of the creature (creature.id).

Example

c0 = GetCreatureFromID(GetGlobalMap(@gm_cartia_adolf));

Usage example

c0 = GetCreatureFromID( room0.GetMemberID( i0 ) );
if ( HaveMemo( c0, @in_the_dimension_rift ) ) {
    SetMemoStateEx( c0, @in_the_dimension_rift, 1, -1 );
}

GetCreatureExFromIndexGLOBAL🟢 high

extended creature data by index

Given a creature's numeric index, returns its "extended" object (CSharedCreatureDataEx) —
a superstructure over the regular creature object with additional fields absent from the base one.
Useful when only an index is at hand but access to the extended properties is needed. Paired
with GetCreatureEx, which does the same but starts from an already available base object rather
than an index. Returns an empty result for an invalid index.

Signature

GetCreatureExFromIndex( int nSMIndex )

Parameters

    nSMIndex (int) — numeric index of the creature whose extended object is taken.

Example (illustrative):

    GetCreatureExFromIndex( nSMIndex );

GetCreatureExGLOBAL🟢 high

extended data from an existing object

Given an already available regular creature object, returns its "extended" object
(CSharedCreatureDataEx) — a superstructure with additional fields on top of the base one. Same as
GetCreatureExFromIndex, except the starting point is not a numeric index but the creature object itself
(e.g. talker). Returns an empty result for an empty object.

Signature

GetCreatureEx( CSharedCreatureData c )

Parameters

    c (CSharedCreatureData) — regular creature object whose extended object is taken.

Example (illustrative):

    GetCreatureEx( talker );

Spawn2MAKER🟢 high

spawn creatures with auto-respawn

Creates the given number of creatures of this define. Arguments: nCount (int) — how many to spawn; nRespawnTime (int) — auto-respawn period (zero disables it); nRespawnRand (int) — random spread added to the period. If the respawn time is zero, there is no auto-revival; otherwise, after death the creature respawns after the specified time with the spread. Called on a define ([CNpcSpawnDefineEx]).
Related event: on the maker — ON_NPC_CREATED/ON_NPC_DELETED; on the new NPC — CREATED (see NASC_HANDLERS).

Signature

Spawn2( int nCount, int nRespawnTime, int nRespawnRand )

Parameters

nCount       (int) — how many creatures to spawn.
nRespawnTime (int) — auto-respawn period (zero disables auto-revival).
nRespawnRand (int) — random spread added to the respawn period.

Example

def0.Spawn2(i2, 0, 0);

SpawnExMAKER🟢 high

spawn at an explicit position with state restoration

Spawns creatures at an explicit position and restores their state from a database record; used at world load. Arguments: nCount (int) — how many to spawn; nMode (int) — mode; x, y, z (int) — coordinates; nHeading (int) — heading (65536 = 360°); nHp, nMp (int) — HP and MP; nDbValue (int) — stored value. Called on a define ([CNpcSpawnDefineEx]).

Signature

SpawnEx( int nCount, int nMode, int nX, int nY, int nZ, int nHeading, int nHp, int nMp, int nDbValue )

Parameters

nCount   (int) — how many creatures to spawn
nMode    (int) — spawn mode
nX       (int) — X coordinate of the spawn point
nY       (int) — Y coordinate of the spawn point
nZ       (int) — Z coordinate of the spawn point
nHeading (int) — heading (65536 = 360°)
nHp      (int) — current health (HP) value of the creature
nMp      (int) — current mana (MP) value of the creature
nDbValue (int) — value stored in the database, restored for the creature

Example

loaded_def.SpawnEx(1, 0, record0.x, record0.y, record0.z, 0, record0.hp, record0.mp, record0.db_value);

SpawnMAKER🟢 high

spawn creatures (simplified)

Creates the given number of creatures of this define. Arguments: nCount (int) — how many to spawn; nRespawnTime (int) — respawn period. Called on a define ([CNpcSpawnDefineEx]). No explicit calls were found in the collected scripts.

Signature

Spawn( int nCount, int nRespawnTime )

Parameters

nCount       (int) — how many creatures to spawn
nRespawnTime (int) — respawn period

Example

def0.Spawn(1, 0);

GetNpcMakerGLOBAL🟢 high

find a maker by name

This is how a regular NPC reaches a maker, finding it by name. Argument sName (string) — the maker's name; called on the global object gg. The result is null-checked via IsNull. Returns a [CNpcMakerEx] object.

Signature

GetNpcMaker( string pwsName )

Parameters

pwsName (string) — name of the maker to search for

Example

maker0 = GetNpcMaker( s0 );

Usage example

maker0 = GetNpcMaker( evilate_maker1 );
if ( IsNull( maker0 ) == 0 ) { SendMakerScriptEvent( maker0, 1000, 0, 0 ); }

GetMyMakerNPC🟢 high

return the NPC's own maker

Returns the maker that spawned this NPC — a direct reference to its creator.
No arguments; called on myself. Unlike GetNpcMaker (which finds a maker by name),
here the name need not be known: the NPC gets exactly its own spawner. Handy for reporting
back to the creator (wave counters, spawn relay). If the NPC has no bound maker, returns
empty — the result is checked via IsNull.

Signature

GetMyMaker(  )

Parameters

(none — the function is called without arguments)

Example

maker0 = myself.GetMyMaker();
if ( IsNull( maker0 ) == 0 ) { SendMakerScriptEvent( maker0, 1001, 0, 0 ); }

IsTournamentEnableGLOBAL🟢 high

is the tournament enabled

Tells whether a tournament is currently running at all: returns @TRUE if the tournament is open
(registration is possible, the schedule can be shown, spectators admitted), and @FALSE if it is
closed. With this check the gate script decides whether to open the tournament menu
at all and offer registration: while the function returns @FALSE, all tournament actions must be suppressed.
No arguments, read-only.

Signature

IsTournamentEnable(  )

Parameters

(none — the function is called without arguments)

Example

if (IsTournamentEnable() == @TRUE)

IsTournamentGroupStageGLOBAL🟢 high

is the tournament group stage running

Distinguishes the two tournament phases: returns @TRUE during the group stage and @FALSE when
the finals (playoffs) are running. The answer determines how to register a player: during the group stage
registration is automatic for the current group match, while in the finals the player must enter
the code of their match (see AddTournament — its second argument is chosen exactly by this check).
No arguments, read-only.

Signature

IsTournamentGroupStage(  )

Parameters

(none — the function is called without arguments)

Example

if (IsTournamentGroupStage() == @TRUE)

IsInCategoryNPC🟢 high

category membership check

Checks whether the value nValue (usually a creature's class or occupation) belongs to category nCategory from the [category_pch] dictionary. Arguments: nCategory (int, namespace [category_pch]) and nValue (int, no namespace); belongs to myself, returns 1 (belongs) or 0. Main uses are telling "own" summons, pets and servitors apart from live players and sorting targets by role (fighter, healer).

Signature

IsInCategory( int nCategory, int nValue )

Parameters

nCategory (int) — which category is checked.
    values — from the [category_pch] dictionary
nValue (int) — the value being checked (usually the creature's .class_id / .occupation).

Example

if ( IsInCategory( @second_class_group, talker.occupation ) ) {

Usage example

if ( IsInCategory( @summon_npc_group, target.class_id ) != 0 ) {
    AddAttackDesire( target.master, @AMT_MOVE_TO_TARGET, 500 );
}

FindRandomUserNPC🟢 high

asynchronous random player selection

Asynchronously asks the engine to pick a random player in the zone by filters and returns nothing itself (void type). The four arguments (no namespace) are selection filters: nInCombat (in combat only), nNotInPeaceZone (not in a peace zone), nNotInOlympiad (not at the Olympiad), nInParty (in a party only); belongs to myself. The chosen player arrives later in the FIND_RANDOM_USER event handler, where it sits in the talker parameter — the typical "request now, answer in the handler" pattern.
Related event: the found player arrives via the FIND_RANDOM_USER(talker) event (see NASC_HANDLERS).

Signature

FindRandomUser( int nInCombat, int nNotInPeaceZone, int nNotInOlympiad, int nInParty )

Parameters

nInCombat (int) — 1 = only players in combat, 0 = no such filter.
nNotInPeaceZone (int) — 1 = exclude players in a peace zone, 0 = no filter.
nNotInOlympiad (int) — 1 = exclude players at the Olympiad, 0 = no filter.
nInParty (int) — 1 = only players in a party, 0 = no filter.

Example

FindRandomUser(0, 0, 0, 0);
FindRandomUser( 1, 1, 1, 1 );

Usage example

if (GetGlobalMap(99) == 1) {
    FindRandomUser(1, 1, 1, 1);
    AddTimerEx(1227, 300000);
}

DespawnNPC🟢 high

remove all NPCs of a define

Removes (despawns) all NPCs of this define. Takes no arguments; called on a define ([CNpcSpawnDefineEx]).

Signature

Despawn(  )

Parameters

(none — the function is called without arguments)

Example

Despawn();

Usage example

if ( private == myself.boss ) {
    Despawn( );
}

Maker_GetNpcCountNPC🟢 high

sibling counter

Tells how many NPCs are currently spawned by this maker — handy for "am I the last of the wave?" logic. Takes no arguments; called on myself ([CNPC]). Returns int.

Signature

Maker_GetNpcCount(  )

Parameters

(none — the function is called without arguments)

Example

if ( script_event_arg1 == @SCE_ANTARAS_USE_FEAR && Maker_GetNpcCount( ) < 150 ) {

Usage example

if ( Maker_GetNpcCount( ) == 1 ) {
    CreateOnePrivateEx( @first_orc, "first_orc", 0, 0, 21036, -107690, -3038, 0, 0, 0, 0 );
}

Maker_FindNpcByKeyNPC🟢 high

find a sibling by key

Looks up a sibling spawned by the same maker by its key — usually the third spawn parameter, sm.param3. The argument nKey (int) is the key of the NPC being searched for; called on myself ([CNPC]). The result is checked like a creature. Returns a [CSharedCreatureData] object.

Signature

Maker_FindNpcByKey( int nKey )

Parameters

nKey (int) — key of the NPC being searched for (usually the third spawn parameter, `sm`.param3).

Example

c0 = Maker_FindNpcByKey( i0 );
c0 = Maker_FindNpcByKey( myself.sm.param3 );

Usage example

c0 = Maker_FindNpcByKey( i0 );
if ( c0 ) {
    AddAttackDesire( c0, @AMT_MOVE_TO_TARGET, 100000 );
}

SoundEffectNPC🟢 high

short sound to a player

Plays a short sound to a player by client resource name. Takes the listener
and the sound name string; called on an NPC (myself), returns nothing. The main
use is quest stage sounds: taking a quest, an intermediate step, obtaining an
item and completion.

Signature

SoundEffect( CSharedCreatureData c, string sSoundName )

Parameters

c (CSharedCreatureData) — the listener (player) the sound is played to.
sSoundName (string) — client sound resource name (e.g. "Itemsound.quest_middle").

Example

SoundEffect( c1, "Itemsound.quest_middle" );

EffectMusicNPC🟢 high

background music

Turns on background music in a radius around the source — in the examples these are boss battle themes.
Per the L2NPC decompile (CNPC::EffectMusic_48943C) the second argument is the broadcast distance:
the engine's error string reads "nDist<=0 or nDist>16384", i.e. the audibility radius, which
must lie in the range 1..16384 (the music goes out to clients within this radius, packet opcode 70).
Called on an NPC, returns nothing.

Signature

EffectMusic( CSharedCreatureData c, int nDist, string sTrack )

Parameters

c (CSharedCreatureData) — the music source (usually the NPC itself via `sm`).
nDist (int) — music audibility radius, 1..16384 (the engine rejects 0 and >16384; 7000 in the calls).
sTrack (string) — music track name (e.g. "BS01_A", "SSQ_Dawn_01").

Example

EffectMusic(myself.sm, 7000, "BS01_A");

Usage example

if ( GetSSQWinner( ) == 2 ) {
    EffectMusic( myself.sm, 0, "SSQ_Dawn_01" );
}

VoiceEffectNPC🟢 high

voice-over with volume

Plays a voice-over — a regular voice at the given volume, for example
tutorial hints. Takes the listener, the voice file and the volume; called on an NPC,
returns nothing.

Signature

VoiceEffect( CSharedCreatureData c, string sFileName, int nVolume )

Parameters

c (CSharedCreatureData) — the listener (player) the voice-over is played to.
sFileName (string) — voice-over file (e.g. "tutorial_voice_026").
nVolume (int) — playback volume (0 or 1000 in the calls).

Example

VoiceEffect(talker, "tutorial_voice_026", 1000);

Usage example

if ( GetMemoStateEx( talker, @tutorial_quest, 1 ) == 3 && timer_id >= 1000000 ) {
    VoiceEffect( talker, "tutorial_voice_010d", 0 );
}

VoiceNPCEffectNPC🟢 high

NPC voice line

Plays an NPC voice line. Takes the listener, the voice file and a numeric mode
id (always zero in the calls); called on an NPC, returns nothing. The third
argument has not been reliably identified.

Signature

VoiceNPCEffect( CSharedCreatureData cCreature, string pwsFileName, int nVoiceNPCEffectId )

Parameters

cCreature (CSharedCreatureData) — the listener (player) the NPC voice line is played to
pwsFileName (string) — NPC voice-over file
nVoiceNPCEffectId (int) — voice mode id (always zero in the calls, meaning not disclosed)

Example

VoiceNPCEffect(h0.creature, s0, 0);

StartScenePlayerNPC🟢 high

cutscene for one player

Starts a scripted movie (cutscene) for a player by its identifier. Takes
the viewer and the numeric scene id; called on an NPC, returns nothing. The identifier
appears both as a raw number and as named constants (boss scene name, scene
number, etc.) declared in the script class itself.
Related event: when the scene finishes — SCENE_STOPPED (see NASC_HANDLERS).

Signature

StartScenePlayer( CSharedCreatureData c, int nSceneId )

Parameters

c (CSharedCreatureData) — the viewer (player) the cutscene is started for.
nSceneId (int) — identifier of the cutscene to start (a raw number or a named scene constant).

Example

StartScenePlayer(talker, 9);

StartScenePlayerAroundNPC🟢 high

cutscene for everyone around a point

Starts a cutscene for all players near a point — within a radius and a height
range. Takes the viewer, the scene id, the radius and the lower/upper height
bounds; called on an NPC, returns nothing.
Related event: when the scene finishes — SCENE_STOPPED (see NASC_HANDLERS).

Signature

StartScenePlayerAround( CSharedCreatureData c, int nSceneId, int nRadius, int nLowZ, int nHighZ )

Parameters

c (CSharedCreatureData) — the reference point (usually myself.sm) for showing the scene to those around.
nSceneId (int) — identifier of the cutscene to start.
nRadius (int) — horizontal coverage radius within which players are shown the scene.
nLowZ (int) — lower height bound of the coverage (Z coordinate).
nHighZ (int) — upper height bound of the coverage (Z coordinate).

Example

StartScenePlayerAround(myself.sm, 1, 4000, 1100, 3100);
StartScenePlayerAround(myself.sm, 7, 8000, -11972, -11772);
StartScenePlayerAround(myself.sm, 6, 8000, -11972, -11772);
StartScenePlayerAround(myself.sm, 5, 8000, -11972, -11772);

Usage example

if (myself.i_ai1 == 4) {
    StartScenePlayerAround(myself.sm, 27, 8000, FloatToInt(myself.sm.z - 1000), FloatToInt(myself.sm.z + 1000));
}

StartScenePlayerToPartyNPC🟢 high

cutscene for the whole party

Starts a cutscene for the player's entire party. Takes the viewer and the scene id;
called on an NPC, returns nothing.
Related event: when the scene finishes — SCENE_STOPPED (see NASC_HANDLERS).

Signature

StartScenePlayerToParty( CSharedCreatureData c, int nSceneId )

Parameters

    c (CSharedCreatureData) — the initiator whose party the cutscene is started for.
    nSceneId (int) — identifier of the cutscene to start.

Example (illustrative):

    StartScenePlayerToParty( talker, nSceneId );

PlaySceneNPC🟢 high

play a cutscene to a player

Plays a cutscene with the given index (client scene id) to a player. Called
on an NPC, returns nothing. Requires a non-null player and a non-negative scene
index (otherwise the engine writes an error to the log). It is a working presentation command, not
a "deprecated" one: it simply sends the scene start command to the client.

Signature

PlayScene( CSharedCreatureData c, int nSceneIndex )

Parameters

    c (CSharedCreatureData) — the player the cutscene is played to.
    nSceneIndex (int) — cutscene index (client id, >= 0).

Example (illustrative):

    PlayScene( talker, nSceneIndex );

SpecialCameraNPC🟢 high

cinematic camera on a target

Turns on a cinematic (staged) camera for all players around the target, aimed
at that target — the picture temporarily detaches from the character and shows the scene from the side.
A single call shows just one angle; a whole movie (boss flyby, dramatic entrance)
is assembled from a chain of such calls in a row on a timer. The camera itself is drawn by the client: the server merely
passes the flyby numbers to it as-is. The leading fields are clear (distance, angles, timings), while
the rest are fine flyby tuning interpreted by the client. Called on an NPC, returns
nothing.

Signature

SpecialCamera( CSharedCreatureData c, int nDist, int nYaw, int nPitch, int nTime, int nDuration, int nTurn, int nRise, int nParam8, int nParam9, int nParam10, int nParam11 )

Parameters

c (CSharedCreatureData) — the target the camera looks at (usually the boss itself, myself.sm).
nDist (int) — how far the camera stands off from the target (500, 700, 1700 in the calls).
nYaw (int) — horizontal camera rotation around the target (small degree numbers: 10, 13, 88).
nPitch (int) — vertical camera tilt (above/below the target line: 0, 4, -19).
nTime (int) — how many milliseconds the camera takes to glide to the given position (0, 300, 5000, 6000 in the calls).
nDuration (int) — how many milliseconds this angle is held (5000, 10000, 15000 in the calls).
nTurn (int) — numeric camera-motion field for the segment (turn/movement; 250, 10000, 20000 in the calls). Exact meaning unconfirmed.
nRise (int) — numeric camera-motion field for the segment (0, 20 in the calls). Exact meaning unconfirmed.
nParam8 (int) — client-side camera tuning field (0, -20 in the calls).
nParam9 (int) — client-side camera tuning field (0, 1 in the calls).
nParam10 (int) — client-side camera tuning field (0, 1 in the calls).
nParam11 (int) — client-side camera tuning field (0, 1 in the calls).

Example

SpecialCamera(myself.sm, 500, 88, 4, 5000, 5000, 10000, 0, 0, 1, 0, 1);

Usage example

if ( timer_id == 1117 ) {
    SpecialCamera( myself.sm, 1700, 10, 0, 300, 15000, 250, 20, -20, 1, 1, 0 );
}

SpecialCamera3NPC🟢 high

extended camera

Another variant of the staged camera from the same family as SpecialCamera — with the same
set of eleven numeric angle and timing settings. It differs in the camera's behavior
on the segment (the calls show a different combination of numbers), but the purpose and the way
it is used are the same: show everyone around the target the scene from the side, and assemble
a movie from a chain of calls. The picture is drawn by the client: the server passes the flyby numbers as-is. Called
on an NPC, returns nothing.

Signature

SpecialCamera3( CSharedCreatureData c, int nDist, int nYaw, int nPitch, int nTime, int nDuration, int nTurn, int nRise, int nParam8, int nParam9, int nParam10, int nParam11 )

Parameters

c (CSharedCreatureData) — the target the camera looks at (usually the boss itself).
nDist (int) — how far the camera stands off from the target (250, 300 in the calls).
nYaw (int) — horizontal camera rotation around the target (180, 220 in the calls).
nPitch (int) — vertical camera tilt (0, 20 in the calls).
nTime (int) — how many milliseconds the camera takes to reach the given position (0, 3000 in the calls).
nDuration (int) — how many milliseconds the angle is held (5000 in the calls).
nTurn (int) — numeric camera-motion field for the segment (10000 in the calls). Exact meaning unconfirmed.
nRise (int) — numeric camera-motion field for the segment (0 in the calls). Exact meaning unconfirmed.
nParam8 (int) — client-side camera tuning field (0, 6 in the calls).
nParam9 (int) — client-side camera tuning field (1 in the calls).
nParam10 (int) — client-side camera tuning field (1 in the calls).
nParam11 (int) — client-side camera tuning field (1 in the calls).

Usage example

if ( timer_id == 2002 ) {
    SpecialCamera3( myself.sm, 0, 180, 80, 4000, 5000, 6000, 0, 0, 1, 1, 1 );
    AddTimerEx( 2003, 6000 );
}

SpecialCameraExNPC🟢 high

camera with two targets

A staged camera with two targets: one sets the point the camera looks from, the other —
what it is aimed at. Handy when a scene must be shown as a link between two creatures (for example,
a gaze from one character toward another). Then come nine numeric flyby fields — the same
angle and timing settings as in regular SpecialCamera; the picture is drawn by the client, the server
passes the numbers as-is. Called on an NPC, returns nothing.

Signature

SpecialCameraEx( CSharedCreatureData cFrom, CSharedCreatureData cTo, int nDist, int nYaw, int nPitch, int nTime, int nDuration, int nParam7, int nParam8, int nParam9, int nParam10 )

Parameters

    cFrom (CSharedCreatureData) — the creature the view is taken from (the shooting point).
    cTo (CSharedCreatureData) — the creature the camera is aimed at.
    nDist (int) — how far the camera stands off from the target.
    nYaw (int) — horizontal camera rotation.
    nPitch (int) — vertical camera tilt.
    nTime (int) — how many milliseconds the camera takes to reach the given position.
    nDuration (int) — how many milliseconds the angle is held.
    nParam7 (int) — client-side camera tuning field.
    nParam8 (int) — client-side camera tuning field.
    nParam9 (int) — client-side camera tuning field.
    nParam10 (int) — client-side camera tuning field.

Example (illustrative):

    SpecialCameraEx( talker, talker, nDist, nYaw, nPitch, nTime, nDuration, nParam7, nParam8, nParam9, nParam10 );

SpecialCameraZLimitNPC🟢 high

camera with a height limit

The same staged camera as SpecialCamera, but with two extra numbers —
the lower and upper height bounds (Z coordinate). They keep the camera within the given
height range so it does not dive underground or fly too high on uneven
terrain. The remaining fields are the usual angle and timing settings; the picture is drawn by the
client, the server passes the numbers as-is. Called on an NPC, returns nothing.

Signature

SpecialCameraZLimit( CSharedCreatureData c, int nDist, int nYaw, int nPitch, int nTime, int nDuration, int nTurn, int nRise, int nParam8, int nParam9, int nParam10, int nParam11, int nLowZ, int nHighZ )

Parameters

    c (CSharedCreatureData) — the target the camera looks at (usually the boss itself).
    nDist (int) — how far the camera stands off from the target.
    nYaw (int) — horizontal camera rotation.
    nPitch (int) — vertical camera tilt.
    nTime (int) — how many milliseconds the camera takes to reach the given position.
    nDuration (int) — how many milliseconds the angle is held.
    nTurn (int) — numeric camera-motion field for the segment. Exact meaning unconfirmed.
    nRise (int) — numeric camera-motion field for the segment. Exact meaning unconfirmed.
    nParam8 (int) — client-side camera tuning field.
    nParam9 (int) — client-side camera tuning field.
    nParam10 (int) — client-side camera tuning field.
    nParam11 (int) — client-side camera tuning field.
    nLowZ (int) — lower height bound: do not lower the camera below this level.
    nHighZ (int) — upper height bound: do not raise the camera above this level.

Example (illustrative):

    SpecialCameraZLimit( talker, nDist, nYaw, nPitch, nTime, nDuration, nTurn, nRise, nParam8, nParam9, nParam10, nParam11, nLowZ, nHighZ );

EarthQuakeByNPCNPC🟢 high

screen shake around a target

Shakes the screen for viewers around the target — for dramatic moments in boss fights. The shake itself
is rendered by the client: the server passes it six numbers as-is. The first two are the intensity and
duration, the other four are client-side effect fields (1/1/1/0 in the calls). Called
on an NPC, returns nothing.

Signature

EarthQuakeByNPC( CSharedCreatureData c, int nIntensity, int nDuration, int nParam3, int nParam4, int nParam5, int nParam6 )

Parameters

c (CSharedCreatureData) — the shake epicenter (often the NPC itself, myself.sm).
nIntensity (int) — screen shake intensity (40, 50 in the calls).
nDuration (int) — shake duration (4, 10 in the calls).
nParam3 (int) — client-side shake effect field (opcode 59). [need_client]
nParam4 (int) — client-side shake effect field (opcode 59). [need_client]
nParam5 (int) — client-side shake effect field (opcode 59). [need_client]
nParam6 (int) — client-side shake effect field (opcode 59). [need_client]

Example

EarthQuakeByNPC(myself.sm, 50, 4, 1, 1, 1, 0);

Usage example

if ( timer_id == 2006 ) {
    EarthQuakeByNPC( myself.sm, 40, 10, 1, 0, 0, 0 );
    EffectMusic( myself.sm, 6000, "BS02_A" );
}

EarthQuakeToPartyNPC🟢 high

screen shake for a party

Shakes the screen for all members of one party — wherever they are, the shake
is received specifically by members of the given party, not everyone around some point. Used for
dramatic moments inside an instant zone/room where the action targets a party. The shake itself
is drawn by the client. Returns nothing.

Signature

EarthQuakeToParty( int nPartyId, int nIntensity, int nDuration, int nParam3 )

Parameters

nPartyId (int) — id of the party whose screens to shake (usually room0.party_id — the party of the current room/instant zone).
nIntensity (int) — shake intensity: the bigger, the more noticeably the picture sways (10, 20 in the calls).
nDuration (int) — shake duration (10 in the calls).
nParam3 (int) — extra client-side shake effect setting (1 in the calls).

Example

EarthQuakeToParty( room0.party_id, 20, 10, 1 );
EarthQuakeToParty( room0.party_id, 10, 10, 1 );

RegisterAsOlympiadOperatorNPC🟢 high

declare the NPC an Olympiad operator

Marks this NPC as an Olympiad operator — registration and match viewing go
through it. No arguments, called on myself once in the creation handler.

Signature

RegisterAsOlympiadOperator(  )

Parameters

(none — the function is called without arguments)

Example

RegisterAsOlympiadOperator();

GetOlympiadModeNPC🟢 high

is Olympiad registration currently open

The operator's main gate: returns [bool_pch] (@TRUE/@FALSE) — whether the Olympiad
registration/period is currently active. No arguments, on myself; nearly all dialog logic is wrapped in
a == @TRUE check.

Signature

GetOlympiadMode(  )

Parameters

(none — the function is called without arguments)

Example

if (GetOlympiadMode() == @TRUE)

Usage example

if (GetOlympiadMode() == @TRUE)
{
    AddClassFreeOlympiad(talker);
}

GetOlympiadStepNPC🟢 high

current phase of the Olympiad cycle

Returns the current phase of the Olympiad cycle as an integer. No arguments, on myself,
read-only.

Signature

GetOlympiadStep(  )

Parameters

(none — the function is called without arguments)

Example

FHTML_SetInt(fhtml0, "olympiad_week", GetOlympiadStep());

GetOlympiadSeasonNPC🟢 high

season number

Returns the current Olympiad season number as an integer. No arguments, on myself,
read-only.

Signature

GetOlympiadSeason(  )

Parameters

(none — the function is called without arguments)

Example

FHTML_SetInt(fhtml0, "olympiad_round", GetOlympiadSeason());

GetOlympiadSeasonElapsedTimeNPC🟢 high

time elapsed in the season

Returns as an integer how much time has already been counted since the start of the current
Olympiad season — that is, how long the current period has been running. The number is usually checked
to see whether enough has passed to allow a given action (for example, to show the results
or admit into a certain mode). No arguments, on myself, read-only.

Unit of measure is seconds: it returns the difference between the current time and the season
start time (0 if the season has not started yet).

Signature

GetOlympiadSeasonElapsedTime(  )

Parameters

(none — the function is called without arguments)

Example

GetOlympiadSeasonElapsedTime( );

GetOlympiadPlayerCountNPC🟢 high

how many players are registered

Returns as an integer the exact number of players registered for the Olympiad at
the moment (the sum of everyone queued for matches). Suitable for showing "this many are
currently signed up" in a dialog. Note: stock scripts deliberately do not show this figure to
players (the output line was commented out) so that the exact participant count does not
provoke a mass simultaneous rush to register. No arguments, on myself,
read-only.

Signature

GetOlympiadPlayerCount(  )

Parameters

(none — the function is called without arguments)

Example

FHTML_SetInt(fhtml0, "olympiad_participant", GetOlympiadPlayerCount());

GetOlympiadWaitingCountNPC🟢 high

classed match queue

Returns as an integer how many players are waiting in the classed match queue.
No arguments, on myself, read-only.

Signature

GetOlympiadWaitingCount(  )

Parameters

(none — the function is called without arguments)

Example

i0 = GetOlympiadWaitingCount();

Usage example

i0 = GetOlympiadWaitingCount( );
if ( i0 < 100 ) {
    FHTML_SetStr( fhtml0, "WaitingCount", MakeFString( 1000504, "100", _blank, _blank, _blank, _blank ) );
} else {
    FHTML_SetStr( fhtml0, "WaitingCount", MakeFString( 1000505, "100", _blank, _blank, _blank, _blank ) );
}

GetClassFreeOlympiadWaitingCountNPC🟢 high

the free-battle queue

Returns as an integer the size of the free-battle queue. No arguments,
on myself, read-only.

Signature

GetClassFreeOlympiadWaitingCount(  )

Parameters

(none — the function is called without arguments)

Example

i0 = GetClassFreeOlympiadWaitingCount();

Usage example

i0 = GetClassFreeOlympiadWaitingCount( );
if ( i0 < 100 ) {
    FHTML_SetStr( fhtml0, "ClassFreeWaitingCount", MakeFString( 1000504, "100", _blank, _blank, _blank, _blank ) );
} else {
    FHTML_SetStr( fhtml0, "ClassFreeWaitingCount", MakeFString( 1000505, "100", _blank, _blank, _blank, _blank ) );
}

GetTeamOlympiadWaitingCountNPC🟢 high

the team-battle queue

Returns as an integer the size of the team-battle queue (3v3). No arguments,
on myself, read-only.

Signature

GetTeamOlympiadWaitingCount(  )

Parameters

(none — the function is called without arguments)

Example

i0 = GetTeamOlympiadWaitingCount();

Usage example

i0 = GetTeamOlympiadWaitingCount();
if (i0 < 100) {
    FHTML_SetStr(fhtml0, "TeamWaitingCount", MakeFString(1000504, "100", _blank, _blank, _blank, _blank));
} else {
    FHTML_SetStr(fhtml0, "WaitingCount", MakeFString(1000505, "100", _blank, _blank, _blank, _blank));
}

GetOlympiadFieldIdNPC🟢 high

the arena identifier

Returns as an integer the identifier of the Olympiad arena (field) to which this
NPC is bound. The number is usually saved to a variable and then substituted into functions for a specific
arena — for example, to learn the names of the fighters on it (GetPlayer1ForOlympiadField /
GetPlayer2ForOlympiadField take exactly this id). No arguments, on myself,
read-only.

Signature

GetOlympiadFieldId(  )

Parameters

(none — the function is called without arguments)

Example

myself.i_ai0 = GetOlympiadFieldId();

IsOlympiadRegisteredNPC🟢 high

is the player registered for a battle

Checks whether the player is already registered for a match; returns an integer (boolean).
Takes the player (talker, of type CSharedCreatureData), called on myself.

Signature

IsOlympiadRegistered( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose match registration is checked

Example

if (IsOlympiadRegistered(talker) == @FALSE)

Usage example

if (IsOlympiadRegistered(talker) == @FALSE)
{
    ShowPage(talker, "sf_antonius_proximo005.htm");
}
else
{
    ShowPage(talker, "sf_antonius_proximo007.htm"); // You are already registered, do you want to cancel?
}

AddOlympiadNPC🟢 high

register for a class 1v1 battle

Registers the player for a class one-on-one match (classed). Takes the player (talker,
of type CSharedCreatureData), on myself; before the call the logic checks the Olympiad mode,
the absence of registration, the level, and the profession.

Signature

AddOlympiad( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player registered for a class one-on-one match

Example

AddOlympiad(talker);

Usage example

if ( GetOlympiadPoint( talker ) > 0 ) {
    AddOlympiad( talker );
} else {
    ShowPage( talker, "olympiad_operator010i.htm" );
}

AddClassFreeOlympiadNPC🟢 high

register for a free 1v1 battle

Registers the player for a free one-on-one match without regard to class. Takes the player
(talker, of type CSharedCreatureData), on myself; the same preliminary checks as
the other Adds.

Signature

AddClassFreeOlympiad( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player registered for a free match without regard to class

Example

AddClassFreeOlympiad(talker);

Usage example

if ( GetOlympiadPoint( talker ) > 0 ) {
    AddClassFreeOlympiad( talker );
} else {
    ShowPage( talker, "olympiad_operator010i.htm" );
}

AddBo3OlympiadNPC🟢 high

register for a best-of-3 battle

Registers the player for a best-of-3 match (up to two wins). Takes the player (talker,
of type CSharedCreatureData), on myself.

Signature

AddBo3Olympiad( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player registered for a best-of-3 match

Example

AddBo3Olympiad(talker);

AddTeamOlympiadNPC🟢 high

register for a 3v3 team battle

Registers the player for a three-on-three team match. Takes the player (talker,
of type CSharedCreatureData), on myself.

Signature

AddTeamOlympiad( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player registered for a three-on-three team match

Example

AddTeamOlympiad(talker);

Usage example

if ( GetOlympiadPoint( talker ) > 0 ) {
    AddTeamOlympiad( talker );
} else {
    ShowPage( talker, "olympiad_operator010i.htm" );
}

RemoveOlympiadNPC🟢 high

cancel registration

Cancels the player's match registration (the "Cancel Registration" menu item). Takes the player
(talker, of type CSharedCreatureData), on myself.

Signature

RemoveOlympiad( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose match registration is cancelled

Example

RemoveOlympiad(talker);

EscapeOlympiadNPC🟢 high

leave/exit

Makes the player leave the Olympiad (exit). Takes the player (talker,
of type CSharedCreatureData), on myself.

Signature

EscapeOlympiad( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the player who is taken out of the Olympiad

Example (illustrative):

    EscapeOlympiad( talker );

ShowOlympiadMatchListNPC🟢 high

open the list of current matches

Opens for the player the list of current battles (the "Watch Match" menu item). Takes the player
(talker, of type CSharedCreatureData), on myself.

Signature

ShowOlympiadMatchList( CSharedCreatureData pCreatureShared )

Parameters

pCreatureShared (CSharedCreatureData) — the player who is shown the list of current battles

Example

ShowOlympiadMatchList(talker);

Usage example

if ( ask == -1 && reply == 1 ) {
    ShowOlympiadMatchList( talker );
}

ObserveOlympiadNPC🟢 high

send as a spectator to an arena

Sends the player as an observer to the chosen arena. Takes the player (talker,
of type CSharedCreatureData) and the arena identifier nFieldId, on myself.

Signature

ObserveOlympiad( CSharedCreatureData cCreature, int nFieldId )

Parameters

cCreature (CSharedCreatureData) — the player sent as an observer.
nFieldId  (int) — the identifier of the arena to observe. In calls it arrives from the menu reply
                  (the number of the chosen arena from the HTML battle list).

Example

ObserveOlympiad( talker, reply );

Usage example

if (ask == -130) {
    ObserveOlympiad( talker, reply );
}

GetPlayer1ForOlympiadFieldNPC🟢 high

the arena's first fighter (name)

Returns as a string the name of the first of the two fighters battling on the specified arena. Needed
to display the list of current duels to an observer — the name is inserted directly into the dialog
text next to the opponent's name (given by the paired GetPlayer2ForOlympiadField). If
there is no battle on the arena, an empty string is returned. Takes the arena identifier (taken from
GetOlympiadFieldId or iterated by arena numbers), on myself.

Signature

GetPlayer1ForOlympiadField( int field_id )

Parameters

field_id (int) — the identifier of the arena whose first fighter is requested

Example

s0 = "&$1718;" + "&nbsp;&nbsp;&nbsp;" + GetPlayer1ForOlympiadField(i0) + "&nbsp;" + GetPlayer2ForOlympiadField(i0);

GetPlayer1ForOlympiadFieldExNPC🟢 high

the arena's first fighter (object)

Returns the first fighter of the specified arena as a creature object (CSharedCreatureData).
Takes the arena identifier nFieldId, on myself.

Signature

GetPlayer1ForOlympiadFieldEx( int field_id )

Parameters

field_id (int) — the identifier of the arena whose first fighter is requested (as a creature object)

Example

c0 = GetPlayer1ForOlympiadFieldEx(event_id);

GetPlayer2ForOlympiadFieldNPC🟢 high

the arena's second fighter (name)

Returns as a string the name of the second of the two fighters on the specified arena — the opponent of the one whose
name is given by GetPlayer1ForOlympiadField. In pair with it, used for the duel line
"fighter1 : fighter2" in the list of current battles for an observer. If there is no battle on the arena, an empty
string is returned. Takes the arena identifier (from GetOlympiadFieldId or by iterating over
arena numbers), on myself.

Signature

GetPlayer2ForOlympiadField( int field_id )

Parameters

field_id (int) — the identifier of the arena whose second fighter is requested

Example

s0 = "&$1718;" + "&nbsp;&nbsp;&nbsp;" + GetPlayer1ForOlympiadField(i0) + "&nbsp;" + GetPlayer2ForOlympiadField(i0);

GetPlayer2ForOlympiadFieldExNPC🟢 high

the arena's second fighter (object)

Returns the second fighter of the specified arena as a creature object (CSharedCreatureData).
Takes the arena identifier nFieldId, on myself.

Signature

GetPlayer2ForOlympiadFieldEx( int field_id )

Parameters

field_id (int) — the identifier of the arena whose second fighter is requested (as a creature object)

Example

c1 = GetPlayer2ForOlympiadFieldEx(event_id);

GetOlympiadPointNPC🟢 high

the player's current points

Returns as an integer the player's current Olympiad points. Takes the player (talker,
of type CSharedCreatureData), on myself.

Signature

GetOlympiadPoint( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose current Olympiad points are requested

Example

if (GetOlympiadPoint(c0) > 0)

Usage example

if ( GetOlympiadPoint( talker ) > 0 ) {
    AddClassFreeOlympiad( talker );
} else {
    ShowPage( talker, "olympiad_operator010i.htm" );
}

GetPreviousOlympiadPointNPC🟢 high

the previous period's points

Returns as an integer the player's points for the previous Olympiad period. Takes the player
(talker, of type CSharedCreatureData), on myself.

Signature

GetPreviousOlympiadPoint( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose points for the previous Olympiad period are requested

Example

/* if (GetPreviousOlympiadPoint(talker) < 50)

Usage example

if (GetPreviousOlympiadPoint(talker) == 0 || GetOlympiadTradePoint(talker) == 0)
{
    ShowPage(talker, "olympiad_operator_basic014.htm");
}
else
{
    ShowPage(talker, "olympiad_operator_basic013.htm");
}

GetOlympiadWinCountNPC🟢 high

the number of wins

Returns as an integer the player's number of Olympiad wins. Takes the player
(talker, of type CSharedCreatureData), on myself.

Signature

GetOlympiadWinCount( CSharedCreatureData c )

Parameters

    c (CSharedCreatureData) — the player whose number of Olympiad wins is requested

Example (illustrative):

    GetOlympiadWinCount( talker );

GetOlympiadTradePointNPC🟢 high

the player's trade points

Returns as an integer the player's "trade" points — the currency for rewards. Takes the player
(talker, of type CSharedCreatureData), on myself.

Signature

GetOlympiadTradePoint( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose trade points are requested

Example

i0 = GetOlympiadTradePoint( talker );

Usage example

if ( GetOlympiadTradePoint( talker ) > 0 ) {
    DeleteOlympiadTradePoint( talker, GetOlympiadTradePoint( talker ) );
}

AddOlympiadTradePointNPC🟢 high

credit trade points

Credits the player with Olympiad trade points — the currency for which rewards are then taken.
The second argument is simply how many points to add (an ordinary number, not a constant). A direct
pair to DeleteOlympiadTradePoint (deduction) and to GetOlympiadTradePoint (current balance):
one credits, another deducts, the third shows the balance. Takes the player and the number of
points, on myself.

Signature

AddOlympiadTradePoint( CSharedCreatureData cCreature, int nPoint )

Parameters

    cCreature (CSharedCreatureData) — the player credited with trade points
    nPoint    (int) — how many trade points to add (an ordinary number, not an enum)

Example (illustrative):

    AddOlympiadTradePoint( talker, nPoint );

DeleteOlympiadTradePointNPC🟢 high

deduct trade points

Deducts the player's Olympiad trade points (the reward currency) — a pair to
AddOlympiadTradePoint. The second argument is how much to deduct; in practice
GetOlympiadTradePoint(talker) is passed, that is, the whole balance is zeroed at once (usually before giving
a reward for all accumulated points). It is reasonable to precede it with a GetOlympiadTradePoint(talker)
> 0 check, so as not to deduct from an empty balance. Takes the player and the number of points, on myself.

Signature

DeleteOlympiadTradePoint( CSharedCreatureData cCreature, int nPoint )

Parameters

cCreature (CSharedCreatureData) — the player from whom trade points are deducted
nPoint    (int) — how many trade points to deduct (usually GetOlympiadTradePoint(talker) — deduct all; not an enum)

Example

DeleteOlympiadTradePoint( talker, i0 );
DeleteOlympiadTradePoint( talker, GetOlympiadTradePoint( talker ) );

Usage example

    if ( GetOlympiadTradePoint( talker ) > 0 ) {
        DeleteOlympiadTradePoint( talker, GetOlympiadTradePoint( talker ) );
    }

Related event: the server's response arrives as the DELETE_OLYMPIAD_TRADE_POINT_RETURNED event (see NASC_HANDLERS).

DeletePreviousOlympiadPointNPC🟢 high

deduct the previous period's points

Deducts the player's points accumulated over the previous (already finished) Olympiad period —
they are exchanged for a reward at the end of the period separately from the current trade points. The second
argument is how much to deduct; in practice GetPreviousOlympiadPoint(talker) is passed,
that is, the whole previous balance is taken at once when giving the reward. Takes the player and the
number of points, on myself.

Signature

DeletePreviousOlympiadPoint( CSharedCreatureData cCreature, int nPoint )

Parameters

cCreature (CSharedCreatureData) — the player from whom the previous period's points are deducted
nPoint    (int) — how many previous-period points to deduct (usually GetPreviousOlympiadPoint(talker) — deduct all; not an enum)

Example

    DeletePreviousOlympiadPoint(talker, GetPreviousOlympiadPoint(talker));

Related event: the server's response arrives as the DELETE_PREVIOUS_OLYMPIAD_POINT_RETURNED event (see NASC_HANDLERS).

GetNameByOlympiadRankOrderNPC🟢 high

the name of the N-th in the class ranking

Returns as a string the name of the fighter standing at the N-th place in the ranking ("hall of fame") of the chosen
class. The first argument is which class we look at (in dialogs it is taken from the player's choice,
state/reply), the second — the ranking row number (1, 2, 3, …). The function fills the
ranking table: in a loop it iterates over places and at each one gets the name, points (GetPointByOlympiadRankOrder),
and rank (GetRankByOlympiadRankOrder). When the places run out, GetRankByOlympiadRankOrder at
that number returns 0 — and it is by this that the iteration is broken. On myself.

Signature

GetNameByOlympiadRankOrder( int nClassId, int nOrder )

Parameters

nClassId (int) — the class by whose ranking the fighter is searched (usually from the player's choice in the dialog)
nOrder (int) — the place number in the class ranking (1 — first place, etc.)

Example

FHTML_SetStr(fhtml0, "Name" + i0, GetNameByOlympiadRankOrder(state, i0));

GetPointByOlympiadRankOrderNPC🟢 high

the points of the N-th in the class ranking

Returns as an integer the points of the fighter standing at the N-th place in the chosen class's ranking.
Fully paired with GetNameByOlympiadRankOrder and GetRankByOlympiadRankOrder — the same two
arguments and the same way of use: in a loop over places it gets the name, points, and rank, to
fill the ranking table. The first argument is which class we look at (in dialogs from the player's
choice), the second — the place number. On myself.

Signature

GetPointByOlympiadRankOrder( int nClassId, int nOrder )

Parameters

    nClassId (int) — the class by whose ranking the fighter is searched (usually from the player's choice in the dialog)
    nOrder (int) — the place number in the class ranking (1 — first place, etc.)

Example (illustrative):

    GetPointByOlympiadRankOrder( nClassId, nOrder );

GetRankByOlympiadRankOrderNPC🟢 high

the rank of the N-th in the class ranking

Returns as an integer the rank of the fighter standing at the N-th place in the chosen class's ranking.
A double purpose: on the one hand it gives the rank value for the table row, on the other —
it serves as an end-of-list marker. As long as someone is at the given place, it returns a rank > 0;
as soon as the places run out, it returns 0 — and it is by this zero that the iteration over places is broken. A pair to
GetNameByOlympiadRankOrder and GetPointByOlympiadRankOrder, the arguments are the same: the first — which
class we look at (in dialogs from the player's choice), the second — the place number. On myself.

Signature

GetRankByOlympiadRankOrder( int nClassId, int nOrder )

Parameters

nClassId (int) — the class by whose ranking the fighter is searched (usually from the player's choice in the dialog)
nOrder (int) — the place number in the class ranking (1 — first place, etc.)

Example

if (GetRankByOlympiadRankOrder(state, i0) > 0)

Usage example

if (GetRankByOlympiadRankOrder(reply, i0) == 0) {
    break;
}

GetOlympiadTeamIdNPC🟢 high

the player's team id

Returns as an integer the number of the team the player fights for in a team (3v3)
Olympiad battle. Needed to distinguish friend from foe on the arena: the player's number is compared
with the team number assigned to a specific side of the field, and thus it is decided whether it is a friend or
an opponent. Outside a team battle the player has no meaningful team. Takes the player,
on myself.

Signature

GetOlympiadTeamId( CSharedCreatureData c )

Parameters

c (CSharedCreatureData) — the player (fighter) whose team number is requested

Example

if (GetOlympiadTeamId(talker) == myself.i_ai1)

AddTournamentNPC🟢 high

register for a tournament match

Registers the player for a specific tournament match (the tournament is a subsystem parallel to the Olympiad).
Takes the player (talker) and the registration code, on myself. The second
argument is NOT a "type/category", but the code of the target match, and it depends on the stage:

- At the group stage (when IsTournamentGroupStage() == @TRUE) zero is passed —
this is auto-registration for the current group match: AddTournament(talker, 0).
- In the finals (a non-group stage) the player enters the match code in the "Enter Code" dialog,
and this code (arrived as reply) is passed as the second argument:
AddTournament(talker, reply).

Before registration it is checked that the tournament is running at all — IsTournamentEnable() == @TRUE.
Related: IsTournamentGroupStage (group/finals), ShowTournamentMatchList
(the match window for viewing), GetTournamentNpcFlagId, AddBo3Olympiad
(registration for the Olympiad "best of three").

Signature

AddTournament( CSharedCreatureData c, int nRegisterCode )

Parameters

c (CSharedCreatureData) — the player being registered
nRegisterCode (int) — the target match code: 0 = group auto-entry; in the finals — the code entered by the player

Usage example

if ( IsTournamentEnable() == @TRUE ) {
    if ( IsTournamentGroupStage() == @TRUE ) { AddTournament( talker, 0 ); }
}
// finals, the "Registration to Match (Enter Code)" item:
if ( IsTournamentGroupStage() == @FALSE ) { AddTournament( talker, reply ); }

ObserveTournamentNPC🟢 high

observe a tournament battle

Sends the player as an observer to a tournament arena. Takes the player (talker,
of type CSharedCreatureData) and the arena identifier nFieldId, on myself.

Signature

ObserveTournament( CSharedCreatureData c, int nFieldId )

Parameters

    c (CSharedCreatureData) — the player sent as an observer to the tournament arena
    nFieldId (int) — the identifier of the tournament arena to observe

Example (illustrative):

    ObserveTournament( talker, nFieldId );

ShowTournamentMatchListNPC🟢 high

the list of tournament matches

Opens for the player the list of current tournament battles. Takes the player (talker,
of type CSharedCreatureData), on myself.

Signature

ShowTournamentMatchList( CSharedCreatureData c )

Parameters

c (CSharedCreatureData) — the player who is shown the list of current tournament battles

Example

ShowTournamentMatchList(talker);

GetTournamentNpcFlagIdNPC🟢 high

the tournament NPC's flag id

Returns as an integer the flag identifier of the tournament NPC. Takes the player (talker,
of type CSharedCreatureData), on myself.

Signature

GetTournamentNpcFlagId( CSharedCreatureData c )

Parameters

c (CSharedCreatureData) — the player for whom the tournament NPC's flag identifier is requested

Example

GetTournamentNpcFlagId( talker );

GetSpawnDefineMAKER🟢 high

get a define by index

Returns the maker's spawn define by index (from zero to the number of defines minus one). Argument nIndex (int) — the define number; called on myself ([CNpcMakerEx]). The result is checked for null via IsNull. Returns a [CNpcSpawnDefineEx] object.

Signature

GetSpawnDefine( int nIndex )

Parameters

nIndex (int) — index of the spawn define (from zero to the number of defines minus one).

Example

def0 = GetSpawnDefine(i0);

Usage example

def0 = GetSpawnDefine( i0 );
if ( IsNull( def0 ) == 0 ) {
    def0.Despawn( );
}

GetSpawnDefineByNickMAKER🟢 high

get a define by nick

Returns the maker's spawn define by its nick (the define's name field). Argument sNick (string) — the nick of the define being searched for; called on myself ([CNpcMakerEx]). The result is checked for null via IsNull. Returns a [CNpcSpawnDefineEx] object.

Signature

GetSpawnDefineByNick( string sNick )

Parameters

sNick (string) — nick (name) of the spawn define being searched for.

Example

def0 = GetSpawnDefineByNick(manager_npc_name);

AtomicIncreaseTotalMAKER🟢 high

atomic slot reservation

Atomically increases the maker's planned spawn count (total) by the given number (under a lock, clamped to the range [0, maximum]). This is protection against a race: until one handler finishes its reservation, another cannot cut in. Returns NOT one, but the current total value after the operation (zero means the increment went out of bounds or deduplication skipped the increment); scripts use the result as a truthy "spawning allowed" flag. Arguments: def ([CNpcSpawnDefineEx]) — the define whose plan is increased; nCount (int) — the increment amount (often the whole total or one unit); the third argument is NOT a "step" but a uniqueness flag: with value 1 deduplication is enabled and each define is counted only once (protection against double counting), with 0 the increment always applies. Called on myself ([CNpcMakerEx]).

Signature

AtomicIncreaseTotal( CNpcSpawnDefineEx def, int nCount, int bUnique )

Parameters

def (CNpcSpawnDefineEx) — the define whose planned total is increased.
nCount (int) — the amount added to the planned count (often the whole total or 1).
bUnique (int) — uniqueness flag: 1 = count the define once (dedup), 0 = always add.

Example

if (AtomicIncreaseTotal(def0, i1, 1))

Usage example

if (AtomicIncreaseTotal(def0, def0.total, 1)) {
    def0.Spawn2(def0.total, 0, 0);
}

DoRespawnMAKER🟢 high

execute pending respawns

Executes the maker's accumulated deferred respawns; usually triggered by a timer. Takes no arguments; called on myself ([CNpcMakerEx]).

Signature

DoRespawn(  )

Parameters

(none — the function is called without arguments)

Example

DoRespawn();

Usage example

if (myself.i_ai0 == 1) {
    DoRespawn();
    AddTimerEx(5001, 1000);
}

ResetRespawnMAKER🟢 high

clear the respawn queue

Resets (clears) the maker's queue of deferred respawns. Takes no arguments; called on myself ([CNpcMakerEx]).

Signature

ResetRespawn(  )

Parameters

(none — the function is called without arguments)

Example

ResetRespawn();

RegisterRespawnMAKER🟢 high

enqueue a respawn

Enqueues a deferred respawn: a given number of specimens of the define after a given delay; usually called when an NPC is deleted. Arguments: nRespawnTime (int) — delay until the respawn; nCount (int) — how many to respawn (one everywhere); def ([CNpcSpawnDefineEx]) — which define to respawn. Called on myself ([CNpcMakerEx]).

Signature

RegisterRespawn( int nRespawnTime, int nCount, CNpcSpawnDefineEx def )

Parameters

nRespawnTime (int) — delay until the deferred respawn (usually deleted_def.respawn_time).
nCount (int) — how many specimens to respawn (one everywhere).
def (CNpcSpawnDefineEx) — the spawn define that must be respawned.

Example

RegisterRespawn( i4, 1, deleted_def );
RegisterRespawn(deleted_def.respawn_time, 1, deleted_def);

Usage example

if (myself.i_ai0 == 1 && deleted_def.respawn_time != 0) {
    RegisterRespawn(deleted_def.respawn_time, 1, deleted_def);
}

RegisterOlympiadFieldEventExMAKER🟢 high

register the maker for arena events

Subscribes the maker (spawner) to Olympiad arena events so that it receives notifications
about the field's lifecycle — phase changes, match preparation, stage changes — and uses them
to place/remove fighters and decorations. Called once during maker initialization; after that
it reacts to arena events. No arguments, called on the maker.

Signature

RegisterOlympiadFieldEventEx(  )

Parameters

(none — the function is called without arguments)

Example

    RegisterOlympiadFieldEventEx();

Related event: subscribes the maker to Olympiad arena events — ON_OLYMPIAD_FIELD_CHANGED (phase change), ON_OLYMPIAD_GAME_PREPARED (match prepared), ON_OLYMPIAD_FIELD_STEP_CHANGED_EVENT (field stage change) (see NASC_HANDLERS).

Teleport and position (Teleport / Position)

25 functions

GetRandomPosInCreatureGLOBAL🟢 high

a random point around a creature

Returns a random position (an object with x/y/z fields) around the creature c at a distance from nMinDistance to nMaxDistance. This is a typical way to pick a point near a player for spawning, teleporting, or scattering helpers. Belongs to the global object; takes a creature c (CSharedCreatureData), nMinDistance (int), and nMaxDistance (int), returns a CPosition.

Signature

GetRandomPosInCreature( CSharedCreatureData cCreature, int nMinDistance, int nMaxDistance )

Parameters

cCreature (CSharedCreatureData) — around whom.
nMinDistance (int) — min. radius.
nMaxDistance (int) — max. radius.

Example

pos0 = GetRandomPosInCreature(c0, 10, 40);

GetRandomPosInPosGLOBAL🟢 high

a random point around a point

Returns a random position around the point x, y in a ring of radii from nMinDistance to
nMaxDistance (takes a random radius and angle). The function does NOT set the Z height manually — it always
snaps it to the terrain (geodata). The bIsFloating flag goes into the visibility/passability check:
one allows "floating"/aerial points (for flying NPCs, over water/void), zero
requires normally reachable ground. Makes up to five attempts to find a valid point; if they all
fail — returns the original point unchanged. Returns a CPosition.

Signature

GetRandomPosInPos( int nX, int nY, int nZ, int bIsFloating, int nMinDistance, int nMaxDistance )

Parameters

nX (int) — the X coordinate of the center around which a random position is searched
nY (int) — the Y coordinate of the center around which a random position is searched
nZ (int) — the Z coordinate of the center around which a random position is searched
bIsFloating (int) — flag for accounting for the "floating" (aerial) height when picking a position
nMinDistance (int) — the minimum radius of the ring within which the random position is picked
nMaxDistance (int) — the maximum radius of the ring within which the random position is picked

Example

pos0 = GetRandomPosInPos(-209282, -53031, -12295, @FALSE, 20, 350);

GetRandomPosInTerritoryGLOBAL🟢 high

a random point inside a territory

Returns a random point inside a named territory; nIsFlying sets whether the position should be flying. Belongs to the global object; takes sTerritoryName (string) and nIsFlying (int), returns a CPosition.

Signature

GetRandomPosInTerritory( string pwsTerritoryName, int nIsFlying )

Parameters

pwsTerritoryName (string) — the name of the territory inside which a random point is picked
nIsFlying (int) — flag for whether the returned position should be flying (aerial)

Example

pos0 = GetRandomPosInTerritory(TRR_STAR, 0);

GetRandomPosInTerritory2GLOBAL🟢 high

a random point inside a named territory

Picks a random point inside a named territory — convenient for scattering a spawn or
setting wandering without writing coordinates by hand. The territory is given by name and must be
declared in npcpos.txt; if it is not found, the function returns nothing and logs it. The
nIsFlying argument says whether to take a point "in the air" (for flying creatures) or on the ground. The third
argument is a label string that the engine calls the "AI name": it is used ONLY in the
log message when the territory is not found and does NOT affect point selection itself. Returns a ready
position (CPosition), from which x/y/z is then taken.

Signature

GetRandomPosInTerritory2( string pwsTerritoryName, int nIsFlying, string pwsAiName )

Parameters

    pwsTerritoryName (string) — the name of the territory (declared in npcpos.txt) inside which a random point is taken.
    nIsFlying (int) — take the point in the air (for flying, 1) or on the ground (0).
    pwsAiName (string) — a label for the log (the calling AI's name); participates only in the error message, does not affect point selection.


Example (illustrative):

    GetRandomPosInTerritory2( "", nIsFlying, "" );

InstantTeleportNPC🟢 high

instantly move a creature to a point

Instantly moves creature c to the given point of the game world. Takes a creature
(CSharedCreatureData) and three integer coordinates x, y, z; the arguments have no
namespace, and there is no return value. The most common teleport: take a player or their
summon (via attacker.master) out of combat or a zone, deliver them to an event site;
works on anyone — talker, attacker, any creature.

Signature

InstantTeleport( CSharedCreatureData cCreature, int x, int y, int z )

Parameters

cCreature (CSharedCreatureData) — who to teleport.
x (int) — destination X coordinate.
y (int) — Y coordinate.
z (int) — Z coordinate.

Example

InstantTeleport( myself.sm, i0, i1, i2 );

Usage example

if (GetPathfindFailCount() > 10 && speller == myself.top_desire_target && FloatToInt(myself.sm.hp) != FloatToInt(myself.sm.max_hp)) {
    InstantTeleport(myself.sm, FloatToInt(speller.x), FloatToInt(speller.y), FloatToInt(speller.z));
}

InstantTeleportInMyTerritoryNPC🟢 high

mass transfer within the NPC's territory

Mass teleport: moves all creatures located on the territory assigned to the NPC
to the point nPosX, nPosY, nPosZ with scatter within radius nRadius around the destination
point. All four arguments are integers, no namespace, returns no
value. This is how raid bosses gather players or, conversely, throw them out of the zone when
resetting a fight.

Signature

InstantTeleportInMyTerritory( int nPosX, int nPosY, int nPosZ, int nRadius )

Parameters

nPosX (int) — destination X.
nPosY (int) — destination Y.
nPosZ (int) — destination Z.
nRadius (int) — scatter radius/area (to be clarified).

Example

InstantTeleportInMyTerritory(f8_x, f8_y, f8_z, 500);

Usage example

if ( myself.sm.db_value == 0 && myself.sm.alive == 1 ) {
    InstantTeleportInMyTerritory( 80464, 152294, -3534, 100 );
}

InstantTeleportInMyTerritory2NPC🟢 high

mass territory transfer variant

The second variant of "gathering" creatures across the NPC's territory: moves everyone currently on
the territory assigned to the NPC at once to the point (x, y, z), spreading them not into a single cell but with
scatter within nRadius around it so the crowd does not clump into one spot. Often
called in a chain via switch — each case gets its own destination point; this is how players are
repositioned between combat phases or platforms. Returns nothing. Differs from the version without "2"
only in the subtlety of picking the final point (a walkability check); for the scripter
the behavior and all four arguments are identical.

Signature

InstantTeleportInMyTerritory2( int nPosX, int nPosY, int nPosZ, int nRadius )

Parameters

nPosX (int) — X of the point where to gather creatures.
nPosY (int) — destination Y.
nPosZ (int) — destination Z.
nRadius (int) — scatter radius around the point: creatures are spread within it so they do not clump.

Example

InstantTeleportInMyTerritory2(-19480, 187344, -5600, 200);

InstantRandomTeleportInMyTerritoryNPC🟢 high

teleport the NPC to a random point of its territory

Teleports the NPC to a random point of its territory without specifying coordinates — the engine
picks it itself. No arguments, no return value. Used for
"jerking" a mob around the zone.

Signature

InstantRandomTeleportInMyTerritory(  )

Parameters

(none — the function is called without arguments)

Example

InstantRandomTeleportInMyTerritory();

Usage example

if ( DBPosCheck == 1 && reply == 1 && InMyTerritory( myself.sm ) == 0 ) {
    InstantRandomTeleportInMyTerritory( );
}

TeleportToNPC🟢 high

pull one creature to another

Teleports creature pTarget1 to the position of creature pTarget2 — pulls one to the
other without specifying explicit coordinates. Takes two creatures (CSharedCreatureData),
no namespace, returns no value. Convenient to gather a target to an anchor.

Signature

TeleportTo( CSharedCreatureData pTarget1, CSharedCreatureData pTarget2 )

Parameters

pTarget1 (CSharedCreatureData) — who is being moved.
pTarget2 (CSharedCreatureData) — to whom (destination = their position).

Example

TeleportTo(myself.sm, myself.c_ai0);
TeleportTo( attacker, attacker.master );
TeleportTo(attacker.master, attacker.master);

TeleportToUserNPC🟢 high

move a creature to a player

A TeleportTo variant aimed at moving creature c1 to player c2 (for example,
summoning an NPC or a pet to its owner). Takes two creatures (CSharedCreatureData),
no namespace, returns no value. The exact difference from TeleportTo is unconfirmed.

Signature

TeleportToUser( CSharedCreatureData c, CSharedCreatureData cUser )

Parameters

c (CSharedCreatureData) — who is being moved.
cUser (CSharedCreatureData) — to which player (destination = their position).

Example

    TeleportToUser(talker, c0);

Related event: the server response arrives via the TELEPORT_TO_USER_RES event (see NASC_HANDLERS).

TeleportNPC🟢 high

classic teleport gatekeeper with a destination menu

The classic city teleport gatekeeper: shows the player a list of destinations
telPosList (type CTelPosList) with labels and transfers by choice. Per the L2NPC decompile
(CNPC::Teleport_4885D0) the window is sent to the server via an opcode 7 packet of format "cdddSSSSdSd":
after the service fields come four window label strings, the currency item id and its
display name. The first label string is the title/shop name (ShopName), the other three
are usually empty; the second-to-last argument is the payment currency from [item_pch] (@adena=57 in the calls),
the last one is its name for display ("Adena"). Returns no value. There is an extension
TeleportFStr with localized NPC-string labels.

Signature

Teleport( CSharedCreatureData c, CTelPosList telPosList, string sTitle, string sLabel2, string sLabel3, string sLabel4, int nCurrencyItemId, string sCurrencyName )

Parameters

c (CSharedCreatureData) — player.
telPosList (CTelPosList) — list of destinations.
sTitle (string) — title/name of the teleport window (ShopName).
sLabel2 (string) — extra window label (usually "" / _blank).
sLabel3 (string) — extra window label (usually "" / _blank).
sLabel4 (string) — extra window label (usually "" / _blank).
nCurrencyItemId (int) — payment currency item (@adena = 57 in the calls).
    values — from the [item_pch] dictionary
sCurrencyName (string) — display name of the currency ("Adena").

Example

Teleport( talker, PositionPrimeHours, ShopName, _blank, _blank, _blank, @adena, "Adena" );
Teleport( talker, Position1, ShopName, _blank, _blank, _blank, 57, _blank );
Teleport( talker, Position2, ShopName, _blank, _blank, _blank, 57, _blank );
Teleport( talker, PositionPrimeHours, ShopName, "", "", "", 57, "Adena" );

Usage example

if ( reply == 3 ) {
    Teleport( talker, Position3, ShopName, "", "", "", 57, MakeFString( 1000308, "", "", "", "", "" ) );
}

TeamInstantTeleportNPC🟢 high

teleport an event team to arena coordinates

Teleports an event team (by nEventId and nTeamId) to the point x, y, z — for PvP and
event arenas, to disperse teams to their starting positions. All five arguments are
integers, no namespace; returns a result (number transferred or a code). There is a
strict version TeamInstantTeleportWithConditions with checks and exclusion of
unsuitable participants.

Signature

TeamInstantTeleport( int nEventId, int nTeamId, int nX, int nY, int nZ )

Parameters

nEventId (int) — event id.
nTeamId (int) — team id.
nX (int) — X coordinate of the point where the team is teleported
nY (int) — Y coordinate of the point where the team is teleported
nZ (int) — Z coordinate of the point where the team is teleported

Example

TeamInstantTeleport(my_Event, 1, 147574, 46717, -3400);
TeamInstantTeleport(my_Event, 1, Return_X, Return_Y, Return_Z );
TeamInstantTeleport(my_Event, 2, Return_X, Return_Y, Return_Z );
TeamInstantTeleport(my_Event, 2, 151496, 46717, -3400);

Usage example

if ( TeamEventGetStatus( my_Event ) == @TEAMEVENT_STATUS_BATTLE ) { // if the event is in battle mode and players are on the arena
    TeamInstantTeleport( my_Event, 1, Return_X, Return_Y, Return_Z );
    TeamInstantTeleport( my_Event, 2, Return_X, Return_Y, Return_Z );
    InstantTeleportInMyTerritory( Return_X, Return_Y, Return_Z, 50 );
}

TeleportPartyNPC🟢 high

teleport an entire party

Teleports party members to the point x, y, z. Per the L2NPC decompile it assembles an atomic-job
and sends the server an opcode 14 packet; the handler (L2Server: AtomicTeleportParty::Do_44BF5C) takes
the party leader's position and iterates over all members. The fifth argument is a filter by distance from
the leader: if 0 — ALL members are teleported; if greater than zero — only those who are within
that distance from the leader (in a straight line). The sixth argument is a private id that the server
assigns to each teleported member (CCreature::SetPrivateID). Returns 1.

Signature

TeleportParty( int nPartyId, int x, int y, int z, int nMaxDistFromLeader, int nPrivateId )

Parameters

nPartyId (int) — id of the party being teleported (party0.id).
x (int) — destination X coordinate.
y (int) — destination Y coordinate.
z (int) — destination Z coordinate.
nMaxDistFromLeader (int) — 0 = teleport all members; >0 = only members within
    this distance from the party leader (0 in the calls).
nPrivateId (int) — private id assigned to each teleported member (0 in the calls).

Example

TeleportParty( party0.id, 113600, -126170, -3512, 0, 0 );

InstantTeleportWithItemNPC🟢 high

paid teleport that deducts an item

Teleport for a fee: moves creature c to the point x, y, z, deducting nCount pieces
of item nItemClassId. Takes a creature, three integer coordinates, the identifier
of the payment item [item_pch] and the count (int64); returns no value. A paid
teleporter.

Signature

InstantTeleportWithItem( CSharedCreatureData c, int x, int y, int z, int nItemClassId, int64 nCount )

Parameters

c (CSharedCreatureData) — who to teleport.
x (int) — destination X coordinate.
y (int) — destination Y coordinate.
z (int) — destination Z coordinate.
nItemClassId (int) — payment item for the teleport.
    values — from the [item_pch] dictionary
nCount (int64) — quantity of the payment item to deduct.

Example

InstantTeleportWithItem(talker, -80684, 149770, -3043, ItemNeeded, 1);
InstantTeleportWithItem(talker, -80749, 149834, -3043, ItemNeeded, 1);

Usage example

if (OwnItemCount( talker, ItemNeeded ) != 0) {
    InstantTeleportWithItem(talker, -80684, 149770, -3043, ItemNeeded, 1);
    return;
} else {
    ShowPage(talker, fnNoItem);
}

SetTeleportPosOnLostNPC🟢 high

NPC return point on target loss

Sets the point x, y, z where the NPC teleports after losing its target (on aggro reset or
leaving the bounds). Takes three integer coordinates, no namespace, returns no
value. Analogous to returning to the spawn point — configures the leash behavior.

Signature

SetTeleportPosOnLost( int x, int y, int z )

Parameters

x (int) — X coordinate of the return point on target loss.
y (int) — Y coordinate of the return point on target loss.
z (int) — Z coordinate of the return point on target loss.

Example

SetTeleportPosOnLost( b03_x1, b03_y1, b03_z1 );
SetTeleportPosOnLost( b03_x2, b03_y2, b03_z2 );
SetTeleportPosOnLost( b03_x3, b03_y3, b03_z3 );
SetTeleportPosOnLost( b03_x4, b03_y4, b03_z4 );

Usage example

if ( myself.i_ai0 == 1 && InMyTerritory( myself.sm ) == 0 ) {
    SetTeleportPosOnLost( b03_x1, b03_y1, b03_z1 );
    InstantTeleport( myself.sm, b03_x1, b03_y1, b03_z1 );
}

DistFromMeNPC🟢 high

distance from the NPC to a creature

Returns the distance from this NPC to creature c. This is the main range-check tool — let the target approach or back off, whether it is within cast range, whether the target ran away; the result is compared with thresholds (less than three hundred, no more than fifteen hundred and so on). Takes creature c (CSharedCreatureData), returns float.

Signature

DistFromMe( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — who to measure the distance to.

Example

f0 = DistFromMe( myself.c_ai1 );
f0 = DistFromMe( c0 );
f0 = DistFromMe(myself.c_quest0);

Usage example

if ( IsNullCreature( myself.boss ) == 0 && DistFromMe( myself.boss ) > 500 && myself.boss.alive != 0 && myself.p_state != 3 ) {
    InstantTeleport( myself.sm, FloatToInt( myself.boss.x ), FloatToInt( myself.boss.y ), FloatToInt( myself.boss.z ) );
}

PointDistFromMeNPC🟢 high

distance from the NPC to a point

Returns the distance from the NPC to an arbitrary point x, y, z rather than to a creature. Convenient for checking proximity to an anchor or a zone when there is no creature at that point. Takes three float coordinates, returns float.

Signature

PointDistFromMe( float x, float y, float z )

Parameters

x (float) — X coordinate of the point to which the distance from the NPC is measured.
y (float) — Y coordinate of the point to which the distance from the NPC is measured.
z (float) — Z coordinate of the point to which the distance from the NPC is measured.

Example

i6 = FloatToInt( PointDistFromMe( i7, i8, i9 ) );

Usage example

if (PointDistFromMe(myself.start_x, myself.start_y, myself.start_z) > 10000)
{
    InstantTeleport(myself.sm, myself.start_x, myself.start_y, myself.start_z);
}

StaticObjectDistFromMeNPC🟢 high

distance to a static object

Returns the distance from the NPC to a static object — a door, siege flag, artifact (an object of type CSharedStaticObjectData). Used in logic around doors and thrones. Takes obj (CSharedStaticObjectData), returns float.

Signature

StaticObjectDistFromMe( CSharedStaticObjectData obj )

Parameters

obj (CSharedStaticObjectData) — static object (door/flag/artifact).

Example

if ( StaticObjectDistFromMe( so0 ) >= 2500 ) {

Usage example

if ( StaticObjectDistFromMe( so0 ) >= 2500 ) { SayFStr( 1110074, _blank, _blank, _blank, _blank, _blank ); } else
{
    if ( Skill_InReuseDelay( DDMagic ) ) { SayFStr( 1010551, _blank, _blank, _blank, _blank, _blank );  }
    if ( Skill_GetConsumeMP( DDMagic ) < myself.sm.mp && Skill_GetConsumeHP( DDMagic ) < myself.sm.hp && Skill_InReuseDelay( DDMagic ) == 0 ) {
        AddUseSkillDesireExByAction(i0, DDMagic, 0, reply, ask, 1000000, 0, action_id);
    }
}

GetAngleFromTargetNPC🟢 high

angle to a creature relative to the NPC

Returns the angle to creature c relative to the NPC's orientation in client units (65536 = 360°). The AI uses it to determine the sector — front, side or back: for example, a range of roughly 36864..61440 (202°…337°) means the target is behind-to-the-side, which is needed for positional skills like a backstab. Takes creature c (CSharedCreatureData), returns int.

Signature

GetAngleFromTarget( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — relative to whom the angle is taken.

Example

i0 = GetAngleFromTarget(creature);

GetDirectionNPC🟢 high

direction from the NPC to a creature

Returns the direction (heading) from the NPC to creature c in client rotation units. Used to turn someone to face the right way or to set orientation when spawning helpers. Takes creature c (CSharedCreatureData), returns int.

Signature

GetDirection( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — who the direction points to.

Example

i0 = GetDirection(myself.sm);
i1 = GetDirection( myself.sm );

GetDirectionToTargetNPC🟢 high

direction from the NPC to a creature

Returns the direction (heading) from the NPC to creature c in client rotation units, like GetDirection; the exact difference between the two variants is unconfirmed (this one probably relates to the current aggro target). Takes creature c (CSharedCreatureData), returns int.

Signature

GetDirectionToTarget( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature whose direction (heading) is returned

Example

CreateOnePrivateEx( @event_its_pig, "ai_event_its_pig", 0, 0, FloatToInt( myself.sm.x ), FloatToInt( myself.sm.y ), FloatToInt( myself.sm.z ), (GetDirectionToTarget( myself.sm ) * 182), myself.i_ai0, 0, 0 );

FindNeighborHeroNPC🟢 high

find a hero nearby

Searches within radius nDist for a character with Hero status and returns them (or null) for a special NPC reaction to the presence of heroes nearby. The result is usually checked via IsNull. Takes nDist (int), returns a creature (CSharedCreatureData).

Signature

FindNeighborHero( int nDist )

Parameters

nDist (int) — search radius.

Example

c3 = FindNeighborHero(4000);

Usage example

c3 = FindNeighborHero( 4000 );
if ( IsNullCreature( c3 ) == 0 ) {
    BroadcastOnScreenMsgFStr( myself.sm, 4000, 1, 0, 0, 0, 0, 0, 3000, 0, 1000519, c3.name, _blank, _blank, _blank, _blank );
}

InstantTeleportMPCCNPC🟢 high

teleport all channel members

Teleports the members of the creature's command channel (MPCC) to the point x, y, z, distributing them around
it. Per the L2Server handler (NpcInstantTeleportMPCC → CMultiPartyCommandChannel::TeleportMPCCToLocation)
the server: takes the channel members, lays out landing points within the scatter radius around the target,
for each checks geodata and picks a ground level (FindGround with +200 on Z, a random
scatter ±60), and if a member is already within the radius — does not move it. The fourth argument is
the scatter radius (compared as radius² with the squared distance; in calls 1000/3000). The fifth and
sixth configure the layout of the landing points; with a given delay (int64 > 0) the teleport is performed
deferred. No return.

Signature

InstantTeleportMPCC( CSharedCreatureData c, int x, int y, int z, int nRadius, int nLayoutParam1, int nLayoutParam2, int nPrivateId, int64 nDelay )

Parameters

c (CSharedCreatureData) — the creature by whose command channel the members are teleported.
x (int) — the X coordinate of the target point.
y (int) — the Y coordinate of the target point.
z (int) — the Z coordinate of the target point.
nRadius (int) — the scatter radius around the target: members are scattered within it, those already
    inside — are not moved (in calls 1000, 3000).
nLayoutParam1 (int) — a landing-point layout parameter (in calls 0, 100, 200).
nLayoutParam2 (int) — a landing-point layout parameter (in calls 200, 300, 500).
nPrivateId (int) — the private id set on the teleported members (in calls 0, 57, 3865).
nDelay (int64) — the teleport delay: >0 enables a deferred teleport (in calls 0 — immediately).

Example

InstantTeleportMPCC( talker, TelPosX, TelPosY, TelPosZ, 3000, 100, 200, 0, 0 );
InstantTeleportMPCC( talker, 179700, 113800, -7709, 1000, 200, 500, 3865, 0 );
InstantTeleportMPCC(talker, TelPosX, TelPosY, TelPosZ, 1000, 100, 200, 0, 0);
InstantTeleportMPCC( talker, 16342, 209557, -9352, 3000, 0, 300, 57, 0 );

InstantTeleportInMyTerritoryWithConditionNPC🟢 high

conditional teleport within the territory

Mass-moves creatures located on this NPC's territory to a given point.
Not everyone moves, but those selected by group membership: the pair (nType, nCondition)
sets the filter. A candidate is moved only if it is in the same instant zone as the NPC,
stands inside the NPC's territory, and falls within its height range. Returns nothing;
used in combat/team zones (towers, halls), to gather at once or, conversely,
to set out a group of players. The landing point is (x, y) with a random scatter within
nRadius (the ground is picked by the terrain).

Signature

InstantTeleportInMyTerritoryWithCondition( int x, int y, int z, int nRadius, int nType, int nCondition )

Parameters

x (int) — the X coordinate of the target point.
y (int) — the Y coordinate of the target point.
z (int) — the Z coordinate of the target point (used as the reference height when searching for ground).
nRadius (int) — the radius of the random scatter around the point (in calls 200).
nType (int) — the group-selection mode (what meaning nCondition has):
    1     — move ONLY members of the group with id = nCondition;
    2     — move everyone on the territory EXCEPT members of the group with id = nCondition;
    other — move everyone, nCondition is not taken into account.
nCondition (int) — the group id (party id) against which each candidate's membership is checked.
    In the example this is myself.i_quest0, into which the player's group id was written in advance
    (myself.i_quest0 = party0.id).

Example

InstantTeleportInMyTerritoryWithCondition( 16110, 243841, 11616, 200, 2, myself.i_quest0 );

// (from c_tower_combat_manager: in advance myself.i_quest0 = party0.id — the id of the entered player's group;
//  nType=2 → move everyone on the territory to the point, except this group)

RenewSpawnedPosNPC🟢 high

recompute the spawn position

Recomputes (updates) the spawn position, for example on revival. Takes the
coordinates x, y, z, usually taken from the NPC's own current position. Returns
nothing.

Signature

RenewSpawnedPos( int x, int y, int z )

Parameters

x (int) — the new X coordinate of the spawn position.
y (int) — the new Y coordinate of the spawn position.
z (int) — the new Z coordinate of the spawn position.

Example

RenewSpawnedPos(FloatToInt(myself.sm.x), FloatToInt(myself.sm.y), FloatToInt(myself.sm.z));

Usage example

if (timer_id == 7777 && type == 1) {
    RenewSpawnedPos(FloatToInt(myself.sm.x), FloatToInt(myself.sm.y), FloatToInt(myself.sm.z));
} else
if (timer_id == 7787) {
    Despawn();
}

INSTANCES AND ROOMS (InstantZone / Room)

14 functions

CreateRoomInfoListGLOBAL🟢 high

build a list of rooms for the interface

Creates a named container of rooms (a RoomInfoList) in the global table.
The first argument is the list name, the second is the capacity (how many rooms). Returns one
if the list was created, and zero if a list with that name already exists (see the example —
that is exactly why the result is checked against zero). Rooms are then addressed through the handler's local
slots (room0, rlist0, etc.).

Signature

CreateRoomInfoList( string sListName, int nCapacity )

Parameters

sListName (string) — the name of the room list being created
nCapacity (int) — the list capacity (number of rooms)

Example

i0 = CreateRoomInfoList(LevelName, 9);

Usage example

i0 = CreateRoomInfoList(LevelName, 9);
if (i0 == 0) {
}

InstantZone_GetNpcMakerGLOBAL🟢 high

find a maker inside an instance

Finds a maker inside an instance by the zone identifier and its name. Called
globally (gg); the arguments are the zone identifier (from InstantZone_GetId /
GetInZoneID) and the maker name; returns the maker object. The result is checked for
emptiness and then sent an event.

Signature

InstantZone_GetNpcMaker( int nInstZoneId, string sMakerName )

Parameters

nInstZoneId (int) — the identifier of the zone inside which the maker is searched (InstantZone_GetId()/GetInZoneID())
sMakerName  (string) — the name of the maker being searched

Example

maker0 = InstantZone_GetNpcMaker( i0, s0 );

Usage example

maker0 = InstantZone_GetNpcMaker( InstantZone_GetId( ), "godard32_1713_103m1" );
if ( IsNull( maker0 ) == @FALSE ) { SendMakerScriptEvent( maker0, @SPAWN_ALL_INSTANT, 0, 0 ); }

GetRoomInfoListGLOBAL🟢 high

a level's room list

Returns a level's list of "rooms" by its name. Called globally (gg);
the single argument is the level name; a room is a record of a party that has taken a slot
or a copy. From the list a room is taken by index, its fields are read (the party
identifier, the number of members, time, atomic state) and its members are iterated;
more about the room object is said in the objects file.

Signature

GetRoomInfoList( string sLevelName )

Parameters

sLevelName (string) — the name of the level whose room list is requested

Example

rlist0 = GetRoomInfoList(LevelName);

Usage example

rlist0 = GetRoomInfoList( LevelName );
if( IsNull( rlist0 ) ) {
    AddTimerEx( timer_id, 10000 );
    return;
}

InstantZone_EnterNPC🟢 high

send a player into a new instant zone

Sends a creature into a new instant zone of the given type. Called on the NPC (myself);
the arguments are the creature itself (talker), the zone type, and the enter type from
[manual_pch] (@eIZ_ET_*), which determines who gets pulled in: only the player himself,
his whole party, or the entire command channel (i.e. the raid). The zone type may be a raw
number, a named constant, or taken directly from the player's field — "the type he is
already using"; the latter is needed to re-enter one's own zone and is the most common case.
Returns nothing.
Related event: the reply arrives as the INSTANT_ZONE_ENTER_RETURNED event (see NASC_HANDLERS).

Signature

InstantZone_Enter( CSharedCreatureData c, int nZoneType, int nEnterType )

Parameters

c (CSharedCreatureData) — who enters (talker).
nZoneType (int) — instant zone type (raw number, named constant, or the player's field — "his type").
nEnterType (int) — who to pull into the instant zone (manual_pch):
    @eIZ_ET_ONLY_ME (0) — only the player himself; @eIZ_ET_ALL_PARTY (1) — his whole party;
    @eIZ_ET_COMMAND_CHANNEL (2) — the entire command channel (raid).

Example

InstantZone_Enter(talker, i0, @eIZ_ET_ONLY_ME);

Usage example

if ( zone_type > -1 && enter_type > -1 ) {
    InstantZone_Enter( talker, zone_type, enter_type );
}

InstantZone_LeaveNPC🟢 high

take a player out of the instant zone

Takes the specified creature out of the instant zone. Called on the NPC (myself); the only
argument is the creature itself. Returns nothing.

Signature

InstantZone_Leave( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature being taken out of the instant zone

Example

InstantZone_Leave(c0);

Usage example

if ( ask == 23000 && reply == 1 ) {
    InstantZone_Leave( talker );
}

InstantZone_FinishNPC🟢 high

close the instant zone

Finishes (closes) the current instant zone with a delay in seconds. Called on the NPC
(myself); the only argument is the delay before closing (0/5/10/15 in the scripts),
given so that players have time to leave or read a message. Returns nothing.

Signature

InstantZone_Finish( int nDelay )

Parameters

nDelay (int) — delay before closing the instant zone, in seconds

Example

InstantZone_Finish(5);

Usage example

if ( InzoneRestriction == 1 || InzoneFinish == 1 ) {
    InstantZone_Finish( 5 );
}

InstantZone_GetIdNPC🟢 high

id of the current instant zone

Returns the identifier of the current instant zone. Called on the NPC (myself), no
arguments; the obtained id is then passed to instant zone door control, to NPC spawning
inside the copy, and to zone maker lookup.

Signature

InstantZone_GetId(  )

Parameters

(none — the function is called without arguments)

Example

i0 = InstantZone_GetId();
i2 = InstantZone_GetId();
i1 = InstantZone_GetId();
i4 = InstantZone_GetId( );

Usage example

i2 = InstantZone_GetId( );
if ( c0.instant_zone_id == i2 ) {
    AddMoveToDesire( FloatToInt( c0.x ), FloatToInt( c0.y ), FloatToInt( c0.z ), 100000000 );
}

InstantZone_GetDurationNPC🟢 high

zone duration

Activates lifetime tracking for the current instant zone — starts its duration timer.
Despite the name, it returns no value (void): in scripts it is called to start the zone's
countdown, after which a custom timer is set (AddTimerEx).

Signature

InstantZone_GetDuration(  )

Parameters

(none — the function is called without arguments)

Usage example

if (myself.sm.flag != 2) {
    InstantZone_GetDuration();
    AddTimerEx(1002, 60 * 1000);
}

InstantZone_AddExtraDurationNPC🟢 high

extend the zone

Extends the lifetime of the current instant zone by nExtraSec seconds. Used, for example,
to give the party extra time for killing a boss (+600 or +1200 s in the scripts).

Signature

InstantZone_AddExtraDuration( int nExtraSec )

Parameters

nExtraSec (int) — extra lifetime for the instant zone, in seconds (1200 in the calls).

Usage example

if ( InstantZone_ID >= 131 && InstantZone_ID <= 132 ) {
    InstantZone_AddExtraDuration( 1200 );
}

InstantZone_MarkRestrictionNPC🟢 high

mark the zone restriction

Marks the player/party as having used the current instant zone — a re-entry restriction
that lasts until the instance resets. Called when the zone has the re-entry restriction
mode enabled.

Signature

InstantZone_MarkRestriction(  )

Parameters

(none — the function is called without arguments)

Usage example

if ( InzoneRestriction == 1 ) {
    InstantZone_MarkRestriction( );
}

InstantZone_SendMakerEventNPC🟢 high

broadcast an event to instant zone makers

Broadcasts an event to the makers (spawners) of a specific instant zone. Per the L2NPC
decompile (CNPC::InstantZone_SendMakerEvent → CNpcMakerDB::InstantZoneEvent_53BB8C) the
engine finds the maker by zone type and cluster, then for every maker with a matching
event code calls NpcMakerEx::OnInstantZoneEvent. There are no direct calls in the scripts,
but the parameter semantics are visible in the code and the engine's error strings
("inzone type… clusterID… event…").

Signature

InstantZone_SendMakerEvent( int nInzoneType, int nClusterId, int nInzoneId, int nEvent, int nEventArg )

Parameters

    nInzoneType (int) — instant zone type (looked up in the maker DB; "inzone type" in the log).
    nClusterId (int) — maker cluster id ("clusterID" in the log).
    nInzoneId (int) — id of the specific instance copy the event is addressed to.
    nEvent (int) — event code for the makers; special values: -1 = delete the zone maker,
        -2 = create the zone maker; otherwise — the event code broadcast to matching makers.
    nEventArg (int) — event data/argument, passed to the maker in OnInstantZoneEvent.

Example (illustrative):

    InstantZone_SendMakerEvent( nInzoneType, nClusterId, nInzoneId, nEvent, nEventArg );

InstantZone_GetTypeIdNPC🟢 high

type of the zone in use

Returns the type (type id) of the current instant zone — the numeric identifier of its
VARIETY from the instance data (which dungeon/hall it is by its template, not the individual
running instance). Takes no arguments — uses the instance this NPC is in. Returns 0 if the
NPC is not inside an instant zone. The result is usually compared against a named zone-type
constant to branch behaviour for a specific instance.

Zone types are named with @..._IZ_ID_* constants (values live in the manual_pch of the
relevant chronicle). In our chronicle, for example: @SSQ2_IZ_ID_AZIT_OF_DAWN=113,
@SSQ2_IZ_ID_TEMPLE_OF_SILENCE=151, @SSQ2_IZ_ID_LIB=156, @SSQ2_IZ_ID_HOME_OF_ELCADIA=158,
@MDE_IZ_ID=159, @MDE_IZ_ID_HELL=196, @SSQ25_IZ_ID_HOME_OF_ELCADIA=197. The set of ids
depends on the chronicle and its instance data.

NOTE: do not confuse the zone type (@..._IZ_ID_*) with the ENTRY type @eIZ_ET_* (ONLY_ME=0,
ALL_PARTY=1, COMMAND_CHANNEL=2) — the latter defines who is admitted on entry (an argument
of InstantZone_Enter) and has nothing to do with the value returned here.

Signature

InstantZone_GetTypeId(  )

Parameters

(none — the function is called without arguments)

Returns

    int — the type id of the instant-zone variety (see @..._IZ_ID_*), or 0 outside an instance.


Example (illustrative):

    if ( InstantZone_GetTypeId( ) == @MDE_IZ_ID_HELL ) {
        // behaviour branch for a specific instance
    }

SharedInstantZone_EnterNPC🟢 high

enter an instant zone by coordinates

Starts the player's entry into an instant zone and initiates loading the dungeon. Takes the
recipient (talker), the zone type, the entry type, and the entry point coordinates x, y, z.
Returns nothing.
Related event: the response arrives as the INSTANT_ZONE_ENTER_RETURNED event (see NASC_HANDLERS).

Signature

SharedInstantZone_Enter( CSharedCreatureData c, int nZoneType, int nEnterType, int x, int y, int z )

Parameters

c (CSharedCreatureData) — the recipient creature of the entry (talker).
nZoneType (int) — the instant-zone type.
nEnterType (int) — whom to pull into the instance (manual_pch): @eIZ_ET_ONLY_ME (0) — only the player,
    @eIZ_ET_ALL_PARTY (1) — the whole party, @eIZ_ET_COMMAND_CHANNEL (2) — the whole command channel.
x (int) — the X coordinate of the entry point.
y (int) — the Y coordinate of the entry point.
z (int) — the Z coordinate of the entry point.

Example

SharedInstantZone_Enter(talker, nInZoneTypeId, nEnterType, 212866, 179998, -15480);
SharedInstantZone_Enter(talker, nInZoneTypeId, nEnterType, x_start, y_start, z_start);

GetInZoneIDMAKER🟢 high

zone identifier of the maker

Returns the identifier of the zone in which the maker was created. Called from the
maker's side (when an NPC is deleted), without arguments; plays the same zone-address role as
InstantZone_GetId.

Signature

GetInZoneID(  )

Parameters

(none — the function is called without arguments)

Example

i0 = GetInZoneID( );
i2 = GetInZoneID( );

DOORS, GATES AND AREAS (Doors / Gates / Areas)

8 functions

Castle_GateOpenClose2GLOBAL🟢 high

open or close a named gate

Opens or closes a named gate or door of a castle or fortress. The first
argument is the door name (a string from the script parameters, like a leaf name or a wall
section), the second is the state from the [manual_pch] dictionary: @CGOC_OPEN=0 means "open", and
@CGOC_CLOSE=1 means "close". It is easy to err here: zero opens, one closes, not the
other way around. A global function on gg, returns an int.

Signature

Castle_GateOpenClose2( string sDoorName, int nOpenClose )

Parameters

sDoorName  (string) — the door/gate name from the world data.
nOpenClose (int) — the state [manual_pch]: @CGOC_OPEN=0 (open), @CGOC_CLOSE=1 (close).

Example

Castle_GateOpenClose2( DoorName1, 0 );

Castle_GateOpenCloseExGLOBAL🟢 high

open or close a gate inside an instance

An extended form of the previous function for doors inside an instance. The first two arguments are the
same — the door name and the state from the [manual_pch] dictionary (@CGOC_OPEN=0 open,
@CGOC_CLOSE=1 close), and the third is the instant-zone identifier, to address the
door inside a specific instance. A global function on gg, returns an int.

Signature

Castle_GateOpenCloseEx( string sDoorName, int nOpenClose, int nInstZoneId )

Parameters

sDoorName   (string) — the name of the door being controlled
nOpenClose  (int) — the state [manual_pch]: @CGOC_OPEN=0 (open), @CGOC_CLOSE=1 (close)
nInstZoneId (int) — the identifier of the instant zone in which the door is addressed (InstantZone_GetId())

Example

Castle_GateOpenCloseEx(DoorName, @CGOC_OPEN, i2);

Usage example

if ( arena == 4 ) {
    Castle_GateOpenCloseEx( "olympiad_door_301", 0, InstantZone_GetId( ) );
    Castle_GateOpenCloseEx( "olympiad_door_302", 0, InstantZone_GetId( ) );
}

Area_SetOnOffGLOBAL🟢 high

turn a named area on or off

Turns a named world area on or off. These are effect zones — territories that
give a buff or debuff, for example healing, empowerment, or harmful effects, as well as an entry ban.
The first argument is the zone name from the script parameters, the second is the state: one
turns it on, zero turns it off. A global function on gg, returns an int.

Signature

Area_SetOnOff( string sAreaName, int nOnOff )

Parameters

sAreaName (string) — the name of the area zone (from the script parameters) that is turned on or off
nOnOff    (int) — the zone state: 1 turns it on (@AS_ON), 0 turns it off

Example

Area_SetOnOff( areadata_heal1, 0 );

Area_SetOnOffExGLOBAL🟢 high

turn an area on or off (extended form)

An extended form of controlling a named area. The first two arguments are the same — the zone name
and the state (one turns it on, zero turns it off), and the third is an additional parameter.
A global function on gg, returns an int.

Signature

Area_SetOnOffEx( string sAreaName, int nOnOff, int nInstZoneId )

Parameters

sAreaName   (string) — the name of the zone being controlled
nOnOff      (int) — the zone state: 1 turns it on (@AS_ON), 0 turns it off
nInstZoneId (int) — the instant-zone identifier for addressing (InstantZone_GetId())

Example

Area_SetOnOffEx(AREA_effect_1s_01, @AS_ON, i0);

Usage example

if ( IsSameString( areadata, "extended_door_trap_area_default" ) == 0 ) {
    Area_SetOnOffEx( areadata, 1, InstantZone_GetId( ) );
}

Area_SetBannedTerritoryOnOffGLOBAL🟢 high

turn a restricted territory on or off

Controls a restricted territory — an area that entry into is blocked. A named area
contains a list of sub-territories; the function turns the ban on/off for a SPECIFIC sub-territory
by its index. Per the L2Server handler (NpcAreaSetBannedTerritoryOnOff → CArea::SetBannedTerritoryOnOff),
the third argument is the index of the sub-territory in the area's list: the server takes the territory with that number
and toggles its state; if the index exceeds the number of territories — it does nothing.
A global function on gg, returns an int.

Signature

Area_SetBannedTerritoryOnOff( string sTerritoryName, int nOnOff, int nTerritoryIndex, int nInstZoneId )

Parameters

sTerritoryName (string) — the name of the area (a set of restricted territories) being controlled.
nOnOff         (int) — the state: 1 turns the ban on, 0 removes it.
nTerritoryIndex (int) — the index of the sub-territory within the area (0-based; 0, 2, 3, 4 in calls;
                      the server toggles the territory with that number, out of bounds — a no-op).
nInstZoneId    (int) — the instant-zone identifier (InstantZone_GetId()).

Example

Area_SetBannedTerritoryOnOff(s0, i1, 0, InstantZone_GetId());

InzoneDoorBreakableGLOBAL🟢 high

make an instance door breakable or unbreakable

Makes a named instant-zone door breakable: the first argument is the door name,
the second is the instant-zone identifier where this door is located (InstantZone_GetId() in calls).
The door name is validated (an invalid one → an error in the log). Per decompile — a thin forwarder (opcode 188),
the function has no "breakable/not" flag. A global function on gg.

Signature

InzoneDoorBreakable( string sDoorName, int nInstZoneId )

Parameters

sDoorName   (string) — the name of the instance door being made breakable.
nInstZoneId (int) — the identifier of the instant zone where the door is located (InstantZone_GetId()).

Example

InzoneDoorBreakable("gate_of_fortress", InstantZone_GetId());

SetDoorHpLevelNPC🟢 high

set a door's durability level

Sets the "HP level" of a door in an instant zone: the first argument is the door name, the second —
the durability level. The engine substitutes the current instant-zone identifier itself. Sends
the server the corresponding command. Returns nothing.

Signature

SetDoorHpLevel( string sDoorName, int nHpLevel )

Parameters

sDoorName (string) — the name of the instance door for which the durability is set.
nHpLevel (int) — the durability level ("HP level") of the door.

Example

SetDoorHpLevel(WallName1, i1);

GetDoorHpLevelNPC🟢 high

request a door's durability level

Requests the "HP level" of a door in an instant zone. This is an ASYNCHRONOUS request (like
IsToggleSkillOnOff): the function itself returns nothing — the engine sends the server a request,
and the result arrives as a separate event; the first argument (the addressee) — whom the answer is
intended for, the second — the door name. The engine substitutes the instant-zone identifier itself.

Signature

GetDoorHpLevel( CSharedCreatureData c, string sDoorName )

Parameters

c (CSharedCreatureData) — the addressee of the request, to whom the result is returned (via an event).
sDoorName (string) — the name of the instance door whose durability is requested.

Example

GetDoorHpLevel(talker, WallName1);

TERRITORY FIELD CYCLE (FieldCycle)

7 functions

GetStep_FieldCycleGLOBAL🟢 high

read the cycle's current phase

Returns the current phase (Step) of a cycle. Takes the cycle identifier nFieldId (a class parameter),
called on the global object gg. Returns the discrete stage number, which is usually
compared with a number to decide what to do next.

Signature

GetStep_FieldCycle( int nFieldId )

Parameters

nFieldId (int) — the identifier of the cycle (a class parameter) whose current phase is requested.

Example

i1 = GetStep_FieldCycle(3);

Usage example

i0 = GetStep_FieldCycle( FieldCycle2 );
if ( i0 >= Threshold_Level_Min2 && i0 <= Threshold_Level_Max2 ) {
}

GetPoint_FieldCycleGLOBAL🟢 high

read the accumulated progress

Returns the current progress (Point) of a cycle — a counter within the phase. Takes the cycle identifier
nFieldId, called on the global object gg. Returns the accumulated number of points, which is
compared with the transition threshold.

Signature

GetPoint_FieldCycle( int nFieldId )

Parameters

nFieldId (int) — the identifier of the cycle whose progress is requested

Example

i1 = GetPoint_FieldCycle(FieldCycle);

Usage example

i1 = GetPoint_FieldCycle( FieldCycle );
if ( i0 < Threshold_Min || i0 > Threshold_Max || i1 < Point_Min || i1 > Point_Max ) {
    created_npc.Despawn( );
}

AddPoint_FieldCycleGLOBAL🟢 high

accumulate progress

Adds nPoint progress points to the cycle nFieldId; nReason is the reason code (a raw number, most often
one for a kill by a player), c is who the credit is for (the last attacker or the manager
myself.sm itself). Called on the global object gg. On reaching the threshold, usually a
phase switch follows.

Signature

AddPoint_FieldCycle( int nFieldId, int nPoint, int nReason, CSharedCreatureData cCreature )

Parameters

nFieldId (int) — the identifier of the cycle to which progress points are credited
nPoint (int) — the number of progress points credited
nReason (int) — the credit reason code (a raw number, most often 1 for a kill by a player)
cCreature (CSharedCreatureData) — the creature the points are credited for (the last attacker or the manager itself)

Example

AddPoint_FieldCycle(1, 5 * 20, 4, talker);

Usage example

if (i0 == 1) {
    AddPoint_FieldCycle(FieldCycle_ID, FieldCycle_point, 1, myself.sm);
}

SetStep_FieldCycleGLOBAL🟢 high

switch phase with an initiator

Moves the cycle nFieldId into a new phase nStep and broadcasts an event to all subscribed NPCs and
makers — this is exactly how they learn it is time to change behavior. Takes the reason code nReason
(a raw number) and the initiator creature c, called on the global object gg.

Signature

SetStep_FieldCycle( int nFieldId, int nStep, int nReason, CSharedCreatureData cCreature )

Parameters

nFieldId (int) — the identifier of the cycle moved into a new phase
nStep (int) — the number of the cycle's new phase
nReason (int) — the reason code for the phase change (a raw number)
cCreature (CSharedCreatureData) — the creature initiating the phase change

Example

SetStep_FieldCycle( FieldCycle, 5, 1, c0 );

Usage example

    if ( i0 == 0 ) {
        SetStep_FieldCycle( RaceCycleID, 1, 8, myself.sm );
    }

Related event: the phase change broadcasts ON_FIELD_CYCLE_CHANGED_EVENT(event_id, state, i1) to subscribers; the phase timer expiration arrives as FIELD_CYCLE_STEP_EXPIRED. Subscription — RegisterFieldCycleEventEx / RegisterAsFieldCycleManager (see NASC_HANDLERS).

SetStepWithoutActor_FieldCycleGLOBAL🟢 high

switch phase without an initiator

The paired form of switching phase for the case when the initiator creature is unknown and is not
passed. Takes the cycle identifier nFieldId, the new phase nStep, and the reason code nReason,
called on the global object gg. A typical pairing: if there is a player — the ordinary form is called,
otherwise the form without an actor.

Signature

SetStepWithoutActor_FieldCycle( int nFieldId, int nStep, int nReason )

Parameters

nFieldId (int) — the identifier of the cycle whose phase is switched
nStep (int) — the new phase of the cycle
nReason (int) — the reason code for the switch

Example

    SetStepWithoutActor_FieldCycle( 1, 9, 5 );
    SetStepWithoutActor_FieldCycle( FieldCycle, 5, 1 );
    SetStepWithoutActor_FieldCycle(FieldCycle, 1, 1);
    SetStepWithoutActor_FieldCycle(FieldCycle, 8, 5);

Related event: like SetStep_FieldCycle, the phase change broadcasts ON_FIELD_CYCLE_CHANGED_EVENT to subscribers; the phase timer expiration — FIELD_CYCLE_STEP_EXPIRED (see NASC_HANDLERS).

RegisterAsFieldCycleManagerNPC🟢 high

mark an NPC as a cycle manager

Marks the NPC as a cycle manager, giving it the right to change the phase and progress. No
arguments, called on the NPC (myself), usually in the creation handler. The phase-change
events themselves are "phase changed" and "phase timer expired"; they arrive to subscribers
and are described in the events file.

Signature

RegisterAsFieldCycleManager(  )

Parameters

(none — the function is called without arguments)

Example

    RegisterAsFieldCycleManager();

Related event: the manager receives cycle events — ON_FIELD_CYCLE_CHANGED_EVENT (phase change) and FIELD_CYCLE_STEP_EXPIRED (phase timer expired). Targeted subscription to a specific cycle — RegisterFieldCycleEventEx (see NASC_HANDLERS).

RegisterFieldCycleEventExMAKER🟢 high

subscribe the maker to cycle events

Subscribes the maker to events of cycle nFieldId: after the call it receives notifications about
phase changes. Called on the maker (myself), usually at startup. The return value is auxiliary;
the point of the call is establishing the subscription.

Signature

RegisterFieldCycleEventEx( int nFieldId )

Parameters

nFieldId (int) — identifier of the cycle whose events the maker is subscribed to.

Example

RegisterFieldCycleEventEx( 1 );
RegisterFieldCycleEventEx( FieldCycle );
RegisterFieldCycleEventEx( FieldCycle_ID );

Usage example

    if ( FieldCycle != -1 ) {
        RegisterFieldCycleEventEx( FieldCycle );
    }

Related event: after subscribing, the maker receives cycle events — ON_FIELD_CYCLE_CHANGED_EVENT (phase change) and FIELD_CYCLE_STEP_EXPIRED (phase timer expired). The phase is changed by SetStep_FieldCycle / SetStepWithoutActor_FieldCycle (see NASC_HANDLERS).

SPEECH AND ANNOUNCEMENTS (Say / Chat)

11 functions

AnnounceGLOBAL🟢 high

a global announcement in literal text

A global announcement from the global object gg, not from a specific NPC,
in literal text. Takes one argument sMessage (string) without namespace. Returns nothing
(void).

Signature

Announce( string pStr1 )

Parameters

pStr1 (string) — the text of the global announcement

Example

Announce("DV");

Usage example

if ( is_debug ) {
    Announce( "Follower_frintessa: Summoning final form. Start sequence" );
}

AnnounceFStrGLOBAL🟢 high

a global announcement via an NPC-string

A global announcement from the global object gg using a localized NPC-string with
parameters. Takes nNpcStringId (int) — the string id — and up to five substitutions p1..p5
(string), without namespace. Returns nothing (void).

Signature

AnnounceFStr( int nArg1, string pStr1, string pStr2, string pStr3, string pStr4, string pStr5 )

Parameters

nArg1 (int) — the identifier of the localized NPC-string for the global announcement
pStr1 (string) — the first string substitution into the NPC-string (unused ones passed as `_blank`)
pStr2 (string) — the second string substitution into the NPC-string (unused ones passed as `_blank`)
pStr3 (string) — the third string substitution into the NPC-string (unused ones passed as `_blank`)
pStr4 (string) — the fourth string substitution into the NPC-string (unused ones passed as `_blank`)
pStr5 (string) — the fifth string substitution into the NPC-string (unused ones passed as `_blank`)

Example

AnnounceFStr(1100030, "", "", "", "", "");

Usage example

if ( IsNullCreature( last_attacker ) == @FALSE ) {
    AnnounceFStr( 3603428, "Antharas", last_attacker.name, _blank, _blank, _blank );
}

SayNPC🟢 high

short-range NPC line

The NPC utters a line (pop-up text above its head), visible locally to players
nearby. Takes a single argument sText (string) without a namespace; most often
MakeFString(...) with an NPC-string id is passed in, literal strings appear in debug
messages. Returns int.

Signature

Say( string sText )

Parameters

sText (string) — text (often MakeFString(npcStringId, ...)).

Example

Say( "Amendment. There is not a master" );

Usage example

if ( c0.is_pc == 1 ) {
    Say( MakeFString( 9858, c0.name, _blank, _blank, _blank, _blank ) );
}

SayFStrNPC🟢 high

short-range line via NPC-string

Same as Say(MakeFString(id, p1..p5)), but in a single call: utters the localized
NPC-string nNpcStringId (int), substituting up to five string parameters p1..p5
(string), no namespace; unused ones are passed as _blank/"". The string text for
this id resides in the chronicle's fstring.txt. Returns int.

Signature

SayFStr( int nArg1, string pStr1, string pStr2, string pStr3, string pStr4, string pStr5 )

Parameters

nArg1 (int) — id of the localized client string.
pStr1 (string) — first string substitution into the localized NPC-string (pass `_blank` when unused)
pStr2 (string) — second string substitution into the localized NPC-string (pass `_blank` when unused)
pStr3 (string) — third string substitution into the localized NPC-string (pass `_blank` when unused)
pStr4 (string) — fourth string substitution into the localized NPC-string (pass `_blank` when unused)
pStr5 (string) — fifth string substitution into the localized NPC-string (pass `_blank` when unused)

Example

SayFStr(18455, "", "", "", "", "");

Usage example

if ( c0.is_pc == @TRUE ) {
    SayFStr( 9858, c0.name, _blank, _blank, _blank, _blank );
}

SayIntNPC🟢 high

say a number (debug)

Utters a numeric value as an NPC line — a debug way to print a number, the Say
analog for numbers. Takes a single argument nValue (int64) without a namespace. Returns int.

Signature

SayInt( int64 nValue )

Parameters

nValue (int64) — number to print.

Example

SayInt(1);

SayFloatNPC🟢 high

say a floating-point number (debug)

Like SayInt, but for a floating-point number: debug output of a float as an NPC line. Takes
a single argument fValue (float) without a namespace. Returns nothing (void).

Signature

SayFloat( float fValue )

Parameters

    fValue (float) — floating-point number to print.

Example (illustrative):

    SayFloat( 0.0 );

ShoutNPC🟢 high

NPC shout across the district

Like Say, but with a larger radius — a "shout" heard across the district (shout channel), not
just up close; this is how bosses announce combat phases and events. Takes a single argument
sText (string) without a namespace, often MakeFString(...). Returns int.

Signature

Shout( string sText )

Parameters

sText (string) — text (often MakeFString(...)).

Example

Shout( "I'm coming..." );

Usage example

if ( ShoutMsg1 > 0 ) {
    Shout( MakeFString( ShoutMsg1, _blank, _blank, _blank, _blank, _blank ) );
}

ShoutFStrNPC🟢 high

shout via NPC-string

A "shout" via NPC-string — Shout and MakeFString combined in one call, with shout radius.
Takes nNpcStringId (int) — the id of the localized string (the text for this id resides
in the chronicle's fstring.txt) — and up to five substitutions p1..p5 (string), no namespace.
Returns int.

Signature

ShoutFStr( int nNpcStringId, string pStr1, string pStr2, string pStr3, string pStr4, string pStr5 )

Parameters

nNpcStringId (int) — id of the localized string.
pStr1 (string) — first string substitution into the localized shout NPC-string (pass `_blank` when unused)
pStr2 (string) — second string substitution into the localized shout NPC-string (pass `_blank` when unused)
pStr3 (string) — third string substitution into the localized shout NPC-string (pass `_blank` when unused)
pStr4 (string) — fourth string substitution into the localized shout NPC-string (pass `_blank` when unused)
pStr5 (string) — fifth string substitution into the localized shout NPC-string (pass `_blank` when unused)

Example

ShoutFStr( 99601, "", "", "", "", "" );

Usage example

if ( msg_dying > 0 ) {
    ShoutFStr( msg_dying, _blank, _blank, _blank, _blank, _blank );
}

ShoutExNPC🟢 high

shout with a specified audibility radius

An extended shout variant with an explicit audibility radius. The text and radius are sent to the game
server via an opcode 100 packet; the handler (L2Server: NpcShout → CNPC::Shout_720900) uses
the second argument as the broadcast radius of the shout to nearby players (BroadcastToNeighborRect). The engine
caps the radius at 16384: if 0 or more than 16384 is passed, 16384 is used.
In the call = 1500. Returns nothing.

Signature

ShoutEx( string sText, int nRange )

Parameters

sText (string) — the NPC's shout text (often MakeFString(...)).
nRange (int) — audibility radius of the shout in world units (0 or >16384 → engine uses 16384; 1500 in the call).

Example

ShoutEx(MakeFString(1000380, "", "", "", "", ""), 1500);

Usage example

if ( ShoutMsg == 1 ) {
    ShoutEx( MakeFString( 1000457, _blank, _blank, _blank, _blank, _blank ), 11500 );
}

ShoutFStrExNPC🟢 high

shout via NPC-string with an extra numeric parameter

Same as ShoutEx (a "shout" in a bubble above the NPC that surrounding players see), except the text
is taken not as a ready-made string but by the id of a localized NPC-string, into which up to
five string pieces are substituted immediately. The first argument is the phrase id, followed by five
substitution slots (placeholders in the phrase template; unused slots are filled with _blank), and the last
argument is the audibility radius in game world units: the larger it is, the farther from the NPC
players will see the shout. The calls use 11500 (a shout over a large area around the arena) or 3000
(a close-range shout at a waypoint). The engine trims an overly large radius to the 16384 limit.
Returns nothing. Convenient when the phrase already resides in the localization table and you don't
want to assemble it manually via MakeFString.

Signature

ShoutFStrEx( int nNpcStringId, string pStr1, string pStr2, string pStr3, string pStr4, string pStr5, int nRectOffset )

Parameters

nNpcStringId (int) — id of the localized NPC-string the NPC will shout
pStr1 (string) — 1st substitution into the phrase template (pass `_blank` when unused)
pStr2 (string) — 2nd substitution (pass `_blank` when unused)
pStr3 (string) — 3rd substitution (pass `_blank` when unused)
pStr4 (string) — 4th substitution (pass `_blank` when unused)
pStr5 (string) — 5th substitution (pass `_blank` when unused)
nRectOffset (int) — audibility radius of the shout in world units: how far around the NPC
    players will see the phrase (11500 and 3000 in the calls; an overly large value is capped by the engine at 16384)

Example

ShoutFStrEx(1000457, _blank, _blank, _blank, _blank, _blank, 11500);

Usage example

if ( myself.i_ai1 >= myself.i_ai2 ) { // reached the end of the route
    ShoutFStrEx( 12000008, _blank, _blank, _blank, _blank, _blank, 3000 );
    RemoveAllDesire( );
    Despawn( );
    return;
}

GlobalAnnounceNPC🟢 high

announcement on behalf of the NPC

Makes an announcement on behalf of the NPC with a specified channel type and text — for important
notifications (events, sieges). Takes nAnnounceType (int) — the announcement type/channel
(table unconfirmed) — and sMessage (string), no namespace. Returns nothing
(void).

Signature

GlobalAnnounce( int nAnnounceType, string sAnnounceMessage )

Parameters

    nAnnounceType (int) — announcement type/channel (table unconfirmed).
    sAnnounceMessage (string) — announcement text.


Example (illustrative):

    GlobalAnnounce( nAnnounceType, "" );

Dialogs, menus, messages (Dialogs / Messages)

12 functions

ShowOnScreenMsgStrGLOBAL🟢 high

text at the center of the screen, with a ready string

Displays to the creature c large cutscene text at the center of the screen (not in chat), akin to BroadcastOnScreenMsg*, but addressed to a single c. The numeric arguments between c and the string set the position, effect type, display time, and fade; sText is the string itself.

Signature

    ShowOnScreenMsgStr( CSharedCreatureData cCreature, int nMsgPosType, int nParam1, int nFontSize, int nParam2, int nParam3, int nEffect, int nTime, int nFade, string sMsg )

Parameters (the same ExShowScreenMessage packet fields as in BroadcastOnScreenMsgStr, but without a radius —
addressed to a single creature; confirmed by the engine source, message type = 1 "arbitrary text"):
    cCreature   (CSharedCreatureData) — the creature shown the on-screen text.
    nMsgPosType (int) — the message position on the screen. 2 in calls.
    nParam1     (int) — a service packet field (unnamed in the engine). 0 in calls.
    nFontSize   (int) — font size. 0 in calls.
    nParam2     (int) — a service packet field (unnamed in the engine). 0 in calls.
    nParam3     (int) — a service packet field (unnamed in the engine). 0/1 in calls.
    nEffect     (int) — the text's visual appearance effect. 0/1 in calls.
    nTime       (int) — display duration, ms. 1000/3000/10000 in calls.
    nFade       (int) — fade effect. 0 in calls.
    sMsg        (string) — the text string to display.

Example

ShowOnScreenMsgStr( c3, 2, 0, 0, 0, 1, 0, 10000, 0, s0 );
ShowOnScreenMsgStr( myself.c_ai1, 2, 0, 0, 0, 1, 0, 1000, 0, " " );
ShowOnScreenMsgStr( attacker, 2, 0, 0, 0, 1, 0, 3000, 0, s0 );
ShowOnScreenMsgStr( talker, 2, 0, 0, 0, 1, 0, 3000, 0, "Exposure" );

Usage example

if ( IsNullCreature( c3 ) == 0 ) {
    ShowOnScreenMsgStr( c3, 2, 0, 0, 0, 1, 0, 10000, 0, s0 );
}

ShowOnScreenMsgFStrGLOBAL🟢 high

text at the center of the screen, by phrase id

The same as ShowOnScreenMsgStr, but the text is given by a phrase id with substitutions (p1..p5). The numeric arguments set the position, effect type, display time, and fade.

Signature

    ShowOnScreenMsgFStr( CSharedCreatureData cCreature, int nMsgPosType, int nParam1, int nFontSize, int nParam2, int nParam3, int nEffect, int nTime, int nFade, int nNpcStringId, string p1, string p2, string p3, string p4, string p5 )

Parameters (same fields as ShowOnScreenMsgStr, but the text is not a string — it is an
npcString phrase id with p1..p5 substitutions):
    cCreature    (CSharedCreatureData) — the creature shown the on-screen text.
    nMsgPosType  (int) — message position on screen. In calls 2/5.
    nParam1      (int) — service packet field (unnamed in the engine). In calls 0.
    nFontSize    (int) — font size. In calls 0.
    nParam2      (int) — service packet field. In calls 0.
    nParam3      (int) — service packet field. In calls 0/1.
    nEffect      (int) — text appearance effect. In calls 0/1.
    nTime        (int) — display duration, ms. In calls 4000/5000.
    nFade        (int) — fade-out effect. In calls 0.
    nNpcStringId (int) — phrase id (npcString) into which p1..p5 are substituted. In calls 36810804.
    p1..p5       (string) — phrase substitutions in order; unused ones pass _blank / "".

Example

ShowOnScreenMsgFStr(target, 5, 0, 0, 0, 1, 0, 5000, 0, 36810804, _blank, _blank, _blank, _blank, _blank);

Usage example

if ( myself.sm.param2 == 0 ) {
    ShowOnScreenMsgFStr( myself.c_ai0, 2, 0, 0, 0, 0, 1, 4000, 0, 1801149, "", "", "", "", "" );
}

AddChoiceNPC🟢 high

add a choice menu entry (as a text string)

Adds one entry to the NPC dialog choice menu: nCode — the code returned when the entry is chosen, pwsMsg — the entry text (usually MakeFString(fstringId, ...)). After collecting the entries, the menu is shown via ShowChoicePage.

Signature

AddChoice( int nCode, string pwsMsg )

Parameters

nCode (int) — code returned when this menu entry is chosen
pwsMsg (string) — menu entry text

Example

AddChoice( 0, MakeFString( 15501, _blank, _blank, _blank, _blank, _blank )  );

AddChoiceExNPC🟢 high

choice menu entry with a color

Same as AddChoice, plus a third argument nColor — the entry text color. nCode — entry code, the second argument — the text (a string, usually MakeFString).

Signature

AddChoiceEx( int nCode, string pwsMsg, int nColor )

Parameters

nCode (int) — code returned when this menu entry is chosen
pwsMsg (string) — menu entry text
nColor (int) — entry text color

Example

AddChoiceEx( 0, MakeFString( 23402, _blank, _blank, _blank, _blank, _blank ), @qcc_progress );

AddChoiceFStrExNPC🟢 high

choice menu entry by phrase id, with a color

Adds a menu entry whose text is given directly by phrase id nFstringId (without the MakeFString wrapper): nCode — entry code, nColor — color.

Signature

AddChoiceFStrEx( int nCode, int nFstringId, int nColor )

Parameters

nCode (int) — code returned when this menu entry is chosen
nFstringId (int) — id of the phrase providing the entry text
nColor (int) — entry text color

Example

AddChoiceFStrEx(0, 17001551, @QCCE_START);

ShowChoicePageNPC🟢 high

show the assembled choice menu

Displays to player cCreature the choice menu previously assembled (via AddChoice*). The second argument nOption is the menu mode/page number.

Signature

ShowChoicePage( CSharedCreatureData cCreature, int nOpton )

Parameters

cCreature (CSharedCreatureData) — player to whom the choice menu is shown
nOpton (int) — menu mode/page number

Example

ShowChoicePage( talker, 1 );
ShowChoicePage( talker, 0 );
ShowChoicePage(talker,0);

Usage example

if ( _choiceN > 1 ) {
    ShowChoicePage( talker, 1 );
    return;
}

ShowSystemMessageNPC🟢 high

system message by number

Shows creature c a system message (the yellow system chat line). nSysMsgNo — the message number from the client system message table.

Signature

ShowSystemMessage( CSharedCreatureData cCreature, int nSysMsgNo )

Parameters

cCreature (CSharedCreatureData) — creature shown the system message
nSysMsgNo (int) — system message number from the client table

Example

if (GetInventoryInfo(talker, @IPT_CURRENT_QUEST_SCOUNT) >= (GetInventoryInfo(talker, @IPT_MAX_QUEST_SCOUNT) * 0.9) || GetInventoryInfo(talker, @IPT_CURRENT_WEIGHT) >= (GetInventoryInfo(talker, @IPT_MAX_CARRY_WEIGHT) * 0.9) || GetInventoryInfo(talker, @IPT_CURRENT_SLOT_COUNT) >= (GetInventoryInfo(talker, @IPT_MAX_SLOT_COUNT) * 0.9)) { ShowSystemMessage(talker, 3262); return; }

Usage example

if ( GetInventoryInfo( talker, @IPT_CURRENT_SLOT_COUNT ) >= ( GetInventoryInfo( talker, @IPT_MAX_SLOT_COUNT ) * 0.800000 ) || GetInventoryInfo( talker, @IPT_CURRENT_WEIGHT ) >= ( GetInventoryInfo( talker, @IPT_MAX_CARRY_WEIGHT ) * 0.800000 ) ) {
    ShowSystemMessage( talker, 1118 );
    return;
}

ShowSystemMessage2NPC🟢 high

system message with substitutions

Shows creature c system message nSysMsgNo, substituting parameters into its template: nParamCount — the number of substitutions, followed by up to eight string values (p1..p8).

Signature

ShowSystemMessage2( CSharedCreatureData cCreature, int nSysMsgNo, int nParamCount, string pwsParam1, string pwsParam2, string pwsParam3, string pwsParam4, string pwsParam5, string pwsParam6, string pwsParam7, string pwsParam8 )

Parameters

cCreature (CSharedCreatureData) — creature shown the system message
nSysMsgNo (int) — system message number from the client table
nParamCount (int) — number of substituted parameters
pwsParam1 (string) — substitution 1 into the message template
pwsParam2 (string) — substitution 2 into the message template
pwsParam3 (string) — substitution 3 into the message template
pwsParam4 (string) — substitution 4 into the message template
pwsParam5 (string) — substitution 5 into the message template
pwsParam6 (string) — substitution 6 into the message template
pwsParam7 (string) — substitution 7 into the message template
pwsParam8 (string) — substitution 8 into the message template

Example

ShowSystemMessage2(talker, 8373, 1, _blank, _blank, _blank, _blank, _blank, _blank, _blank, _blank);

ShowSystemMessageStrNPC🟢 high

system message from a ready-made string

Displays to creature c an already prepared string sText as a system message (without a template from the client table).

Signature

ShowSystemMessageStr( CSharedCreatureData cCreature, string sText )

Parameters

cCreature (CSharedCreatureData) — creature shown the system message
sText     (string) — ready-made message text string

Example

ShowSystemMessageStr( talker, s0 );

Usage example

if (creature.is_pc) {
    ShowSystemMessageStr(creature, MakeFString(1800294, myself.c_ai2.name, "", "", "", ""));
}

ShowSystemMessageFStrNPC🟢 high

system message by phrase id with substitutions

Shows creature c system message nSysMsgNo, substituting up to five string values (p1..p5) into the phrase template.

Signature

ShowSystemMessageFStr( CSharedCreatureData cCreature, int nArg0, string pStr1, string pStr2, string pStr3, string pStr4, string pStr5 )

Parameters

cCreature (CSharedCreatureData) — creature shown the system message
nArg0 (int) — system message number from the client table
pStr1 (string) — substitution 1 into the message template
pStr2 (string) — substitution 2 into the message template
pStr3 (string) — substitution 3 into the message template
pStr4 (string) — substitution 4 into the message template
pStr5 (string) — substitution 5 into the message template

Example

ShowSystemMessageFStr(talker, 1800250, _blank, _blank, _blank, _blank, _blank);

WhisperNPC🟢 high

NPC whispers privately to a player (ready-made string)

The NPC whispers a private string sStr only to the addressee pTalker (unlike Say/Shout, which those nearby can hear).

Signature

Whisper( CSharedCreatureData pTalker, string sStr )

Parameters

pTalker (CSharedCreatureData) — addressee to whom the NPC whispers privately
sStr (string) — the whispered text string

Example

Whisper(creature, "status " + s0);

WhisperFStrNPC🟢 high

NPC whispers privately by NPC-string id

Same as Whisper, but the text is given by an NPC-string id (nNpcStringId) with substitutions (p1..p5); the addressee is c.

Signature

WhisperFStr( CSharedCreatureData cCreature, int nNpcStringId, string pStr1, string pStr2, string pStr3, string pStr4, string pStr5 )

Parameters

cCreature (CSharedCreatureData) — addressee to whom the NPC whispers privately
nNpcStringId (int) — NPC-string id providing the whisper text
pStr1 (string) — substitution 1 into the text template
pStr2 (string) — substitution 2 into the text template
pStr3 (string) — substitution 3 into the text template
pStr4 (string) — substitution 4 into the text template
pStr5 (string) — substitution 5 into the text template

Example

WhisperFStr( c0, 60018, _blank, _blank, _blank, _blank, _blank );

Usage example

if ( myself.i_ai1 == 2 ) {
    WhisperFStr( c0, 60020, _blank, _blank, _blank, _blank, _blank );
    SendScriptEvent( myself.sm, 45702, 0 );
}

DIALOG HTML WINDOWS (FHTML)

7 functions

ShowPageNPC🟢 high

show a ready html page

Shows the player a ready HTML page by the .htm file name without any
substitutions. Takes whom to show (usually talker) and the html file name; returns
nothing. The most frequent way to give an NPC's line or menu; the file name is often stored
in a variable.
Related event: the selection of an html-menu item arrives as the MENU_SELECTED(talker, ask, reply) event (see NASC_HANDLERS).

Signature

ShowPage( CSharedCreatureData cCreature, string pwsPage )

Parameters

cCreature (CSharedCreatureData) — whom to show (usually talker).
pwsPage (string) — the html file name.

Example

ShowPage( talker, fnHi );

Usage example

if ( talker.level >= 46 && talker.level < 52 ) {
    ShowPage( talker, "reflect_weapon_c.htm" );
}

FHTML_SetFileNameNPC🟢 high

set the window template

Sets the window buffer's html template, into which values will then be substituted. This is the
first step of building a dynamic window. Takes the window buffer (usually fhtml0) and the
html template name; returns nothing.

Signature

FHTML_SetFileName( CFHTML fhtml, string sFileName )

Parameters

fhtml     (CFHTML) — the window buffer (usually fhtml0).
sFileName (string) — the html template name.

Example

FHTML_SetFileName(fhtml0, s0 );

Usage example

if ( ask == -201 ) {
    FHTML_SetFileName( fhtml0, "map_agit_" + fnAgitMap + ".htm" );
    ShowFHTML( talker, fhtml0 );
}

FHTML_SetStrNPC🟢 high

substitute a string into the template

Substitutes a string value into the template in place of the placeholder with the given key.
Takes the window buffer, the placeholder name, and the substituted string; returns nothing.
Passing _blank clears the field — this is often used to hide a button or block.

Signature

FHTML_SetStr( CFHTML fhtml, string sKey, string sValue )

Parameters

fhtml  (CFHTML) — the window buffer.
sKey   (string) — the placeholder name.
sValue (string) — the substituted string.

Example

FHTML_SetStr( fhtml0, "HP" + "Reset", _blank );

Usage example

if ( IsNull( pledge0 ) == 0 ) {
    FHTML_SetStr( fhtml0, "pledge0", pledge0.name );
    FHTML_SetStr( fhtml0, "p_member_count0", IntToStr( i1 ) );
}

FHTML_SetIntNPC🟢 high

substitute an integer

Substitutes an integer value in place of the placeholder with the given key. Takes
the window buffer, the placeholder name, and the number; returns nothing. Used to display
prices, quantities, percentages, and tax rates.

Signature

FHTML_SetInt( CFHTML fhtml, string sKey, int64 nValue )

Parameters

fhtml  (CFHTML) — the window buffer.
sKey   (string) — the placeholder name.
nValue (int64) — the substituted integer value for the placeholder

Example

FHTML_SetInt( fhtml0, "quest_id", @black_swan );

Usage example

if ( Agit_GetDecoLevel( decotype_hpregen ) == 0 ) {
    FHTML_SetInt( fhtml0, "HPDepth", 0 );
} else {
    FHTML_SetInt( fhtml0, "HPDepth", ( Agit_GetDecoLevel( decotype_hpregen ) * 20 ) );
}

FHTML_SetFloatNPC🟢 high

substitute a fractional number

Substitutes a fractional value in place of the placeholder with the given key. Takes the window
buffer, the placeholder name, and the number; returns nothing. Applied in the same places as the
integer variant — for values with a fractional part.

Signature

FHTML_SetFloat( CFHTML fhtml, string sKey, float fValue )

Parameters

    fhtml  (CFHTML) — the dialog window buffer (`fhtml0`) into which the substitution goes
    sKey   (string) — the placeholder name in place of which the value is substituted
    fValue (float) — the substituted fractional value for the placeholder

Example (illustrative):

    FHTML_SetFloat( fhtml0, "", 0.0 );

FHTML_SetFStrNPC🟢 high

substitute a localized string with parameters

Substitutes in place of the placeholder a localized NPC-string by its identifier with
five string parameters — the same as building a string from an identifier and inserting
it, but in one call. Takes the window buffer, the placeholder name, the localized string id,
and five substitutions; returns nothing. For localized captions and buttons in the window.

Signature

FHTML_SetFStr( CFHTML pfhtml, string pStr1, int nArg1, string pStr2, string pStr3, string pStr4, string pStr5, string pStr6 )

Parameters

pfhtml (CFHTML) — the window buffer.
pStr1 (string) — the placeholder name.
nArg1 (int) — the localized string id.
pStr2 (string) — the first string substitution into the localized string
pStr3 (string) — the second string substitution into the localized string
pStr4 (string) — the third string substitution into the localized string
pStr5 (string) — the fourth string substitution into the localized string
pStr6 (string) — the fifth string substitution into the localized string

Example

FHTML_SetFStr( fhtml0, "QuizString", 1010635, "", "", "", "", "" );

Usage example

if (GetAbnormalLevel(talker, Skill_GetAbnormalType(buff1)) >= Skill_GetAbnormalLevel(buff1)) { FHTML_SetStr(fhtml0, "bypass_buff1", _blank); FHTML_SetFStr(fhtml0, "button_type1", 36810606, _blank, _blank, _blank, _blank, _blank); }
else { FHTML_SetStr(fhtml0, "bypass_buff1", "bypass -h menu_select?ask=-301&reply=1"); FHTML_SetFStr(fhtml0, "button_type1", 36810605, _blank, _blank, _blank, _blank, _blank); }

ShowFHTMLNPC🟢 high

show the assembled window

Shows the player the assembled window from the buffer — the final step of a dynamic window after
setting the template and a series of substitutions. Takes whom to show and the filled window buffer;
returns nothing.

Signature

ShowFHTML( CSharedCreatureData cCreature, CFHTML fhtml )

Parameters

cCreature (CSharedCreatureData) — whom to show.
fhtml     (CFHTML) — the filled window buffer.

Example

ShowFHTML( talker, fhtml0 );

Usage example

if ( i8 != 4 ) {
    ShowFHTML( talker, fhtml0 );
} else {
    ShowPage( talker, "master_lv3_hef_07.htm" );
}

EVENTS AND BROADCASTS (Events / Broadcast)

13 functions

SendScriptEventGLOBAL🟢 high

an addressed event to a specific creature

Sends a script event to a specific creature/NPC c by address, not
broadcast. Takes CSharedCreatureData c, int nEventId, and int nParam (without
namespace), returns an int (apparently, a delivery/handling flag). Used for
"master → its minions" communication.
Related event: the addressee catches SCRIPT_EVENT; SendMakerScriptEvent → maker ON_SCRIPT_EVENT (see NASC_HANDLERS).

Signature

SendScriptEvent( CSharedCreatureData cCreature, int nEventId, int nParam )

Parameters

cCreature (CSharedCreatureData) — the event addressee (in calls c0/c1/c4).
nEventId  (int) — the event code: a @SCE_* constant or an arbitrary number set by the script
                  (not a fixed enum; the addressee catches it in the SCRIPT_EVENT handler).
nParam    (int) — data (often a creature index from GetIndexFromCreature).

Example

SendScriptEvent( c1, @SCE_MPCC_ID, i0 );

Usage example

if ( myself.i_ai1 > 135 ) {
    SendScriptEvent( myself.c_ai2, 0, 0 );
}

SendScriptEventExGLOBAL🟢 high

an addressed event with two data fields

An addressed version of the event with two data fields for a specific creature. Takes
CSharedCreatureData c, int nEventId, int nParam2, and int nParam3 (without namespace),
returns an int.
Related event: the addressee catches SCRIPT_EVENT; SendMakerScriptEvent → maker ON_SCRIPT_EVENT (see NASC_HANDLERS).

Signature

SendScriptEventEx( CSharedCreatureData cCreature, int nEventId, int nParam2, int nParam3 )

Parameters

cCreature (CSharedCreatureData) — the receiving creature of the event
nEventId  (int) — the event code: @SCE_* or an arbitrary number (not a fixed enum)
nParam2   (int) — the first payload field of the event
nParam3   (int) — the second payload field of the event

Example

SendScriptEventEx(c0, @AI_MONSTER_ELITE_START, GetIndexFromCreature(myself.sm), 0);

SendMakerScriptEventGLOBAL🟢 high

an addressed event to a spawner

Sends an event with two data fields to a spawner (CNpcMakerEx), to control
spawn waves — for example, to start the next wave. Takes CNpcMakerEx maker,
int nEventId, int nParam2, and int nParam3 (without namespace), returns an int. For
territory wars there exists a related variety SendDominiSCRIPT_EVENT.

Signature

SendMakerScriptEvent( CNpcMakerEx maker, int nEventId, int nParam2, int nParam3 )

Parameters

maker    (CNpcMakerEx) — the receiving spawner of the event, controlling spawn waves
nEventId (int) — the event code: @SCE_* or an arbitrary number (not a fixed enum)
nParam2  (int) — the first payload field of the event
nParam3  (int) — the second payload field of the event

Example

SendMakerScriptEvent( maker0, 0, 0, 0 );

Usage example

if ( IsNull( maker0 ) == 0 ) {
    SendMakerScriptEvent( maker0, 1001, 0, 0 );
}

BroadcastOnScreenMsgFStrGLOBAL🟢 high

an on-screen message with a localized string

Displays large text right on the screen (not in chat, but over the picture) to all players
around the source. The text is taken by the number of a ready (localized) phrase nNpcStringId,
its substitution slots are filled with the strings sStr1..sStr5. Where exactly the caption appears
(nMsgPosType), how long it stays (nTime, ms), and with what appearance/fade effect —
is set by numeric parameters. Used for dramatic notifications: a boss's
appearance, an event phase change. Returns nothing.

Signature

BroadcastOnScreenMsgFStr( CSharedCreatureData c, int nRange, int nMsgPosType, int nParam1, int nFontSize, int nParam2, int nParam3, int nEffect, int nTime, int nFade, int nNpcStringId, string sStr1, string sStr2, string sStr3, string sStr4, string sStr5 )

Parameters

c (CSharedCreatureData) — the source creature; the circle whose players see the caption is measured around it
nRange (int) — visibility radius in game units: how far from the source the text is still shown (maximum 16384; 0 — minimal coverage right at the source)
nMsgPosType (int) — where on the screen to place the caption (a code designation of the screen zone; 1 and 2 in calls)
nParam1 (int) — a service output field (0 in calls)
nFontSize (int) — font size (0 — default size)
nParam2 (int) — a service output field (0 in calls)
nParam3 (int) — a service output field (0 in calls)
nEffect (int) — the caption's appearance effect (0 — no effect, 1 — with effect)
nTime (int) — how long to keep the caption on screen, milliseconds (3000 and 10000 in calls)
nFade (int) — smooth fade on disappearance (0 — off)
nNpcStringId (int) — the number of the ready (localized) phrase to show
sStr1 (string) — the first string substitution into the phrase (for example, the target's name)
sStr2 (string) — the second string substitution
sStr3 (string) — the third string substitution
sStr4 (string) — the fourth string substitution
sStr5 (string) — the fifth string substitution

Example

BroadcastOnScreenMsgFStr(myself.sm, 8000, 2, 0, 0, 0, 0, 1, 10000, 0, 1100223, "", "", "", "", "");

Usage example

if ( IsNullCreature( c3 ) == 0 ) {
    BroadcastOnScreenMsgFStr( myself.sm, 4000, 1, 0, 0, 0, 0, 0, 3000, 0, 1000519, c3.name, _blank, _blank, _blank, _blank );
}

BroadcastOnScreenMsgStrGLOBAL🟢 high

an on-screen message with an arbitrary string

Displays large text on the screen to players within a radius using an arbitrary string. The function is
a thin forwarder: the NPC server checks the radius and forwards the fields to the main server,
which builds the client packet ExShowScreenMessage. Position, font size, effect,
display time, and fade are set by numeric parameters (confirmed by the engine source).

Signature

    BroadcastOnScreenMsgStr( CSharedCreatureData cCreature, int nRange, int nMsgPosType, int nParam1, int nFontSize, int nParam2, int nParam3, int nEffect, int nTime, int nFade, string sMsg )

Parameters (confirmed by the engine source — the on-screen message handler builds the client
packet ExShowScreenMessage; the message type is fixed = 1 "arbitrary text"):
    cCreature   (CSharedCreatureData) — the source creature; its id is the recipient, and its position is the broadcast center.
    nRange      (int) — the broadcast radius; checked on the NPC server side (0..16384). 4000 in calls.
    nMsgPosType (int) — the message position on the screen. 2 in calls.
    nParam1     (int) — a service packet field (unnamed in the engine, nParam1). 0 in calls.
    nFontSize   (int) — font size. 0 in calls (default).
    nParam2     (int) — a service packet field (unnamed in the engine, nParam2). 0 in calls.
    nParam3     (int) — a service packet field (unnamed in the engine, nParam3). 0 in calls.
    nEffect     (int) — the text's visual appearance effect. 1 in calls.
    nTime       (int) — display duration on screen, ms. 3000 in calls.
    nFade       (int) — fade effect (smooth disappearance). 0 in calls.
    sMsg        (string) — the text to display.

Example

BroadcastOnScreenMsgStr( myself.sm, 4000, 2, 0, 0, 0, 0, 1, 3000, 0, MakeFString( 1000527, _blank, _blank, _blank, _blank, _blank ) );

BroadcastOnScreenNpcStringGLOBAL🟢 high

an on-screen message via an NPC-string

The same as BroadcastOnScreenMsgFStr: large text over the screen to all players around the
source, with the same layout of numeric fields (caption position, appearance effect, display
time, fade). The only difference is the text source — here the phrase is taken from the NPC's
string set by its number nNpcStringId, with substitutions sStr1..sStr5. Returns nothing.

Signature

BroadcastOnScreenNpcString( CSharedCreatureData c, int nRange, int nMsgPosType, int nParam1, int nFontSize, int nParam2, int nParam3, int nEffect, int nTime, int nFade, int nNpcStringId, string sStr1, string sStr2, string sStr3, string sStr4, string sStr5 )

Parameters

c (CSharedCreatureData) — the source creature; the circle whose players see the caption is measured around it
nRange (int) — visibility radius in game units: how far from the source the text is still shown (maximum 16384)
nMsgPosType (int) — where on the screen to place the caption (a code designation of the screen zone; 2 in calls)
nParam1 (int) — a service output field (0 in calls)
nFontSize (int) — font size (0 — default size)
nParam2 (int) — a service output field (0 in calls)
nParam3 (int) — a service output field (0 in calls)
nEffect (int) — the caption's appearance effect (0 — no effect, 1 — with effect)
nTime (int) — how long to keep the caption on screen, milliseconds (10000 in calls)
nFade (int) — smooth fade on disappearance (0 — off)
nNpcStringId (int) — the number of the NPC string to show
sStr1 (string) — the first string substitution into the phrase (for example, the player's name)
sStr2 (string) — the second string substitution
sStr3 (string) — the third string substitution
sStr4 (string) — the fourth string substitution
sStr5 (string) — the fifth string substitution

Example

BroadcastOnScreenNpcString( myself.sm, 16384, 2, 0, 0, 0, 0, 1, 10000, 0, 1100292, talker.name, _blank, _blank, _blank, _blank );

MakeAttackEventNPC🟢 high

trigger a combat reaction on a target

Initiates a combat reaction of the NPC to the creature c as if it had dealt damage dDamage:
adds hate and starts an attack. Takes CSharedCreatureData c, float
dDamage, and int nIsParty (no namespace), returns nothing; with nIsParty=1 the aggro
spreads to the target's whole party, with 0 — only to the target itself.

Signature

MakeAttackEvent( CSharedCreatureData cCreature, float dDamage, int nIsParty )

Parameters

cCreature (CSharedCreatureData) — the target of the combat reaction.
dDamage (float) — the weight of the "damage"/hate.
nIsParty (int) — 1 = to the target's whole party, 0 = only to the target.

Example

MakeAttackEvent(c1, 100, 0);

Usage example

if ( i0 == 1 ) {
    MakeAttackEvent( h0.creature, 100, 0 );
}

BroadcastScriptEventNPC🟢 high

a broadcast event within a radius

Broadcasts the script event nEventId with the data nParam to all NPCs within the radius nDist,
each recipient handles it in SCRIPT_EVENT. Takes int nEventId, int
nParam, and int nDist (no namespace), returns nothing. A classic — calling for
help: "I was attacked, the target is this index".
Related event: the addressees catch SCRIPT_EVENT(script_event_arg1..3) (see NASC_HANDLERS).

Signature

BroadcastScriptEvent( int nParam1, int nParam2, int nDist )

Parameters

nParam1 (int) — the event id (a script constant).
nParam2 (int) — the data (often GetIndexFromCreature(attacker)).
nDist (int) — the broadcast radius.

Example

BroadcastScriptEvent( @NAVIT_DESPAWN2, 0, 500 );

Usage example

if ( myself.top_desire_target == attacker ) {
    BroadcastScriptEvent( 10016, GetIndexFromCreature( attacker ), 300 );
}

BroadcastScriptEventExNPC🟢 high

a broadcast event with two data fields

An extended version of the broadcast event, carrying two data fields nParam2 and
nParam3. Takes int nEventId, int nParam2, int nParam3, and int nDist (no
namespace), returns nothing.
Related event: the addressees catch SCRIPT_EVENT(script_event_arg1..3) (see NASC_HANDLERS).

Signature

BroadcastScriptEventEx( int nParam1, int nParam2, int nParam3, int nDist )

Parameters

nParam1 (int) — the event id.
nParam2 (int) — data 1.
nParam3 (int) — data 2.
nDist (int) — the broadcast radius.

Example

BroadcastScriptEventEx(@SCE_PHASE_END, 1, 0, 4000);

Usage example

if ( i2 != NumberOfCircle ) {
    BroadcastScriptEventEx( i2, 30003, 0, 10000 );
}

BroadcastScriptEventCondNPC🟢 high

a broadcast event with a condition

The same extended broadcast with two data fields, additionally filtering
recipients by a condition (probably by the NPC's type/state); the exact meaning of the differences is not
confirmed. Takes int nEventId, int nParam2, int nParam3, and int nDist (no
namespace), returns nothing.
Related event: the addressees catch SCRIPT_EVENT(script_event_arg1..3) (see NASC_HANDLERS).

Signature

BroadcastScriptEventCond( int nParam1, int nParam2, int nParam3, int nDist )

Parameters

nParam1 (int) — the identifier of the broadcast event (the event code)
nParam2 (int) — the first payload field of the event
nParam3 (int) — the second payload field of the event
nDist (int) — the broadcast radius: the distance within which the event is received

Example

BroadcastScriptEventCond(@SCE_BELETH_DESPAWN, 0, 0, 4000);

BroadcastSystemMessageNPC🟢 high

a system message by id within a radius

Broadcasts a system message by the identifier nSysMsgId to players within the radius nDist
(a system-chat line). Takes CSharedCreatureData c, int nSysMsgId, and int
nDist (no namespace), returns an int.

Signature

BroadcastSystemMessage( CSharedCreatureData cCreature, int nSysMsgId, int nDist )

Parameters

cCreature (CSharedCreatureData) — the source creature relative to which the broadcast radius is determined
nSysMsgId (int) — the identifier of the system message to show
nDist     (int) — the broadcast radius: the distance (0..16384) within which the message is seen

Example

BroadcastSystemMessage(myself.sm, 0, 6503);

Usage example

if ( GetSSQSealOwner( 1 ) == 1 ) {
    BroadcastSystemMessage( myself.sm, 0, 1215 );
}

BroadcastSystemMessageStrNPC🟢 high

a system message with an arbitrary string

Shows a system message (a line in system chat) with the arbitrary text
sText to all players around the source. The message is seen by those within the
radius nDist from the source creature; beyond that circle the text does not arrive. The text is usually
prepared in advance — via MakeFString with substitutions — and passed as an already-assembled
string. Used for "across the whole courtyard" notifications: congratulations, announcements about the progress of an
event. Returns nothing.

Signature

BroadcastSystemMessageStr( CSharedCreatureData cCreature, int nDist, string sText )

Parameters

cCreature (CSharedCreatureData) — the source creature; the circle whose players receive the message is measured around it
nDist     (int) — the audibility radius in game units: how far from the source the message is still seen (maximum 16384; 0 — minimal coverage right at the source)
sText     (string) — the ready message text (an arbitrary string or the result of MakeFString)

Example

BroadcastSystemMessageStr(myself.sm, 8000, s0);
BroadcastSystemMessageStr(myself.sm, 0, "Wow! " + myself.master.name + " " + s1 + "!" );
BroadcastSystemMessageStr(myself.sm, 0, MakeFString(1900027, c0.name, "", "", "", ""));
BroadcastSystemMessageStr(myself.sm, 2000, MakeFString(1800881, "", "", "", "", ""));

Usage example

if (i0 <= i1) {
    BroadcastSystemMessageStr(myself.sm, range_to_yell, MakeFString(yell_congratz01, myself.c_ai0.name, "", "", "", ""));
    BroadcastOnScreenMsgStr(myself.sm, range_to_yell, 5, 0, 1, 3, 1, 1, 5000, 0, MakeFString(yell_congratz01, myself.c_ai0.name, "", "", "", ""));
} else {
    BroadcastSystemMessageStr(myself.sm, range_to_yell, MakeFString(yell_congratz02, myself.c_ai0.name, "", "", "", ""));
    BroadcastOnScreenMsgStr(myself.sm, range_to_yell, 5, 0, 1, 3, 1, 1, 5000, 0, MakeFString(yell_congratz02, myself.c_ai0.name, "", "", "", ""));
}

BroadcastSystemMessageFStrNPC🟢 high

a localized system message with parameters

The same as BroadcastSystemMessageStr, but the text is taken not as an arbitrary string, but by the
number of a ready (already translated) phrase nNpcStringId. This phrase has slots for
substitutions — they are filled with the strings pStr1..pStr5 (the target's name, a number, etc.); the extra
ones are left empty. The message is shown as a system line to all players within the
radius nDist from the source. Returns nothing.

Signature

BroadcastSystemMessageFStr( CSharedCreatureData cCreature, int nDist, int nNpcStringId, string pStr1, string pStr2, string pStr3, string pStr4, string pStr5 )

Parameters

cCreature (CSharedCreatureData) — the source creature; the circle whose players receive the message is measured around it
nDist (int) — the audibility radius in game units: how far from the source the message is still seen (maximum 16384)
nNpcStringId (int) — the number of the ready (localized) phrase to show
pStr1 (string) — the first string substitution into the template (in place of [p1])
pStr2 (string) — the second string substitution (in place of [p2])
pStr3 (string) — the third string substitution (in place of [p3])
pStr4 (string) — the fourth string substitution (in place of [p4])
pStr5 (string) — the fifth string substitution (in place of [p5])

Example

BroadcastSystemMessageFStr(myself.sm, 1500, Message_ID, "", "", "", "", "");
BroadcastSystemMessageFStr(myself.sm, 1500, 1100153, "", "", "", "", "");
BroadcastSystemMessageFStr(myself.sm, 1500, 1100139, "", "", "", "", "");
BroadcastSystemMessageFStr(myself.sm, 1500, i4, target.name, IntToStr(i5), "", "", "");

Usage example

if ( NeedShoutSA ) {
    BroadcastSystemMessageFStr( myself.sm, 2500, i4, target.name, IntToStr( i5 ), _blank, _blank, _blank );
}

PARTIES AND CLANS (Party / Pledge)

24 functions

GetPartyGLOBAL🟢 high

a creature's party object

Returns the party object in which the creature c is a member, or empty/null
if the creature is not in a party (checked via IsNullParty). Takes a creature
CSharedCreatureData; a function of the global object gg. Returns a CSharedPartyData.

Signature

GetParty( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — whose party we get.

Example

party0 = GetParty( c3 );

Usage example

party0 = GetParty( target );
if ( IsNullParty( party0 ) ) {
    return;
} else {
    TeleportParty( party0.id, SibylPosX, SibylPosY, SibylPosZ, 300, ( part_type * RoomIndex ) );
}

Party_GetCountGLOBAL🟢 high

the number of party members

Returns the number of members in the creature c's party; this is the basis for iterating a party in a loop. If
the creature is not in a party — usually 0 or 1. Takes a creature CSharedCreatureData;
a function of the global object gg. Returns an integer.

Signature

Party_GetCount( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — whose party.

Example

i1 = Party_GetCount( c1 );

Party_GetCreatureGLOBAL🟢 high

a party member by index

Returns a member of the creature c's party by index nIndex (zero-based). Together with
Party_GetCount it gives an iteration over all party mates — for example, to give a reward or a buff
to the whole party. Takes a creature CSharedCreatureData and an integer index
(0..count-1); a function of the global object gg. Returns a CSharedCreatureData.

Signature

Party_GetCreature( CSharedCreatureData cCreature, int nIndex )

Parameters

cCreature (CSharedCreatureData) — whose party.
nIndex    (int) — the member index (0..count-1).

Example

c0 = Party_GetCreature( c1, i0 );

Usage example

c1 = Party_GetCreature( talker, i2 );
if ( OwnItemCount( c1, @q_antique_brooch ) == 0 ) {
    GiveItem1( c1, @q_used_adm_to_grave, 1 );
}

Party_GetLeaderGLOBAL🟢 high

a party's leader by creature

Returns the leader of the party in which the creature c is a member. Convenient when you have a
player at hand. Takes a creature CSharedCreatureData; a function of the global object gg.
Returns a CSharedCreatureData.

Signature

Party_GetLeader( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature by whose party the leader is searched

Example

c0 = Party_GetLeader( c0 );
c0 = Party_GetLeader( talker );
c1 = Party_GetLeader(talker);

Usage example

if ( Party_GetLeader( talker ) != talker ) {
    ShowPage( talker, "ssq_main_event_sibyl_q0505_04.htm" );
} else {
    ShowPage( talker, "ssq_main_event_sibyl_q0505_01.htm" );
}

GetTopDamageCreatureGLOBAL🟢 high

the damage champion (creature)

Returns the single creature that dealt the creature c (usually a raid boss) the greatest
total damage. Applied on a boss's death to distribute the reward to whoever fought
hardest. Takes a creature CSharedCreatureData; a function of the global object
gg. Returns a CSharedCreatureData.

Signature

GetTopDamageCreature( CSharedCreatureData c )

Parameters

    c (CSharedCreatureData) — the creature (usually a raid boss) for which the top-damage dealer is searched

Example (illustrative):

    GetTopDamageCreature( talker );

GetTopDamagePartyGLOBAL🟢 high

the party with the greatest damage

Returns the party that dealt the creature c the greatest total damage. The
aggregation level of the damage is a single party; used when distributing the reward for a boss fight.
Takes a creature CSharedCreatureData; a function of the global object gg. Returns a
CSharedPartyData.

Signature

GetTopDamageParty( CSharedCreatureData c )

Parameters

    c (CSharedCreatureData) — the creature by whose damage the party that damaged it most is determined

Example (illustrative):

    GetTopDamageParty( talker );

GetTopDamageMpccGLOBAL🟢 high

the command channel with the greatest damage

Returns the command channel (MPCC — a union of several parties) that dealt the creature c
the greatest total damage. The senior level of damage aggregation when distributing the reward for a
raid-boss fight. Takes a creature CSharedCreatureData; a function of the global object gg.
Returns a CSharedGeneralObjectData.

Signature

GetTopDamageMpcc( CSharedCreatureData c )

Parameters

    c (CSharedCreatureData) — the creature by whose damage the command channel (MPCC) that damaged it most is determined


Example (illustrative):

    GetTopDamageMpcc( talker );

GetLeaderOfPartyNPC🟢 high

a party's leader by the party object

Returns a party's leader by the party object p itself. Applied when you only have a
CSharedPartyData — for example, one obtained from GetTopDamageParty. Takes a party object
CSharedPartyData; an NPC function (myself). Returns a CSharedCreatureData.

Signature

GetLeaderOfParty( CSharedPartyData p )

Parameters

p (CSharedPartyData) — the party object whose leader is taken.

Example

c0 = GetLeaderOfParty(lparty);

Usage example

c1 = GetLeaderOfParty( party0 );
if ( IsNullCreature( c1 ) == 0 ) {
    Shout( MakeFString( 1010634, c1.name, IntToStr( i2 ), "", "", "" ) );
}

Party_GetMemberNPC🟢 high

a party member by numeric identifiers

Returns a party member by numeric identifiers. Per the L2NPC decompile
(CNPC::Party_GetMember_4A79A8) the first argument is the party id (its low 20 bits
index the party array), the second is the member index, limited by the engine to the range 0..9.
It then calls the same code as GetMemberOfParty. An NPC function (myself). Returns a
CSharedCreatureData.

Signature

Party_GetMember( int nPartyId, int nIndex )

Parameters

nPartyId (int) — the party id (party0.id; in calls also myself.i_quest0 with a saved id).
nIndex (int) — the member index in the party, 0..9.

Example

c0 = Party_GetMember(i2, i9);

Usage example

c3 = Party_GetMember( myself.i_quest0, i8 );
if ( IsNullCreature( c3 ) == 0 ) {
    ShowOnScreenMsgStr( c3, 2, 0, 0, 0, 1, 0, 10000, 0, s0 );
}

GetMemberOfPartyNPC🟢 high

a party member by the party object and index

Returns a member of the party p by index nIndex. Applied when you only have a party
object CSharedPartyData. Takes a party object CSharedPartyData and an integer index;
an NPC function (myself). Returns a CSharedCreatureData.

Signature

GetMemberOfParty( CSharedPartyData p, int nIndex )

Parameters

p (CSharedPartyData) — the party object from which the member is taken.
nIndex (int) — the member index in the party.

Example

c3 = GetMemberOfParty( party0, i8 );

Usage example

target = GetMemberOfParty( lparty, i9 );
if ( HaveMemo( target, @relics_of_the_old_empire ) == 1 ) {
    random1_list.SetInfo( 0, target );
}

IsMemberOfPartyNPC🟢 high

check party membership

Checks whether the creature c is a member of the party p (returns 1 or 0). Serves for
the "friend/foe" logic in group scenes. Takes a creature CSharedCreatureData and a party
object CSharedPartyData; an NPC function (myself). Returns an integer.

Signature

IsMemberOfParty( CSharedCreatureData c, CSharedPartyData p )

Parameters

    c (CSharedCreatureData) — whom we check.
    p (CSharedPartyData) — in which party.

Example (illustrative):

    IsMemberOfParty( talker, party0 );

GetPledgeNPC🟢 high

a creature's clan object

Returns the clan (pledge) object in which the creature c is a member. This is the starting point
of all clan operations — the treasury, ranks, war registration. Takes a creature
CSharedCreatureData; an NPC function (myself). Returns a CSharedPledgeData.

Signature

GetPledge( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — whose clan.

Example

pledge0 = GetPledge(talker);

Usage example

pledge0 = GetPledge( last_attacker );
if ( IsNull( pledge0 ) == 1 ) { return; }

HavePledgePowerNPC🟢 high

check a clan privilege

Checks whether the player c has the clan privilege nPledgePower (returns 1 or
0). Privileges are given by @-constants (@ppSetGate, @PP_OPEN_CASTLE_DOOR,
@ppRegisterWar, @PP_USE_AGIT_FUNC, etc.). This is how castle and clan NPCs decide
whether the player is entitled to open a door, register a war, manage a clan hall. Takes
a creature CSharedCreatureData and an integer privilege code; an NPC function (myself).
Returns an integer.

Signature

HavePledgePower( CSharedCreatureData c, int nPledgePower )

Parameters

c (CSharedCreatureData) — the player.
nPledgePower (int) — the code of the clan privilege being checked (manual_pch; the current numbering):
    1 @PP_JOIN clan recruitment, 2 @PP_GIVE_NICKNAME/@ppGiveTitle title, 3 @PP_VIEW_WAREHOUSE warehouse,
    4 @PP_MANAGE_GRADE ranks, 5 @PP_DECLARE_WAR war, 6 @PP_OUST_MEMBER expulsion,
    7 @PP_SET_CREST crest, 8 @PP_MANAGE_MASTER unit leaders, 9 @PP_MANAGE_GROWTH/@ppSubPledgeMaster,
    10 @PP_SUMMON_AIRSHIP, 11 @PP_OPEN_AGIT_DOOR/@ppGateOpen clan hall doors, 12 @PP_USE_AGIT_FUNC/@ppDecoFunction,
    13 @PP_AGIT_AUCTION clan hall auction, 14 @PP_OUST_FROM_AGIT/@ppClanHallBanish, 15 @PP_CONTROL_AGIT_FUNC/@ppManage,
    16 @PP_OPEN_CASTLE_DOOR/@ppSetGate castle doors, 17 @PP_MANAGE_MANOR/@ppManor manor,
    18 @PP_REGISTER_CASTLE_WAR/@ppSiege siege, 19 @PP_USE_CASTLE_FUNC/@ppCastleShop, 20 @PP_OUST_FROM_CASTLE/@ppBanish,
    21 @PP_MANAGE_TAX/@ppTaxVault tax/treasury, 22 @PP_MANAGE_MERCENARY mercenaries, 23 @PP_CONTROL_CASTLE_FUNC/@ppSiegeDefend,
    24 @PP_USE_THRONE_OF_HERO throne. The numbers are shifted in early chronicles (see manual_pch, the "IL" labels).

Example

if (HavePledgePower(talker, @ppDecoFunction) && Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0)

Usage example

if ( IsMyLord( talker ) || ( HavePledgePower( talker, @ppGateOpen ) && Castle_GetPledgeId( ) == talker.pledge_id && talker.pledge_id != 0 ) ) {
    ShowPage( talker, fnDoor );
} else {
    ShowPage( talker, fnNoAuthority );
}

GetPledgeMemberCountNPC🟢 high

the number of clan members

Returns the number of members of the clan in which the creature c is a member. Used in clan
dialogs and conditions. Takes a creature CSharedCreatureData; an NPC function (myself).
Returns an integer.

Signature

GetPledgeMemberCount( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature by whose clan the member count is calculated

Example

i0 = GetPledgeMemberCount(talker);

Usage example

if ( GetPledgeMemberCount(talker) >= 40 ) { // orig >= 140
    UpdatePledgeNameValue( talker, -100000 );
    DeleteItem1( talker, item_lvup10 , num_item_lvup10 );
    PledgeLevelUp( talker, 10 );
    AddUseSkillDesire(talker, EffectSkill1, @ST_HEAL, @AMT_STAND, 1000000);
    ShowPage( talker, "pl_err_total_member.htm" );
}

GetPledgeMoneyNPC🟢 high

the clan treasury

In meaning it returns the adena of the creature c's clan treasury. IMPORTANT: in the NPC build the function is actually a STUB — under any circumstances it returns 0 (no clan — 0; there is a clan —
still 0, the money field is not read). The real treasury amount is known only to the server side
(L2Server), so in NPC AI scripts this result cannot be relied upon. The units are adena
(a 32-bit integer). Takes a creature CSharedCreatureData; an NPC function (myself).

Signature

GetPledgeMoney( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the creature by whose clan the treasury (clan money) is taken

Example (illustrative):

    GetPledgeMoney( talker );

Pledge_GetCountNPC🟢 high

the clan counter

Returns the clan counter of the creature c (a basic clan datum). Used in
clan dialogs and conditions. Takes a creature CSharedCreatureData; an NPC function
(myself). Returns an integer.

Signature

Pledge_GetCount( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the creature by whose clan the counter is taken

Example (illustrative):

    Pledge_GetCount( talker );

Pledge_GetLeaderNPC🟢 high

the clan leader

Returns the leader of the clan in which the creature c is a member. Used in clan
dialogs and conditions. Takes a creature CSharedCreatureData; an NPC function (myself).
Returns a CSharedCreatureData.

Signature

Pledge_GetLeader( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature by whose clan the clan leader is searched

Example

c2 = Pledge_GetLeader( c1 );

Usage example

c2 = Pledge_GetLeader( c1 );
if ( IsNullCreature( c2 ) == 0 ) {
    if ( HaveMemo( c2, @pursuit_of_clan_ambition ) == 1 && GetMemoState( c2, @pursuit_of_clan_ambition ) < 8511 && GetMemoState( c2, @pursuit_of_clan_ambition ) >= 8500 && DistFromMe( c2 ) <= 1500 ) {
        CreateOnePrivate( @imperial_coffer, "imperial_coffer", 0, 1 );
    }
}

HasSubPledgeNPC🟢 high

presence of a clan sub-unit

Checks whether the creature c's clan has a sub-unit of type nType (knights, academy,
royal guard). Returns 1 if such a sub-unit is created, otherwise 0. Per decompile it takes the creature's
clan (no clan — 0), converts the type into an internal index (0..7), and checks the corresponding
bit in the mask of the clan's existing sub-units — that is, up to eight sub-unit types. The exact
"type → index" table lies in the engine data. Takes a creature CSharedCreatureData and
an integer unit type.

Signature

HasSubPledge( CSharedCreatureData c, int nType )

Parameters

c (CSharedCreatureData) — the creature by whose clan the presence of a sub-unit is checked.
nType (int) — the sub-unit type (enum PledgeType, from manual_pch):
    -1 @ACADEMY academy, 100 @ROYAL_GUARD_1, 200 @ROYAL_GUARD_2,
    1001 knight 1, 1002 knight 2, 2001 knight 3, 2002 knight 4.

Example

if (HasSubPledge(talker, @ROYAL_GUARD_1) == @TRUE)

Usage example

if (HasSubPledge(talker, i0) == 1) {
    ShowPage(talker, "pl_err_fame.htm");
    return;
}

MPCC_GetPartyIDNPC🟢 high

the party ID in an MPCC by index

By the key mpcc_id and the ordinal index party_index returns the party ID in a multi-party command channel. Called on an NPC object.

Signature

MPCC_GetPartyID( int nMpccId, int nPartyIndex )

Parameters

nMpccId (int) — the command channel identifier (mpcc_id).
nPartyIndex (int) — the ordinal index of the party in the channel.

Example

i1 = MPCC_GetPartyID( i0, 0 );

MPCC_GetMPCCIdNPC🟢 high

the ID of the channel the player is in

Returns the ID of the command channel the creature is in. Called on an NPC object.

Signature

MPCC_GetMPCCId( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature whose command channel is requested

Example

i0 = MPCC_GetMPCCId( talker );

Usage example

i3 = MPCC_GetMPCCId( talker );
if ( i3 > 0 ) {
    i4 = MPCC_GetMemberCount( i3 );
    if ( i4 >= 55 ) {
        SendScriptEvent( c0, 99999999, i3 );
    }
}

MPCC_SetMasterPartyRoutingNPC🟢 high

assign the master party

Enables or resets the master-party routing of a command channel. Per the L2NPC decompile it
sends the server a packet opcode 124; the handler (L2Server: NpcSetMPCCMasterPartyRouting_731E6C)
chooses the action by the flag: 1 — set master-party routing (SetMasterPartyRouting),
0 — reset it (ResetMasterPartyRouting, if this channel was the routing one). No return.

Signature

MPCC_SetMasterPartyRouting( int nMpccId, CSharedCreatureData cMaster, int nOnOff )

Parameters

nMpccId (int) — the command channel identifier (mpcc_id).
cMaster (CSharedCreatureData) — the creature — the master party's leader.
nOnOff (int) — 1 = set master-party routing; 0 = reset the routing.

Example

MPCC_SetMasterPartyRouting( script_event_arg2, myself.sm, 1 );

Usage example

if ( c0.db_value == 0 ) {
    MPCC_SetMasterPartyRouting( myself.i_ai1, c0, 0 );
    SendScriptEvent( c0, @SCE_ANTARAS_PC_ENTERED, 0 );
}

MPCC_GetMasterNPC🟢 high

the channel's master party leader

By the key mpcc_id returns the creature — the leader of the command channel's master party. Called on an NPC object.

Signature

MPCC_GetMaster( int nMpccId )

Parameters

nMpccId (int) — the command channel identifier (mpcc_id).

Example

c0 = MPCC_GetMaster( i0 );
c1 = MPCC_GetMaster( i9 );
c1 = MPCC_GetMaster( i1 );
c3 = MPCC_GetMaster( i3 );

Usage example

c0 = MPCC_GetMaster( i0 );
if ( IsNullCreature( c0 ) ) { c0 = target; } // if the player somehow dropped out of the CC and the leader is not found

MPCC_GetMemberCountNPC🟢 high

the number of members in the channel

By the key mpcc_id returns the total number of members in the command channel.

Signature

MPCC_GetMemberCount( int nMpccId )

Parameters

nMpccId (int) — the command channel identifier (mpcc_id).

Example

i4 = MPCC_GetMemberCount( i3 );
i2 = MPCC_GetMemberCount(i1);

Usage example

i4 = MPCC_GetMemberCount( i3 );
if ( i4 >= 55 ) {
    SendScriptEvent( c0, 99999999, i3 );
}

MPCC_GetPartyCountNPC🟢 high

the number of parties in the channel

By the key mpcc_id returns the number of parties in the command channel. Called on an NPC object.

Signature

MPCC_GetPartyCount( int nMpccId )

Parameters

nMpccId (int) — the command channel identifier (mpcc_id).

Example

i7 = MPCC_GetPartyCount( i0 );

Usage example

i1 = MPCC_GetPartyCount( i0 );
if ( i1 < 7 ) {
    ShowPage( talker, "zaken_enter001d.htm" );
}

Academy

6 functions

IsAcademyMemberNPC🟢 high

is a member of the academy

Returns whether the player cCreature is a member of the clan academy as a student (1/0, compared with @TRUE), namespace CNPC.

Signature

IsAcademyMember( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose membership in the clan academy is checked

Example

if (_from_choice == 0 || (HaveMemo(talker, @one_who_leads_one_who_is_led) == @FALSE && HaveMemo(talker, @one_who_leads_one_who_is_led_2) == @FALSE && talker.level >= 19 && IsAcademyMember(talker) == @TRUE && HasAcademyMaster(talker) == @TRUE && GetOneTimeQuestFlag(talker, @one_who_leads_one_who_is_led_2) == @FALSE && GetOneTimeQuestFlag(talker, @one_who_leads_one_who_is_led) == @FALSE))

Usage example

if( IsAcademyMember( talker ) == 1 ) {
    GiveItem1( talker, @academy_circlet ,1 );
    ShowSystemMessage( talker,1749 );
}

HasAcademyMasterNPC🟢 high

is there a mentor

Returns whether the player cCreature has a mentor in the academy (1/0), namespace CNPC.

Signature

HasAcademyMaster( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose presence of an academy mentor is checked

Example

if ( HaveMemo( talker, @to_lead_and_be_led ) == 0 && HaveMemo( talker, @one_who_leads_one_who_is_led_2 ) == 0 && talker.level >= 19 && IsAcademyMember( talker ) == 1 && HasAcademyMaster( talker ) == 1 && GetOneTimeQuestFlag( talker, @to_lead_and_be_led ) == 0 && GetOneTimeQuestFlag( talker, @one_who_leads_one_who_is_led_2 ) == 0 ) {

Usage example

if ( _from_choice == 0 || ( ( ( HaveMemo( talker, @to_lead_and_be_led ) == 0 && HaveMemo( talker, @one_who_leads_one_who_is_led_2 ) == 0 && ( talker.level < 19 || IsAcademyMember( talker ) == 0 || HasAcademyMaster( talker ) == 0 ) ) && GetOneTimeQuestFlag( talker, @one_who_leads_one_who_is_led_2 ) == 0 ) && GetOneTimeQuestFlag( talker, @to_lead_and_be_led ) == 0 ) ) {
    SetCurrentQuestID( @one_who_leads_one_who_is_led_2 );
    ShowQuestPage( talker, "head_blacksmith_newyear_q0123_02.htm", @one_who_leads_one_who_is_led_2 );
}

GetAcademyMasterNPC🟢 high

get the mentor

Returns the player cCreature's mentor in the academy (a creature), namespace CNPC.

Signature

GetAcademyMaster( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose academy mentor is to be obtained

Example

c0 = GetAcademyMaster( talker );
c0 = GetAcademyMaster( target );

HasAcademyMemberNPC🟢 high

is there a student

Returns whether the player cCreature has a student in the academy (1/0, compared with @TRUE), namespace CNPC.

Signature

HasAcademyMember( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) whose presence of an academy student is checked

Example

if (_from_choice == 0 || HasAcademyMember(talker) == @TRUE)

Usage example

if ( HasAcademyMember( talker ) == 1 ) {
    _choiceN = ( _choiceN + 1 );
    _code = 15;
    AddChoice( 15, MakeFString( 11804, _blank, _blank, _blank, _blank, _blank ) );   // To Lead And Be Led (Sponsor)
}

GetAcademyMemberNPC🟢 high

get the student

Returns the player cCreature's student in the academy (a creature), namespace CNPC.

Signature

GetAcademyMember( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) whose academy student is returned

Example

c0 = GetAcademyMember( talker );

HasAcademyNPC🟢 high

presence of an academy

Returns whether the player cCreature has an academy (1/0, compared with @TRUE), namespace CNPC. The exact difference from HasAcademyMaster/HasAcademyMember is not fully confirmed.

Signature

HasAcademy( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) whose presence of an academy is checked

Example

if ( HasAcademy( talker) == @TRUE ) {

Usage example

if ( HasAcademy( talker) == 1 ) {
    ShowPage( talker, "pl_err_aca.htm" );
} else {
    ShowPage( talker, "pl_err_aca.htm" );
}

Player: name & status (Player)

10 functions

GetCountryGLOBAL🟢 high

the player's country/region

Returns the numeric country/region code of the player cCreature (int), namespace gg. Used for localization (choosing the right .htm or text).

Signature

GetCountry( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player for whom the country/region code is returned

Example

if (GetCountry(talker) == 2) { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-ua.htm"); }

Usage example

if (GetCountry(talker) == 2) { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-ua.htm"); }
else if (GetCountry(talker) == 4) { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-cn.htm"); }
else if (GetCountry(talker) == 8) { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-ru.htm"); }
else { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-eu.htm"); }

ChangeNickNameNPC🟢 high

change the title

Changes the creature cCreature's title — the string above its head — to sName, namespace CNPC.

Signature

ChangeNickName( CSharedCreatureData pCreatureShared, string sName )

Parameters

pCreatureShared (CSharedCreatureData) — the creature whose title above its head is changed
sName (string) — the new title text

Example

case 1:  { ChangeNickName(myself.sm, LocationName_01); break; }

ChangeMasterNameNPC🟢 high

change the second name line

Changes the "second line" / owner name of the creature cCreature to sName, namespace CNPC.

Signature

ChangeMasterName( CSharedCreatureData pCreatureShared, string sName )

Parameters

pCreatureShared (CSharedCreatureData) — the creature whose owner name (the second line) is changed
sName (string) — the new owner name text

Example

ChangeMasterName(myself.sm, "DEAD * RESPAWN IN " + IntToStr(myself.i_ai3) + " MIN");

ChangeFStrNickNameNPC🟢 high

title via FString

Changes the creature cCreature's title to localizable text by the phrase id nFStringId with the parameter sParam, namespace CNPC.

Signature

ChangeFStrNickName( CSharedCreatureData cCreature, int nArg1, string pStr1 )

Parameters

cCreature (CSharedCreatureData) — the creature whose title is changed
nArg1 (int) — the id of the localizable phrase for the title (`nFStringId`)
pStr1 (string) — the substitution parameter into the phrase (`sParam`)

Example

ChangeFStrNickName(myself.sm, 1801100, IntToFStr(i1));

Usage example

if ( i0 >= 60008 && i0 <= 60011 ) {
    ChangeFStrNickName( myself.sm, i0, "" );
}

ChangeFStrMasterNameNPC🟢 high

the second line via FString

Changes the creature cCreature's name "second line" to localizable text by the phrase id nFStringId with the parameter sParam, namespace CNPC.

Signature

ChangeFStrMasterName( CSharedCreatureData cCreature, int nArg1, string pStr1 )

Parameters

cCreature (CSharedCreatureData) — the creature whose name second line is changed
nArg1 (int) — the id of the localizable phrase for the second line (`nFStringId`)
pStr1 (string) — the substitution parameter into the phrase (`sParam`)

Example

ChangeFStrMasterName(myself.sm, 1100159, _blank);

IsNewbieNPC🟢 high

is the player a newbie

Returns whether the player cCreature is considered a newbie (1/0), namespace CNPC.

Signature

IsNewbie( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) checked for newbie status

Example

if ( IsNewbie( talker ) ) {

Usage example

if ( talker.level < 25 && IsNewbie( talker ) && IsInCategory( @fighter_group, talker.occupation ) ) {
    GiveItem1( talker, @soulshot_none_for_rookie, 7000 );
    VoiceEffect( talker, "tutorial_voice_026", 1000 );
}

SetNoblessNPC🟢 high

grant noblesse status

Assigns the player cCreature noblesse status, namespace CNPC.

Signature

SetNobless( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) assigned noblesse status

Example

SetNobless( talker );

SetHeroNPC🟢 high

grant hero status

Assigns the player cCreature hero status, namespace CNPC.

Signature

SetHero( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) assigned hero status

Example

SetHero( talker );

Usage example

    if ( talker.hero_type == 1 ) {
        SetHero( talker );
    }

Related event: the server's response arrives as the SET_HERO_RETURNED event (see NASC_HANDLERS).

GetHwidNPC🟢 high

the player's HWID

Returns the HWID — a string identifier of the player cCreature's hardware (string), namespace CNPC. There are few calls, the string format is weakly confirmed.

Signature

GetHwid( CSharedCreatureData c )

Parameters

c (CSharedCreatureData) — the player (`cCreature`) whose HWID is returned

Example

if(IsSameString(myself.str_list.Get(i0), GetHwid(talker)))

Usage example

if(IsSameString(myself.str_list.Get(i0), GetHwid(talker)))
{
    ShowPage(talker, "atb_event_hw_portal_03.htm");
    return;
}

ShowChangePledgeNameUINPC🟢 high

the clan name change window

Opens for the player cCreature the clan name change window, namespace CNPC.

Signature

ShowChangePledgeNameUI( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) for whom the clan name change window is opened

Example

ShowChangePledgeNameUI( talker );

Usage example

if ( talker.is_pledge_master == 1 ) {
    ShowChangePledgeNameUI( talker );
} else {
    ShowPage( talker, "pl_err_master.htm" );
}

Pets & summons (Pets)

7 functions

GetSummonNPC🟢 high

get a player's summon/pet

Returns the summon or pet summoned by the creature cCreature (of type CSharedCreatureData), namespace CNPC. If there is no summoned one, the result may be empty — it is checked via IsNull*. Used before operations with a pet/summon.

Signature

GetSummon( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose summon/pet is returned

Example

c0 = GetSummon(talker);

Usage example

c0 = GetSummon(talker);
if (IsNullCreature(c0) == 0 && skip_chk_summon_pet1 == 1) {
    ShowPage(talker, fnEvolutionStopped);
    return;
}

EvolvePetNPC🟢 high

pet evolution (hatchling into adult)

Turns the player cCreature's pet from a hatchling into an adult form, namespace CNPC. Arguments: nPetDbId — the pet's id in the database, nBabyClassId — the hatchling's class, nEvolveItemId — the evolution item, nGrownClassId — the adult's class, nPetLevel — the pet's level.

Signature

EvolvePet( CSharedCreatureData c, int nPetDbId, int nBabyClassId, int nEvolveItemId, int nGrownClassId, int nPetLevel )

Parameters

c (CSharedCreatureData) — the pet's owner player.
nPetDbId (int) — the pet's identifier in the database (usually item0.dbid).
nBabyClassId (int) — the hatchling's class (the initial form).
nEvolveItemId (int) — the evolution item.
nGrownClassId (int) — the pet's adult-form class.
nPetLevel (int) — the pet's level (usually item0.pet_level).

Example

EvolvePet( talker, item0.dbid, 1012311, 4422, 1012526, item0.pet_level );
EvolvePet( talker, item0.dbid, 1012312, 4423, 1012527, item0.pet_level );
EvolvePet( talker, item0.dbid, 1012313, 4424, 1012528, item0.pet_level );
EvolvePet(talker, item0.dbid, i2, i1, i3, item0.pet_level);

Usage example

if (item0.pet_level >= i4) {
    EvolvePet(talker, item0.dbid, i2, i1, i3, item0.pet_level);
    ShowPage(talker, fnHi);
    SoundEffect(talker, "ItemSound.quest_finish");
} else {
    ShowPage(talker, "pet_manager_evolve_no.htm");
}

EvolvePetWithSameExpNPC🟢 high

pet evolution with experience preserved

Evolution of the player cCreature's pet into the adult form nGrownClassId with the accumulated experience preserved, namespace CNPC. Unlike EvolvePet, only the final class is passed.

Signature

EvolvePetWithSameExp( CSharedCreatureData c, int nGrownClassId )

Parameters

c (CSharedCreatureData) — the pet's owner player.
nGrownClassId (int) — the final class of the pet's adult form.

Example

EvolvePetWithSameExp( talker, id_grown_pet1 );

DestroyPetNPC🟢 high

remove a pet

Removes the player cCreature's pet, namespace CNPC. Arguments: nPetDbId — the pet's id in the database, nPetLevel — the level (the value -99 sets a special removal case).

Signature

DestroyPet( CSharedCreatureData c, int nPetDbId, int nPetLevel )

Parameters

c (CSharedCreatureData) — the pet's owner player.
nPetDbId (int) — the pet's identifier in the database (usually item0.dbid / myself.sm.pet_dbid).
nPetLevel (int) — the pet's level; the special value -99 sets a special removal case.

Example

DestroyPet( talker, item0.dbid, item0.pet_level );
DestroyPet( myself.master, myself.sm.pet_dbid, -99 );

Usage example

if ( item0 ) {
    DestroyPet( talker, item0.dbid, item0.pet_level );
}

GetEvolutionIdNPC🟢 high

the id of the current evolution

Returns the numeric identifier of the current evolution (int), namespace CNPC. There are almost no calls in our scripts, the semantics is weakly confirmed.

Signature

GetEvolutionId(  )

Parameters

(none — the function is called without arguments)

Example

i0 = GetEvolutionId( );

Summon_SetOptionNPC🟢 high

set a summon option

Sets an option of a summoned summon and returns an int, namespace CNPC. Arguments: nOption — the option number (0..3), nValue — the value (for option 1 often 900, for 2/3 — 0 or 1).

Signature

Summon_SetOption( int nOption, int nValue )

Parameters

nOption (int) — the summon option number (0..3).
nValue (int) — the option value (for option 1 often 900, for 2/30 or 1).

Example

Summon_SetOption( 3, 1 );

RideWyvernNPC🟢 high

seat the player on a wyvern

Seats the player cCreature astride the wyvern nWyvernId (usually @wyvern), namespace CNPC.

Signature

RideWyvern( CSharedCreatureData c, int nWyvernId )

Parameters

c (CSharedCreatureData) — the player who is seated astride.
nWyvernId (int) — the wyvern identifier (usually `@wyvern`).
    the values are from the [npc_pch] dictionary

Example

RideWyvern(talker, @wyvern);
RideWyvern( talker, 1012621 );

Classes & subclasses (Class / Subclass)

7 functions

ClassChangeNPC🟢 high

change the main class

Changes the player cCreature's main class to nClassId and returns an int, namespace CNPC. The class is given by a @-constant (@duelist, @phoenix_knight, @grand_khavatari, etc.) or a number.

Signature

ClassChange( CSharedCreatureData c, int nClassId )

Parameters

c (CSharedCreatureData) — the player whose main class is changed.
nClassId (int) — the identifier of the new class (a class @-constant, e.g. @grand_khavatari, or a number).

Example

ClassChange( talker, @grand_khavatari );

Usage example

if ( ask == -512 ) {
    ClassChange( talker, reply );
}

ChangeSubJobNPC🟢 high

change the active subclass

Makes the specified subclass nSubJobClass active for the player cCreature, namespace CNPC.

Signature

ChangeSubJob( CSharedCreatureData cCreature, int nSubJobClass )

Parameters

cCreature (CSharedCreatureData) — the player for whom the subclass is activated
nSubJobClass (int) — the subclass made active

Example

ChangeSubJob( talker, i0 );

Usage example

    if( talker.alive ) {
        ChangeSubJob( talker, @shillien_knight );
    }

Related event: the server's response arrives as the SUBJOB_CHANGED event (see NASC_HANDLERS).

RenewSubJobNPC🟢 high

reset/replace the subclass in a slot

Resets or replaces the player cCreature's subclass in the slot nSlot with the class nClassId, namespace CNPC.

Signature

RenewSubJob( CSharedCreatureData c, int nSlot, int nClassId )

Parameters

c (CSharedCreatureData) — the player whose subclass is reset/replaced.
nSlot (int) — the subclass slot number.
nClassId (int) — the identifier of the new subclass class.

Example

    RenewSubJob( talker, i8, 12 );

Related event: the server's response arrives as the SUBJOB_RENEWED event (see NASC_HANDLERS).

GetSubJobListNPC🟢 high

build the list of available subclasses

Fills the list of subclasses available for the player cCreature to choose for a menu, namespace CNPC. Arguments: nCategory — the category (10/20/...), nState — the state/filter.

Signature

GetSubJobList( CSharedCreatureData c, int nCategory, int nState )

Parameters

c (CSharedCreatureData) — the player for whom the subclass list is built.
nCategory (int) — the subclass category (10/20/…; in calls reply-10).
nState (int) — the selection state/filter (0 in calls).

Example

    GetSubJobList( talker, ( reply - 10 ), 0 );

Related event: the server's response arrives as the SUBJOB_LIST_INFORMED event (see NASC_HANDLERS).

IsMainClassNPC🟢 high

is the main class active

Returns whether the player cCreature's main class is currently active (1/0, compared with @TRUE), namespace CNPC.

Signature

IsMainClass( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose main class activity is checked

Example

if ( IsMainClass( talker ) == @TRUE ) {

Usage example

if (IsMainClass(talker) == 1 && talker.level >= 81) {
    ShowPage(talker, "inzone_frantz_q010296_01.htm");
}

CheckSubJobAsMainNPC🟢 high

can a subclass be made main

Checks whether the player cCreature's subclass nSubJobClass can be made the main class, returns an int, namespace CNPC. The return semantics is weakly confirmed.

Signature

CheckSubJobAsMain( CSharedCreatureData cCreature, int nSubJobClass )

Parameters

cCreature (CSharedCreatureData) — the player whose subclass is checked
nSubJobClass (int) — the subclass checked for the possibility of becoming the main class

Example

CheckSubJobAsMain( talker, i10 );
CheckSubJobAsMain( talker, @judicator );

Usage example

if ( myself.av_quest0.CompareExchange( GetIndexFromCreature( talker ), 0 ) == 0 ) {
    CheckSubJobAsMain( talker, i10 );
}

SetSubJobAsMainNPC🟢 high

make a subclass the main

Makes the player cCreature's subclass nSubJobClass the main class, namespace CNPC. There are few calls, the behavior is weakly confirmed.

Signature

SetSubJobAsMain( CSharedCreatureData cCreature, int nSubJobClass )

Parameters

cCreature (CSharedCreatureData) — the player whose subclass is made the main
nSubJobClass (int) — the subclass converted into the main class

Example

SetSubJobAsMain( c0, myself.av_quest1.GetValue() );
SetSubJobAsMain( talker, reply );
SetSubJobAsMain(c0, @judicator);
SetSubJobAsMain( talker, @judicator );

Tutorial

5 functions

ShowTutorialHTMLNPC🟢 high

show a tutorial HTML window

Shows the player cCreature a tutorial HTML window from the file sFile (a .htm name), namespace CNPC.

Signature

ShowTutorialHTML( CSharedCreatureData c, string sFile )

Parameters

c (CSharedCreatureData) — the player who is shown the tutorial window.
sFile (string) — the tutorial .htm file name (e.g. "tutorial_human_fighter001.htm").

Example

ShowTutorialHTML( talker, "tutorial_human_fighter001.htm" );

Usage example

if ( talker.occupation == @shillien_oracle ) {
    ShowTutorialHTML( talker, "tutorial_22q.htm" );
}

ShowTutorialHTML2NPC🟢 high

a tutorial window with sound

The same as ShowTutorialHTML, but with a delay and sound. Per the L2NPC decompile
(CNPC::ShowTutorialHTML2 → CShowTutorialHTMLTimer) the third argument is the display delay
in seconds: the engine sets AddTimer(1000*nDelaySec) and on firing shows the window
with a sound played. namespace CNPC.

Signature

ShowTutorialHTML2( CSharedCreatureData c, string sFile, int nDelaySec, string sSound )

Parameters

c (CSharedCreatureData) — the player who is shown the tutorial window.
sFile (string) — the tutorial .htm file name.
nDelaySec (int) — the delay before showing the window, seconds (engine: AddTimer(1000*nDelaySec); 3 in calls).
sSound (string) — the name of the sound played on display (e.g. "ItemSound.quest_tutorial").

Example

ShowTutorialHTML2( talker, "tutorial_03.htm", 3, "ItemSound.quest_tutorial" );
ShowTutorialHTML2( talker, "tutorial_05.htm", 3, "ItemSound.quest_tutorial" );

ShowNewTutorialHTMLNPC🟢 high

a new-format tutorial

Shows the player cCreature a new-format tutorial window from the file sFile (localized .htm), namespace CNPC.

Signature

ShowNewTutorialHTML( CSharedCreatureData cCreature, string pwsName )

Parameters

cCreature (CSharedCreatureData) — the player who is shown the new-format tutorial window
pwsName (string) — the name of the localized tutorial .htm file

Example

if (GetCountry(talker) == 2) { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-ua.htm"); }

Usage example

if (GetCountry(talker) == 2) { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-ua.htm"); }
else if (GetCountry(talker) == 4) { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-cn.htm"); }
else if (GetCountry(talker) == 8) { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-ru.htm"); }
else { ShowNewTutorialHTML(talker, "..\L2text\pet_visual26-eu.htm"); }

CloseTutorialHTMLNPC🟢 high

close the tutorial window

Closes the player cCreature's open tutorial window, namespace CNPC.

Signature

CloseTutorialHTML( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) whose tutorial window is closed

Example

CloseTutorialHTML( talker );

Usage example

else if ( reply == 999999) {
    CloseTutorialHTML( talker );
    return;
}

EnableTutorialEventNPC🟢 high

enable tutorial events

Enables the player cCreature's tutorial events by a bit mask of flags, namespace CNPC.
The argument is a bit mask: scripts set/add individual bits (e.g. i0 | 1048576,
where 1048576 = 0x100000 — the bit of a specific class of tutorial events).

Signature

EnableTutorialEvent( CSharedCreatureData c, int nFlags )

Parameters

c (CSharedCreatureData) — the player for whom tutorial events are enabled.
nFlags (int) — the bit mask of tutorial event flags (combined via OR;
    in calls the bit 1048576 = 0x100000 is found).

Example

EnableTutorialEvent( talker, ( i0 | 1048576 ) );

Radar

3 functions

ShowRadarNPC🟢 high

place a marker on the map

Places for the player cCreature a pointer marker at the point with coordinates nX, nY, nZ, namespace CNPC. The argument nType sets the radar: 1/2 or @RPT_BOTH (both radars at once).

Signature

ShowRadar( CSharedCreatureData c, int nX, int nY, int nZ, int nType )

Parameters

c (CSharedCreatureData) — the player for whom the marker is placed.
nX (int) — the X coordinate of the marker point.
nY (int) — the Y coordinate of the marker point.
nZ (int) — the Z coordinate of the marker point.
nType (int) — the radar type (manual_pch): @RPT_RADAR (0) — radar only,
    @RPT_MAP (1) — map only, @RPT_BOTH (2) — both.

Example

ShowRadar( attacker, -2908, 44128, -2712, 1 );

Usage example

if ( ( GetMemoStateEx( talker, @an_arrogant_search, 1 ) % 10 ) == 0 ) {
    ShowRadar( talker, 181472, 7158, -2725, 1 );
}

DeleteRadarNPC🟢 high

remove a specific marker

Removes for the player cCreature one marker at the point with coordinates nX, nY, nZ for the radar nType, namespace CNPC.

Signature

DeleteRadar( CSharedCreatureData c, int nX, int nY, int nZ, int nType )

Parameters

c (CSharedCreatureData) — the player from whom the marker is removed.
nX (int) — the X coordinate of the removed marker.
nY (int) — the Y coordinate of the removed marker.
nZ (int) — the Z coordinate of the removed marker.
nType (int) — the radar type (manual_pch): @RPT_RADAR (0), @RPT_MAP (1), @RPT_BOTH (2).

Example

DeleteRadar( talker, 10133, 157155, -2383, 2 );

Usage example

if ( ( i0 % 10 ) == 0 ) {
    DeleteRadar( attacker, -2908, 44128, -2712, 1 );
    ShowRadar( attacker, -2908, 44128, -2712, 1 );
} else {
    SetFlagJournal( attacker, @an_arrogant_search, 19 );
    ShowQuestMark( attacker, @an_arrogant_search );
}

DeleteAllRadarNPC🟢 high

remove all markers

Removes for the player cCreature all markers of the radar nType (@RPT_BOTH or 2), namespace CNPC.

Signature

DeleteAllRadar( CSharedCreatureData c, int nType )

Parameters

c (CSharedCreatureData) — the player from whom all markers are removed.
nType (int) — the radar type (manual_pch): @RPT_RADAR (0), @RPT_MAP (1), @RPT_BOTH (2).

Example

DeleteAllRadar(talker, @RPT_BOTH);
DeleteAllRadar( talker, 2 );

Usage example

if ( reply == 65 ) {
    DeleteAllRadar( talker, 2 );
    ShowRadar( talker, 12311, 17470, -4574, 2 );
    ShowPage( talker, "guide_delf_frankia_q0255_05.htm" );
}

Henna

2 functions

OpenHennaItemListForEquipNPC🟢 high

open the henna application window

Opens for the player cCreature the henna application (drawing) window, namespace CNPC.

Signature

OpenHennaItemListForEquip( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) for whom the henna application window is opened

Example

OpenHennaItemListForEquip( talker );

Usage example

if ( reply == 1 ) {
    OpenHennaItemListForEquip( talker );
} else if ( reply == 2 ) {
    OpenHennaListForUnquip( talker );
}

OpenHennaListForUnquipNPC🟢 high

open the henna removal window

Opens for the player cCreature the henna removal window, namespace CNPC.

Signature

OpenHennaListForUnquip( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`cCreature`) for whom the henna removal window is opened

Example

OpenHennaListForUnquip( talker );

Usage example

if ( reply == 2 ) {
    OpenHennaListForUnquip( talker );
}

TRADE AND MANOR (Shop / Multisell / PC-Cafe / Manor)

27 functions

BuyNPC🟢 high

open the buy window

Opens the trade buy window for a player. Takes the buyer (talker), a goods list [CBuySellList] (e.g. BuyList0), three string html decoration pages (header, list, empty page) and the tax/markup as a fraction; all on the NPC (myself). Returns nothing.

Signature

Buy( CSharedCreatureData cCreature, CBuySellList pBuyList, string pwsPage0, string pwsPage1, string pwsEmptyPage, float dTax )

Parameters

cCreature (CSharedCreatureData) — 1.
pBuyList (CBuySellList) — the list of goods for purchase displayed in the window
pwsPage0 (string) — html decoration page (window header)
pwsPage1 (string) — html decoration page (goods list)
pwsEmptyPage (string) — html page shown when the list is empty
dTax (float) — tax/markup fraction applied to the purchase price

Example

Buy( talker, BuyList0, ShopName, fnSell, fnUnableItemSell, -50 );

SellNPC🟢 high

open the sell window

Opens the trade sell window for a player. Takes the seller (talker), a goods list [CBuySellList] (e.g. SellList0) and four string html window decoration pages; all on the NPC (myself). Returns nothing.

Signature

Sell( CSharedCreatureData cCreature, CBuySellList pSellList, string pwsPage0, string pwsPage1, string pwsPage2, string pwsEmptyPage )

Parameters

cCreature (CSharedCreatureData) — the player for whom the sell window is opened
pSellList (CBuySellList) — the list of goods for sale displayed in the window
pwsPage0 (string) — html window decoration page
pwsPage1 (string) — html window decoration page
pwsPage2 (string) — html window decoration page
pwsEmptyPage (string) — html page shown when the list is empty

Example

Sell(talker, SellList0, ShopName, fnHi, _blank, _blank);

ShowBuySellNPC🟢 high

combined buy-sell window

Opens the combined buy-sell window — the more modern form of the trade window. Takes the player (talker), a buy goods list and a sell list (both [CBuySellList]) and a rate fraction; all on the NPC (myself). Returns nothing.

Signature

ShowBuySell( CSharedCreatureData pTalker, CBuySellList pBuyList, CBuySellList pSellList, float fRate )

Parameters

pTalker (CSharedCreatureData) — the player for whom the buy-sell window is opened
pBuyList (CBuySellList) — the list of goods for purchase
pSellList (CBuySellList) — the list of goods for sale
fRate (float) — rate fraction (tax/markup) applied to prices

Example

ShowBuySell( talker, SellList0, BuyList0, -50 );

Usage example

if ( GetPchValue( "client_hf" ) == 1 ) {
    ShowBuySell( talker, SellList0, BuyList0, -50 );
} else {
    Sell( talker, SellList0, ShopName, fnBuy, _blank, _blank );
}

ShowMultisellNPC🟢 high

open a multisell

Opens a multisell for the player — an exchange by predefined recipes — with the given identifier. Takes the recipe identifier (a raw number from the multisell data, often the incoming menu item number) and the player (talker); called on the NPC (myself). Returns nothing.

Signature

ShowMultisell( int nMultisellId, CSharedCreatureData c )

Parameters

nMultisellId (int) — multisell list/recipe identifier (raw number from the data, often a menu item number).
c (CSharedCreatureData) — the player for whom the multisell is opened (usually talker).

Example

ShowMultisell(212, talker);

Usage example

if ( GetSSQPart( talker ) != 0 ) {
    ShowMultisell( reply, talker );
}

GiveItemByPCCafePointNPC🟢 high

give an item for PC-Cafe points

Gives the player an item for PC-Cafe points, deducting the specified cost. Per the L2NPC
decompile (CNPC::GiveItemByPCCafePoint_49224C) the engine checks the cost against the point
balance (will not give the item if insufficient), requires a non-negative item/enchant/count,
and sends the grant as an opcode 122 packet of format "cddddQ" (the enchant is a plain int,
the count is a 64-bit Q). ATTENTION: the order of the last two is enchant, then count (the
previous table had them swapped).
Returns 1 on success, 0 on insufficient points/error.

Signature

GiveItemByPCCafePoint( CSharedCreatureData c, int nCost, int nItemClassId, int nEnchant, int64 nCount )

Parameters

c (CSharedCreatureData) — the player receiving the item for PC-Cafe points.
nCost (int) — cost in PC-Cafe points deducted for the grant (checked against the balance).
nItemClassId (int) — identifier of the item being given.
    values — from the [item_pch] dictionary
nEnchant (int) — enchant level of the item being given (0 in the calls; must be >= 0).
nCount (int64) — count of the item being given (1 in the calls; must be >= 0).

Example

GiveItemByPCCafePoint(talker, ticket_price, event_ticket, 0, 1);

Usage example

if ( GetDailyQuestFlag( talker, 993 ) == 1 ) {
    GiveItemByPCCafePoint( talker, ticket_price, event_ticket, 0, 1 );
    SetDailyQuestFlag( talker, 993 );
} else {
    ShowPage( talker, NotYetTime );
}

GetPCCafePointNPC🟢 high

how many PC-Cafe points the player has

Reports how many PC-Cafe points the player has. Takes the player; called on the NPC (myself). Returns an integer — the point count, used as a gate before giving a reward.

Signature

GetPCCafePoint( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose PC-Cafe points are queried

Example

if (GetPCCafePoint(talker) >= ticket_price) {

Usage example

if ( i9 > -1 && enter_type > -1 && ( GetPCCafePoint( talker ) >= required_PCCafePoint || pccafe_pass_mode == 2 ) ) {
    if ( IsUserPremium( talker ) == @FALSE ) {
        ShowPage( talker, "npc_rim_maker001e.htm" );
        return;
    }
    InstantZone_Enter( talker, i9, enter_type );
}

IsPCCafeUserNPC🟢 high

is the player playing from a PC-Cafe

Checks whether the player is playing from a PC-Cafe. Takes the player; called on the NPC (myself). Returns an integer flag (1 — playing from a cafe), used together with the point check.

Signature

IsPCCafeUser( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose PC-Cafe play flag is checked

Example

if (IsPCCafeUser(target) == @TRUE)

Usage example

if ( IsPCCafeUser( talker ) == 1 ) {
    GiveItem1( talker, cratae_reward, 5 );
}

CanUsePCCafePointNPC🟢 high

can PC-Cafe points be spent

Checks whether the player can use PC-Cafe points. Takes the player; called on the NPC (myself). Returns an integer flag.

Signature

CanUsePCCafePoint( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the player whose ability to spend PC-Cafe points is checked

Example (illustrative):

    CanUsePCCafePoint( talker );

UpdatePCCafePointNPC🟢 high

change PC-Cafe points

Changes the player's PC-Cafe point balance by the given amount (positive or negative). Takes the player and the change amount; called on the NPC (myself). Returns an integer.

Signature

UpdatePCCafePoint( CSharedCreatureData c, int nDelta )

Parameters

c (CSharedCreatureData) — the player whose PC-Cafe point balance is changed.
nDelta (int) — signed point change amount (e.g. -1000 in the calls).

Example

if ( UpdatePCCafePoint( talker, -1000 ) == 1 || pccafe_pass_mode == 2 ) {

ShowManorDefaultInfoNPC🟢 high

general manor summary

Shows the player a general manor summary. Takes the player; called on the NPC (myself) — the castle manager. Returns nothing.

Signature

ShowManorDefaultInfo( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player who is shown the manor summary

Usage example

if ( ask == 5 ) { ShowManorDefaultInfo( talker ); } else
if ( ask == 7 ) { ShowSeedSetting( talker, state ); } else
if ( ask == 8 ) { ShowCropSetting( talker, state );  }

ShowSeedInfoNPC🟢 high

seed information

Shows the player manor seed information. Takes the player, the manor identifier and the time; called on the NPC (myself). Returns nothing.

Signature

ShowSeedInfo( CSharedCreatureData pTalker, int nManorState, int nTime )

Parameters

pTalker     (CSharedCreatureData) — the player who is shown the seed information (talker).
nManorState (int) — manor identifier: the NPC's residence_id (state/manor_id in the scripts;
                    when state == -1, myself.sm.residence_id is substituted).
nTime       (int) — manor period/time. Comes as the time field of the
                    MANOR_MENU_SELECTED(talker, …, time) event; not set directly by the script.

Usage example

if ( state == -1 ) {
    ShowSeedInfo( talker, manor_id, time );
} else {
    ShowSeedInfo( talker, state, time );
}

ShowCropInfoNPC🟢 high

crop information

Shows the player manor crop information. Takes the player, the manor identifier and the time; called on the NPC (myself). Returns nothing.

Signature

ShowCropInfo( CSharedCreatureData pTalker, int nManorState, int nTime )

Parameters

pTalker     (CSharedCreatureData) — the player who is shown the crop information (talker).
nManorState (int) — manor identifier: the NPC's residence_id (state/manor_id in the scripts;
                    when state == -1, myself.sm.residence_id is substituted).
nTime       (int) — manor period/time. Comes as the time field of the
                    MANOR_MENU_SELECTED(talker, …, time) event; not set directly by the script.

Usage example

if ( state == -1 ) {
    ShowCropInfo( talker, manor_id, time );
} else {
    ShowCropInfo( talker, state, time );
}

ShowSeedSettingNPC🟢 high

seed sale settings

Shows the lord the seed sale settings menu. Takes the player and the state; called on the NPC (myself). Returns nothing.

Signature

ShowSeedSetting( CSharedCreatureData cCreature, int nManorState )

Parameters

cCreature   (CSharedCreatureData) — the lord who is shown the seed sale settings menu
nManorState (int) — menu state/mode (manor state/id in the calls)

Example

ShowSeedSetting(talker, state);

Usage example

if ( ask == 7 ) {
    ShowSeedSetting( talker, state );
} else
if ( ask == 8 ) {
    ShowCropSetting( talker, state );
}

ShowCropSettingNPC🟢 high

crop procurement settings

Shows the lord the crop procurement settings menu. Takes the player and the state; called on the NPC (myself). Returns nothing.

Signature

ShowCropSetting( CSharedCreatureData cCreature, int nManorState )

Parameters

cCreature   (CSharedCreatureData) — the lord who is shown the crop procurement settings menu
nManorState (int) — menu state/mode (manor state/id in the calls)

Usage example

if ( ask == 8 ) {
    ShowCropSetting( talker, state );
}

ShowProcureCropListNPC🟢 high

list of procured crops

Shows the player the list of crops the castle procures. Takes the player and the manor identifier; called on the NPC (myself). Returns nothing.

Signature

ShowProcureCropList( CSharedCreatureData cCreature, int nManorId )

Parameters

cCreature (CSharedCreatureData) — the player who is shown the list of procured crops
nManorId  (int) — manor identifier

Example

ShowProcureCropList(talker, manor_id);

ShowProcureCropDetailNPC🟢 high

details for a single crop

Shows the player the details of a single procured crop entry. Takes the player and the state; called on the NPC (myself). Returns nothing.

Signature

ShowProcureCropDetail( CSharedCreatureData cCreature, int nManorState )

Parameters

cCreature   (CSharedCreatureData) — the player who is shown the crop entry details
nManorState (int) — state/selected entry (manor state in the calls)

Usage example

if ( ask == 9 ) {
    ShowProcureCropDetail( talker, state );
}

ShowSellSeedListNPC🟢 high

list of seeds for sale

Shows the player the list of seeds for sale. Takes the player and the manor identifier; called on the NPC (myself). Returns nothing.

Signature

ShowSellSeedList( CSharedCreatureData cCreature, int nManorId )

Parameters

cCreature (CSharedCreatureData) — the player who is shown the list of seeds for sale
nManorId  (int) — manor identifier

Example

ShowSellSeedList(talker, manor_id);

Manor_GetSeedIncomeNPC🟢 high

manor income from seed sales

Reports the manor's accumulated income from seed sales. No arguments; works with the manor
of the NPC's own residence. Returns a 64-bit number (the adena amount from the manor data),
so there is no overflow.

Signature

Manor_GetSeedIncome(  )

Parameters

(none — the function is called without arguments)

Example

FHTML_SetInt(fhtml0, "seed_income", Manor_GetSeedIncome());

GetSeedClassidByOrderNumNPC🟢 high

seed class_id by list position number

Given the selected castle and a seed's position number in its list, returns the class_id of the seed item itself. Each castle's seed list is split into positions (1, 2, 3, …), and the seeds occupying them have different class_ids — this function translates the "row number in the dialog" into the real class_id, to show the player the seed's name or verify that exactly this seed is being bought. Fully analogous to GetCropClassidByOrderNum, only for seeds rather than crops.

The first argument is the castle (manor) id: the lord/player first picks a castle from the menu, its number is stored in the "ManorId" cookie and passed here. The second argument is the seed number chosen in the list (reply). Returns the seed's class_id (0 if the position is empty/invalid).

Signature

GetSeedClassidByOrderNum( int nManorId, int nOrderNum )

Parameters

nManorId  (int) — id of the castle/manor the seed list belongs to (usually from the "ManorId" cookie).
nOrderNum (int) — the seed's position number in the castle's list; in the dialog this is the player's choice (`reply`).

Example

i1 = GetSeedClassidByOrderNum( i0, reply );

GetCropClassidByOrderNumNPC🟢 high

crop class_id by number

Given the selected castle and a crop's position number in its list, returns the class_id of the crop item itself. Each castle's crop list is fixed by positions (1, 2, 3, …), while items with different class_ids can be planted and turned in — this function translates the "row number in the dialog" into the real class_id, to then show the player the crop's name or verify that he is turning in exactly that item.

The first argument is the castle (manor) id: in the dialog the lord first picks a castle from the menu, the castle number is stored in the "ManorId" cookie and then passed here. The second argument is the crop number the player chose in the list (reply). Returns the crop's class_id (0 if the position is empty/invalid).

Signature

GetCropClassidByOrderNum( int nManorId, int nOrderNum )

Parameters

nManorId  (int) — id of the castle/manor the crop list belongs to (usually taken from the "ManorId" cookie).
nOrderNum (int) — the crop's position number in the castle's list; in the dialog this is the player's choice (`reply`).

Example

i1 = GetCropClassidByOrderNum(i0, reply);

GetCurrentSeedPriceNPC🟢 high

current seed price

Given the selected castle and a seed's number in its list, returns the price at which the castle currently sells this seed to players. This is the effective price of the current period: it has already been set by the lord and trading proceeds at it until the settings change next. The value is inserted into an HTML dialog field (e.g. "CurrentSeedPrice") so that the player or lord sees the current price.

The first argument is the castle (manor) id; in the dialog it comes from the castle selection in the menu (variables state / i0, the number is in the "ManorId" cookie). The second argument is the seed number: either the player's specific choice (reply) or the index i2 when iterating over all 25 positions to fill the table. Returns the price in adena.

Signature

GetCurrentSeedPrice( int nManorId, int nOrderNum )

Parameters

nManorId  (int) — id of the castle/manor whose seed price list we read (state / i0 in the scripts, from the castle selection menu).
nOrderNum (int) — the seed's position number in the list; the player's choice (`reply`) or the iteration index i2 (1..25).

Example

FHTML_SetInt( fhtml0, "CurrentSeedPrice" + i2, GetCurrentSeedPrice( state, i2 ) );

GetCurrentSeedSellCountSetNPC🟢 high

seed sale limit

Given the selected castle and a seed number, returns the sale limit set by the lord for the current period: how many units of this seed in total the castle is willing to sell to players during the period. This is the planned number from the manufacture settings, not the stock remainder (the remainder is returned by GetCurrentSeedRemainCount). The value is shown in the dialog field "CurrentSeedCount".

The first argument is the castle (manor) id; in the dialog it comes from the castle selection (state / i0). The second argument is the seed number: the index i2 when iterating over all 25 positions for the table, or the player's choice (reply).

Signature

GetCurrentSeedSellCountSet( int nManorId, int nOrderNum )

Parameters

nManorId  (int) — id of the castle/manor whose seed sale plan we read (state / i0 in the scripts, from the castle selection menu).
nOrderNum (int) — the seed's position number in the list; the iteration index i2 (1..25) or the player's choice (`reply`).

Example

FHTML_SetInt( fhtml0, "CurrentSeedCount" + i2, GetCurrentSeedSellCountSet( state, i2 ) );

GetCropDefaultPriceNPC🟢 high

base crop price

Given the selected castle and a crop number, returns the base (starting) price of the crop — the reference value from which procurement is calculated. This is not the current price declared by the lord, but the position's base rate: it is convenient for showing the "recommended" price and calculating the planned revenue. It pairs with GetSeedDefaultPrice, which likewise returns the base price for a seed; in the dialog that one is called as GetSeedDefaultPrice( i0, i2 ) — the same two arguments.

The first argument is the castle (manor) id; in the dialog it comes from the castle selection (variables state / i0, the number is in the "ManorId" cookie). The second argument is the crop number: the index i2 when iterating over all 25 positions, or the player's choice (reply). Returns the price in adena.

Signature

GetCropDefaultPrice( int nManorId, int nOrderNum )

Parameters

    nManorId  (int) — id of the castle/manor whose base crop price we read (state / i0 in the scripts, from the castle selection menu).
    nOrderNum (int) — the crop's position number in the list; the iteration index i2 (1..25) or the player's choice (`reply`).

Example (illustrative; there are no direct calls in the collected scripts, but the paired GetSeedDefaultPrice is called exactly the same way):

    i1 = GetCropDefaultPrice( i0, i2 );

GetRemainProcureCropCountNPC🟢 high

remaining crop procurement

Given the selected castle and a crop number, returns how much of this crop the castle is still willing to accept from players before the period ends. The castle declares a procurement plan for the period; players turn in the crop, and this number decreases. When it reaches zero, the castle no longer buys this kind of crop. The value is shown in the dialog field "RemainCropCount" so the player can see whether it is still worth bringing the crop for turn-in.

The first argument is the castle (manor) id; in the dialog it comes from the castle selection (variables manor_id / state / i0). The second argument is the crop number: the index i2 when iterating over all 25 positions for the table, or the player's choice (reply).

Signature

GetRemainProcureCropCount( int nManorId, int nOrderNum )

Parameters

nManorId  (int) — id of the castle/manor whose procurement remainder we read (manor_id / state / i0 in the scripts, from the castle selection menu).
nOrderNum (int) — the crop's position number in the list; the iteration index i2 (1..25) or the player's choice (`reply`).

Example

FHTML_SetInt( fhtml0, "RemainCropCount" + i2, GetRemainProcureCropCount( manor_id, i2 ) );

SetSeedSellPropertyNPC🟢 high

set seed sale

Setter for the seed getters (GetCurrentSeedPrice / GetCurrentSeedSellCountSet): the lord sets, for a single seed position, at what price and in what quantity the castle will sell this seed to players in the next period. These values then fill the "NextSeedPrice"/"NextSeedCount" fields in the dialog, and when the new period starts they become the current ones.

The first argument is the lord himself who changes the setting (his manor rights are checked through him). Then — which castle and which position we are editing, then the new price and the new limit. The castle identifier must be a real castle number (you cannot pass the "menu state" instead, otherwise the setting will not apply).

Signature

SetSeedSellProperty( CSharedCreatureData cCreature, int nManorId, int nOrderNum, int64 nPrice, int64 nCount )

Parameters

    cCreature (CSharedCreatureData) — the lord (or authorized clan member) setting the property; his manor rights are verified.
    nManorId  (int) — id of the castle/manor whose seed we configure (a real castle number, not a "menu state").
    nOrderNum (int) — the seed's position number in the castle's list (the same index as in the seed getters).
    nPrice    (int64) — new seed sale price to players (adena per unit).
    nCount    (int64) — new sale limit: how many units of this seed the castle will offer for the period.

Example (illustrative; there are no direct calls in the collected scripts, the argument order is taken from the signature and confirmed by the paired getters):

    SetSeedSellProperty( talker, i0, reply, i_price, i_count );

SetCropProcurePropertyNPC🟢 high

set crop procurement

Setter for the crop getters (GetProcurementRate / GetProcurementCount / GetProcurementType and GetRemainProcureCropCount): the lord sets, for a single crop position, at what price and in what volume the castle will buy this crop from players in the next period. These values are then visible in the dialog as "NextProcurePrice"/"NextProcureCount"/"NextProcureType", and when the new period starts they determine how much crop the castle will accept.

The first argument is the lord himself (his manor rights are checked through him). Then — which castle and which crop position we are editing, then the procurement price, a separate "procurement type" parameter and the volume. The crop's separate parameter (nArg) corresponds to the "procurement type" that GetProcurementType returns on read (e.g. payment form/acceptance mode); the difference from seeds is that crops have this setting while seeds do not — hence the extra int in the signature between the price and the count.

The argument order is "price (64-bit) → type → count (64-bit)"; the manor id is accepted in the range 1..40. There are no direct calls in the collected scripts, but the layout and the presence of a separate "procurement type" between the price and the volume are confirmed and consistent with the paired seed setter SetSeedSellProperty (seeds have no "type").

Signature

SetCropProcureProperty( CSharedCreatureData cCreature, int nManorId, int nOrderNum, int64 nPrice, int nArg, int64 nCount )

Parameters

    cCreature (CSharedCreatureData) — the lord (or authorized clan member) setting the property; his manor rights are verified.
    nManorId  (int) — id of the castle/manor whose crop procurement we configure (a real castle number).
    nOrderNum (int) — the crop's position number in the castle's list (the same index as in the procurement getters).
    nPrice    (int64) — crop procurement price (adena per unit) the castle will offer to players.
    nArg      (int) — procurement type/mode for this position (a value with the same meaning as GetProcurementType returns).
    nCount    (int64) — procurement volume: how many units of this crop the castle is willing to accept for the period.

Example (illustrative — there are no direct calls in the collected scripts):

    SetCropProcureProperty( talker, i0, reply, i_price, i_type, i_count );

GiveItemByCastleSiegeDefenceNPC🟢 high

reward for defending the castle in a siege

Exchanges the clan's accumulated "castle defence counter" for a reward: deducts nConsume
units of this counter from the player's clan and gives the player an item. Requires the
player to be the clan leader and his clan's defence counter to be at least nConsume;
otherwise nothing is given. The counter accumulates for the clan's participation in castle
defence during sieges and is read via GetPledgeCastleSiegeDefenceCount.

Signature

GiveItemByCastleSiegeDefence( CSharedCreatureData cCreature, int nConsume, int nItemClassId, int nEnchant, int64 nCount )

Parameters

cCreature    (CSharedCreatureData) — the player (clan leader) receiving the reward; his clan
               must have a defence counter >= nConsume.
nConsume     (int) — how many units of the "castle defence counter" to deduct from the clan (in the
               example — the whole accumulated counter i0).
nItemClassId (int) — class of the item being given (defence medal); values from the [item_pch] dictionary.
nEnchant     (int) — enchant/extra field of the item being given (0 in the example).
nCount       (int64) — count of the item being given (i0 in the example — one medal per
               counter unit).

Example

GiveItemByCastleSiegeDefence(talker, i0, item_medal, 0, i0);

Usage example

i0 = GetPledgeCastleSiegeDefenceCount( talker );
if ( i0 == 0 ) {
    ShowPage( talker, fnNoReward );
    return;
}
GiveItemByCastleSiegeDefence( talker, i0, item_medal, 0, i0 );

Manor: seeds & crops (Manor / Seeds)

13 functions

GetProcurementCountNPC🟢 high

how much crop has been procured in the current cycle

Getter of the agrarian manor system (CNPC). Returns int — the amount of crop procured by the residence in the current cycle for seed type nSeedType at state nManorState. The value is inserted into the manor manager's HTML menu.

Signature

GetProcurementCount( int nManorState, int nSeedType )

Parameters

nManorState (int) — manor state/period. In real calls = 1 (the manor_id/state variables
                    are initialized to one); there are no dedicated @-constants for it.
nSeedType   (int) — crop type = ordinal index 1..25, iterated by the loop for i2=1..25
                    when building the manor's HTML menu.

Example

FHTML_SetInt( fhtml0, "CurrentCropProcureCount" + i2, GetProcurementCount( manor_id, i2 ) );

GetProcurementRateNPC🟢 high

crop procurement price/rate

Manor getter (CNPC). Given state nManorState and seed type nSeedType, returns int — the crop procurement price (rate) for the current cycle. Used to render current prices in the menu.

Signature

GetProcurementRate( int nManorState, int nSeedType )

Parameters

nManorState (int) — manor state/period. In real calls = 1 (the manor_id/state variables
                    are initialized to one); there are no dedicated @-constants for it.
nSeedType   (int) — crop type = ordinal index 1..25, iterated by the loop for i2=1..25
                    when building the manor's HTML menu.

Example

FHTML_SetInt( fhtml0, "CurrentCropPrice" + i2, GetProcurementRate( manor_id, i2 ) );

GetProcurementTypeNPC🟢 high

crop procurement type/flag

Manor getter (CNPC). Given nManorState and nSeedType, returns int — the crop procurement type (flag) of the current cycle. Goes into the HTML menu next to the count and price.

Signature

GetProcurementType( int nManorState, int nSeedType )

Parameters

nManorState (int) — manor state/period. In real calls = 1 (the manor_id/state variables
                    are initialized to one); there are no dedicated @-constants for it.
nSeedType   (int) — crop type = ordinal index 1..25, iterated by the loop for i2=1..25
                    when building the manor's HTML menu.

Example

FHTML_SetInt( fhtml0, "CurrentProcureType" + i2, GetProcurementType( manor_id, i2 ) );

GetNextProcurementCountNPC🟢 high

forecast procurement volume for the next cycle

Manor getter (CNPC). Given state nManorState and seed type nSeedType, returns int — the crop procurement volume planned for the next cycle.

Signature

GetNextProcurementCount( int nManorState, int nSeedType )

Parameters

nManorState (int) — manor state/period. In real calls = 1 (the manor_id/state variables
                    are initialized to one); there are no dedicated @-constants for it.
nSeedType   (int) — crop type = ordinal index 1..25, iterated by the loop for i2=1..25
                    when building the manor's HTML menu.

Example

FHTML_SetInt( fhtml0, "NextProcureCount" + i2, GetNextProcurementCount( state, i2 ) );

GetNextSeedPriceNPC🟢 high

seed price for the next period

Manor getter (CNPC). Given state nManorState and seed type nSeedType, returns int — the seed sale price set for the next period.

Signature

GetNextSeedPrice( int nManorState, int nSeedType )

Parameters

nManorState (int) — manor identifier: the NPC's residence_id (in scripts the variables manor_id/state/i0,
                    usually = 1; when state == -1, myself.sm.residence_id is substituted).
nSeedType   (int) — crop type = ordinal index 1..25 (iterated by the loop for i2=1..25).

Example

FHTML_SetInt( fhtml0, "NextSeedPrice" + i2, GetNextSeedPrice( state, i2 ) );

GetSeedDefaultPriceNPC🟢 high

base seed price

Manor getter (CNPC). Given nManorState and nSeedType, returns int — the base (default) seed price from which sale settings are computed.

Signature

GetSeedDefaultPrice( int nManorState, int nSeedType )

Parameters

nManorState (int) — manor identifier: the NPC's residence_id (in scripts the variables manor_id/state/i0,
                    usually = 1; when state == -1, myself.sm.residence_id is substituted).
nSeedType   (int) — crop type = ordinal index 1..25 (iterated by the loop for i2=1..25).

Example

FHTML_SetInt( fhtml0, "DefaultSeedPrice" + i2, GetSeedDefaultPrice( i0, i2 ) );

GetNextSeedSellCountSetNPC🟢 high

seed sale plan (next period)

For the selected castle and seed number, returns the sale limit set for the NEXT period: how many units of this seed the castle will put up for sale when the new manufacture cycle begins. This is the counterpart of GetCurrentSeedSellCountSet (which returns the current period's limit) — in the settings dialog they are shown side by side ("now" and "will become") so the lord can see what he changed. The value is inserted into the "NextSeedCount" field.

The first argument is the castle (manor) id; in the dialog it comes from the castle selection (state / i0). The second argument is the seed number: the index i2 when iterating all 25 positions for the table, or the player's choice (reply).

Signature

GetNextSeedSellCountSet( int nManorId, int nOrderNum )

Parameters

nManorId  (int) — id of the castle/manor whose next-period plan is being read (in scripts state / i0, from the castle selection menu).
nOrderNum (int) — number of the seed position in the list; the iteration index i2 (1..25) or the player's choice (`reply`).

Example

FHTML_SetInt( fhtml0, "NextSeedCount" + i2, GetNextSeedSellCountSet( state, i2 ) );

GetCurrentSeedRemainCountNPC🟢 high

remaining seeds of the current period

Manor getter (CNPC). Given state nManorState and seed type nSeedType, returns int — the unsold remainder of seeds for the current period.

Signature

GetCurrentSeedRemainCount( int nManorState, int nSeedType )

Parameters

nManorState (int) — manor identifier: the NPC's residence_id (in scripts the variables manor_id/state/i0,
                    usually = 1; when state == -1, myself.sm.residence_id is substituted).
nSeedType   (int) — crop type = ordinal index 1..25 (iterated by the loop for i2=1..25).

Example

FHTML_SetInt( fhtml0, "CurrentSeedRemain" + i2, GetCurrentSeedRemainCount( state, i2 ) );

GetMaxSellableCountNPC🟢 high

maximum seeds allowed for sale

Manor getter (CNPC). Given nManorState and nSeedType, returns int — the maximum allowed number of seeds for sale.

Signature

GetMaxSellableCount( int nManorState, int nSeedType )

Parameters

nManorState (int) — manor identifier: the NPC's residence_id (in scripts the variables manor_id/state/i0,
                    usually = 1; when state == -1, myself.sm.residence_id is substituted).
nSeedType   (int) — crop type = ordinal index 1..25 (iterated by the loop for i2=1..25).

Example

FHTML_SetInt( fhtml0, "MaxSell" + i2, GetMaxSellableCount( i0, i2 ) );

IsManorSettingTimeNPC🟢 high

is the manor setup period active

Manor predicate (CNPC), no arguments. Returns 1 if the manor setup period (prices/plans)
is currently active, otherwise 0. Per the decompile, the setup window is the time of day outside
the 8..19 hour range (i.e. from 20:00 to 07:59). The menu uses it to decide whether to allow
editing parameters.

Signature

IsManorSettingTime(  )

Parameters

(none — the function is called without arguments)

Example

if ( IsManorSettingTime( ) == 1 ) {

Usage example

if ( IsManorSettingTime( ) == 0 ) {
    FHTML_SetFileName( fhtml0, "manor_crop_client_info_next.htm" );
}

SellPreviewNPC🟢 high

preview of the sale list

Method of the manor/trade menu (CNPC). Shows creature c a preview of the sale list: arguments — a list of goods (CBuySellList) and three page-layout strings (sPage0..sPage2).

Signature

SellPreview( CSharedCreatureData cCreature, CBuySellList pSellList, string pwsPage0, string pwsPage1, string pwsPage2, string pwsEmptyPage )

Parameters

cCreature (CSharedCreatureData) — creature (player) shown the sale preview
pSellList (CBuySellList) — list of goods put up for sale
pwsPage0 (string) — first layout string of the menu page
pwsPage1 (string) — second layout string of the menu page
pwsPage2 (string) — third layout string of the menu page
pwsEmptyPage (string) — text shown when the sale list is empty

Example

SellPreview( talker, SellList0, ShopName, fnBuy, _blank, _blank );

Usage example

if ( reply == 2 ) {
    SellPreview( talker, SellPreview1, ShopName, fnBuy, _blank, _blank );
}

GetNextProcurementRateNPC🟢 high

the purchase price of the manor's next good

Returns the purchase price of the manor's next good. Takes the state (state) and
the position number; called on myself and usually substituted into an HTML field.
Works in pair with GetNextProcurementType.

Signature

GetNextProcurementRate( int nManorState, int nSeedType )

Parameters

nManorState (int) — the manor state/period. In real calls = 1 (the manor_id/state variables
                    are initialized to one); there are no separate @-constants for it.
nSeedType   (int) — the crop type = the ordinal index 1..25, iterated by the loop for i2=1..25
                    when building the manor HTML menu.

Example

FHTML_SetInt( fhtml0, "NextProcurePrice" + i2, GetNextProcurementRate( state, i2 ) );

GetNextProcurementTypeNPC🟢 high

the manor's purchase type by position

Returns the type of the manor's purchased good (seeds/crop). Takes the state
(state) and the position number; called on myself. Works in pair with
GetNextProcurementRate, usually for output into HTML.

Signature

GetNextProcurementType( int nManorState, int nSeedType )

Parameters

nManorState (int) — the manor state/period. In real calls = 1 (the manor_id/state variables
                    are initialized to one); there are no separate @-constants for it.
nSeedType   (int) — the crop type = the ordinal index 1..25, iterated by the loop for i2=1..25
                    when building the manor HTML menu.

Example

FHTML_SetInt( fhtml0, "NextProcureType" + i2, GetNextProcurementType( state, i2 ) );

Marriage

2 functions

MarryNPC🟢 high

register a marriage between two characters

Registers a marriage between two characters by their indexes. Takes two indexes
(idx1, idx2), usually obtained via GetIndexFromCreature; returns nothing.

Signature

Marry( int nChar1Index, int nChar2Index )

Parameters

nChar1Index (int) — the index of the first character entering the marriage
nChar2Index (int) — the index of the second character entering the marriage

Example

Marry( GetIndexFromCreature(myself.c_ai0), GetIndexFromCreature(myself.c_ai1) );

DivorceNPC🟢 high

dissolve a player's marriage

Dissolves a marriage: removes the marriage status for a player. Takes the player index
(user_idx), usually obtained via GetIndexFromCreature; returns nothing.

Signature

Divorce( int nCharIndex )

Parameters

nCharIndex (int) — the index of the player whose marriage is dissolved

Example

Divorce( GetIndexFromCreature( talker ) );

Usage example

if ( myself.i_ai0 == 0 ) {
    Divorce( GetIndexFromCreature( talker ) );
    ShowPage( talker, "sia_wedding012a.htm" );
}

UTILITIES — STRINGS, NUMBERS, CHECKS (Utility)

12 functions

RandGLOBAL🟢 high

a random integer

Returns a random integer in the range from zero to the value of [base] minus one.
Takes a single argument [base] (the upper bound, exclusive), namespace not
set. All probabilistic logic rests on this function — drop and line chances,
enchant spread, random branching.

Signature

Rand( int base )

Parameters

base (int) — the upper bound (exclusive).

Example

i0 = Rand( 4 );

Usage example

if ( MoveAroundSocial1 > 0 && Rand( 100 ) < 40 ) {
    AddEffectActionDesire( myself.sm, 2, ( ( MoveAroundSocial1 * 1000 ) / 30 ), 50 );
}

MakeFStringGLOBAL🟢 high

build a localized string

Builds a string from a localized NPC-string with identifier [id], substituting up to
five parameters [p1]..[p5]. Arguments: [id] (a client string id) and five string
substitutions, namespace not set; returns the ready text, which is usually passed to
Say, Shout, or FHTML. Unused parameters are left empty (_blank or
an empty string), and calls can be nested inside one another.

Where the id comes from: the strings themselves lie in the chronicle's fstring.txt file — by the id from
the call the text is found there (for example, 1001000 = "The Kingdom of Aden",
1001100 = "The Kingdom of Elmore"; hence the idiom MakeFString(1001000 +
myself.sm.residence_id, ...) — the domain name by residence number).

Signature

MakeFString( int id, string pwsValue1, string pwsValue2, string pwsValue3, string pwsValue4, string pwsValue5 )

Parameters

id (int) — a client string id.
pwsValue1 (string) — the first string substitution into the template (in place of [p1]); empty — `_blank`
pwsValue2 (string) — the second string substitution (in place of [p2]); empty — `_blank`
pwsValue3 (string) — the third string substitution (in place of [p3]); empty — `_blank`
pwsValue4 (string) — the fourth string substitution (in place of [p4]); empty — `_blank`
pwsValue5 (string) — the fifth string substitution (in place of [p5]); empty — `_blank`

Example

Say( MakeFString( 33413, "", "", "", "", "" ) );

MakeFStringMultiGLOBAL🟢 high

a localized string bound to a creature

Works like MakeFString, but additionally takes a creature [c] — apparently,
for multilingual substitution according to a specific player's language or locale. Arguments: [c]
(for whom the string is built), [id] (the string id) and five string substitutions
[p1]..[p5], namespace not set; returns the assembled string. No direct calls were
extracted from the code.

Signature

MakeFStringMulti( CSharedCreatureData c, int id, string pwsValue1, string pwsValue2, string pwsValue3, string pwsValue4, string pwsValue5 )

Parameters

    c (CSharedCreatureData) — for whom the string is built (language/context).
    id (int) — the string id.
    pwsValue1 (string) — the first string substitution into the template (in place of [p1]); empty — `_blank`
    pwsValue2 (string) — the second string substitution (in place of [p2]); empty — `_blank`
    pwsValue3 (string) — the third string substitution (in place of [p3]); empty — `_blank`
    pwsValue4 (string) — the fourth string substitution (in place of [p4]); empty — `_blank`
    pwsValue5 (string) — the fifth string substitution (in place of [p5]); empty — `_blank`

Example (illustrative):

    MakeFStringMulti( talker, id, "", "", "", "", "" );

IntToStrGLOBAL🟢 high

a number to text

Converts an integer to text for insertion into lines and HTML windows. Takes a
single argument [nValue] (the source number), namespace not set; returns the
string representation.

Signature

IntToStr( int nValue )

Parameters

nValue (int) — the integer to turn into text

Example

FHTML_SetStr( fhtml0, "p_member_count0", IntToStr( i1 ) );

StrToIntGLOBAL🟢 high

text to a number

Parses text back into an integer — used when parsing string
parameters. Takes a single argument [sValue] (the source string), namespace not
set; returns an integer.

Signature

StrToInt( string sValue )

Parameters

sValue (string) — the source string parsed into an integer

Example

i2 = StrToInt( s0 );

Usage example

if ( StrToInt( s0 ) == 2 ) {
    FHTML_SetStr( fhtml0, "Winner", MakeFString( 1000311, "", "", "", "", "" ) );
} else {
    FHTML_SetStr( fhtml0, "Winner", "" );
}

FloatToIntGLOBAL🟢 high

a fractional number to an integer

Converts a fractional number to an integer (truncation or rounding). Takes a single
argument [fValue] (the source fractional value), namespace not set; returns an integer
number. Especially often needed for coordinates: a creature's position is stored as fractional, while
the spawn and teleport functions expect integers.

Signature

FloatToInt( float fValue )

Parameters

fValue (float) — the source fractional value truncated/rounded to an integer

Example

x = FloatToInt(speller.x);

Usage example

if ( FloatToInt( ( ( attacker.hp / attacker.max_hp ) * 100 ) ) < 20 && Rand( 100 ) < 3 && attacker.is_pc == 1 ) {
    CreateOnePrivateEx( HelpHeroSilhouette, HelpHeroAI, 0, 0, ( FloatToInt( myself.sm.x ) + 80 ), ( FloatToInt( myself.sm.y ) + 80 ), FloatToInt( myself.sm.z ), 0, 0, 0, GetIndexFromCreature( myself.sm ) );
}

GetIndexFromCreatureGLOBAL🟢 high

a creature's numeric identifier

Returns the numeric index or object identifier of the creature [c]. Takes a
single argument [c] (a creature), namespace not set; returns an int. Needed where
a function takes not a creature but the int-id of a target or owner — for example, a spawn's
owner or a skill target given by number.

Signature

GetIndexFromCreature( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature.

Example

i0 = GetIndexFromCreature( last_attacker );

IsNullGLOBAL🟢 high

a general emptiness check

Checks an arbitrary object for "empty/invalid". Takes a single
argument [o] (an object), namespace not set; returns one if the object is empty or
invalid, otherwise zero. Mandatory before accessing an object's fields, so as not to hit
an error on a missing value.

Signature

IsNull( object obj )

Parameters

obj (object) — an arbitrary object checked for empty/invalid

Example

if (IsNull(item0) == 0) {

Usage example

while ( IsNull( code_info = always_list.Next( ) ) == 0 ) {
}

IsNullCreatureNPC🟢 high

check a creature for null

A typed check of a creature for "null/invalid", belongs to the NPC itself.
Takes a single argument [c] (creature), no namespace specified; returns
one if the creature is null or invalid, zero otherwise. Used before accessing
the target's fields.

Signature

IsNullCreature( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature checked for null/invalid

Example

if (IsNullCreature(c0) == 0) {

Usage example

if ( IsNullCreature( myself.boss ) == 0 && DistFromMe( myself.boss ) > 500 && myself.boss.alive != 0 && myself.p_state != 3 ) {
    InstantTeleport( myself.sm, FloatToInt( myself.boss.x ), FloatToInt( myself.boss.y ), FloatToInt( myself.boss.z ) );
}

IsNullPartyNPC🟢 high

check a party for null

A typed check of a party for "null/invalid". Takes a single
argument [p] (party), no namespace specified; returns one if the party is null
or invalid, zero otherwise.

Signature

IsNullParty( CSharedPartyData p )

Parameters

p (CSharedPartyData) — the party checked for null/invalid.

Example

if (IsNullParty(party0) == @FALSE)

Usage example

if ( IsNullParty( party0 ) == 0 ) {
    myself.i_ai0 = party0.id;
}

IsNullStringNPC🟢 high

check a string for null

A typed check of a string for "null/invalid". Takes a single
argument [s] (string), no namespace specified; returns one if the string is empty or
invalid, zero otherwise.

Signature

IsNullString( string s )

Parameters

s (string) — the string checked for null/invalid.

Example

if (IsNullString(s0) == @TRUE) {

Usage example

if ( IsNullString( DoorName ) == 0 ) {
    Castle_GateOpenClose2( DoorName, 0 );
}

IsNullHateInfoNPC🟢 high

check a hate-info record for null

A typed check of an aggro information record (hate-info) for "null/invalid".
Takes a single argument [h] (hate-info), no namespace specified; returns
one if the value is null or invalid, zero otherwise.

Signature

IsNullHateInfo( CHateInfo h )

Parameters

h (CHateInfo) — the aggro information record (hate-info) checked for null/invalid.

Example

if (IsNullHateInfo(h0) == @FALSE)

Usage example

if (IsNullHateInfo(h0) == @TRUE || h0.hate <= 0)
{
    h0 = GetMaxHateInfo(0);
}

TIME AND CALENDAR (Time / DateTime)

5 functions

GetTimeOfDayGLOBAL🟢 high

the current server time (Unix seconds)

This is NOT the "part of the day" as one might think from the name. The function takes the server's system
time and returns it as the number of seconds elapsed since January 1, 1970
(a Unix timestamp). No arguments, called on gg. Needed for arithmetic with
deadlines: the difference from a boundary mark gives "how many seconds remain". The classic
idiom — GetTimeOfSSQ(1) - GetTimeOfDay() — how many seconds until the end of the Seven
Signs period. Day or night is NOT determined by this function — for that there is
GetL2Time(@L2F_IS_NIGHT) (see below) or GetTimeHour. The same timestamp is
fed to GetDateTime to parse "now" into year/month/hour, etc.

Signature

GetTimeOfDay(  )

Parameters

(none — the function is called without arguments)

Example

i0 = GetTimeOfDay( );
i6 = GetTimeOfDay( );

Usage example

if ( ( ( ( i0 >= 0 && i0 < 18 ) || ( i0 >= 20 && i0 < 38 ) ) || ( i0 >= 40 && i0 < 58 ) ) || ( GetTimeOfSSQ( 1 ) - GetTimeOfDay( ) ) <= 120 ) {
    ShowPage( talker, "ssq_main_event_acolyte_q0505_22.htm" );
    RemoveMemo( talker, @blood_offering );
    return;
}

GetDateTimeGLOBAL🟢 high

parse date-time into a field

Parses a date-time into a single component and returns it as a number. The first
argument is a timestamp: zero means "now", nonzero means a specific moment,
for example the expiration date of a castle decoration. The second argument selects the component
(year, month, day, hour, minute, second, or day of week). Called on the global
object gg; for the day of week it returns a number from zero (Sunday) to six (Saturday).

Signature

GetDateTime( int nTime, int nField )

Parameters

nTime  (int) — the timestamp: 0 = current time; >0 = a specific moment (e.g. an expiration date).
nField (int) — which component to extract (confirmed by engine decompile):
    0 year · 1 month · 2 day · 3 hour · 4 minute · 5 second · 6 day of week (0=Sun … 6=Sat)

Example

i0 = GetDateTime( 0, 3 );

Usage example

i0 = GetDateTime( 0, 4 );
if ( i0 > 49 && i0 < 60 ) {
    Say( MakeFString( 1010552, "", "", "", "", "" ) );
    return;
}

GetL2TimeGLOBAL🟢 high

a component of the world's in-game time

Returns a component of L2 in-game time (an in-game day runs faster than a
real one). Called on gg. The single argument is not "day/night", but the NUMBER
OF THE FIELD to get; the codes are taken from [manual_pch] (the same in all
chronicles):

@L2F_HOUR = 0 — the in-game hour
@L2F_MIN = 1 — the in-game minute
@L2F_IS_NIGHT = 2 — whether it is night now: 1 = night, 0 = day

That is, GetL2Time(@L2F_IS_NIGHT) is the most convenient way to check "is it night now?":
it returns 1 at night and 0 during the day. GetL2Time(@L2F_HOUR) is the same as GetTimeHour().
Not to be confused with GetTimeOfDay (which returns the raw server timestamp in seconds).

Signature

GetL2Time( int nField )

Parameters

nField (int) — which time field to return: @L2F_HOUR(0) / @L2F_MIN(1) / @L2F_IS_NIGHT(2)

Example

i1 = GetL2Time(@L2F_MIN);

Usage example

i0 = GetL2Time(@L2F_IS_NIGHT);
if (i0 == 0)    //Day
{
    Despawn();
}

GetLifeTimeNPC🟢 high

how many seconds the NPC has been alive

Returns how many seconds the NPC has lived since appearing. No arguments,
called on myself. The most frequent use — a "grace period" after spawn: for the first
few seconds the monster does not aggro and does not move, to have time to look around;
the threshold is taken either as a number or from a class parameter.

Signature

GetLifeTime(  )

Parameters

(none — the function is called without arguments)

Example

if ( GetLifeTime( ) > 7 ) {

Usage example

if ( GetLifeTime( ) >= ( Rand( 5 ) + 3 ) && InMyTerritory( myself.sm ) ) {
    AddAttackDesire( creature, @AMT_MOVE_TO_TARGET, 200 );
}

GetTimeHourNPC🟢 high

the current in-game hour

Returns the current in-game hour (0..23) by the accelerated in-game clock — the same
as GetL2Time(@L2F_HOUR). No arguments, called on myself. In old
scripts "day or night" is checked by a threshold (hour five and above — day, less — night),
but it is more reliable to ask directly GetL2Time(@L2F_IS_NIGHT) (returns 1 at night, 0 during the day).
Not to be confused with GetTimeOfDay — that returns the raw server timestamp in seconds.

Signature

GetTimeHour(  )

Parameters

(none — the function is called without arguments)

Example

if (GetTimeHour() < 5)

Usage example

if (GetTimeHour() < 6)
{
    CreateOnePrivateEx(@sf_halloween21_vampire1 + Rand(4), "sf_halloween21_vampire", 0, 0, FloatToInt(myself.sm.x + 30), FloatToInt(myself.sm.y + 30), FloatToInt(myself.sm.z), 0, 0, 0, 0);
    CreateOnePrivateEx(@sf_halloween21_vampire1 + Rand(4), "sf_halloween21_vampire", 0, 0, FloatToInt(myself.sm.x - 30), FloatToInt(myself.sm.y - 30), FloatToInt(myself.sm.z), 0, 0, 0, 0);
}

STATE STORAGE (GlobalMap / DBSavingMap / DBValue)

8 functions

RegisterDBSavingMapGLOBAL🟢 high

write a value to the saved map

Writes a "key — number" pair to the persistent map whose value is stored
in the DB and survives a restart; used for counters that must not be lost.
Takes arguments (int key, int value) in the gg namespace (CGlobalObject);
returns an integer.
Related event: reading (LoadDBSavingMap) responds with the event LOAD_DBSAVING_MAP_RETURNED(i0=key, i1=value) (see NASC_HANDLERS).

Signature

RegisterDBSavingMap( int nMapKey, int nValue )

Parameters

nMapKey (int) — map key: a @gm_* constant [manual_pch] or a raw number.
nValue  (int) — number stored in the persistent DB map under this key.

Example

RegisterDBSavingMap(@gm_supply_box, i2);

Usage example

if ( myself.i_ai2 == 1 ) {
    RegisterDBSavingMap( GM_ID1, Castle_GetRawSystemTime( ) );
    myself.i_ai0 = Castle_GetRawSystemTime( );
    myself.i_ai1 = 0;
    myself.i_ai2 = 2;
}

GetDBSavingMapGLOBAL🟢 high

read a value from the saved map

Reads the number stored under a key in the persistent DB map. Takes argument
(int key) in the gg namespace (CGlobalObject); returns the stored number.

Signature

GetDBSavingMap( int nMapKey )

Parameters

nMapKey (int) — map key: a @gm_* constant [manual_pch] or a raw number.

Example

i1 = GetDBSavingMap(@gm_supply_box);

Usage example

i1 = GetDBSavingMap(@gm_supply_carriage);
if ((i1 % 10) >= 1) {
    i2 = i1 - 1;
    RegisterDBSavingMap(19, i2);
}

LoadDBSavingMapGLOBAL🟢 high

load a creature's saved data from the DB

Initiates an ASYNCHRONOUS load of a creature's saved data map from the database (by character
identifier). The first argument — the creature whose data to load — determines whose record to fetch
from the DB. The function does NOT return a value directly: the result arrives as a separate event, after
which the data is available via the Get functions. So in scripts, Load merely starts loading into
the cache, and reading happens later. Called on gg.

Signature

LoadDBSavingMap( CSharedCreatureData cCreature, int nMapKey )

Parameters

cCreature (CSharedCreatureData) — creature in whose context the value is loaded.
nMapKey   (int) — map key: a @gm_* constant [manual_pch] or a raw number.

Example

    LoadDBSavingMap(myself.sm, @gm_hot_spot);

Related event: the server's response arrives as the LOAD_DBSAVING_MAP_RETURNED event (see NASC_HANDLERS).

RegisterSharedGlobalMapGLOBAL🟢 high

map with extended visibility scope

A "ledger" of "key → number" shared by everyone, through which different NPCs (including ones from different
scripts) coordinate with each other. Works like a bulletin board: a single number is written
under a unique key, then anyone can read that number, and when it is no longer needed —
the entry is erased.

In practice this is a registry of "who currently plays role X". A typical raid-boss pattern: on
spawn the boss registers its id under its constant key — RegisterSharedGlobalMap
(@ghost_of_orfen, myself.sm.id)
. Another NPC later asks GetSharedGlobalMap(@ghost_of_orfen):
if a number greater than zero came back, the boss is alive and this is its id — it is used to get the creature itself
(GetCreatureFromID) and, for example, send it a signal. When the boss dies or leaves, it calls
UnregisterSharedGlobalMap(@ghost_of_orfen) to clear the entry, and the next check returns 0
("nobody there"). This is how some mobs learn whether the boss is alive and where it is, without holding a direct reference to it.

- RegisterSharedGlobalMap(key, value) — write number value under key key (usually an NPC id). No return.
- GetSharedGlobalMap(key) — read the number written under key key; 0 if nothing/nobody is under the key.
- UnregisterSharedGlobalMap(key) — erase the entry under key key.

The key is a meaningful named constant (@ghost_of_orfen, @zaken, @dent, etc.), the same for
everyone communicating through this board. The value is an integer, most often the id of the NPC that
"claimed" the role under this key.

Signature

RegisterSharedGlobalMap( int key, int value )
GetSharedGlobalMap( int key )
UnregisterSharedGlobalMap( int key )

Parameters

key (int) — shared role-name key (@… constant) under which writing/reading happens.
value (int) — number to write, usually the id of the NPC that took the role (Register only).

Example

RegisterSharedGlobalMap( @ghost_of_orfen, myself.sm.id );
i0 = GetSharedGlobalMap( @ghost_of_orfen );
UnregisterSharedGlobalMap( @ghost_of_orfen );

Usage example

i0 = GetSharedGlobalMap( @zaken );
if ( i0 > 0 ) {
    c0 = GetCreatureFromID( i0 );
    if ( IsNullCreature( c0 ) == @FALSE ) {
        SendScriptEvent( c0, @zaken, 111 ); // notify the registered NPC about the event
    }
}

RegisterGlobalMapNPC🟢 high

write a value to the global map

Writes a "key — number" pair to the in-memory server cache with which NPCs exchange
state on the fly. Takes the arguments (int key, int value) in the myself namespace
(CNPC); returns nothing. The cache is reset on a server restart.

Signature

RegisterGlobalMap( int key, int value )

Parameters

key (int) — the record key in the server state cache
value (int) — the number saved in the global map under the given key

Example

RegisterGlobalMap(@gm_cartia, myself.sm.id);

Usage example

if ( i0 == -1 ) {
    RegisterGlobalMap( GM_ID, GetIndexFromCreature( myself.sm ) );
}

GetGlobalMapNPC🟢 high

read a value from the global map

Reads a number previously written by key to the global map. Takes the argument
(int key) in the myself namespace (CNPC); returns the stored number or -1 if
the key is absent.

Signature

GetGlobalMap( int key )

Parameters

key (int) — the key by which the number is read from the global map

Example

i0 = GetGlobalMap(@gm_cartia);

Usage example

i0 = GetGlobalMap( @gm_frintessa );
if ( i0 != -1 ) { c0 = GetCreatureFromIndex( i0 ); }

UnregisterGlobalMapNPC🟢 high

delete a key from the global map

Deletes the record by key from the in-memory global map. Takes the argument (int key)
in the myself namespace (CNPC); returns an integer.

Signature

UnregisterGlobalMap( int key )

Parameters

key (int) — the key whose record is deleted from the global map

Example

UnregisterGlobalMap(@i_core);

Usage example

if ( c0.db_value == 0 ) {
    UnregisterGlobalMap( myself.i_ai2 );
    Despawn( );
}

SetDBValueNPC🟢 high

save a permanent number for a creature

Saves for the creature c (most often myself.sm) a permanent number — for example,
a stage number that the NPC remembers between re-logins. Takes the arguments
(CSharedCreatureData c, int nValue) in the myself namespace (CNPC); returns nothing.
There is no reverse read function — the written value is read through the creature's .db_value field.

Signature

SetDBValue( CSharedCreatureData c, int nValue )

Parameters

c (CSharedCreatureData) — the creature (usually `myself.sm`) for which the number is saved.
nValue (int) — the permanent number saved for the creature (read through the `.db_value` field).

Example

SetDBValue( myself.sm, @SCE_FRINTESSA_ALL_READY );

Usage example

if ( myself.sm.db_value == 1 ) {
    SetDBValue( myself.sm, 0 );
}

DATA STORAGE (DbData / DbCookie / AtomicValue)

16 functions

CompareExchangeGLOBAL🟢 high

atomically compare and swap a value

A method of the thread-safe counter CAtomicValue (per decompile — _InterlockedCompareExchange). If
the current value matches the expected one (the SECOND argument — the comparand), it swaps it for the new one
(the FIRST argument) and returns the old one; if it does not match — leaves it as is and returns the current one.
The basis of lock-free flags: in one operation you safely "capture" a state without a race.

Signature

CompareExchange( int nNew, int nComparand )

Parameters

nNew       (int) — the new value written into the counter on a match.
nComparand (int) — the expected value: compared with the counter's current content (on equality — a swap).
    Example: av_ai0.CompareExchange(1, 0) — if the counter == 0, write 1 and return the old (0).

Example

if (myself.av_ai0.CompareExchange(1, 0) == 0)

Usage example

if ( myself.av_quest0.CompareExchange( GetIndexFromCreature( talker ), 0 ) == 0 ) {
    CheckSubJobAsMain( talker, i10 );
}

DecrementGLOBAL🟢 high

atomically decrease a counter

A method of CAtomicValue: atomically decreases the counter by nAmount and returns the new value
(per decompile — _InterlockedExchangeAdd(-nAmount); the counter itself is an atomic object, e.g. av_ai0).
Under the hood — an aligned integer field and hardware interlocked instructions.

Signature

Decrement( int nAmount )

Parameters

nAmount (int) — by how much to decrease the counter (1 in calls).

Example

myself.av_ai0.Decrement(1);

SetMaxSizeGLOBAL🟢 high

limit the maximum size of a list

A method of a list (integer or string): sets the maximum size. Called before
filling the list.

Signature

SetMaxSize( int nMaxSize )

Parameters

nMaxSize (int) — the maximum size of the list

Example

myself.int_list.SetMaxSize(100);

SetAsNullGLOBAL🟢 high

null out an object reference

Nulls out an object reference — used to clear temporary references to creatures like c_ai0/c_ai1.

Signature

SetAsNull( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature reference being nulled out (for example `c_ai0`/`c_ai1`)

Example

SetAsNull( myself.c_ai1 );

LoadDBNpcInfoMAKER🟢 high

load NPC data from the database

Pulls saved NPC data from the database into a spawn-define object by a
numeric key. Called on the define itself: first the maker iterates its own
spawn-defines via GetSpawnDefine, for each checks whether it is bound to the database (the field
has_dbname), and only for the bound ones calls LoadDBNpcInfo — otherwise there is nothing to load. After
this, the define holds the data from the database, and NPCs can be spawned from it already with the restored
state. The argument is the numeric key of the database record (1010 in calls).

Signature

LoadDBNpcInfo( int nNpcId )

Parameters

nNpcId (int) — the numeric key of the database record whose data is pulled into the spawn define.

Example

def0.LoadDBNpcInfo( 1010 );

SetDBLoadedMAKER🟢 high

mark that data is loaded from the database

Sets the flag that the character/define data is already loaded from the database (1 — loaded,
0 — not).

Signature

SetDBLoaded( int nLoaded )

Parameters

nLoaded (int) — the flag for loading data from the database: 1 — loaded, 0 — not

Example

loaded_def.SetDBLoaded( 1 );

GetDbCookieIntNPC🟢 high

read an integer from a named group

Reads an integer value from a DbCookie group by key. The group is given by an identifier
(for example BuffCookieGroupID), the key — by a number. If the key is absent, zero is returned. The first
argument is the player, the second — the group, the third — the key.

Signature

GetDbCookieInt( CSharedCreatureData cCreature, int nGroupId, int nCookieId )

Parameters

cCreature (CSharedCreatureData) — the player whose DbCookie value is read
nGroupId (int) — the cookie group identifier
nCookieId (int) — the key of the read value within the group

Example

i9 = GetDbCookieInt( talker, BuffCookieGroupID, 0 );

Usage example

i5 = GetDbCookieInt(talker, BuffCookieGroupID, i1+1);
if ((i4 == i6) && (i5 == state)) { i0 = i2; i2 = i3+1; }

SetDbCookieIntNPC🟢 high

write an integer to a group and save to the database

Writes an integer value to a group by key and immediately saves it to the database. If the key did
not yet exist, it is created. Arguments: the player, the group identifier, the key, the value.

Signature

SetDbCookieInt( CSharedCreatureData cCreature, int nGroupId, int nCookieId, int64 nValue )

Parameters

cCreature (CSharedCreatureData) — the player for whom the value is written to DbCookie
nGroupId (int) — the cookie group identifier
nCookieId (int) — the key of the written value within the group
nValue (int64) — the written value

Example

SetDbCookieInt(talker, @AbilityCheckCookieGroup, 7, 1);

LoadDbCookieGroupNPC🟢 high

load one group from the database

Loads one specified cookie group from the database and along the way calls an event about its loading.
Arguments: the player and the group identifier.

Signature

LoadDbCookieGroup( CSharedCreatureData cCreature, int nGroupId )

Parameters

cCreature (CSharedCreatureData) — the player whose cookie group is loaded from the database
nGroupId (int) — the identifier of the loaded cookie group

Example

LoadDbCookieGroup( talker, BuffCookieGroupID );

Usage example

if ( reply == 4 ) { // start working with buffs
    LoadDbCookieGroup( talker, BuffCookieGroupID );
    return;
}

LoadDbCookieAllGroupsNPC🟢 high

load all of a character's groups

Loads all of a character's cookie groups from the database at once. The single argument is the player.

Signature

LoadDbCookieAllGroups( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player all of whose cookie groups are loaded from the database

Example

LoadDbCookieAllGroups(talker);

DeleteDbCookieGroupNPC🟢 high

delete an entire group

Deletes the specified cookie group entirely — both from memory and from the database. Arguments: the player and
the group identifier.

Signature

DeleteDbCookieGroup( CSharedCreatureData cCreature, int nGroupId )

Parameters

cCreature (CSharedCreatureData) — the player from whom the cookie group is deleted
nGroupId (int) — the identifier of the deleted cookie group

Example

DeleteDbCookieGroup( talker, BuffCookieGroupID );

Usage example

if ( reply == 8 ) { // deleting profileS
    DeleteDbCookieGroup( talker, BuffCookieGroupID );
    ShowPage( talker, fn_BuffProfilesDelOk );
    return;
}

SetDbDataNPC🟢 high

insert or update a table row

Works with an arbitrary database table. Takes a dozen string parameters: the first
play the role of keys, the rest — of data. Inserts a new row or updates an existing one.
The semantics of the keys and data are reconstructed from calls.

Signature

SetDbData( string pws1, string pws2, string pws3, string pws4, string pws5, string pws6, string pws7, string pws8, string pws9, string pws10 )

Parameters

pws1 (string) — the first key parameter of the row (table name/primary key)
pws2 (string) — a key/data parameter of the row
pws3 (string) — a key/data parameter of the row
pws4 (string) — a key/data parameter of the row
pws5 (string) — a data parameter of the row
pws6 (string) — a data parameter of the row
pws7 (string) — a data parameter of the row
pws8 (string) — a data parameter of the row
pws9 (string) — a data parameter of the row
pws10 (string) — a data parameter of the row (unused ones passed as `_blank`)

Example

SetDbData("za_monolit", "0", "0", "0", "0", "0", "0", "0", "0", s1);
SetDbData( config_ID, s0, "0", "0", "-1", "-1", "0", _blank, _blank, _blank );

Usage example

if ( reply > 0 ) {
    SetDbData( "SUB_USER", talker.name, "MAIN: " + talker.subjob0_class, "SUB1: " + talker.subjob1_class, "SUB2: " + talker.subjob2_class, "SUB3: " + talker.subjob3_class, "LV: " + talker.level, IntToStr( talker.dbid ), "reply: " + reply , "level: " + level );
} else {
    SetDbData( "SUB_USER", talker.name, "Error on SET_SUBJOB_AS_MAIN", _blank, _blank, _blank, _blank, _blank, _blank, _blank );
}

GetDbDataNPC🟢 high

request table rows (asynchronously)

Requests table rows by criteria (the same ten string parameters). The request is
asynchronous: the rows arrive not immediately, but later — in the return event, where the number of found
rows lies in the first integer parameter. Unused parameters are passed as _blank.

Signature

GetDbData( string pws1, string pws2, string pws3, string pws4, string pws5, string pws6, string pws7, string pws8, string pws9, string pws10 )

Parameters

pws1 (string) — the first selection criterion (table name/key)
pws2 (string) — a row selection criterion
pws3 (string) — a row selection criterion
pws4 (string) — a row selection criterion
pws5 (string) — a row selection criterion
pws6 (string) — a row selection criterion
pws7 (string) — a row selection criterion
pws8 (string) — a row selection criterion
pws9 (string) — a row selection criterion
pws10 (string) — a row selection criterion (unused ones passed as `_blank`)

Example

    GetDbData( tiat_top_dbname, "top10", _blank, _blank, _blank, _blank, _blank, IntToStr( myself.i_quest9 ), _blank, _blank );

Related event: the server's response arrives as the GETDBDATA_RETURNED event (see NASC_HANDLERS).

DelDbDataNPC🟢 high

delete rows by criteria

Deletes from a table the rows matching the passed criteria (ten string
parameters, unused ones — _blank).

Signature

DelDbData( string pws1, string pws2, string pws3, string pws4, string pws5, string pws6, string pws7, string pws8, string pws9, string pws10 )

Parameters

pws1 (string) — the first deletion criterion (table name/key)
pws2 (string) — a row deletion criterion
pws3 (string) — a row deletion criterion
pws4 (string) — a row deletion criterion
pws5 (string) — a row deletion criterion
pws6 (string) — a row deletion criterion
pws7 (string) — a row deletion criterion
pws8 (string) — a row deletion criterion
pws9 (string) — a row deletion criterion
pws10 (string) — a row deletion criterion (unused ones passed as `_blank`)

Example

DelDbData( db_type, s0, s1, _blank, _blank, _blank, _blank, _blank, _blank, _blank );

Usage example

if ( i2 == 0 && (i0 == 0) && (i1 == 0) ) { // change the season on Sunday, at 00:00
    DelDbData( tiat_top_dbname_season, IntToStr( myself.i_quest9 ), _blank, _blank, _blank, _blank, _blank, _blank, _blank, _blank ); // delete the record about the previous season
    myself.i_quest9 = myself.i_quest9 + 1;
    SetDbData( tiat_top_dbname_season, IntToStr( myself.i_quest9 ), _blank, _blank, _blank, _blank, _blank, _blank, _blank, _blank ); // write the current value
}

DelDbDataByIdNPC🟢 high

delete a row by numeric identifier

Deletes one table row by its numeric identifier — the fastest way to delete.

Signature

DelDbDataById( int nId )

Parameters

nId (int) — the numeric identifier of the deleted table row

Example

DelDbDataById( myself.db_int_list.Get( i1 ) );
DelDbDataById( myself.db_int_list.Get( 0 ) );

Usage example

for( i1=0; i1<i0; ++i1 ) {
    DelDbDataById( myself.db_int_list.Get( i1 ) );
}

GetAllUserForInZoneNPC🟢 high

request all players in a zone (asynchronously)

Requests the list of all players in the current zone. The list arrives asynchronously — in an event,
where each player becomes a target, and their total number lies in the first integer parameter.

Signature

GetAllUserForInZone(  )

Parameters

(none — the function is called without arguments)

Example

GetAllUserForInZone( );

Usage example

if (myself.sm.flag != 2) {
    GetAllUserForInZone();
    myself.av_ai0.Increment(1);
    AddTimerEx(1001, 1000);
}

NR-MEMO / LOG / COOKIE (persistent state memory)

14 functions

HaveNRMemoGLOBAL🟢 high

is there an NR marker

Checks whether the given quest/event's NR marker is set on the player. Arguments: the player and
nQuestId ([quest_pch], a @-constant). Returns 1 if the marker exists, otherwise 0.

Signature

HaveNRMemo( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — the player whose NR marker is checked
nQuestId  (int) — the choice of quest/event whose marker presence is checked (a quest `@`-constant)
    the values are from the [quest_pch] dictionary

Example

if (HaveNRMemo(talker, @dominion_war_state) == @FALSE)

Usage example

if (HaveNRMemo(talker, @defend_catapult_of_dom) == @TRUE)
{
    SetNRMemoState(talker, @defend_catapult_of_dom, 100);
}

GetNRMemoStateGLOBAL🟢 high

read an NR state

Reads the numeric NR state bound to a quest/event (the persistent analog of GetMemoState).
Arguments: the player and nQuestId ([quest_pch], a @-constant). Returns the stored number.

Signature

GetNRMemoState( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — the player whose NR state is read
nQuestId  (int) — the choice of quest/event whose state is read (a quest `@`-constant)
    the values are from the [quest_pch] dictionary

Example

i0 = GetNRMemoState(talker, @dominion_war_state);

Usage example

i6 = GetNRMemoState(talker, i10);
if (i6 >= 0)
{
    i7 = GetNRMemoState(talker, @dominion_war_state);
    SetNRMemoState(talker, @dominion_war_state, (i6 + i7));
    RemoveNRMemo(talker, i10);
    AddLog(2, talker, i10);
}

GetNRMemoStateExGLOBAL🟢 high

read an additional NR-state slot

Reads an additional NR-state slot (several cells per one quest, like GetMemoStateEx).
Arguments: the player, nQuestId ([quest_pch], a @-constant), and nSlot — the slot number. Returns
the number stored in the slot.

Signature

GetNRMemoStateEx( CSharedCreatureData cCreature, int nQuestId, int nSlot )

Parameters

cCreature (CSharedCreatureData) — the player whose additional NR-state slot is read
nQuestId  (int) — the choice of quest/event whose state is read (a quest `@`-constant)
    the values are from the [quest_pch] dictionary
nSlot     (int) — the number of the additional state slot

Example

if (i4 != GetNRMemoStateEx(talker, @dominion_war_state, 1))

Usage example

if (i4 != GetNRMemoStateEx(talker, @dominion_war_state, 1))
{
    SetNRMemoState(talker, @dominion_war_state, 0);
    SetNRMemoStateEx(talker, @dominion_war_state, 1, i4);
}

SetNRMemoNPC🟢 high

set a persistent NR marker of contact with a quest/event

Sets on the player the NR marker "contact with a quest/event" — an analog of SetMemo, but persistent
(not reset when quests are cleared). Arguments: the player and nQuestId (resolved from
[quest_pch], i.e. a @-constant of the quest/event). Returns an int.

Signature

SetNRMemo( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — the player on whom the NR marker is set
nQuestId  (int) — the choice of quest/event whose marker is set (a quest `@`-constant)
    the values are from the [quest_pch] dictionary

Example

SetNRMemo(talker, @dominion_war_state);

Usage example

if (GetDailyQuestFlag(target, @destory_shield) == @TRUE) {
    SetNRMemo(target, @destory_shield);
    AddLog(1, target, @destory_shield);
    SetNRMemoState(target, @destory_shield, i5);
    ShowOnScreenMsgFStr(target, 2, 0, 0, 0, 1, 0, 5000, 0, 73451, IntToStr(i5), _blank, _blank, _blank, _blank);
}

RemoveNRMemoNPC🟢 high

remove a persistent NR marker

Removes from the player a previously set NR marker (an analog of RemoveMemo). Arguments: the player and
nQuestId ([quest_pch], a @-constant of the quest/event). Returns an int.

Signature

RemoveNRMemo( CSharedCreatureData cCreature, int nQuestId )

Parameters

cCreature (CSharedCreatureData) — the player from whom the NR marker is removed
nQuestId  (int) — the choice of quest/event whose marker is removed (a quest `@`-constant)
    the values are from the [quest_pch] dictionary

Example

RemoveNRMemo(talker, @defend_catapult_of_dom);

Usage example

if ( HaveNRMemo( talker, @defend_catapult_of_dom ) == 1 ) {
    RemoveNRMemo( talker, @defend_catapult_of_dom );
    AddLog( 2, talker, 729 );
}

SetNRMemoStateNPC🟢 high

write an NR state

Writes a numeric NR state for a quest/event (a persistent analog of SetMemoState).
Arguments: the player, nQuestId ([quest_pch], a @-constant), and nValue — the written number.
Returns an int.

Signature

SetNRMemoState( CSharedCreatureData cCreature, int nQuestId, int nValue )

Parameters

cCreature (CSharedCreatureData) — the player whose NR state is written
nQuestId  (int) — the choice of quest/event for which the state is written (a quest `@`-constant)
    the values are from the [quest_pch] dictionary
nValue    (int) — the written numeric state

Example

SetNRMemoState(talker, @dominion_war_state, 0);

Usage example

if (HaveNRMemo(talker, @defend_catapult_of_dom) == @TRUE) {
    SetNRMemoState(talker, @defend_catapult_of_dom, i0);
    SetNRMemoStateEx(talker, @defend_catapult_of_dom, 1, i3);
    AddLog(1, talker, @defend_catapult_of_dom);
    ShowQuestMark(talker, @defend_catapult_of_dom);
    SoundEffect(talker, "ItemSound.quest_middle");
}

SetNRMemoStateExNPC🟢 high

write an additional NR-state slot

Writes a value into an additional NR-state slot (several cells per quest, like
SetMemoStateEx). Arguments: the player, nQuestId ([quest_pch], a @-constant), nSlot — the slot number,
and nValue — the written number. Returns an int.

Signature

SetNRMemoStateEx( CSharedCreatureData cCreature, int nQuestId, int nSlot, int nValue )

Parameters

cCreature (CSharedCreatureData) — the player whose additional NR-state slot is written
nQuestId  (int) — the choice of quest/event for which the state is written (a quest `@`-constant)
    the values are from the [quest_pch] dictionary
nSlot     (int) — the number of the additional state slot
nValue    (int) — the number written into the slot

Example

SetNRMemoStateEx(talker, @dominion_war_state, 1, i4);

GetNRMemoCountNPC🟢 high

the number of NR markers on the player

Returns the number of NR markers set on the player (a persistent analog of GetMemoCount).
The single argument is the player. Returns an int.

Signature

GetNRMemoCount( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the player whose number of NR markers is counted

Example: there are no direct calls in our scripts.

SetNRFlagJournalNPC🟢 high

set the journal flag of an NR event

Sets a flag (bit/step) of the NR-event journal — a visible progress mark (an analog of
SetFlagJournal). Arguments: the player, nQuestId ([quest_pch], a @-constant or a variable with the id), and
nFlag — the flag-step (in calls accumulated with values like 3..11). Returns nothing.

Signature

SetNRFlagJournal( CSharedCreatureData cCreature, int nQuestId, int nFlag )

Parameters

cCreature (CSharedCreatureData) — the player for whom the NR-event journal flag is set
nQuestId  (int) — the choice of quest/event whose journal is marked (a quest `@`-constant)
    the values are from the [quest_pch] dictionary
nFlag     (int) — the set journal progress flag-step

Example

SetNRFlagJournal(talker, i10, 1);

SetJournalNPC🟢 high

set an ordinary quest journal flag

Sets an ordinary (resettable) quest-journal flag-step — a visible progress mark.
Arguments: the player, nQuestId ([quest_pch], a @-constant), and nStep — the step number. Returns
nothing.

Signature

SetJournal( CSharedCreatureData cCreature, int nQuestId, int nStep )

Parameters

cCreature (CSharedCreatureData) — the player for whom the quest journal flag is set
nQuestId  (int) — the choice of quest whose journal is marked (a quest `@`-constant)
    the values are from the [quest_pch] dictionary
nStep     (int) — the number of the set journal step

Example

SetJournal( talker, @the_wishing_potion, 1 );

GetHTMLCookieNPC🟢 high

read a dialog/quest stage cookie

Reads the "cookie" of dialog/quest stage progress bound to the shown HTML. Arguments:
the player, nQuestId ([quest_pch], a @-constant), and nIndex — the stage/cookie number. Returns -1
if the stage is not yet marked.

Signature

GetHTMLCookie( CSharedCreatureData cCreature, int nQuestId, int nIndex )

Parameters

cCreature (CSharedCreatureData) — the player whose dialog/quest stage cookie is read
nQuestId  (int) — the choice of quest to which the stage is bound (a quest `@`-constant)
    the values are from the [quest_pch] dictionary
nIndex    (int) — the stage/cookie number

Example

i0 = GetHTMLCookie( talker, @the_ocean_of_distant_stars, 3 );

SetHTMLCookieNPC🟢 high

mark a dialog/quest stage cookie

Marks that the player has passed a dialog/quest stage (a cookie of the shown HTML), so that on a repeat
entry the dialog immediately shows the needed page. Arguments: the player, nQuestId ([quest_pch],
a @-constant), and nIndex — the stage/cookie number. Returns nothing.

Signature

SetHTMLCookie( CSharedCreatureData cCreature, int nQuestId, int nIndex )

Parameters

cCreature (CSharedCreatureData) — the player for whom the passed dialog/quest stage is marked
nQuestId  (int) — the choice of quest to which the stage is bound (a quest `@`-constant)
    the values are from the [quest_pch] dictionary
nIndex    (int) — the stage/cookie number

Example

SetHTMLCookie( talker, @the_ocean_of_distant_stars, 3 );

Usage example

if ( GetMemoState( talker, @into_the_flame ) == ( ( 2 * 10 ) + 2 ) && OwnItemCount( talker, @q_vacualite_ore ) >= 50 ) {
    SetHTMLCookie( talker, 618, 2 );
    ShowPage( talker, "blacksmith_byron_q0618_0202.htm" );
} else {
    ShowPage( talker, "blacksmith_byron_q0618_0203.htm" );
}

GetCookieNPC🟢 high

read a named state value

Reads an arbitrary named state value on the player by a string key (unlike
memo/HTML-cookie, the key is given by a string, not a quest-id). Arguments: the player and sKey —
the string key. Returns the stored number.

Signature

GetCookie( CSharedCreatureData cCreature, string sKey )

Parameters

cCreature (CSharedCreatureData) — the player whose named state is read
sKey      (string) — the string key of the read value

Example

if ( OwnItemCount( talker, @adena ) >= GetCookie( talker, "AgitDecoFee" ) ) {

Usage example

i1 = GetCookie( talker, "gate_level" );
if ( i0 == 1 && i1 == 200 ) {
    i2 = DDoorPrice1_1;
}

SetCookieNPC🟢 high

write a named state value

Writes an arbitrary named state value on the player by a string key — into it the
script saves computed parameters between dialog steps (a service price, a branch choice, zone/gate
numbers, a manor id). Arguments: the player, sKey — the string key, and nValue — the written number.

Signature

SetCookie( CSharedCreatureData cCreature, string sKey, int nValue )

Parameters

cCreature (CSharedCreatureData) — the player for whom the named state is written
sKey      (string) — the string key of the written value
nValue    (int) — the written number

Example

SetCookie( talker, "AgitDecoFee", Agit_GetDecoFee( i0, i1 ) );

Usage example

if ( reply == 2 ) {
    SetCookie( talker, "dmgzone_num", 2 );
}

CASTLES, SIEGES, AND FORTRESSES (Castle / Siege / Fortress)

53 functions

Fortress_GetOwnerPledgeIdGLOBAL🟢 high

fortress owner

Returns the id of the clan owning fortress nFortressId. If the fortress is not captured by anyone — returns 0,
so checking the result > 0 tells whether the fortress has an owner.

Signature

Fortress_GetOwnerPledgeId( int nFortressId )

Parameters

nFortressId (int) — identifier of the fortress whose owning clan is queried

Usage example

if ( Fortress_GetOwnerPledgeId( fortress_id ) > 0 ) {
    return;
}

Fortress_GetParentCastleIdGLOBAL🟢 high

parent castle of a fortress

Returns the identifier of the fortress's parent castle. Purpose inferred from the name;
direct calls were not analyzed.

Signature

Fortress_GetParentCastleId( int nFortressId )

Parameters

nFortressId (int) — identifier of the fortress whose parent castle is queried

Example

Fortress_GetParentCastleId(fortress_id);

Fortress_GetFacilityLevelGLOBAL🟢 high

fortress facility level

Returns the level of the specified facility of fortress nFortressId. A fortress has five facility
types (nFacilityType 0..4, see below); for an unknown type -1 is returned. The level
shows how upgraded the facility is (guard reinforcement, gates, etc.).

Signature

Fortress_GetFacilityLevel( int nFortressId, int nFacilityType )

Parameters

nFortressId   (int) — identifier of the fortress whose facilities are queried
nFacilityType (int) — fortress facility type. Values @FORTRESS_* [manual_pch]:
    0 GUARD_REINFORCEMENT · 1 GUARD_POWER_UP · 2 DOOR_POWER_UP · 3 PHOTOCANNON · 4 SCOUT

Usage example

i0 = Fortress_GetFacilityLevel( fortress_id, facility_type );
if ( i0 < facility_level ) {
    return;
}

Fortress_GetRentCostGLOBAL🟢 high

fortress rent cost

Returns the maintenance cost of fortress nFortressId — the amount (in adena) that the owning clan
periodically pays to keep the fortress. Used in fortress manager dialogs to display
and deduct the fee.

Signature

Fortress_GetRentCost( int nFortressId )

Parameters

nFortressId (int) — identifier of the fortress whose maintenance cost is returned

Example

i6 = Fortress_GetRentCost( fortress_id );

GetDominionStateGLOBAL🟢 high

territory war state

Returns the state code of the territory war (Dominion) for territory nResidenceId.
Non-zero values correspond to active phases of the siege cycle: in the example, states 1 and 2
enable additional respawn of objects on the territory.

Signature

GetDominionState( int nResidenceId )

Parameters

nResidenceId (int) — identifier of the residence/territory whose state is queried

Usage example

i1 = GetDominionState(dominion_id);
if (i1 == 1 || i1 == 2) {
    if (deleted_def.respawn_time != 0) {
        if (AtomicIncreaseTotal(deleted_def, 1, 1)) {
            deleted_def.Spawn2(1, deleted_def.respawn_time, deleted_def.respawn_rand);
        }
    }
}

Castle_GetPledgeStateNPC🟢 high

a creature's relation to the castle (friend/foe)

Returns the creature c's relation to this NPC's castle — the basis of the "friend or foe" logic
during a siege. The argument c (CSharedCreatureData) — whom we check. A value of 2 means
belonging to the side owning the castle (a member of the owner clan or a defender): guards
do not attack those whose state is 2, and are hostile to the rest; for summons the state of
their owner (attacker.master) is checked.

Signature

Castle_GetPledgeState( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — whom we check.

Example

if (IsInCategory(@summon_npc_group, speller.npc_class_id) != 0 && Castle_GetPledgeState(speller.master) == 2) {

Usage example

if ( Castle_GetPledgeState( creature ) != 2 ) {
    AddAttackDesire( creature, @AMT_STAND, 200 );
}

Castle_IsUnderSiegeNPC🟢 high

is the castle currently under siege

Returns whether this NPC's castle is currently under siege (1/0), no arguments. By this flag
guards switch behavior between peaceful and combat mode (aggression to foes,
opening or closing gates). There is a version Castle_IsUnderSiege2(nCastleId) — for
a specific castle by identifier.

Signature

Castle_IsUnderSiege(  )

Parameters

(none — the function is called without arguments)

Example

if (Castle_IsUnderSiege() == @TRUE)

Usage example

if ( Castle_IsUnderSiege( ) != 0 ) {
    Say( "Castle is Under Attack..." );
}

Castle_GetPledgeIdNPC🟢 high

the identifier of the castle's owner clan

Returns the identifier of this NPC's castle's owner clan, no arguments. It is often
compared with the player's affiliation (talker.pledge_id), so that together with a
clan-privilege check it decides whether the player belongs to the owning clan.

Signature

Castle_GetPledgeId(  )

Parameters

(none — the function is called without arguments)

Example

if (Castle_GetPledgeId())

Usage example

if ( Castle_GetPledgeId( ) == talker.pledge_id && talker.pledge_id != 0 ) {
    ShowPage( talker, "farm_kel_mahum_messenger_25.htm" );
    return;
}

Castle_GetPledgeNameNPC🟢 high

the name of the castle's owner clan

Returns a string with the name of this NPC's castle's owner clan, no arguments.
Used to show the player information about the castle's owner.

Signature

Castle_GetPledgeName(  )

Parameters

(none — the function is called without arguments)

Example

FHTML_SetStr(fhtml0, "my_pledge_name", Castle_GetPledgeName());

Castle_GetOwnerNameNPC🟢 high

the castle owner's name

Returns a string with the name of this NPC's castle's owner itself, no arguments.
Used to show the player information about the owner.

Signature

Castle_GetOwnerName(  )

Parameters

(none — the function is called without arguments)

Example

FHTML_SetStr(fhtml0, "my_owner_name", Castle_GetOwnerName());

Castle_GateOpenCloseNPC🟢 high

open/close the castle gates

Opens or closes the gates of this NPC's castle. The argument nState (int, from [manual_pch])
sets the state: @CGOC_OPEN=0 open, @CGOC_CLOSE=1 close. Available to the owner
or a lord with the privilege @PP_OPEN_CASTLE_DOOR. The global variants
Castle_GateOpenClose2(sGate, nState) and ...Ex(sGate, nState, nZoneId) (on gg)
address specific gates by name — see the doors, gates, and areas group.

Signature

Castle_GateOpenClose( int nState )

Parameters

nState (int) — the gate state (manual_pch):
    @CGOC_OPEN (0) — open; @CGOC_CLOSE (1) — close.

Example

Castle_GateOpenClose(@CGOC_OPEN);
Castle_GateOpenClose( 0 );
Castle_GateOpenClose( 1 );
Castle_GateOpenClose(@CGOC_CLOSE);

Castle_GetSiegeTimeNPC🟢 high

the time of the nearest siege

Returns a string with the time of the castle's nearest siege, no arguments. Intended for
showing to the player.

Signature

Castle_GetSiegeTime(  )

Parameters

(none — the function is called without arguments)

Example

if (Castle_GetSiegeTime() != "")

Usage example

if ( Castle_GetSiegeTime( ) != _blank ) {
    FHTML_SetFileName( fhtml0, "farm_messenger_q0655_11.htm" );
    FHTML_SetStr( fhtml0, "next_siege", Castle_GetSiegeTime( ) );
    ShowFHTML( talker, fhtml0 );
}

RegisterSiegeNPC🟢 high

register a clan as a siege attacker

Registers the clan of the player c (CSharedCreatureData) as a siege attacker. Returns
nothing.

Signature

RegisterSiege( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the player whose clan is registered as a siege attacker

Example (illustrative):

    RegisterSiege( talker );

RegisterSiegeDefenderNPC🟢 high

register a clan as a siege defender

By design — registers the clan of the player c (CSharedCreatureData) as a castle siege defender. IMPORTANT: in
this server build (CT2.3) the call actually does nothing — like the whole castle siege registration
family (RegisterSiege/UnregisterSiege/CheckSiege), the recording of defenders has been moved to the community board.
The function is left for compatibility with old scripts.

Signature

RegisterSiegeDefender( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the player whose clan is registered as a siege defender

Example (illustrative):

    RegisterSiegeDefender( talker );

OpenSiegeInfoNPC🟢 high

open the siege information window

Opens for the player c (CSharedCreatureData) a window with siege information. Returns
nothing.

Signature

OpenSiegeInfo( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player for whom the siege information window is opened

Example

OpenSiegeInfo(talker);

Usage example

if ( IsMyLord( talker ) || ( HavePledgePower( talker, @ppSiege ) && Castle_GetPledgeId( ) == talker.pledge_id && talker.pledge_id != 0 ) ) {
    OpenSiegeInfo( talker );
} else {
    ShowPage( talker, fnNoAuthority );
}

Castle_BanishOthersNPC🟢 high

banish outsiders from the castle

Banishes from this NPC's castle (residence) zone all outsiders — players not in the
owner clan. No arguments: the residence is taken by the NPC itself. Corresponds to the
"Banish Outsiders" button in the castle management menu.

Signature

Castle_BanishOthers(  )

Parameters

(none — the function is called without arguments)

Example

Castle_BanishOthers();

Usage example

if ( IsMyLord( talker ) || ( HavePledgePower( talker, @ppClanHallBanish ) && Castle_GetPledgeId( ) == talker.pledge_id && talker.pledge_id != 0 ) ) {
    Castle_BanishOthers( );
    ShowPage( talker, fnAfterBanish );
} else {
    ShowPage( talker, fnNoAuthority );
}

Castle_GetHPRegenNPC🟢 high

HP regen in the castle zone

Returns the level (grade) of the installed residence function "HP Restore" of this NPC's
castle. This is one of the paid residence functions (an analog of clan hall functions): its level
is set by Castle_SetHPRegen and determines the strength of the HP regeneration bonus on the territory. No
arguments — works by the NPC's own residence; if the function is not installed, returns 0.

Signature

Castle_GetHPRegen(  )

Parameters

(none — the function is called without arguments)

Example

Castle_GetHPRegen( );

Castle_SetHPRegenNPC🟢 high

set HP regen in the castle zone

Installs (or removes) the residence function "HP Restore" of the castle at the given level.
At nLevel>0 the function is enabled for 7 days; at nLevel=0 — it is removed. The residence is taken by
the NPC itself.

Signature

Castle_SetHPRegen( int nLevel )

Parameters

    nLevel (int) — the level (grade) of the residence's HP restore function; >0 — install for
                   7 days, 0 — remove the function.

Example (illustrative):

    Castle_SetHPRegen( nLevel );

Castle_GetMPRegenNPC🟢 high

MP regen in the castle zone

Returns the level (grade) of the installed residence function "MP Restore" of this NPC's
castle — an analog of Castle_GetHPRegen for MP (a function of type 1). The level is set by Castle_SetMPRegen and
determines the strength of the MP regeneration bonus on the territory. No arguments — by the NPC's own
residence; if the function is not installed, returns 0.

Signature

Castle_GetMPRegen(  )

Parameters

(none — the function is called without arguments)

Example

Castle_GetMPRegen( );

Castle_SetMPRegenNPC🟢 high

set MP regen in the castle zone

Installs (or removes) the residence function "MP Restore" of the castle at the given level —
an analog of Castle_SetHPRegen for MP. At nLevel>0 the function is enabled for 7 days; at nLevel=0 —
it is removed. The residence is taken by the NPC itself.

Signature

Castle_SetMPRegen( int nLevel )

Parameters

    nLevel (int) — the level (grade) of the residence's MP restore function; >0 — install for
                   7 days, 0 — remove the function.

Example (illustrative):

    Castle_SetMPRegen( nLevel );

Castle_GetLifeControlLevelNPC🟢 high

the castle's "life control" level

Returns the configured "life control" level of this NPC's castle/residence (no arguments —
works by the NPC's own residence). If the NPC has no bound residence, returns 0; otherwise it
reads the level from the residence's static data. This is an upgrade-level getter (affects the tier
of the regeneration bonus on the castle's territory); the bonus itself is applied by other code.

Signature

Castle_GetLifeControlLevel(  )

Parameters

(none — the function is called without arguments)

Example

if (Castle_IsUnderSiege() == @TRUE && Castle_GetLifeControlLevel() == 0) {

Usage example

if ( Castle_IsUnderSiege( ) && Castle_GetLifeControlLevel( ) == 0 ) {
    ShowPage( talker, fnBrokenCtrlTower );
} else {
    ShowPage( talker, fnHi );
}

Castle_GetRawSiegeTimeNPC🟢 high

the raw siege time (number)

Returns the "raw" start time of this NPC's castle's nearest siege — as an integer timestamp
in seconds (unlike the formatted Castle_GetSiegeTime). Convenient for arithmetic with
time: in the example below a quest script compares it with the system time (Castle_GetRawSystemTime)
and with a saved memo mark, to catch a daily window (86400 s) and make sure the siege is still in the
future. No arguments — by the NPC's own castle.

Signature

Castle_GetRawSiegeTime(  )

Parameters

(none — the function is called without arguments)

Usage example

if ( _from_choice == 0 || ( HaveMemo( talker, @competition_for_the_bandit_stronghold ) == 1 && OwnItemCount( talker, @q_contest_certificate ) > 0 && OwnItemCount( talker, @q_tarlk_amulet ) < 30 && ( Castle_GetRawSiegeTime( ) - GetMemoState( talker, @competition_for_the_bandit_stronghold ) ) < 86400 && ( Castle_GetRawSiegeTime( ) - Castle_GetRawSystemTime( ) ) > 0 ) ) {
    SetCurrentQuestID( @competition_for_the_bandit_stronghold );
    ShowPage( talker, "azit_messenger_q0504_07.htm" );
}

Castle_SetSiegeTimeNPC🟢 high

set the siege time setting

Sets the date/time of the castle's nearest siege. Per the L2NPC decompile (CNPC::Castle_SetSiegeTime_48B04C)
the engine takes the nearest "siege" day, zeroes it to midnight, then adds offsets from the
arguments and sends the server the computed timestamp (packet opcode 13). The first two arguments are
boolean shifts (+1 day and +12 hours), the last two are the hour and minute of the siege start.

Signature

Castle_SetSiegeTime( int nAddDay, int nAddHalfDay, int nHour, int nMinute )

Parameters

    nAddDay (int) — the base-day shift: 1 = +1 day, 0 = no shift (engine: +86400 s).
    nAddHalfDay (int) — a half-day shift: 1 = +12 hours, 0 = no shift (engine: +43200 s).
    nHour (int) — the siege start hour (added as 3600·nHour).
    nMinute (int) — the siege start minute (added as 60·nMinute).

Example (illustrative):

    Castle_SetSiegeTime( nAddDay, nAddHalfDay, nHour, nMinute );

ShowSetSiegeTimeNPC🟢 high

show the right HTML page of the siege-scheduling window

Shows the player one of three HTML pages depending on the siege state of this NPC's
residence. Per the L2NPC decompile (CNPC::ShowSetSiegeTime_4ACEE8) the engine reads the
residence data and calls ShowPage with one of three pages: if a siege is already scheduled for the
future — the third page; otherwise if the flag "time was already scheduled in the current cycle" is set —
the second; otherwise (the time can be set) — the first. That is, the three arguments are the names of HTML pages,
not the time text.

Signature

ShowSetSiegeTime( CSharedCreatureData c, string sPageCanSet, string sPageRegistered, string sPageScheduled )

Parameters

    c (CSharedCreatureData) — the player who is shown the page.
    sPageCanSet (string) — the HTML page when no siege is scheduled and the time can be set (the default branch).
    sPageRegistered (string) — the HTML page when the flag "time was already scheduled in the current cycle" is set.
    sPageScheduled (string) — the HTML page when a siege is already scheduled for the future (the time is in the future).

Example (illustrative):

    ShowSetSiegeTime( talker, "", "", "" );

Castle_GetRelatedFortressListNPC🟢 high

the list of fortresses related to the castle

Requests the list of fortresses "related" to this NPC's castle — fortresses that have concluded a contract/agreement
with the castle. The function is asynchronous: the result arrives as a separate event (see below). The argument c —
the request's context creature.

Signature

Castle_GetRelatedFortressList( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature by whose castle the list of related fortresses is taken

Example

    Castle_GetRelatedFortressList(talker);

Related event: the server's response arrives as the GET_RELATED_FORTRESS_LIST_RETURNED event (see NASC_HANDLERS).

CheckSiegeNPC🟢 high

check siege registration

By design — checks the creature c's clan's registration for a castle siege. IMPORTANT: in this server build
(CT2.3) the call actually does nothing — the registration and checking of castle sieges have been moved to the
community board. The function is left for compatibility with old scripts.

Signature

CheckSiege( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the creature whose clan registration is checked for a siege

Example (illustrative):

    CheckSiege( talker );

UnregisterSiegeNPC🟢 high

remove siege registration

By design — removes the creature c's clan's registration for a castle siege. IMPORTANT: in this server build
(CT2.3) the call actually does nothing — the castle siege registration (and its cancellation) has been moved to the
community board. The function is left for compatibility with old scripts.

Signature

UnregisterSiege( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the creature whose clan registration is removed from the siege

Example (illustrative):

    UnregisterSiege( talker );

ViewSiegeListNPC🟢 high

the siege list

Shows the player c the list of registered sieges, rendered into the passed HTML page
sPage. If sPage is an empty string, the list is not shown. Unlike CheckSiege and
UnregisterSiege, in this build the function works.

Signature

ViewSiegeList( CSharedCreatureData c, string sPage )

Parameters

    c (CSharedCreatureData) — the player who is shown the siege list.
    sPage (string) — the name of the HTML page of the siege-list window; an empty string is not accepted (the list will not be shown).

Example (illustrative):

    ViewSiegeList( talker, "" );

Fortress_GetStateNPC🟢 high

the fortress state

Returns the code of the current state of the fortress nFortressId (the ownership/contract stage). By this code
fortress scripts branch their logic: for example, by comparison with 0 they distinguish an unowned fortress from
one occupied by a clan.

Signature

Fortress_GetState( int nFortressId )

Parameters

nFortressId (int) — the identifier of the fortress whose state is requested

Example

if ( Fortress_GetState( fortress_id ) == 0 ) {

Fortress_GetSiegeStatusNPC🟢 high

the fortress siege state

Returns the siege-state code of the fortress nFortressId (no siege / siege in progress and its phase). Allows
fortress scripts to understand what stage the siege cycle is in.

Signature

Fortress_GetSiegeStatus( int nFortressId )

Parameters

    nFortressId (int) — the identifier of the fortress whose siege state is requested

Example (illustrative):

    Fortress_GetSiegeStatus( nFortressId );

Fortress_PledgeRegisterNPC🟢 high

register a clan for a fortress

Registers the player's clan as a contender for the fortress nFortressId (an application for a fortress siege/capture).
The action is initiated by the NPC managing the fortress on behalf of the arriving player.

Signature

    Fortress_PledgeRegister( int nNpcId, int nUserId, int nFortressId )

Parameters (per real calls — myself.sm.id, talker.id, fortress_id):
    nNpcId      (int) — the id of the NPC source of the action (myself.sm.id).
    nUserId     (int) — the player id (talker.id).
    nFortressId (int) — the identifier of the fortress the player's clan is registered for.

Example

Fortress_PledgeRegister(myself.sm.id, talker.id, fortress_id);

Fortress_BarrackCapturedNPC🟢 high

the fortress barrack capture event

Reports the capture of a barrack during a fortress siege: marks the barrack nBarrackId of the fortress nFortressId
captured. When all the fortress's barracks are captured, the siege ends in favor of the attackers.

Signature

    Fortress_BarrackCaptured( int nNpcId, int nFortressId, int nBarrackId )

Parameters (per real calls — myself.sm.id, fortress_id, barrack_id):
    nNpcId      (int) — the id of the NPC source of the event (myself.sm.id).
    nFortressId (int) — the identifier of the fortress where the barracks are captured.
    nBarrackId  (int) — the identifier of the captured barracks.

Example

Fortress_BarrackCaptured(myself.sm.id, fortress_id, barrack_id);

Fortress_ContractCastleNPC🟢 high

the fortress's contract with a castle

Concludes the agreement of the fortress nFortressId with a castle (the fortress's choice of a suzerain castle — a contract). The function is
asynchronous: the result arrives as a separate event (see below). In calls nArg = -1.

Signature

    Fortress_ContractCastle( int nNpcId, int nUserId, int nFortressId, int nArg )

Parameters (per real calls — myself.sm.id, talker.id, fortress_id, -1):
    nNpcId      (int) — the id of the NPC source of the action (myself.sm.id).
    nUserId     (int) — the player id (talker.id).
    nFortressId (int) — the identifier of the fortress concluding the contract.
    nArg        (int) — the contract parameter (in calls -1).

Usage example

    if ( reply == 1 ) {
        Fortress_ContractCastle( myself.sm.id, talker.id, fortress_id, -1 );
        return;
    }

Related event: the server's response arrives as the FORTRESS_CONTRACT_CASTLE_RETURNED event (see NASC_HANDLERS).

Fortress_OwnerRewardTakenNPC🟢 high

the fortress owner taking the reward

Marks that the owner of the fortress nFortressId took the due periodic reward, and gives
the player the item nItemClassId in the quantity nCount. Protects against re-receiving the owner's
reward.

Signature

    Fortress_OwnerRewardTaken( int nNpcId, int nUserId, int nFortressId, int nItemClassId, int64 nCount )

Parameters (per real calls — myself.sm.id, talker.id, fortress_id, item_medal, i0):
    nNpcId       (int) — the id of the NPC source of the event (myself.sm.id).
    nUserId      (int) — the id of the owner player (talker.id).
    nFortressId  (int) — the identifier of the fortress whose reward is received.
    nItemClassId (int) — the id of the reward item ([item_pch], e.g. item_medal).
    nCount       (int64) — the reward quantity.

Example

Fortress_OwnerRewardTaken(myself.sm.id, talker.id, fortress_id, item_medal, i0);

Agit_GetDecoExpireNPC🟢 high

the end date of a clan hall decoration

A getter for clan hall (agit) decorations. By the decoration type nDecoType returns an int — the moment
of expiration of the installed decoration as a timestamp. In scripts this value
is passed to GetDateTime to extract the year/month/day and show the expiration date in a dialog.

Signature

Agit_GetDecoExpire( int nDecoType )

Parameters

nDecoType (int) — the agit decoration type. Values (script-convention constants):
    1 hpregen · 2 mpregen · 3 cpregen · 6 broadcast · 7 curtain · 8 hanging ·
    9 buff · 10 outerflag · 11 platform · 12 item

Example

IntToStr( GetDateTime( Agit_GetDecoExpire( decotype_hpregen ), 1 ) );

Agit_GetTeleportLevelNPC🟢 high

the agit's teleport level

Returns the level of the teleport function of this NPC's clan hall (agit): 0 — the function is off,
a higher value — the installed upgrade tier. A pair to Agit_SetTeleportLevel.

Signature

Agit_GetTeleportLevel(  )

Parameters

(none — the function is called without arguments)

Example

Agit_GetTeleportLevel( );

Agit_SetTeleportLevelNPC🟢 high

set the agit's teleport level

Sets the teleport level of the clan hall (agit). Described in overview, the exact arguments — in
the source tables.

Signature

Agit_SetTeleportLevel( int nLevel )

Parameters

    nLevel (int) — the level to set for the clan hall's teleport function (0 = off, then the upgrade tiers).

Example (illustrative):

    Agit_SetTeleportLevel( nLevel );

Agit_StartObserverNPC🟢 high

the agit observer

Sends the player c into observer mode (the siege camera of the clan hall/residence) to the point with
coordinates x, y, z. The position is checked against geodata: with an invalid point observation is not
enabled. If the residence nResidenceId is currently under siege — observation is forbidden (the player
receives a system message). Observation lasts 1 hour (3600 s). It is also blocked if the player
is registered for the Olympiad or has a private store open.

Signature

Agit_StartObserver( CSharedCreatureData c, int x, int y, int z, int nCamParam4, int nCamParam5, int nResidenceId )

Parameters

    c (CSharedCreatureData) — the player sent into observer mode.
    x (int) — the X coordinate of the observation point (checked against geodata).
    y (int) — the Y coordinate of the observation point.
    z (int) — the Z coordinate of the observation point.
    nCamParam4 (int) — an observer camera parameter (passed to the client).
    nCamParam5 (int) — an observer camera parameter (passed to the client).
    nResidenceId (int) — the residence id: with an active siege observation is forbidden.

Example (illustrative):

    Agit_StartObserver( talker, x, y, z, nCamParam4, nCamParam5, nResidenceId );

AuctionAgit_GetAgitCostInfoNPC🟢 high

agit auction information

Shows the player c information about the cost of the clan hall (agit) at auction — the price and rental
conditions. Usually called in a manager's dialog after checking that the player is from the owner clan.

Signature

AuctionAgit_GetAgitCostInfo( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature initiating the request for hall cost/auction information

Usage example

if (Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0) {
    AuctionAgit_GetAgitCostInfo(talker);
} else {
    ShowPage(talker, fnNoAuthority);
}

GetDominionSiegeIDNPC🟢 high

the Dominion siege identifier

Returns the siege id of the territory war (Dominion) to which the creature c belongs — by its
territory. The value is used as a base for computing related ids (in the example, other identifiers
are obtained from it by offsets).

Signature

GetDominionSiegeID( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature by which the territory's siege identifier is determined

Usage example

i0 = GetDominionSiegeID( target );
if ( i0 < 90 ) { i1 = ( i0 + 636 ); } else { i1 = ( i0 + 650 ); }

RegisterDominionNPC🟢 high

register in a territory war

Registers the creature c's clan as a participant in the territory war (Dominion) for the territory
nDominionId. Usually called by a castle manager and requires lord/clan-leader authority
(in the example IsMyLord and the clan right are checked).

Signature

RegisterDominion( int nDominionId, CSharedCreatureData c )

Parameters

nDominionId (int) — the identifier of the territory/residence (Dominion) for registering participation (in calls dominion_id).
c (CSharedCreatureData) — the initiator creature (a player or a clan representative).

Usage example

if (IsMyLord(talker) || (HavePledgePower(talker, 18) && Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0)) {
    RegisterDominion(dominion_id, talker);
} else {
    ShowPage(talker, fnNoAuthority);
}

CancelPledgeDominionNPC🟢 high

cancel a clan's participation in a Dominion

Cancels the creature c's clan's registration in the territory war (Dominion) for the territory
nDominionId — the reverse action to RegisterDominion.

Signature

CancelPledgeDominion( int nDominionId, CSharedCreatureData c )

Parameters

    nDominionId (int) — the identifier of the territory/residence (Dominion) whose participation is cancelled.
    c (CSharedCreatureData) — the initiator creature (a player or a clan representative).

Example (illustrative):

    CancelPledgeDominion( nDominionId, talker );

IsDominionOfLordNPC🟢 high

a Dominion's belonging to a lord

Reports whether the territory (Dominion) nDominionId has an owning lord: 0 — the territory is unclaimed,
a value > 0 — the territory has an owner. Territory identifiers lie in the 80+ range
(in the examples 87, 80+i0).

Signature

IsDominionOfLord( int nDominionId )

Parameters

nDominionId (int) — the identifier of the territory/residence (Dominion) checked for belonging to a lord (in calls 87).

Usage example

if (IsDominionOfLord(87) == 0) {
    ShowQuestPage( talker, "chamberlain_alfred_q0715_01.htm", @path_of_feudal_lord_godard );
} else {
    ShowQuestPage( talker, "chamberlain_alfred_q0715_03.htm", @path_of_feudal_lord_godard );
}

IsHostileInDominionSiegeNPC🟢 high

hostility in a Dominion siege

Reports whether the creature c is a hostile participant in the current territory-war (Dominion) siege
— an opponent relative to the defending side. Returns 1 (@TRUE) if c
is hostile, otherwise 0.

Signature

IsHostileInDominionSiege( CSharedCreatureData cCreature )

Parameters

    cCreature (CSharedCreatureData) — the creature checked for hostility in the territory siege

Example (illustrative):

    IsHostileInDominionSiege( talker );

Residence_GetTaxRateNPC🟢 high

the residence's current tax rate

Returns the tax rate of this NPC's residence that will take effect in the next cycle
(in dialogs substituted into the "next_tax_rate" field). No arguments — by the NPC's own residence.
A pair to Residence_GetTaxRateCurrent (the active rate).

Signature

Residence_GetTaxRate(  )

Parameters

(none — the function is called without arguments)

Example

FHTML_SetInt(fhtml0, "next_tax_rate", Residence_GetTaxRate());

Residence_GetTaxRateCurrentNPC🟢 high

the residence's active tax rate

Returns the currently active tax rate of this NPC's residence (in dialogs substituted
into the "current_tax_rate" field). No arguments — by the NPC's own residence. A pair to Residence_GetTaxRate
(the next cycle's rate).

Signature

Residence_GetTaxRateCurrent(  )

Parameters

(none — the function is called without arguments)

Example

Residence_GetTaxRateCurrent( );

Residence_GetTaxIncomeNPC🟢 high

the residence's tax income

Returns the accumulated tax adena of this NPC's residence (no arguments — by the NPC's own
residence). The value is 64-bit (read from the residence data), so there is no overflow.
The paired Residence_GetTaxIncomeReserved returns the reserved (not yet paid out) part.

Signature

Residence_GetTaxIncome(  )

Parameters

(none — the function is called without arguments)

Example

Residence_GetTaxIncome( );

Residence_VaultSaveMoneyNPC🟢 high

replenish the residence treasury

Deposits nAmount adena from the player c's inventory into the treasury (income) of this NPC's residence. Requires
the player to have at least nAmount adena — otherwise the deposit does not happen. Usually called
by a manager and requires authority (in the example — the @ppTaxVault right or lord status).

Signature

Residence_VaultSaveMoney( CSharedCreatureData c, int nAmount )

Parameters

c (CSharedCreatureData) — the creature initiating the treasury replenishment.
nAmount (int) — the treasury replenishment amount for the residence (adena; in calls reply).

Usage example

if ( IsMyLord( talker ) || ( HavePledgePower( talker, @ppTaxVault ) && Castle_GetPledgeId( ) == talker.pledge_id && talker.pledge_id != 0 ) ) {
    Residence_VaultSaveMoney( talker, reply );
    ShowPage( talker, fnHi );
} else {
    ShowPage( talker, fnNoAuthority );
}

Residence_TakeOutMoneyNPC🟡 medium

withdraw from the residence treasury

Withdraws funds from the residence treasury — the operation reverse to Residence_VaultSaveMoney (in which
the player deposits adena into the treasury). The meaning is clear, but the function itself cannot be found either in the signature
references, or in the engine sources, or in L2NPC (neither CT2.3 nor CT2.6) — possibly, in these builds it
is absent or is named differently, so the argument list is not confirmed.

Example (illustrative):

Residence_TakeOutMoney( ... );

RemoveResidenceNPC🟢 high

remove a residence

Disbands the residence nResidenceId — resets its clan affiliation (a service
action of the manager). c — the initiator creature.

Signature

RemoveResidence( CSharedCreatureData c, int nResidenceId )

Parameters

    c (CSharedCreatureData) — the creature initiating the residence removal
    nResidenceId (int) — the identifier of the residence being removed

Example (illustrative):

    RemoveResidence( talker, nResidenceId );

AssignResidenceNpcToPledgeNPC🟢 high

bind a residence NPC to a clan

Binds the residence NPC of residence_id to the creature c's clan — transfers the residence's
managing/service NPCs into the clan's ownership. A service action on a change of residence owner.

Signature

AssignResidenceNpcToPledge( int residence_id, CSharedCreatureData c )

Parameters

    residence_id (int) — the identifier of the residence whose NPC is bound
    c (CSharedCreatureData) — the creature/clan to which the residence NPC is bound


Example (illustrative):

    AssignResidenceNpcToPledge( residence_id, talker );

RegisterUserResurrectionTowerNPC🟢 high

register a player at a resurrection tower

Registers a player at a resurrection tower for tracking potentially
resurrectable ones. Takes the user identifier (user_id); returns
nothing.

Signature

RegisterUserResurrectionTower( int nUserId )

Parameters

nUserId (int) — the user identifier (user_id) registered at the resurrection tower (in calls myself.sm.id).

Example

    RegisterUserResurrectionTower( myself.sm.id );

Related event: the server's response arrives as the REGISTER_USER_RESURRECTION_TOWER_RESULT event (see NASC_HANDLERS).

RegisterResurrectionTowerNPC🟢 high

register a resurrection tower

Registers the resurrection tower itself in the system and binds it to a zone. Takes the
tower identifier and the zone identifier; returns nothing.

Signature

RegisterResurrectionTower( int nTowerId, int nZoneId )

Parameters

nTowerId (int) — the resurrection tower identifier (in calls myself.i_ai0).
nZoneId (int) — the identifier of the zone the tower is bound to (in calls myself.i_ai1).

Example

    RegisterResurrectionTower( myself.i_ai0, myself.i_ai1 );

Related event: the server's response arrives as the REGISTER_RESURRECTION_TOWER_RESULT event (see NASC_HANDLERS).

Fortresses, clan halls, dominion (Fortress / Agit / Dominion)

30 functions

Fortress_GetContractStatusGLOBAL🟢 high

a fortress's contract status

A getter (gg). By the fortress id nFortId returns an int — the status of its contract (for fortresses with id 101…111).

Signature

Fortress_GetContractStatus( int nFortressId )

Parameters

nFortressId (int) — the identifier of the fortress whose contract state is requested

Example

if (Fortress_GetContractStatus(fortress_id) != @FORTRESS_CONTRACT_CASTLE)

Usage example

if ( Fortress_GetContractStatus( fortress_id ) != 0 ) {
    return;
}

Fortress_GetAvailableOwnMinutesGLOBAL🟢 high

remaining fortress-ownership time

A getter (gg). By the fortress id nFortId returns an int — how many minutes the current owner has left.

Signature

Fortress_GetAvailableOwnMinutes( int nFortressId )

Parameters

nFortressId (int) — the identifier of the fortress whose available ownership time is returned

Example

if ( Fortress_GetAvailableOwnMinutes( fortress_id ) <= 120 && Fortress_GetOwnerPledgeId( fortress_id ) > 0 ) {

Usage example

if ( Fortress_GetAvailableOwnMinutes( fortress_id ) <= 120 && Fortress_GetOwnerPledgeId( fortress_id ) > 0 ) {
    ShowPage( talker, fnHi6 );
    return;
}

Fortress_GetNextRewardRemainTimeGLOBAL🟢 high

time until the next payout to the owner

A getter (gg). By the fortress id nFortId returns an int — the time remaining until the next reward payout to the fortress owner.

Signature

Fortress_GetNextRewardRemainTime( int nFortressId )

Parameters

nFortressId (int) — the identifier of the fortress whose time until the next reward is returned

Example

i7 = Fortress_GetNextRewardRemainTime( fortress_id );

Castle_GetDomainFortressContractStatusGLOBAL🟢 high

a fortress's contract status in the castle's domains

A getter (gg). By the fortress id nFortId returns an int — the status of its contract in the castle's domains.

Signature

Castle_GetDomainFortressContractStatus( int nFortId )

Parameters

nFortId (int) — the id of the fortress for which the contract status in the castle's domains is requested

Example

if ( Castle_GetDomainFortressContractStatus( fortress_id ) == 0 ) {

Usage example

if ( Castle_GetDomainFortressContractStatus( fortress_id ) == 0 ) {
    ShowPage( talker, fnNoCastleContract );
    return;
}

GetDominionWarStateGLOBAL🟢 high

the state of the war for a domain

A getter (gg). By the domain id nDominionId (@*_dominion or 81…89) returns an int — the state of the war for the domain; a value of 5 means the war is on.

Signature

GetDominionWarState( int nDominionId )

Parameters

nDominionId (int) — the identifier of the territory/residence (Dominion) whose war state is requested

Example

if (Castle_IsUnderSiege() == @TRUE || GetDominionWarState(dominion_id) == 5)

Usage example

if ( Castle_IsUnderSiege( ) == @FALSE && GetDominionWarState( i0 ) != 5 ) {
    ShowPage(talker, "mass_teleporter_instant.htm");
    return;
}

Fortress_GetPledgeSiegeStateNPC🟢 high

siege state for the creature's clan

Fortress getter (CNPC). Given creature c, returns int — the siege state for its clan; a value of 2 means the creature's clan is currently under siege.

Signature

Fortress_GetPledgeSiegeState( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) whose clan's fortress siege state is checked

Example

if (Fortress_GetPledgeSiegeState(creature) == 2 || (IsNullCreature(creature.master) == @FALSE && Fortress_GetPledgeSiegeState(creature.master) == 2))

Usage example

if ( ( Fortress_GetPledgeSiegeState( creature ) == 2 ) || ( IsNullCreature( creature.master ) == 0 && Fortress_GetPledgeSiegeState( creature.master ) == 2 ) ) {
    return;
}

Fortress_SetFacilityNPC🟢 high

set a fortress facility level

Fortress method (CNPC). For creature c, sets level nLevel of the facility of type nFacilityType (a @FORTRESS_* constant or 0..4).

Signature

Fortress_SetFacility( CSharedCreatureData cCreature, int nFacilityType, int nValue )

Parameters

cCreature     (CSharedCreatureData) — creature initiating the setting (usually talker).
nFacilityType (int) — type of the fort facility being configured, @FORTRESS_*:
    0 GUARD_REINFORCEMENT · 1 GUARD_POWER_UP · 2 DOOR_POWER_UP · 3 PHOTOCANNON · 4 SCOUT
nValue        (int) — the facility level/value being set.

Example

Fortress_SetFacility(talker, @FORTRESS_PHOTOCANNON, 1);

Usage example

if ( OwnItemCount( talker, @adena ) >= i0 ) {
    Fortress_SetFacility( talker, 1, 0 );
} else {
    ShowPage( talker, "fortress_not_enough_money.htm" );
}

Fortress_ResetFacilityNPC🟢 high

reset all fortress facilities

Fortress method (CNPC). Resets all facilities of the fortress bound to creature c.

Signature

Fortress_ResetFacility( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature initiating the fort facility reset

Example

Fortress_ResetFacility( talker );

Usage example

if ( OwnItemCount( talker, @adena ) >= i0 ) {
    Fortress_ResetFacility( talker );
} else {
    ShowPage( talker, "fortress_not_enough_money.htm" );
}

Fortress_IsInBoundaryNPC🟢 high

is the NPC within the fortress boundaries

Fortress predicate (CNPC). Given fortress id nFortId, returns int (1/0) — whether the NPC is within its boundaries.

Signature

Fortress_IsInBoundary( int nFortId )

Parameters

nFortId (int) — id of the fortress whose boundaries the NPC is checked against.

Example

i8 = fortress_dependancy + Fortress_IsInBoundary(i0);

Fortress_GetCastleTreasureLevelNPC🟢 high

treasury level of the parent castle

Fortress getter (CNPC). Given fortress id nFortId, returns int — the treasury level of the castle the fortress is subordinate to.

Signature

Fortress_GetCastleTreasureLevel( int nFortId )

Parameters

nFortId (int) — id of the fortress for which the owning castle's treasury level is taken.

Example

i0 = Fortress_GetCastleTreasureLevel( fortress_id );

Fortress_CastleTreasureTakenNPC🟢 high

mark that the fortress treasury has been taken

Fortress method (CNPC). Records the fact that the fortress treasury has been taken. Arguments: nNpcId — NPC id, nTalkerId — player id, nFortId — fortress id.

Signature

    Fortress_CastleTreasureTaken( int nNpcId, int nUserId, int nFortressId )

Parameters (per real calls — myself.sm.id, talker.id, fortress_id):
    nNpcId      (int) — id of the NPC originating the event (myself.sm.id).
    nUserId     (int) — id of the player who took the treasury (talker.id).
    nFortressId (int) — identifier of the fort where the treasury was seized.

Example

Fortress_CastleTreasureTaken( myself.sm.id, talker.id, fortress_id );

Usage example

if ( i0 > 0 ) {
    Fortress_CastleTreasureTaken( myself.sm.id, talker.id, fortress_id );
    ShowPage( talker, fnGetTreasureSuccess );
}

Fortress_ProtectedNpcDiedNPC🟢 high

death of a protected fortress NPC

Fortress method (CNPC). Notifies the system about the death of a protected fortress NPC. Arguments: nNpcId — NPC id, nFortId — fortress id.

Signature

    Fortress_ProtectedNpcDied( int nNpcId, int nFortressId )

Parameters (per real calls — myself.sm.id, fortress_id):
    nNpcId      (int) — id of the NPC originating the event (myself.sm.id).
    nFortressId (int) — identifier of the fort where the protected NPC died.

Example

Fortress_ProtectedNpcDied( myself.sm.id, fortress_id );

Fortress_PledgeUnregisterNPC🟢 high

remove a clan's fortress registration

Fortress method (CNPC). Removes the clan's registration for the siege/ownership of a fortress. Arguments: nNpcId — NPC id, nTalkerId — player id, nFortId — fortress id.

Signature

    Fortress_PledgeUnregister( int nNpcId, int nUserId, int nFortressId )

Parameters (per real calls — myself.sm.id, talker.id, fortress_id):
    nNpcId      (int) — id of the NPC originating the action (myself.sm.id).
    nUserId     (int) — player id (talker.id).
    nFortressId (int) — identifier of the fort the registration is removed from.

Example

Fortress_PledgeUnregister( myself.sm.id, talker.id, fortress_id );

Usage example

if ( reply == 0 ) {
    Fortress_PledgeUnregister( myself.sm.id, talker.id, fortress_id );
} else {
    if ( reply == 2 ) {
        ShowMultisell( 614, talker );
    }
}

Fortress_GetOwnerRewardCycleCountNPC🟢 high

number of reward cycles received

Fortress getter (CNPC). Given fortress id nFortId, returns int — how many reward cycles its owner has already received.

Signature

Fortress_GetOwnerRewardCycleCount( int nFortId )

Parameters

nFortId (int) — id of the fortress for which the owner's received reward cycles are counted.

Example

i0 = Fortress_GetOwnerRewardCycleCount( fortress_id );

Agit_GetDecoLevelNPC🟢 high

current level of a clan hall decoration

Clan hall decoration getter (CNPC). Given decoration type nDecoType (@decotype_*), returns int — its current level; a value greater than 0 means the decoration is installed.

Signature

Agit_GetDecoLevel( int nDecoType )

Parameters

nDecoType (int) — agit decoration type. Values (script-convention constants):
    1 hpregen · 2 mpregen · 3 cpregen · 6 broadcast · 7 curtain · 8 hanging ·
    9 buff · 10 outerflag · 11 platform · 12 item

Example

if ( Agit_GetDecoLevel( decotype_buff ) > 0 ) {

Usage example

if ( Agit_GetDecoLevel( decotype_item ) == 0 ) {
    ShowPage( talker, fnFuncDisabled );
}

Agit_GetDecoFeeNPC🟢 high

fee for a decoration of the given level

Decoration getter (CNPC). Given type nDecoType and level nLevel, returns int — the fee for installing/renewing a decoration of that level.

Signature

Agit_GetDecoFee( int nDecoType, int nLevel )

Parameters

nDecoType (int) — agit decoration type. Values (script-convention constants):
    1 hpregen · 2 mpregen · 3 cpregen · 6 broadcast · 7 curtain · 8 hanging ·
    9 buff · 10 outerflag · 11 platform · 12 item
nLevel    (int) — decoration level (usually Agit_GetDecoLevel(nDecoType)).

Example

FHTML_SetStr( fhtml0, "HP" + "Cost", "(" + MakeFString( 6, IntToStr( Agit_GetDecoFee( decotype_hpregen, Agit_GetDecoLevel( decotype_hpregen ) ) ), IntToStr( Agit_GetDecoDay( decotype_hpregen, Agit_GetDecoLevel( decotype_hpregen ) ) ), _blank, _blank, _blank ) + ")" );

Agit_GetDecoDayNPC🟢 high

decoration duration (days)

Decoration getter (CNPC). Given type nDecoType and level nLevel, returns int — the decoration's duration in days.

Signature

Agit_GetDecoDay( int nDecoType, int nLevel )

Parameters

nDecoType (int) — agit decoration type. Values (script-convention constants):
    1 hpregen · 2 mpregen · 3 cpregen · 6 broadcast · 7 curtain · 8 hanging ·
    9 buff · 10 outerflag · 11 platform · 12 item
nLevel    (int) — decoration level (usually Agit_GetDecoLevel(nDecoType)).

Example

FHTML_SetStr( fhtml0, "HP" + "Cost", "(" + MakeFString( 6, IntToStr( Agit_GetDecoFee( decotype_hpregen, Agit_GetDecoLevel( decotype_hpregen ) ) ), IntToStr( Agit_GetDecoDay( decotype_hpregen, Agit_GetDecoLevel( decotype_hpregen ) ) ), _blank, _blank, _blank ) + ")" );

Agit_GetCostFailDayNPC🟢 high

days of overdue payment before losing the decoration

Decoration getter (CNPC), no arguments. Returns int — the allowed number of days of overdue payment after which the decoration is lost.

Signature

Agit_GetCostFailDay(  )

Parameters

(none — the function is called without arguments)

Example

if ( Agit_GetCostFailDay( ) == 0 ) {

Usage example

if ( Agit_GetCostFailDay( ) == 0 ) {
    ShowPage( talker, fnHi );
} else {
    FHTML_SetFileName( fhtml0, fnCostFail );
    FHTML_SetInt( fhtml0, "CostFailDayLeft", ( 8 - Agit_GetCostFailDay( ) ) );
    ShowFHTML( talker, fhtml0 );
}

Agit_GetDecoIdNPC🟢 high

internal decoration id

Decoration getter (CNPC). Given decoration type nDecoType, returns int — its internal id.

Signature

Agit_GetDecoId( int nDecoType )

Parameters

    nDecoType (int) — agit decoration type. Values (script-convention constants):
        1 hpregen · 2 mpregen · 3 cpregen · 6 broadcast · 7 curtain · 8 hanging ·
        9 buff · 10 outerflag · 11 platform · 12 item

Example: no direct calls in our scripts.

Agit_SetDecoNPC🟢 high

install/update a decoration

Decoration method (CNPC). For creature c, installs or updates the decoration of type nDecoType to level nLevel.

Signature

Agit_SetDeco( CSharedCreatureData cCreature, int nDecoType, int nLevel )

Parameters

cCreature (CSharedCreatureData) — creature initiating the clan hall decoration setting.
nDecoType (int) — agit decoration type. Values (script-convention constants):
    1 hpregen · 2 mpregen · 3 cpregen · 6 broadcast · 7 curtain · 8 hanging ·
    9 buff · 10 outerflag · 11 platform · 12 item
nLevel    (int) — the decoration level being set.

Example

Agit_SetDeco( talker, i0, i1 );

Agit_ResetDecoNPC🟢 high

reset a decoration

Decoration method (CNPC). For creature c, resets the decoration of type nDecoType.

Signature

Agit_ResetDeco( CSharedCreatureData cCreature, int nDecoType )

Parameters

cCreature (CSharedCreatureData) — creature whose clan hall decoration is reset (talker).
nDecoType (int) — type of the agit decoration to reset; in calls = FloatToInt(reply/1000).
    Values (script-convention constants):
    1 hpregen · 2 mpregen · 3 cpregen · 6 broadcast · 7 curtain · 8 hanging ·
    9 buff · 10 outerflag · 11 platform · 12 item

Example

Agit_ResetDeco( talker, i0 );

DeclareLordNPC🟢 high

declare a player lord of a dominion

Method (CNPC). Declares creature c the lord of dominion nDominionId.

Signature

DeclareLord( int nDominionId, CSharedCreatureData c )

Parameters

nDominionId (int) — id of the dominion for which the lord is declared.
c (CSharedCreatureData) — creature (player) being declared lord of the dominion.

Example

DeclareLord(dominion_id, talker);

IsLordOfCastleNPC🟢 high

is the player the lord of a castle/dominion

Predicate (CNPC). Given creature c, returns int (1/0) — whether the player is the lord of a castle/dominion.

Signature

IsLordOfCastle( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) checked for castle/dominion lord status

Example

i0 = IsLordOfCastle( talker );
i1 = IsLordOfCastle(talker);

CancleUserDominionNPC🟢 high

withdraw a player's participation in a dominion war

Method (CNPC). Withdraws creature c's participation in the war for dominion nDominionId.

Signature

CancleUserDominion( int nDominionId, CSharedCreatureData c )

Parameters

    nDominionId (int) — id of the dominion from whose war the participant is withdrawn.
    c (CSharedCreatureData) — creature (player) whose war participation is withdrawn.

Example: no direct calls in our scripts.

Residence_GetTaxIncomeReservedNPC🟢 high

reserved tax income

Residence getter (CNPC), no arguments. Returns int64 — the reserved (not yet paid out) tax income.

Signature

Residence_GetTaxIncomeReserved(  )

Parameters

(none — the function is called without arguments)

Example

FHTML_SetInt( fhtml0, "tax_income_reserved", Residence_GetTaxIncomeReserved( ) );

Residence_SetTaxRateNPC🟢 high

set the tax rate

Residence method (CNPC). Sets the residence tax rate nRate.

Signature

Residence_SetTaxRate( int nTaxRate )

Parameters

nTaxRate (int) — the residence tax rate being set, in percent (in calls 0 or reply).

Example

Residence_SetTaxRate( 0 );
Residence_SetTaxRate( reply );

Usage example

if ( reply < 0 ) {
    Residence_SetTaxRate( 0 );
    FHTML_SetInt( fhtml0, "next_tax_rate", 0 );
} else {
    Residence_SetTaxRate( reply );
    FHTML_SetInt( fhtml0, "next_tax_rate", reply );
}

Residence_VaultTakeOutMoneyNPC🟢 high

withdraw money from the residence treasury

Residence method (CNPC). Gives creature c the amount nAmount from the residence treasury; returns int.

Signature

Residence_VaultTakeOutMoney( CSharedCreatureData c, int nAmount )

Parameters

c (CSharedCreatureData) — creature (player) who receives the money from the treasury.
nAmount (int) — amount to give out (adena; in calls reply).

Example

Residence_VaultTakeOutMoney( talker, reply );

GetControlTowerLevelNPC🟢 high

control tower level of a zone

Method (CNPC). Given creature c and zone name sZoneName, reports the level of that zone's control tower (return type not confirmed).

Signature

GetControlTowerLevel( CSharedCreatureData c, string sZoneName )

Parameters

c (CSharedCreatureData) — creature that will receive the result (via the CONTROLTOWER_LEVEL_INFORMED event).
sZoneName (string) — name of the zone whose control tower is queried.

Example

GetControlTowerLevel( talker, dmgzonename1 );
GetControlTowerLevel( talker, dmgzonename2 );

Usage example

    if ( GetCookie( talker, "dmgzone_num" ) == 2 ) {
        GetControlTowerLevel( talker, dmgzonename2 );
    }

Related event: the server's response arrives as the CONTROLTOWER_LEVEL_INFORMED event (see NASC_HANDLERS).

SetControlTowerLevelNPC🟢 high

set the control tower level

Method (CNPC). For the zone named sZoneName, sets the control tower level nLevel.

Signature

SetControlTowerLevel( string sZoneName, int nLevel )

Parameters

sZoneName (string) — name of the zone whose control tower level is set.
nLevel (int) — the control tower level being set.

Example

SetControlTowerLevel( dmgzonename1, ( 2 * i1 ) );
SetControlTowerLevel( dmgzonename2, ( 2 * i1 ) );
SetControlTowerLevel(dmgzonename1, 2 * i1);
SetControlTowerLevel(dmgzonename2, 2 * i1);

Castle_GetRawSystemTimeNPC🟢 high

raw system time

Getter (CNPC), no arguments. Returns int — the raw system time, used to synchronize sieges.

Signature

Castle_GetRawSystemTime(  )

Parameters

(none — the function is called without arguments)

Example

if ( ( Castle_GetRawSystemTime( ) - Castle_GetRawSiegeTime( ) ) < 1800 ) {

Usage example

if ( _from_choice == 0 || ( HaveMemo( talker, @competition_for_the_bandit_stronghold ) == 1 && OwnItemCount( talker, @q_contest_certificate ) > 0 && OwnItemCount( talker, @q_tarlk_amulet ) < 30 && ( Castle_GetRawSiegeTime( ) - GetMemoState( talker, @competition_for_the_bandit_stronghold ) ) < 86400 && ( Castle_GetRawSiegeTime( ) - Castle_GetRawSystemTime( ) ) > 0 ) ) {
    SetCurrentQuestID( @competition_for_the_bandit_stronghold );
    ShowPage( talker, "azit_messenger_q0504_07.htm" );
}

TERRITORY BATTLES, CLANS, EVENT REGISTRATION AND PREMIUM (TB / Pledge / Register / Premium)

26 functions

GetSubpledgeMasterNameGLOBAL🟢 high

learn the name of a sub-clan leader

Returns the name of a sub-clan leader as a string. The first argument is a creature
(CSharedCreatureData), the second is the sub-clan ID.

Signature

GetSubpledgeMasterName( CSharedCreatureData cCreature, int nSubPledgeId )

Parameters

cCreature    (CSharedCreatureData) — the creature (player) in whose clan context the sub-clan is searched
nSubPledgeId (int) — the id of the sub-clan whose leader name is requested

Example

s0 = GetSubpledgeMasterName( talker, reply );

Usage example

s0 = GetSubpledgeMasterName( talker, reply );
if ( IsNullString(s0 ) == 1 ) {
    s0 = "";
    s0 = MakeFString( 1010642, "", "", "", "", "" );
}

TB_SetNpcTypeNPC🟢 high

set a territory battle participant type

Sets the territory battle participant type (1–5: NPC kinds). Called on a
creature object (CSharedCreatureData), with the type number passed as the second argument;
returns nothing.

Signature

TB_SetNpcType( CSharedCreatureData c, int nType )

Parameters

c (CSharedCreatureData) — creature whose territory battle participant type is set.
nType (int) — number of the territory battle participant type being set, 1..5 (in calls 2, 5).

Example

TB_SetNpcType( talker, 2 );

Usage example

    if ( reply == 8 ) {
        TB_SetNpcType( talker, 5 );
    } else
    if ( reply == 9 ) {
        TB_GetNpcType( talker );
    }

Related event: the server's response arrives as the TB_SET_NPC_TYPE_RETURNED event (see NASC_HANDLERS).

TB_GetNpcTypeNPC🟢 high

get a territory battle participant type

Gets the current territory battle participant type for the given creature
(CSharedCreatureData). Called on the creature object.

Signature

TB_GetNpcType( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature whose territory battle participant type is queried

Example

TB_GetNpcType( talker );

Usage example

    if ( reply == 9 ) {
        TB_GetNpcType( talker );
    }

Related event: the server's response arrives as the TB_GET_NPC_TYPE_INFORMED event (see NASC_HANDLERS).

TB_GetPledgeRegisterStatusNPC🟢 high

check a clan's battle registration

Checks the registration status of the player's clan in the territory battle; the result arrives via an event.
Per the L2Server handler (NpcQueryTeamBattlePledge → CTeamBattleAgit::GetPledgeRegisterStatusForNpcServer)
the server looks for the player's clan among those registered at the agit (up to 5 slots) and returns the slot index,
or a "not registered" code. The flag affects exactly this code when there is no registration: with
nMode=0 it returns -3, with nMode=1 it stays -1 — scripts use this for different dialog branches.

Signature

TB_GetPledgeRegisterStatus( CSharedCreatureData c, int nMode )

Parameters

c (CSharedCreatureData) — creature (player) whose clan's registration is checked.
nMode (int) — response mode for an unregistered clan: 0 → result code -3, 1 → code -1.

Example

TB_GetPledgeRegisterStatus( talker, 1 );
TB_GetPledgeRegisterStatus( talker, 0 );

Usage example

    if ( GetPledgeSkillLevel( talker ) >= 4 ) {
        TB_GetPledgeRegisterStatus( talker, 0 );
    } else {
        ShowPage( talker, "azit_messenger_q0504_04.htm" );
    }

Related event: the server's response arrives as the TB_GET_PLEDGE_REGISTER_STATUS_INFORMED event (see NASC_HANDLERS).

TB_RegisterPledgeNPC🟢 high

register a clan for territory wars

Registers a clan for participation in territory wars. Called on a creature
object (CSharedCreatureData), with no extra arguments.

Signature

TB_RegisterPledge( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) whose clan is registered for territory wars

Example

    TB_RegisterPledge( talker );

Related event: the server's response arrives as the TB_REGISTER_PLEDGE_RETURNED event (see NASC_HANDLERS).

TB_RegisterMemberNPC🟢 high

register a clan member as a battle participant

Registers a clan member as a territory battle participant. Called on a
creature object (CSharedCreatureData) with no extra arguments.

Signature

TB_RegisterMember( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) registered as a territory battle participant

Example

TB_RegisterMember( talker );

Usage example

    if ( talker.is_pledge_master != 1 ) {
        TB_RegisterMember( talker );
    } else {
        ShowPage( talker, "farm_kel_mahum_messenger_5.htm" );
    }

Related event: the server's response arrives as the TB_REGISTER_MEMBER_RETURNED event (see NASC_HANDLERS).

TB_CheckMemberRegisterStatusNPC🟢 high

check a clan member's registration

Checks a clan member's registration in the territory battle. The first argument is the
event/agit ID, the second is a creature (CSharedCreatureData).

Signature

TB_CheckMemberRegisterStatus( int nAgitId, CSharedCreatureData c )

Parameters

nAgitId (int) — id of the event/agit within which the registration is checked (in calls AgitID).
c (CSharedCreatureData) — creature (player) whose clan member registration is checked.

Example

TB_CheckMemberRegisterStatus( AgitID, talker );

Usage example

if ( myself.i_ai1 == 0 ) {
    TB_CheckMemberRegisterStatus( AgitID, talker );
} else {
    ShowPage( talker, "agit_mass_teleporter001.htm" );
}

TB_GetBattleRoyalPledgeListNPC🟢 high

get the list of clans in battles

Returns the list of clans participating in territory battles. Called on a
creature object (CSharedCreatureData).

Signature

TB_GetBattleRoyalPledgeList( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature in whose context the participant clan list is requested

Example

TB_GetBattleRoyalPledgeList( talker );

Usage example

    if ( ask == 101 ) {
        TB_GetBattleRoyalPledgeList( talker );
    }

Related event: the server's response arrives as the TB_GET_BATTLE_ROYAL_PLEDGE_LIST_INFORMED event (see NASC_HANDLERS).

UpdatePledgeNameValueNPC🟢 high

change clan reputation

Changes the clan's reputation by the given number (negative decreases it).
Called on a creature object (CSharedCreatureData); returns the new reputation
value.

Signature

UpdatePledgeNameValue( CSharedCreatureData c, int nDelta )

Parameters

c (CSharedCreatureData) — creature (player) whose clan's reputation is changed.
nDelta (int) — signed amount of the reputation change (negative decreases; in calls -10000, i0).

Example

UpdatePledgeNameValue( talker, -10000 );

Usage example

if ( i0 > 0 ) {
    UpdatePledgeNameValue( talker, i0 );
}

OwnPledgeNameValueNPC🟢 high

get clan reputation

Returns the current clan reputation of the talker (CSharedCreatureData) as an integer.

Signature

OwnPledgeNameValue( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (talker) whose clan reputation is queried

Example

if ( OwnPledgeNameValue( talker ) >= 10000 ) {

Usage example

if ( OwnPledgeNameValue( talker) >= 5000 ) {
    UpdatePledgeNameValue( talker, -5000 );
    CreateSubPledge( talker, i0, i1, s0 );
} else {
    ShowPage( talker, "pl_err_fame.htm" );
}

GetPledgeByIndexNPC🟢 high

get clan data by index

Gets a clan data object (CSharedPledgeData) by a numeric index.

Signature

GetPledgeByIndex( int nIndex )

Parameters

nIndex (int) — numeric index of the clan whose data is taken.

Example

pledge0 = GetPledgeByIndex( i0 );

Usage example

pledge0 = GetPledgeByIndex( i0 );
if ( IsNull( pledge0 ) == 0 ) {
    FHTML_SetStr( fhtml0, "pledge0", pledge0.name );
    FHTML_SetStr( fhtml0, "p_member_count0", IntToStr( i1 ) );
}

GetPledgeCastleSiegeDefenceCountNPC🟢 high

clan defense attempt counter

Returns the number of the clan's defense attempts in a castle siege. Argument — a creature
(CSharedCreatureData), return — an integer.

Signature

GetPledgeCastleSiegeDefenceCount( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) whose clan's siege defense attempts are counted

Example

i0 = GetPledgeCastleSiegeDefenceCount(talker);

RegisterToEventListenerNPC🟢 high

register an event listener

Subscribes this NPC to global events. Per the L2NPC decompile
(CNPC::RegisterToEventListener_48F6DC) the engine registers the NPC in the shared
GlobalEventListener registry by event type. In the compiled scripts only the value 1 is used
(per the call context ssq_event_listener == 1 — subscription to Seven Signs events).

Signature

RegisterToEventListener( int nEventType )

Parameters

nEventType (int) — global event type to subscribe to (registered in GlobalEventListener;
    in calls 1 — per context, the SSQ / Seven Signs event).

Example

RegisterToEventListener( 1 );

Usage example

if ( ssq_event_listener == 1 ) {
    RegisterToEventListener( 1 );
}

AddPremiumPointsNPC🟢 high

grant premium points

Adds premium points to a player. First argument — a creature (CSharedCreatureData),
second — the number of points (int64); returns nothing.

Signature

AddPremiumPoints( CSharedCreatureData cCreature, int64 points )

Parameters

cCreature (CSharedCreatureData) — creature (player) who is granted the premium points
points (int64) — number of premium points to add

Example

AddPremiumPoints( talker, ( i7 * 3 ) );

IsUserPremiumNPC🟢 high

check for an active subscription

Returns 1 if the player has an active premium subscription. Argument — a creature
(CSharedCreatureData).

Signature

IsUserPremium( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) whose active premium subscription is checked

Example

if (IsUserPremium(talker) == @FALSE)

Usage example

if ( IsUserPremium( talker ) == @FALSE ) {
    ShowPage( talker, "npc_rim_maker001e.htm" );
    return;
}

GetPremiumLevelNPC🟢 high

get the premium level

Returns the player's premium level (0 — none, 1 and above — the level). Argument —
a creature (CSharedCreatureData).

Signature

GetPremiumLevel( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) whose premium level is queried

Example

if (GetPremiumLevel(talker) == 2) {

Usage example

if (GetPremiumLevel(talker) < 2) {
    ShowPage(talker, "not_enoth_vip_lvl.htm");
}

SetUserPremiumNPC🟢 high

activate or extend premium

Activates or extends the player's premium subscription. Arguments: a creature
(CSharedCreatureData), duration in seconds, two integer parameters and
a string parameter; returns nothing.

Signature

SetUserPremium( CSharedCreatureData cCreature, int nDuration, int nParam1, int nParam2, string pwsParam3 )

Parameters

cCreature (CSharedCreatureData) — creature (player) whose premium is activated/extended
nDuration (int) — subscription duration in seconds
nParam1 (int) — additional integer subscription parameter
nParam2 (int) — additional integer subscription parameter
pwsParam3 (string) — additional string subscription parameter

Example

SetUserPremium( talker, ( i4 * 86400 ), 1, 1, "" );

Usage example

if ( IsUserPremium( talker ) == 0 ) {
    SetUserPremium( talker, ( 30 * 86400 ), 1, 1, "" );
    ShowPage( talker, "obtshop_premium_ok.htm" );
} else {
    ShowPage( talker, "obtshop_premium_already.htm" );
}

ShowPremiumItemListNPC🟢 high

show the premium goods window

Shows the player a window with premium goods. Argument — a creature
(CSharedCreatureData).

Signature

ShowPremiumItemList( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) shown the premium goods window

Example

ShowPremiumItemList(talker);

Usage example

if (reply == 1) {
    ShowPremiumItemList(talker);
}

IsMidWarMemberNPC🟢 high

check participation in mid wars

Returns 1 if the player is a participant in mid wars. Argument —
a creature (CSharedCreatureData).

Signature

IsMidWarMember( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) being checked, whose participation in mid wars is determined

Example

if (MidWarIsEnable == @TRUE && IsMidWarMember(talker) != @FALSE)

Usage example

if (MidWarIsEnable == @TRUE && IsMidWarMember(talker) != @FALSE)
{
    ShowPage(talker, "midwar_no_epic.htm");
    return;
}

IsJoinableToDawnNPC🟢 high

check eligibility to join the Lords of Dawn

Returns 1 if the player can join the Lords of Dawn. Argument —
a creature (CSharedCreatureData).

Signature

IsJoinableToDawn( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) being checked, whose eligibility to join the Lords of Dawn is verified

Example

if ( IsJoinableToDawn( talker ) ) {

Usage example

if ( IsJoinableToDawn( talker ) ) {
    ShowPage( talker, szName + "_" + QUEST_ID + "_39a.htm" );
} else {
    ShowPage( talker, szName + "_" + QUEST_ID + "_38.htm" );
}

CheckCursedUserNPC🟢 high

check a player's curse

Checks a player's curse. Argument — a creature (CSharedCreatureData); returns
nothing.

Signature

CheckCursedUser( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — creature (player) being checked for the presence of a curse

Example

CheckCursedUser(talker);

RegisterFortressEventExMAKER🟢 high

bind an event to a fortress

Binds an event to a fortress. Three integer arguments: fortress ID, event ID and
a spawn flag; returns nothing.

Signature

RegisterFortressEventEx( int nFortId, int nEventId, int bSpawn )

Parameters

nFortId (int) — id of the fortress the event is bound to.
nEventId (int) — id of the event being bound.
bSpawn (int) — spawn flag (is_spawnN in calls, 0/1).

Example

RegisterFortressEventEx( fortress_id, event_id1, is_spawn1 );
RegisterFortressEventEx( fortress_id, event_id2, is_spawn2 );
RegisterFortressEventEx( fortress_id, event_id3, is_spawn3 );
RegisterFortressEventEx( fortress_id, event_id4, is_spawn4 );

Usage example

    if ( event_id1 > -1 ) {
        RegisterFortressEventEx( fortress_id, event_id1, is_spawn1 );
    }

Related event: the bound event_id is returned to the maker in the event_id field of the ON_FORTRESS_EVENT event when the fortress reaches the corresponding state (see NASC_HANDLERS).

RegisterInstantZoneEventExMAKER🟢 high

bind an event to an instant zone

Binds an event to an instant zone. Four integer arguments: zone type, cluster
ID, event ID and a flag (0/1); returns nothing.

Signature

RegisterInstantZoneEventEx( int nZoneType, int nClusterId, int nEventId, int nFlag )

Parameters

nZoneType (int) — instant zone type.
nClusterId (int) — id of the zone cluster.
nEventId (int) — id of the event being bound.
nFlag (int) — mode flag: 1 — spawn, 0despawn (in calls: spawn_event_id=1, despawn_event_id=0).

Example

RegisterInstantZoneEventEx( inzone_type_param, inzone_cluster_id, spawn_event_id, 1 );
RegisterInstantZoneEventEx( inzone_type_param, inzone_cluster_id, despawn_event_id, 0 );
RegisterInstantZoneEventEx(inzone_type_param, inzone_cluster_id, olympiad_event_id, 0);

Usage example

    if ( on_start_spawn == 1 ) {
        RegisterInstantZoneEventEx( inzone_type_param, inzone_cluster_id, spawn_event_id, 1 );
    }

Related event: the bound event_id is returned to the maker in the event_id field of the ON_INSTANT_ZONE_EVENT event when a zone of the corresponding type spawns/despawns (see NASC_HANDLERS).

RegisterAgitSiegeEventExMAKER🟢 high

register an agit siege event

Registers an agit siege event. The argument is a castle ID; the return value is an integer.

Signature

RegisterAgitSiegeEventEx( int nCastleId )

Parameters

nCastleId (int) — id of the castle for which the agit siege event is registered (CastleID in calls).

Example

    RegisterAgitSiegeEventEx( CastleID );

Related event: subscribes the maker to residence (agit/clan hall) siege events for the specified castle — the siege event family ON_START_SIEGE_EVENT / ON_END_SIEGE_EVENT / ON_PROCLAIM_SIEGE_EVENT / ON_CANCEL_SIEGE_EVENT (see NASC_HANDLERS).

RegisterSiegeEventExMAKER🟢 high

register a siege event

Registers a siege event. The argument is a castle or dominion ID; the return value is an
integer.

Signature

RegisterSiegeEventEx( int nCastleOrDominionId )

Parameters

nCastleOrDominionId (int) — id of the castle or dominion for which the siege event is registered (CastleID / dominion_id in calls).

Example

    RegisterSiegeEventEx(dominion_id);
    RegisterSiegeEventEx(CastleID);

Related event: subscribes the maker to castle siege events — ON_START_SIEGE_EVENT, ON_END_SIEGE_EVENT, ON_PROCLAIM_SIEGE_EVENT, ON_CANCEL_SIEGE_EVENT; for a dominion — DOMINION_SIEGE_START, DOMINION_SIEGE_END, ON_DECLARE_DOMINION_EVENT (see NASC_HANDLERS).

RegisterNpcPosEventMAKER🟢 high

register an event by name

Registers an event by name; bound to the NPC's position. The argument is a string with
the event name; the return value is an integer.

Signature

RegisterNpcPosEvent( string sEventName )

Parameters

sEventName (string) — name of the event bound to the NPC's position.

Example

RegisterNpcPosEvent( EventName );

SEVEN SIGNS (Seven Signs, SSQ)

18 functions

GetSSQPartGLOBAL🟢 high

the player's side

Available on CNPC (myself) or globally (gg), takes a creature [CSharedCreatureData]. Reports which side the player is on: none, Dusk, or Dawn. The return is the side scale from [manual_pch] (none 0, Dusk 1, Dawn 2).

Signature

GetSSQPart( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose side (none/Dusk/Dawn) is requested

Example

if ( GetSSQPart( c0 ) == 0 ) {

Usage example

if ( GetSSQPart( talker ) != 0 ) {
    ShowMultisell( reply, talker );
}

GetSSQStatusNPC🟢 high

current event phase

Available on CNPC (myself) and CGlobalObject (gg), no arguments. Returns the current event phase from [manual_pch]: the collection period (side competition, 1), the tallying period (2), or the seal validity period (winner bonuses, 3). This is the main gate of all NPC SSQ logic; almost everything else is wrapped in it.

Signature

GetSSQStatus(  )

Parameters

(none — the function is called without arguments)

Example

if (GetSSQStatus() == 3) {

Usage example

if ( GetSSQStatus( ) == 3 && GetSSQPart( talker ) != 2 ) {
    ShowPage( talker, szName + "083.htm" );
}

GetSSQWinnerNPC🟢 high

winning side of the cycle

Available on CNPC (myself) or globally (gg), no arguments. Returns the winning side of the current event cycle. The return value uses the same side scale as the player's side lookup.

Signature

GetSSQWinner(  )

Parameters

(none — the function is called without arguments)

Example

if ( GetSSQWinner( ) == 1 ) {

Usage example

if ( GetSSQPart( talker ) != GetSSQWinner( ) ) {
    return;
}

GetSSQSealOwnerNPC🟢 high

seal owner

Available on CNPC (myself) or globally (gg), takes the seal number nSeal from [manual_pch]. Returns which side owns a specific seal; there are seven seals, each with its own name constant. The return value uses the same side scale (none, Dusk, Dawn).

Signature

GetSSQSealOwner( int nSeal )

Parameters

nSeal (int) — seal number (manual_pch): 1 = Avarice, 2 = Revelation,
    3 = Strife. Return — the owning side: 0 = tie/nobody, 1 = Dusk, 2 = Dawn.

Example

i0 = GetSSQSealOwner(SSQLoserTeleport);
i1 = GetSSQSealOwner( SSQLoserTeleport );

Usage example

if ( GetSSQSealOwner( 1 ) == 1 ) {
    BroadcastSystemMessage( myself.sm, 0, 1215 );
}

GetTimeOfSSQNPC🟢 high

SSQ period boundary time

Available on CNPC (myself). Returns the timestamp of one of the Seven Signs period boundaries (in the same Unix seconds as GetTimeOfDay). The argument is a field index from 0 to 3: the engine stores four boundary timestamps of the event (e.g. start and end of collection, seal check, end of season), and nArg selects the needed one; any other value returns zero. The typical use is to compute how long remains until the end of the period: subtract the current time GetTimeOfDay() from the result.

Signature

GetTimeOfSSQ( int nIndex )

Parameters

nIndex (int) — index of the SSQ period boundary timestamp, 0..3 (the engine stores 4 timestamps; any other value → 0).

Example

i1 = GetTimeOfSSQ(1) - GetTimeOfDay();

Usage example

if ( ( ( ( i0 >= 0 && i0 < 18 ) || ( i0 >= 20 && i0 < 38 ) ) || ( i0 >= 40 && i0 < 58 ) ) || ( GetTimeOfSSQ( 1 ) - GetTimeOfDay( ) ) <= 120 ) {
    ShowPage( talker, "ssq_main_event_acolyte_q0505_22.htm" );
    RemoveMemo( talker, @blood_offering );
    return;
}

AddSSQMemberNPC🟢 high

register a player with a side

Registers a player with the chosen Seven Signs (SSQ) side, specifying the seal and the points to award.
Returns 1 if the registration was accepted, and 0 if no player was passed. The awarded points are 64-bit.

Signature

AddSSQMember( CSharedCreatureData cCreature, int nPart, int nType, int nSeal, int64 nPoints, int nArg5 )

Parameters

cCreature (CSharedCreatureData) — the player being registered with the SSQ side.
nPart   (int) — SSQ side: 1 = Dusk, 2 = Dawn.
nType   (int) — registration type (participant role); = 1 in the calls.
nSeal   (int) — chosen seal: 1 = Avarice, 2 = Revelation, 3 = Strife.
nPoints (int64) — points awarded on registration.
nArg5   (int) — additional participant registration parameter.

Example

if (AddSSQMember(talker, 2, 1, 2, i3, i4) == 0) {

Usage example

if ( AddSSQMember( talker, 2, 1, 2, i3, i4 ) == 0 ) {
    return;
}

GetDepositedSSQItemCountNPC🟢 high

number of deposited items

Available on CNPC (myself), takes a creature [CSharedCreatureData], the side nPart and the item type nType. Returns how many items (seals/symbols) the player has deposited. The side and type are passed as numbers; the exact semantics of some arguments are inferred from the calls.

Signature

GetDepositedSSQItemCount( CSharedCreatureData cCreature, int nPart, int nType )

Parameters

cCreature (CSharedCreatureData) — the player whose deposited items are counted.
nPart (int) — SSQ side: 1 = Dusk, 2 = Dawn.
nType (int) — category of the deposited item: observed values are 0 and 1 (two categories of seals/symbols).

Example

i0 = GetDepositedSSQItemCount( talker, 2, 0 );

DepositSSQItemNPC🟢 high

deposit an item

Available on CNPC (myself), takes a creature [CSharedCreatureData], the side nPart, the item type nType, the identifier nId and the count nCount. Deposits an item (seal/symbol) on the player's behalf. The side and type are passed as numbers; the exact semantics of some arguments are inferred from the signature.

Signature

DepositSSQItem( CSharedCreatureData cCreature, int nPart, int nType, int64 nId, int64 nCount )

Parameters

    cCreature (CSharedCreatureData) — the player on whose behalf the item is deposited.
    nPart  (int) — SSQ side: 1 = Dusk, 2 = Dawn.
    nType  (int) — category of the deposited item: 0/1 (two categories of seals/symbols).
    nId    (int64) — identifier of the deposited item.
    nCount (int64) — count of the deposited item.

Example (illustrative):

    DepositSSQItem( talker, nPart, nType, nId, nCount );

DeleteDepositedSSQItemNPC🟢 high

write off deposited items

Available on CNPC (myself), takes a creature [CSharedCreatureData], the side nPart, the item type nType and the count nCount. Writes off previously deposited items. The side and type are passed as numbers; the exact semantics of some arguments are inferred from the calls.

Signature

DeleteDepositedSSQItem( CSharedCreatureData cCreature, int nPart, int nType, int64 nCount )

Parameters

cCreature (CSharedCreatureData) — the player whose deposited items are written off
nPart (int) — SSQ side
nType (int) — type of the item being written off (seal/symbol)
nCount (int64) — number of items being written off

Example

DeleteDepositedSSQItem(talker, 2, 0, i0);

DeleteDepositedSSQItemAndGiveRewardsNPC🟢 high

write off deposited items and give rewards

Writes off nCount of the player's previously deposited Seven Signs items (seals/symbols) and
at the same time gives him the rewards he is entitled to. The side nPart and the item type
nType are set as numbers (see parameters).

Signature

DeleteDepositedSSQItemAndGiveRewards( CSharedCreatureData member, int nPart, int nType, int64 nCount )

Parameters

    member (CSharedCreatureData) — the player whose deposited items are written off and who receives the rewards
    nPart (int) — SSQ side
    nType (int) — type of the item being written off (seal/symbol)
    nCount (int64) — number of items being written off

Example (illustrative):

    DeleteDepositedSSQItemAndGiveRewards( talker, nPart, nType, nCount );

GetSSQMemberCountNPC🟢 high

number of side members

Returns the number of participants registered with the specified Seven Signs (SSQ) side: 1 = Dusk,
2 = Dawn.

Signature

GetSSQMemberCount( int nPart )

Parameters

    nPart (int) — the SSQ side whose participant count is returned: 1 = Dusk, 2 = Dawn.

Example (illustrative):

    GetSSQMemberCount( nPart );

GetSSQSealSelectionCountNPC🟢 high

number of seal selections

Returns how many participants of the specified Seven Signs side chose the specified seal (see
parameters — sides and seals).

Signature

GetSSQSealSelectionCount( int nPart, int nSeal )

Parameters

    nPart (int) — SSQ side: 1 = Dusk, 2 = Dawn.
    nSeal (int) — seal: 1 = Avarice, 2 = Revelation, 3 = Strife.

Example (illustrative):

    GetSSQSealSelectionCount( nPart, nSeal );

GetSSQTotalPointNPC🟢 high

total points of a side

Returns the total points of the specified Seven Signs side accumulated in the current cycle: 1 = Dusk,
2 = Dawn.

Signature

GetSSQTotalPoint( int nPart )

Parameters

    nPart (int) — the SSQ side whose total points are returned: 1 = Dusk, 2 = Dawn.

Example (illustrative):

    GetSSQTotalPoint( nPart );

GetSSQPrevWinnerNPC🟢 high

previous winner

Returns the winning side of the previous Seven Signs cycle: 1 = Dusk, 2 = Dawn,
0 — tie/no winner. Scripts compare the result with 2 to find out whether
Dawn won.

Signature

GetSSQPrevWinner(  )

Parameters

(none — the function is called without arguments)

Example

if (GetSSQPrevWinner() == 2) {

GetSSQRoundNumberNPC🟢 high

round number

Returns the number of the current Seven Signs period (round) — the counter of competition
cycles. In the example it is used as an item subtype: the "lord of manor's agreement" is
valid within its own round.

Signature

GetSSQRoundNumber(  )

Parameters

(none — the function is called without arguments)

Example

if (IsInCategory(@third_class_group, talker.occupation) == 1 && OwnItemCountEx(talker, 5708, GetSSQRoundNumber()) > 0) {

Usage example

if ( IsInCategory( @third_class_group, talker.occupation ) == 1 && OwnItemCountEx( talker, @the_lord_of_manor_s_agreement, GetSSQRoundNumber( ) ) > 0 ) {
    ShowPage( talker, szName + "_" + QUEST_ID + "_07.htm" );
}

GetTicketBuyCountNPC🟢 high

the number of purchased tickets

Returns the number of tickets already bought by the player talker in the current period (a daily limit). A creature method (myself).

Signature

GetTicketBuyCount( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`talker`) whose purchased tickets are counted

Example

if ( GetTicketBuyCount( talker ) < ( SSQ_DawnTicketQuantity / SSQ_DawnTicketBundle ) ) {

SetTicketBuyCountNPC🟢 high

set the number of tickets

Sets the player talker's purchased-ticket counter to the value count (usually the current value plus one). No return. A creature method (myself).

Signature

SetTicketBuyCount( CSharedCreatureData c, int nCount )

Parameters

c (CSharedCreatureData) — the player (talker) whose ticket counter is set.
nCount (int) — the new value of the purchased-ticket counter (usually current + 1).

Example

SetTicketBuyCount( talker, ( GetTicketBuyCount( talker ) + 1 ) );
SetTicketBuyCount(talker, GetTicketBuyCount(talker) + 1);

DepositSSQItemExNPC🟢 high

deposit funds into the SSQ manor account

Deposits money into the SSQ manor account when trading seeds and crops. Takes the
recipient (talker), the operation type, and three quantity values, as well as the final
computed coefficient; called on myself. Returns a success flag (1/0).

Signature

DepositSSQItemEx( CSharedCreatureData cCreature, int nPart, int64 nCount1, int64 nCount2, int64 nCount3, int64 nCalcTotal )

Parameters

cCreature  (CSharedCreatureData) — the recipient creature of the operation (talker).
nPart      (int) — the SSQ side: 1 = Dusk, 2 = Dawn. In calls = 2.
nCount1    (int64) — the first quantity (e.g. the number of turned-in seals/seeds; in calls reply or i0).
nCount2    (int64) — the second quantity (in calls 0 if not used).
nCount3    (int64) — the third quantity (in calls 0 if not used).
nCalcTotal (int64) — the final computed value — a weighted sum of the quantities
                     (e.g. (nCount1 + nCount2) + nCount3 * 10).

Example

if ( DepositSSQItemEx( talker, 2, i0, i1, i2, ( ( i0 + i1 ) + ( i2 * 10 ) ) ) ) {

Usage example

if ( DepositSSQItemEx( talker, 2, reply, 0, 0, i0 ) ) {
    DeleteItem1( talker, @blue_sealstone, reply );
    ShowPage( talker, szName + "_" + QUEST_ID + "_25.htm" );
} else {
    ShowSystemMessage( talker, 1279 );
}

Time Attack

7 functions

GetTimeAttackRecordInfoGLOBAL🟢 high

get a time-attack record

A method of the global object CGlobalObject. By three numeric keys (event_id, stage_id, rank) and an ordinal index returns a string with information about a time-attack record — the player's name, the completion time, the date.

Signature

GetTimeAttackRecordInfo( int nEventId, int nStageId, int nRank, int nIndex )

Parameters

nEventId (int) — the identifier of the time-attack event (`event_id`)
nStageId (int) — the identifier of the time-attack stage (`stage_id`)
nRank    (int) — the record's rank (`rank`)
nIndex   (int) — the ordinal index of the record in the list

Example

s0 = GetTimeAttackRecordInfo( RoomIndex, i1, 1, 0 );

GetTimeAttackRewardFlagGLOBAL🟢 high

check whether the reward was given

Checks for a creature whether it has already received the reward for a time-attack run with the given event_id; return: 1 — received, 0 — not.

Signature

GetTimeAttackRewardFlag( CSharedCreatureData cCreature, int nEventId )

Parameters

cCreature (CSharedCreatureData) — the creature whose reward receipt is checked
nEventId  (int) — the identifier of the time-attack event (`event_id`)

Example

if ( GetTimeAttackRewardFlag( talker, 1 ) ) {

Usage example

if ( GetTimeAttackRewardFlag( talker, 1 ) ) {
    ShowPage( talker, "ssq_main_event_acolyte_q0505_19.htm" );
    return;
}

IsWinnerOfTimeAttackEventGLOBAL🟢 high

check whether it is the run's winner

Checks whether a creature is the winner of a time-attack run with the given event_id; return: 1 — yes.

Signature

IsWinnerOfTimeAttackEvent( CSharedCreatureData cCreature, int nEventId )

Parameters

cCreature (CSharedCreatureData) — the creature checked for a win in the run
nEventId  (int) — the identifier of the time-attack event (`event_id`)

Example

if ( IsWinnerOfTimeAttackEvent( talker, 1 ) == 0 ) {

Usage example

if ( IsWinnerOfTimeAttackEvent( talker, 1 ) == 0 ) {
    ShowPage( talker, "ssq_main_event_acolyte_q0505_17.htm" );
    return;
}

GetTimeAttackFeeNPC🟢 high

learn the run entry cost

By the numeric event_id returns the entry cost of a time-attack run (in adena). Called on an NPC object.

Signature

GetTimeAttackFee( int nEventId )

Parameters

nEventId (int) — the identifier of the run event whose entry cost is returned (in adena).

Example

i1 = GetTimeAttackFee( i0 );

AddTimeAttackFeeNPC🟢 high

pay the run entry fee

Pays the fee (points) for entry into a time-attack run. Per the L2Server handler (AtomicAddTimeAttackFee::Do →
TimeAttackBoard::AddFee_6BBFB0) the server finds the run's "room" by the event number and ADDS
the passed amount to the accumulated fee value for this room (with a check: an invalid room
or too large a value, above ~100 billion, is rejected with an error to the log). The first argument is
the event/room number, the rest form the accumulated fee amount. Returns the result (1 — success).

Signature

AddTimeAttackFee( int nEventId, int nFee, int nPartyId )

Parameters

nEventId (int) — the run event/room number (in calls 1; searched on the time-attack board).
nFee (int) — the fee amount added to the room's accumulated value (in calls 2700).
nPartyId (int) — the id of the participant/party paying the fee (in calls party0.id).

Example

AddTimeAttackFee( 1, 2700, party0.id );

AddTimeAttackRecordNPC🟢 high

record a new run record

Records a time-attack run record bound to the Seven Signs (SSQ). The roles of the arguments are revealed by
the server function (L2Server: AtomicAddTimeAttackRecord::Do → TimeAttackBoard::AddRecord), its
signature: AddRecord(nRoomNo, SSQPart nPartType, nPartySID, nPoint, nRecordTime, nElapsedTime).
The server checks that the SSQ side is 1 or 2 and that all party members belong to that side
(otherwise system message 1367), adds the points to the accumulated SSQ points of that side (with a
limit check) and writes the record to the DB. Returns 1 on success.

Signature

AddTimeAttackRecord( int nRoomNo, int nSSQPart, int nPartySID, int nPoint, int nRecordTime, int nElapsedTime )

Parameters

nRoomNo (int) — the run room/event number (in calls 1).
nSSQPart (int) — the Seven Signs side: 1 = Dusk, 2 = Dawn (in calls 2).
nPartySID (int) — the SID of the participant party (in calls party0.id; all members must be of this SSQ side).
nPoint (int) — the points credited to the SSQ side (in the call OwnItemCount(@q_blood_of_offering); with a limit check).
nRecordTime (int) — the record time (in the call GetTimeOfDay()).
nElapsedTime (int) — the elapsed time (in the call GetMemoState(@blood_offering)).

Example

AddTimeAttackRecord( 1, 2, party0.id, OwnItemCount( talker, @q_blood_of_offering ), GetTimeOfDay( ), GetMemoState( talker, @blood_offering ) );

GiveTimeAttackRewardNPC🟢 high

give the run reward

Gives a creature the run reward: event_id, item (item_id), and quantity; return: 1 — success. Called on an NPC object.

Signature

GiveTimeAttackReward( CSharedCreatureData c, int nEventId, int nItemId, int nCount )

Parameters

c (CSharedCreatureData) — the creature given the reward.
nEventId (int) — the identifier of the run event.
nItemId (int) — the identifier of the reward item.
nCount (int) — the quantity of the reward item.

Example

GiveTimeAttackReward( talker, 1, 5575, i1 );

Event rooms (Event Room)

3 functions

GetPartyFromEventRoomGLOBAL🟢 high

take a party from an event room

By the key room_id and the ordinal index party_index returns a party from an event's virtual room.

Signature

GetPartyFromEventRoom( int nRoomId, int nPartyIndex )

Parameters

nRoomId     (int) — the identifier of the event room (room_id)
nPartyIndex (int) — the ordinal index of the party in the room

Example

party0 = GetPartyFromEventRoom( RoomIndex, SSQPart );

Usage example

party0 = GetPartyFromEventRoom( RoomIndex, SSQPart );
if ( IsNull( party0 ) ) { return; }

AddPartyToEventRoomGLOBAL🟢 high

add a party to an event room

Adds a party to an event's virtual room by the keys room_id and party_id with a service parameter; return: 1 — success.

Signature

AddPartyToEventRoom( int nRoomId, int nPartyId, int nArg )

Parameters

nRoomId  (int) — the identifier of the event room (room_id)
nPartyId (int) — the identifier of the party being added (party_id)
nArg     (int) — the service parameter for the addition (in calls — the party object id party0.id)

Example

if ( AddPartyToEventRoom( 1, 2, party0.id ) ) {

ClearEventRoomGLOBAL🟢 high

clear an event room

Clears an event's virtual room by the key room_id with two service parameters; returns the result.

Signature

ClearEventRoom( int nRoomId, int nArg1, int nArg2 )

Parameters

nRoomId (int) — the identifier of the event room (room_id)
nArg1   (int) — the service parameter for clearing
nArg2   (int) — the service parameter for clearing

Example

ClearEventRoom( room_index, part_type, 1 );
ClearEventRoom( room_index, part_type, 0 );

Gifts & anniversaries (Gifts)

5 functions

IsCreateDateGLOBAL🟢 high

check the character's creation day

Checks whether the current day falls on the character's creation date. Takes the
recipient (talker); returns 1 (yes) or 0 (no).

Signature

IsCreateDate( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player creature (talker) whose creation date is checked

Example

if ( IsCreateDate( talker ) == 1 ) {

CanGetBirthdayGiftGLOBAL🟢 high

whether a birthday gift can be given

Checks whether the player can receive a birthday gift. Takes the recipient
(talker); returns 1 (yes) or 0 (no).

Signature

CanGetBirthdayGift( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player creature (talker) checked for eligibility to receive the gift

Example

if ( CanGetBirthdayGift( talker ) == 1 ) {

SaveGetBirthdayGiftTimeGLOBAL🟢 high

save the time a birthday gift was given

Saves the time a birthday gift was received (for a subsequent cooldown).
Takes the recipient (talker); returns nothing.

Signature

SaveGetBirthdayGiftTime( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player creature (talker) for whom the gift-issue time is saved

Example

SaveGetBirthdayGiftTime( talker );

CanGet5YearGiftGLOBAL🟢 high

whether the 5-year reward can be given

Checks whether the player can receive the reward for 5 years of play. Takes the recipient
(talker); returns 1 (yes) or 0 (no).

Signature

CanGet5YearGift( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player creature (talker) checked for eligibility to receive the 5-year reward

Example

if (CanGet5YearGift(talker) == 1) {

Usage example

if (CanGet5YearGift(talker) == 1) {
    GiveItem1( talker, @adena, ( 300 * QuestAdenaRate ) );
    SaveGet5YearGiftTimeCount(talker);
    ShowPage(talker, "event_master_yogi_5th_success_q01_23.htm");
} else {
    ShowPage(talker, "event_master_yogi_5th_failed_q01_24.htm");
}

SaveGet5YearGiftTimeCountGLOBAL🟢 high

save the 5-year reward issue counter

Saves (increments) the counter of receiving the reward for 5 years of play. Takes the
recipient (talker); returns nothing.

Signature

SaveGet5YearGiftTimeCount( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player creature (talker) whose reward-issue counter is incremented

Example

SaveGet5YearGiftTimeCount(talker);

Bingo

6 functions

SelectBingoNumberNPC🟢 high

select a number on the bingo board

Selects the cell nCell on the player talker's bingo board; returns the selection result (a success/error code). A creature method (myself).

Signature

SelectBingoNumber( CSharedCreatureData c, int nCell )

Parameters

c (CSharedCreatureData) — the player (talker) on whose board the cell is selected.
nCell (int) — the index of the selected bingo board cell.

Example

SelectBingoNumber( talker, 1 );

IsSelectedBingoNumberNPC🟢 high

check whether a number is selected

Checks whether a number is selected in the cell nCell on the player talker's board; returns 1 if selected, 0 otherwise. A creature method (myself).

Signature

IsSelectedBingoNumber( CSharedCreatureData c, int nCell )

Parameters

c (CSharedCreatureData) — the player (talker) on whose board the cell is checked.
nCell (int) — the index of the checked bingo board cell.

Example

if ( IsSelectedBingoNumber( talker, i1 ) == 1 ) {

Usage example

if ( IsSelectedBingoNumber( talker, i1 ) == 1 ) {
    FHTML_SetInt( fhtml0, "Cell" + ( i0 + 1 ), i1 );
} else {
    FHTML_SetStr( fhtml0, "Cell" + ( i0 + 1 ), "?" );
}

GetNumberFromBingoBoardNPC🟢 high

get the number from a board cell

Extracts the number value from the cell nCell of the player talker's bingo board (by index); returns the number itself. A creature method (myself).

Signature

GetNumberFromBingoBoard( CSharedCreatureData c, int nCell )

Parameters

c (CSharedCreatureData) — the player (talker) from whose board the number is read.
nCell (int) — the index of the bingo board cell.

Example

i1 = GetNumberFromBingoBoard( talker, i0 );

Usage example

i1 = GetNumberFromBingoBoard( talker, i0 );
if ( IsSelectedBingoNumber( talker, i1 ) == 1 ) {
    FHTML_SetInt( fhtml0, "Cell" + ( i0 + 1 ), i1 );
} else {
    FHTML_SetStr( fhtml0, "Cell" + ( i0 + 1 ), "?" );
}

GetBingoSelectCountNPC🟢 high

the number of selected numbers

Returns the number of already-selected numbers on the player talker's board. A creature method (myself).

Signature

GetBingoSelectCount( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`talker`) whose number of selected numbers is counted

Example

i3 = GetBingoSelectCount( talker );

ClearBingoBoardNPC🟢 high

clear the bingo board

Resets the player talker's bingo board: zeroes the selection and the selected counter. No return. A creature method (myself).

Signature

ClearBingoBoard( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`talker`) whose bingo board is reset

Example

ClearBingoBoard( talker );

GetMatchedBingoLineCountNPC🟢 high

the number of matched lines

Returns the number of matched lines (horizontal, vertical, or diagonal) on the player talker's board. A creature method (myself).

Signature

GetMatchedBingoLineCount( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`talker`) whose matched lines are counted

Example

i3 = GetMatchedBingoLineCount( talker );

Lotto

11 functions

CanLottoNPC🟢 high

is the lottery available on the server

Checks whether the lottery system is enabled on the server; returns 1 (@TRUE) if available, 0 otherwise. Called without an object.

Signature

CanLotto(  )

Parameters

(none — the function is called without arguments)

Example

if (CanLotto() == @TRUE)

Lotto_GetStateNPC🟢 high

the lottery state

Returns the current state of the lottery (closed/open, etc.). No arguments. A creature method (myself).

Signature

Lotto_GetState(  )

Parameters

(none — the function is called without arguments)

Example

if ( myself.i_ai0 != Lotto_GetState( ) ) {

Usage example

if ( Lotto_GetState( ) != 3 ) {
    return;
}

Lotto_GetRoundNumberNPC🟢 high

the current lottery round number

Returns the number of the current lottery round (draw). No arguments. A creature method (myself).

Signature

Lotto_GetRoundNumber(  )

Parameters

(none — the function is called without arguments)

Example

Shout( MakeFString( 1000284, "" + Lotto_GetRoundNumber( ), Lotto_GetChosenNumber( ), "", "", "" ) );

Lotto_GetChosenNumberNPC🟢 high

the round's winning numbers

Returns a string of the current lottery round's winning numbers (numbers). No arguments. A creature method (myself).

Signature

Lotto_GetChosenNumber(  )

Parameters

(none — the function is called without arguments)

Example

Shout( MakeFString( 1000284, "" + Lotto_GetRoundNumber( ), Lotto_GetChosenNumber( ), "", "", "" ) );

Lotto_GetAccumulatedRewardNPC🟢 high

the accumulated lottery prize

Returns the total amount of the accumulated jackpot (prize) in the lottery. No arguments. A creature method (myself).

Signature

Lotto_GetAccumulatedReward(  )

Parameters

(none — the function is called without arguments)

Example

FHTML_SetInt( fhtml0, "current_reward", Lotto_GetAccumulatedReward( ) );

Lotto_BuyTicketNPC🟢 high

buy a lottery ticket

Buys the player talker a lottery ticket with selected numbers and deducts the cost. Per the
L2NPC decompile (CNPC::Lotto_BuyTicket_4A1CF0) the second argument is a bit mask of selected
numbers: the engine counts the set bits and requires exactly 5 (otherwise it logs
"invalid bit flag. hack?"), and the third argument is the cost in adena (item
57=adena is deducted for this amount). The sale is possible only in the LTS_SELLING state. No return.

Signature

Lotto_BuyTicket( CSharedCreatureData c, int nNumbersMask, int nCost )

Parameters

c (CSharedCreatureData) — the player (talker) for whom the lottery ticket is bought.
nNumbersMask (int) — the bit mask of selected lottery numbers (exactly 5 bits; in calls reply).
nCost (int) — the ticket cost in adena (deducted; in calls 2000).

Example

Lotto_BuyTicket( talker, reply, 2000 );

Lotto_GiveRewardNPC🟢 high

pay out the lottery reward

Pays out to the player talker the reward for the result reply (the winning number). No return. A creature method (myself).

Signature

Lotto_GiveReward( CSharedCreatureData c, int nResult )

Parameters

c (CSharedCreatureData) — the player (talker) to whom the reward is paid out.
nResult (int) — the result/winning number (in calls reply).

Example

Lotto_GiveReward( talker, reply );

Usage example

if ( ask == -801 ) {
    Lotto_GiveReward( talker, reply );
    Lotto_ShowCurRewardPage( talker, 0 );
}

Lotto_ShowBuyingPageNPC🟢 high

show the ticket purchase page

Generates the HTML page of the ticket purchase interface for the player talker (page number page) and fills the fhtml object. No return. A creature method (myself).

Signature

Lotto_ShowBuyingPage( CSharedCreatureData c, int nPage, CFHTML fhtml )

Parameters

c (CSharedCreatureData) — the player (talker) who is shown the purchase page.
nPage (int) — the interface page number.
fhtml (CFHTML) — the HTML object to fill.

Example

Lotto_ShowBuyingPage( talker, 0, fhtml0 );
Lotto_ShowBuyingPage( talker, talker.param1, fhtml0 );

Lotto_ShowCurRewardPageNPC🟢 high

show the current rewards

Shows the player talker the list of current (active) rewards/winnings by page page. No return. A creature method (myself).

Signature

Lotto_ShowCurRewardPage( CSharedCreatureData c, int nPage )

Parameters

c (CSharedCreatureData) — the player (talker) who is shown the current rewards.
nPage (int) — the list page number.

Example

Lotto_ShowCurRewardPage( talker, 0 );
Lotto_ShowCurRewardPage( talker, reply );

Lotto_ShowPrevRewardPageNPC🟢 high

show past rewards

Shows the player talker the archive of past rounds and their results by page page. No return. A creature method (myself).

Signature

Lotto_ShowPrevRewardPage( CSharedCreatureData c, int nPage )

Parameters

c (CSharedCreatureData) — the player (talker) who is shown the archive of past rounds.
nPage (int) — the archive page number.

Example

Lotto_ShowPrevRewardPage( talker, 0 );
Lotto_ShowPrevRewardPage( talker, reply );

Lotto_MakeFinalRewardFHTMLNPC🟢 high

build the final results HTML

Generates the final HTML report of the lottery results and fills the fhtml object. No return. A creature method (myself).

Signature

Lotto_MakeFinalRewardFHTML( CFHTML fhtml )

Parameters

fhtml (CFHTML) — the HTML object to fill with the final report.

Example

Lotto_MakeFinalRewardFHTML( fhtml0 );

Minigame MG (MG)

4 functions

MG_JoinGameNPC🟢 high

join a minigame

Registers the player talker for participation in a minigame and initiates preparation. No return. A creature method (myself).

Signature

MG_JoinGame( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`talker`) registered for participation in the minigame

Example

MG_JoinGame( talker );

Usage example

    if ( ask == -200 ) {
        MG_JoinGame( talker );
    }

Related event: the server's response arrives as the MG_JOIN_GAME_RETURNED event (see NASC_HANDLERS).

MG_SetWinnerNPC🟢 high

declare the winner

Declares the clan clanObj the winner of the minigame (by context — paying out the prize and updating the status). No return. A creature method (myself).

Signature

MG_SetWinner( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the object of the minigame's winner clan (`clanObj`)

Example

MG_SetWinner( c0 );
MG_SetWinner( c1 );

Usage example

if ( IsNullCreature( c1 ) == 0 && DistFromMe( c1 ) < 1000 ) {
    MG_SetWinner( c1 );
    BroadcastScriptEvent( 0, 20002, 8000 );
    return;
}

MG_UnregisterPledgeNPC🟢 high

cancel minigame registration

Removes the player/clan talker's registration from participation in the minigame (bet cancellation). No return. A creature method (myself).

Signature

MG_UnregisterPledge( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player/clan (`talker`) whose minigame registration is removed

Example

    MG_UnregisterPledge( talker );

Related event: the server's response arrives as the MG_UNREGISTER_PLEDGE_RETURNED event (see NASC_HANDLERS).

MG_GetUnreturnedPointNPC🟢 high

unreturned points

Returns the number of points not paid out to the player talker. The semantics of "unreturned points" is reconstructed from a single call. Called without an object.

Signature

MG_GetUnreturnedPoint( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player (`talker`) whose unpaid points are counted

Example

    MG_GetUnreturnedPoint(talker);

Related event: the server's response arrives as the MG_GET_UNRETURNED_POINT_RETURNED event (see NASC_HANDLERS).

Lucky Game

1 functions

ShowLuckyGameNPC🟢 high

show the Lucky Game

Opens for the player talker the Lucky Game interface; the argument mode sets the type/mode (for example, 2). No return. Called without an object.

Signature

ShowLuckyGame( CSharedCreatureData cCreature, int nGameType )

Parameters

cCreature (CSharedCreatureData) — the player (`talker`) for whom the Lucky Game interface is opened
nGameType (int) — the game type/mode (`mode`)

Example

ShowLuckyGame( talker, 2 );
ShowLuckyGame( talker, 1 );

FISHING EVENT (Fishing)

4 functions

GetFishingEventRankingNPC🟢 high

player's place in the fishing ranking

Returns the player's place in the fishing event ranking. Takes one argument — the player (talker) of type CSharedCreatureData. Returns an integer.

Signature

GetFishingEventRanking( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player whose place in the fishing event ranking is queried

Example

i0 = GetFishingEventRanking(talker);

Usage example

i0 = GetFishingEventRanking(talker);
if (i0 == 0) {
    Say("");
} else {
    Say(IntToStr(i0) + "");
}

ShowHtmlFishingEventRankingNPC🟢 high

show the ranking window

Shows the player the fishing event ranking window. Takes one argument — the player (talker) of type CSharedCreatureData. Returns an integer.

Signature

ShowHtmlFishingEventRanking( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player who is shown the fishing event ranking window

Example

ShowHtmlFishingEventRanking(talker);

GiveFishingEventPrizeNPC🟢 high

give a participation prize

Gives the player a prize for participating in the fishing event — sends the server a command
to grant the reward to the specified player. Takes one argument — the player (talker) of type CSharedCreatureData.
The function is real and working (the event is simply not used in the collected live scripts); the other
fishing functions nearby (ranking, time until reward, ranking window) are genuine too.

Signature

GiveFishingEventPrize( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player who is given the fishing event prize

Example

GiveFishingEventPrize(talker);

GetFishingEventRewardRemainTimeNPC🟢 high

time until the next reward distribution

Reports how long remains until the next fishing event reward distribution. Takes no arguments. Returns an integer.

Signature

GetFishingEventRewardRemainTime(  )

Parameters

(none — the function is called without arguments)

Example

if (GetFishingEventRewardRemainTime() == @FALSE)

Usage example

if (GetFishingEventRewardRemainTime() == 0) {
    ShowPage(talker, "no_fish_event_reward001.htm");
} else {
    GiveFishingEventPrize(talker);
}

PvP matchmaking (PvP Match)

10 functions

UpdatePVPPointNPC🟢 high

change a player's PvP points

Changes the creature's PvP points by the amount delta (may be negative). No return.

Signature

UpdatePVPPoint( CSharedCreatureData c, int nDelta )

Parameters

c (CSharedCreatureData) — the creature whose PvP points are changed.
nDelta (int) — the signed amount of the PvP points change (in calls -5000, i4).

Example

UpdatePVPPoint(talker, i4);

Usage example

if (IsInCategory(@third_class_group, talker.occupation) || IsInCategory(@fourth_class_group, talker.occupation) && talker.level >= 40) {
    UpdatePVPPoint(talker, -5000);
    IncrementParam(talker, 9, -1);
    ShowPage(talker, fnPkDownSuccess);
} else {
    ShowPage(talker, fnNoPvpPoint);
}

GetPVPPointNPC🟢 high

get a player's PvP points

Returns the creature's current number of PvP points.

Signature

GetPVPPoint( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature whose PvP points are returned

Example

if (GetPVPPoint(talker) < 0)

Usage example

if (GetPVPPoint(talker) < 0) {
    ShowPage(talker, fnNoPvpPoint);
} else {
    ShowMultisell(638, talker);
}

RegisterUserPVPMatchNPC🟢 high

register a player for a PvP match

Registers a creature for participation in a PvP match. No return.

Signature

RegisterUserPVPMatch( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature registered for the PvP match

Example

RegisterUserPVPMatch( talker );

Usage example

    if ( talker.level >= 70 && talker.level <= 75 ) {
        RegisterUserPVPMatch( talker );
    } else {
        ShowPage( talker, "cratae_teleport_npc010.htm" );
    }

Related event: the server's response arrives as the REGISTER_USER_PVP_MATCH_RESULT event (see NASC_HANDLERS).

UnregisterUserPVPMatchNPC🟢 high

remove a player from a PvP match

Cancels a creature's registration in a PvP match. No return.

Signature

UnregisterUserPVPMatch( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature whose PvP match registration is cancelled

Example

UnregisterUserPVPMatch( talker );
UnregisterUserPVPMatch( creature );
UnregisterUserPVPMatch( c0 );

Usage example

    if ( InMyTerritory( c0 ) == 0 ) {
        UnregisterUserPVPMatch( c0 );
    }

Related event: the server's response arrives as the UNREGISTER_USER_PVP_MATCH_RESULT event (see NASC_HANDLERS).

IsUserPVPMatchingNPC🟢 high

check participation in a PvP match

A diagnostic function: checks whether a creature is registered in a PvP match.

Signature

IsUserPVPMatching( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature checked for registration in a PvP match

Example

IsUserPVPMatching( creature );

Usage example

    if ( creature.is_pc == @TRUE ) {
        IsUserPVPMatching( creature );
    }

Related event: the server's response arrives as the IS_USER_PVPMATCHING_RESULT event (see NASC_HANDLERS).

CheckRegisterUserPVPMatchNPC🟢 high

check the conditions for PvP match registration

A diagnostic function: validates the preconditions for a creature's registration in a PvP match.

Signature

CheckRegisterUserPVPMatch( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature for which the PvP match registration preconditions are checked

Example

    CheckRegisterUserPVPMatch( talker );

Related event: the server's response arrives as the CHECK_REGISTER_USER_RESULT event (see NASC_HANDLERS).

AddKillPointUserPVPMatchNPC🟢 high

credit points for a kill

Adds kill points to a creature in a PvP match (kill_points). No return.

Signature

AddKillPointUserPVPMatch( CSharedCreatureData c, int nKillPoints )

Parameters

c (CSharedCreatureData) — the creature credited with kill points.
nKillPoints (int) — the number of kill points added.

Example

AddKillPointUserPVPMatch( c0, i0 );
AddKillPointUserPVPMatch(c0, my_point);

Usage example

if ( IsNullCreature( c0 ) == 0 ) {
    AddKillPointUserPVPMatch( c0, i0 );
    AddHateInfo( c0, i0, 0, 1, 1 );
}

GetRankUserPVPMatchNPC🟢 high

get the rank in the PvP ranking

A diagnostic function: returns a creature's current rating/rank in the PvP ranking.

Signature

GetRankUserPVPMatch( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the creature whose PvP-ranking rank is returned

Example

GetRankUserPVPMatch( c0 );

Usage example

    if ( IsNullCreature( c0 ) == 0 ) {
        GetRankUserPVPMatch( c0 );
    }

Related event: the server's response arrives as the GET_RANK_USER_PVP_MATCH_RESULT event (see NASC_HANDLERS).

UnregisterPVPMatchNPC🟢 high

remove a party from a team match

Cancels a party's registration from a team PvP match; takes a party and a creature. No return.

Signature

UnregisterPVPMatch( CSharedPartyData party, CSharedCreatureData c )

Parameters

party (CSharedPartyData) — the party being removed from match registration.
c (CSharedCreatureData) — the creature (the party's initiator/representative) from whom the cancellation comes.

Example

UnregisterPVPMatch(party0, c0);
UnregisterPVPMatch(party1, c2);
UnregisterPVPMatch(party0, talker);

Usage example

    if (IsNullCreature(c1) == 0) {
        UnregisterPVPMatch(party0, c0);
    }

Related event: the server's response arrives as the UNREGISTER_PVP_MATCH_RESULT event (see NASC_HANDLERS).

GetStatusForOlympiadFieldNPC🟢 high

get the Olympiad field status

By the numeric field_id returns the Olympiad field status: 0 — free, 1 — occupied. Called on an NPC object.

Signature

GetStatusForOlympiadField( int nFieldId )

Parameters

nFieldId (int) — the number of the Olympiad field whose status is requested (return: 0 — free, 1 — occupied).

Example

if ( GetStatusForOlympiadField( i0 ) == 0 ) {

Usage example

if (GetStatusForOlympiadField(i0) == 0) {
    FHTML_SetStr(fhtml0, "Status" + i0, "&$906;");
}

Team events (Team Event)

10 functions

TeamGetMembersCountNPC🟢 high

the number of members in a team

By the keys event_id and team_id returns the number of members in a team.

Signature

TeamGetMembersCount( int nEventId, int nTeamId )

Parameters

nEventId (int) — the identifier of the team event
nTeamId (int) — the identifier of the team within the event

Example

i8 = TeamGetMembersCount( my_Event, i0 );
i9 = TeamGetMembersCount( my_Event, 1 );
i9 = TeamGetMembersCount( my_Event, 2 );
i3 = TeamGetMembersCount( my_Event, talker.m_nPvP_Event_TeamId );

Usage example

i3 = TeamGetMembersCount( my_Event, talker.m_nPvP_Event_TeamId );
if ( i1 == 0 ) { i2 = myself.sm.subjob0_class + myself.sm.subjob1_class; i3 = TeamGetMembersCount( my_Event, 1 ) + TeamGetMembersCount( my_Event, 2 ); }

TeamEventGetStatusNPC🟢 high

the team event status

By event_id returns the team event status: 0 — inactive, 1 — active.

Signature

TeamEventGetStatus( int nEventId )

Parameters

nEventId (int) — the identifier of the team event whose status is requested

Example

if ( TeamEventGetStatus( my_Event ) == @TEAMEVENT_STATUS_BATTLE ) {

Usage example

if ( TeamEventGetStatus( my_Event ) == @TEAMEVENT_STATUS_NOMINATION ) {
    SendScriptEventEx( myself.sm, seDirectorShowPage, pageNomination, talker.id ); // show the results output page
}

TeamEventSetStatusNPC🟢 high

set the team event status

Sets the status of a team event by event_id and the value status. No return.

Signature

TeamEventSetStatus( int nEventId, int nStatus )

Parameters

nEventId (int) — the identifier of the team event
nStatus (int) — the new event status (0 — inactive, 1 — active)

Example

TeamEventSetStatus( my_Event, @TEAMEVENT_STATUS_REGISTRATION);

Usage example

if ( timer_id == timer_teleport ) { // teleport the teams to town
    TeamEventSetStatus( my_Event, @TEAMEVENT_STATUS_NOMINATION );
    TeamInstantTeleport(my_Event, 1, Return_X, Return_Y, Return_Z );
    TeamInstantTeleport(my_Event, 2, Return_X, Return_Y, Return_Z );
    InstantTeleportInMyTerritory( Return_X, Return_Y, Return_Z, 50 );
}

TeamShowSystemMessage2NPC🟢 high

a system message to the whole team

Shows a system message to all members of a team: event_id, team_id, msg_id, the number of parameters, and the parameters themselves (unused ones — _blank).

Signature

TeamShowSystemMessage2( int nEventId, int nTeamId, int nSysMsgNo, int nParamCount, string pwsParam1, string pwsParam2, string pwsParam3, string pwsParam4, string pwsParam5, string pwsParam6, string pwsParam7 )

Parameters

nEventId (int) — the identifier of the team event
nTeamId (int) — the identifier of the team the message is sent to
nSysMsgNo (int) — the system message number
nParamCount (int) — the number of filled message parameters
pwsParam1 (string) — the 1st substitution parameter into the system message
pwsParam2 (string) — the 2nd substitution parameter into the system message
pwsParam3 (string) — the 3rd substitution parameter into the system message
pwsParam4 (string) — the 4th substitution parameter into the system message
pwsParam5 (string) — the 5th substitution parameter into the system message
pwsParam6 (string) — the 6th substitution parameter into the system message
pwsParam7 (string) — the 7th substitution parameter into the system message

Example

TeamShowSystemMessage2( my_Event, 1, 1983, 1, s0, _blank, _blank, _blank, _blank, _blank, _blank );

Usage example

if ( timer_id == 33328 ) { // message: Teleport in 1
    TeamShowSystemMessage2( my_Event, my_Team, sysCenterRed, 1, MakeFString( 3223119, "1", _blank, _blank, _blank, _blank ), _blank, _blank, _blank, _blank, _blank, _blank );
    AddTimerEx( 33323, 1000 );
}

TeamGetMemberByIndexNPC🟢 high

get a team member by index

By the keys event_id, team_id, and member_index returns a creature — a team member.

Signature

TeamGetMemberByIndex( int nEventId, int nTeamId, int nMemberIndex )

Parameters

nEventId (int) — the identifier of the team event
nTeamId (int) — the identifier of the team within the event
nMemberIndex (int) — the ordinal index of the team member

Example

c0 = TeamGetMemberByIndex( my_Event, i0, 0 );
c0 = TeamGetMemberByIndex( my_Event, i0, i1 );
c0 = TeamGetMemberByIndex( my_Event, 1, i8 );
c0 = TeamGetMemberByIndex( my_Event, 2, i8 );

Usage example

c0 = TeamGetMemberByIndex( my_Event, i0, i1 );
if ( IsNullCreature( c0 ) == 0 ) {
    GiveItem1( c0, defaultCostID, defaultCostAmount ); // return the entry fee
}

TeamAddMemberNPC🟢 high

add a player to a team

Adds a creature to a team by the keys event_id and team_id; returns the result.

Signature

TeamAddMember( int nEventId, int nTeamId, CSharedCreatureData target )

Parameters

nEventId (int) — the identifier of the team event
nTeamId (int) — the identifier of the team the member is added to
target (CSharedCreatureData) — the creature (player) added to the team

Example

TeamAddMember( my_Event, 1, c0 );
TeamAddMember( my_Event, 2, c0 );
TeamAddMember( my_Event, 3, talker );
TeamAddMember( my_Event, 4, talker );

Usage example

if ( TeamGetMembersCount( my_Event, 4) < 100 ) { // if team 4 is not yet full — add to it
    TeamAddMember( my_Event, 4, talker );
}

TeamRemoveMemberNPC🟢 high

remove a player from a team

Removes a creature from a team; returns the result.

Signature

TeamRemoveMember( CSharedCreatureData target )

Parameters

target (CSharedCreatureData) — the creature (player) removed from the team

Example

TeamRemoveMember( c0 );
TeamRemoveMember( target );

Usage example

if ( IsNullCreature( c0 ) == 0 ) {
    TeamRemoveMember( c0 );
    if ( myself.i_quest4 > 0 ) {
        GiveItem1( c0, myself.i_quest3, myself.i_quest4 );
    }
}

TeamSetRestartPointNPC🟢 high

a team's respawn point

Sets the respawn point for a team by the keys event_id, team_id and the coordinates x, y, z; returns the result.

Signature

TeamSetRestartPoint( int nEventId, int nTeamId, int nX, int nY, int nZ )

Parameters

nEventId (int) — the identifier of the team event
nTeamId (int) — the identifier of the team whose respawn point is set
nX (int) — the X coordinate of the respawn point
nY (int) — the Y coordinate of the respawn point
nZ (int) — the Z coordinate of the respawn point

Example

TeamSetRestartPoint(my_Event, 1, 147574, 46717, -3400);
TeamSetRestartPoint(my_Event, 2, 151496, 46717, -3400);

TeamGetInactiveCharactersNPC🟢 high

get inactive team members

By the keys event_id, team_id and the idle threshold in seconds (timeout_sec) returns the inactive team members.

Signature

TeamGetInactiveCharacters( int nEventId, int nTeamId, int nInactiveTimeSec )

Parameters

nEventId (int) — the identifier of the team event
nTeamId (int) — the identifier of the team
nInactiveTimeSec (int) — the idle threshold in seconds after which a member is considered inactive

Example

TeamGetInactiveCharacters( my_Event, 1, checkInnactiveCharPeriod * 60 );
TeamGetInactiveCharacters( my_Event, 2, checkInnactiveCharPeriod * 60 );

Usage example

if ( TeamEventGetStatus( my_Event ) == @TEAMEVENT_STATUS_BATTLE ) {
    TeamGetInactiveCharacters( my_Event, 1, checkInnactiveCharPeriod * 60 );
    TeamGetInactiveCharacters( my_Event, 2, checkInnactiveCharPeriod * 60 );

    AddTimerEx( 33319, checkInnactiveCharPeriod * 60000 );
}

TeamEventAddMembersWithBalanceNPC🟢 high

add members with balancing

Adds members to an event with automatic balancing: event_id, the member list, the number of teams (teams_count), and the category range (category_from, category_to); returns the result.

Signature

TeamEventAddMembersWithBalance( int nEventId, CIntList pIntList, int nTeamsNumber, int nBalanceCategoryFrom, int nBalanceCategoryTo )

Parameters

nEventId (int) — the identifier of the team event
pIntList (CIntList) — the list of identifiers of the added members
nTeamsNumber (int) — the number of teams the participants are distributed across
nBalanceCategoryFrom (int) — the lower bound of the balancing category
nBalanceCategoryTo (int) — the upper bound of the balancing category

Example

i0 = TeamEventAddMembersWithBalance( my_Event, myself.db_int_list, 2, tvt_group_start, tvt_group_end );

Cleft event (Cleft)

5 functions

GetCleftStateNPC🟢 high

state of the Cleft zone

Getter (CNPC), no arguments. Returns int — the current state of the Cleft zone (the rift).

Signature

GetCleftState(  )

Parameters

(none — the function is called without arguments)

Example

if ( GetCleftState( ) != 2 ) {

Usage example

if ( GetCleftState( ) != 2 ) {
    return;
}

CleftManagerEnterNPC🟢 high

cleft manager initialization

Initializes the cleft (Cleft) manager; called on zone creation.
Takes no arguments and returns nothing.

Signature

CleftManagerEnter(  )

Parameters

(none — the function is called without arguments)

Example

CleftManagerEnter();

CleftUserEnterNPC🟢 high

register a player in the cleft

Registers a player in the cleft system for tracking participants. Takes the
recipient (talker); returns nothing.

Signature

CleftUserEnter( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player creature (talker) registered in the cleft system

Example

CleftUserEnter(talker);

Usage example

if (IsCleftUser(talker) == 0) {
    CleftUserEnter(talker);
} else {
    ShowPage(talker, fnNoEnter);
}

IsCleftUserNPC🟢 high

check participation in the cleft

Checks whether a player is a participant in the cleft. Takes the recipient
(talker); returns 0 (no) or 1 (yes).

Signature

IsCleftUser( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player creature (talker) checked for participation in the cleft

Example

if (IsCleftUser(talker) == 0) {

Usage example

if (IsCleftUser(talker) == 0) {
    CleftUserEnter(talker);
} else {
    ShowPage(talker, fnNoEnter);
}

CleftCenterDestroyedNPC🟢 high

cleft center destruction handler

Handles the destruction of the cleft center and triggers the completion events.
Takes the zone type, a creature, and the destruction point; returns nothing.

Signature

CleftCenterDestroyed( int nZoneType, CSharedCreatureData c, int nDestroyPoint )

Parameters

nZoneType (int) — the cleft zone type.
c (CSharedCreatureData) — the creature associated with the center destruction.
nDestroyPoint (int) — the destruction point (position value) of the center.

Example

CleftCenterDestroyed( ZoneType, myself.c_ai0, DestroyPoint );

Block Checker (Block Upset)

6 functions

BlockUpsetNPC🟢 high

"upset" minigame initialization

Registers a participant of the BlockUpset minigame on the ground. Per the L2Server handler
(NpcSocket::NpcBlockUpset_756428) packet opcode 187 is a sub-command dispatcher by the first field;
the BlockUpset call corresponds to sub-command 1 → CBlockUpsetManager::AddBlockUpsetPoint (adds
a point/participant to the ground GroundID). The handler uses the participant creature and the ground id;
the second argument (nInitParam) is 0 in all calls and is not consumed by the registration path —
a reserved field. Returns nothing.

Signature

BlockUpset( int nGroundId, int nInitParam, CSharedCreatureData c, int nStartPoint )

Parameters

nGroundId (int) — the game ground identifier (GroundID).
nInitParam (int) — a reserved service field (always 0 in calls; not used by the server during registration).
c (CSharedCreatureData) — the participant creature (speller) added to the ground.
nStartPoint (int) — the participant's start point (BlockUpsetPoint).

Example

BlockUpset( GroundID, 0, speller, BlockUpsetPoint );
BlockUpset( GroundID, 0, GetCreatureFromIndex( script_event_arg2 ), BlockUpsetPoint );

Usage example

if ( script_event_arg1 == 9999 ) {
    BlockUpset( GroundID, 0, GetCreatureFromIndex( script_event_arg2 ), BlockUpsetPoint );
    SetVisible( 0 );
    AddTimerEx( 1000, 3000 );
}

BlockUpsetChangeAmountNPC🟢 high

set the number of blocks

Changes the number of blocks in the current game (14, 16, or 20). Takes the ground identifier
(GroundID) and the count; returns nothing.

Signature

BlockUpsetChangeAmount( int nGroundId, int nBlockCount )

Parameters

nGroundId (int) — the game ground identifier (GroundID).
nBlockCount (int) — the number of blocks (14, 16, or 20).

Example

BlockUpsetChangeAmount( GroundID, 16 );
BlockUpsetChangeAmount( GroundID, 20 );
BlockUpsetChangeAmount( GroundID, 14 );

Usage example

if ( timer_id == 2000 ) {
    BlockUpsetChangeAmount( GroundID, 14 );
}

BlockUpsetChangeColorNPC🟢 high

switch the block color

Switches the block color (0 or 1) to change the difficulty level. Takes the
ground identifier (GroundID) and the color identifier (ColorID); returns
nothing.

Signature

BlockUpsetChangeColor( int nGroundId, int nColorId )

Parameters

nGroundId (int) — the game ground identifier (GroundID).
nColorId (int) — the block color identifier (ColorID, 0 or 1).

Example

BlockUpsetChangeColor( GroundID, ColorID );

BlockUpsetRegisterMeNPC🟢 high

register the NPC in the game instance

Registers the current NPC as part of the game instance. Takes the ground identifier
(GroundID); returns nothing.

Signature

BlockUpsetRegisterMe( int nGroundId )

Parameters

nGroundId (int) — the game ground identifier (GroundID) to which the NPC is bound.

Example

BlockUpsetRegisterMe( GroundID );

BlockUpsetUserEnterNPC🟢 high

player entry into the game instance

Brings a player into the BlockUpset instance and prepares its state. Takes the
ground identifier (GroundID) and the recipient (talker); returns nothing.

Signature

BlockUpsetUserEnter( int nGroundId, CSharedCreatureData c )

Parameters

nGroundId (int) — the game ground identifier (GroundID).
c (CSharedCreatureData) — the player creature (talker) brought into the instance.

Example

BlockUpsetUserEnter( GroundID, talker );

BlockUpsetManagerEnterNPC🟢 high

game manager initialization

Initializes the game manager; called once on instance creation.
Takes the ground identifier (GroundID); returns nothing.

Signature

BlockUpsetManagerEnter( int nGroundId )

Parameters

nGroundId (int) — the game ground identifier (GroundID) for which the manager is created.

Example

BlockUpsetManagerEnter( GroundID );

Misc events & system (Misc)

11 functions

IsUserLockedGLOBAL🟢 high

check the player's lock status

Checks whether the player is in a locked status. Takes the recipient
(talker); returns 1 (locked) or 0 (no).

Signature

IsUserLocked( CSharedCreatureData c )

Parameters

c (CSharedCreatureData) — the player creature checked for lock status

Example

if ( IsUserLocked( talker ) ) {

Usage example

if ( IsUserLocked( talker ) ) {
    ShowPage( talker, "locked_user.htm" );
    return;
}

GetRank_RimKamarokaGLOBAL🟢 high

the player's rank in the boss ranking

Returns a string with the player's data in the Rim/Kamaroka boss ranking. Takes the
level and the request type (2 — rank, 4 — XP); returns a string.

Signature

GetRank_RimKamaroka( int nRimType, int nLevel )

Parameters

nRimType (int) — the type of ranking-data request (2 — rank, 4 — XP)
nLevel (int) — the level for which the ranking data is requested

Example

if ( IsSameString( GetRank_RimKamaroka( i6, 2 ), _blank ) == 1 ) {

Usage example

if ( i6 >= 7 && i6 <= 14 && IsSameString( GetRank_RimKamaroka( ( i6 - 5 ), 2 ), _blank ) != 1 ) {
    if ( babble_mode == 1 ) { Shout( "Rank propagation " + IntToStr( i6 - 5 ) ); }
    s0 = MakeFString( 1800200, _blank, _blank, _blank, _blank, _blank );
    Say( MakeFString( 1800202, GetRank_RimKamaroka( ( i6 - 5 ), 2 ), s0, _blank, _blank, _blank ) );
} else {
    if ( babble_mode == 1 ) { Shout( "Rank propagation failed" ); }
}

Party_GetSubLeaderGLOBAL🟢 high

get a party's sub-leader

Returns the sub-leader of the player's party. Takes the recipient (talker);
returns an object/creature (in the example assigned to a creature-type variable).

Signature

Party_GetSubLeader( CSharedCreatureData cCreature )

Parameters

cCreature (CSharedCreatureData) — the player creature (talker) whose party is queried for the sub-leader

Example

c1 = Party_GetSubLeader(talker);

BroadCastUIEventNpcStrGLOBAL🟢 high

broadcast a UI event to all players in a zone

Broadcasts a UI event (for example, an airship one) to all players in a zone. Takes an NPC,
the event identifier, and a set of numeric and string parameters (coordinates,
message); returns nothing.

Signature

BroadCastUIEventNpcStr( CSharedCreatureData cCreature, int nRange, int nShowTimer, int nUnk1, int nUnk2, string pwsTimerType, string pwsStartTimeMin, string pwsStartTimeSec, int nNpcStringId, string pwsEndTimeMin, string pwsEndTimeSec )

Parameters

cCreature (CSharedCreatureData) — the source NPC of the broadcast UI event
nRange (int) — the broadcast radius of the event around the NPC
nShowTimer (int) — the flag for displaying the timer
nUnk1 (int) — a service numeric parameter of the event
nUnk2 (int) — a service numeric parameter of the event
pwsTimerType (string) — the timer type of the event
pwsStartTimeMin (string) — the minutes of the timer's start time
pwsStartTimeSec (string) — the seconds of the timer's start time
nNpcStringId (int) — the identifier of the NPC string for the message
pwsEndTimeMin (string) — the minutes of the timer's end time
pwsEndTimeSec (string) — the seconds of the timer's end time

Example

    BroadCastUIEventNpcStr( myself.sm, 2000, 0, 0, 0, "0", IntToStr( myself.i_ai2 ), "00", SUMMON_AIRSHIP_MESSAGE_ID + 3 , "0", "0" );




================================================================================
================================================================================
PART II.  NPC FUNCTIONS
================================================================================
================================================================================

Methods of the character (NPC) itself. Called in NPC scripts; the notation is short,
without `myself.` (the receiver is the character itself).

CheckRegisterParty2NPC🟢 high

check two parties for a team match

A diagnostic function: validates whether two parties can register for a team match.

Signature

CheckRegisterParty2( CSharedPartyData party1, CSharedPartyData party2 )

Parameters

party1 (CSharedPartyData) — the first party registered for the team match.
party2 (CSharedPartyData) — the second party checked for the possibility of joint registration.

Example

CheckRegisterParty2(party0, party1);

Usage example

if (myself.i_quest0 == 1 && myself.i_quest3 == 1) {
    CheckRegisterParty2(party0, party1);
}

IsEventDropTimeNPC🟢 high

is the event drop time in effect

Checks whether the event drop time is currently in effect. Takes no arguments;
returns 1 (yes) or 0 (no).

Signature

IsEventDropTime(  )

Parameters

(none — the function is called without arguments)

Example

if ( IsEventDropTime( ) == 1 ) {

Usage example

if ( IsEventDropTime( ) == 1 ) {
    ShowPage( talker, fnHi );
} else {
    ShowPage( talker, fnHi2 );
}

SetPrivateIDNPC🟢 high

set the private ID of an object

Sets the private identifier for an NPC/object. Takes the ID value (often
the product of part_type by room_index); called on myself, returns
nothing.

Signature

SetPrivateID( int nId )

Parameters

nId (int) — the private identifier assigned to the NPC/object (often part_type * room_index).

Example

SetPrivateID( ( part_type * room_index ) );

GetPlayingUserCountNPC🟢 high

the number of active players on the server

Returns the number of active players on the server. Takes no arguments;
the returned value is not used explicitly in the decoded scripts.

Signature

GetPlayingUserCount(  )

Parameters

(none — the function is called without arguments)

Example

GetPlayingUserCount( );

IsAutoMacroUseNPC🟢 high

check macro usage

Checks whether a player uses macros. Takes the target (target); returns
1 (yes) or 0 (no), in the example compared with @TRUE.

Signature

IsAutoMacroUse( CSharedCreatureData c )

Parameters

c (CSharedCreatureData) — the target creature (target) checked for macro usage

Example

if (HaveMemo(target, @c_development_quest70) == @TRUE && GetMemoState(target, @c_development_quest70) == 2 && IsAutoMacroUse( target ) == @TRUE)

Usage example

if (HaveMemo(target, @c_development_quest70) == @TRUE && GetMemoState(target, @c_development_quest70) == 2 && IsAutoMacroUse( target ) == @TRUE)
{
    i0 = @c_development_quest70;
    i1 = @c_development_item7;
    i2 = 100;
    i3 = 15;
}

RegisterPledgeUpEventListenerNPC🟢 high

register a clan event listener

Registers a listener for clan level-up events. Takes no arguments and
returns nothing.

Signature

RegisterPledgeUpEventListener(  )

Parameters

(none — the function is called without arguments)

Example

RegisterPledgeUpEventListener();

XMasEventManagerEnterNPC🟢 high

Christmas event initialization

Initializes the Christmas event (Xmas). Takes no arguments and returns
nothing.

Signature

XMasEventManagerEnter(  )

Parameters

(none — the function is called without arguments)

Example

XMasEventManagerEnter();

Usage example

    if (is_main_manager) {
        XMasEventManagerEnter();
    }


================================================================================
================================================================================
PART III.  MAKER (SPAWNER) FUNCTIONS
================================================================================
================================================================================

Methods of the spawner/maker (NpcMaker) — spawning and respawning NPCs, registering
territory events. Called in NpcMaker scripts.

LOGGING (Log)

8 functions

AddLogGLOBAL🟢 high

write an entry to the player action log

Adds an entry to the player action log: the first argument is nLogType — the
entry type code, the second is the player c, the third is the related identifier nParam.
The type defines the meaning: 1 — quest acceptance, 2 — progress update, 3 — completion (the
three most common), 6 — item obtained; other codes (4, 7–11 and named constants of the
@LOG_* form from [manual_pch]) cover other categories. Important subtlety: the namespace
of the third argument depends on the type — for quest types 1/2/3 it is a quest id [quest_pch],
while for 6 it is the id of the item [item_pch] that was just given out; the function returns
nothing meaningful.

Signature

AddLog( int nLogType, CSharedCreatureData cCreature, int nParam )

Parameters

nLogType  (int) — log entry category code. Named constants [manual_pch] @LOG_*:
    1 GET_NOBLESS_GATE_PASS · 2 ERROR · 3 DEBUG · 4 OF_TIMEATTACK ·
    7 ENTER_CREVICE_OF_THE_DIMENSION · 8 LEAVE_CREVICE · 9 ENTER_ROYAL_RUSH ·
    10 CASTLE_WIZARD_TELEPORT · 111 PCCAFE_POINT_BUFF · 324 USE_CHANCE_CARD.
    NB: the observed usage of the small values with quests does NOT match these names
    (1/2/3 come massively with quest_id — by context the quest stages accept/progress/complete,
    6 — with an item id), i.e. the first argument is treated as a log category code, and some
    values (5, 6, 11) have no named constant at all.
cCreature (CSharedCreatureData) — the player.
nParam    (int) — related id; the namespace depends on the category: for quest values — [quest_pch],
    for "item obtained" (6) — [item_pch].

Example

AddLog( 2, talker, @deliver_goods );

AddLogExGLOBAL🟢 high

extended log entry with an additional numeric field

Extended version of AddLog with an additional numeric field nParam2. Takes nLogType
(event type code), the player c, and two related values nParam and nParam2; the namespace
of the fields depends on the event type. Belongs to the global object.

Signature

AddLogEx( int nLogType, CSharedCreatureData cCreature, int nParam, int nParam2 )

Parameters

nLogType  (int) — log entry category code (same space as AddLog: @LOG_* constants
    from [manual_pch], e.g. @LOG_USE_CHANCE_CARD=324; script-defined ones like Log_pc_LevDiff also occur).
cCreature (CSharedCreatureData) — the player associated with the entry
nParam    (int) — first related value of the entry (namespace depends on the category)
nParam2   (int) — second related value of the entry

Example

AddLogEx(@LOG_USE_CHANCE_CARD, talker, RoomIndex, i0);

Usage example

if ( log_mode == 1 ) {
    AddLogEx( Log_pc_LevDiff, attacker, i0, 0 );
}

AddScriptLogGLOBAL🟢 high

arbitrary string entry in the script log

Writes an arbitrary string entry to the script log: a debug and diagnostic
message with a numeric tag nLogId and text sText. Serves for tracing script
logic and is not visible to the player. Belongs to the global object.

Signature

AddScriptLog( int nLogId, string sText )

Parameters

nLogId (int) — numeric tag of the entry. @LOG_ERROR (2) and raw 2/3 occur; an arbitrary
               debug-log category tag (does not affect gameplay).
sText  (string) — log text.

Example

AddScriptLog( 3, "... all ok" );

Usage example

if (i2 > 5) {
    AddScriptLog(3, "[" + myself.sm.name + "] try return 5000 CRP to [ " + talker.name + "]");
}

AddLogExWithoutCreatureGLOBAL🟢 high

an extended record without a creature binding

An extended version of logging that writes a record not bound to a creature — for
system and global events where there is no specific player. Takes nLogType (the event-type
code) and two related values nParam and nParam2. Belongs to the global
object.

Example

AddLogExWithoutCreature(Log_NoKilling, i0, 0);
AddLogExWithoutCreature(Log_ChainSpawnSuccess, i0, 0);
AddLogExWithoutCreature(Log_MobClearing, i0, 0);

Usage example

if (log_mode == 1) {
    AddLogExWithoutCreature(Log_ChainSpawnSuccess, i0, 0);
}

AddLogByNpcNPC🟢 high

logging on behalf of an NPC

Logging on behalf of an NPC: the record is attributed to a specific NPC, not to the global
system. The server merely writes a tag and two numbers to the log (does not affect gameplay),
so the tag is an open set of analytics codes set by script convention, not
a fixed enum. Belongs to the NPC.

Signature

AddLogByNpc( int nLogTag, CSharedCreatureData c, int nParam1, int nParam2 )

Parameters

nLogTag (int) — the log record tag/type (an open analytics set; in calls
    122, 326, 413, 414, 416, 899, 8057, etc. are found — the meaning is set by the script analytics).
c (CSharedCreatureData) — the player associated with the record.
nParam1 (int) — the first number of the record (an analytics value per the tag's meaning).
nParam2 (int) — the second number of the record (an analytics value per the tag's meaning).

Example

AddLogByNpc(122, talker, 1, 0);

AddLogByNpc2NPC🟢 high

a detailed analytics record on behalf of an NPC

A detailed version of logging on behalf of an NPC for detailed telemetry of its actions
(rewards, sales, events). Takes nLogId (the record type/tag), the associated player c,
two string fields s1 and s2, and up to six large numeric fields nP1..nP6 (int64).
Belongs to the NPC.

Signature

AddLogByNpc2( int nLogId, CSharedCreatureData pCreatureShared, string sStr1, string sStr2, int64 nParam1, int64 nParam2, int64 nParam3, int64 nParam4, int64 nParam5, int64 nParam6 )

Parameters

nLogId (int) — the log record type/tag
pCreatureShared (CSharedCreatureData) — the player associated with the record
sStr1 (string) — the first string field of the record
sStr2 (string) — the second string field of the record
nParam1 (int64) — the first large numeric field of the record
nParam2 (int64) — the second large numeric field of the record
nParam3 (int64) — the third large numeric field of the record
nParam4 (int64) — the fourth large numeric field of the record
nParam5 (int64) — the fifth large numeric field of the record
nParam6 (int64) — the sixth large numeric field of the record

Example

AddLogByNpc2(127, target, "ADDLOG", "RANGE_OVER", 0, 0, 0, 0, 0, 0);

Usage example

if ( babble_mode > 0 ) {
    AddLogByNpc2( 127, myself.sm, "antaras_test", "MY_DYING: dead and combat terminated", 0, 0, 0, 0, 0, 1 );
}

GetNPCLogByIDNPC🟢 high

read the kill/collection counter for a quest

Reads the current value of the built-in "killed/collected X" counter for a quest — a table
on the character separate from the memo-state (up to 40 slots). The record key is the triple of nQuestId
(the quest [quest_pch]), nQuestState (the quest stage), and nNpcId (the class of the NPC whose kills
are counted); the first argument passes the player pTalker. Returns the accumulated
counter value. Belongs to the NPC.

Signature

GetNPCLogByID( CSharedCreatureData pTalker, int nQuestId, int nQuestState, int nNpcId )

Parameters

pTalker (CSharedCreatureData) — 2.
nQuestId (int) — 2.
    the values are from the [quest_pch] dictionary
nQuestState (int) — the quest stage — part of the counter key
nNpcId (int) — 4 (Increase).

Example

if (GetNPCLogByID(last_attacker, @one_stroke_one_kill, 0, i3) < 10)

Usage example

if (_from_choice == 0 || (HaveMemo(talker, @one_stroke_one_kill) == @TRUE && GetMemoState(talker, @one_stroke_one_kill) == 1 && GetNPCLogByID(talker, @one_stroke_one_kill, 0, 1018879) < 1 && GetNPCLogByID(talker, @one_stroke_one_kill, 0, 1018886) < 1 && GetNPCLogByID(talker, @one_stroke_one_kill, 0, 1018893) < 1 && GetNPCLogByID(talker, @one_stroke_one_kill, 0, 1018900) < 1)) {
    SetCurrentQuestID(@one_stroke_one_kill);
    ShowPage(talker, "keleia_q0458_13.htm");
}

IncreaseNPCLogByIDNPC🟢 high

increase the kill/collection counter for a quest

Increases the built-in "killed/collected X" counter by 1, but no higher than the ceiling nMaxValue
(convenient for "kill N mobs" tasks: on reaching the ceiling, the counter no longer grows). The record
key is the triple of nQuestId (the quest [quest_pch]), nQuestState (the quest stage), and nNpcId
(the NPC class); the first argument passes the player pTarget, the fifth — nMaxValue (the ceiling).
Belongs to the NPC.

Signature

IncreaseNPCLogByID( CSharedCreatureData pTarget, int nQuestId, int nQuestState, int nNpcId, int nMaxValue )

Parameters

pTarget (CSharedCreatureData) — the player on whose character the counter is stored
nQuestId (int) — the quest — part of the counter key; the quest choice from the [quest_pch] dictionary
    the values are from the [quest_pch] dictionary
nQuestState (int) — the quest stage — part of the counter key
nNpcId (int) — the class of the NPC whose kills/collection are counted — part of the counter key
nMaxValue (int) — the counter ceiling above which it does not grow

Example

IncreaseNPCLogByID( target, 453, 0, @kiriona, 20 );
Nothing found

Timers & script events

6 events

TIMER_FIRED_EXNPCid 11🟢 high

a deferred timer fired

Fires when a timer set via AddTimerEx expires. The engine fills in: timer_id — id of the fired timer.

Initiated by: AddTimerEx (see NASC_FUNCTIONS).

Usage example

EventHandler TIMER_FIRED_EX(timer_id)
{
    if (timer_id == 1001) {
    }
    super;
}

SCRIPT_EVENTNPCid 51🟢 high

a script signal arrived

Fires on receiving a script signal (sent via Broadcast/SendScriptEvent). The engine fills in: sev_arg1 — signal argument 1; sev_arg2 — signal argument 2; sev_arg3 — signal argument 3.

Initiated by: SendScriptEvent/BroadcastScriptEvent (see NASC_FUNCTIONS).

Usage example

EventHandler SCRIPT_EVENT( script_event_arg1, script_event_arg2, script_event_arg3, i0 )
{
    if ( script_event_arg1 == 10022) {
        i0 = GetIndexFromCreature( myself.c_ai0 );
        if ( i0 == script_event_arg2 ) {
            if ( myself.i_ai1 < script_event_arg3 ) {
                Despawn( );
            }
        }
    }
}

ON_SCRIPT_EVENTMAKERid 3🟢 high

a script signal in the maker (spawner)

Judging by the name and arguments, handles a script signal on the maker (spawner) side. The engine fills in: sev_arg1 — signal argument 1; sev_arg2 — signal argument 2; sev_arg3 — signal argument 3.

Initiated by: SendMakerScriptEvent/def.SendScriptEvent (see NASC_FUNCTIONS).

Usage example

EventHandler ON_SCRIPT_EVENT(script_event_arg1, script_event_arg2, script_event_arg3, i0, def0)
{
    super;
    if (script_event_arg1 == 21150002) {
        def0.SendScriptEvent(21150002, script_event_arg2, script_event_arg3);
    }
}

ON_TIMERMAKERid 5🟢 high

maker (spawner) timer

Fires on a maker (spawner) timer. The engine fills in: timer_id — id of the fired timer.

Initiated by: AddTimerEx (maker) (see NASC_FUNCTIONS).

Usage example

EventHandler ON_TIMER( timer_id )
{
    if (timer_id == 3384) {
        SendMakerScriptEvent(myself, 1000, 0, 0);
    }
    super;
}

TIMER_FIREDNPCid 10🟢 high

a simple timer fired

Fires when a simple timer fires (legacy mechanism). The event carries no fields of its own — the engine fills in only myself (the NPC itself).

Initiated by: AddTimer (see NASC_FUNCTIONS).

Usage example

EventHandler TIMER_FIRED( i6 )
{
    i6 = Rand( 90 );
    if ( i6 > 60 ) {
        InstantTeleport( myself.sm, 178849, -184342, -342 );
    } else {
        if ( i6 > 30 ) {
            InstantTeleport( myself.sm, 154132, -220070, -3404 );
        } else {
            InstantTeleport( myself.sm, 151572, -174829, -1781 );
        }
    }
}

DOMINION_SCRIPT_EVENTNPCid 161🟢 high

Dominion mode script signal

Arrives as a script signal within the Dominion subsystem. The engine fills in: talker — the player; sev_arg1 — signal argument 1; sev_arg2 — signal argument 2; sev_arg3 — signal argument 3.

Usage example

EventHandler DOMINION_SCRIPT_EVENT(talker, script_event_arg1, script_event_arg2, script_event_arg3, i0, i1, i2, i3, i4, i5, c0, c1, c2)
{
    c0 = GetCreatureFromIndex(script_event_arg1);
    i0 = GetDominionSiegeID(talker);
    i1 = script_event_arg3 % 100;
    i2 = script_event_arg3 / 100;
    i3 = GetCurrentTick();
    if (i0 == script_event_arg2)
    {
        if (GetDominionWarState(script_event_arg2) == 5)
        {
            if (i1 == 1)
            {
                if (i2 == 729)
                {
                    if (HaveNRMemo(talker, @defend_catapult_of_dom) == @FALSE && talker.level >= 40 && (IsInCategory(@third_class_group, talker.occupation) || IsInCategory(@fourth_class_group, talker.occupation)))
                    {
                        SetNRMemo(talker, @defend_catapult_of_dom);
                        SetNRMemoState(talker, @defend_catapult_of_dom, i0);
                        SetNRMemoStateEx(talker, @defend_catapult_of_dom, 1, i3);
    // ... (full body omitted)
}

Quests

8 events

QUEST_ACCEPTEDNPCid 30🟢 high

the player accepted a quest

Fires at the moment the player accepts a quest from the NPC. The engine fills in: talker — the player; quest_id — quest [quest].

Usage example

EventHandler QUEST_ACCEPTED(quest_id, talker)
{
    if (quest_id == 11111)
    {
        if (HaveMemo(talker, @eternal_weapon_quest) == @FALSE && talker.level >= 82)
        {
            SetCurrentQuestID(quest_id);
            SetMemo(talker, quest_id);
            SetMemoState(talker, quest_id, 1);
            AddLog(1, talker, quest_id);
            SoundEffect(talker, "ItemSound.quest_accept");
            ShowPage(talker, "eternal_quest_collector_legnar_002.htm");
            SetFlagJournal(talker, quest_id, 1);
            ShowQuestMark(talker, quest_id);
        }
        return;
    }
    super;
}

TELEPORT_REQUESTEDNPCid 27🟢 high

a teleport request

Judging by the name and argument, fires when a player requests teleportation from the NPC. The engine fills in: talker — the player.

Usage example

EventHandler TELEPORT_REQUESTED(talker)
{
    InstantTeleport(talker, PosX, PosY, PosZ);
}

LEARN_SKILL_REQUESTEDNPCid 32🟢 high

a skill learning request

Judging by the name and argument, fires when a player asks the NPC to learn skills. The engine fills in: talker — the player.

Usage example

EventHandler LEARN_SKILL_REQUESTED(talker)
{
    ShowSkillList(talker, "");
}

ENCHANT_SKILL_REQUESTEDNPCid 33🟢 high

the player requested skill enchanting

Fires when the player approaches the NPC with a skill enchant request. The engine fills in: talker — the player; action_id — action code.

Usage example

EventHandler ENCHANT_SKILL_REQUESTED(talker, action_id)
{
    if (talker.transformID == 312 || talker.transformID == 313 || talker.transformID == 314 || talker.transformID == 315 || talker.transformID == 316 || talker.transformID == 317 || talker.transformID == 318) {
        ShowPage(talker, "skillenchant_notvang.htm");
    } else {
        ShowEnchantSkillList(talker, action_id);
    }
}

CLASS_CHANGE_REQUESTEDNPCid 37🟢 high

the player requested a class change

Fires when the player approaches the NPC with a class/profession change request. The engine fills in: talker — the player; occupation_name_id — profession id.

Usage example

EventHandler CLASS_CHANGE_REQUESTED( talker, occupation_name_id )
{
    ClassChange( talker, occupation_name_id );
    SoundEffect( talker, "ItemSound.quest_fanfare_2" );
    ShowPage( talker, fnAfterClassChange );
}

QUESTION_MARK_CLICKEDNPCid 53🟢 high

question mark clicked

Fires when the player clicks the question mark icon (tutorial/interface hint). The engine fills in: talker — the player; question_id — question-marker id.

Initiated by: ShowQuestionMark (see NASC_FUNCTIONS).

Usage example

EventHandler QUESTION_MARK_CLICKED( talker, question_id, i0 )
{
    i0 = ( GetMemoState( talker, @tutorial_quest ) & 2147483392 );
    select ( question_id ) {
        case 1 : {
            myself.VoiceEffect( talker, "tutorial_voice_007", 3500 );
            myself.SetMemoStateEx( talker, @tutorial_quest, 1, -5 );
            if ( talker.occupation == @fighter ) {
                myself.ShowTutorialHTML( talker, "tutorial_human_fighter007.htm" );
                myself.ShowRadar( talker, -71424, 258336, -3109, 2 );
            } else
            if ( talker.occupation == @mage ) {
                myself.ShowTutorialHTML( talker, "tutorial_human_fighter007.htm" );
                myself.ShowRadar( talker, -91036, 248044, -3568, 2 );
            } else
            if ( talker.occupation == @elven_fighter || talker.occupation == @elven_mage ) {
                myself.ShowTutorialHTML( talker, "tutorial_human_fighter007.htm" );
                myself.ShowRadar( talker, 46112, 41200, -3504, 2 );
            } else
            if ( talker.occupation == @dark_fighter || talker.occupation == @dark_mage ) {
    // ... (full body omitted)
}

ON_DYNAMIC_QUEST_EVENTMAKERid not🟡 medium

dynamic quest event

An event of the dynamic quest subsystem (Dynamic/Crusade Quest; server packets 0x9302+), arrives in the maker (spawner) context. reply — event code/phase; success — success flag; def0 — spawn define (CNpcSpawnDefineEx); maker0 — the maker (spawner); i0, i1 — accompanying values. There is no dedicated factory in the disassembled builds — fields inferred from actual usage.

Usage example

EventHandler ON_DYNAMIC_QUEST_EVENT(reply, success, def0, i0, i1, maker0)
{
    if (reply == 1)
    {
        myself.i_ai0 = 0;
        for (i0 = 0; i0 < myself.def_count; ++i0)
        {
            def0 = GetSpawnDefine(i0);
            if (IsNull(def0) == @FALSE)
            {
                if (myself.maximum_npc >= (myself.npc_count + def0.total))
                {
                    if (AtomicIncreaseTotal(def0, def0.total, 1))
                    {
                        def0.Spawn2(def0.total, 0, 0);
                    }
                }
            }
        }
        AddTimerEx(DoRespawn_Timer, 1000);
    // ... (full body omitted)
}

ON_DYNAMIC_QUEST_INFOMAKERid none🟡 medium

dynamic quest information

An informational event of the dynamic quest subsystem (Dynamic/Crusade Quest). quest_id — the quest identifier; event_id — the event/stage identifier; def0 — the spawn define; i0 — an accompanying value. There is no separate factory in the disassembled builds — the fields are per real usage.

Usage example

EventHandler ON_DYNAMIC_QUEST_INFO(quest_id, event_id, i0, def0)
{
    myself.i_ai2 = event_id;
    myself.i_ai1 = quest_id;
}

Sieges, forts, dominion, TB

29 events

TB_REGISTER_PLEDGE_RETURNEDNPCid 79🟢 high

response to clan registration (Territory Battle)

Fires when the server's response to registering a clan in the territory battle arrives. The engine fills in: talker — the player; reply — response code/choice.

Values of reply (L2Server: synchronous NpcRegisterTeamBattle + async ReplyNewTeamBattleAgitPledge): -1 — registration failed (the clan is already a participant in the synchronous branch, or a DB context error); 0,1,2,3,4 — SUCCESS, the number of the assigned team/slot (the agit has 5 slots — the same range as TB_GET_PLEDGE_REGISTER_STATUS; the script uses it to show messenger_4a..4e). With 5+ registered clans — sys.msg 1007.

Initiated by: TB_RegisterPledge (see NASC_FUNCTIONS).

Usage example

EventHandler TB_REGISTER_PLEDGE_RETURNED( talker, reply )
{
    if ( reply < 0 ) { ShowPage( talker, "farm_kel_mahum_messenger_3.htm" ); } else
    if ( reply == 0 ) { ShowPage( talker, "farm_kel_mahum_messenger_4a.htm" ); } else
    if ( reply == 1 ) { ShowPage( talker, "farm_kel_mahum_messenger_4b.htm" ); } else
    if ( reply == 2 ) { ShowPage( talker, "farm_kel_mahum_messenger_4c.htm" ); } else
    if ( reply == 3 ) { ShowPage( talker, "farm_kel_mahum_messenger_4d.htm" ); } else
    if ( reply == 4 ) { ShowPage( talker, "farm_kel_mahum_messenger_4e.htm" ); }
}

TB_GET_PLEDGE_REGISTER_STATUS_INFORMEDNPCid 83🟢 high

clan registration status received (Territory Battle)

Fires when information about the clan's registration status in the territory battle arrives. The engine fills in: talker — the player; reply — response code/choice.

Values of reply: reply (L2Server NpcQueryTeamBattlePledge): 0..4 — the clan is registered (team slot number); -1 — not found, but free slots remain; -2 — not found, all slots taken; -3 — the clan has no such sub-pledge. Early refusals: the clan awaits dissolution (sys.msg 1114), not allowed (2240).

Initiated by: TB_GetPledgeRegisterStatus (see NASC_FUNCTIONS).

Usage example

EventHandler TB_GET_PLEDGE_REGISTER_STATUS_INFORMED( talker, reply )
{
    if ( reply == -2 ) {
        ShowPage( talker, "agit_oel_mahum_messeger_21.htm" );
    } else
    if ( reply == -1 ) {
        if ( IsMyLord( talker ) ) {
            ShowPage( talker, "agit_oel_mahum_messeger_22.htm" );
        } else {
            TB_RegisterPledge( talker );
        }
    } else
    if ( reply == 0 ) {
        ShowPage( talker, "agit_oel_mahum_messeger_4a.htm" );
    } else
    if ( reply == 1 ) {
        ShowPage( talker, "agit_oel_mahum_messeger_4b.htm" );
    } else
    if ( reply == 2 ) {
        ShowPage( talker, "agit_oel_mahum_messeger_4c.htm" );
    // ... (full body omitted)
}

TB_REGISTER_MEMBER_RETURNEDNPCid 80🟢 high

response to member registration (Territory Battle)

Fires when the server's response to registering a participant in the territory battle arrives. The engine fills in: talker — the player; reply — response code/choice.

Values of reply: reply (L2Server NpcRegisterTeamBattle, sub 63, member): 0 — success (or clan not found); 1 — the participant is already registered under another team; 2 — the participant limit (18) is reached.

Initiated by: TB_RegisterMember (see NASC_FUNCTIONS).

Usage example

EventHandler TB_REGISTER_MEMBER_RETURNED( talker, reply )
{
    if ( reply == 0 ) { ShowPage( talker, "farm_kel_mahum_messenger_7.htm" ); } else
    if ( reply == 1 ) { ShowPage( talker, "farm_kel_mahum_messenger_8.htm" ); } else
    if ( reply == 2 ) { ShowPage( talker, "farm_kel_mahum_messenger_9.htm" ); }
}

TB_SET_NPC_TYPE_RETURNEDNPCid 82🟢 high

response to setting the NPC type (Territory Battle)

Fires when the server's response to setting the NPC type in the territory battle context arrives. The engine fills in: talker — the player; reply — response code/choice.

Values of reply: reply (L2Server NpcQueryTeamBattleNpc, SET): -1 — invalid arguments (no clan or type<0); 0..5 — the type was set (echo of the assigned one).

Initiated by: TB_SetNpcType (see NASC_FUNCTIONS).

Usage example

EventHandler TB_SET_NPC_TYPE_RETURNED( talker, reply )
{
    if ( reply == -1 ) { ShowPage( talker, "farm_kel_mahum_messenger_7.htm" ); } else
    if ( reply >= 1 && reply <= 5 ) { ShowPage( talker, "farm_kel_mahum_messenger_9.htm" ); }
}

TB_GET_NPC_TYPE_INFORMEDNPCid 81🟢 high

NPC type received (Territory Battle)

Fires when information about the NPC type in the territory battle context arrives. The engine fills in: talker — the player; reply — response code/choice.

Values of reply: reply (L2Server NpcQueryTeamBattleNpc, GET): -1 — no type assigned / no clan; 0..5 — the assigned NPC type.

Initiated by: TB_GetNpcType (see NASC_FUNCTIONS).

Usage example

EventHandler TB_GET_NPC_TYPE_INFORMED( talker, reply )
{
    if ( reply == -1 ) {
        ShowPage( talker, "agit_oel_mahum_messeger_7.htm" );
    } else
    if ( reply == 0 ) {
        if ( talker.is_pledge_master == 1 ) {
            ShowPage( talker, "agit_oel_mahum_messeger_6.htm" );
        } else {
            ShowPage( talker, "agit_oel_mahum_messeger_10.htm" );
        }
    } else
    if ( reply == 1 ) {
        ShowPage( talker, "agit_oel_mahum_messeger_16.htm" );
    } else
    if ( reply == 2 ) {
        ShowPage( talker, "agit_oel_mahum_messeger_17.htm" );
    } else
    if ( reply == 3 ) {
        ShowPage( talker, "agit_oel_mahum_messeger_18.htm" );
    // ... (full body omitted)
}

SET_AGIT_DECO_RETURNEDNPCid 90🟢 high

response to setting residence decoration

Fires when the server's response to setting a residence decoration arrives. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server CSetResidenceDeco server-job): 1 — clan hall decoration set, 0 — not set.

Usage example

EventHandler SET_AGIT_DECO_RETURNED(talker, reply)
{
    if (reply) {
        if (OwnItemCount(talker, 57) >= GetCookie(talker, "AgitDecoFee")) {
            DeleteItem1(talker, 57, GetCookie(talker, "AgitDecoFee"));
            ShowPage(talker, fnAfterSetDeco);
        } else {
            ShowPage(talker, fnNotEnoughAdena);
        }
    } else {
        ShowPage(talker, fnFailtoSetDeco);
    }
}

RESET_AGIT_DECO_RETURNEDNPCid 91🟢 high

response to resetting residence decoration

Fires when the server's response to resetting the residence decoration to its initial state arrives. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server CResetResidenceDeco server-job): 1 — decoration reset, 0 — not reset.

Usage example

EventHandler RESET_AGIT_DECO_RETURNED(talker, reply)
{
    if (reply) {
        ShowPage(talker, fnAfterResetDeco);
    } else {
        ShowPage(talker, fnFailtoResetDeco);
    }
}

TB_GET_BATTLE_ROYAL_PLEDGE_LIST_INFORMEDNPCid 84🟢 high

battle royal clan list received (Territory Battle)

Fires when the list of clans participating in the battle royal arrives. The engine fills in: talker — the player; i0..i11 — the clan table (see below).

i0..i11 values (L2Server NpcGetBattleRoyalPledgeList, opcode 75): pairs of (pledge-id,
registration status) for the 5 attacking clans and the owner clan:
i0 = pledge-id of attacking clan 1; i1 = its registration status
i2 = pledge-id of attacking clan 2; i3 = its status
i4 = pledge-id of attacking clan 3; i5 = its status
i6 = pledge-id of attacking clan 4; i7 = its status
i8 = pledge-id of attacking clan 5; i9 = its status
i10 = pledge-id of the owner clan; i11 = its status
An empty attacking-clan slot arrives as -1. The status is the clan's registration flag
in this battle (per the residence's internal table).

Initiated by: TB_GetBattleRoyalPledgeList (see NASC_FUNCTIONS).

Usage example

EventHandler TB_GET_BATTLE_ROYAL_PLEDGE_LIST_INFORMED(talker, fhtml0, i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, pledge0)
{
    FHTML_SetFileName(fhtml0, fnBRList);
    if (i0 >= 0) {
        pledge0 = GetPledgeByIndex(i0);
        if (IsNull(pledge0) == 0) {
            FHTML_SetStr(fhtml0, "pledge0", pledge0.name);
            FHTML_SetStr(fhtml0, "p_member_count0", IntToStr(i1));
        }
    } else {
        FHTML_SetStr(fhtml0, "pledge0", MakeFString(1000495, "", "", "", "", ""));
    }
    if (i2 >= 0) {
        pledge0 = GetPledgeByIndex(i2);
        if (IsNull(pledge0) == 0) {
            FHTML_SetStr(fhtml0, "pledge1", pledge0.name);
            FHTML_SetStr(fhtml0, "p_member_count1", IntToStr(i3));
        }
    } else {
        FHTML_SetStr(fhtml0, "pledge1", MakeFString(1000495, "", "", "", "", ""));
    // ... (full body omitted)
}

ON_END_SIEGE_EVENTMAKERid 10🟢 high

siege end

Fires when the siege of the associated residence ends. The event carries no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_END_SIEGE_EVENT( def0, maker0, i0 )
{
    for ( i0 = 1; i0 < myself.def_count; ++i0 ) {
        def0 = GetSpawnDefine( i0 );
        if ( AtomicIncreaseTotal( def0, def0.total, 1 ) ) {
            def0.Spawn2( def0.total, 0, 0 );
        }
    }
}

FORTRESS_UPGRADE_FACILITY_RETURNEDNPCid 127🟢 high

response to a fortress facility upgrade

Fires when the server's response to upgrading a fortress facility arrives. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server CDx*FortressFacility): 1 — setting the facility level (set); 0 — reset. The actual level application is asynchronous.

Usage example

EventHandler FORTRESS_UPGRADE_FACILITY_RETURNED(talker, reply, i0, i1)
{
    if (reply == 1) {
        ShowPage(talker, fnUpgradeSuccess);
    } else {
        if (reply == 0) {
            ShowPage(talker, fnUpgradeFail);
        }
    }
}

ON_FORTRESS_EVENTMAKERid 16🟢 high

fortress event

Fires when a fortress-related event occurs. The engine fills in: residence_id — residence id; event_id — the bound event id (the one set in RegisterFortressEventEx); s0 — string.

Initiated by: binding an event to the fort via RegisterFortressEventEx(fortress_id, event_id, is_spawn) — when the state is reached, the maker receives this event (see NASC_FUNCTIONS).

Usage example

EventHandler ON_FORTRESS_EVENT(residence_id, event_id, reply, i0, i1, s0, def0, maker0)
{
    AddScriptLog(3, "[" + myself.name + "[fortress_event][res_id][" + IntToStr(residence_id) + "]" + IntToStr(event_id) + "]" + IntToStr(reply) + "]");
    myself.enabled = reply;
    if (event_id <= 2) {
        myself.i_ai0 = Fortress_GetOwnerPledgeId(fortress_id);
    }
    i0 = Fortress_GetOwnerPledgeId(fortress_id);
    if (i0 > 0) {
        if (is_npc_own == 1 && i0 == myself.i_ai0) {
            return;
        }
    } else {
        if (is_npc_own == -1 && i0 == myself.i_ai0) {
            return;
        }
    }
    if (facility_level > -1 && facility_type > -1) {
        i0 = Fortress_GetFacilityLevel(fortress_id, facility_type);
        if (i0 < facility_level) {
    // ... (full body omitted)
}

TB_CHECK_MEMBER_REGISTER_STATUSNPCid 111🟢 high

team battle member registration status

Fires when checking a participant's registration status in the team battles (TB) subsystem. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server NpcTBAgitCheckMemberRegisterStatus): there is no numeric code — reply=1 records "check performed"; the defender/offender result is sent to the player separately.

Usage example

EventHandler TB_CHECK_MEMBER_REGISTER_STATUS( reply, talker, pledge0 )
{
    if (reply == 1) {
        myself.i_ai1 = myself.i_ai1 + 1;
        if (myself.i_ai1 == 1) {
            if (Rand(100) < 50) {
                InstantTeleport(talker, Pos_x1, Pos_y1, Pos_z1);
            } else {
                InstantTeleport(talker, Pos_x2, Pos_y2, Pos_z2);
            }
        }
        AddTimerEx( 1001, (60 * 1000) );
    } else {
        ShowPage(talker, "agit_mass_teleporter002.htm");
    }
}

CONTROLTOWER_LEVEL_INFORMEDNPCid 78🟢 high

control tower level notification

Fires when information about the level of a control tower (siege object) is received. The engine fills in: talker — the player; level — level.

Initiated by: GetControlTowerLevel (see NASC_FUNCTIONS).

Usage example

EventHandler CONTROLTOWER_LEVEL_INFORMED(talker, level, i0, i1, i2, fhtml0)
{
    if (Castle_IsUnderSiege() || GetDominionWarState(dominion_id) == 5)
    {
        ShowPage(talker, fnSiegeStoppedFunction);
    }
    else if (IsMyLord(talker) == @TRUE || ((HavePledgePower(talker, 23) && Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0)))
    {
        i0 = GetCookie(talker, "dmgzone_price");
        i1 = GetCookie(talker, "dmgzone_level");
        i2 = GetCookie(talker, "dmgzone_num");
        if (level >= (2 * i1))
        {
            FHTML_SetFileName(fhtml0, fnCurrentDmgzoneLevelHigher);
            FHTML_SetInt(fhtml0, "dmglevel", (level / 2));
            ShowFHTML(talker, fhtml0);
        }
        else if (OwnItemCount(talker, @adena) >= i0)
        {
            DeleteItem1(talker, @adena, i0);
    // ... (full body omitted)
}

ON_START_SIEGE_EVENTMAKERid 9🟢 high

siege start

Fires when a siege event starts. The event carries no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_START_SIEGE_EVENT( def0, i0 )
{
    for ( i0 = 1; i0 < ( myself.def_count - 1 ); ++i0 ) {
        def0 = GetSpawnDefine( i0 );
        if ( AtomicIncreaseTotal( def0, def0.total, 1 ) ) {
            def0.Spawn2( def0.total, 0, 0 );
        }
    }
    Castle_GateOpenClose2( DoorName1, 1 );
    Castle_GateOpenClose2( DoorName2, 1 );
    Castle_GateOpenClose2( DoorName3, 1 );
    Castle_GateOpenClose2( DoorName4, 1 );
    Castle_GateOpenClose2( DoorName5, 1 );
}

ON_START_TEAMBATTLEAGIT_FINAL_EVENTMAKERid 14🟢 high

start of the residence team battle final

Fires when the final stage of the team battle for a residence (teambattle agit) starts. The event carries no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_START_TEAMBATTLEAGIT_FINAL_EVENT( def0, i0 )
{
    for ( i0 = 1; i0 < myself.def_count; ++i0 ) {
        def0 = GetSpawnDefine( i0 );
        if ( AtomicIncreaseTotal( def0, def0.total, 1 ) ) {
            def0.Spawn2( def0.total, 0, 0 );
        }
    }
    Castle_GateOpenClose2( DoorName1, 1 );
    Castle_GateOpenClose2( DoorName2, 1 );
    Castle_GateOpenClose2( DoorName3, 1 );
    Castle_GateOpenClose2( DoorName4, 1 );
    Castle_GateOpenClose2( DoorName5, 1 );
}

FORTRESS_CONTRACT_CASTLE_RETURNEDNPCid 126🟢 high

result of a fortress contract with a castle

Fires as the response to a request to bind a fortress to a castle by contract. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server CFortress::ContractWithCastle): -1 — the contract with the castle has been concluded (success); 0 — refusal (the castle is not linked to the fortress / a contract already exists / there is already an owning castle).

Initiated by: Fortress_ContractCastle (see NASC_FUNCTIONS).

Usage example

EventHandler FORTRESS_CONTRACT_CASTLE_RETURNED( talker, reply )
{
    if (reply == -1) {
        ShowPage(talker, fnContractSuccess);
        AddTimerEx( 7792, (3 * 1000) );
    } else
    if (reply == 0) {
        ShowPage(talker, fnContractFail);
    } else
    if (reply == 1) {
        ShowPage(talker, fnHi1);
        AddTimerEx( 7792, (3 * 1000) );
    } else
    if (reply == 2) {
        ShowPage(talker, fnIndepFail);
    } else
    if (reply == 3) {
        ShowPage(talker, fnIndepAlready);
    }
}

FORTRESS_SIEGE_REGISTER_RETURNEDNPCid 124🟢 high

fortress siege registration result

Fires as the response to a request to register for a fortress siege. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server CFortress::RegisterSiege): -1 — siege registration successful (sys.msg 2169); 3 — the fortress is not accepting registration (wrong state); 4 — the clan is already registered; 0 — registration not allowed.

Usage example

EventHandler FORTRESS_SIEGE_REGISTER_RETURNED(talker, reply, i0)
{
    if (reply == -1) {
        i0 = GetCookie(talker, "commission");
        if (i0 == commission) {
            if (OwnItemCount( talker, @adena ) >= i0) {
                DeleteItem1( talker, @adena , i0);
            } else {
                ShowPage(talker, fnHi3);
                return;
            }
        }
        ShowPage(talker, fnRegisterSuccess);
    } else {
        if (reply == 3) {
            ShowPage(talker, fnNoRegisterPeriod);
        } else {
            if (reply == 4) {
                ShowPage(talker, fnAlreadyRegistered);
            } else {
    // ... (full body omitted)
}

FORTRESS_SIEGE_UNREGISTER_RETURNEDNPCid 125🟢 high

result of cancelling fortress siege registration

Fires as a response to a fortress siege unregistration request. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server CFortress::UnregisterSiege): -1 — unregistration successful; 3 — wrong fortress state; 4 — clan is not registered.

Usage example

EventHandler FORTRESS_SIEGE_UNREGISTER_RETURNED(talker, reply)
{
    if (reply == -1) {
        ShowPage(talker, fnCancelSuccess);
    } else {
        if (reply == 3) {
            ShowPage(talker, fnNoRegisterPeriod);
        } else {
            if (reply == 4) {
                ShowPage(talker, fnNotARegistered);
            } else {
                ShowPage(talker, fnCancelFail);
            }
        }
    }
    super;
}

DOMINION_SIEGE_STARTNPCid 153🟢 high

siege start in Dominion mode

Fires when a territory siege starts in Dominion mode. The engine fills in: talker — the player; i0 — Dominion region.

Usage example

EventHandler DOMINION_SIEGE_START(talker, i0, i1)
{
    // Big War Castles
    RegisterDBSavingMap(@gm_supply_carriage, 111111111);
    RegisterDBSavingMap(@gm_supply_box, 111111111);
    RegisterDBSavingMap(@gm_guard_proxy, 111111111);
    RegisterDBSavingMap(@gm_priest_proxy, 111111111);
    RegisterDBSavingMap(@gm_trader_proxy, 111111111);
    // Mid War Castles
    RegisterDBSavingMap(@gm_supply_carriage_midwar, 1111111);
    RegisterDBSavingMap(@gm_supply_box_midwar, 1111111);
    RegisterDBSavingMap(@gm_guard_proxy_midwar, 1111111);
    RegisterDBSavingMap(@gm_priest_proxy_midwar, 1111111);
    RegisterDBSavingMap(@gm_trader_proxy_midwar, 1111111);

    if (HaveNRMemo(talker, @dominion_war_state) == @FALSE)
    {
        SetNRMemo(talker, @dominion_war_state);
        AddLog(1, talker, @dominion_war_state);
        SetNRMemoState(talker, @dominion_war_state, 0);
    // ... (full body omitted)
}

DOMINION_SIEGE_ENDNPCid 154🟢 high

siege end in Dominion mode

Fires when a territory siege ends in Dominion mode. The engine fills in: talker — the player; i0 — Dominion region.

Usage example

EventHandler DOMINION_SIEGE_END(talker, i0, i1, i2, i3, i4, i5, i6, i7)
{
    if (HaveNRMemo(talker, @dominion_war_state) == @FALSE)
    {
        SetNRMemo(talker, @dominion_war_state);
        AddLog(1, talker, @dominion_war_state);
    }

    i1 = 1;    // mask
    i2 = 0; i3 = 0; i4 = 0; i5 = 0;
    select (i0)
    {
        // Big War Castles
        case @gludio_dominion:     { i1 = 1;         i2 = @for_the_gludio;      i3 = @gm_supply_carriage;    break; }
        case @dion_dominion:       { i1 = 10;        i2 = @for_the_dion;        i3 = @gm_supply_carriage;    break; }
        case @giran_dominion:      { i1 = 100;       i2 = @for_the_giran;       i3 = @gm_supply_carriage;    break; }
        case @oren_dominion:       { i1 = 1000;      i2 = @for_the_oren;        i3 = @gm_supply_carriage;    break; }
        case @aden_dominion:       { i1 = 10000;     i2 = @for_the_aden;        i3 = @gm_supply_carriage;    break; }
        case @innadrile_dominion:  { i1 = 100000;    i2 = @for_the_innadrille;  i3 = @gm_supply_carriage;    break; }
        case @godad_dominion:      { i1 = 1000000;   i2 = @for_the_godard;      i3 = @gm_supply_carriage;    break; }
    // ... (full body omitted)
}

DOMINION_SUPPLY_DESTRUCTEDNPCid 168🟢 high

Dominion supply object destroyed

Fires when a supply object is destroyed in Dominion mode. The engine fills in: attacker — the one who destroyed the object; i0 — Dominion region.

Usage example

EventHandler DOMINION_SUPPLY_DESTRUCTED(attacker, i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, c0, c1)
{
    if (i0 == @gludio_dominion) {
        i1 = GetDBSavingMap(@gm_supply_carriage);
        if ((i1 % 10) >= 1) {
            i2 = i1 - 1;
            RegisterDBSavingMap(19, i2);
        }
    } else

    if (i0 == @dion_dominion) {
        i1 = GetDBSavingMap(@gm_supply_carriage);
        if ((i1 % 100) >= 10) {
            i2 = i1 - 10;
            RegisterDBSavingMap(19, i2);
        }
    } else

    if (i0 == @giran_dominion) {
        i1 = GetDBSavingMap(@gm_supply_carriage);
    // ... (full body omitted)
}

DOMINION_SIEGE_PC_KILLEDNPCid 155🟢 high

player killed in a Dominion siege

Fires when a player dies during a siege in Dominion mode. The engine fills in: talker — the victim; attacker — the killer; i0 — Dominion region.

Usage example

EventHandler DOMINION_SIEGE_PC_KILLED(target, talker, attacker, i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, c0, c1, party0, always_list, code_info)
{
    if (IsNull(attacker) != @FALSE || IsNull(talker) != @FALSE)
        return;

    always_list = AllocCodeInfoList();
    party0 = GetParty(attacker);
    if (IsNullParty(party0) == @FALSE)
    {
        for (i9 = 0; i9 < party0.member_count; ++i9)
        {
            target = GetMemberOfParty(party0, i9);
            always_list.SetInfo(0, target);
        }
    }
    else
    {
        always_list.SetInfo(0, attacker);
    }

    // ... (full body omitted)
}

ON_DECLARE_DOMINION_EVENTMAKERid 21🟢 high

Dominion event declaration

Fires when a Dominion event is declared (started). The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_DECLARE_DOMINION_EVENT(i0, def0)
{
    for (i0 = 0; i0 < myself.def_count; ++i0)
    {
        def0 = GetSpawnDefine(i0);
        if (IsNull(def0) == @FALSE)
        {
            if (AtomicIncreaseTotal(def0, def0.total, 1))
            {
                def0.Spawn2(def0.total, 0, 0);
            }
        }
    }
}

AUCTION_AGIT_GET_COST_INFO_RETURNEDNPCid 92🟢 high

returned residence cost data (auction)

Arrives as a response with information about a residence's (clan hall / agit) cost at auction. The engine fills in: talker — the player; reply — response code/choice; s0 — string.

reply values: reply/s0 are NOT a code but a payload: they carry the COST of the clan hall (L2Server NpcAuctionAgitGetCostInfo); sent only for a valid agit with a positive cost.

Usage example

EventHandler AUCTION_AGIT_GET_COST_INFO_RETURNED( talker, reply, s0, fhtml0 )
{
    if (Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0) {
        FHTML_SetFileName(fhtml0, fnWarehouse);
        FHTML_SetInt( fhtml0, "agit_lease", reply );
        FHTML_SetStr(fhtml0, "pay_time", s0);
        ShowFHTML(talker, fhtml0);
    }
}

ON_PROCLAIM_SIEGE_EVENTMAKERid 11🟢 high

siege declaration

Fires when a siege is declared. The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_PROCLAIM_SIEGE_EVENT(def0)
{
    def0 = GetSpawnDefine(1);
    if (AtomicIncreaseTotal(def0, def0.total, 1))
    {
        def0.Spawn2(def0.total, 0, 0);
    }
}

ON_DESTRUCT_CTRL_TOWER_EVENTMAKERid 12🟢 high

control tower destruction

Fires when a control tower is destroyed during a siege. The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_DESTRUCT_CTRL_TOWER_EVENT(def0)
{
    def0 = GetSpawnDefine(1);
    if (GetDominionWarState(dominion_id) != 5)
    {
        if (def0.npc_count == 1)
        {
            def0.SendScriptEvent(10100, 1, 0);
            def0 = GetSpawnDefine(0);
            def0.SendScriptEvent(10101, 1, 0);
        }
        else
        {
            if (IsNull(def0) == 0 && def0.has_dbname)
            {
                def0.LoadDBNpcInfo(10);
            }
        }
    }
}

ON_CANCEL_SIEGE_EVENTMAKERid 13🟢 high

siege cancellation

Fires when a siege is cancelled. The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_CANCEL_SIEGE_EVENT(def0)
{
    def0 = GetSpawnDefine(1);
    def0.Despawn();
}

PLEDGE_CASTLE_SIEGE_DEFENCE_COUNT_DECREASE_RETURNEDNPCid 129🟢 high

returned decrease of castle defense count

Arrives as a response to a request to decrease the castle defensive-siege counter for a clan. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply has no numeric code in the NPC (an internal DB callback confirming castle defense); on refusal — sys.msg 640/641 (the defense counter is unchanged).

Usage example

EventHandler PLEDGE_CASTLE_SIEGE_DEFENCE_COUNT_DECREASE_RETURNED(talker, reply)
{
    if (reply == 0) {
        ShowPage(talker, fnDecreaseCountFailed);
        return;
    } else {
        if (reply == 1) {
            ShowPage(talker, fnGetMedalSuccess);
            return;
        }
    }
}

Clans, subclasses, academy

22 events

SUBJOB_CHANGEDNPCid 87🟢 high

subclass change

Fires when the player changes their subclass (secondary profession). The engine fills in: talker — the player; reply — subjob class; level — level.

Values of reply: reply (async ReplyChangeSubJob): on SUCCESS = the new ClassId of the subjob (not a code!); -1 — refusal (the change failed, imm default).

Initiated by: ChangeSubJob (see NASC_FUNCTIONS).

Usage example

EventHandler SUBJOB_CHANGED(talker,reply,level)
{
    if( reply == -1 ) {
        ShowPage( talker, "master_lv3_hef_18.htm" );
    } else {
        ShowPage( talker, "master_lv3_hew_05.htm" );
    }
}

SUBJOB_LIST_INFORMEDNPCid 85🟢 high

the subclass list was received

Arrives as the server's response with information about the character's classes (main + subclasses). The engine fills in: talker — the player; ask — sub-request; i0..i8 — the character's class table (see below).

Values of i0..i8 — the character's class table (L2Server ReplyLoadSubJob, opcode 66). The engine
sends 4 slots, each as a pair (ClassId, level): slot 0 — the main class, slots 1..3 —
subclasses. Value order:
i0 = class of the main (slot 0); i1 = its level
i2 = class of subclass 1; i3 = its level
i4 = class of subclass 2; i5 = its level
i6 = class of subclass 3; i7 = its level
An unused slot arrives as -1 (the engine initializes empty slots to -1). ClassId is
the class id (cf. the creature's class_id/occupation). i8 is a service field (the packet has
routing d-fields); the exact mapping of i-indices is set by the L2NPC factory, but the composition
and order of the (class, level) pairs for the 4 slots are proven by disassembly of ReplyLoadSubJob.

Initiated by: GetSubJobList (see NASC_FUNCTIONS).

Usage example

EventHandler SUBJOB_LIST_INFORMED(talker,ask,i0,i1,i2,i3,i4,i5,i6,i7,i8,fhtml0)
{
    if ( talker.transformID > 0 ) {
        ShowPage(talker,"transform_forbidden.htm");
        return;
    }
    if ( talker.race == @race_kamael ) {
        ShowPage(talker,"kamael_forbidden.htm");
        return;
    }
    // cancel third-profession quests
    if ((ask>=1) && (ask<=3) && (i8>0)) {
        if (((i8==1) && (i3>=40)) || ((i8==2) && (i5>=40)) || ((i8==3) && (i7>=40))) {
            myself.c_ai4 = talker;
            SendScriptEvent( myself.sm, 101, i8);
        }
    }

    if( ask == 1 ) {
        if( i8 == 0 ) {
    // ... (full body omitted)
}

SUBJOB_CREATEDNPCid 86🟢 high

a subclass was created

Judging by the name and arguments, fires after a new subclass is created for the player. The engine fills in: talker — the player; reply — response code/choice.

Values of reply (from real scripts): reply (L2Server ReplyCreateSubJob): the packet carries only routing indices, WITHOUT a success/failure number; success is accompanied by sys.msg 1269 to the player. The NPC script receives no numeric result code.

Initiated by: CreateSubJob (see NASC_FUNCTIONS).

Usage example

EventHandler SUBJOB_CREATED(talker,reply)
{
    if( reply == -1 ) {
        ShowPage( talker, "master_lv3_hef_17.htm" );
    } else {
        ShowPage( talker, "master_lv3_de_06.htm" );
    }
}

SUBJOB_RENEWEDNPCid 88🟢 high

the subclass was renewed

Judging by the name and arguments, fires when the active subclass is renewed/changed. The engine fills in: talker — the player; reply — response code/choice; i0 — integer (i0).

Values of reply: reply (L2Server ReplyRenewSubJob): on success = the new subclass class (+ sys.msg 1269 "subclass added"); 0 — refusal (log "renew subjob failed").

Initiated by: RenewSubJob (see NASC_FUNCTIONS).

Usage example

EventHandler SUBJOB_RENEWED( talker, reply, i0 )
{
    if ( reply == -1 ) {
        ShowPage( talker, "master_lv3_hef_18.htm" );
    } else
    if ( i0 == @cardinal ) {
        DeleteItem1( talker, @potion_of_experience_bishop, OwnItemCount( talker, @potion_of_experience_bishop ) );
    } else
    if ( i0 == @evas_saint ) {
        DeleteItem1( talker, @potion_of_experience_elder, OwnItemCount( talker, @potion_of_experience_elder ) );
    } else
    if ( i0 == @shillien_saint ) {
        DeleteItem1( talker, @potion_of_experience_silien_elder, OwnItemCount( talker, @potion_of_experience_silien_elder ) );
    }

    ShowPage( talker, "master_lv3_hew_05.htm" );
}

PLEDGE_MASTER_TRANSFERNPCid 109🟢 high

clan leadership transfer

Fires upon confirmation of the transfer of clan leader rights. The engine fills in: talker — the player; reply — response code/choice; s0 — string.

reply values: reply: -2 — the clan is awaiting dissolution (synchronous). The remaining codes (-8,-4,-1,0,1) come from the DB SQL procedure via byref (ReplyPledgeMasterTransfer relays nResult; not present as imm in the binary). Other synchronous refusals — a member is entering a team battle (2241), no clan / not the master (236).

Usage example

EventHandler PLEDGE_MASTER_TRANSFER( talker, reply )
{
    if (reply == 1) { ShowPage(talker, "pl_transfer_success.htm"); } else
    if (reply == 0) { ShowPage(talker, "pl_err_sm2.htm"); } else
    if (reply == -1) { ShowPage(talker, "pl_err_master.htm"); } else
    if (reply == -2) { ShowPage(talker, "pl_transfer_already.htm"); } else
    if (reply == -4) { ShowPage(talker, "pl_err_agit_owner.htm"); } else
    if (reply == -8) { ShowPage(talker, "pl_already_transfer.htm"); } else
    if (reply <= -3) { ShowPage(talker, "pl_err_master_transfer.htm"); }
}

PLEDGE_MASTER_TRANSFER_CANCELNPCid 110🟢 high

cancellation of clan leadership transfer

Fires when the clan leader rights transfer procedure is cancelled. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply: codes (-4,-2,-1,1) — from the DB SQL procedure via byref (ReplyPledgeMasterTransferCancel relays nResult). Synchronously — refusals (clan awaiting dissolution / no clan-not master, 236).

Usage example

EventHandler PLEDGE_MASTER_TRANSFER_CANCEL(talker, reply)
{
    if (reply == 1) { ShowPage(talker, "pl_cancel_success.htm"); } else
    if (reply == -1) { ShowPage(talker, "pl_err_master.htm"); } else
    if (reply == -2) { ShowPage(talker, "pl_transfer_already.htm"); } else
    if (reply == -4) { ShowPage(talker, "pl_not_transfer.htm"); } else
    if (reply <= -3) { ShowPage(talker, "pl_err_master_transfer.htm"); }
}

SET_SUBJOB_AS_MAINNPCid 188🟢 high

setting a subclass as main

Fires when an additional profession (subclass) is set as the main one. The engine fills in: talker — the player; reply — response code/choice; level — level.

Usage example

EventHandler SET_SUBJOB_AS_MAIN( talker, reply, level, s0 )
{
    if ( reply > 0 ) {
        SetDbData( "SUB_USER", talker.name, "MAIN: " + talker.subjob0_class, "SUB1: " + talker.subjob1_class, "SUB2: " + talker.subjob2_class, "SUB3: " + talker.subjob3_class, "LV: " + talker.level, IntToStr( talker.dbid ), "reply: " + reply , "level: " + level );
    } else {
        SetDbData( "SUB_USER", talker.name, "Error on SET_SUBJOB_AS_MAIN", _blank, _blank, _blank, _blank, _blank, _blank, _blank );
    }
}

LEVEL_UP_PLEDGENPCid 47🟢 high

clan level increase

Fires when the clan level is raised. The engine fills in: talker — the player; reply — response code/choice.

reply values (from real scripts): reply (L2Server CPledge::PledgeLevelUpByNpc): on success it carries the CURRENT clan level (the script uses it to start the upgrade); -1 — refusal (clan awaiting dissolution, sys.msg 551; or no clan / not the master, 236).

Usage example

EventHandler LEVEL_UP_PLEDGE( talker, reply )
{
    if ( reply == 0 ) {
        myself.PledgeLevelUp( talker, 1 );
    } else
    if ( reply == 1 ) {
        myself.PledgeLevelUp( talker, 2 );
    } else
    if ( reply == 2 ) {
        myself.PledgeLevelUp( talker, 3 );
    } else
    if ( reply == 3 ) {
        myself.PledgeLevelUp( talker, 4 );
    } else
    if ( reply == 4 ) {
        myself.PledgeLevelUp( talker, 5 );
    }
}

CHECK_CURSED_USER_RETURNEDNPCid 105🟢 high

response to a cursed player check

Fires when the response to checking a player for a curse arrives (e.g., possession of a cursed weapon). The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server NpcCheckCursedUser): 0 — the player does NOT carry a cursed weapon (check passed), 1 — carries one (per the CCursedWeaponMgr counter).

Initiated by: CheckCursedUser (see NASC_FUNCTIONS).

Usage example

EventHandler CHECK_CURSED_USER_RETURNED(talker, reply, fhtml0)
{
    if (reply == 0)
    {
        ShowPage(talker, "tournament_operator001.htm");
    }
    else
    {
        ShowPage(talker, "tournament_operator002.htm");    // The owner of a cursed sword cannot participate
    }
}

CHECK_SUBJOB_AS_MAINNPCid 195🟢 high

checking a subclass as main

Fires when the character's current active class is checked for being the main one when working with the dual profession (subclass) system. The engine fills in: talker — the player; reply — response code/choice; i0 — integer (i0).

Usage example

EventHandler CHECK_SUBJOB_AS_MAIN( talker, reply, i0, i1 )
{
            if ( reply > 0 ) {
                AddScriptLog( 2, "BooksLog: "+talker.name+" SubJobAsMain" );

                // clean up the books
                if ( OwnItemCount( talker, @sb_subclass_beginner ) > 0 ) { DeleteItem1( talker, @sb_subclass_beginner, OwnItemCount( talker, @sb_subclass_beginner ) ); }
                if ( OwnItemCount( talker, @sb_subclass_expert ) > 0 ) { DeleteItem1( talker, @sb_subclass_expert, OwnItemCount( talker, @sb_subclass_expert ) ); }
    //            if ( OwnItemCount( talker, @sb_subclass_summoner ) > 0 ) { DeleteItem1( talker, @sb_subclass_summoner, OwnItemCount( talker, @sb_subclass_summoner ) ); }
                // clear the book-taken states
                for ( i0 = flag_subjob_start; i0 <= flag_subjob_end; ++i0 ) {
                    SetOneTimeQuestFlag( talker, i0, @FALSE );
                }
                // wipe the skills
                DeleteAcquireSkills( talker, @subjob_skill_acquire );
                myself.av_quest1.Exchange( reply );
                AddTimerEx( 234567, 1000 );
            } else {
                myself.av_quest0.Exchange(0);
                ShowPage( talker, "subjob_transfer04.htm" );
    // ... (full body omitted)
}

MG_UNREGISTER_PLEDGE_RETURNEDNPCid 99🟢 high

clan unregistration result

Fires as the return of the result of a clan unregistration operation in the MG subsystem. The engine fills in: talker — the player; reply — response code/choice.

Initiated by: MG_UnregisterPledge (see NASC_FUNCTIONS).

Usage example

EventHandler MG_UNREGISTER_PLEDGE_RETURNED( talker, reply, i0 )
{
    if (reply > 0) {
        ShowPage(talker, "messenger_yetti005.htm");
        GiveItem1( talker, @hs_agit_war_joining_certificate, (reply / 2) );
    }
    select ( reply ) {
        case -2: {
            ShowPage(talker, "messenger_yetti010.htm");
            break;
        }
        case -11: {
            ShowPage(talker, "messenger_yetti016.htm");
            break;
        }
        case -12: {
            ShowPage(talker, "messenger_yetti017.htm");
            break;
        }
    }
}

MG_REGISTER_PLEDGE_RETURNEDNPCid 98🟢 high

clan registration result

Fires as the return of the result of a clan registration operation in the MG subsystem. The engine fills in: talker — the player; reply — response code/choice.

Usage example

EventHandler MG_REGISTER_PLEDGE_RETURNED( talker, reply, i0 )
{
    select ( reply ) {
        case 0 : {
            i0 = OwnItemCount( talker, @hs_agit_war_joining_certificate );
            myself.DeleteItem1( talker, @hs_agit_war_joining_certificate, i0 );
            myself.ShowPage( talker, "messenger_yetti009.htm" );
            break;
        }
        case -1 : { myself.ShowPage( talker, "messenger_yetti010.htm" ); break; }
        case -2 : { myself.ShowPage( talker, "messenger_yetti010.htm" ); break; }
        case -7 : { myself.ShowPage( talker, "messenger_yetti011.htm" ); break; }
        case -8 : { myself.ShowPage( talker, "messenger_yetti012.htm" ); break; }
        case -9 : { myself.ShowPage( talker, "messenger_yetti011.htm" ); break; }
        case -10 : { myself.ShowPage( talker, "messenger_yetti011.htm" ); break; }
        case -11 : { myself.ShowPage( talker, "messenger_yetti013.htm" ); break; }
        case -12 : { myself.ShowPage( talker, "messenger_yetti014.htm" ); break; }
        case -13 : { myself.ShowPage( talker, "messenger_yetti008.htm" ); break; }
    }
}

CREATE_PLEDGENPCid 44🟢 high

clan creation result

Fires as the response to a clan creation request. The engine fills in: talker — the player; reply — response code/choice.

reply values (from real scripts): reply (L2Server ReplyCreatePledgeByNpc): 1 — clan created, 0 — refusal (the name cannot be used, sys.msg 752).

Usage example

EventHandler CREATE_PLEDGE(talker, reply)
{
    if (reply == 1) {
        ShowPage(talker, "pl006.htm");
    }
}

CREATE_ALLIANCENPCid 50🟢 high

alliance creation result

Fires as the response to an alliance creation request. The engine fills in: talker — the player; reply — response code/choice.

reply values (from real scripts): reply (L2Server CAlliance::CreateAllianceByNpc): 1 — alliance created; 0 — refusal. Refusal reasons (sys.msg): not the clan master (504), clan level < 5 (549), already has an alliance (502), creation not allowed (505), the name cannot be used (752/506), name > 16 characters (507), clan awaiting dissolution/at war (550/721).

Usage example

EventHandler CREATE_ALLIANCE( talker, reply )
{
    if (reply == 1) {
        ShowPage(talker, "al006.htm");
    }
}

DISMISS_PLEDGENPCid 45🟢 high

clan dissolution result

Fires as the response to a clan dissolution request. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply: no numeric reply is sent to the NPC at all — the server performs the dissolution based on the DB success flag (ReplyDeletePledge) + penalties; the NPC learns of it indirectly (the clan no longer exists). Synchronously (CPledge::DismissPledgeByNpc) only a REFUSAL (code 0) is sent, with reasons: not the master (236), already awaiting dissolution (263), penalty timeout (728), pending applications (554), war (264), castle/fortress (266), siege (265).

Usage example

EventHandler DISMISS_PLEDGE(talker, reply)
{
    if (reply == 1) {
        ShowPage(talker, "pl009.htm");
    }
}

CREATE_ACADEMYNPCid 103🟢 high

clan academy creation result

Fires as the response to a request to create an academy (the clan's training unit). The engine fills in: talker — the player; s0 — string; reply — response code/choice.

reply values: reply: 1 — request accepted (synchronous CPledge::CreateAcademyByNpc); 2 — academy CREATED (async ReplyCreateAcademy, imm); -2 — the name is already in use (sys.msg 1855); 0 — refusal (no clan/rights/name).

Usage example

EventHandler CREATE_ACADEMY(talker, reply, i0, i1, i2, pledge0, s0, s1)
{
    pledge0 = GetPledge(talker);
    if (IsNull(pledge0) == @FALSE)
    {
        i0 = pledge0.skill_level;
        i1 = 0;
        i2 = 0;
        s1 = "";

        if (reply == 0) {
            ShowPage(talker, "pl_err_aca.htm");
        } else if (reply == 1) {
            if (talker.is_pledge_master == @TRUE || HavePledgePower(talker, @PP_MANAGE_GROWTH) == @TRUE && talker.pledge_id > 0 && i0 >= 5) {
                CreateAcademy(talker, s0);
            } else if (i0 < 5) {
                ShowPage(talker, "pl_err_plv.htm");
            } else if (talker.is_pledge_master != 1 || HavePledgePower(talker, @PP_MANAGE_MASTER) == 0) {
                ShowPage(talker, "pl_err_master.htm");
            } else {
    // ... (full body omitted)
}

CREATE_SUBPLEDGENPCid 104🟢 high

clan subunit creation result

Fires as the response to a request to create a clan subunit (subpledge). The engine fills in: talker — the player; reply — response code/choice; i0 — integer (i0); i1 — integer (i1); s0 — string.

reply values: reply: codes -2..2 — from the DB SQL procedure via byref (ReplyCreateSubPledge relays the result field). Synchronous refusal reasons (log lines): cannot create an academy/main clan; a skill upgrade is required or it is already created; invalid/too long name; name taken (1855); no master candidate; a sub-master already exists; no rights/clan.

Usage example

EventHandler CREATE_SUBPLEDGE(talker, reply, i0, i1, i2, pledge0, s0)
{
    if (reply == -1)
    {
        ShowPage(talker, "pl_err_man.htm");
    }
    else if (reply == 0)
    {
        ShowPage(talker, "pl_err_subname.htm");
    }
    else if (reply == 1)
    {
        if ((talker.is_pledge_master == @TRUE || HavePledgePower(talker, @PP_MANAGE_GROWTH) == @TRUE) && talker.pledge_id > 0)
        {
            if (i0 < 1000 && i0 >= 100) {
                if (HasSubPledge(talker, i0) == 1) {
                    ShowPage(talker, "pl_err_fame.htm");
                    return;
                }

    // ... (full body omitted)
}

UPDATE_SUBPLEDGE_MASTERNPCid 106🟢 high

subunit leader change result

Fires as the response to a request to appoint/change the leader of a clan subunit. The engine fills in: talker — the player; reply — response code/choice; i0 — integer (i0).

reply values: reply (async ReplyUpdateSubPledgeMaster, imm): 1 — success (subpledge leader updated), 0 — failure; -1 — the default when there is no response (synchronous NpcServer::Send refusal without a number).

Usage example

EventHandler UPDATE_SUBPLEDGE_MASTER(talker, reply, i0)
{
    if (reply == -1) {
        if (i0 < 1000) {
            ShowPage(talker, "pl_err_sm3.htm");
        } else {
            ShowPage(talker, "pl_err_sm4.htm");
        }
    } else if (reply == 0) {
        if (i0 < 1000) {
            ShowPage(talker, "pl_err_sm3.htm");
        } else {
            ShowPage(talker, "pl_err_sm4.htm");
        }
    } else if (reply == 1) {
        ShowPage(talker, "pl_create_ok_submaster.htm");
    }
}

RENAME_SUBPLEDGENPCid 112🟢 high

subunit rename result

Fires as the response to a request to rename a clan subunit. The engine fills in: talker — the player; reply — response code/choice; s0 — string; i0 — integer (i0).

reply values: reply (L2Server): 1 — rename successful (async ReplyRenameSubpledge, imm). Negative -9..-1 — the raw result of the DB SQL procedure (not materialized in the binary). Synchronous refusal reasons (CPledge::RenameSubPledgeByNpc, log lines): no clan right; main clan; no subpledge; invalid/too long name.

Usage example

EventHandler RENAME_SUBPLEDGE(talker, reply, i0)
{
    if (reply == 1) {
        if (i0 == -1) {
            ShowPage(talker, "pl_rename_ok_aca.htm");
        } else if (i0 < 1000) {
            ShowPage(talker, "pl_rename_ok_sub1.htm");
        } else {
            ShowPage(talker, "pl_rename_ok_sub2.htm");
        }
    } else if (reply == -1) {
        ShowPage(talker, "pl_err_master.htm");
    } else if (reply == -2) {
        ShowPage(talker, "pl_err_rename_disband.htm");
    } else if (reply == -3) {
        ShowPage(talker, "pl_err_rename_main.htm");
    } else if (reply == -4) {
        if (i0 == -1) {
            ShowPage(talker, "pl_err_rename_aca.htm");
        } else if (i0 < 1000) {
    // ... (full body omitted)
}

UPGRADE_SUBPLEDGE_MEMBER_COUNTNPCid 107🟢 high

subunit member limit expansion result

Fires as the response to a request to increase the maximum member count of a clan subunit. The engine fills in: talker — the player; reply — response code/choice; i0 — integer (i0).

reply values: reply (async ReplyUpgradeSubPledgeMemberCount): 1 — upgrade success (byref from the DB), 0 — failure (imm). Synchronous refusals (level<9, not enough adena 5000/7500, no rights/subpledge) — before the async.

Usage example

EventHandler UPGRADE_SUBPLEDGE_MEMBER_COUNT(talker, reply)
{
    if (reply == 0) {
        ShowPage(talker, "pl_upgrade_err_sub2.htm");
    } else if (reply == 1) {
        ShowPage(talker, "pl_upgrade_ok_sub2.htm");
    }
}

SET_HERO_RETURNEDNPCid 95🟢 high

hero status grant result

Fires as the response to a request to set hero status on a character. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server DxSaveHeroType server-job) = the applied hero-type: 2 — became a hero (hero/clan skills granted), 0 — hero status removed. reply==2 in scripts = "hero confirmed".

Initiated by: SetHero (see NASC_FUNCTIONS).

Usage example

EventHandler SET_HERO_RETURNED( talker, reply )
{
    if ( reply == 2 ) {
        Announce( MakeFString( ( 1000376 + talker.subjob0_class ), talker.name, "", "", "", "" ) );
    }
}

REVIVE_PLEDGENPCid 46🟢 high

revive a clan

Fires as part of the clan (pledge) revival procedure. The engine fills in: talker — the player; reply — response code/choice.

reply values (per real scripts): reply (L2Server CPledge::RevivePledgeByNpc): success — if the clan was awaiting dissolution (the dissolution is cancelled); refusal — the clan is NOT in dissolution (sys.msg 267), or there is no clan / the player is not the master (236). There is no separate numeric code in the packet tail.

Usage example

EventHandler REVIVE_PLEDGE( talker, reply )
{
    if (reply == 1) {
        ShowPage(talker, "pl012.htm");
    }
}

Zones, instances, doors, traps

16 events

INZONE_ALL_USERNPCid 192🟢 high

iteration over all players of an instance zone

Iteration/processing of all players inside an instance zone. The engine fills in: target — a player in the zone; i0 — total number of players.

Usage example

EventHandler INZONE_ALL_USER( target, i0, i1, c0, s0 )
{
    if (IsNullCreature(target) == @FALSE) {
        i1 = InstantZone_GetId( );
        if (target.instant_zone_id == i1) {
            if (myself.sm.flag == 2) {
                SendUIEventFStr(target, 2, 0, 0, p_sNoTimer, IntToStr(myself.av_ai0.GetValue()), IntToStr(inst_duration), p_sPercent, "0", p_iTitleUI, _blank, _blank, _blank, _blank, _blank);
            } else {
                SendUIEventFStr(target, 5, 0, 0, p_sNoTimer, IntToStr(myself.av_ai0.GetValue()), IntToStr(inst_duration), p_sPercent, "0", p_iTitleUI, _blank, _blank, _blank, _blank, _blank);
            }

            // write results to the database
            if ( myself.sm.param1 == 1 ) {
                myself.sm.param1 = 0;

                i0 = MPCC_GetMPCCId( target );
                if ( i0 > 0 ) {
                    c0 = MPCC_GetMaster( i0 );
                    if ( IsNullCreature( c0 ) ) { c0 = target; } // in case the player dropped out of the CC and the leader is not found

    // ... (full body omitted)
}

INSTANT_ZONE_ENTER_RETURNEDNPCid 123🟢 high

response to an instance zone entry request

Response to a player's attempt to enter an instance zone. The engine fills in: talker — the player; reply — entry success; state — related id.

Values of reply (from real scripts): reply = nSuccess: 0 — entry denied, 1 — entry allowed.

Initiated by: entering an instance zone (InstantZone_Enter) (see NASC_FUNCTIONS).

Usage example

EventHandler INSTANT_ZONE_ENTER_RETURNED( talker, reply, state, party0, i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, c0, s0, s1, pledge0 )
{
    if ( state == 0 ) {
    } else
    if ( state == 1 ) {
    }
    if ( reply == 0 ) {
    } else
    if ( reply == 1 ) {
        if ( state == 0 ) {
            s1 = IntToStr(GetDateTime(0,0))+"-"+IntToStr(GetDateTime(0,1))+"-"+IntToStr(GetDateTime(0,2))+" "+IntToStr(GetDateTime(0,3))+":"+IntToStr(GetDateTime(0,4))+":"+IntToStr(GetDateTime(0,5));
            SetDbData( "instance_log", "enter_181", talker.name, IntToStr( talker.dbid ), s0, "", IntToStr( talker.occupation ), IntToStr( reply ), IntToStr( talker.level ), s1 ); // detail
        }
    }
}

ON_INSTANT_ZONE_EVENTMAKERid 17🟢 high

instance zone event

Judging by the name and arguments, delivers an event associated with an instance zone. The engine fills in: inzone_type_id — instance zone type; event_id — arena/zone/field id.

Values of inzone_type_id are NOT a small enum but a zone type identifier (nInZoneTypeId in
the engine, cf. CNPC::SharedInstantZone_Enter(..., int nInZoneTypeId, ...)): each instance zone
is described by a row in instantzonedata.txt with its own type-id, and the script distinguishes
zones by it (like a field cycle id). There is no fixed list of values — it comes from instantzonedata.txt.

Initiated by: binding an event to a zone via RegisterInstantZoneEventEx(type, cluster, event_id, flag) — when the zone is spawned/despawned the maker receives this event with the same event_id (see NASC_FUNCTIONS).

Usage example

EventHandler ON_INSTANT_ZONE_EVENT(inzone_type_id, inzone_id, event_id, reply, i0, def0)
{
    AddScriptLog(3, "[" + myself.name + "]" + IntToStr(inzone_type_id) + "" + IntToStr(event_id) + "" + IntToStr(reply) + "" + IntToStr(i0) + "]");
    if (event_id == olympiad_event_id) {
        if (i0 == field_status_waitmatch) {
            for (i0 = 0; i0 < myself.def_count; i0 = i0 + 1)
            {
                def0 = GetSpawnDefine(i0);
                if (IsNull(def0) == 0) {
                    if (myself.maximum_npc >= myself.npc_count + def0.total) {
                        if (AtomicIncreaseTotal(def0, def0.total, 1)) {
                            def0.Spawn2(def0.total, 0, 0);
                        }
                    }
                }
            }
        } else {
            for (i0 = 0; i0 < myself.def_count; i0 = i0 + 1)
            {
                def0 = GetSpawnDefine(i0);
    // ... (full body omitted)
}

TRAP_STEP_INNPCid 116🟢 high

someone stepped on a trap

Fires when a creature enters a trap's area of effect. The engine fills in: i0 — id of the creature caught in the trap; i1 — extra interaction parameter. (L2NPC factory CreateTrapStepInEvent: i0/i1 come from the TrapCreatureStepInOut packet; the "creature" label in AI_EVENTS_REFERENCE is wrong.)

Usage example

EventHandler TRAP_STEP_IN(i0, i1, c0)
{
    c0 = GetCreatureFromID(i0);
    Shout(MakeFString(1800077, "", "", "", "", ""));
}

ON_FIELD_CYCLE_CHANGED_EVENTMAKERid 15🟢 high

the field cycle/phase changed

Fires when the cycle (phase) of a game field/zone changes. The engine fills in: event_id — arena/zone/field id; state — the new cycle phase (nStep number; a raw number set by the script).

Initiated by: a phase change via SetStep_FieldCycle / SetStepWithoutActor_FieldCycle; subscription — RegisterFieldCycleEventEx / RegisterAsFieldCycleManager (see NASC_FUNCTIONS).

Usage example

EventHandler ON_FIELD_CYCLE_CHANGED_EVENT(event_id, state, i1)
{
    if (event_id == 1) {
        if (state >= 1 && state <= 8) {
        }
    }
}

ON_DOOR_EVENTMAKERid 8🟢 high

door event

Fires when the state of a linked door changes (e.g. opened/closed). The event carries no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_DOOR_EVENT( enabled, i0, i1, i2, def0, maker0 )
{
    if ( enabled ) {
        if ( myself.enabled ) {
            return;
        }
        myself.enabled = 1;
        if ( room_index == 1 ) {
            i2 = GetInZoneID( );
            maker0 = InstantZone_GetNpcMaker( i2, alarm_maker_name );
            if ( IsNull( maker0 ) == @FALSE ) {
                SendMakerScriptEvent( maker0, @SPAWN_ALL_INSTANT, 0, 0 );
                SendMakerScriptEvent( maker0, 12566, room_index, 0 );
            }
            AddTimerEx( 2004, ( 20 * 1000 ) );
        }
        if ( room_index == 8 ) {
            AddTimerEx( 2003, 3000 );
        }
        for( i0 = 0; i0 < myself.def_count; ++i0 ) {
    // ... (full body omitted)

TRAP_DEFUSEDNPCid 119🟢 high

the trap was defused

Fires when the linked trap has been defused. The engine fills in: i0 — integer (i0).

Usage example

EventHandler TRAP_DEFUSED(i0)
{
    myself.c_ai0 = GetCreatureFromID(i0);
    ShowSystemMessage(myself.c_ai0, 2285);
}

TRAP_DETECTEDNPCid 120🟢 high

trap detected

Fires when the associated trap has been detected. The engine fills in: i0 — integer (i0).

Usage example

EventHandler TRAP_DETECTED( i0, i1 )
{
    SetVisible( 1 );
}

TRAP_ACTIVATEDNPCid 118🟢 high

trap activated

Fires when the associated trap has triggered (activated). The engine fills in: i0 — integer (i0).

Usage example

EventHandler TRAP_ACTIVATED( i0 )
{

}

INSTANT_ZONE_REMAIN_DURATIONNPCid 191🟢 high

remaining instance zone time

Fires when information about the remaining instance zone access duration arrives. The engine fills in: reply — response code/choice.

Usage example

EventHandler INSTANT_ZONE_REMAIN_DURATION(reply)
{
    myself.av_ai0.Exchange(reply);
}

TRAP_STEP_OUTNPCid 117🟢 high

leaving the trap zone

Fires when a creature leaves the area of effect of the associated trap. The engine fills in: i0 — integer (i0); i1 — integer (i1).

Usage example

EventHandler TRAP_STEP_OUT(i0, i1, c0)
{
    c0 = GetCreatureFromID(i0);
    SetWorldTrapVisibleByClassId(myself.sm.class_id, show_step_out);
}

DOOR_HP_LEVEL_INFORMEDNPCid 77🟢 high

gate HP level notification

Fires when information about the durability (HP) level of a door/gate is received. The engine fills in: talker — the player; level — level.

Initiated by: GetDoorHpLevel (see NASC_FUNCTIONS).

Usage example

EventHandler DOOR_HP_LEVEL_INFORMED(talker, level, i0, i1, i2, fhtml0)
{
    if (Castle_IsUnderSiege() || GetDominionWarState(dominion_id) == 5)
    {
        ShowPage(talker, fnSiegeStoppedFunction);
    }
    else if (IsMyLord(talker) == @TRUE || ((HavePledgePower(talker, 23) && Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0)))
    {
        i0 = GetCookie(talker, "gate_price");
        i1 = GetCookie(talker, "gate_level");
        i2 = GetCookie(talker, "gate_num");
        if (level >= i1)
        {
            FHTML_SetFileName(fhtml0, fnCurrentDoorLevelHigher);
            FHTML_SetInt(fhtml0, "doorlevel", level);
            ShowFHTML(talker, fhtml0);
        }
        else if (OwnItemCount(talker, @adena) >= i0)
        {
            DeleteItem1(talker, @adena, i0);
    // ... (full body omitted)
}

MPCC_TELEPORTEDNPCid 108🟢 high

command channel teleportation

Fires when members of an MPCC (united command channel) are teleported. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server TeleportMPCCToLocation) = the number of command alliance (MPCC) members actually teleported; >0 — someone was moved.

Usage example

EventHandler MPCC_TELEPORTED( talker, reply, i0, i1, c0 )
{
    i0 = GetGlobalMap(3);
    if (i0 != -1) {
        c0 = GetCreatureFromIndex(i0);
        i1 = MPCC_GetMPCCId(talker);
        if (talker == MPCC_GetMaster(i1) && IsNullCreature(c0) == 0 && c0.alive) {
            if (reply >= 99) {
                SendScriptEvent(c0, 99999999, i1);
                myself.i_ai1 = i1;
            }
            if (reply > 0) {
                myself.i_ai0 = myself.i_ai0 + reply;
                SetDBValue(myself.sm, myself.i_ai0);
                if (c0.db_value == 0) {
                    MPCC_SetMasterPartyRouting(myself.i_ai1, c0, 0);
                    SendScriptEvent(c0, 0, 0);
                }
            }
        }
    // ... (full body omitted)
}

ON_NPCPOS_EVENTMAKERid 7🟢 high

NPC position event

Fires on an event related to NPC position/appearance. The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_NPCPOS_EVENT( enabled, i0, def0 )
{
    if ( enabled ) {
        if ( myself.enabled ) {
            return;
        }
        myself.enabled = 1;
        for( i0 = 0; i0 < myself.def_count; ++i0 ) {
            def0 = GetSpawnDefine( i0 );
            if ( IsNull( def0 ) == @FALSE ) {
                if ( AtomicIncreaseTotal( def0, def0.total, 1 ) ) {
                    def0.Spawn2( def0.total, 0, 0 );
                }
            }
        }
    } else {
        if ( myself.enabled == 0 ) {
            return;
        }
        myself.enabled = 0;
    // ... (full body omitted)

FIELD_CYCLE_STEP_EXPIREDNPCid 186🟢 high

field cycle step expiration

Fires when the timer of the next phase of a cyclic field event expires. The engine fills in: event_id — arena/zone/field id; i0 — number of the expired phase; i1 — integer (extra parameter).

Initiated by: expiration of the cycle phase timer; subscription — RegisterFieldCycleEventEx / RegisterAsFieldCycleManager; the phase change is done by SetStep_FieldCycle (see NASC_FUNCTIONS).

Usage example

EventHandler FIELD_CYCLE_STEP_EXPIRED(event_id, i0, i1)
{
    if (event_id == RaceCycleID)
    {
        if (i0 == 0 || i0 == 1)
        {
            if (i1 == 0)
            {
                SetStep_FieldCycle(RaceCycleID, 2, 8, myself.sm);
            }
        }
    }
}

TELEPORT_TO_USER_RESNPCid 114🟢 high

response to a teleport to a player

Arrives as a response to a request to teleport to a player. The engine fills in: talker — the player; i0 — residence id; success — success.

Triggered by: TeleportToUser (see NASC_FUNCTIONS).

Usage example

EventHandler TELEPORT_TO_USER_RES(talker, i0, success, c0)
{
    if (success == @FALSE)
    {
        AddLog(10, talker, success);
    }
    else
    {
        c0 = GetCreatureFromID(i0);
        if (IsNullCreature(c0) == @FALSE)
        {
            AddLog(10, talker, 3);
        }
        else
        {
            AddLog(10, talker, 3);
        }
        ShowPage(talker, "court_magician003.htm");
    }
}

Dialogs, menus, learning

9 events

MENU_SELECTEDNPCid 31🟢 high

the player selected a dialog menu item

Fires when the player clicks an item in the NPC's open menu. The engine fills in: talker — the player; ask — menu section; reply — the selected option; state — state/status; action_id — action code.

WHERE THE ask/reply NUMBERS COME FROM. They are assigned by the dialog author: the NPC's
html page contains a link of the form

<a action="bypass -h menu_select?ask=635&reply=1">...</a>

The player's click on such a link is what generates MENU_SELECTED with those ask/reply. The
links themselves live in external dialog html files (which is why these numbers are "not
visible" in .nasc — they come from html); the script can also insert such a link into the
page itself via FHTML_SetStr (see NASC_FUNCTIONS, FHTML group). The ask/reply pairs are
an arbitrary convention between the html and the handler, but in real scripts
conventions have settled:

ask > 0 (common case) the number of the QUEST that the dialog branch belongs to:
quest N's pages are named *_q0NNN_MM.htm, the links
in them send ask=N, and the handler in the ask == N branch
immediately calls SetCurrentQuestID(@quest)
ask == -1000 base citizen menu: reply 0 —
greeting, reply 1 — information about domain/tax
ask == -303 multisell selection: reply — multisell id,
passed directly to ShowMultisell(reply, talker)
ask == -301 buff menu (links are built by the script via FHTML_SetStr)

Values of reply (from real scripts): reply is NOT a result code but the id of the selected menu item (arbitrary, set by the html page; in the scripts — hundreds of values).

Initiated by: html menu (ShowPage/links in html of the form bypass -h menu_select?ask=N&reply=M) (see NASC_FUNCTIONS).

Usage example

EventHandler MENU_SELECTED( talker, ask, reply, state, i0, s0 )
{
    if ( myself.sm.flag < 2 ) { return; }

    if ( ask == 1002 ) {
        if ( reply == 3 && state > 0 ) {
            if( ( GetCurrentTick() - talker.quest_last_reward_time ) < 2 ) { return; }
            talker.quest_last_reward_time = GetCurrentTick();

            if ( OwnItemCount( talker, @adena ) >= 75000000 * state ) {
                DeleteItem1( talker, @adena, 75000000 * state );
                i0 = @s_atb_b_f_buff1 + Rand(5);
                CastBuffForQuestReward( myself.c_ai0, i0 );
                GiveItem1( talker, @atb_black_friday_box_a, 1 * state );
                ShowPage( talker, "atb_black_friday003.htm" );
            } else {
                ShowPage( talker, "atb_black_friday004.htm" );
                myself.c_ai1 = myself.c_ai0;
                myself.c_ai0 = GetNullCreature( );
                myself.sm.flag = 0;
    // ... (full body omitted)
}

TALK_SELECTEDNPCid 4🟢 high

the player clicked on the NPC

Fires when the player selects the NPC with a click (targets it for conversation). The engine fills in: talker — the player; _from_choice — _from_choice; _code — _code.

Usage example

EventHandler TALK_SELECTED( fhtml0, i0, talker )
{
    if ( _from_choice == 0 ) {

        if ( _choiceN > 1 ) {
            myself.ShowChoicePage( talker, 1 );
            return;
        }
    }

    if ( _from_choice || _choiceN == 1 ) {
        if ( myself.GetInventoryInfo( talker, 0 ) >= ( myself.GetInventoryInfo( talker, 1 ) * 0.800000 ) || myself.GetInventoryInfo( talker, 2 ) >= ( myself.GetInventoryInfo( talker, 3 ) * 0.800000 ) ) {
            myself.ShowSystemMessage( talker, 1118 );
            return;
        }

        select ( _code ) {
        }
        return;
    }
    // ... (full body omitted)
}

TALKEDNPCid 3🟢 high

the player started a conversation with the NPC

Fires when the player initiates a dialog with the NPC. The engine fills in: talker — the player; _from_choice — _from_choice; _code — _code.

Usage example

EventHandler TALKED( talker )
{
    if ( _from_choice == 0 ) {
        if ( HaveMemo( talker, @bak_event ) == 0 ) {
            _choiceN = ( _choiceN + 1 );
            _code = 0;
            AddChoiceFStrEx(0, 101, @QCCE_START);    // Letters of Love
        }
        if ( _choiceN > 1 ) {
            ShowChoicePage( talker, 0 );
            return;
        }
    }
    if ( _from_choice || _choiceN == 1 ) {
        if ( _code == 0 ) {
            if ( _from_choice == 0 || HaveMemo( talker, @bak_event ) == 0 ) {
                SetCurrentQuestID( @gourd_event );
                if (GetInventoryInfo(talker, @IPT_CURRENT_WEIGHT) >= (GetInventoryInfo(talker, @IPT_MAX_CARRY_WEIGHT) * 0.900000) || GetInventoryInfo(talker, @IPT_CURRENT_SLOT_COUNT) >= (GetInventoryInfo(talker, @IPT_MAX_SLOT_COUNT) * 0.900000))
                {
                    ShowSystemMessage(talker, 3262);
    // ... (full body omitted)
}

ONE_SKILL_SELECTEDNPCid 34🟢 high

a specific skill was selected

Judging by the name and arguments, fires when the player selects a single skill (e.g. from the learn list). The engine fills in: talker — the player; skill_name_id — skill [skill]; need_quest — quest flag; i0 — integer (i0).

Usage example

EventHandler ONE_SKILL_SELECTED(talker, skill_name_id, need_quest, i0)
{
    ShowGrowEtcSkillMessage(talker, skill_name_id, i0, "");
}

MANOR_MENU_SELECTEDNPCid 38🟢 high

manor menu item selected

Fires when the player selects an item in the manor menu (castle agriculture). The engine fills in: talker — the player; ask — manor menu section; state — state/status; time — game time.

reply values (from real scripts): ask/reply are defined by the manor html menu (not fixed codes).

Usage example

EventHandler MANOR_MENU_SELECTED(talker, state, ask, time)
{
    if (state == -1)
    {
        state = myself.sm.residence_id;
    }
    if (ask == 3) { ShowSeedInfo(talker, state, time); } else
    if (ask == 4) { ShowCropInfo(talker, state, time); } else
    if (ask == 5) { ShowManorDefaultInfo(talker); } else
    if (ask == 7) { ShowSeedSetting(talker, state); } else
    if (ask == 8) { ShowCropSetting(talker, state);  }
}

SHOW_ENCHANT_SKILL_DRAWERNPCid 121🟢 high

showing the skill enchant window

Fires when the skill enchant window (drawer) needs to be shown to the player. The engine fills in: talker — the player; skill_name_id — skill [skill]; action_id — action code.

Usage example

EventHandler SHOW_ENCHANT_SKILL_DRAWER(talker, skill_name_id, action_id)
{
    ShowEnchantSkillListDrawer(talker, skill_name_id, action_id);
}

ONE_ENCHANT_SKILL_SELECTEDNPCid 35🟢 high

one skill selected for enchanting

Fires when the player selects a specific skill for enchanting. The engine fills in: talker — the player; skill_name_id — skill [skill]; action_id — action code.

Usage example

EventHandler ONE_ENCHANT_SKILL_SELECTED(talker, skill_name_id, action_id)
{
    ShowEnchantSkillMessage(talker, skill_name_id, action_id);
}

TUTORIAL_EVENTNPCid 52🟢 high

tutorial event

Fires when a tutorial system step occurs for the player. The engine fills in: talker — the player; event_id — arena/zone/field id.

Usage example

EventHandler TUTORIAL_EVENT( event_id, fhtml0, i1, i2, i3, i4, s1, talker )
{
    i1 = event_id * (-1);

    select ( i1 ) {
        case 3000 : {
            FHTML_SetFileName( fhtml0, LUCKY_GAME_COL_START_HTML );
            FHTML_SetInt( fhtml0, "user_ticket_count", OwnItemCount( talker, LUCKY_GAME_COL_ITEM_ID ) );
            ShowFHTML(talker, fhtml0);
            break;
        }
        case 4000 : {
            FHTML_SetFileName( fhtml0, LUCKY_GAME_ADENA_START_HTML );
            FHTML_SetInt( fhtml0, "user_ticket_count", OwnItemCount( talker, LUCKY_GAME_ADENA_ITEM_ID ) );
            ShowFHTML(talker, fhtml0);
            break;
        }
        case 3333 : {
            SetMemoStateEx( talker, LUCKY_GAME_COL_QUEST_ID, LUCKY_GAME_REQUEST_COUNT_SECTION, 0 );
            SetMemoStateEx( talker, LUCKY_GAME_ADENA_QUEST_ID, LUCKY_GAME_REQUEST_COUNT_SECTION, 0 );
    // ... (full body omitted)
}

SOCIAL_ACTION_EVENTNPCid 164🟢 high

social action

Fires when a player performs a social action (emote/gesture). The engine fills in: talker — the player; action_id — the action code.

Usage example

EventHandler SOCIAL_ACTION_EVENT(talker, action_id, i0)
{
    if (action_id == 4)
    {
        BroadcastScriptEvent(@SCE_START, 0, 9999);
        SayFStr(2010031, _blank, _blank, _blank, _blank, _blank);
    }
    super;
}

Combat & skills

16 events

ATTACKEDNPCid 1🟢 high

the NPC was hit

Fires when an attack lands on the NPC. The engine fills in: attacker — the attacker; damage — damage; weapon_class_id — weapon class; skill_name_id — skill [skill] (0 on a regular hit).

Usage example

EventHandler ATTACKED(attacker, damage, skill_name_id)
{
    if (attacker.is_pc == @TRUE || IsInCategory(@summon_npc_group, attacker.npc_class_id) == @TRUE || IsInCategory(@icequeen_npc, attacker.npc_class_id) == @TRUE)
    {
        if (myself.sm.hp < (myself.sm.max_hp / 20.000000))
        {
            if (myself.i_ai0 == 0)
            {
                myself.i_ai0 = 1;
                AddTimerEx(TIMER_elemental_killed, 1000);
            }
        }
        else
        {
            AddAttackDesire(attacker, @AMT_MOVE_TO_TARGET, damage * 2);
            if (skill_name_id != 0)
            {
                if (Skill_GetAbnormalType(@s_hate11) == Skill_GetAbnormalType(skill_name_id))
                {
                    AddAttackDesire(attacker, @AMT_MOVE_TO_TARGET, damage * 5);
    // ... (full body omitted)
}

CLAN_ATTACKEDNPCid 22🟢 high

a clanmate of the NPC was hit

Fires when a member of the same clan as the NPC is attacked. The engine fills in: attacker — the attacker; victim — the victim; weapon_class_id — weapon class; skill_name_id — skill [skill]; damage — damage.

Usage example

EventHandler CLAN_ATTACKED( victim, attacker, damage, i0 )
{
    if ( myself.boss.alive && victim == myself.boss ) {
        if ( IsNullCreature( attacker ) == 0 ) {
            MakeAttackEvent( attacker, damage, 0 );
        }
    }
    super;
}

USE_SKILL_FINISHEDNPCid 64🟢 high

the NPC finished using a skill

Fires when the NPC's skill cast finishes, and is also called on failure. The engine fills in: target — the target; skill_name_id — skill [skill]; success — success.

Initiated by: AddUseSkillDesire (see NASC_FUNCTIONS).

Usage example

EventHandler USE_SKILL_FINISHED( target, skill_name_id, success )
{
    if (skill_name_id == Skill03_ID && success == 1) {
        SetNpcParam( target, @VCP_HP, (target.hp + (target.max_hp * hp_heal_percentage)) );
    }
    super;
}

SEE_SPELLNPCid 15🟢 high

the NPC saw someone else's cast

Fires when the NPC notices another creature using a skill. The engine fills in: speller — the caster; target — the target; skill_name_id — skill [skill].

Usage example

EventHandler SEE_SPELL( speller, skill_name_id, target, i0 )
{
    if ( IsNullCreature( speller ) == 0 ) {
        if ( skill_name_id == detectSkill ) {
            if ( DistFromMe( speller ) < 600 ) {
                AddUseSkillDesire( target, detectSkill, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 99999999900000000 );
            }
        }
    }
}

PARTY_ATTACKEDNPCid 18🟢 high

a party member or subordinate was hit

Fires when a member of the NPC's party or one of its minions is attacked. The engine fills in: attacker — the attacker; private — the minion/party member; damage — damage.

Usage example

EventHandler PARTY_ATTACKED( attacker, private, damage )
{
    if ( private != myself.sm && attacker != myself.sm ) {
        myself.i_ai1 = myself.i_ai1 + damage;
    }
}

PARTY_DIEDNPCid 20🟢 high

a party member died

Judging by the name and argument, fires when a member of the NPC's party dies. The engine fills in: private — the minion/party member; attacker — the attacker.

Usage example

EventHandler PARTY_DIED(attacker, private, i0, i1)
{
    if (private == myself.boss && myself.sm.alive != 0) {
        if (FieldCycle2 != -1 && FieldCycle2_Condition == 101) {
            i0 = GetStep_FieldCycle(FieldCycle2);
            if (i0 >= Threshold_Level_Min2 && i0 <= Threshold_Level_Max2) {
                AddPoint_FieldCycle(FieldCycle2, FieldCycle2_Quantity, 3, attacker);
            }
            RemoveAllDesire();
            Say(MakeFString(1800024, "", "", "", "", ""));
            AddTimerEx(1399, 1500);
        }
    }
    super;
}

SPELLEDNPCid 2🟢 high

a skill was used on the NPC

Fires when a used skill lands on the NPC (the effect reached the target). The engine fills in: speller — the caster; skill_id — skill id; skill_level — skill level; skill_name_id — skill [skill].

Usage example

EventHandler SPELLED( speller, skill_name_id, skill_id )
{
    if (babble_mode == 1) {
        Say("" + IntToStr(skill_id));
    }
    if (skill_name_id == Skill_unlock) {
        if (GetInventoryInfo( speller, @IPT_CURRENT_SLOT_COUNT ) >= GetInventoryInfo( speller, @IPT_MAX_SLOT_COUNT ) * 0.900000 || GetInventoryInfo( speller, @IPT_CURRENT_WEIGHT ) >= GetInventoryInfo( speller, @IPT_MAX_CARRY_WEIGHT ) * 0.900000) {
            if (Inven_Check_SysMsg != 0) {
                ShowSystemMessage(speller, Inven_Check_SysMsg);
            }
            return;
        }
        if (babble_mode == 1) {
            Say("");
        }
        GiveItem1( speller, Item_reward_coin , Qty_reward_coin);
    }
}

ATTACK_FINISHEDNPCid 57🟢 high

the NPC finished an attack

Fires when the NPC's attacking action completes. The engine fills in: target — the target.

Initiated by: AddAttackDesire (see NASC_FUNCTIONS).

Usage example

EventHandler ATTACK_FINISHED(target)
{
    if (target.alive == @FALSE && target.is_pc == @TRUE)
    {
        Despawn();
    }
    super;
}

ABNORMAL_STATUS_CHANGEDNPCid 113🟢 high

the NPC's abnormal status changed

Judging by the name and arguments, fires when the NPC's abnormal state changes (buff/debuff). The engine fills in: speller — the caster; skill_id — skill id; skill_level — skill level; skill_name_id — skill [skill].

Usage example

EventHandler ABNORMAL_STATUS_CHANGED(speller, skill_id, skill_level, skill_name_id, s0, i0)
{
    i0 = skill_id - 5106;
    if (skill_id == 5106 || skill_id == 5107 || skill_id == 5108)
    {
        if (skill_level == 0)
        {
            if (myself.i_quest0 > 0)
            {
                if (Skill_GetConsumeMP(CaptureCancel_all) < myself.sm.mp && Skill_GetConsumeHP(CaptureCancel_all) < myself.sm.hp && Skill_InReuseDelay(CaptureCancel_all) == 0)
                {
                    AddUseSkillDesire(myself.sm, CaptureCancel_all, @ST_HEAL, @AMT_MOVE_TO_TARGET, 10000000);
                }
                AddLogByNpc(414, myself.sm, 6, 0);
                if (myself.sm.alive != 0)
                {
                    myself.i_quest0 = 0;
                }
            }
        }
    // ... (full body omitted)
}

CLAN_DIEDNPCid 93🟢 high

a clanmate of the NPC died

Judging by the name and arguments, fires when a member of the same clan dies. The engine fills in: victim — the victim.

Usage example

EventHandler CLAN_DIED(victim, i0)
{
    AddFleeDesireEx(victim, Distance, 10000);
    super;
}

STATIC_OBJECT_CLAN_ATTACKEDNPCid 24🟢 high

a clan-owned static object was attacked

Fires when a hit lands on a static object belonging to the clan. The engine fills in: attacker — the attacker; victim_so — the victim static object; weapon_class_id — weapon class; skill_name_id — skill [skill]; damage — damage.

Usage example

EventHandler STATIC_OBJECT_CLAN_ATTACKED( attacker, damage, skill_name_id, i0 )
{
    if (skill_name_id == 154796033) {
        if (DistFromMe(attacker) < 500) {
            if (myself.i_ai0 == 1) {
                AddEffectActionDesire(myself.sm, 1, 10000, 10000);
                BroadcastScriptEvent(13013, 0, 5000);
                AddTimerEx(2005, 2000);
                AddTimerEx(2006, 5500);
                if (Skill_GetConsumeMP(354418689) < myself.sm.mp && Skill_GetConsumeHP(354418689) < myself.sm.hp && Skill_InReuseDelay(354418689) == 0 && (GetAbnormalLevel(myself.sm, Skill_GetAbnormalType(23134209)) <= 0 && GetAbnormalLevel(myself.sm, Skill_GetAbnormalType(87556097)) <= 0)) {
                    AddUseSkillDesire(myself.sm, 354418689, 0, 1, 1000000);
                }
            } else {
                i0 = Rand(100);
                if (i0 < 33) {
                    Shout(MakeFString(1800064, "", "", "", "", ""));
                } else {
                    if (i0 < 66) {
                        Shout(MakeFString(1800065, "", "", "", "", ""));
                    } else {
    // ... (full body omitted)
}

PET_DIEDNPCid 165🟢 high

pet death

Fires when a pet dies. The engine fills in: i0 — integer (i0); i1 — integer (i1).

Usage example

EventHandler PET_DIED(i0, i1, i2)
{
    if (i0 == 1 && i1 == 0) {
        i2 = Rand(10) + 1;

        if (myself.sm.master.pk_count <= i2) {
            IncrementParam(myself.sm.master, @PARAM_PKCOUNT, -1 * myself.sm.master.pk_count);
        } else {
            IncrementParam(myself.sm.master, @PARAM_PKCOUNT, -1 * i2);
        }
    }
}

SPELL_SUCCESSEDNPCid 187🟢 high

successful skill use

Fires when a skill use completes successfully. The engine fills in: target — the target the cast landed on; skill_id — skill id; skill_level — skill level; skill_name_id — skill [skill].

Usage example

EventHandler SPELL_SUCCESSED(skill_name_id, target)
{
    if (skill_name_id == @s_npc_monster_garden_of_genesis_aphros_draw1)
    {
        AddUseSkillDesire(target, @s_npc_monster_garden_of_genesis_aphros_attack6, @ST_ATTACK, @AMT_MOVE_TO_TARGET, -1);
    }
}

USE_SKILL_STARTEDNPCid 193🟢 high

start of skill use

Fires at the moment the NPC starts using a skill. The engine fills in: target — the target; skill_name_id — the skill [skill].

Initiated by: AddUseSkillDesire (see NASC_FUNCTIONS).

Usage example

EventHandler USE_SKILL_STARTED(skill_name_id)
{
    if (skill_name_id == @s_npc_monster_garden_of_genesis_aphros_draw1)
    {
        SayFStr(1811750, _blank, _blank, _blank, _blank, _blank);
    }
    super;
}

IS_TOGGLE_SKILL_ONOFFNPCid 175🟢 high

query the state of a toggle skill

Fires as a query/check of the state of a toggle skill — on or off. The engine fills in: target — the target; i0 — integer (i0).

Usage example

EventHandler IS_TOGGLE_SKILL_ONOFF(target, i0)
{
    myself.i_ai1 = i0;
}

REALDAMAGEDid none🟡 medium

real damage dealt

Fires when "real" damage (real damage) has gone through on the NPC — a damage type from the skill effect i_real_damage that bypasses the normal defense calculations. attacker — the damage source; reply — the damage amount/code; i0 — an accompanying value. There is no separate factory in the disassembled builds — the fields are per real usage.

Usage example

EventHandler REALDAMAGED(attacker, reply, i0)
{
    //
}

AI, movement, perception

10 events

SEE_CREATURENPCid 5🟢 high

the NPC noticed a creature

Fires when a creature enters the NPC's field of view. The engine fills in: creature — the creature seen.

Usage example

EventHandler SEE_CREATURE(creature, i0, i1, c0, party0)
{
    myself.c_ai0 = creature;
    super;
}

NO_DESIRENPCid 0🟢 high

the desire queue is empty, the NPC is idle

Fires when the NPC has no active desires left and nothing to do. The event carries no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler NO_DESIRE( i0, i1, i2, i3, i4, i5, i6, i7, i8, i9 )
{
    if ( myself.sm.flag == 4 ) {
        if ( IsNullCreature( myself.c_ai0 ) == 0 ) {
            if ( ( myself.c_ai0.alive == @FALSE ) || ( DistFromMe( myself.c_ai0 ) > 1000 ) ) {
                ChangeMoveType( 0 );
                myself.sm.flag = 0;
                if ( IsNullCreature( myself.c_ai1 ) == 0 ) {
                    SendScriptEventEx( myself.c_ai1, 32110005, 0, 0 );
                }
                myself.i_ai3 = 0;
                myself.i_ai0 = -1;
                myself.c_ai0 = GetNullCreature( );
                myself.c_ai1 = GetNullCreature( );
            }
        } else {
            ChangeMoveType( 0 );
            myself.sm.flag = 0;
            if ( IsNullCreature( myself.c_ai1 ) == 0 ) {
                SendScriptEventEx( myself.c_ai1, 32110005, 0, 0 );
    // ... (full body omitted)

MOVE_TO_FINISHEDNPCid 65🟢 high

the NPC reached a point

Fires when the NPC completes its movement and reaches the given point. The engine fills in: x — X coordinate; y — Y coordinate; z — Z coordinate.

Initiated by: AddMoveToDesire/AddMoveToTargetDesire (see NASC_FUNCTIONS).

Usage example

EventHandler MOVE_TO_FINISHED( x, y, z )
{
    if ( x == myself.start_x && y == myself.start_y && z == myself.start_z ) {
        AddDoNothingDesire( 40, 30 );
    }
}

OUT_OF_TERRITORYNPCid 16🟢 high

the NPC left its territory

Fires when the NPC goes beyond the bounds of its assigned territory. The event carries no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler OUT_OF_TERRITORY( i0, i1, i2, c0 )
{
    if ( myself.sm.db_value != 3 ) {
        return;
    }
    c0 = myself.top_desire_target;
    if ( IsNullCreature( c0 ) == 0 ) {
        if ( c0.is_pc == @FALSE ) {
        } else {
        }
    }
    StopMove( );
    RemoveAllAttackDesire( );
    InstantTeleport( myself.sm, 174226, -88013, -5112 );
}

DESIRE_MANIPULATIONNPCid 17🟢 high

external influence on the NPC's desires

Judging by the name and arguments, fires on an attempt to control the NPC's behavior (desires) from outside. The engine fills in: speller — the initiator; desire — desire type (motive).

Values of desire — desire type (AI motive, @AMT_* in manual_pch). In the pch of all chronicles only
two are named: @AMT_STAND = 0 (stand), @AMT_MOVE_TO_TARGET = 1 (move to target). The full set of
motives is the family of Add*Desire functions (Attack, MoveTo, Follow, UseSkill, Flee, etc.);
their numeric enum is defined in the engine (L2NPC) and is not fully dumped in the loaded L2Server/pch.

Usage example

EventHandler DESIRE_MANIPULATION(speller, desire)
{
    MakeAttackEvent(speller, desire, 0);
}

NODE_ARRIVEDNPCid 115🟢 high

arrival at a route node

Fires when the NPC reaches the next node of a route/patrol. The engine fills in: sev_arg1 — node index; sev_arg2 — NPC class; sev_arg3 — phrase index; state — id of the social action (gesture) for the node; success — arrival success.

Values of state are the id of the social action (gesture) the NPC plays at the node (engine
CNPC::SocialAction(int nActionId, ...), constants SOCIALACTION_*). Not a short fixed enum:
the gesture number is set in the route data (see freewayinfo.txt / waypoints), so the set of
values is determined by that data, not hardcoded in the language.

Initiated by: AddMoveFreewayDesire/AddMoveToWayPointDesire (see NASC_FUNCTIONS).

Usage example

EventHandler NODE_ARRIVED( script_event_arg1, script_event_arg2, script_event_arg3, success )
{
    if (success == 1) { Despawn(); }

    if (script_event_arg1 == 3) { EquipItem(OHS_Weapon); } else
    if (script_event_arg1 == 4) { UnequipWeapon(); } else
    if (script_event_arg1 == 36) { EquipItem(OHS_Weapon); } else
    if (script_event_arg1 == 37) { UnequipWeapon(); } else
    if (script_event_arg1 == 51) { EquipItem(OHS_Weapon); } else
    if (script_event_arg1 == 52) {
        UnequipWeapon();
        BroadcastScriptEventEx( 10005, GetIndexFromCreature(myself.sm), 0, 5000 );
        BroadcastScriptEventEx( 10002, GetIndexFromCreature(myself.sm), 0, 8000 );
    } else
    if (script_event_arg1 == 53) {
        BroadcastScriptEventEx( 10001, 0, 0, 5000);
        BroadcastScriptEventEx( 10002, GetIndexFromCreature(myself.sm), 0, 8000 );
        AddTimerEx( 1001, 3000 );
    } else
    if (script_event_arg1 == 54) { EquipItem(OHS_Weapon); } else
    // ... (full body omitted)
}

MOVE_TO_WAY_POINT_FINISHEDNPCid 63🟢 high

the NPC reached a waypoint

Fires when the NPC has finished moving to a route waypoint. The engine fills in: way_point_index — waypoint index; next_way_point_index — next waypoint index.

Initiated by: AddMoveToWayPointDesire (see NASC_FUNCTIONS).

Usage example

EventHandler MOVE_TO_WAY_POINT_FINISHED(way_point_index, next_way_point_index)
{
    myself.i_ai1 = next_way_point_index;
    AddTimerEx(100001, GetWayPointDelay(WayPointDelays, way_point_index) * 1000);
}

SEE_ITEMNPCid 7🟢 high

the NPC saw items on the ground

Fires when the NPC notices items on the ground within its field of view (PoI). The engine fills in: item_index_list — list of items (CIntList).

Usage example

EventHandler SEE_ITEM( item_index_list, i0, i1, i2 )
{
    i0 = item_index_list.GetSize( );
    for ( i1 = 0; i1 < i0; ++i1 ) {
        AddGetItemDesireEx( item_index_list.GetItemIndex( i1 ), 10 - i1 );
    }
}

GET_ITEM_FINISHEDNPCid 60🟢 high

NPC finished picking up an item

Fires when the NPC has finished picking up an item. The engine fills in: item — the item; success — whether the pickup succeeded.

Initiated by: AddGetItemDesire (see NASC_FUNCTIONS).

Usage example

EventHandler GET_ITEM_FINISHED( item, success )
{
    if (item.class_id == 8190 || item.class_id == 8689) {
        if (success == 1) {
            Say(MakeFString(1800023, "", "", "", "", ""));
        }
    }
}

FIND_RANDOM_USERNPCid 172🟡 medium

find a random player

Arrives as a response to a call of the FindRandomUser(...) function (a network request to L2Server, opcode 227): the server looks for a random suitable player. The engine fills in only talker — the found player (empty if none found); i0 and the rest in the declaration are free slots for the body. The event factory exists in build CT2.3; it is absent in the CT26 build.

Related function: FindRandomUser (see NASC_FUNCTIONS).

Usage example

EventHandler FIND_RANDOM_USER( talker, i0 )
{
    myself.c_quest0 = talker;
    RegisterGlobalMap( 101, talker.id );
    if ( IsNullCreature( talker ) == 0 ) {
        CreateOnePrivateNearUser( talker, @br_santa_white_gift, "br_santa_white_gift", myself.sm.weight_point, 1, 90, 60 );
    }
    super;
}

Events, PvP, olympiad, minigames

31 events

ON_OLYMPIAD_GAME_PREPAREDNPCid 128🟢 high

Olympiad match prepared

Fires when an Olympiad duel has been prepared for start. The engine fills in: event_id — the arena; i0 — match rule type (see below).

i0 values — match rule type (enum GameRuleType, L2Server; proven by the table
g_anTeamMembersNumber = {3, 1, 1}: type 0 has 3 fighters per team, types 1 and 2 have one each):
0 gamerule_team team battle (3×3)
1 gamerule_nonclassbased non-class-based 1×1 battle (default value)
2 gamerule_classbased class-based 1×1 battle
The order is also confirmed by the example below itself: select(i0) branches case 0 -> fstr_prepared_team,
case 1 -> fstr_prepared_classless, case 2 -> fstr_prepared_class — i.e. the value arrives
at the NPC as is, without remapping. (In another script, sw_ilgf, the author marked the order as reversed — that
is an error in his comment; see OLYMPIAD_MATCH_RESULT_EVENT.)

Usage example

EventHandler ON_OLYMPIAD_GAME_PREPARED(event_id, i0, i1, i2, c0, c1)
{
    c0 = GetCreatureFromID(i1);
    c1 = GetCreatureFromID(i2);
    if (IsNullCreature(c0) == @FALSE && IsNullCreature(c1) == @FALSE)
    {
        SayFStr( 3603431, c0.name, "#" + IntToStr(1811000 + c0.occupation), c1.name, "#" + IntToStr(1811000 + c1.occupation), IntToStr(event_id));
    }
    else
    {
        select (i0)
        {
            case 0: { SayFStr(fstr_prepared_team, IntToStr(event_id), _blank, _blank, _blank, _blank); break; }
            case 1: { SayFStr(fstr_prepared_classless, IntToStr(event_id), _blank, _blank, _blank, _blank); break; }
            case 2: { SayFStr(fstr_prepared_class, IntToStr(event_id), _blank, _blank, _blank, _blank); break; }
        }
    }
}

ON_OLYMPIAD_FIELD_STEP_CHANGED_EVENTMAKERid 18🟢 high

Olympiad field stage changed

Fires when the stage (step) of an Olympiad field/arena changes. The engine fills in: event_id — arena/zone/field id; state — state/status; inzone_type_id — instance zone type.

Usage example

EventHandler ON_OLYMPIAD_FIELD_STEP_CHANGED_EVENT(state, event_id, maker0)
{
    if (maker_event_id == event_id) {
        if (state == 0) {
            maker0 = GetNpcMaker(myself.name);
            if (IsNull(maker0) == 0) {
                SendMakerScriptEvent(maker0, 1000, 0, 0);
            }
        } else {
            maker0 = GetNpcMaker(myself.name);
            if (IsNull(maker0) == 0) {
                SendMakerScriptEvent(maker0, 1001, 0, 0);
            }
        }
    }
}

IS_USER_PVPMATCHING_RESULTNPCid 138🟢 high

result of checking a player's PvP matchmaking participation

Fires when the result of checking whether the player is participating in PvP matchmaking arrives. The engine fills in: i0 — integer (i0); reply — response code/choice.

reply values: reply (L2Server NpcIsPVPMatching → IsCrataeCubeUser): 0 — the player is NOT in a match (Cratae Cube); 1 — in a match.

Initiated by: IsUserPVPMatching (see NASC_FUNCTIONS).

Usage example

EventHandler IS_USER_PVPMATCHING_RESULT(reply, i0, c0)
{
    if (reply == 0) {
        c0 = GetCreatureFromID(i0);
        InstantTeleport(c0, -70411, -70958, -1416);
    }
}

UNREGISTER_USER_PVP_MATCH_RESULTNPCid 140🟢 high

result of cancelling PvP matchmaking registration

Fires when the result of cancelling the player's registration in PvP matchmaking arrives. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server NpcUnregisterUserPVPMatch): there is no numeric code — an echo of userId (UnregisterUser is void).

Initiated by: UnregisterUserPVPMatch (see NASC_FUNCTIONS).

Example:

EventHandler UNREGISTER_USER_PVP_MATCH_RESULT( )

MG_JOIN_GAME_RETURNEDNPCid 101🟢 high

game join result

Fires as the return of the result of a request to join a game of the MG subsystem. The engine fills in: talker — the player; reply — response code/choice.

Initiated by: MG_JoinGame (see NASC_FUNCTIONS).

Usage example

EventHandler MG_JOIN_GAME_RETURNED( talker, reply )
{
    select ( reply ) {
        case 0 : { break; }
        case -1 : { myself.ShowPage( talker, "game_manager002.htm" ); break; }
        case -2 : { myself.ShowPage( talker, "game_manager004.htm" ); break; }
        case -3 : { myself.ShowPage( talker, "game_manager005.htm" ); break; }
        case -4 : { myself.ShowPage( talker, "game_manager006.htm" ); break; }
        case -5 : { myself.ShowPage( talker, "game_manager007.htm" ); break; }
        case -6 : { myself.ShowPage( talker, "game_manager008.htm" ); break; }
        case -7 : { myself.ShowPage( talker, "game_manager009.htm" ); break; }
        case -8 : { myself.ShowPage( talker, "game_manager010.htm" ); break; }
        case -9 : { myself.ShowPage( talker, "game_manager011.htm" ); break; }
        case -10 : { myself.ShowPage( talker, "game_manager012.htm" ); break; }
        case -11 : { myself.ShowPage( talker, "game_manager013.htm" ); break; }
        case -12 : { myself.ShowPage( talker, "game_manager003.htm" ); break; }
        case -14 : { myself.ShowPage( talker, "game_manager014.htm" ); break; }
        case -15 : { myself.ShowPage( talker, "game_manager015.htm" ); break; }
    }
}

ON_SSQ_SYSTEM_EVENTNPCid 89🟢 high

Seven Signs system event

Fires when an event of the Seven Signs (SSQ) subsystem occurs. The engine fills in: ask — menu section/sub-request; reply — response code/choice.

reply values: reply (L2Server SSQSystem, Seven Signs global event): 1 — the event has STARTED (OnEventStart), 0 — ENDED (OnEventEnd). ask/1st field = seal type (=1).

Usage example

EventHandler ON_SSQ_SYSTEM_EVENT( talker, ask, reply )
{
    if ( ask == 1 && reply == 1 ) {
        EffectMusic( myself.sm, 0, "SSQ_Neutral_01" );
        BroadcastSystemMessage( myself.sm, 0, 1210 );
    } else
    if ( ask == 1 && reply == 0 ) {
        EffectMusic( myself.sm, 0, "SSQ_Neutral_01" );
        BroadcastSystemMessage( myself.sm, 0, 1211 );
    } else
    if ( ask == 3 && reply == 1 ) {
        BroadcastSystemMessage( myself.sm, 0, 1218 );
        if ( GetSSQWinner( ) == 1 ) {
            EffectMusic( myself.sm, 0, "SSQ_Dusk_01" );
        } else {
            if ( GetSSQWinner( ) == 2 ) {
                EffectMusic( myself.sm, 0, "SSQ_Dawn_01" );
            }
        }
        if ( GetSSQSealOwner( 1 ) == 2 ) {
    // ... (full body omitted)
}

DELETE_PREVIOUS_OLYMPIAD_POINT_RETURNEDNPCid 96🟢 high

result of resetting previous Olympiad points

Fires as the response to a request to delete previously accumulated Olympiad points. The engine fills in: talker — the player; ask — menu section/sub-request; reply — response code/choice.

Initiated by: DeletePreviousOlympiadPoint (see NASC_FUNCTIONS).

Usage example

EventHandler DELETE_PREVIOUS_OLYMPIAD_POINT_RETURNED(talker, ask, reply, i0, i1)
{
    i1 = 0;
    if (reply != 0)
    {
        if (talker.hero_type == @HERO_WAITING || talker.hero_type == @HERO_ACTIVE)
        {
            i1 = 300;
        }
        if (ask > 1000)
        {
            i0 = (1000 + i1) * 1000;
        }
        else
        {
            i0 = (ask + i1) * 1000;
        }
        GiveItem1(talker, OlympiadGiveItems, i0);
        AddLogEx(1, talker, ask, i0);
    }
}

LET_IN_USER_PVP_MATCHNPCid 144🟢 high

admitting a player into a PvP match

Fires when a player is admitted to participate in a PvP match. The engine fills in: talker — the player.

Usage example

EventHandler LET_IN_USER_PVP_MATCH( talker, i0, party0 )
{
    if (talker.transformID == 260 || talker.transformID == 8 || talker.transformID == 9) {
        Dispel(talker, Skill_GetAbnormalType(55181313));
    }
    party0 = GetParty(talker);
    if (IsNullParty(party0) == 0) {
        ShowPage(talker, "cratae_teleport_npc007.htm");
        UnregisterUserPVPMatch(talker);
    } else {
        if (talker.instant_zone_id > 0) {
            UnregisterUserPVPMatch(talker);
        } else {
            if (talker.level >= 70 && talker.level <= 75) {
                i0 = Rand(100);
                if (i0 < 20) {
                    InstantTeleport(talker, -87247, -16391, -8320);
                } else
                if (i0 < 40) {
                    InstantTeleport(talker, -87159, -16594, -8320);
    // ... (full body omitted)
}

REGISTER_USER_PVP_MATCH_RESULTNPCid 139🟢 high

result of registering a player in a PvP match

Fires as a response to a request to register a player in a PvP match. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server NpcRegisterUserPVPMatch → RegisterUser): 0 — success; 1 — no active match of the required type; 8 — match is full (25 participants); 10 — player is not online; 12/13/14 — condition check codes (from the match object).

Initiated by: RegisterUserPVPMatch (see NASC_FUNCTIONS).

Usage example

EventHandler REGISTER_USER_PVP_MATCH_RESULT( talker, reply )
{
    if (reply == 0) {
        ShowPage(talker, "cratae_teleport_npc009.htm");
    } else
    if (reply == 1) {
    } else
    if (reply == 8) {
        ShowPage(talker, "cratae_teleport_npc005.htm");
    } else
    if (reply == 10) {
    } else
    if (reply == 12) {
    } else
    if (reply == 13) {
        ShowPage(talker, "cratae_teleport_npc007.htm");
    } else
    if (reply == 14) {
        ShowPage(talker, "cratae_teleport_npc011.htm");
    }
}

REGISTER_USER_RESURRECTION_TOWER_RESULTNPCid 141🟢 high

result of registering at a resurrection tower

Fires as a response to a request to register a player at a resurrection tower. The engine fills in: i0 — integer (i0); reply — response code/choice.

reply values: reply (L2Server NpcRegisterUserResurrectionTower): 0 — no match/resurrection NPC (fail); non-zero — ok.

Initiated by: RegisterUserResurrectionTower (see NASC_FUNCTIONS).

Usage example

EventHandler REGISTER_USER_RESURRECTION_TOWER_RESULT( reply )
{
    if (reply == 0) {
    } else {
        if (reply == 1) {
        }
    }
}

GET_RANK_USER_PVP_MATCH_RESULTNPCid 143🟢 high

result of requesting a player's PvP match rank

Fires as a response to a request to get a player's rank in a PvP match. The engine fills in: talker — the player; reply — response code/choice.

reply values: reply (L2Server NpcGetRankUserPVPMatch): 0 — no match/record; 1..5 — the player's rank (raw record-board field).

Initiated by: GetRankUserPVPMatch (see NASC_FUNCTIONS).

Usage example

EventHandler GET_RANK_USER_PVP_MATCH_RESULT( talker, reply, i0, i4, i5, h0 )
{
    if (myself.i_ai3 <= 25 && myself.i_ai3 >= 21) {
        if (reply == 1) {
            i4 = 100;
        } else {
            if (reply == 2) {
                i4 = 80;
            } else {
                if (reply == 3) {
                    i4 = 60;
                } else {
                    if (reply == 4) {
                        i4 = 40;
                    } else {
                        if (reply == 5) {
                            i4 = 20;
                        } else {
                            if (reply > 5) {
                                i4 = 10;
    // ... (full body omitted)
}

KILLED_USER_PVP_MATCH_RESULTNPCid 142🟢 high

kill recorded in a PvP match

Fires when a player kill is recorded during a PvP match. The engine fills in: talker — the player; attacker — the attacker; reply — response code/choice.

reply values: reply (L2Server NpcAddKillPointUserPVPMatch): there is NO reply packet — the handler only awards a kill point and writes a log; it returns no success/failure number.

Usage example

EventHandler KILLED_USER_PVP_MATCH_RESULT( talker, attacker, reply, i0, c0 )
{
    SetAsNull(c0);
    if (reply == 0) {
        i0 = pc_point;
    } else {
        if (reply == 1) {
            i0 = 1;
        }
    }
    if (talker.is_pc == 1) {
        if (attacker.is_pc == 1) {
            c0 = attacker;
        } else {
            if (attacker.summon_type == 1) {
                c0 = attacker.master;
            }
        }
        if (IsNullCreature(c0) == 0) {
            AddKillPointUserPVPMatch(c0, i0);
    // ... (full body omitted)
}

START_USER_PVP_MATCH_RESULTNPCid 145🟢 high

PvP match start

Fires when a PvP match starts. The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler START_USER_PVP_MATCH_RESULT( maker0 )
{
    if ( myself.i_ai0 == 1 ) {
    } else {
        myself.i_ai0 = 1;
        maker0 = GetNpcMaker( cratae_enter_name );
        if ( IsNull( maker0 ) == @FALSE ) {
            SendMakerScriptEvent( maker0, 2114002, 0, 0 );
        }
        if ( nType == 70 ) {
            maker0 = GetNpcMaker( maker_name_70 );
            if ( IsNull( maker0 ) == @FALSE ) {
                SendMakerScriptEvent( maker0, 2114002, 0, 0 );
            }
        } else {
            if ( nType == 75 ) {
                maker0 = GetNpcMaker( maker_name_75 );
                if ( IsNull( maker0 ) == @FALSE ) {
                    SendMakerScriptEvent( maker0, 2114002, 0, 0 );
                }
    // ... (full body omitted)

END_USER_PVP_MATCH_RESULTNPCid 147🟢 high

PvP match end

Fires when a PvP match ends. The engine fills in: c0 — creature (c0); c1 — creature (c1); c2 — creature (c2); c3 — creature (c3); c4 — creature (c4).

Usage example

EventHandler END_USER_PVP_MATCH_RESULT( maker0 )
{
    if ( myself.i_ai0 == 0 ) {
    } else {
        myself.i_ai0 = 0;
        maker0 = GetNpcMaker( cratae_enter_name );
        if ( IsNull( maker0 ) == @FALSE ) {
            SendMakerScriptEvent( maker0, 1717006, 0, 0 );
        }
        if ( nType == 70 ) {
            maker0 = GetNpcMaker( maker_name_70 );
            if ( IsNull( maker0 ) == @FALSE ) {
                SendMakerScriptEvent( maker0, 1717006, 0, 0 );
            }
        } else {
            if ( nType == 75 ) {
                maker0 = GetNpcMaker( maker_name_75 );
                if ( IsNull( maker0 ) == @FALSE ) {
                    SendMakerScriptEvent( maker0, 1717006, 0, 0 );
                }
    // ... (full body omitted)

WITHDRAW_USER_PVP_MATCH_RESULTNPCid 146🟢 high

player withdrawal from a PvP match

Fires when a player leaves/withdraws from a PvP match. The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Example:

EventHandler WITHDRAW_USER_PVP_MATCH_RESULT( )

REGISTER_PVP_MATCH_RESULTNPCid 130🟢 high

PvP match registration

Fires when an application to participate in a PvP match is processed. The engine fills in: talker — the player; reply — response code/choice; i0 — integer (i0); i1 — integer (i1); i2 — integer (i2); i3 — integer (i3); i4 — integer (i4).

reply values: reply (L2Server NpcRegisterPVPMatch): in this build there is NO numeric code — the packet carries an echo of the id + the list of registered parties (the 0..10 values observed in scripts are not produced by this handler).

Usage example

EventHandler REGISTER_PVP_MATCH_RESULT( talker, reply, i0, i1, i2, i3, i4, i5, i6, c0, party0, party1, fhtml0, fhtml1 )
{
    if (reply == 0) {
        ShowPage(talker, "kerthang_manager014.htm");
        myself.i_ai0 = i0;
        myself.i_ai1 = i1;
        myself.i_ai2 = i2;
        myself.i_ai3 = i3;
        myself.i_ai4 = i4;
        if (myself.i_ai0 > 0 && myself.i_ai1 > 0 && myself.i_quest0 == 0) {
            myself.i_quest0 = 1;
            myself.i_quest3 = 1;
            party0 = GetPartyFromID(myself.i_ai0);
            party1 = GetPartyFromID(myself.i_ai1);
            AddTimerEx( 1002, ((3 * 60) * 1000) );
            AddTimerEx( 1008, (60 * 1000) );
            if (IsNullParty(party0) == 0) {
                i6 = party0.member_count;
                for (i5 = 0; i5 < i6; i5 = i5 + 1)
                {
    // ... (full body omitted)
}

START_PVP_MATCH_RESULTNPCid 132🟢 high

PvP match start

Fires when a PvP match starts. The engine fills in: reply — response code/choice; i0 — integer (i0); i1 — integer (i1).

reply values: reply (L2Server NpcStartPVPMatch → CPVPMatchSystem::StartMatch): 0 — match started (success); 1 — did not start.

Usage example

EventHandler START_PVP_MATCH_RESULT(reply, i0, i1, i2, i3, i4, i5, i6, i7, party0, party1, c0, maker0, h0)
{
    if (debug_mode)
    {
        Say("* START *");
    }
    myself.i_ai0 = i0;
    myself.i_ai1 = i1;
    party0 = GetPartyFromID(i0);
    party1 = GetPartyFromID(i1);
    if (IsNullParty(party0) == @FALSE)
    {
        if (debug_mode)
        {
            Say("START : party0 is not null. [OK]");
        }
    }
    if (IsNullParty(party1) == @FALSE)
    {
        if (debug_mode)
    // ... (full body omitted)
}

END_PVP_MATCH_RESULTNPCid 133🟢 high

PvP match end

Fires when a PvP match ends. The engine fills in: i0 — integer (i0); i1 — integer (i1); i2 — integer (i2); i3 — integer (i3); i4 — integer (i4); i5 — integer (i5).

reply values: reply (L2Server NpcEndPVPMatch): no numeric code — echo + list of parties (EndMatch is called unconditionally).

Usage example

EventHandler END_PVP_MATCH_RESULT( i0, i1, i2, i3, i4, i5, i6, i7, c0, party0 )
{
    myself.i_ai0 = i0;
    myself.i_ai1 = i1;
    myself.i_ai2 = i2;
    myself.i_ai3 = i3;
    myself.i_ai4 = i4;
    myself.i_quest1 = i5;
    myself.i_quest0 = 5;
    AddTimerEx( 1003, (20 * 1000) );
    AddTimerEx(1004, 5000);
    party0 = GetPartyFromID(myself.i_ai0);
    if (IsNullParty(party0) == 0) {
        i6 = party0.member_count;
        for (i7 = 0; i7 < i6; i7 = i7 + 1)
        {
            c0 = GetMemberOfParty(party0, i7);
            if (IsNullCreature(c0) == 0) {
                Dispel(c0, Skill_GetAbnormalType(@s_entry_for_game1));
            }
    // ... (full body omitted)
}

ON_AIRSHIP_EVENTNPCid 167🟢 high

airship event

Fires when the airship state changes. The engine fills in: state — ship state (see below).

state values — the ship's voyage phase (confirmed by the example below and by the announcement
texts fstring 1800219-1800223):
0 arrived at the destination port (announcement "arrived, departing in 1 min")
1 departing on a voyage (announcement "departing")
2 summoned/brought in (announcement "the Airship has been summoned, take-off in 5 min")
Values 0, 1, 2 occur in the collected scripts; other phases (if any) were not observed.

Usage example

EventHandler ON_AIRSHIP_EVENT(state, i0, i1, i2, i3, i4, c0)
{
    if (state == 0) {
        if (airport_ID == 1) {
            Shout(MakeFString(1800222, "", "", "", "", ""));
        } else {
            if (airport_ID == 3) {
                Shout(MakeFString(1800220, "", "", "", "", ""));
            }
        }
        myself.i_ai0 = 1;
    } else {
        if (state == 1) {
            if (airport_ID == 1) {
                Shout(MakeFString(1800223, "", "", "", "", ""));
            } else {
                if (airport_ID == 3) {
                    Shout(MakeFString(1800221, "", "", "", "", ""));
                }
            }
    // ... (full body omitted)
}

DELETE_OLYMPIAD_TRADE_POINT_RETURNEDNPCid 97🟢 high

returned deletion of Olympiad trade points

Arrives as a response to a request to delete/deduct Olympiad trade points. The engine fills in: talker — the player; ask — menu section/sub-request; reply — response code/choice.

Triggered by: DeleteOlympiadTradePoint (see NASC_FUNCTIONS).

Usage example

EventHandler DELETE_OLYMPIAD_TRADE_POINT_RETURNED( talker, ask, reply, i0, i1, i2, i3 )
{
    i1 = 0;
    if ( reply != 0 && ask > 0 ) {
        i2 = GetDateTime(0,3); i3 = GetDateTime(0,4);

        if ( talker.hero_type == 1 || talker.hero_type == 2 ) { i1 = 100; }
        i0 = ( ( ask + i1 ) * 500 ); // the sum for rating and for hero status must not exceed 100,000.

        AddLogEx( 1, talker, ask, i0 );
        GiveItem1( talker, @olympiad_token, i0 );

        AddScriptLog( 2, ":: Curr Time ["+IntToStr( i2 ) + ":" + IntToStr( i3 )+"] tp="+IntToStr(ask)+" hero="+IntToStr(i1)+" token="+IntToStr(i0) );
    }
}

GET_PLAYING_USER_COUNTNPCid 171🟡 medium

query the number of players online

Arrives as a response to a call of the GetPlayingUserCount() function (a network request to L2Server, opcode 230): the server returns the number of players online. The engine fills in i0 — the count of players online. The event factory exists in build CT2.3; it is absent in the CT26 build.

Related function: GetPlayingUserCount (see NASC_FUNCTIONS).

Usage example

EventHandler GET_PLAYING_USER_COUNT( i0 )
{
    myself.i_ai2 = ((i0 * 80) / 100);
    if (i0 == 1) { myself.i_ai2 = 1; }
}

MG_GET_UNRETURNED_POINT_RETURNEDNPCid 102🟢 high

returned unreturned points (MG)

Arrives as a response with the count of unreturned points of the MG subsystem (minigame / monster gladiator). The engine fills in: talker — the player; reply — response code/choice.

Triggered by: MG_GetUnreturnedPoint (see NASC_FUNCTIONS).

Usage example

EventHandler MG_GET_UNRETURNED_POINT_RETURNED(talker, reply)
{
    if (reply > 0)
    {
        ShowPage(talker, "messenger_yetti019.htm");
        GiveItem1(talker, @hs_agit_war_joining_certificate, reply);
    }
    else
    {
        ShowPage(talker, "messenger_yetti020.htm");
    }
}

OLYMPIAD_MATCH_RESULT_EVENTNPCid 184🟢 high

Olympiad match result

Fires with the result of an Olympiad duel. The engine fills in: talker — the player; reply — the battle outcome (see below); i0 — the match rule type (see below).

reply values — battle outcome: 0 — loss, 1 — win, 2 — draw (enum MatchResultType,
main-server). Win = 1 is agreed across all sources. This script author's comment
gives the reverse order of loss/draw (0 — draw, 2 — loss), but the same author also flipped i0
(provably wrong, see below), so their version of reply should not be trusted — we take main-server.

i0 values — match rule type (enum GameRuleType, L2Server; proven by the table
g_anTeamMembersNumber = {3, 1, 1}): 0 — team (3×3), 1 — non-class 1×1 (default),
2 — class-based 1×1. The order is independently confirmed by the example in ON_OLYMPIAD_GAME_PREPARED
(select(i0): 0->team, 1->classless, 2->class). THIS script author's comment
(0 — class-based, 2 — team) is flipped and wrong.

Usage example

EventHandler OLYMPIAD_MATCH_RESULT_EVENT(talker, ask, reply, i0)    // reply: 0-draw, 1-win, 2-loss.     i0: 0-class-based, 1-non-class, 2-team
{
    /* Change the Olympiad Token award
    For a win: 1000 pcs.
    For a loss: 500 pcs.
    For a draw: 100 pcs.
    */
    select (reply)
    {
        case 0: { GiveItem1( talker, @olympiad_token, 100 ); break; }    // Draw
        case 1: { GiveItem1( talker, @olympiad_token, 1000 ); break; }    // Win
        case 2: { GiveItem1( talker, @olympiad_token, 500 ); break; }    // Loss
    }
    if (HaveMemo(talker, @olympiad_begins) == @TRUE && GetMemoState(talker, @olympiad_begins) == 1)
    {
        if (GetMemoStateEx(talker, @olympiad_begins, 1) == 9)
        {
            SetMemoStateEx(talker, @olympiad_begins, 1, GetMemoStateEx(talker, @olympiad_begins, 1) + 1);
            GiveItem1(talker, @q511_olympiad_mark02, 1);
            SetMemoState(talker, @olympiad_begins, 2);
    // ... (full body omitted)

BLOCK_UPSET_STARTEDNPCid 157🟢 high

block upset started

Fires at the start of the block "upset" phase (block checker / fallen blocks in a minigame). The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Example:

EventHandler BLOCK_UPSET_STARTED( )

BLOCK_UPSET_FINISHEDNPCid 158🟢 high

block upset finished

Fires at the end of the block "upset" phase (block checker). The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Example:

EventHandler BLOCK_UPSET_FINISHED( )

CLEFT_STATE_CHANGEDNPCid 156🟢 high

state change (Cleft)

Fires when the state of the Cleft event changes. The event passes no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler CLEFT_STATE_CHANGED( maker0, i0, i1 )
{
    select ( GetCleftState() ) {
        case 1: {
            maker0 = GetNpcMaker(StarStoneMakerName0);
            if (IsNull(maker0) == 0) {
                SendMakerScriptEvent(maker0, 1325001, 0, 0);
            }
            maker0 = GetNpcMaker(StarStoneMakerName1);
            if (IsNull(maker0) == 0) {
                SendMakerScriptEvent(maker0, 1325001, 0, 0);
            }
            maker0 = GetNpcMaker(StarStoneMakerName2);
            if (IsNull(maker0) == 0) {
                SendMakerScriptEvent(maker0, 1325001, 0, 0);
            }
            maker0 = GetNpcMaker(StarStoneMakerName3);
            if (IsNull(maker0) == 0) {
                SendMakerScriptEvent(maker0, 1325001, 0, 0);
            }
    // ... (full body omitted)

CREATE_SANTA_TO_WINNERNPCid 169🟢 high

give Santa to the winner

Fires to create/give the New Year NPC "Santa" to the winner of an event. The engine fills in: target — the target.

Usage example

EventHandler CREATE_SANTA_TO_WINNER( target, i0 )
{
    if (IsNullCreature(target) == 0) {
        i0 = target.instant_zone_id;
        if (target.instant_zone_id == 0) {
            CreateOnePrivateEx( @xmas_santa, "ai_event_xmas_giver_santa", 0, 0, FloatToInt( (target.x - 50 + Rand( 100 )) ), FloatToInt( (target.y - 50 + Rand( 100 )) ), FloatToInt( (target.z + 10) ), (GetDirectionToTarget( target ) * 182), GetIndexFromCreature( target ), 0, 0 );
        }
    }
}

REGISTER_RESURRECTION_TOWER_RESULTNPCid 136🟢 high

resurrection tower registration result

Arrives as the result of registering a resurrection tower. The engine fills in: i0 — integer (i0); reply — response code/choice.

reply values: reply (L2Server NpcRegisterResurrectionTower): 0 — registration failed (no PVP match by NPC); nonzero (1…) — the match-object result (success/detailed code).

Triggered by: RegisterResurrectionTower (see NASC_FUNCTIONS).

Example:

EventHandler REGISTER_RESURRECTION_TOWER_RESULT( )

UNREGISTER_PVP_MATCH_RESULTNPCid 131🟢 high

cancel PvP-match registration

Fires when a request to participate in a PvP match is withdrawn. The engine fills in: talker — the player; i0 — integer (i0); i1 — integer (i1); i2 — integer (i2); i3 — integer (i3); i4 — integer (i4); i5 — integer (i5).

reply values: reply (L2Server NpcUnregisterPVPMatch): there is no numeric code — it echoes the id + a list of parties.

Triggered by: UnregisterPVPMatch (see NASC_FUNCTIONS).

Usage example

EventHandler UNREGISTER_PVP_MATCH_RESULT( talker, i0, i1, i2, i3, i4, i5, i6, i7, c0, party0, party1 )
{
    myself.i_ai0 = i0;
    myself.i_ai1 = i1;
    myself.i_ai2 = i2;
    myself.i_ai3 = i3;
    myself.i_ai4 = i4;
    myself.i_quest1 = i5;
    party0 = GetPartyFromID(myself.i_ai0);
    party1 = GetPartyFromID(myself.i_ai1);
    if (myself.i_quest2 == 1) {
        if (IsNullParty(party0) == 0) {
            i6 = party0.member_count;
            for (i7 = 0; i7 < i6; i7 = i7 + 1)
            {
                c0 = GetMemberOfParty(party0, i7);
                if (IsNullCreature(c0) == 0) {
                    ShowOnScreenMsgStr(c0, 2, 0, 0, 0, 1, 0, 10000, 0, MakeFString(1800106, "", "", "", "", ""));
                }
            }
    // ... (full body omitted)
}

ON_OLYMPIAD_FIELD_CHANGEDNPCid 173🟢 high

Olympiad arena state change

Fires when the Olympiad arena's phase changes. The engine fills in:
attacker, c0, c1 the winners (up to three)
victim, c2, c3 the losers (up to three)
event_id the arena number
action_id the match rule type (see below)
state the new arena phase (see below)

action_id values — match rule type (enum GameRuleType, L2Server; proven by the table
g_anTeamMembersNumber = {3, 1, 1}: type 0 has 3 fighters per team, types 1 and 2 have one each):
0 gamerule_team team battle (3×3)
1 gamerule_nonclassbased ordinary 1×1 battle, no class restriction (default)
2 gamerule_classbased class-based 1×1 battle
(3 = gamerule_max — a service array bound, not a match value.)
On the discrepancy of this order with the comment in one of the scripts — see OLYMPIAD_MATCH_RESULT_EVENT.

state values — the arena phase. This is a finite state machine of seven states
(L2Server, dispatcher COlympiadField::TimerExpired):
0 Idle the arena is free; cleanup, penalty tally
1 Prepare preparation, resetting counters
2 Wait waiting for and gathering fighters
3 Start battle start
4 Process battle in progress
5 Finish battle finished, tally
6 Clear arena cleanup

In the NPC (NpcServer::Send, opcode 109 from COlympiadField::ChangeStatus) only the
Wait and Process transitions are sent; along the way, SharedOlympiadInfo writes, by arena number, the game
flag (1 = Wait, 2 = Process, 0 = Finish) together with the team leaders and rule type,
from which the NPC side reconstructs the attacker/victim/c0..c3 roster. The exact literal
arriving in state (the full enum 0..6 or the flag 0/1/2) is determined by the opcode-109 factory
on the L2NPC side; here L2Server is loaded in IDA. Most likely state = 0 (battle
finished) / 1 (waiting) / 2 (battle in progress).

Usage example

EventHandler ON_OLYMPIAD_FIELD_CHANGED(attacker, victim, state, action_id, i2, c0, c1, c2, c3)
{
    if (is_quest != 1) {
        return;
    }
    if (debug == 1) {
        if (IsNullCreature(attacker) == 0) {
            Say("attacker");
        } else {
            Say("attacker");
        }
        if (IsNullCreature(victim) == 0) {
            Say("victim");
        } else {
            Say("victim");
        }
        if (IsNullCreature(c0) == 0) {
            Say("c0");
        } else {
            Say("c0");
    // ... (full body omitted)
}

INACTIVE_CHARACTER_RETURNEDNPCid 181🟢 high

returned inactive character

Arrives as a response with the data of an inactive (away/AFK) character. The engine fills in: target — the found inactive character; i0 — seconds of inactivity.

Usage example

EventHandler INACTIVE_CHARACTER_RETURNED( i0, target )
{
    if ( TeamEventGetStatus( my_Event ) == @TEAMEVENT_STATUS_BATTLE ) {
        if ( i0 > ( checkInnactiveCharPeriod*60 ) ) {
            if ( logEnable > 0 ) { AddScriptLog( 2, ":: Detect AFK : "+target.name+" ( "+IntToStr( i0 )+" )" ); }
            TeamRemoveMember( target );
            target.param3 = 123;
        }
    }
}

Lifecycle & DB

15 events

MY_DYINGNPCid 9🟢 high

the NPC dies: last processing before death

Fires at the moment of the NPC's death, right before its removal. The engine fills in: last_attacker — the killer (for a summon — its owner); lparty — the killer's party; lmpcc — the killer's alliance. The drop lists always_list/random1_list/code_info are created by the script itself (AllocCodeInfoList).

Usage example

EventHandler MY_DYING( target, i0, i2, i3, i4, i5, i6, i9, i10, i11, last_attacker, lparty, random1_list, always_list, code_info, lmpcc, aparty )
{
    always_list = AllocCodeInfoList();
    random1_list = AllocCodeInfoList();
    target = last_attacker;
    if (IsNull(lparty) == 0) {
        for ( i9 = 0; i9 < lparty.member_count; ++i9 ) {
            target = GetMemberOfParty(lparty, i9);
            if (HaveMemo( target, @put_the_power_in_your_blade ) == 1) {
                always_list.SetInfo(0, target);
            }
        }
    } else {
        if (HaveMemo( target, @put_the_power_in_your_blade ) == 1) {
            always_list.SetInfo(0, target);
        }
    }

    target = last_attacker;
    if ( IsNull( lmpcc ) == 0 ) {
    // ... (full body omitted)
}

CREATEDNPCid 12🟢 high

the NPC has spawned and is initializing

Fires when the NPC is created/initialized on the server. The engine fills in: reply — flag: data was loaded from the DB.

Values of reply (from real scripts): reply = nIsDbLoaded: 0 — data NOT from the DB (first spawn), 1 — loaded from the DB.

Initiated by: NPC spawn (Spawn/CreateOnePrivate*) (see NASC_FUNCTIONS).

Usage example

EventHandler CREATED( reply )
{
    if ( reply == 0 ) {
        myself.i_ai0 = 0;
        SetDBValue( myself.sm, 0 );
    } else {
        myself.i_ai0 = myself.sm.db_value;
    }

    AddTimerEx( 2002, ( 60 * 1000 ) );
}

ON_NPC_DELETEDMAKERid 1🟢 high

the maker (spawner) learned of an NPC's deletion

Fires in the maker (spawner) when an NPC belonging to one of its defines is deleted. The engine fills in: deleted_def — deleted_def; deleted_npc — deleted_npc; reply — response code/choice; died — died.

Initiated by: Despawn/removal of an instance (see NASC_FUNCTIONS).

Usage example

EventHandler ON_NPC_DELETED(deleted_def, died, i0, i1, maker0, reply, c0)
{
    if (died == 0) {
        myself.i_ai0 = 0;
    } else {
        myself.i_ai0 = 1;
    }
    if (myself.i_ai0 == 1 && reply == 0) {
        maker0 = GetNpcMaker(myself.name);
        SendMakerScriptEvent(maker0, 1001, 0, 0);
    }
}

ON_STARTMAKERid 0🟢 high

maker (spawner) start

Fires when the maker (spawner) starts. The event carries no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_START( i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, def0 )
{
    myself.i_ai0 = 0;
    super;
}

ON_ALL_NPC_DELETEDMAKERid 2🟢 high

all of the maker's NPCs were deleted

Judging by the name, fires in the maker (spawner) when all NPCs it spawned have been deleted. The event carries no fields of its own — the engine fills in only myself (the NPC itself).

Usage example

EventHandler ON_ALL_NPC_DELETED(maker0, myself, _choiceN, _code, _from_choice)
{
    maker0 = GetNpcMaker(maker_name);
    if (IsNull(maker0) == 0) {
        SendMakerScriptEvent(maker0, 1001, 0, 0);
    }
}

ON_NPC_CREATEDMAKERid 6🟢 high

the maker (spawner) spawned an NPC

Fires in the maker (spawner) when a new NPC is spawned. The engine fills in: created_def — created_def; created_npc — created_npc.

Initiated by: Spawn2/SpawnEx (see NASC_FUNCTIONS).

Usage example

EventHandler ON_NPC_CREATED(created_npc, created_def)
{
    if (myself.enabled == 0 || (myself.i_ai4 == 0 && created_def != GetSpawnDefine(1)))
    {
        created_npc.Despawn();
    }
}

ON_DB_NPC_INFOMAKERid 4🟢 high

NPC data arrived from the DB

Judging by the name and arguments, delivers NPC information loaded from the database. The engine fills in: loaded_def — loaded_def; record0 — record0.

Usage example

EventHandler ON_DB_NPC_INFO(loaded_def, record0, i0)
{
    if (record0.is_alive) {
        if (AtomicIncreaseTotal(loaded_def, 1, 1)) {
            loaded_def.SetDBLoaded(1);
            loaded_def.SpawnEx(1, 0, record0.x, record0.y, record0.z, 0, record0.hp, record0.mp, record0.db_value);
        }
    }
}

ON_DBCOOKIE_LOADEDNPCid 178🟢 high

the NPC's saved data was loaded from the DB

Fires when the previously database-saved data (db-cookie) of this NPC has been fetched. The engine fills in: talker — the player; script_event_arg1 — group id; script_event_arg2 — group size.

Usage example

EventHandler ON_DBCOOKIE_LOADED( talker, script_event_arg1, script_event_arg2, i0, i1, i2, i3, i4 )
{
    if ( script_event_arg1 == CookieGroup ) {
        if ( script_event_arg2 < 3 ) { // build the quest list
            i0 = @march2023_event1; i1 = @march2023_event2;
            i2 = @march2023_event3; i3 = @march2023_event4;

            if ( Rand(100) < 50 ) { i4 = i0; i0 = i2; i2 = i4; }
            if ( Rand(100) < 50 ) { i4 = i1; i1 = i3; i3 = i4; }
            if ( Rand(100) < 50 ) { i4 = i0; i0 = i1; i1 = i4; }
            if ( Rand(100) < 50 ) { i4 = i1; i1 = i2; i2 = i4; }
            if ( Rand(100) < 50 ) { i4 = i2; i2 = i3; i3 = i4; }
            if ( Rand(100) < 50 ) { i4 = i3; i3 = i4; i4 = i4; }

            // save the quest list
            SetDbCookieInt( talker, CookieGroup, 1, i0 );
            SetDbCookieInt( talker, CookieGroup, 2, i1 );
            SetDbCookieInt( talker, CookieGroup, 3, i2 );

            i4 = i0; // current quest
    // ... (full body omitted)
}

DIE_SETNPCid 162🟢 high

death state set

Fires when the death state is set/committed on the associated object. The engine fills in: talker — the player; attacker — the attacker.

Usage example

EventHandler DIE_SET(myself, talker)
{
    if (talker.alive == @FALSE && talker.is_pc == @TRUE && IsNullCreature(myself.c_ai0) == @FALSE)
    {
        RemoveAllAttackDesire();
        RemoveAllDesire();
        AddTimerEx(p_iTimerDesire, 1 * 1000);
    }
}

GETDBDATA_RETURNEDNPCid 179🟢 high

data returned from the DB

Fires when the response to a database data request (GetDbData) arrives. The engine fills in: i0 — the number of returned rows.

Where the data lands (source — npc-server: CNPCEventFactory.cpp, CNPC.cpp,
CachedNpcPacketHandlers.cpp): the event itself carries ONLY i0 = the row count. The rows
themselves are placed by the engine into fields of the NPC itself:
myself.db_int_list — record id (needed for DelDbDataById)
myself.db_str_list1..10 — the 10 columns of a row
Each list holds one column across all rows: row r = myself.db_str_listN.Get(r),
r = 0..i0-1; myself.db_int_list.Get(r) is the id of the r-th record. The remaining fields of the
handler declaration (i1..i9, s0, s1) are free local slots of the body; the engine does NOT fill
them (in the example the script itself puts data from db_str_list* there). The lists are NOT
cleared before filling — on repeated GetDbData calls clear them yourself.

Initiated by: GetDbData (a request with 10 filter strings; the response arrives row by row into the db_* lists) (see NASC_FUNCTIONS).

Usage example

EventHandler GETDBDATA_RETURNED( i0, i1, i2, i3, i4, i5, i8, i9, s0, s1, fhtml0, talker, c1 )
{
    talker = GetCreatureFromIndex( myself.av_quest0.GetValue() );
    if ( i0 > 0 && IsNullCreature( talker ) == @FALSE ) {
        i9 = myself.av_quest1.GetValue();

        if ( i9 == 0 ) { // collect the reward
            s0 = myself.db_str_list2.Get( 0 ); // type
            i1 = StrToInt( myself.db_str_list3.Get( 0 ) ); // dbid
            i2 = StrToInt( myself.db_str_list9.Get( 0 ) ); // is_winner
            i3 = StrToInt( myself.db_str_list10.Get( 0 ) ); // is_NOT_rewarded

            if ( talker.dbid == i1 && i2 == 1 && i3 > 0 )  { // char_id matched, is the winner, reward not yet given
                talker.param1 = GetDateTime( 0, 6 ); // player already came today. another way to block a redundant request
                // delete the record
                DelDbDataById( myself.db_int_list.Get( 0 ) );
                // write to the DB that the reward was taken
                SetDbData( tiat_top_dbname, myself.db_str_list2.Get( 0 ), IntToStr(talker.dbid), talker.name, myself.db_str_list5.Get( 0 ), myself.db_str_list6.Get( 0 ), myself.db_str_list7.Get( 0 ), myself.db_str_list8.Get( 0 ), "1", "-1" );
                AddScriptLog( 2, ":: ("+tiat_top_dbname+") Get Reward: "+talker.name );

    // ... (full body omitted)

LOAD_DBSAVING_MAP_RETURNEDNPCid 160🟢 high

response to loading a saved data map

Fires when the response to loading a data set saved in the DB (a "key→value" map) arrives. The engine fills in: i0 — record key; i1 — record value.

Values: the map stores key→value pairs; each loaded record arrives as a separate
event, where i0 is the key and i1 is the saved value.

Initiated by: LoadDBSavingMap (see NASC_FUNCTIONS).

Usage example

EventHandler LOAD_DBSAVING_MAP_RETURNED( i0, i1 )
{
    if (i0 == GM_ID1) {
        myself.i_ai0 = i1;
    }
}

USER_CONNECTEDNPCid 54🟢 high

player connected

Fires when a player connects (logs in). The engine fills in: talker — the player.

Usage example

EventHandler USER_CONNECTED( talker, i0, i1, i2, i3, i4, i5, i6, i7, i9 )
{
    if ( talker.level < 6 ) {
        if ( myself.GetOneTimeQuestFlag( talker, @tutorial_quest ) != 0 ) {
            return;
        }
        i0 = GetMemoState( talker, @tutorial_quest );
        if ( i0 == -1 ) {
            i0 = 0;
            i1 = 0;
        } else {
            i1 = ( i0 & 255 );
            i0 = ( i0 & 2147483392 );
        }
        select ( i1 ) {
            case 0 : {
                myself.AddTimerEx( ( GetIndexFromCreature( talker ) + 1000000 ), ( 1000 * 10 ) );
                i0 = ( 2147483392 & ( 8388608 | 1048576 ) );
                myself.SetMemoState( talker, @tutorial_quest, ( 1 | i0 ) );
                myself.SetMemoStateEx( talker, @tutorial_quest, 1, -2 );
    // ... (full body omitted)
}

WAS_COLLECTEDNPCid 166🟢 high

object collected

Fires when the object has been collected (e.g., a harvestable resource/plant). The engine fills in: attacker — the collector; i0 — integer (i0).

Usage example

EventHandler WAS_COLLECTED( attacker, i1 )
{
    if ( seed_item > 0 ) {
        GiveItem1( attacker, seed_item, Rand(10) + 1 );
    }
}

LEVEL_UPNPCid 159🟢 high

level up

Fires when a player in the NPC's zone has gained a level. The engine fills in: talker — the player; reply — the level reached.

Usage example

EventHandler LEVEL_UP( i0, i1, reply, talker )
{
    if (reply >= 6 && GetMemoState(talker, @tutorial_quest) <= 5)
    {
        SetMemoState(talker, @tutorial_quest, 6);
    }
    if (reply == 18)    // Mutated Kaneus - Gludio
    {
        if (HaveMemo(talker, @mutation_kanooth_gludio) == @FALSE && GetOneTimeQuestFlag(talker, @mutation_kanooth_gludio) == @FALSE)
        {
            ShowTutorialHTML(talker, "kanooth_gludio.htm");
            ShowOnScreenMsgFStr(talker, 2, 0, 0, 0, 1, 0, 5000, 0, 3603400, _blank, _blank, _blank, _blank, _blank);
            ShowQuestionMark(talker, 10276);
            ShowRadar(talker, -13900, 123822, -3112, @RPT_BOTH);
            SoundEffect(talker, "ItemSound.quest_tutorial");
        }
    }
    else if (reply == 28)    // Mutated Kaneus - Dion
    {
        if (HaveMemo(talker, @mutation_kanooth_dion) == @FALSE && GetOneTimeQuestFlag(talker, @mutation_kanooth_dion) == @FALSE)
    // ... (full body omitted)
}

SCENE_STOPPEDid none🟡 medium

cutscene stopped

Fires when a played scene/cutscene, started by functions of the PlayScene/StartScenePlayer family, has finished (been stopped). scene_id — the scene identifier; creature — the associated creature (whom it was played for); maker0 — the spawner; c0, c1, party0 — associated creatures/party. There is no separate factory in the disassembled builds — the fields are per real usage.

Related function: PlayScene / StartScenePlayer* (see NASC_FUNCTIONS).

Usage example

EventHandler SCENE_STOPPED(scene_id, i0, maker0, creature, i1, c0, c1, party0)
{
    //
}

Other

3 events

DEBUG_AIid not🟢 high

AI debug handler

Service/debug handler (marked as commented out in the sources). The engine fills in: reply — response code/choice; creature — the creature seen.

Usage example

EventHandler DEBUG_AI(creature, reply, s0)
{
    if (reply == 1)
    {
        Whisper(creature, "status " + myself.i_ai0);
    }
}

CHECK_REGISTER_USER_RESULTNPCid 137🟢 high

player registration check result

Fires as a response to a check of whether the player is registered (in some registration subsystem). The engine fills in: i0 — integer (i0); reply — response code/choice.

reply values: reply (L2Server NpcCheckRegisterUser): 10 — player is not online; 11 — no PVP match for the player's level; 0/1/3/12..16 — domain codes of the match object (already registered, match closed, wrong status, etc.).

Initiated by: CheckRegisterUserPVPMatch (see NASC_FUNCTIONS).

Usage example

EventHandler CHECK_REGISTER_USER_RESULT( reply, i0, c0 )
{
    c0 = GetCreatureFromID(i0);
    if (myself.i_ai0 == 1) {
    } else {
        if (GetInventoryInfo( c0, @IPT_CURRENT_SLOT_COUNT ) >= GetInventoryInfo( c0, @IPT_MAX_SLOT_COUNT ) * 0.900000 || GetInventoryInfo( c0, @IPT_CURRENT_WEIGHT ) >= GetInventoryInfo( c0, @IPT_MAX_CARRY_WEIGHT ) * 0.900000) {
            ShowPage(c0, "cratae_teleport_npc006.htm");
        } else

        if (reply == 13) {
            ShowPage(c0, "cratae_teleport_npc007.htm");
        } else
        if (reply == 1) {
        } else
        if (reply == 3) {
            ShowPage(c0, "cratae_teleport_npc008.htm");
        } else
        if (reply == 10) {
        } else
        if (reply == 11) {
    // ... (full body omitted)
}

CHECK_REGISTER_PARTY_RESULT2NPCid 135🟢 high

check party registration (variant 2)

Fires when checking the possibility/result of registering a party (the second variant of the check). The engine fills in: i0 — integer (i0); i1 — integer (i1); i2 — integer (i2); i3 — integer (i3).

reply values: reply (L2Server NpcCheckRegisterParty) is not a single code but a LIST of pairs (member id, code) for all party members; code 1 = no match, otherwise = the per-member result.

Usage example

EventHandler CHECK_REGISTER_PARTY_RESULT2( i0, i1, i2, i3, i5, i6, c0, c1, c2, party0, party1 )
{
    party0 = GetPartyFromID(myself.i_ai0);
    party1 = GetPartyFromID(myself.i_ai1);
    if (i1 == 7) {
        party0 = GetPartyFromID(i0);
        if (IsNullParty(party0) == 0) {
            c0 = GetLeaderOfParty(party0);
            i6 = party0.member_count;
            for (i5 = 0; i5 < i6; i5 = i5 + 1)
            {
                c1 = GetMemberOfParty(party0, i5);
                if (IsNullCreature(c1) == 0) {
                    ShowOnScreenMsgStr(c1, 2, 0, 0, 0, 1, 0, 10000, 0, MakeFString(1800081, "", "", "", "", ""));
                }
            }
            if (IsNullCreature(c1) == 0) {
                UnregisterPVPMatch(party0, c0);
            }
        }
    // ... (full body omitted)
}

UI, trade, atomics

3 types

CAtomicValuetype🟢 high

atomic value (counter/flag)
In scripts
NPC fieldsmyself.av_ai0..1 myself.av_quest0..1
room fieldroom0.status

A single integer read and modified atomically — safe when the same cell may be touched
by different threads/individuals (a counter of occupied slots, a state flag). Occurs as
fields of the NPC itself (myself.av_ai0/av_ai1, myself.av_quest0/av_quest1) and as the
status field of a room (room0.status).

Properties:
.valuecurrent value (read)
Methods:
Exchange(int v)atomically write v; return the previous value

CFHTMLtype🟢 high

dialog window buffer
In scripts
event slotsfhtml0 fhtml1

The buffer of the NPC's dialog HTML window; in examples — fhtml0. It is filled with
FHTML_SetFileName / FHTML_SetStr / FHTML_SetInt / FHTML_SetFStr, then shown to the player
with ShowFHTML (see the FHTML group in NASC_FUNCTIONS).

Working with the buffer (functions):
FHTML_SetFileName(fhtml, name)set the window's html file
FHTML_SetStr(fhtml, key, s)substitute a string by key
FHTML_SetInt(fhtml, key, n)substitute a number by key
ShowFHTML(talker, fhtml)show the window to the player
Example:
FHTML_SetFileName( fhtml0, fnFeudInfo );
ShowFHTML( talker, fhtml0 );

CBuySellListtype🟢 high

goods list of the trade window
In scripts
class parameterBuyList0 SellList0

A goods list for the trade window. Defined as a class parameter (e.g. BuyList0,
SellList0) and contains the shop's entries. Used by the Buy / Sell / ShowBuySell
functions.

Example:

ShowBuySell( talker, SellList0, BuyList0, -50 ); // -50 — markup/discount, %

NPC, spawners, global object

5 types

CNPCtype🟢 high

the NPC itself (myself)
In scripts
myself
event slotsnpc0..npc2
maker slotscreated_npc deleted_npc

The class of the NPC itself. It is the receiver of all functions marked "Class: NPC"
(in code they are called by bare name, without myself.) and the owner of the persistent
state fields that survive individual events. The full table of myself.* fields with
explanations is in NASC_LANGUAGE (section 6.2); in brief:

Properties:
.i_ai0..9 / .i_quest0..9integer state cells for AI / quests
.c_ai0..4 / .c_quest0..4remembered creatures (target, ally)
.av_ai0..1 / .av_quest0..1atomic counters (CAtomicValue)
.int_list / .str_listlists of integers / strings
.db_int_list / .db_str_list1..10the same lists, but persisted to the DB
.sm"self as creature" (CSharedCreatureData)
.master / .bossowner / boss
.top_desire_targetcurrent target of the top desire
.p_statethe NPC's current physical action (read-only; values are @ACT_* — full breakdown in NASC_ENUMS, section ACT)
.start_x .start_y .start_zspawn point
Methods: hundreds of NPC functions from the NASC_FUNCTIONS reference (class NPC) —
desires (AddAttackDesire...), timers (AddTimerEx), items (GiveItem1), etc.
Example:
if ((myself.p_state == @ACT_STAND || myself.p_state == @ACT_SIT || myself.p_state == @ACT_OPENCLOSE) && (myself.sm.hp > (myself.sm.max_hp * 0.400000) && myself.sm.alive != @FALSE)) {
The NPC is free (standing, sitting, or busy with a door), healthy and alive — it can
play a social gesture or chat.

CNpcMakerExtype🟢 high

NPC spawner (maker)
In scripts
event slotsmaker0 maker1
myself (in a maker script)

The NPC spawner. In a maker context it is myself; a regular NPC obtains it via
GetNpcMaker / InstantZone_GetNpcMaker / GetMyMaker.

Properties:
.def_countnumber of spawn defines
.maximum_npcpopulation limit
.npc_countcurrently alive
Methods:
GetSpawnDefine(int i)i-th spawn define (CNpcSpawnDefineEx)
GetSpawnDefineByNick(string) spawn define by nick
AtomicIncreaseTotal(def, n, step)atomically change the define's planned population
DoRespawn()perform a respawn
ResetRespawn()reset the respawn
RegisterRespawn(time, n, def) schedule a respawn
AddTimerEx(int id, int ms)maker timer (caught in TIMER_FIRED_EX)
Example:
def0 = GetSpawnDefineByNick( manager_npc_name );

CNpcSpawnDefineExtype🟢 high

spawn define (a row of the spawn table)
In scripts
maker slotsdef0 deleted_def loaded_def created_def

One row of the maker's spawn table. In examples — def0, deleted_def, loaded_def.

Properties:
.totalplanned number of individuals
.npc_countcurrently alive
.respawn_timerespawn time
.respawn_randrespawn time variance
.namethe define's nick
Methods:
Spawn2(count, respawnTime, respawnRand)spawn count individuals
SpawnEx(count, mode, x, y, z, heading, hp, mp, dbValue)spawn with full control
Spawn(count, respawnTime)simplified spawn
Despawn()remove the define's individuals
SendScriptEvent(int id, a2, a3)send a script event to its NPCs
RegToRespawnTimer(t)put on the respawn timer
LoadDBNpcInfo(n)load NPC data from the DB
SetDBLoaded(n)mark as loaded from the DB
Example:
def0.Spawn2( def0.total, 0, 0 );// spawn the planned number, no respawn
deleted_def.Spawn2( 1, deleted_def.respawn_time, deleted_def.respawn_rand );

CSpawnDefinetype🟡 medium (rarely used in the collected scripts)

individual state record for the DB (DBNpcInfo)
In scripts
maker slotrecord0

A snapshot of one specific individual's state for DB respawn (DBNpcInfo). In a maker
script — the record0 slot. A separate type from CNpcSpawnDefineEx: the latter describes
a row of the spawn table, while CSpawnDefine is the saved state of one individual
(whether alive, where, with what HP/MP).

Properties:
.hp .mpthe individual's health and mana
.x .y .zcoordinates
.is_aliveis the individual alive
.death_timetime of death
.db_valueuser value persisted to the DB

CGlobalObjecttype🟢 high

global namespace object (gg)
In scripts
event slotgg

The server's global namespace object; available in scripts as gg (field CNPCEvent::gg).
It hosts the "global" functions not bound to a specific NPC: time and randomness, spawn
and creature lookup by index, AllocCodeInfoList(), MPCC_GetPartyID,
GetPartyFromID, broadcast and DB functions. In most scripts it is called implicitly,
without the gg. prefix — the engine substitutes the gg receiver itself.

Creatures, parties, data

8 types

CSharedCreatureDatatype🟢 high

creature (base descriptor)
In scripts
event slotstalker attacker victim target creature speller friend commander private member last_attacker c0..c4
NPC fieldsmyself.sm myself.c_ai0..4 myself.c_quest0..4 myself.master myself.boss myself.top_desire_target

The base creature descriptor. Arrives in almost all handlers (attacker, talker,
creature, speller) and is available on the NPC itself as myself.sm. Always check
IsNullCreature(c) before reading its fields.

Properties (commonly read):
.hp .max_hp .mpcurrent/max health, mana
.levellevel
.namename
.pledge_idclan id
.is_pcis this a player (rather than an NPC)?
.masterowner (for summons)
.sm"self as creature" on an NPC (myself.sm)
.dbidcharacter id in the DB
.summoner_idsummoner's id
.occupation .class_idoccupation / class
.npc_class_idNPC class
.racecreature race (race id; combat scripts compare it with a class parameter, e.g. SetHateRace == attacker.race)
.residence_idid of the residence (castle/domain) the NPC is assigned to: 0 — not assigned; used to build the domain name (idiom MakeFString(1001000 + residence_id, ...))
.aliveis it alive
.idpermanent id
.x .y .zcoordinates
.instant_zone_idinstance zone id
.p_statecurrent physical action; a creature has it too, but scripts almost always read myself.p_state. Values are @ACT_* (0 idle, 1 standing, 2 sitting, 3 walking, 4 attacking, 5 casting, …16) — full breakdown in NASC_ENUMS, section ACT
.param1 .param2 .param33 user data slots of the creature. For a private NPC they are filled with the last 3 arguments of CreateOnePrivateEx; an NPC reads its own as myself.sm.param1..3. Anything can be stored: owner index, dbid, a tag, coordinates
Example:
if ( myself.sm.level < 2 ) { return; }// read a field of the NPC itself

CSharedCreatureDataExtype🟠 low (field set unconfirmed)

extended creature data
In scripts
no slots — only from GetCreatureEx / GetCreatureExFromIndex

The extended creature descriptor. Returned by GetCreatureEx(c) and
GetCreatureExFromIndex(nIndex). There are no calls in the collected ai*.nasc, so its
field set is unconfirmed — see NASC_DOUBTS.

CSharedItemDatatype🟢 high

inventory item
In scripts
event slotsitem item0 item1

An inventory item descriptor. Returned by GetItemData; passed into AddGetItemDesire,
IsStackableItem and the like. In the collected scripts its properties and methods are
almost never read directly — the item is usually used as an opaque descriptor.

CHateInfotype🟢 high

hate list record
In scripts
event slotsh0..h4

One record of the NPC's hate (aggro) list. Returned by GetMaxHateInfo,
GetNthHateInfo, GetHateInfoByCreature/...ByIndex. In examples — usually h0 (a handler
holds up to five: h0..h4). Check IsNullHateInfo(h) before reading.

Properties:
.creaturethe target creature of this record (CSharedCreatureData)
.hateamount of hate (int) — GetMaxHateInfo(0) uses it to find the target with maximum aggression
.temp0temporary value (int) — the metric for GetMaxHateInfo(1)
Check:
IsNullHateInfo(h)is the record empty/invalid?
Example:
h0 = GetMaxHateInfo( 0 );// target with the highest hate
if ( IsNullHateInfo( h0 ) == 0 ) {
if ( IsNullCreature( h0.creature ) == 0 ) {MakeAttackEvent( h0.creature, 100, 0 );
}
}

CSharedPartyDatatype🟢 high

party
In scripts
event slotsparty0 party1 aparty lparty

A party. Returned by GetParty, GetTopDamageParty; in examples — party0,
lparty. The roster is read with Party_GetCount / Party_GetCreature or
GetMemberOfParty / GetLeaderOfParty. Check with IsNullParty(p).

Working with a party (functions, not object methods):
Party_GetCount(c)number of members in creature c's party
Party_GetCreature(p, i)i-th party member (CSharedCreatureData)
GetLeaderOfParty(p)party leader
IsNullParty(p)is the party empty/invalid?
Example:
i1 = Party_GetCount( talker );// how many people are in talker's party

CSharedPledgeDatatype🟢 high

clan (pledge)
In scripts
event slotspledge0 pledge1

A clan. Returned by GetPledge. Clan details are obtained with
GetPledgeMemberCount, GetPledgeMoney, HavePledgePower and others (see the Party / Pledge
group in NASC_FUNCTIONS).

MPCCDatatype🟢 high

command channel
In scripts
event slotlmpcc (command channel of the killer in MY_DYING)

A command channel — an association of several parties into a raid. Returned by GetMPCC(c)
and GetTopDamageMpcc(c). In the dat signatures the type is named CSharedGeneralObjectData.
It is also the type of the event field CNPCEvent::lmpcc (the killer's command alliance
in MY_DYING).

Properties:
.mpcc_idchannel id
.party_countnumber of parties in the channel
Methods / traversal functions:
GetParty(int i)i-th party of the channel (MPCCData object method)
MPCC_GetPartyID(mpcc_id, i)id of the channel's i-th party (gg function)
GetPartyFromID(id)get a party (CSharedPartyData) by its id
Example:
i0 = lmpcc.mpcc_id;// command channel id (e.g. of the killer in MY_DYING)
i2 = MPCC_GetPartyID( i0, i1 );// id of the i1-th party of this channel
party0 = GetPartyFromID( i2 );// get the party itself by id

CSharedStaticObjectDatatype🟢 high

immovable world object
In scripts
event slotsvictim_so so0

An immovable world object — a door, a control tower, a siege object. It is the type of
the event fields victim_so / so0: it is what gets hit or spelled in the
STATIC_OBJECT_CLAN_ATTACKED and STATIC_OBJECT_CLAN_SPELLED events. Returned by door and
tower functions; check IsNull(o) before accessing.

Lists

7 types

CIntListtype🟢 high

list of integers
In scripts
NPC fieldsmyself.int_list myself.db_int_list

A list of integers. Most often it is a persistent field of the NPC itself:
myself.int_list (regular) and myself.db_int_list (persisted to the DB across restarts).
It also arrives in events as the aggregate field int_list / db_int_list. It has no
fields of its own — access is via methods only.

Methods:
GetSize()number of elements (int)
Add(int v)append a value to the end
Get(int i)value at index i (int)
RemoveAt(int i)remove the element at an index
Clear()clear the list
SetMaxSize(int n)set the capacity
GetItemIndex(int v)index of the first occurrence of v (-1 if absent)
GetItemIndexNext(int v)index of the next occurrence of v (iterating duplicates)
Example:
myself.int_list.Add( 1115649 );// accumulate ids directly in the NPC's list field
myself.int_list.Add( 1115651 );
myself.int_list.Add( 1113858 );

CStrListtype🟢 high

list of strings
In scripts
NPC fieldsmyself.str_list myself.db_str_list1..10

A list of strings. The methods mirror CIntList but operate on strings. Like CIntList,
it is most often a persistent NPC field: myself.str_list (regular) and
myself.db_str_list1 (persisted to the DB). Convenient as a set: accumulate values and
check membership (e.g., a list of HWIDs of players who already entered).

Methods:
GetSize()number of elements (int)
Add(string s)append a string to the end
Get(int i)string at index i (string)
GetItemIndex(string s)index of the first occurrence of s (-1 if absent)
GetItemIndexNext(string s)index of the next occurrence of s
Remove(string s)remove by value
RemoveAt(int i)remove by index
Clear()clear the list
SetMaxSize(int n)set the capacity
Example:
myself.str_list.SetMaxSize( 200 );
...
for ( i0 = 0; i0 < myself.str_list.GetSize(); ++i0 ) {
if ( IsSameString( myself.str_list.Get( i0 ), GetHwid( talker ) ) ) {ShowPage( talker, "atb_event_hw_portal_03.htm" ); // HWID already in the list return;
}
}
myself.str_list.Add( GetHwid( talker ) );// new — add it

CItemIndexListtype🟢 high

list of seen items
In scripts
event slotitem_index_list

A list of items the NPC sees on the ground. Arrives in the SEE_ITEM event as the
item_index_list field. It is usually used to pick items up via AddGetItemDesireEx.

Methods:
GetSize()how many items are in the list (int)
GetItemIndex(int n)object index of the n-th item (int) — suitable for AddGetItemDesireEx; comparable with @item ids from [item_pch]
Example:
i0 = item_index_list.GetSize();
for ( i1 = 0; i1 < i0; ++i1 ) {
AddGetItemDesireEx( item_index_list.GetItemIndex( i1 ), 10000 );
}

CCodeInfotype🟢 high

a single drop/quest "code" record
In scripts
event slotcode_info

A single reward "code" record. Arrives as the code_info event field; it is usually
extracted from a CCodeInfoList using Next() or RandomSelectOne().

Properties:
.codethe record's code (int); select(code_info.code) branches the reward logic on it — what to give and to whom
Methods:
Next()next creature bound to the code (CSharedCreatureData)
RandomSelectOne()random creature among those bound to the code (CSharedCreatureData)
Example:
code_info = random1_list.RandomSelectOne();// take a random record from the list
select ( code_info.code ) {// branch on the record's code
case 1: { target = code_info.RandomSelectOne(); ... break; }
}

CCodeInfoListtype🟢 high

list of CCodeInfo records
In scripts
event slotsalways_list random1_list

A list of CCodeInfo records. Arrives in the MY_DYING death event under the names
always_list (guaranteed reward) and random1_list (random reward). A script creates its
own list by calling AllocCodeInfoList().

Methods:
SetInfo(int code, CSharedCreatureData c)register creature c under code code
Next()next record in the list (CCodeInfo); empty at the end
RandomSelectOne()random record from the list (CCodeInfo)
Example:
random1_list.SetInfo( 0, target );// register the creature under code 0
...
code_info = random1_list.RandomSelectOne();// random record from the list
target= code_info.RandomSelectOne(); // random creature of that record
// the guaranteed list is walked with a loop:
// while ( IsNull( code_info = always_list.Next() ) == 0 ) { ... }

CPositionListtype🟢 high

list of points (waypoints)
In scripts
event slotsplist0 plist1

A list of waypoint positions. Its only method is GetPosition(n). Returned by
GetCloestPositionList. There is no separate GetSize — iterate over a known count or
until an empty point. The event fields plist0 / plist1 (type CPositionList) are free
slots: the engine does not fill them; the script itself stores the result of
GetCloestPositionList there.

Method:
GetPosition(int n) n-th point of the list (CPosition)

Where it comes from:
myself.GetCloestPositionList(nList, nX, nY, nZ, nCount)
up to nCount points closest to (x,y,z) from the named waypoint set nList
(@PrivatePosList1, @FleePoints, etc.)

Example:

plist0 = myself.GetCloestPositionList( @PrivatePosList1,
FloatToInt(attacker.x), FloatToInt(attacker.y), FloatToInt(attacker.z), 2 );
if ( IsNull( plist0 ) ) {
// the set is empty — fallback
} else {
pos0 = plist0.GetPosition( 0 ); // nearest safe point next to the enemy
}

CRoomInfoListtype🟢 high

instance zone rooms
In scripts
event slotsrlist0 rlist1 (lists)
room0 room1 (rooms)

A list of instance zone rooms and a single room (a record of the party occupying a
copy). The list is returned by GetRoomInfoList(sLevelName), a room — by the
GetRoomInfo(i) method.

CRoomInfoList:
GetRoomInfo(int i) i-th room (CRoomInfo)

CRoomInfo — properties:
.party_id id of the party occupying the room
.member_count number of members
.time time
.status room state (atomic: .value — read,
.Exchange(v) — atomic swap)

CRoomInfo — methods:
GetMemberID(int i) id of the i-th member
PartyChanged() has the party changed
SetParty(int id) assign a party
Clear() clear the room

Example:

rlist0 = GetRoomInfoList( LevelName );
room0 = rlist0.GetRoomInfo( RoomIndex );

Position & geometry

1 types

CPositiontype🟢 high

point (coordinate)
In scripts
event slotspos0 pos1

A point with coordinates. Returned by the random-position generators
(GetRandomPosInCreature / GetRandomPosInPos / GetRandomPosInTerritory[2]); in examples —
pos0, pos1.

Properties:
.x .y .zpoint coordinates

Enums

10 groups

NASC

FLAGS AND ENUMERATIONS (ENUM CONSTANTS)

ACT

physical action of an NPC (p_state)

what the character/NPC is physically doing right now.

Consumer: the myself.p_state field (and c.p_state on a creature). One of the most frequent

Example

if (myself.p_state == @ACT_STAND || myself.p_state == @ACT_SIT) { ... }
@const#
@ACT_NOTHING0no action set / idle (initial state)
@ACT_STAND1standing, doing nothing
@ACT_SIT2sitting
@ACT_MOVE3moving freely (walking/running)
@ACT_ATTACK4attacking a target
@ACT_SKILL5using a skill (cast)
@ACT_TALK6talking to a player (dialog open)
@ACT_GENERAL7performing a general (non-combat) action/animation
@ACT_GETITEM8picking up an item from the ground
@ACT_OPENCLOSE9opening/closing a door (or similar object)
@ACT_MOVE_TO_TARGET10moving toward the selected target (closing in)
@ACT_MOVE_TO_TARGET_WAIT11moving to the target and waiting on arrival
@ACT_CHANGE_WEAPON12changing weapon (weapon-swap animation)
@ACT_MOVE_IN_VEHICLE13moving in a vehicle (boat/airship)
@ACT_ATTACK_WAIT14pause between attacks (attack cooldown)
@ACT_PRIVATE_STORE15keeping a private store open (private shop)
@ACT_MOVE_TO_TARGET_RELATIVE16moving to the target along a relative trajectory (following/holding position)

AT

weapon type (attack/weapon type)

the weapon category of a character/item.

Consumer: the weapon type of a creature/item (compared as a number). In the compiled

@const#
@AT_NONE0no weapon (bare fists by default)
@AT_SWORD1one-handed sword
@AT_BLUNT2blunt/mace
@AT_DAGGER3dagger
@AT_POLE4polearm (halberd/spear)
@AT_FIST5fists (fist weapon)
@AT_BOW6bow
@AT_ETC7other
@AT_DUAL8dual swords
@AT_DUALFIST9dual fists
@AT_FISHINGROD10fishing rod (fishing tackle)
@AT_RAPIER11rapier
@AT_CROSSBOW12crossbow
@AT_ANCIENTSWORD13ancient sword (special two-handed)

SAT

social action (gesture/animation)

the social action/animation the character plays.

Consumer: AddPCSocial( nIndex, @SAT_... ) — make the player at the given index play the social action.

Example

AddPCSocial( GetIndexFromCreature( talker ), @SAT_VICTORY );
@const#
@SAT_GREET2greeting
@SAT_VICTORY3victory gesture
@SAT_ADVANCE4"advance" (rallying/charge call)
@SAT_NO5"no" (denial)
@SAT_YES6"yes" (agreement)
@SAT_BOW7bow
@SAT_UNAWARE8confusion (shrug)
@SAT_WAITINGA9waiting ("I'm waiting" gesture)
@SAT_LAUGH10laughter
@SAT_APPLAUS11applause
@SAT_DANCE12dance
@SAT_SAD13sadness
@SAT_LEVEL_UP15level-up effect
@SAT_HERO16hero effect/gesture
@SAT_CURSED_WEAPON_LEVEL_UP17cursed weapon growth effect

STGT

skill target type

who the skill targets.

Consumer: the return value of Skill_GetTargetType( nSkillId ).

Example

if ( Skill_GetTargetType( skill_id ) == @STGT_ENEMY ) { ... }
@const#
@STGT_SELF0self
@STGT_TARGET1the selected target
@STGT_OTHERS2others (excluding self)
@STGT_MY_PARTY3own party
@STGT_ENEMY4an enemy
@STGT_ENEMY_ONLY5enemy only
@STGT_NPC_ENEMY_ONLY_BUT_SIEGE6hostile NPCs only (except siege ones)
@STGT_ITEM7an item
@STGT_SUMMON8a summoned creature (summon)
@STGT_MY_PLEDGE9own clan
@STGT_DOOR_TREASURE10a door/treasure chest

PARAM

parameter/stat type

which character parameter is being read/changed.

Consumer: IncrementParam( c, @PARAM_..., nAmount ) and related stat operations.

Example

IncrementParam( target, @PARAM_EXP, 460000 );
@const#
@PARAM_EXP0experience (EXP)
@PARAM_SP1skill points (SP)
@PARAM_INT2Intelligence (INT)
@PARAM_STR3Strength (STR)
@PARAM_CON4Constitution (CON)
@PARAM_MEN5Mental strength (MEN)
@PARAM_DEX6Dexterity (DEX)
@PARAM_WIT7Wit (WIT)
@PARAM_LEVEL8level
@PARAM_PKCOUNT9player-kill counter (PK)
@PARAM_KARMA13karma
@PARAM_SKILL_MULTIPLIER65536internal skill multiplier (special value, not a stat)

KT

skill kind / combat role

classification of a skill/combat role (by class purpose).

Consumer: skill/role category (ai scripts almost never compare against @KT_* directly;

@const#
@KT_BASIC1basic (common)
@KT_WARRIOR2warrior (melee)
@KT_TANKER3tank (defense/provocation)
@KT_ARCHER4archer (ranged)
@KT_ROUGE5rogue (damage/evasion)
@KT_WIZARD6wizard (offensive magic)
@KT_ENCHANT7buffer/bard (enhancement)
@KT_SUMMON8summoner
@KT_HEAL9healer (healing)

SEAL

Seven Signs seal (SSQ)

a seal in the Seven Signs system (Sky/Seven Signs Quest).

Consumer: GetSSQSealOwner( @SEAL_... ) and other SSQ functions taking a seal argument.

Example

if ( GetSSQSealOwner( @SEAL_AVARICE ) == GetSSQPart( talker ) ) { ... }
@const#
@SEAL_AVARICE1Avarice
@SEAL_REVELATION2Revelation
@SEAL_STRIFE3Strife
@SEAL_CHASTISEMENT4Chastisement
@SEAL_AROUSAL5Arousal
@SEAL_DISASTER6Disaster
@SEAL_AMAGEDON7Armageddon

PP

clan privilege (pledge power)

a specific clan right (what a member is allowed to do).

Consumer: HavePledgePower( c, @PP_... ) — whether the player has this right in their clan.

Example

if ( HavePledgePower( talker, @PP_MANAGE_MANOR ) ) { ... }
@const#
@PP_JOIN1invite/accept members into the clan
@PP_GIVE_NICKNAME2grant titles (nicknames) to members
@PP_VIEW_WAREHOUSE3access the clan warehouse
@PP_MANAGE_GRADE4manage member ranks/grades
@PP_DECLARE_WAR5declare clan wars
@PP_OUST_MEMBER6expel members from the clan
@PP_SET_CREST7change the clan crest
@PP_MANAGE_MASTER8appoint managers (masters)
@PP_MANAGE_GROWTH9manage clan development
@PP_SUMMON_AIRSHIP10summon the clan airship
@PP_OPEN_AGIT_DOOR11open the doors of the clan hall (agit)
@PP_USE_AGIT_FUNC12use clan hall functions
@PP_AGIT_AUCTION13participate in the clan hall auction
@PP_OUST_FROM_AGIT14banish outsiders from the clan hall
@PP_CONTROL_AGIT_FUNC15set/remove clan hall functions
@PP_OPEN_CASTLE_DOOR16open castle doors
@PP_MANAGE_MANOR17manage the manor (seeds/crops)
@PP_REGISTER_CASTLE_WAR18register for a castle siege
@PP_USE_CASTLE_FUNC19use castle functions
@PP_OUST_FROM_CASTLE20banish outsiders from the castle
@PP_MANAGE_TAX21manage the castle tax rate
@PP_MANAGE_MERCENARY22manage (siege) mercenaries
@PP_CONTROL_CASTLE_FUNC23set/remove castle functions

FORTRESS

fortress states and facilities

three separate value sets for the fortress. Consumers are the Fortress_* functions.

@const#
@FORTRESS_ANNOUNCING0announced (announcement before registration)
@FORTRESS_REGISTRATION1participant registration in progress
@FORTRESS_STANDBY2standby before the siege starts
@FORTRESS_SIEGE3siege in progress
@FORTRESS_GUARD_REINFORCEMENT0guard reinforcement
@FORTRESS_GUARD_POWER_UP1guard power-up
@FORTRESS_DOOR_POWER_UP2gate power-up
@FORTRESS_PHOTOCANNON3photon cannon (siege weapon)
@FORTRESS_SCOUT4scouting (scout)
@FORTRESS_CONTRACT_INDEP-1independent (no liege)
@FORTRESS_CONTRACT_NONE0no contract
@FORTRESS_CONTRACT_CASTLE1contract with a castle concluded