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]...")
 
 
Line 1: Line 1:
 
==Syntax==
 
==Syntax==
*'''donpcevent''' <"event label">;
+
*[[donpcevent]] "<NPC object name>::<event label>";
*'''cmdothernpc''' <"npc name">, <"command">;
+
  
 
==Description==
 
==Description==
Line 7: Line 6:
  
 
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 [[npctalk|talking]].
 
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 [[npctalk|talking]].
 
The command '''cmdothernpc''' is equivalent to '''donpcevent''' "<npc name>::OnCommand<command>" and an approximation to the [[AEGIS]] script command with same name.
 
  
 
==Examples==
 
==Examples==
Line 32: Line 29:
 
Whichever of the both NPCs is talked to, both will show a random emotion at the same time.
 
Whichever of the both NPCs is talked to, both will show a random emotion at the same time.
  
 +
Command returns 1 or 0 on success and failure. A debug message also shows on the console when no events are triggered.
 
==See Also==
 
==See Also==
 
* [[doevent]]
 
* [[doevent]]
  
 
[[Category:Script Command]]
 
[[Category:Script Command]]

Latest revision as of 05:10, 11 November 2014

Contents

Syntax

  • donpcevent "<NPC object name>::<event label>";

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.

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.

Command returns 1 or 0 on success and failure. A debug message also shows on the console when no events are triggered.

See Also