Difference between revisions of "Donpcevent"

From Hercules Wiki
Jump to: navigation, search
(Created page with "==Syntax== *'''donpcevent''' <"event label">; *'''cmdothernpc''' <"npc name">, <"command">; ==Description== This command invokes the event label code within an another [[NPC]...")

Revision as of 00:00, 23 June 2013

Contents

Syntax

  • donpcevent <"event label">;
  • cmdothernpc <"npc name">, <"command">;

Description

This command invokes the event label code within an another NPC or NPCs. If event label has the form "NpcName::OnLabel", then only given NPC's event label will be invoked (much like goto into another NPC). If the form is "::OnLabel" (NpcName ommited), the event code of all NPCs with given label will be invoked, one after another. In both cases the invoked script will run without an attached RID, whether or not the invoking script was attached to a player. The event label name is required to start with On.

This command can be used to make other NPCs act, as if they were responding to the invoking NPC's actions, such as using an emotion or talking.

The command cmdothernpc is equivalent to donpcevent "<npc name>::OnCommand<command>" and an approximation to the AEGIS script command with same name.

Examples

prontera,150,150,3	script	NPC	53,{
    mes "Hey NPC2 copies what I do.";
    close2;
    set .@emote, rand(1,30);
    donpcevent "NPC2::OnEmote";
OnEmote:
    emotion .@emote;
    end;
}

prontera,152,150,5	script	NPC2	53,{
    mes "Hey NPC copies what I do.";
    close2;
    set .@emote, rand(1,30);
    donpcevent "NPC::OnEmote";
OnEmote:
    emotion .@emote;
    end;
}

Whichever of the both NPCs is talked to, both will show a random emotion at the same time.

See Also