Updated to include the attacked players level and a level range to help. #1

Closed
Zafrusteria wants to merge 3 commits from master into Add_player_level_pkgo

@ -1,5 +1,6 @@
# PK_Alert
Notify to channel PK alert information.
# PKAdmin
## Usage:
pkadmin help : This menu
@ -9,6 +10,29 @@ pkadmin sound <yes/no> : Turns on/off sound alerts
pkadmin volume <0-100> : Sets the play volume for sound
pkadmin levelrange <1-100> : Set the range of levels displayed in the PK Alert
pkadmin enable : Enables the script
pkadmin disable : Disables the script
pkgo : "Runto" help your clan mate out
## Installation:
Copy the sound file redalert.wav into your MUSHclient\sounds directory.
Copy the xml file into your MUSHclient\worlds\plugins diretory or a subdirectory.
Then just install the plugin into MUSHClient and you are ready to go.
Usage
At the end of the PK alert message is the level of the player being attacked
and a level range. The level range defaults to plus and minus 10. It can be
changed to any value with tht epkadmin levelrange command.
When you see a PK Alert from a clan mate, the second line that is displayed
has a clickable link for the room number. If you have explored the room and all
necessary cexits are setup you will run directly to the room.
There is also a handy alias pkgo that will again run you to the room of your
clan mate. It is reset each time the PK alert is displayed on your screen.

@ -14,7 +14,7 @@
purpose="Notify to channel PK alert information."
save_state="y"
date_written="2018-10-29 13:37:21"
version="1.4"
version="1.6"
>
<description trim="y">
<![CDATA[
@ -24,7 +24,6 @@ Description Here
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
@ -32,17 +31,6 @@ Description Here
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^@\w\(@\wGroup@\w\) @\w(?<saveme>.+): '@\w(?<target>\w+).* @\win @x202(?<area>\w+) @\w\[@x202(?<roomnum>\d+)@\w\]'$"
regexp="y"
sequence="100"
script="respondAlert"
omit_from_output="n"
>
</trigger>
<trigger
enabled="y"
match="^(\w+) disappears!$"
@ -53,21 +41,21 @@ Description Here
</trigger>
<trigger
enabled="y"
match="^You grab hold of (.*?)\'s neck and choke \w+ to unconsciousness\!$"
match="^You grab hold of (.+?)\'s neck and choke \w+ to unconsciousness\!$"
regexp="y"
sequence="100"
script="sendStrangleAlert"
>
</trigger>
<trigger
enabled="y"
match="^(.*?) looks very uncomfortable\.$"
match="^(?<target>\w[\w\s]+) looks very uncomfortable\."
regexp="y"
sequence="100"
script="sendCursedAlert"
>
</trigger>
<!--You switch targets and direct your attacks at Ralyn.-->
<!--** You can take revenge on Yatzi for 15 minutes-->
<trigger
@ -97,9 +85,14 @@ Description Here
>
</trigger>
<!--
The prefix characters '\' that YOU need to use are to be found in world properties -> scripts and then look at the top right for the characters in Script.
Room 10676 is in Kimr's Farm. safe room. test with
\Simulate("SuperBuff (Newbie member) tells the CLAN: 'PK Alert:Noddy in Farm [10676].'\n")
-->
<trigger
enabled="y"
match="^(?<clan>.+?)\s\(.+\)\s+tells the CLAN: 'PK Alert:(?<attacker>.+)\s+in\s+(?<area>.+?)\s+\[(?<roomid>\d+)\]'$"
match="^(?<clan>.+?)\s\(.+\)\s+tells the CLAN: 'PK Alert:\s+(?<attacker>.+)\s+in\s+(?<area>.+?)\s+\[(?<roomid>\d+)\](?: I am level \d+ \(\d+ - \d+\))?'$"
regexp="y"
sequence="100"
script="outputHyperLink"
@ -107,13 +100,9 @@ Description Here
keep_evaluating="y"
>
</trigger>
</triggers>
<!-- Plugin help -->
<aliases>
<alias
enabled="y"
match="pkc *"
@ -151,6 +140,18 @@ Description Here
script="COMMAND_PKAdmin"
>
</alias>
<alias
enabled="y"
sequence="100"
ignore_case="y"
regexp="y"
keep_evaluating="n"
match="^\s*pk\s*go\s*$"
script="runto_PK_room"
>
</alias>
</aliases>
<script>
@ -163,6 +164,11 @@ PKASettings.volume = 100
PKASettings.alert = 1
PKASettings.sound = 1
PKASettings.enabled = 1
PKASettings.playerlevel = 1
defLevelRange = 10
PKASettings.levelrange = defLevelRange
local runto_roomid = 0
function SaveSettings()
SetVariable("PKSettings", serialize.save_simple(PKASettings))
@ -194,6 +200,7 @@ PKAdminCommands = {
COMMAND_PKAdmin_Sound = {"sound", "soun", "soun", "sou" },
COMMAND_PKAdmin_Status = {"status", "statu", "stat" },
COMMAND_PKAdmin_Volume = {"volume", "volum", "volu", "vol" },
COMMAND_PKAdmin_LevelRange = {"levelrange", "levelr", "level",},
COMMAND_PKAdmin_Reset = {"reset"}
}
@ -224,9 +231,13 @@ function COMMAND_PKAdmin_Help()
cnote(" @Gpkadmin alert <yes/no> @w: @WTurns on/off channel alerts ")
cnote(" @Gpkadmin sound <yes/no> @w: @WTurns on/off sound alerts ")
cnote(" @Gpkadmin volume <0-100> @w: @WSets the play volume for sound")
cnote(" @Gpkadmin levelrange <1-100> @w: @WSet the range of levels displayed in the PK Alert")
cnote(" @Gpkadmin enable @w: @WEnables the script ")
cnote(" @Gpkadmin disable @w: @WDisables the script ")
Note()
cnote(" @Gpkgo @w: @W\"Runto\" help your clan mate out")
Note()
end
function COMMAND_PKAdmin_Enable()
@ -322,6 +333,18 @@ function COMMAND_PKAdmin_Volume(args)
cnote(Prepend.."@wVolume is now set to @Y"..tonumber(args[1]).."@w.")
end
function COMMAND_PKAdmin_LevelRange(args)
if not tonumber(args[1]) or (tonumber(args[1]) < 0) then
cnote(Prepend.."@RLevel Range@w requires a number greater than zero.")
Note()
return
end
PKASettings.levelrange = tonumber(args[1])
SaveSettings()
cnote(Prepend.."@wLevel range is now set to @Y+/-"..PKASettings.levelrange.."@w.")
end
function COMMAND_PKAdmin_Status()
cnote( "@R+@w-----------------------------------------------------------------------------------------@R+@w" )
cnote( " " .. Prepend .. " PKAnnouncer's current status is " .. (PKASettings.enabled == 1 and "@GOn" or "@ROff") .. "@w" )
@ -329,6 +352,7 @@ function COMMAND_PKAdmin_Status()
cnote( (" @x208Channel Alerts :@w %-30.30s " ):format( PKASettings.alert == 1 and "@GOn@w" or "@ROff@w"))
cnote( (" @x208Sound Alerts :@w %-30.30s " ):format( PKASettings.sound == 1 and "@GOn@w" or "@ROff@w"))
cnote( (" @x208Sound Volume :@w %-30.0d " ):format( PKASettings.volume ) )
cnote( (" @x208Level Range :@w +/-%-30.0d " ):format( PKASettings.levelrange) )
cnote( "@R+@w-----------------------------------------------------------------------------------------@R+@w" )
Note()
end
@ -339,6 +363,8 @@ function COMMAND_PKAdmin_Reset()
PKASettings.alert = 1
PKASettings.sound = 1
PKASettings.enabled = 1
PKASettings.levelrange = defLevelRange
PKASettings.playerlevel = tonumber(gmcp("char.status.level"))
cnote( Prepend.."PKASettings have been reset to defaults." )
SaveSettings()
end
@ -386,14 +412,15 @@ function isAlertEnabled()
else
return false
end
end
function sendPkInfoClan(name, line, wildcards)
if isEnabled() then
getRoomInformation()
if isAlertEnabled() then
SendNoEcho(string.format("cl @W%s@C ENGAGED @Win @x202%s @W[@x202%s@W]",wildcards[1], area, roomid))
local msg = string.format(" @W%s@C ENGAGED @Win @x202%s @W[@x202%s@W]",wildcards[1], area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("clan "..msg)
end
target = wildcards[1]
end
@ -401,12 +428,12 @@ end
function recalled(name, line, wildcards)
if isEnabled() and isAlertEnabled() then
if(wildcards[1] == target) then
if (ingroup == true) then
chan = "gt "
else
chan = "clan "
end
if(wildcards[1] == target) then
SendNoEcho(string.format(chan .. "@W%s@C Recalled!",wildcards[1], area, roomid))
end
end
@ -415,7 +442,10 @@ end
function sendPkInfoGroup(name, line, wildcards)
if isEnabled() and isAlertEnabled() then
getRoomInformation()
SendNoEcho(string.format("gt @W%s@C ENGAGED @Win @x202%s @W[@x202%s@W]",wildcards[1], area, roomid))
local msg = string.format(" @W%s@C ENGAGED @Win @x202%s @W[@x202%s@W]",wildcards[1], area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("gt "..msg)
target = wildcards[1]
end
end
@ -425,17 +455,13 @@ function sendPkAlert(name, line, wildcards)
if isAlertEnabled() then
getRoomInformation()
if(wildcards[1] ~= nil) then
if (ingroup == true) then
SendNoEcho(string.format("gt @RPK Alert: @W%s@C @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid))
if wildcards[1] ~= nil then
local msg = string.format(" @RPK Alert: @W%s @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("clan "..msg)
if ingroup == true then
SendNoEcho("gt "..msg)
end
SendNoEcho(string.format("cla @RPK Alert: @W%s@C @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid))
target = wildcards[1]
else
if (ingroup == true) then
SendNoEcho(string.format("gt @RPK Alert: @W%s@C @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid))
end
SendNoEcho(string.format("cla @RPK Alert: @W%s@C @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid))
target = wildcards[1]
end
end
@ -450,6 +476,8 @@ end
function outputHyperLink(name, line, wildcards)
if wildcards.roomid ~= nil then
runto_roomid = wildcards.roomid
ColourTell("red", "", "RPK Alert: ", "goldenrod", "", "I'm getting attacked please help at ",
"white", "", "[")
Hyperlink("mg "..wildcards.roomid, wildcards.roomid, "Click to run directly to then room Id"..roomid, "orangered", "", 0)
@ -457,21 +485,23 @@ function outputHyperLink(name, line, wildcards)
end
end
function runto_PK_room()
if runto_roomid ~= 0 then
Execute("mapper goto "..runto_roomid)
end
end
function sendStrangleAlert(name, line, wildcards)
if isEnabled() and isAlertEnabled() then
getRoomInformation()
if (ingroup == true) then
chan = "gt "
else
chan = "clan "
end
if(wildcards[1] ~= nil) then
Send(string.format(chan .. "@W%s@C STRANGLED @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid))
target = wildcards[1]
else
Send(string.format(chan .. "@W%s@C STRANGLED @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid))
local msg = string.format("@W%s@C STRANGLED @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("clan "..msg)
if ingroup == true then
SendNoEcho("gt "..msg)
end
target = wildcards[1]
end
end
@ -485,17 +515,17 @@ function sendCursedAlert(name, line, wildcards)
chan = "clan "
end
getRoomInformation()
if(wildcards[1] ~= nil) then
SendNoEcho(string.format(chan .. "@W%s@C CURSED @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid))
target = wildcards[1]
else
Send(string.format(chan .. "@W%s@C CURSED @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid))
target = wildcards[1]
if(wildcards.target ~= nil and wildcards.target ~= "") then
local msg = string.format("@W%s@C CURSED @Win @x202%s @W[@x202%s@W]", wildcards.target, area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("clan "..msg)
if ingroup == true then
SendNoEcho("gt "..msg)
end
target = wildcards.target
end
end
function respondAlert(name, line, wildcards)
end
function getRoomInformation()
@ -510,14 +540,30 @@ function getRoomInformation()
room = gmcproom.info.name
end
function addLevelRangeText(msg)
if PKASettings.playerlevel > 0 and PKASettings.levelrange > 0 then
local min = PKASettings.playerlevel - PKASettings.levelrange
if min < 1 then min = 1 end
local max = PKASettings.playerlevel + PKASettings.levelrange
if max > 201 then max = 201 end
msg = msg.." I am level @x202"..PKASettings.playerlevel.." @W(@x202"..min.."@W - @x202"..max.."@W)"
end
return msg
end
function OnPluginBroadcast (msg, id, name, text)
if id == "3e7dedbe37e44942dd46d264" then
if id == GMCPPluginID then
if text == "group" then
local res, membercount = CallPlugin(GMCPPluginID, "gmcpval", "group.count")
if membercount == "" then membercount = 0 end
if tonumber(membercount) >= 1 then
ingroup = true
end
elseif text == "char.status" then
PKASettings.playerlevel = tonumber(gmcp("char.status.level"))
end
end
end
@ -525,13 +571,17 @@ end
function OnPluginInstall()
OnPluginEnable()
end
function OnPluginEnable()
local settings = GetVariable("PKSettings")
if settings and settings ~= "" then
assert(loadstring("PKASettings = "..GetVariable("PKSettings"))) ()
end
end
if PKASettings.levelrange == nil then PKASettings.levelrange = defLevelRange end
Send_GMCP_Packet("request char")
end
function OnHelp ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))

Loading…
Cancel
Save