Forcing emotes from other NPCs?

bWolfie

I'm the man
Messages
850
Points
0
Location
Alberta, Midgard
Github
bWolfie
Emulator
Hi,

I am struggling to get my script to force an emotion from an NPC from another script. 

Bit of info:

- Both NPCs are on the same map.

- Player cannot see both NPCs at the same time on their screen (too far apart).

- NPC 1 (who you are talking to) warps you in front of NPC 2, who talks a bit then responds with emotions.

What is wrong with this? Thank you in advance for any help.

Code:
prontera,100,100,5    script    NPC1    53,{
  mes "[NPC1]";
  mes "I am now warping you to NPC2";
  next;
  warp "prontera",150,150,0;
  mes "[NPC1];
  mes "This is NPC2. Say hello to the player, NPC2.";
  set .@emote, e_paper;
  next;
  donpcevent "NPC2::OnEmote";
  //Conversation 'mes' continues from here
 
//At the bottom of NPC1's script (but still inside it)
OnEmote:
  emotion .@emote;
  end;
}
 
OnEmote label should be put in NPC2, because you invoke donpcevent "NPC2::OnEmote";
 

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

This command invokes the event label code within an another NPC or NPCs.
It starts a separate instance of execution, and the invoking NPC will
resume execution its immediately.

If the supplied 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" (NPC name omitted), 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.

place,100,100,1%TAB%script%TAB%NPC%TABS,{
mes "Hey NPC2 copy what I do";
close2;
@emote = rand(1,30);
donpcevent "NPC2::OnEmote";
OnEmote:
emotion @emote;
end;
}

place,102,100,1%TAB%script%TAB%NPC2%TABS,{
mes "Hey NPC copy what I do";
close2;
@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.

In docs there OnEmote label in first NPC because second NPC2 invokes it.

 
Last edited by a moderator:
Back
Top