Can this code be cleaned up? menu

User Tag List

Results 1 to 2 of 2
  1. #1
    Iaccidentallytwink's Avatar Elite User
    Reputation
    591
    Join Date
    Aug 2007
    Posts
    1,020
    Thanks G/R
    1/16
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can this code be cleaned up?

    If your team is about to cap the flag, or the opposing team is about to win the game, -- Code goes here should fire. I don't have the coordinates for the horde room yet, but this should be working.


    However, how can I clean up the if and else mess I've created?


    Code:
    local function isWSGMode()
        oneX, oneY, oneT = GetBattlefieldFlagPosition(1);
        twoX, twoY, twoT = GetBattlefieldFlagPosition(2);
        _, _, _, scoreAlliance = GetWorldStateUIInfo(2)
        _, _, _, scoreHorde = GetWorldStateUIInfo(3)
        if isAlliance() then -- If we're Alliance
            if (oneT == "HordeFlag") and ((oneX >= 0.46) and (oneX <= 0.51)) and ((oneY >= 0.11) and (oneY <= 0.17)) and ((twoX == 0) and (twoY == 0)) then -- And we're about to cap
                -- Code goes here
            else 
                if ((twoX >= 0.46) and (twoX <= 0.51)) and ((twoY >= 0.11) and (twoY <= 0.17)) and ((oneX == 0) and (oneY == 0)) then
                    -- Code goes here
                end
            end
            if scoreHorde == "2/3" then -- And Horde is about to win
                if (oneT == "AllianceFlag") and ((oneX >= 0.1) and (oneX <= 0.1)) and ((oneY >= 0.1) and (oneY <= 0.1)) and ((twoX == 0) and (twoY == 0)) then
                    -- Code goes here
                else 
                    if ((twoX >= 0.1) and (twoX <= 0.1)) and ((twoY >= 0.1) and (twoY <= 0.1)) and ((oneX == 0) and (oneY == 0)) then
                        -- Code goes here
                    end
                end
            end
        else -- If we're Horde
            if ((oneX >= 0.1) and (oneX <= 0.1)) and ((oneY >= 0.1) and (oneY <= 0.1)) and (twoX == 0) and (twoY == 0) then -- And we're about to cap
                -- Code goes here
            else 
                if ((twoX >= 0.1) and (twoX <= 0.1)) and ((twoY >= 0.1) and (twoY <= 0.1)) and (oneX == 0) and (oneY == 0) then
                    -- Code goes here
                end
            end
            if scoreAlliance == "2/3" then -- And Alliance is about to win
                if (oneT == "HordeFlag") and ((oneX >= 0.46) and (oneX <= 0.51)) and ((oneY >= 0.11) and (oneY <= 0.17)) and ((twoX == 0) and (twoY == 0)) then
                    -- Code goes here
                else 
                    if ((twoX >= 0.46) and (twoX <= 0.51)) and ((twoY >= 0.11) and (twoY <= 0.17)) and ((oneX == 0) and (oneY == 0)) then
                        -- Code goes here
                    end
                end
            end
        end
    end


    Can this code be cleaned up?
  2. #2
    bluesius's Avatar Established Member
    Reputation
    181
    Join Date
    Jun 2007
    Posts
    350
    Thanks G/R
    3/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It appears as if you are working on flag position based on coordinates. Suggestion: Base it on time instead.
    It should be safe to assume that approximately 30 seconds after the flag has been picked up, it will probably be on its way over to their base.
    60 seconds after it has been picked up, chances are its dangerously close to being turned in.

    This solution will NOT be as hardcoded robust as the work you have done thus far, but it does allow for very simplified code. The exact timing will have to be preciser, of course, but thats something you can handle.

    Just a suggestion

Similar Threads

  1. Can anyone rewrite this code to work in VB 2008
    By insignia96 in forum Programming
    Replies: 5
    Last Post: 12-15-2008, 01:20 PM
  2. What can this farmer be doing?
    By Seductive in forum World of Warcraft General
    Replies: 10
    Last Post: 12-30-2007, 01:51 AM
  3. Can this be caught in any way?
    By drano in forum World of Warcraft General
    Replies: 3
    Last Post: 12-28-2007, 08:27 AM
  4. Omg can this be real?
    By kuzzekurt123 in forum World of Warcraft General
    Replies: 1
    Last Post: 10-15-2007, 06:00 AM
  5. Replies: 1
    Last Post: 09-24-2007, 02:57 AM
All times are GMT -5. The time now is 09:26 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search