• 0

    posted a message on dgks - dG KillShot notifier
    freaking Useless
    Posted in: General AddOns
  • 0

    posted a message on dgks - dG KillShot notifier
    anyone?
    Posted in: General AddOns
  • 0

    posted a message on dgks - dG KillShot notifier
    i also tried to edit the coding for my own liking but what i did makes the mod not work at all... anyone see the problems...?


    -----------------------
    -- PRIVATE CONSTANTS --
    -----------------------

    -- Edit these to adjust killingstreak ranks --
    KSRANK1 = 1;
    KSRANK2 = 2;
    KSRANK3 = 4;
    KSRANK4 = 8;
    KSRANK5 = 12;
    KSRANK6 = 15;
    KSRANK7 = 17;
    KSRANK8 = 19;
    KSRANK9 = 21;
    KSRANK10 = 23;
    KSRANK11 = 25;
    KSRANK12 = 27:
    KSRANK13 = 30;
    -- End of editable killing streak ranks --

    -- Sound Files
    KSSOUND1 = "Interface\\AddOns\\dgks\\sounds\\firstblood.mp3";
    KSSOUND2 = "Interface\\AddOns\\dgks\\sounds\\ohyeah.mp3";
    KSSOUND3 = "Interface\\Addons\\dgks\\sounds\\ownage.mp3";
    KSSOUND4 = "Interface\\AddOns\\dgks\\sounds\\killingspree.mp3";
    KSSOUND5 = "Interface\\AddOns\\dgks\\sounds\\dominating.mp3";
    KSSOUND6 = "Interface\\AddOns\\dgks\\sounds\\unstoppable.mp3";
    KSSOUND7 = "Interface\\AddOns\\dgks\\sounds\\rampage.mp3";
    KSSOUND8 = "Interface\\AddOns\\dgks\\sounds\\monsterkill.mp3";
    KSSOUND9 = "Interface\\AddOns\\dgks\\sounds\\godlike.mp3";
    KSSOUND10 = "Interface\\AddOns\\dgks\\sounds\\ludicrouskill.mp3";
    KSSOUND11 = "Interface\\AddOns\\dgks\\sounds\\whickedsick.mp3";
    KSSOUND12 = "Interface\\AddOns\\dgks\\sounds\\humiliation.mp3";
    KSSOUND13 = "Interface\\AddOns\\dgks\\sounds\\haleluya.mp3";
    KSSOUNDM1 = "Interface\\AddOns\\dgks\\sounds\\doublekill.mp3";
    KSSOUNDM2 = "Interface\\AddOns\\dgks\\sounds\\triplekill.mp3";
    KSSOUNDM3 = "Interface\\AddOns\\dgks\\sounds\\megakill.mp3";
    KSSOUNDM4 = "Interface\\AddOns\\dgks\\sounds\\monsterkill.mp3";
    KSSOUNDH = "Interface\\AddOns\\dgks\\sounds\\humiliation.mp3";

    -- Multikill Text
    KSTEXTM1 = "DOUBLEKILL!";
    KSTEXTM2 = "TRIPLEKILL!";
    KSTEXTM3 = "MEGAKILL!";
    KSTEXTM4 = "MONSTERKILL!!!";
    KSTEXTMH = "Total Humiliation!!!!!!!!";

    -- Amount of time to delay between selected player list updates and how long
    -- to hold a recently selected player in cache.
    local RECENTLY_SELECTED_PLAYERS_UPDATE_INTERVAL = 1;
    local RECENTLY_SELECTED_PLAYERS_HOLD_TIME = 45;

    -----------------------
    -- PRIVATE VARIABLES --
    -----------------------

    local killingstreak = 0;
    local dgks_playername = UnitName("player");
    local dgks_multikill = 0;
    local dgks_lastkill = 0;

    -- Holds a list of recently selected hostile players.
    local recentlySelectedPlayers = {};
    local elapsedTime = 0;

    -- Setup the Ace2 slash commands
    local options = {
    type='group',
    args = {
    sound = {
    type = 'toggle',
    name = 'Play Sound',
    desc = 'Toggles the playing of the audible message',
    get = "issound",
    set = "togglesound"
    },
    emote = {
    type = 'toggle',
    name = 'Show Emote',
    desc = 'Toggles the display of the emote',
    get = "isemote",
    set = "toggleemote"
    },
    bgonly = {
    type = 'toggle',
    name = 'Battleground Only',
    desc = 'Toggles battleground only mode',
    get = "isbgonly",
    set = "togglebgonly"
    },
    raid = {
    type = 'toggle',
    name = 'Sync with Raid',
    desc = 'Toggles the syncing the message with raid',
    get = "israid",
    set = "toggleraid"
    },
    -- ENABLE FOR DEBUGGING
    --test = {
    -- type = 'execute',
    -- name = 'Test dgks',
    -- desc = 'Test dgks message output',
    -- func = "dgks_Killshot"
    --},
    score = {
    type = 'execute',
    name = 'Print KillingStreak',
    desc = 'Print KillingStreak',
    func = "dgks_KillingStreak"
    }--,
    --config = {
    -- type = 'execute',
    -- name = 'Show Config',
    -- desc = 'Show Config',
    -- func = "dgks_toggleConfig"
    --}
    }
    };

    --------------------
    -- DGKS MAIN CODE --
    --------------------

    -- Create the Ace2 main object
    dgks = AceLibrary("AceAddon-2.0"):new("AceConsole-2.0", "AceEvent-2.0", "AceDB-2.0");

    -- Register the Ace2 / commands
    dgks:RegisterChatCommand({"/dgks", "/ksn"}, options)

    -- Register default options
    dgks:RegisterDB("dgksDB", "dgksDBPC");
    dgks:RegisterDefaults("profile", {
    sound = true,
    emote = false,
    bgonly = false,
    raid = true
    } );

    -- Setup the Ace2 slash command functions
    function dgks:issound()
    return self.db.profile.sound;
    end

    function dgks:togglesound()
    self.db.profile.sound = not self.db.profile.sound;
    end

    function dgks:isemote()
    return self.db.profile.emote;
    end

    function dgks:toggleemote()
    self.db.profile.emote = not self.db.profile.emote;
    end

    function dgks:isbgonly()
    return self.db.profile.bgonly;
    end

    function dgks:togglebgonly()
    -- toggle current setting
    self.db.profile.bgonly = not self.db.profile.bgonly;

    -- if bg only mode watch zone changes
    if (self.db.profile.bgonly) then
    -- Setup bg only mode
    self:RegisterEvent("ZONE_CHANGED_NEW_AREA");
    -- Check to see if we are in bg or not
    dgks:ZONE_CHANGED_NEW_AREA();
    else
    -- Setup all the time mode
    self:UnregisterEvent("ZONE_CHANGED_NEW_AREA");
    self:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH");
    self:RegisterEvent("CHAT_MSG_SYSTEM");
    self:RegisterEvent("PLAYER_DEAD");
    self:RegisterEvent("CHAT_MSG_ADDON");
    self:RegisterEvent("PLAYER_TARGET_CHANGED");
    end


    end

    function dgks:israid()
    return self.db.profile.raid;
    end

    function dgks:toggleraid()
    self.db.profile.raid = not self.db.profile.raid;
    end

    function dgks:OnUpdate(arg1)
    -- Increment the amount of time passed since the last update.
    elapsedTime = elapsedTime + arg1;

    -- Check if it's time for an update.
    if (elapsedTime >= RECENTLY_SELECTED_PLAYERS_UPDATE_INTERVAL) then
    -- Loop through all of the recently selected players.
    for playerName, lastSeen in recentlySelectedPlayers do
    -- Increment the amount of time since the player was last seen.
    recentlySelectedPlayers[playerName] = lastSeen + elapsedTime;

    -- Check if enough time has passed and remove the player from the list.
    if (lastSeen + elapsedTime >= RECENTLY_SELECTED_PLAYERS_HOLD_TIME) then
    recentlySelectedPlayers[playerName] = nil;
    end
    end

    -- Reset the elapsed time.
    elapsedTime = 0;
    end
    end

    function dgks:OnEnable()
    -- Called when the addon is enabled
    self:RegisterEvent("dgks_PlaySoundFile");
    if (self.db.profile.bgonly) then
    self:RegisterEvent("ZONE_CHANGED_NEW_AREA");
    else
    self:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH");
    self:RegisterEvent("CHAT_MSG_SYSTEM");
    self:RegisterEvent("PLAYER_DEAD");
    self:RegisterEvent("CHAT_MSG_ADDON");
    self:RegisterEvent("PLAYER_TARGET_CHANGED");
    end
    end

    function dgks:CHAT_MSG_COMBAT_HOSTILE_DEATH(arg1)
    if (string.find (arg1, "You have slain ")) then
    -- KILLSHOT!
    killingstreak = dgks:dgks_Killshot(arg1, killingstreak);
    end
    end

    function dgks:CHAT_MSG_SYSTEM(arg1)
    if (string.find (arg1, dgks_playername .. " has defeated ")) then
    -- Duel won!
    if ( killingstreak < KSRANK1) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND1", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND1);
    elseif (killingstreak < KSRANK2) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND2", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND2);
    elseif (killingstreak < KSRANK3) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND3", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND3);
    elseif (killingstreak < KSRANK4) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND4", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND4);
    elseif (killingsteak < KSRANK5) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND5", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND5);
    elseif (killingstreak > (KSRANK5 - 1)) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND6", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND6);
    end
    -- Increment killingblow streak
    killingstreak = killingstreak + 1;
    dgks:dgks_SendAddonMessage("dgks_txt", arg1, "RAID");
    dgks:dgks_Blamo(arg1);
    elseif (string.find (arg1, "has defeated " .. dgks_playername .. " in a duel.")) then
    -- Duel lost!
    killingstreak = 0;
    dgks:dgks_SendAddonMessage("dgks_txt", arg1, "RAID");
    end
    if (string.find(arg1, dgks_playername .. " has fled from ")) then
    -- lol u ran from a duel
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUNDH", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUNDH);
    dgks:dgks_Blamo(arg1);
    dgks:dgks_SendAddonMessage("dgks_txt", arg1, "RAID");
    end
    end

    function dgks:PLAYER_DEAD()
    -- Player has died. End killing streak.
    killingstreak = 0;
    end

    function dgks:CHAT_MSG_ADDON(arg1,arg2,arg3,arg4)
    if not (arg4 == dgks_playername) then
    if (arg1 == "dgks") then
    dgks:dgks_Blamo(arg4 .. arg2);

    elseif (arg1 == "dgks_snd") then
    if arg2 == "KSSOUND1" then
    dgks:dgks_PlaySoundFile(KSSOUND1);
    elseif arg2 == "KSSOUND2" then
    dgks:dgks_PlaySoundFile(KSSOUND2);
    elseif arg2 == "KSSOUND3" then
    dgks:dgks_PlaySoundFile(KSSOUND3);
    elseif arg2 == "KSSOUND4" then
    dgks:dgks_PlaySoundFile(KSSOUND4);
    elseif arg2 == "KSSOUND5" then
    dgks:dgks_PlaySoundFile(KSSOUND5);
    elseif arg2 == "KSSOUND6" then
    dgks:dgks_PlaySoundFile(KSSOUND6);
    elseif arg2 == "KSSOUND7" then
    dgks:dgks_PlaySoundFile(KSSOUND7);
    elseif arg2 == "KSSOUND8" then
    dgks:dgks_PlaySoundFile(KSSOUND8);
    elseif arg2 == "KSSOUND9" then
    dgks:dgks_PlaySoundFile(KSSOUND9);
    elseif arg2 == "KSSOUND10" then
    dgks:dgks_PlaySoundFile(KSSOUND10);
    elseif arg2 == "KSSOUND11" then
    dgks:dgks_PlaySoundFile(KSSOUND11);
    elseif arg2 == "KSSOUND12" then
    dgks:dgks_PlaySoundFile(KSSOUND12);
    elseif arg2 == "KSSOUND13" then
    dgks:dgks_PlaySoundFile(KSSOUND13);
    elseif arg2 == "KSSOUNDM1" then
    dgks:dgks_PlaySoundFile(KSSOUNDM1);
    elseif arg2 == "KSSOUNDM2" then
    dgks:dgks_PlaySoundFile(KSSOUNDM2);
    elseif arg2 == "KSSOUNDM3" then
    dgks:dgks_PlaySoundFile(KSSOUNDM3);
    elseif arg2 == "KSSOUNDM4" then
    dgks:dgks_PlaySoundFile(KSSOUNDM4);
    elseif arg2 == "KSSOUNDH" then
    dgks:dgks_PlaySoundFile(KSSOUNDH);
    end
    elseif (arg1 == "dgks_txt") then
    dgks:dgks_Print(arg2);
    end
    end
    end

    function dgks:ZONE_CHANGED_NEW_AREA()

    local dgks_newzone = GetZoneText();

    if ((dgks_newzone == "Warsong Gulch") or (dgks_newzone == "Arathi Basin") or (dgks_newzone == "Alterac Valley")) then
    self:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH");
    self:RegisterEvent("PLAYER_DEAD");
    self:RegisterEvent("CHAT_MSG_ADDON");
    self:RegisterEvent("PLAYER_TARGET_CHANGED");
    else
    if self:IsEventRegistered("CHAT_MSG_COMBAT_HOSTILE_DEATH") then
    self:UnregisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH");
    self:UnregisterEvent("PLAYER_DEAD");
    self:UnregisterEvent("CHAT_MSG_ADDON");
    self:UnregisterEvent("PLAYER_TARGET_CHANGED");
    end
    end
    end

    function dgks:PLAYER_TARGET_CHANGED()
    -- Make sure a unit is selected, is a player and is hostile.
    if (UnitExists("target") and UnitIsPlayer("target") and not UnitIsFriend("player", "target")) then
    -- Get the unit's name and make sure it's valid before adding it to the recently selected player's list.
    local playerName = UnitName("target");
    if (playerName) then
    recentlySelectedPlayers[playerName] = 0;
    end
    end
    end

    function dgks:dgks_Print(msg)
    -- New school Ace2 style
    dgks:Print(msg);
    end

    function dgks:dgks_Blamo(msg)
    if (IsAddOnLoaded("Blizzard_CombatText")) then
    -- If Blizzard CombatText enable send msg there
    CombatText_AddMessage(msg, CombatText_StandardSCroll, 1, 0.1, 0.1, "crit", 0);
    elseif (IsAddOnLoaded("SCT")) then
    -- If SCT is loaded send msg there
    color = {r=1.0, g=0.1, b=0.1};
    SCT:DisplayText(msg, color, 1, "event", 1, 1);
    elseif (IsAddOnLoaded("MikScrollingBattleText")) then
    -- If Mik's Scrolling Battle Text is loaded send msg here
    MikSBT.DisplayMessage(msg, MikSBT.DISPLAYTYPE_OUTGOING, false, 0, 0, 255);
    end
    -- Last and least just send it to the text box if no scrolling text available.
    dgks:dgks_Print(msg);
    end

    function dgks:dgks_Killshot(arg1, arg2)

    -- Do some PC/NPC checking before we get all excited and flag a kill
    -- There has got to be a better way to do this, but as of now this is my rig
    local npc = 1;

    -- Make sure arg2 is not nil
    if (arg2 == nil) then
    arg2 = 0;
    end

    -- If arg1 is nil then this must be a test
    if (arg1 == nil) then
    arg1 = "You have slain Test."
    npc = 0;
    -- DEBUG arg2 = arg2 - 1;
    end

    -- Get name from kill string
    local dgks_victimname = string.sub(arg1,16,-2);


    -- Check if the current target is the slain enemy and is a player, or the slain target is on the recently
    -- selected players list.
    if ((UnitExists("target") and (UnitName("target") == dgks_victimname) and UnitIsPlayer("target")) or (recentlySelectedPlayers[dgks_victimname] ~= nil)) then
    npc = 0;
    end


    if npc==0 then
    -- PLAYER GOT KILLSHOT
    -- Emote Enabled
    if (self.db.profile.emote) then
    SendChatMessage("has destroyed " .. dgks_victimname, "EMOTE");
    end

    -- Print to SCT or Text Box
    dgks:dgks_Blamo(dgks_playername .. " has killed " .. dgks_victimname);

    dgks:dgks_SendAddonMessage("dgks", " has killed " .. dgks_victimname, "RAID");

    -- Play correct sounds and send to raid
    if (arg2 < KSRANK1) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND1", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND1);
    elseif (arg2 < KSRANK2) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND2", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND2);
    elseif (arg2 < KSRANK3) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND3", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND3);
    elseif (arg2 < KSRANK4) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND4", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND4);
    elseif (arg2 < KSRANK5) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND5", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND5);
    elseif (arg2 > (KSRANK5 - 1)) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUND6", "RAID");
    dgks:dgks_PlaySoundFile(KSSOUND6);
    end

    -- Check for multikill
    local dgks_thiskill = GetTime();
    if((dgks_lastkill + 5) > dgks_thiskill) then
    -- multikill!!
    dgks_multikill = dgks_multikill + 1;
    if (dgks_multikill == 2) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUNDM1", "RAID");
    dgks:dgks_SendAddonMessage("dgks_txt", dgks_playername .. " has got a " .. KSTEXTM1, "RAID");
    dgks:Print(dgks_playername .. " has got a " .. KSTEXTM1);
    dgks:dgks_PlaySoundFile(KSSOUNDM1);
    elseif (dgks_multikill == 3) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUNDM2", "RAID");
    dgks:dgks_SendAddonMessage("dgks_txt", dgks_playername .. " has got a " .. KSTEXTM2, "RAID");
    dgks:Print(dgks_playername .. " has got a " .. KSTEXTM2);
    dgks:dgks_PlaySoundFile(KSSOUNDM2);
    elseif (dgks_multikill == 4) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUNDM3", "RAID");
    dgks:dgks_SendAddonMessage("dgks_txt", dgks_playername .. " has got a " .. KSTEXTM3, "RAID");
    dgks:Print(dgks_playername .. " has got a " .. KSTEXTM3);
    dgks:dgks_PlaySoundFile(KSSOUNDM3);
    elseif (dgks_multikill > 4) then
    dgks:dgks_SendAddonMessage("dgks_snd", "KSSOUNDM4", "RAID");
    dgks:dgks_SendAddonMessage("dgks_txt", dgks_playername .. " has got a " .. KSTEXTM4, "RAID");
    dgks:Print(dgks_playername .. " has got a " .. KSTEXTM4);
    dgks:dgks_PlaySoundFile(KSSOUNDM4);
    end

    else
    -- last kill was more than 5 seconds ago
    dgks_multikill = 1;
    end
    dgks_lastkill = dgks_thiskill;

    -- Increment killingblow streak
    return arg2+1;
    end
    -- Since it was an npc dont increment our killingblow streak
    return arg2;
    end

    function dgks:dgks_PlaySoundFile(arg1)
    if(self.db.profile.sound) then
    if not (PlaySoundFile(arg1)) then
    self:ScheduleEvent("dgks_PlaySoundFile", 0.2 , arg1);
    end
    end
    end

    function dgks:dgks_SendAddonMessage(arg1, arg2, arg3)
    if(self.db.profile.raid) then
    SendAddonMessage(arg1, arg2, arg3);
    end
    end

    function dgks:dgks_KillingStreak()
    dgks:dgks_Print("KillingStreak: " .. killingstreak);
    end

    function dgks:dgks_toggleConfig()
    if not dgks_configframe then
    dgks_configframe = CreateFrame("Frame",nil,UIParent);
    dgks_configframe:SetFrameStrata("BACKGROUND");
    dgks_configframe:SetWidth(128); -- Set These to whatever height/width is needed
    dgks_configframe:SetHeight(64); -- for your Texture

    dgks_configtexture = dgks_configframe:CreateTexture(nil,"BACKGROUND");
    dgks_configtexture:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp");
    dgks_configtexture:SetAllPoints(dgks_configframe);
    dgks_configframe.texture = dgks_configframe;

    dgks_configframe:SetPoint("CENTER",0,0);
    dgks_configframe:Show();
    end
    if(dgks_configframe:IsVisible()) then
    dgks_configframe:Hide();
    else
    dgks_configframe:Show();
    end
    end
    Posted in: General AddOns
  • To post a comment, please or register a new account.