<?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="eprep" script="announceMobPercent"
keep_evaluating="y"
enabled="y"
regexp="n"
send_to="12"
sequence="100"
ignore_case = "y"
>
</alias>
<alias
match="eptoggle" script="toggleMobPercent"
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 = true,
DEBUG = false,
channels = { "gtell" }
}
plugin_configs = {
channel = "gt",
prepend = "@D[@x166HP%@D]:@w"
}
--[[ Plugin State Functions ]]--
function isEnabled()
return plugin_state.ENABLED
end
function toggleEnabled()
plugin_state.ENABLED = not 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(name)
return string.lower(checkGMCPValue("group.leader")) == string.lower(name)
end
function isIcecool(name)
return string.lower(name) == "icecool"
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 not isEnabled() then
cnote(("%s @wis @Rdisabled@w. Please use the '@Yeptoggle@w' command to enable before attempting to announce the enemy percentage."):format(getPrepend()))
end
if isFighting() and isEnabled() 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
if string.lower(getZone()) == "transcend" then
if getEnemyName() == "Void Trooper" then
Send(("%s %s [@WRoom %d] @R---> @W%s @R<--- @ w " ) : f o r m a t ( g e t C h a n n e l ( ) , g e t P r e p e n d ( ) , g e t R o o m I D ( ) , g e t E n e m y N a m e ( ) ) )
elseif getEnemyName() == "Void Guardian" then
Send(("%s %s @D[@WRoom %d@D]@w %s is at @R%s%%@w"):format(getChannel(), getPrepend(), getRoomID(), getEnemyName(), mpmsg))
end
else
Send(("%s %s @D[@WRoom %d@D]@w %s is at @R%s%%@w"):format(getChannel(), getPrepend(), getRoomID(), getEnemyName(), mpmsg))
end
end
end
function toggleMobPercent()
toggleEnabled()
cnote(("%s @Wis now %s@w"):format(getPrepend(), isEnabled() and "@Genabled@w" or "@Rdisabled@w"))
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')
local comm_player = gmcp('comm.channel.player')
if isValidChannel(comm_chan) and isEnabled() and (isLeader(comm_player) or isIcecool(comm_player)) then
local chan_msg = strip_colours(gmcp('comm.channel.msg'))
processMobPercentRequest(chan_msg)
end
end
end
function OnPluginEnable()
cnote(("@GEnemyPercentReporter Plugin"))
cnote(("@W----------------------------------------"))
cnote(("@RCommands:@w"))
cnote(("@W eprep@w -- Manual report"))
cnote(("@W eptoggle@w -- toggles script on/off"))
Note()
end
function OnPluginInstall()
OnPluginEnable()
end
]]>
</script>
</muclient>