/
talk.c
77 lines (70 loc) · 2.43 KB
/
talk.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//*****************************************************************************
// Copyright (c) 2019 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//*****************************************************************************
inherit "/lib/commands/baseCommand.c";
#include "/lib/include/settings.h"
/////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg)
{
if (!arg)
{
CommandType = "Social";
addCommandTemplate("talk [##Target##]");
addCommandTemplate("talk to [##Target##]");
addCommandTemplate("repeat [##Target##]");
}
}
/////////////////////////////////////////////////////////////////////////////
public nomask int execute(string command, object initiator)
{
int ret = 0;
if (canExecuteCommand(command))
{
object target = getTarget(initiator, command);
if (target && target->canConverse(initiator))
{
ret = target->beginConversation(initiator);
if (!ret)
{
notify_fail(sprintf("%s has nothing to say at the moment.\n",
target->Name()));
}
}
else
{
object *others = filter(all_inventory(environment(initiator)),
(: $1->canConverse($2) :), initiator);
if (sizeof(others))
{
ret = others[0]->beginConversation(initiator);
if (!ret)
{
notify_fail(sprintf("%s has nothing to say at the moment.\n",
others[0]->Name()));
}
}
else
{
notify_fail("Nobody has anything to say at the moment.\n");
}
}
}
return ret;
}
/////////////////////////////////////////////////////////////////////////////
protected string synopsis(string displayCommand)
{
return "Initiate a conversation with an NPC.";
}
/////////////////////////////////////////////////////////////////////////////
protected string description(string displayCommand)
{
return format("Talk initiates a conversation with an NPC provided that "
"the NPC has something they wish to discuss.", 78);
}
/////////////////////////////////////////////////////////////////////////////
protected string notes(string displayCommand)
{
return "See also: say";
}