📄 roguestunhelper.lua
字号:
local glimRogueStunHelper;
function RSHprint(text)
if RSH_Debug==1 then
DEFAULT_CHAT_FRAME:AddMessage(text);
end
end
function RSH_OnLoad()
RSH_Debug = 0;
this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE");
this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE");
this:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_OTHER");
this:RegisterEvent("CHAT_MSG_SPELL_BREAK_AURA");
this:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE");
this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("PLAYER_ENTERING_WORLD");
this:RegisterEvent("PLAYER_COMBO_POINTS");
this:RegisterEvent("PLAYER_ENTER_COMBAT");
SLASH_ROGUESTUNHELPER1 = "/roguestunhelper";
SLASH_ROGUESTUNHELPER2 = "/rsh";
SlashCmdList["ROGUESTUNHELPER"] = function(msg)
RSH_SlashCommandHandler(msg);
end
end
function RSH_SlashCommandHandler(msg)
if( msg ) then
local command = string.lower(msg);
if( command == "on" ) then
if ( RSH_STATUS == 0 ) then
RSH_STATUS = 1;
RSH_Save.status = RSH_STATUS;
DEFAULT_CHAT_FRAME:AddMessage(RSH_CHAT_MSG1);
end
elseif ( command == "off" ) then
if ( RSH_STATUS ~= 0 ) then
RSH_STATUS = 0;
RSH_Save.status = RSH_STATUS;
DEFAULT_CHAT_FRAME:AddMessage(RSH_CHAT_MSG2);
end
elseif ( command == "unlock" ) then
RSH_STATUS = 3;
RogueStunHelper1:Show();
RogueStunHelper2:Show();
elseif ( command == "lock" ) then
RSH_STATUS = 1;
RogueStunHelper1:Hide();
RogueStunHelper2:Hide();
elseif ( command == "clear" ) then
RSH_Save = nil;
RSH_STATUS = 0;
RSH_LoadVariables();
elseif ( command == "list" ) then
RSH_Init_Duration();
DEFAULT_CHAT_FRAME:AddMessage(RSH_HELP1);
DEFAULT_CHAT_FRAME:AddMessage(RSH_Skill_Distract.." ( "..RSH[RSH_Skill_Distract]..RSH_CHAT_MSG3);
RSH_Init_Sap();
if RSH[RSH_Skill_Sap] ~= nil then
DEFAULT_CHAT_FRAME:AddMessage(RSH_Skill_Sap.." ( "..RSH[RSH_Skill_Sap]..RSH_CHAT_MSG3);
end
DEFAULT_CHAT_FRAME:AddMessage(RSH_Skill_Blind.." ( "..RSH[RSH_Skill_Blind]..RSH_CHAT_MSG3);
DEFAULT_CHAT_FRAME:AddMessage(RSH_Skill_CheapShot.." ( "..RSH[RSH_Skill_CheapShot]..RSH_CHAT_MSG3);
RSH_Init_Gouge();
DEFAULT_CHAT_FRAME:AddMessage(RSH_Skill_Gouge.." ( "..RSH[RSH_Skill_Gouge]..RSH_CHAT_MSG3);
RSH_Init_KS();
if RSH[RSH_Skill_KidneyShot]~=nil then
DEFAULT_CHAT_FRAME:AddMessage(RSH_Skill_KidneyShot.." ( "..RSH[RSH_Skill_KidneyShot]..RSH_CHAT_MSG4);
end
else
DEFAULT_CHAT_FRAME:AddMessage(RSH_HELP1);
DEFAULT_CHAT_FRAME:AddMessage(RSH_HELP2);
DEFAULT_CHAT_FRAME:AddMessage(RSH_HELP3);
DEFAULT_CHAT_FRAME:AddMessage(RSH_HELP4);
end
end
end
function RSH_OnEvent()
if ( RSH_STATUS == 0 ) then
return;
end
if ( event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE"
or event == "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE" ) then
-- Sap, CheapShot, Gouge, KidneyShot et Blind sont des attaques directes contre une cible
for mobname,spell in string.gfind(arg1, RSH_TEXT_ON) do
RSH_StartSkill(spell,mobname,GetTime());
end
elseif ( event == "CHAT_MSG_SPELL_SELF_DAMAGE" ) then
-- Distract est une attaque "sans cible"
for spell in string.gfind(arg1, RSH_TEXT2_ON) do
RSH_StartSkill(spell,"",GetTime());
end
elseif ( event == "PLAYER_ENTER_COMBAT" ) then
if ( RSH2_SPELL ~= nil and RSH2_SPELL == RSH_Skill_Distract ) then
RSH2_TIMER_END = GetTime();
end
elseif ( event == "CHAT_MSG_SPELL_BREAK_AURA" ) then
for mobname,spell in string.gfind(arg1, RSH_TEXT_BREAK) do
RSH_StopSkill(spell,GetTime());
end
elseif ( event == "CHAT_MSG_SPELL_AURA_GONE_OTHER" ) then
for spell,mobname in string.gfind(arg1, RSH_TEXT_OFF) do
RSH_StopSkill(spell,GetTime());
end
elseif (event == "PLAYER_COMBO_POINTS") then
RSHComboPointOld = RSHComboPoint;
RSHComboPoint = GetComboPoints();
elseif (event == "VARIABLES_LOADED" ) then
RSH_LoadVariables();
RogueStunHelper_Register();
glimRogueStunHelper = RSH_STATUS;
elseif (event == "PLAYER_ENTERING_WORLD" ) then
local lcl,uscl = UnitClass("player");
if (uscl ~= "ROGUE") then
this:UnregisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE");
this:UnregisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE");
this:UnregisterEvent("CHAT_MSG_SPELL_AURA_GONE_OTHER");
this:UnregisterEvent("CHAT_MSG_SPELL_BREAK_AURA");
this:UnregisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE");
this:UnregisterEvent("VARIABLES_LOADED");
this:UnregisterEvent("PLAYER_ENTERING_WORLD");
this:UnregisterEvent("PLAYER_COMBO_POINTS");
this:UnregisterEvent("PLAYER_ENTER_COMBAT");
RSH_STATUS=0;
--DEFAULT_CHAT_FRAME:AddMessage(RSH_CHAT_MSG2);
else
RSH_Init_Duration();
end
end
end
function RSH_StartSkill(RSHspell,RSHmobname,RSHstart)
if ( RSHspell == RSH_Skill_Distract ) then
RSH2_SPELL = RSHspell;
RSH2_TIMER_START = RSHstart;
RSH2_TIMER_END = RSH2_TIMER_START + RSH[RSHspell];
RSH2_MOBNAME = RSHspell;
RogueStunHelper2:SetAlpha(1);
RogueStunHelper2:Show();
elseif ( RSHspell == RSH_Skill_Sap ) then
RSH_Init_Sap();
RSH2_SPELL = RSHspell;
RSH2_TIMER_START = RSHstart;
RSH2_TIMER_END = RSH2_TIMER_START + RSH[RSHspell];
RSH2_MOBNAME = RSHspell.." "..RSHmobname;
RogueStunHelper2:SetAlpha(1);
RogueStunHelper2:Show();
elseif ( RSHspell == RSH_Skill_CheapShot or RSHspell == RSH_Skill_Gouge or RSHspell == RSH_Skill_Blind ) then
RSH_Init_Gouge();
RSH1_SPELL = RSHspell;
RSH1_Spell_Text = RSHspell
RSH1_TIMER_START = RSHstart;
RSH1_TIMER_END = RSH1_TIMER_START + RSH[RSHspell];
RSH1_MOBNAME = RSHspell.." "..RSHmobname;
RogueStunHelper1:SetAlpha(1);
RogueStunHelper1:Show();
elseif ( RSHspell == RSH_Skill_KidneyShot ) then
RSH_Init_KS();
RSH1_SPELL = RSHspell;
RSH1_Spell_Text = RSHspell
RSH1_TIMER_START = RSHstart;
RSH1_TIMER_END = RSH1_TIMER_START + RSH[RSHspell] + RSHComboPointOld;
RSH1_MOBNAME = RSHspell.." "..RSHmobname;
RogueStunHelper1:SetAlpha(1);
RogueStunHelper1:Show();
end
end
function RSH_StopSkill(RSHspell,RSHend)
if ( RSHspell == RSH_Skill_Distract or RSHspell == RSH_Skill_Sap ) then
RSH2_TIMER_END = RSHend;
elseif ( RSHspell == RSH_Skill_CheapShot or RSHspell == RSH_Skill_Gouge or RSHspell == RSH_Skill_KidneyShot or RSHspell == RSH_Skill_Blind ) then
RSH1_TIMER_END = RSHend;
end
end
function RSH1_OnShow()
if (RSH_STATUS ~= 3) then
RSH_STATUS = 2;
end
this:SetAlpha(1);
RogueStunHelperFrameStatusBar1:SetStatusBarColor(1, 1, 0);
RogueStunHelperSpark1:SetPoint("CENTER", "RogueStunHelperFrameStatusBar1", "LEFT", 0, 0);
if ( RSH1_MOBNAME == nil or RSH1_MOBNAME == "" ) then
RogueStunHelperText1:SetText(RSH_HELP1.."1");
else
RogueStunHelperText1:SetText(RSH1_MOBNAME);
end
end
function RSH2_OnShow()
if (RSH_STATUS ~= 3) then
RSH_STATUS = 2;
end
this:SetAlpha(1);
RogueStunHelperFrameStatusBar2:SetStatusBarColor(1, 1, 0);
RogueStunHelperSpark2:SetPoint("CENTER", "RogueStunHelperFrameStatusBar2", "LEFT", 0, 0);
if ( RSH2_MOBNAME == nil or RSH2_MOBNAME == "" ) then
RogueStunHelperText2:SetText(RSH_HELP1.."2");
else
RogueStunHelperText2:SetText(RSH2_MOBNAME);
end
end
function RSH1_OnUpdate()
if (RSH_STATUS == 3) then
return nil;
end
local Status = GetTime();
-- Si on est avant la fin du timer
if (Status <= RSH1_TIMER_END) then
RogueStunHelperText1:SetText(RSH1_Spell_Text.." (|cFF00FF00"..UnitMana("player").."|r/|cFFFF50FF"..UnitManaMax("player").."|r)");
local sparkPosition = ((Status - RSH1_TIMER_START) / (RSH1_TIMER_END - RSH1_TIMER_START)) * 195;
RogueStunHelperFrameStatusBar1:SetMinMaxValues(RSH1_TIMER_START, RSH1_TIMER_END);
RogueStunHelperFrameStatusBar1:SetValue(GetTime());
if ( Status > RSH1_TIMER_END - 0.5 ) then
RogueStunHelperFrameStatusBar1:SetStatusBarColor(1, 0, 0);
elseif ( Status > RSH1_TIMER_END - 1 ) then
RogueStunHelperFrameStatusBar1:SetStatusBarColor(1, 0.5, 0);
end
if ( sparkPosition < 0 ) then
sparkPosition = 0;
end
RogueStunHelperSpark1:SetPoint("CENTER", "RogueStunHelperFrameStatusBar1", "LEFT", sparkPosition, 0);
elseif ( this:GetAlpha() > 0 ) then
if ( RSH_STATUS == 2 ) then
RogueStunHelperText1:SetText(RSH_TEXT_TIMEOUT);
end
local alpha = this:GetAlpha() - RSH_ALPHA_STEP;
if ( alpha > 0 ) then
this:SetAlpha(alpha);
else
this.fadeOut = nil;
this:Hide();
end
-- Au cas ou le FadeOut arrive ici
else
RSH1_SPELL = "";
RSH1_Spell_Text = "";
RSH1_MOBNAME = "";
this:Hide();
end
if ( RogueStunHelper1:IsVisible() or RogueStunHelper2:IsVisible() ) then
-- nothing
else
RSH_STATUS = 1;
end
end
function RSH2_OnUpdate()
if (RSH_STATUS == 3) then
return nil;
end
local Status = GetTime();
-- Si on est avant la fin du timer
if (Status <= RSH2_TIMER_END) then
RogueStunHelperText2:SetText(RSH2_MOBNAME);
local sparkPosition = ((Status - RSH2_TIMER_START) / (RSH2_TIMER_END - RSH2_TIMER_START)) * 195;
RogueStunHelperFrameStatusBar2:SetMinMaxValues(RSH2_TIMER_START, RSH2_TIMER_END);
RogueStunHelperFrameStatusBar2:SetValue(GetTime());
if ( Status > RSH2_TIMER_END - 0.5 ) then
RogueStunHelperFrameStatusBar2:SetStatusBarColor(1, 0, 0);
elseif ( Status > RSH2_TIMER_END - 1 ) then
RogueStunHelperFrameStatusBar2:SetStatusBarColor(1, 0.5, 0);
end
if ( sparkPosition < 0 ) then
sparkPosition = 0;
end
RogueStunHelperSpark2:SetPoint("CENTER", "RogueStunHelperFrameStatusBar2", "LEFT", sparkPosition, 0);
elseif ( this:GetAlpha() > 0 ) then
if ( RSH_STATUS == 2 ) then
RogueStunHelperText2:SetText(RSH_TEXT_TIMEOUT);
end
local alpha = this:GetAlpha() - RSH_ALPHA_STEP;
if ( alpha > 0 ) then
this:SetAlpha(alpha);
else
this.fadeOut = nil;
this:Hide();
end
-- Au cas ou le FadeOut arrive ici
else
RSH2_SPELL = "";
RSH2_Spell_Text = "";
RSH2_MOBNAME = "";
this:Hide();
end
if ( RogueStunHelper1:IsVisible() or RogueStunHelper2:IsVisible() ) then
-- nothing
else
RSH_STATUS = 1;
end
end
function RSH_LoadVariables()
if not RSH_Save then
RSH_Save = {};
RSH_Save.status = 1;
end
RSH_STATUS = RSH_Save.status;
end
function RSH_Init_Duration()
RSH = {};
-- Init de Cheap Shot (facile, 4sec tout le temps)
RSH[RSH_Skill_CheapShot] = 4;
-- Init de Distract (facile, 10sec tout le temps, peut casser avant, mais on s'en fout)
RSH[RSH_Skill_Distract] = 10;
-- Init de Blind (facile, 10sec tout le temps, peut casser avant, mais on s'en fout, comme pour Distract ^_^)
RSH[RSH_Skill_Blind] = 10;
RSH_ALPHA_STEP = 0.2;
end
function RSH_Init_Gouge()
-- Init de Gouge (4sec + 0.5sec par point de talent)
RSH[RSH_Skill_Gouge] = 4
local _, texture, _, _, rank, _, _, _ = GetTalentInfo( 2, 1 );
if rank then
RSH[RSH_Skill_Gouge] = 4 + rank*0.5;
end
end
function RSH_Init_Sap()
local i = 1;
while true do
local spellName, spellRank = GetSpellName(i, BOOKTYPE_SPELL);
if not spellName then
do break end;
end
if (spellName == RSH_Skill_Sap) then
for text,rank in string.gfind(spellRank, "(.+) (%d+)") do
RSH[RSH_Skill_Sap] = 15 + 10*tonumber(rank);
end
do break end;
end
i = i + 1;
end
end
function RSH_Init_KS()
i = 1;
while true do
local spellName, spellRank = GetSpellName(i, BOOKTYPE_SPELL);
if not spellName then
do break end;
end
if (spellName == RSH_Skill_KidneyShot) then
for text,rank in string.gfind(spellRank, "(.+) (%d+)") do
RSH[RSH_Skill_KidneyShot] = rank - 1;
end
do break end;
end
i = i + 1;
end
end
-- local name, texture, line, column, rank, maxrank, TalentGiveSkill?, 1 = GetTalentInfo( 2, 1 );
--glim reg
local GLIMRogueStunHelper_WINDOW_TEXT = "盗贼助手";
local RogueStunHelperENABLE_WINDOW_DISPLAY_INFO = "设置是否开启盗贼助手";
local RogueStunHelperENABLE_WINDOW_DISPLAY = "开启盗贼助手";
local RogueCONTROLENABLE_WINDOW_DISPLAY_INFO = "选中时才会开启盗贼助手";
local RogueCONTROLENABLE_WINDOW_DISPLAY = "开启盗贼助手";
local function glimRogueStunHelperEnable(toggle)
if (toggle == 1 ) then
RSH_STATUS = 1;
RSH_Save.status = RSH_STATUS;
DEFAULT_CHAT_FRAME:AddMessage(RSH_CHAT_MSG1);
else
RSH_STATUS = 0;
RSH_Save.status = RSH_STATUS;
DEFAULT_CHAT_FRAME:AddMessage(RSH_CHAT_MSG2);
end
end
function RogueStunHelper_Register()
gLim_RegisterButton (
"RogueStunHelper",
"盗贼助手",
"Interface\\AddOns\\RogueStunHelper\\Icon",
function()
gLimModSecBookShowConfig("gLimRogueStunHelper");
end,
2,
7
);
gLim_RegisterConfigClass("gLimRogueStunHelper","RogueStunHelper","Pigbaby");
gLim_RegisterConfigSection(
"gLimRogueStunHelperSection",
GLIMRogueStunHelper_WINDOW_TEXT,
GLIMRogueStunHelper_WINDOW_TEXT.." 最后修改自 Pigbaby",
GLIMRogueStunHelper_WINDOW_TEXT,"gLimRogueStunHelper");
gLim_RegisterConfigCheckBox(
"gLim_RogueStunHelper_Enable",
RogueCONTROLENABLE_WINDOW_DISPLAY,
RogueCONTROLENABLE_WINDOW_DISPLAY_INFO,
glimRogueStunHelper,
glimRogueStunHelperEnable,
"gLimRogueStunHelper"
);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -