-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrandom_message.pl
More file actions
124 lines (117 loc) · 3.39 KB
/
random_message.pl
File metadata and controls
124 lines (117 loc) · 3.39 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
###Usage: plugin::RandomSay(chance(1-100), "message1","message2", etc..);
#::: Author: Trevius
#::: Description: Used for random quest::say messages
#::: Usage: plugin::RandomSay(chance(1-100), "message1","message2", etc..);
sub RandomSay {
my $chance = $_[0];
my $DoMessage = 0;
# First roll to see if a message will be sent or not depending on chance
if ($chance > 0 && $chance <= 100)
{
my $RandomNum = plugin::RandomRange(1, 100);
if ($RandomNum <= $chance)
{
$DoMessage = 1;
}
}
# Choose the random message to send and send it
if ($DoMessage)
{
my $count = 1;
while ($_[$count])
{
$count++;
}
my $RandMessage = plugin::RandomRange(1, $count);
quest::say($_[$RandMessage]);
}
}
#::: Author: Trevius
#::: Description: Used for random quest::emote messages
#::: Usage: plugin::RandomEmote(chance(1-100), "message1","message2", etc..);
sub RandomEmote {
my $chance = $_[0];
my $DoMessage = 0;
# First roll to see if a message will be sent or not depending on chance
if ($chance > 0 && $chance <= 100)
{
my $RandomNum = plugin::RandomRange(1, 100);
if ($RandomNum <= $chance)
{
$DoMessage = 1;
}
}
# Choose the random message to send and send it
if ($DoMessage)
{
my $count = 1;
while ($_[$count])
{
$count++;
}
my $RandMessage = plugin::RandomRange(1, $count);
quest::emote($_[$RandMessage]);
}
}
#::: Author: Trevius
#::: Description: Used for random emote messages to group
#::: Usage: plugin::RandomGroupEmote(chance(1-100), "message1","message2", etc..);
sub RandomGroupEmote {
my $npc = plugin::val('$npc');
my $client = plugin::val('$client');
my $chance = $_[0];
my $TextColor = 7; # Set the Text Color for the Message (this one is WHITE)
my $DoMessage = 0;
# First roll to see if a message will be sent or not depending on chance
if ($chance > 0 && $chance <= 100)
{
my $RandomNum = plugin::RandomRange(1, 100);
if ($RandomNum <= $chance)
{
$DoMessage = 1;
}
}
# Choose the random message to send and send it
if ($DoMessage)
{
my $count = 1;
while ($_[$count])
{
$count++;
}
my $RandMessage = plugin::RandomRange(1, $count);
my $MyMessage = $_[$RandMessage];
if($client) # Verify we got a client
{
my $NPCName = $npc->GetCleanName(); # Get the clean name of the NPC sending the message
my $ClientGroup = $client->GetGroup(); # Check if the client is in a group
if ($ClientGroup)
{
my $GroupID = $ClientGroup->GetID(); # Get the Group ID for this client
my @clientlist = $entity_list->GetClientList();
foreach $ent (@clientlist)
{
$EntGroup = $ent->GetGroup(); # Check all clients for groups
if ($EntGroup)
{
$EntGroupID = $EntGroup->GetID(); #Check the group ID
if ($EntGroupID == $GroupID) # Compare group ID to the original client's group ID
{
$ent->Message($TextColor, "$NPCName $MyMessage"); # Message all members of the group
}
}
}
}
else # No Group, so just emote to this client only
{
$client->Message($TextColor, "$NPCName $MyMessage");
}
}
}
}
###Usage: plugin::RandomCloseEmote(chance(1-100), "message1","message2", etc..);
# The idea for this plugin is to make it so you can send a message that can appear differently to the person
# who triggered the message and to nearby players. Example:
# PlayerA attacks a snake and sees "a snake attacks you!"
# PlayerB is nearby and sees "a snake attacks PlayerA!"
return 1;