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.

184 lines
4.5 KiB

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on niedziela, listopad 17, 2013, 5:54 -->
<!-- MuClient version 4.89 -->
<!-- Plugin "AreaChanger" generated by Plugin Wizard -->
<muclient>
<plugin
name="EnemyPercentReporter"
author="Icecool"
id="5860abf62293b73e2fc34712"
language="Lua"
purpose="Script to report Room Number and Enemy HP Percent"
date_written="2021-09-10 00:00:00"
version="1.0"
>
</plugin>
<triggers>
</triggers>
<aliases>
<alias
match="mprep" script="announceMobPercent"
keep_evaluating="y"
enabled="y"
regexp="n"
send_to="12"
sequence="100"
ignore_case = "y"
>
</alias>
</aliases>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<script>
<![CDATA[
dofile(GetInfo(60) .. "aardwolf_colors.lua") -- Used to support Aard Colors for the eprint() function
--[[ Plugin ID Variables ]]--
require 'gmcphelper'
plugin_ids = {
["gmcp_plugin"] = "3e7dedbe37e44942dd46d264"
}
--[[Global Plugin Variables]]--
plugin_state = {
ENABLED = false,
DEBUG = false,
channels = { "gtell" }
}
plugin_configs = {
channel = "gt",
prepend = "@D[@x166Enemy HP%@D]:@w"
}
--[[ Plugin State Functions ]]--
function isEnabled()
return plugin_state.ENABLED
end
function isDebug()
return plugin_state.DEBUG
end
--[[ Plugin Configs commands ]]--
function getPrepend()
return plugin_configs.prepend
end
function getChannel()
return plugin_configs.channel
end
--[[ Utility Functions ]]--
function cnote(string)
AnsiNote(stylesToANSI(ColoursToStyles(string)))
end
function dnote(string)
if isDebug() then
cnote( "@r[@RDEBUG@r]: @w" .. string )
end
end
function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
function Split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, trim(match));
end
return result;
end
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
--[[ GMCP Functions ]]--
function getGMCPPluginID()
return plugin_ids.gmcp_plugin
end
function isGMCP(arg)
return getGMCPPluginID() == arg
end
function isGMCPCommChannel(arg)
return arg == "comm.channel"
end
function checkGMCPValue(key)
local result, value = CallPlugin(getGMCPPluginID(),"gmcpval", key)
return value
end
function getZone()
return checkGMCPValue("room.info.zone")
end
function isLeader()
return checkGMCPValue("group.leader") == checkGMCPValue("char.base.name")
end
function isFighting()
return checkGMCPValue("char.status.state") == "8"
end
function getEnemyName()
return checkGMCPValue("char.status.enemy")
end
function getEnemyPercent()
return tonumber(checkGMCPValue("char.status.enemypct"))
end
function getRoomID()
return tonumber(checkGMCPValue("room.info.num"))
end
--[[ Check if channel is in White List ]]--
function isValidChannel(chan)
for index, value in pairs(plugin_state.channels) do
if value == chan then
return true
end
end
return false
end
function processMobPercentRequest(arg)
dnote(("%s processMobPercentRequest(%s)"):format(getPrepend(), arg))
local request_pattern = "^.+ %a+: %'(!PERCENT)%'$"
_a, _b, processed_pattern = string.find(arg:upper(), request_pattern)
if _a and string.match(request_pattern, processed_pattern) then
if isFighting() then
announceMobPercent()
end
else
dnote(("%s processMobPercentRequest() called and failed to find a match."):format(getPrepend()))
end
end
function announceMobPercent()
if isFighting() then
local mpmsg = ""
local percent = getEnemyPercent()
if percent > 40 then
mpmsg = ("@G%s"):format(getEnemyPercent())
elseif percent > 20 and percent <= 40 then
mpmsg = ("@Y%s"):format(getEnemyPercent())
elseif percent <= 20 then
mpmsg = ("@R%s"):format(getEnemyPercent())
end
Send(("%s %s @D[@WRoom %d@D]@w %s is at @R%s%%@w"):format(getChannel(), getPrepend(), getRoomID(), getEnemyName(), mpmsg))
end
end
--[[ Mushclient Plugin Functions ]]--
--[[
-- OnPluginLineReceived(s) is not in use for this plugin, commented out for now....
function OnPluginLineReceived(s)
end
]]--
function OnPluginBroadcast(msg, id, name, text)
if isGMCP(id) and isGMCPCommChannel(text) then
local comm_chan = gmcp('comm.channel.chan')
if isValidChannel(comm_chan) then
local chan_msg = strip_colours(gmcp('comm.channel.msg'))
processMobPercentRequest(chan_msg)
end
end
end
function OnPluginEnable()
end
function OnPluginInstall()
OnPluginEnable()
end
]]>
</script>
</muclient>