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

Updated to include the attacked players level and a level range to help.
New trigger for anyone willingt o help now has a clickable link to run you to the room where the fight is no going.
Added an alias  pkgo that also runs you to the room.
Added more details to the readme.md file. This includes installation and usage.
pull/1/head
Zafrusteria 5 years ago
parent 538949fdb8
commit 15472dc9da

@ -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.5"
>
<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!$"
@ -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"}
}
@ -223,10 +230,14 @@ function COMMAND_PKAdmin_Help()
cnote(" @Gpkadmin help @w: @WThis menu")
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 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
@ -486,18 +516,17 @@ function sendCursedAlert(name, line, wildcards)
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))
local msg = string.format("@W%s@C CURSED @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
end
function respondAlert(name, line, wildcards)
end
function getRoomInformation()
if IsConnected() then
Send_GMCP_Packet("request room")
@ -510,14 +539,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 +570,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