You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
308 lines
8.7 KiB
308 lines
8.7 KiB
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!DOCTYPE muclient>
|
|
<!-- Saved on Thursday, December 29, 2016, 11:46 PM -->
|
|
<!-- MuClient version 0.00 -->
|
|
<muclient>
|
|
<plugin
|
|
name="MobChecker"
|
|
author="Icecool"
|
|
id="611bda96cef62a9aeec67074"
|
|
language="Lua"
|
|
purpose="Check mob's existance on tick"
|
|
date_written="2021-08-26 00:00:00"
|
|
save_state="n"
|
|
requires="0.00"
|
|
version="1.00"
|
|
>
|
|
</plugin>
|
|
|
|
<aliases>
|
|
<alias
|
|
enabled="y" regexp="y" keep_evaluating="y" send_to="12" name="add_MobName" sequence="100"
|
|
script="aliasAddMobName"
|
|
match="^mc add (?<mob_name>.+)$"
|
|
> </alias>
|
|
<alias
|
|
enabled="y" regexp="y" keep_evaluating="y" send_to="12" name="update_SocialCommand" sequence="100"
|
|
script="aliasUpdateSocialCommand"
|
|
match="^mc social (?<social>.+)$"
|
|
> </alias>
|
|
<alias
|
|
enabled="y" regexp="y" keep_evaluating="y" send_to="12" name="update_ChannelCommand" sequence="100"
|
|
script="aliasUpdateChannelCommand"
|
|
match="^mc channel (?<channel>.+)$"
|
|
> </alias>
|
|
<alias
|
|
enabled="y" regexp="y" keep_evaluating="y" send_to="12" name="ShowHelp" sequence="100"
|
|
script="aliasShowHelp"
|
|
match="^mc(\s+)?help$"
|
|
> </alias>
|
|
|
|
</aliases>
|
|
|
|
<triggers>
|
|
</triggers>
|
|
|
|
<!-- Get our standard constants -->
|
|
|
|
<include name="constants.lua"/>
|
|
|
|
<!-- Script -->
|
|
<script>
|
|
<![CDATA[
|
|
dofile(GetInfo(60) .. "aardwolf_colors.lua") -- Used to support Aard Colors for the eprint() function
|
|
require 'gmcphelper'
|
|
GMCPPluginID = "3e7dedbe37e44942dd46d264"
|
|
|
|
plugin_state = {
|
|
DEBUG = false,
|
|
ENABLED = false,
|
|
PREPEND = "@D[@RMobChecker@D]:@w"
|
|
}
|
|
-- default 'MobChecker' usage items
|
|
mc_config = {
|
|
channel="gt",
|
|
social="prod",
|
|
max_column=72
|
|
}
|
|
mobs = {
|
|
}
|
|
socials = {
|
|
"prod",
|
|
"slap",
|
|
"fakebs",
|
|
"sdropkick"
|
|
}
|
|
social_lines = {
|
|
{ match = "^.+ You prod (.*) into action!$" },
|
|
{ match = "^.+ You slap (.*).$" },
|
|
{ match = "^.+ You backstab (.*) with your fake dagger!$"},
|
|
{ match = "^.+ You tear off (.*) head and dropkick it into a lake.$" }
|
|
}
|
|
-- Channels White List
|
|
channels = {
|
|
"gtell",
|
|
"spouse"
|
|
}
|
|
|
|
--[[ GMCP Check Functions ]]--
|
|
function isGMCP(id)
|
|
return id == GMCPPluginID
|
|
end
|
|
function isTick(arg)
|
|
return arg == "comm.tick"
|
|
end
|
|
function isChannel(arg)
|
|
return arg == "comm.channel"
|
|
end
|
|
--[[ Plugin State functions ]]--
|
|
function isEnabled()
|
|
return plugin_state.ENABLED
|
|
end
|
|
function enablePlugin()
|
|
plugin_state.ENABLED = true
|
|
end
|
|
function disablePlugin()
|
|
plugin_state.ENABLED = false
|
|
end
|
|
function isDebug()
|
|
return plugin_state.DEBUG
|
|
end
|
|
function getPrepend()
|
|
return plugin_state.PREPEND
|
|
end
|
|
|
|
function getConfigChannel()
|
|
return mc_config.channel
|
|
end
|
|
function getConfigSocial()
|
|
return mc_config.social
|
|
end
|
|
function getConfigMaxColumn()
|
|
return tonumber(mc_config.max_column)
|
|
end
|
|
function setConfigSocial(arg)
|
|
mc_config.social = arg:lower()
|
|
cnote(("%s @wUpdated MobChecker to use '@G%s@w' for the social when checking mobs."):format(getPrepend(), getConfigSocial()))
|
|
end
|
|
function setConfigChannel(arg)
|
|
mc_config.channel = arg:lower()
|
|
cnote(("%s @wUpdated MobChecker to use '@G%s@w' for the channel when checking mobs."):format(getPrepend(), getConfigChannel()))
|
|
end
|
|
--[[ Note functions for coloring lines and debugging ]]--
|
|
function cnote(string)
|
|
AnsiNote(stylesToANSI(ColoursToStyles(string)))
|
|
end
|
|
function dnote(string)
|
|
if isDebug() then
|
|
cnote( "@r[@RDEBUG@r]: @w" .. string )
|
|
end
|
|
end
|
|
-- This string.split works like MUSHclient's utils.split, but allows
|
|
-- any pattern and also allows you to preserve the pattern match entities.
|
|
function string.split(self, pat, add_pattern_matches_to_result, max_matches)
|
|
local fields = {}
|
|
local start = 1
|
|
local match_times = 0
|
|
self:gsub("()("..pat..")",
|
|
function(index,match)
|
|
if max_matches == nil or max_matches > match_times then
|
|
table.insert(fields, self:sub(start,index-1))
|
|
if add_pattern_matches_to_result then
|
|
table.insert(fields, match)
|
|
end
|
|
start = index + #match
|
|
match_times = match_times + 1
|
|
end
|
|
end
|
|
)
|
|
table.insert(fields, self:sub(start))
|
|
return fields
|
|
end
|
|
function returnCenterPad(arg)
|
|
local pad_length = math.floor((getConfigMaxColumn()-tonumber(string.len(arg)))/2)
|
|
return tonumber(pad_length)
|
|
end
|
|
-- Utility function to return length of a table
|
|
function tablelength(T)
|
|
local count = 0
|
|
for _ in pairs(T) do count = count + 1 end
|
|
return count
|
|
end
|
|
|
|
--[[ Mob Check Functions ]]--
|
|
function isMobMatch(mob)
|
|
-- Fiendish help supply code to make this function work. Thank you, sir! 08/28/2021 [debt paid with an Aard Public Vote]
|
|
mob_split = mob:split("%W+")
|
|
for index, value in ipairs(mob_split) do
|
|
if mobs[value] then
|
|
target = value
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
function addMob(arg)
|
|
if isMobMatch(arg) then
|
|
cnote(("%s @w'@G%s@w' already exists in the MobChecker's mob list."):format(getPrepend(),arg))
|
|
return
|
|
end
|
|
mobs[arg] = true
|
|
cnote(("%s Added @w'@G%s@w' to MobChecker's mob list."):format(getPrepend(),arg))
|
|
end
|
|
function removeMob(arg)
|
|
if isMobMatch(arg) then
|
|
mobs[arg] = nil
|
|
cnote(("%s @w'@G%s@w' is alive! If you want to check for '@G%s@w' again, please add to the mob list."):format(getPrepend(),arg, arg))
|
|
else
|
|
dnote(("%s %s was not found. Could not remove from the mobs table"):format(getPrepend(), arg))
|
|
end
|
|
end
|
|
-- Check if channel is in White List
|
|
function isValidChannel(chan)
|
|
for index, value in pairs(channels) do
|
|
if value == chan then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
function isValidSocial(soc)
|
|
for index, value in pairs(socials) do
|
|
if value == soc:lower() then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
function isSocialMatch(arg)
|
|
for i, v in ipairs(social_lines) do
|
|
is_match, _b, target = string.find(arg, v.match)
|
|
if is_match then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
function checkMobs()
|
|
if tablelength(mobs) > 0 then
|
|
for i, v in pairs(mobs) do
|
|
Send(("%s *%s %s"):format(getConfigChannel(), getConfigSocial(), i))
|
|
end
|
|
elseif tablelength(mobs) == 0 then
|
|
dnote(("%s No mobs in queue."):format(getPrepend()))
|
|
end
|
|
end
|
|
|
|
function aliasAddMobName(name,line,args)
|
|
addMob(args.mob_name)
|
|
dnote(("%s Table Data: @Gmobs(@w%d@G) social_lines(@w%d@G)@w"):format(getPrepend(), tablelength(mobs), #social_lines))
|
|
end
|
|
function aliasUpdateSocialCommand(name,line,args)
|
|
if isValidSocial(args.social) then
|
|
setConfigSocial(args.social)
|
|
else
|
|
local msg = ""
|
|
cnote(("%s %s is not a valid social for this plugin."):format(getPrepend(), args.social:lower()))
|
|
for index, value in pairs(socials) do
|
|
msg = ("%s%s "):format(msg, value)
|
|
end
|
|
cnote(("%s @wValid socials are:@G %s@w"):format(getPrepend(), msg))
|
|
end
|
|
end
|
|
function aliasUpdateChannelCommand(name,line,args)
|
|
if isValidChannel(args.channel) then
|
|
setConfigChannel(args.channel)
|
|
else
|
|
local msg = ""
|
|
cnote(("%s %s is not a valid channel for this plugin."):format(getPrepend(), args.channel:lower()))
|
|
for index, value in pairs(channels) do
|
|
msg = ("%s%s "):format(msg, value)
|
|
end
|
|
cnote(("%s @wValid channels are:@G %s@w"):format(getPrepend(), msg))
|
|
end
|
|
end
|
|
|
|
function aliasShowHelp()
|
|
local name = "Mob Checker"
|
|
local pad_length = returnCenterPad(name)
|
|
|
|
cnote(("@w%s@w"):format(string.rep("-", getConfigMaxColumn())))
|
|
cnote(("%s@G%s@w"):format(string.rep(" ", pad_length), name))
|
|
cnote(("@w%s@w"):format(string.rep("-", getConfigMaxColumn())))
|
|
cnote(("@RSyntax:@w"))
|
|
cnote(("@w @Cmc help@w - This menu"))
|
|
cnote(("@w @Cmc add @w<mob_name> - Adds a mob to the checker list"))
|
|
cnote(("@w @Cmc social @w<social_name> - Updates the social used in the script"))
|
|
cnote(("@w @Cmc channel @w<channel_name> - Updates the channel used in the script"))
|
|
cnote(("@w%s@w"):format(string.rep("-", getConfigMaxColumn())))
|
|
cnote(("%s@G%s@w"):format(string.rep(" ", pad_length), name))
|
|
cnote(("@w%s@w"):format(string.rep("-", getConfigMaxColumn())))
|
|
end
|
|
-- check for tick and send mob checker function
|
|
function OnPluginBroadcast (msg, id, name, text)
|
|
if isGMCP(id) and isTick(text) then
|
|
checkMobs()
|
|
end
|
|
if isGMCP(id) and isChannel(text) then
|
|
local commchan = gmcp('comm.channel.chan'):lower()
|
|
local msg, player = strip_colours(gmcp('comm.channel.msg')), gmcp('comm.channel.player')
|
|
if isValidChannel(commchan) and player == gmcp('char.base.name') then
|
|
if isSocialMatch(msg) and isMobMatch(target) then
|
|
dnote(("%s %s Target mob matches!"):format(getPrepend(), target))
|
|
removeMob(target)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function OnPluginInstall()
|
|
dnote(("%s Table Data: @Gmobs(@w%d@G) social_lines(@w%d@G)@w"):format(getPrepend(), tablelength(mobs), #social_lines))
|
|
aliasShowHelp()
|
|
end
|
|
|
|
]]>
|
|
|
|
</script>
|
|
</muclient>
|