• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resurrection function that avoids mobs for Logitechs grinder
#1
i wrote a function that tries to find a better spot for res 

logic:
go to corpse
create 1000 random spots and check their distance to surrounding mobs
if there is a spot that has enough distance to all mobs around go there and repop
if not stay at corpse and repop

Issues:
doesn't check when at "save res spot" if there are mobs that are closer now (because they patrol)
doesn't check if you can actually walk to res spot, so you might get stuck

is use fr0s4 improved version but it should also work for logitechs original grinder 

you can change and test 2 variable
1) v.r is aggro range of mobs, so here it would be aggrorange + 10 yards (increase if you want the safespot to be further away from mobs)
Code:
if GetDistance3D(v.x,v.y,v.z,self.move_res_x, self.move_res_y,self.move_res_z) < v.r+10 then

2) you can increase the area that is searched by raisng the ressdistance, on Lh its more like 30 or 35
Code:
ressDistance = 25,



if you want to use it you have to edit "script_grind_logitech.lua"

in the top part add these variables
Code:
    searched_save_repop_spot = false,
    move_res_x = 0,
    move_res_y = 0,
    move_res_z = 0,

somewhere above "function script_grind:run()" add
Code:
function script_grind:MobTable()
-- put enemies in a table    
    local me = GetLocalPlayer();
    objectTable = {};
    local obj_, type_ = GetFirstObject();
    while obj_ ~= 0 do
        if type_ == 3 or type_ == 4 then
            local objX, objY, objZ = obj_:GetPosition();
            -- objR is mob aggro ranged, i tested it  and it is at least 6 and maximum 46, on same lvl its 21
            local objR = obj_:GetLevel() - me:GetLevel() + 21
            if objR > 46 then objR = 46 end;
            if objR < 6 then objR = 6 end;
            local objGUID = obj_:GetGUID();
            local objName = obj_:GetUnitName();
            objectTable[obj_] = {x = objX, y = objY, z = objZ, type = type_, r = objR, GUID = objGUID, name = objName};
        end
        obj_, type_ = GetNextObject(obj_);
    end
end

and replace the  resurrect part in the code between "-- Corpse-walk if we are dead" and "-- Check: If in group wait for members to be within 60 yards and 75% mana" with :
Code:
        if(localObj:IsDead()) then
            self.message = "Walking to corpse...";
            -- Release body
            if(not IsGhost()) then RepopMe(); self.waitTimer = GetTimeEX() + 5000; return; end
            -- Ressurrect within the ress distance to our corpse
            local _lx, _ly, _lz = localObj:GetPosition();
            if(GetDistance3D(_lx, _ly, _lz, GetCorpsePosition()) > 2) and self.searched_save_repop_spot == false then -- if we are more than 2 yards away from corpse AND havent looked for a save resspot
                script_nav:moveToNav(localObj, GetCorpsePosition());
                return;
            else
                if self.searched_save_repop_spot == false then -- if we havent looked for a spot
                    local c_x,c_y,c_z = GetCorpsePosition();
                    script_grind:MobTable();
                
                    for i=1,1000 do  -- there might be no save xy then res at corpse_xy

                         r = self.ressDistance * sqrt(math.random())
                         theta = math.random() * 2 * math.pi
                        
                        save_res_x = c_x + r * math.cos(theta)
                         save_res_y = c_y + r * math.sin(theta)
                        
                        self.move_res_x = save_res_x
                        self.move_res_y = save_res_y
                    
                         isVis, _hx, _hy, _hz = Raycast(self.move_res_x, self.move_res_y, 10000, self.move_res_x, self.move_res_y, -10000);
                        self.move_res_z = _hz
                         self.Is_spot_save = true

                        for i,v in pairs(objectTable) do
                    
                            if v.type == 3     and i:CanAttack() == true  and i:IsCritter() == false then

                                if GetDistance3D(v.x,v.y,v.z,self.move_res_x, self.move_res_y,self.move_res_z) < v.r+10 then -- aggro radius PLUS a save distance
                                    self.Is_spot_save = false;
                                end

                            end
                        end

                        if self.Is_spot_save == true then
                            self.searched_save_repop_spot = true;
                            break; -- break for i do        
                        end
                        
                        if i == 1000 then -- if we dont find a savespot till the last i then there is no savespot
                            self.Is_spot_save = false;
                            self.searched_save_repop_spot = true;
                        end        
                    end -- for i do end

                    if self.Is_spot_save == false then -- if we didnt find a save spot to res, res at corpse xyz
                        self.move_res_x = c_x
                        self.move_res_y = c_y
                        self.move_res_z = c_z
                    end
                end -- if not searched_save_repop_spot end
                
                if self.searched_save_repop_spot == true and--if we looked for a save res position
                 GetDistance3D(_lx, _ly, _lz, self.move_res_x,self.move_res_y,self.move_res_z) < 2 then -- if a we are close to safe res spot
                    script_grind:savePos(); -- save pos so we don't log out (stuck feature)
                    RetrieveCorpse();
                else -- we looked for a save spot and are more than 2 yards away
                    Move(self.move_res_x,self.move_res_y,self.move_res_z);
                end
                
            end
            return;
        end
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)