Need help editing radar script menu

User Tag List

Results 1 to 2 of 2
  1. #1
    Bloodmoor's Avatar Member
    Reputation
    11
    Join Date
    Jun 2012
    Posts
    18
    Thanks G/R
    1/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help editing radar script

    Hi, trying to make radar script for Ogasai draw objects, but dont understand what i am doing wrong
    WoW 1.12.1

    Code:
    script_radar = {
        timer = 0,
        tickRate = 100,
        radarOffsetX = 230,
        radarOffsetY = 365,
        radiusOne = 0,
        radiusTwo = 0,
        radarScale = 150;
        showRadar = true,
        drawRadarFriendlyPlayer = true,
        drawRadarHostilePlayer = true,
        drawRadarMob = true,
        drawNavFriendlyPlayers = true,
        drawNavHostilePlayers = true,
        drawNavMonsters = false
    }
    
    function script_radar:draw()    
        if (self.showRadar) then
            script_radar:Radar();
        end        
    end
    
    function script_radar:drawUnitOnRadar(aUnit, unitType)
        
        local red = 128; local green = 192; local blue = 128;
        local name = ''; local radarName = ''; local screenName = '';
        local me = GetLocalPlayer();
        local myTarget = GetTarget(); 
    
        if (unitType == 3 and  aUnit:CanAttack() and not aUnit:IsCritter()) then -- draw the mob on radar
            name = '' .. aUnit:GetCreatureType() .. ' (' .. aUnit:GetLevel() .. ')';
            if (self.drawNavMonsters) then 
                screenName = name;
            end
            if (self.drawRadarMob) then
                radarName = name;
            end
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    	elseif (unitType == 1 and aUnit:IsLootable()) then -- should draw objects? 
            name = '' .. aUnit:GetObjectPosition() ..')';
    		if (self.drawNavMonsters) then 
                screenName = name;
            end
            if (self.drawRadarMob) then
                radarName = name;
            end
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            if (myTarget ~= 0 and myTarget:GetGUID() == aUnit:GetGUID()) then -- the mob is our target
                red = 255; green = 255; blue = 0;
            elseif (aUnit:IsDead()) then -- dead mob
                red = 64; green = 128; blue = 64;
            end   
        elseif (unitType == 4 and me:GetGUID() ~= aUnit:GetGUID()) then -- draw the player on radar
            name = '' .. aUnit:GetUnitName() .. ' (' .. aUnit:GetLevel() .. ')';
            unitTarget = aUnit:GetUnitsTarget();
            local unitIsHostilePlayer = false;
            if (aUnit:CanAttack()) then -- player is hostile
                unitIsHostilePlayer = true;
                if (unitTarget ~=0 and unitTarget:GetGUID() == me:GetGUID()) then -- hostile is targeting us
                    red = 255; green = 0; blue = 0;
                elseif (aUnit:IsDead()) then -- dead hostile player
                    red = 64; green = 64; blue = 128;
                else -- hostile player
                    red = 192; green = 64; blue = 0;
                end
                if (self.drawNavHostilePlayers) then
                    screenName = name;
                end
                if (self.drawRadarHostilePlayer) then
                    radarName = name;
                end
            else
                if (myTarget ~= 0 and myTarget:GetGUID() == aUnit:GetGUID()) then -- friendly player in our target
                    red = 255; green = 255; blue = 0;
                elseif (aUnit:IsDead()) then -- dead hostile player
                    red = 64; green = 64; blue = 128;
                else -- friendly player
                    red = 0; green = 255; blue = 0;
                end
                if (self.drawNavFriendlyPlayers) then
                    screenName = name;
                end
                if (self.drawRadarFriendlyPlayer) then
                    radarName = name;
                end
            end
        end
        
        if (radarName ~= '') then -- draw the recognised unit on radar
            -- Transform the game coordinates to 2D pixel coords.
            local cX, cY, __ = aUnit:GetPosition();
            local centerX, centerY, __ = me:GetPosition();     
            -- X and Y coordinates are swapped dunno why
            local unitOffsetX = (centerY - cY) * (self.radarScale / 100);
            local unitOffsetY = (centerX - cX) * (self.radarScale / 100);
            local cross = 3;
            local uX = self.radarOffsetX + unitOffsetX;
            local uY = self.radarOffsetY + unitOffsetY;
            DrawLine(uX - cross, uY - cross, uX + cross, uY + cross, red, green, blue, 1);
            DrawLine(uX - cross, uY + cross, uX + cross, uY - cross, red, green, blue, 1);
            local distance = math.floor(aUnit:GetDistance());
            DrawText('' .. radarName, uX + 5, uY, red, green, blue);
            -- DrawText('  (' .. distance .. ' yd)', uX, uY + 10, red, green, blue);
        end
    
        if (screenName ~= '') then -- draw the recognised unit on screen (script_nav style)
            local distance = math.floor(aUnit:GetDistance());
            local tX, tY, onScreen = WorldToScreen(aUnit:GetPosition());
            if (onScreen) then
                DrawText(screenName, tX, tY-10, red, green, blue);
                DrawText('HP: ' .. math.floor(aUnit:GetHealthPercentage()) .. '%', tX, tY, 255, 64, 64);
                DrawText('' .. distance .. ' yd.', tX, tY+10, 255, 255, 255);
            end
        end 
    
    end
    
    function script_radar:Radar()
        
        local pi = 3.14;
        local numberOfValidTargets = 0; local localObj = GetLocalPlayer();
        local currentObj, typeObj = GetFirstObject();
        
        -- draw mobs and players
        while currentObj ~= 0 do 
            script_radar:drawUnitOnRadar(currentObj, typeObj)
            currentObj, typeObj = GetNextObject(currentObj);
        end
    
        -- Draw the radar's outline        
        local cx = self.radarOffsetX;
        local cy = self.radarOffsetY;
        local cross = 3;
        DrawLine(cx - cross, cy - cross, cx + cross, cy + cross, 192, 64, 192, 1);
        DrawLine(cx - cross, cy + cross, cx + cross, cy - cross, 192, 64, 192, 1);
        for i= 1, 360 do
            local cX = self.radarOffsetX + self.radiusOne * (self.radarScale / 100) * math.cos(i/(2*pi));
            local cY = self.radarOffsetY + self.radiusOne * (self.radarScale / 100) * math.sin(i/(2*pi));
            DrawLine(cX, cY, cX+1, cY+1, 128, 128, 128, 1);
            local cX = self.radarOffsetX + self.radiusTwo * (self.radarScale / 100) * math.cos(i/(2*pi));
            local cY = self.radarOffsetY + self.radiusTwo * (self.radarScale / 100) * math.sin(i/(2*pi));
            DrawLine(cX, cY, cX+1, cY+1, 128, 128, 128, 1);
        end
    
    end
    
    function script_radar:run()
    	if(GetTimeEX() > self.timer) then
    		self.timer = GetTimeEX() + self.tickRate;
        end
        
    end
    
    function script_radar:menu()
        if (CollapsingHeader("[Radar")) then
            wasClicked, self.showRadar = Checkbox("Draw the radar", self.showRadar);
            Separator();
            wasClicked, self.drawRadarFriendlyPlayer = Checkbox("Draw friendly players on radar", self.drawRadarFriendlyPlayer);
            wasClicked, self.drawRadarHostilePlayer = Checkbox("Draw hostile players on radar", self.drawRadarHostilePlayer);
            wasClicked, self.drawRadarMob = Checkbox("Draw mob on radar", self.drawRadarMob);
            Separator();
            wasClicked, self.drawNavFriendlyPlayers = Checkbox("Draw friendly players script_nav style", self.drawNavFriendlyPlayers);
            wasClicked, self.drawNavHostilePlayers = Checkbox("Draw hostile players script_nav style", self.drawNavHostilePlayers);
            wasClicked, self.drawNavMonsters = Checkbox("Draw monsters script_nav style", self.drawNavMonsters);
            self.radarOffsetX = SliderInt("radarOffsetX", 1, 1920, self.radarOffsetX);
            self.radarOffsetY = SliderInt("radarOffsetY", 1, 1080, self.radarOffsetY);
            self.radiusOne = SliderInt("radius #1 ", 1, 300, self.radiusOne);
            self.radiusTwo = SliderInt("radius #2 ", 1, 300, self.radiusTwo);
            self.radarScale = SliderInt("Scaling factor", 0, 300, self.radarScale);
        end
    end
    Last edited by Bloodmoor; 4 Weeks Ago at 04:56 AM.

    These ads disappear when you log in.

  2. #2
    Bloodmoor's Avatar Member
    Reputation
    11
    Join Date
    Jun 2012
    Posts
    18
    Thanks G/R
    1/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It was unitType == 5
    added "Draw objects on radar" , "Draw objects nav style" and "Highlight by name" to menu

    Code:
    script_radar = {
        timer = 0,
        tickRate = 100,
        radarOffsetX = 265,
        radarOffsetY = 365,
        radiusOne = 175,
        radiusTwo = 0,
        radarScale = 150,
    	lfObjName1 = '',
    	lfObjName2 = '',
    	lfMobName = '',
        showRadar = true,
        drawRadarFriendlyPlayer = true,
        drawRadarHostilePlayer = true,
        drawRadarMob = false,
    	drawRadarObjects = true,
        drawNavFriendlyPlayers = true,
        drawNavHostilePlayers = true,
        drawNavMonsters = false,
    	drawNavObjects = true
    	
    }
    
    function script_radar:draw()    
        if (self.showRadar) then
            script_radar:Radar();
        end        
    end
    
    function script_radar:drawUnitOnRadar(aUnit, unitType)
        
        local red = 32; local green = 192; local blue = 64;
        local name = ''; local radarName = ''; local screenName = '';
        local me = GetLocalPlayer();
        local myTarget = GetTarget(); 
    	
    	if (unitType == 5 and not aUnit:IsGatherNode()) then -- draw objects on radar
    		red = 0; green = 255; blue = 255;
    		name = '' .. aUnit:GetUnitName() .. '';
    		if (self.drawNavObjects) then 
                screenName = name;
            end
            if (self.drawRadarObjects) then
                radarName = name;
            end
    		if(aUnit:GetUnitName() == self.lfObjName1) then
    			red = 255; green = 0; blue = 0;
    		end
    		if(aUnit:GetUnitName() == self.lfObjName2) then
    			red = 255; green = 0; blue = 0;
    		end
    	end
    	
        if (unitType == 3 and  aUnit:CanAttack() and not aUnit:IsCritter()) then -- draw the mob on radar
            name = '' .. aUnit:GetUnitName() .. ' (' .. aUnit:GetLevel() .. ')';
            if (self.drawNavMonsters) then 
                screenName = name;
            end
            if (self.drawRadarMob) then
                radarName = name;
            end
    		if(aUnit:GetUnitName() == self.lfMobName) then
    			red = 255; green = 0; blue = 0;
    		end
    	end	
    	
        if (unitType == 4 and me:GetGUID() ~= aUnit:GetGUID()) then -- draw the player on radar
            name = '' .. aUnit:GetUnitName() .. ' (' .. aUnit:GetLevel() .. ')';
            unitTarget = aUnit:GetUnitsTarget();
            local unitIsHostilePlayer = false;
            if (aUnit:CanAttack()) then -- player is hostile
                unitIsHostilePlayer = true;
                if (unitTarget ~=0 and unitTarget:GetGUID() == me:GetGUID()) then -- hostile is targeting us
                    red = 255; green = 0; blue = 0;
                elseif (aUnit:IsDead()) then -- dead hostile player
                    red = 64; green = 64; blue = 128;
                else -- hostile player
                    red = 192; green = 64; blue = 0;
                end
                if (self.drawNavHostilePlayers) then
                    screenName = name;
                end
                if (self.drawRadarHostilePlayer) then
                    radarName = name;
                end
            else
                if (myTarget ~= 0 and myTarget:GetGUID() == aUnit:GetGUID()) then -- friendly player in our target
                    red = 255; green = 255; blue = 0;
                elseif (aUnit:IsDead()) then -- dead hostile player
                    red = 64; green = 64; blue = 128;
                else -- friendly player
                    red = 0; green = 255; blue = 0;
                end
                if (self.drawNavFriendlyPlayers) then
                    screenName = name;
                end
                if (self.drawRadarFriendlyPlayer) then
                    radarName = name;
                end
            end
        end
        
        if (radarName ~= '') then -- draw the recognised unit on radar
            -- Transform the game coordinates to 2D pixel coords.
            local cX, cY, __ = aUnit:GetPosition();
            local centerX, centerY, __ = me:GetPosition();     
            -- X and Y coordinates are swapped dunno why
            local unitOffsetX = (centerY - cY) * (self.radarScale / 100);
            local unitOffsetY = (centerX - cX) * (self.radarScale / 100);
            local cross = 3;
            local uX = self.radarOffsetX + unitOffsetX;
            local uY = self.radarOffsetY + unitOffsetY;
            DrawLine(uX - cross, uY - cross, uX + cross, uY + cross, red, green, blue, 1);
            DrawLine(uX - cross, uY + cross, uX + cross, uY - cross, red, green, blue, 1);
            local distance = math.floor(aUnit:GetDistance());
            DrawText('' .. radarName, uX + 5, uY, red, green, blue);
            -- DrawText('  (' .. distance .. ' yd)', uX, uY + 10, red, green, blue);
        end
    
        if (screenName ~= '') then -- draw the recognised unit on screen (script_nav style)
            local distance = math.floor(aUnit:GetDistance());
            local tX, tY, onScreen = WorldToScreen(aUnit:GetPosition());
            if (onScreen) then
                DrawText(screenName, tX, tY-10, red, green, blue);
                --DrawText('HP: ' .. math.floor(aUnit:GetHealthPercentage()) .. '%', tX, tY, 255, 64, 64);
                DrawText('' .. distance .. ' yd.', tX, tY+10, 255, 255, 255);
            end
        end 
    
    end
    
    function script_radar:Radar()
        
        local pi = 3.14;
        local numberOfValidTargets = 0; local localObj = GetLocalPlayer();
        local currentObj, typeObj = GetFirstObject();
        
        -- draw mobs and players
        while currentObj ~= 0 do 
            script_radar:drawUnitOnRadar(currentObj, typeObj)
            currentObj, typeObj = GetNextObject(currentObj);
        end
    
        -- Draw the radar's outline        
        local cx = self.radarOffsetX;
        local cy = self.radarOffsetY;
        local cross = 3;
        DrawLine(cx - cross, cy - cross, cx + cross, cy + cross, 192, 64, 192, 1);
        DrawLine(cx - cross, cy + cross, cx + cross, cy - cross, 192, 64, 192, 1);
        for i= 1, 360 do
            local cX = self.radarOffsetX + self.radiusOne * (self.radarScale / 100) * math.cos(i/(2*pi));
            local cY = self.radarOffsetY + self.radiusOne * (self.radarScale / 100) * math.sin(i/(2*pi));
            DrawLine(cX, cY, cX+1, cY+1, 128, 128, 128, 1);
            local cX = self.radarOffsetX + self.radiusTwo * (self.radarScale / 100) * math.cos(i/(2*pi));
            local cY = self.radarOffsetY + self.radiusTwo * (self.radarScale / 100) * math.sin(i/(2*pi));
            DrawLine(cX, cY, cX+1, cY+1, 128, 128, 128, 1);
        end
    
    end
    
    function script_radar:run()
    	if(GetTimeEX() > self.timer) then
    		self.timer = GetTimeEX() + self.tickRate;
        end
        
    end
    
    function script_radar:menu()
            wasClicked, self.showRadar = Checkbox("Draw the radar", self.showRadar);
            Separator();
            wasClicked, self.drawRadarFriendlyPlayer = Checkbox("Draw friendly players on radar", self.drawRadarFriendlyPlayer);
            wasClicked, self.drawRadarHostilePlayer = Checkbox("Draw hostile players on radar", self.drawRadarHostilePlayer);
    		Separator();
            wasClicked, self.drawNavFriendlyPlayers = Checkbox("Draw friendly players script_nav style", self.drawNavFriendlyPlayers);
            wasClicked, self.drawNavHostilePlayers = Checkbox("Draw hostile players script_nav style", self.drawNavHostilePlayers);
            Separator();
    		Text("Mobs options")
    		wasClicked, self.drawRadarMob = Checkbox("Draw mob on radar", self.drawRadarMob);
    		wasClicked, self.drawNavMonsters = Checkbox("Draw monsters script_nav style", self.drawNavMonsters);
    		self.lfMobName = InputText("Mob to highlight", self.lfMobName);
    		Separator();
    		Text("Objects options")
    		wasClicked, self.drawRadarObjects = Checkbox("Draw objects on radar", self.drawRadarObjects);
    		wasClicked, self.drawNavObjects = Checkbox("Draw objects script_nav style", self.drawNavObjects);
    		self.lfObjName1 = InputText("Object to highlight 1", self.lfObjName1);
    		self.lfObjName2 = InputText("Object to highlight 2", self.lfObjName2);
    		Separator();
            self.radarOffsetX = SliderInt("radarOffsetX", 1, 1920, self.radarOffsetX);
            self.radarOffsetY = SliderInt("radarOffsetY", 1, 1080, self.radarOffsetY);
            self.radiusOne = SliderInt("radius #1", 1, 300, self.radiusOne);
            self.radiusTwo = SliderInt("radius #2", 1, 300, self.radiusTwo);
            self.radarScale = SliderInt("Scaling factor", 0, 300, self.radarScale);
    end
    Last edited by Bloodmoor; 3 Weeks Ago at 05:13 AM. Reason: improved code a little

Similar Threads

  1. [How To] Need help editing gathering script
    By dbh- in forum WoW Bots Questions & Requests
    Replies: 4
    Last Post: 12-13-2018, 06:10 AM
  2. [WIP] Need help editing Hyena.M2!
    By Elthea in forum World of Warcraft Model Editing
    Replies: 2
    Last Post: 05-14-2008, 07:48 AM
  3. [C++]Need help with my Scripted Item
    By freezer1012 in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 01-13-2008, 05:55 PM
  4. [Help] I need help creating a script.
    By jokerjokes in forum World of Warcraft Emulator Servers
    Replies: 23
    Last Post: 01-10-2008, 10:06 PM
  5. Need help editing itemcache.wdb and sword position
    By Kaiderai in forum World of Warcraft General
    Replies: 2
    Last Post: 09-06-2007, 05:28 PM
All times are GMT -5. The time now is 04:55 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search