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 willing to 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.
Add_player_level_pkgo
Zafrusteria 5 years ago
parent af54651f8a
commit 303fb3ce69

@ -14,7 +14,7 @@
purpose="Notify to channel PK alert information." purpose="Notify to channel PK alert information."
save_state="y" save_state="y"
date_written="2018-10-29 13:37:21" date_written="2018-10-29 13:37:21"
version="1.4" version="1.5"
> >
<description trim="y"> <description trim="y">
<![CDATA[ <![CDATA[
@ -24,7 +24,6 @@ Description Here
</plugin> </plugin>
<!-- Get our standard constants --> <!-- Get our standard constants -->
<include name="constants.lua"/> <include name="constants.lua"/>
@ -32,17 +31,6 @@ Description Here
<!-- Triggers --> <!-- Triggers -->
<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 <trigger
enabled="y" enabled="y"
match="^(\w+) disappears!$" match="^(\w+) disappears!$"
@ -97,9 +85,14 @@ Description Here
> >
</trigger> </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 <trigger
enabled="y" 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" regexp="y"
sequence="100" sequence="100"
script="outputHyperLink" script="outputHyperLink"
@ -107,13 +100,9 @@ Description Here
keep_evaluating="y" keep_evaluating="y"
> >
</trigger> </trigger>
</triggers> </triggers>
<!-- Plugin help -->
<aliases> <aliases>
<alias <alias
enabled="y" enabled="y"
match="pkc *" match="pkc *"
@ -151,6 +140,18 @@ Description Here
script="COMMAND_PKAdmin" script="COMMAND_PKAdmin"
> >
</alias> </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> </aliases>
<script> <script>
@ -163,6 +164,11 @@ PKASettings.volume = 100
PKASettings.alert = 1 PKASettings.alert = 1
PKASettings.sound = 1 PKASettings.sound = 1
PKASettings.enabled = 1 PKASettings.enabled = 1
PKASettings.playerlevel = 1
defLevelRange = 10
PKASettings.levelrange = defLevelRange
local runto_roomid = 0
function SaveSettings() function SaveSettings()
SetVariable("PKSettings", serialize.save_simple(PKASettings)) SetVariable("PKSettings", serialize.save_simple(PKASettings))
@ -194,6 +200,7 @@ PKAdminCommands = {
COMMAND_PKAdmin_Sound = {"sound", "soun", "soun", "sou" }, COMMAND_PKAdmin_Sound = {"sound", "soun", "soun", "sou" },
COMMAND_PKAdmin_Status = {"status", "statu", "stat" }, COMMAND_PKAdmin_Status = {"status", "statu", "stat" },
COMMAND_PKAdmin_Volume = {"volume", "volum", "volu", "vol" }, COMMAND_PKAdmin_Volume = {"volume", "volum", "volu", "vol" },
COMMAND_PKAdmin_LevelRange = {"levelrange", "levelr", "level",},
COMMAND_PKAdmin_Reset = {"reset"} COMMAND_PKAdmin_Reset = {"reset"}
} }
@ -220,12 +227,16 @@ end
function COMMAND_PKAdmin_Help() function COMMAND_PKAdmin_Help()
cnote("@GPKAdmin") cnote("@GPKAdmin")
cnote("@WUsage:") cnote("@WUsage:")
cnote(" @Gpkadmin help @w: @WThis menu") cnote(" @Gpkadmin help @w: @WThis menu")
cnote(" @Gpkadmin alert <yes/no> @w: @WTurns on/off channel alerts ") cnote(" @Gpkadmin alert <yes/no> @w: @WTurns on/off channel alerts ")
cnote(" @Gpkadmin sound <yes/no> @w: @WTurns on/off sound 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 enable @w: @WEnables the script ") cnote(" @Gpkadmin levelrange <1-100> @w: @WSet the range of levels displayed in the PK Alert")
cnote(" @Gpkadmin disable @w: @WDisables the script ") 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() Note()
end end
@ -322,6 +333,18 @@ function COMMAND_PKAdmin_Volume(args)
cnote(Prepend.."@wVolume is now set to @Y"..tonumber(args[1]).."@w.") cnote(Prepend.."@wVolume is now set to @Y"..tonumber(args[1]).."@w.")
end 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() function COMMAND_PKAdmin_Status()
cnote( "@R+@w-----------------------------------------------------------------------------------------@R+@w" ) cnote( "@R+@w-----------------------------------------------------------------------------------------@R+@w" )
cnote( " " .. Prepend .. " PKAnnouncer's current status is " .. (PKASettings.enabled == 1 and "@GOn" or "@ROff") .. "@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( (" @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 Alerts :@w %-30.30s " ):format( PKASettings.sound == 1 and "@GOn@w" or "@ROff@w"))
cnote( (" @x208Sound Volume :@w %-30.0d " ):format( PKASettings.volume ) ) cnote( (" @x208Sound Volume :@w %-30.0d " ):format( PKASettings.volume ) )
cnote( (" @x208Level Range :@w +/-%-30.0d " ):format( PKASettings.levelrange) )
cnote( "@R+@w-----------------------------------------------------------------------------------------@R+@w" ) cnote( "@R+@w-----------------------------------------------------------------------------------------@R+@w" )
Note() Note()
end end
@ -339,6 +363,8 @@ function COMMAND_PKAdmin_Reset()
PKASettings.alert = 1 PKASettings.alert = 1
PKASettings.sound = 1 PKASettings.sound = 1
PKASettings.enabled = 1 PKASettings.enabled = 1
PKASettings.levelrange = defLevelRange
PKASettings.playerlevel = tonumber(gmcp("char.status.level"))
cnote( Prepend.."PKASettings have been reset to defaults." ) cnote( Prepend.."PKASettings have been reset to defaults." )
SaveSettings() SaveSettings()
end end
@ -386,14 +412,15 @@ function isAlertEnabled()
else else
return false return false
end end
end end
function sendPkInfoClan(name, line, wildcards) function sendPkInfoClan(name, line, wildcards)
if isEnabled() then if isEnabled() then
getRoomInformation() getRoomInformation()
if isAlertEnabled() then 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 end
target = wildcards[1] target = wildcards[1]
end end
@ -401,12 +428,12 @@ end
function recalled(name, line, wildcards) function recalled(name, line, wildcards)
if isEnabled() and isAlertEnabled() then if isEnabled() and isAlertEnabled() then
if (ingroup == true) then
chan = "gt "
else
chan = "clan "
end
if(wildcards[1] == target) then if(wildcards[1] == target) then
if (ingroup == true) then
chan = "gt "
else
chan = "clan "
end
SendNoEcho(string.format(chan .. "@W%s@C Recalled!",wildcards[1], area, roomid)) SendNoEcho(string.format(chan .. "@W%s@C Recalled!",wildcards[1], area, roomid))
end end
end end
@ -415,7 +442,10 @@ end
function sendPkInfoGroup(name, line, wildcards) function sendPkInfoGroup(name, line, wildcards)
if isEnabled() and isAlertEnabled() then if isEnabled() and isAlertEnabled() then
getRoomInformation() 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] target = wildcards[1]
end end
end end
@ -425,19 +455,15 @@ function sendPkAlert(name, line, wildcards)
if isAlertEnabled() then if isAlertEnabled() then
getRoomInformation() getRoomInformation()
if(wildcards[1] ~= nil) then if wildcards[1] ~= nil then
if (ingroup == true) then local msg = string.format(" @RPK Alert: @W%s @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid)
SendNoEcho(string.format("gt @RPK Alert: @W%s@C @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid)) msg = addLevelRangeText(msg)
end SendNoEcho("clan "..msg)
SendNoEcho(string.format("cla @RPK Alert: @W%s@C @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid)) if ingroup == true then
target = wildcards[1] SendNoEcho("gt "..msg)
else end
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] target = wildcards[1]
end end
end end
--- Give the audio indicator --- Give the audio indicator
@ -450,6 +476,8 @@ end
function outputHyperLink(name, line, wildcards) function outputHyperLink(name, line, wildcards)
if wildcards.roomid ~= nil then if wildcards.roomid ~= nil then
runto_roomid = wildcards.roomid
ColourTell("red", "", "RPK Alert: ", "goldenrod", "", "I'm getting attacked please help at ", ColourTell("red", "", "RPK Alert: ", "goldenrod", "", "I'm getting attacked please help at ",
"white", "", "[") "white", "", "[")
Hyperlink("mg "..wildcards.roomid, wildcards.roomid, "Click to run directly to then room Id"..roomid, "orangered", "", 0) Hyperlink("mg "..wildcards.roomid, wildcards.roomid, "Click to run directly to then room Id"..roomid, "orangered", "", 0)
@ -457,22 +485,24 @@ function outputHyperLink(name, line, wildcards)
end end
end end
function runto_PK_room()
if runto_roomid ~= 0 then
Execute("mapper goto "..runto_roomid)
end
end
function sendStrangleAlert(name, line, wildcards) function sendStrangleAlert(name, line, wildcards)
if isEnabled() and isAlertEnabled() then if isEnabled() and isAlertEnabled() then
getRoomInformation() getRoomInformation()
if (ingroup == true) then
chan = "gt "
else
chan = "clan "
end
if(wildcards[1] ~= nil) then if(wildcards[1] ~= nil) then
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)
target = wildcards[1] msg = addLevelRangeText(msg)
else SendNoEcho("clan "..msg)
Send(string.format(chan .. "@W%s@C STRANGLED @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid)) if ingroup == true then
target = wildcards[1] SendNoEcho("gt "..msg)
end
target = wildcards[1]
end end
end end
end end
@ -486,18 +516,17 @@ function sendCursedAlert(name, line, wildcards)
end end
getRoomInformation() getRoomInformation()
if(wildcards[1] ~= nil) then if(wildcards[1] ~= nil) then
SendNoEcho(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)
target = wildcards[1] msg = addLevelRangeText(msg)
else SendNoEcho("clan "..msg)
Send(string.format(chan .. "@W%s@C CURSED @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid)) if ingroup == true then
target = wildcards[1] SendNoEcho("gt "..msg)
end
target = wildcards[1]
end end
end end
end end
function respondAlert(name, line, wildcards)
end
function getRoomInformation() function getRoomInformation()
if IsConnected() then if IsConnected() then
Send_GMCP_Packet("request room") Send_GMCP_Packet("request room")
@ -510,14 +539,30 @@ function getRoomInformation()
room = gmcproom.info.name room = gmcproom.info.name
end 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) function OnPluginBroadcast (msg, id, name, text)
if id == "3e7dedbe37e44942dd46d264" then if id == GMCPPluginID then
if text == "group" then if text == "group" then
local res, membercount = CallPlugin(GMCPPluginID, "gmcpval", "group.count") local res, membercount = CallPlugin(GMCPPluginID, "gmcpval", "group.count")
if membercount == "" then membercount = 0 end if membercount == "" then membercount = 0 end
if tonumber(membercount) >= 1 then if tonumber(membercount) >= 1 then
ingroup = true ingroup = true
end end
elseif text == "char.status" then
PKASettings.playerlevel = tonumber(gmcp("char.status.level"))
end end
end end
end end
@ -525,13 +570,17 @@ end
function OnPluginInstall() function OnPluginInstall()
OnPluginEnable() OnPluginEnable()
end end
function OnPluginEnable() function OnPluginEnable()
local settings = GetVariable("PKSettings") local settings = GetVariable("PKSettings")
if settings and settings ~= "" then if settings and settings ~= "" then
assert(loadstring("PKASettings = "..GetVariable("PKSettings"))) () assert(loadstring("PKASettings = "..GetVariable("PKSettings"))) ()
end end
end
if PKASettings.levelrange == nil then PKASettings.levelrange = defLevelRange end
Send_GMCP_Packet("request char")
end
function OnHelp () function OnHelp ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3)) world.Note (world.GetPluginInfo (world.GetPluginID (), 3))

Loading…
Cancel
Save