Lineage 2 Tower Forum

Full Version: CPU leak - autofarm script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello guys.
I have script:
    LUA Programming
dofile (GetDir() .. "\\scripts\\QuestsMystic\\fight.lua");
moveDistance = 30;
repeat
if(GetZoneType() == 12) then
Sleep(10000);
SetPause(true); ---- to stop Tower in town, untill u get in farm-spot
 
MoveTo(147661, 26685, -2200, moveDistance);
MoveTo(147213, 25827, -2008, moveDistance);
TargetNpc("Adventurers' Guide", 32327);
Talk();
ClickLinkAndWait("blessing_list001.htm");
ClickText("\"Wizard's Harmony, of course!\"");
ClearTargets();
LearnAllSkills();
MoveTo(*, moveDistance);
MoveTo(*, moveDistance);
MoveTo(*, moveDistance);
MoveTo(*, moveDistance);
MoveTo(*, moveDistance);
Sleep(3000);
 
if(GetZoneType() == 15) then
Sleep(11000);
SetPause(false);  ------ to reactivate Tower in farm spot.
end;
end;
until false;


After i launch hem my computer take lag i see in task mannager every l2 window where i launch that script have leac CPU.
When i stop, this leak stop.
I think m.b. that becouse (if) try check location every moment.. and that is hard...Hove fix that? Maybe do some delay for (if) check every 1min. location? Or what i do wrong? I am noob i think that i do something wrong. Help please.
what's this ? are they valid locations? if not suspend them whit -- or remove

MoveTo(*, moveDistance);
MoveTo(*, moveDistance);
MoveTo(*, moveDistance);
MoveTo(*, moveDistance);
MoveTo(*, moveDistance);
you can write here any coordinats as you want..
help. )
Please post the code of "fight.lua", the problem could be there.

Also, if you're using this script as it is right now, It should be giving you an error on the coordinates of that MoveTo Fox quoted. If those are usable piece of code to the program but it's giving you errors every tick, that might be it.
Please right click on L2Tower icon right beside the clock at the bottom-right corner of the screen, go to Running Games -> The client using this script -> Logs. Upload a screenshot of the logs just right after you stop the script and everything isn't freezing anymore.

The IF checking every single moment isn't a problem on Tower nor L2 CPU usage.

Good luck
put Sleep(100); in the beggining (or in repeat cycle) of every script
Fight.lua
Code:
function Nuke_AddSkill(id, range)
    local it = L2TConfig.NukeSetting();
    local SCONFIG = L2TConfig.GetConfig();
    it.meHpCondition = L2TConfig.ENukeCondition.NC_ALWAYS;
    it.meMpCondition = L2TConfig.ENukeCondition.NC_ALWAYS;
    it.meHpValue = 100;
    it.meMpValue = 100;
    it.useRepeat = true;
    it.requireTarget = true;
    it.skillId = id;
    it.targetCount = 1;
    it.targetHpCondition = L2TConfig.ENukeCondition.NC_ALWAYS;
    it.targetHpValue = 100;
    it.targetRange = range;
    it.useEvery = 0; --autodetect
    SCONFIG.nuke.skills:Add(it);
end;

function EnableAttackRange(range)
    local SCONFIG = L2TConfig.GetConfig();
--SCONFIG.nuke.skills:Clear(); -- Очистить нюк
    Nuke_AddSkill(1178, range*1); --Twister
    SCONFIG.nuke.enabled = true;
end;



function PreSetup()
    SCONFIG.potions.enabled = true;
    SCONFIG.potions.HP.enabled = true;
    SCONFIG.potions.HP.LesserHealingPotion.DamagePercent = 10;
    SCONFIG.pickup.userPickup.pickupRange = 300;            --Pickup Range Setup
    SCONFIG.pickup.userPickup.pickupTimeout = 15;
    SCONFIG.pickup.userPickup.mode = L2TConfig.EPickupMode.PICKUP_AFTER;            --Pickup After On
    SCONFIG.pickup:SwapFilter(512);
    SCONFIG.pickup:SwapFilter(256);
    SCONFIG.pickup:SwapFilter(128);
    SCONFIG.pickup:SwapFilter(64);
    SCONFIG.pickup:SwapFilter(8192);
    SCONFIG.pickup:SwapFilter(2);
    SCONFIG.pickup:SwapFilter(4);
    SCONFIG.pickup:SwapFilter(8);
    SCONFIG.pickup:SwapFilter(16);
    SCONFIG.resurrect.enabled = true;
    SCONFIG.resurrect.autoRevive = true;
    SCONFIG.resurrect.reviveDelay = 5;
    SCONFIG.resurrect:SwapAllowed(0x0002);
    SCONFIG.sleep.enabled = true;
    --SCONFIG.sleep.noActionSleep = true;
    SCONFIG.sleep.sitMP=23
    SCONFIG.sleep.standMP=55
    end
    ActivateSoulShot(22249,true);
    ActivateSoulShot(22250,true);
    ActivateSoulShot(22251,true);
    LearnAllSkills();
function EnableAttack()
    EnableAttackRange(700);
end;


function DisableAttack()
    local SCONFIG = L2TConfig.GetConfig();
    SCONFIG.nuke.enabled = false;
    SCONFIG.nuke.skills:Clear();
end;


function CountMonstersInRange(range)
    local me = GetMe();
    local l = GetMonsterList();
    local c = 0;
        
    for user in l.list do
        if ((user:IsAlikeDeath() == false) and (user:GetRangeTo(me)             c = c + 1;
        end;        
    end;
    return c;
end;

function KillTarget()
    local t = GetTarget();
    if (t == nil) then
        return true;
    end;
    if ((t:IsValid() == false) or (t:IsAlikeDeath() == true)) then
        return true;
    end;
    --wylacz targetowanie, wlacz attack...
    EnableAttackRange(10000);
    SCONFIG.targeting.option = L2TConfig.ETargetingType.TT_OFF;
    local paused = IsPaused();
    SetPause(false);
    repeat
        ClearTargets();
        Target(t);
        Sleep(500);
    until (t:IsValid() == false) or (t:IsAlikeDeath() == true);
    DisableAttack();
    SetPause(paused);
    return true;
end;

function KillEveryooneWhoAttacks(u)
    local monsters = GetMonsterList();
    local t = nil;
    repeat
        t = nil;
        for user in monsters.list do
            if (user:IsEnemy() and user:GetTarget() == u:GetId() ) then
                t = user;
                break;
            end;
        end;
        if (t ~= nil) then
            Target(t);
            KillTarget();
        end;
    until t == nil;
end;

function AddPathPoint(X, Y, Z, Range)
    local tmpPoint = L2TConfig.L2PathPoint();
    tmpPoint.X = X;
    tmpPoint.Y = Y;
    tmpPoint.Z = Z;
    tmpPoint.range = Range;
    tmpPoint.type = L2TConfig.ETargetingRangeType.TRT_CIRCLE;
    SCONFIG.targeting.pathPoints:Add(tmpPoint);
end;

autofarm.lua
Code:
dofile (GetDir() .. "\\scripts\\QuestsMystic\\fight.lua");
moveDistance = 30;
repeat
if(GetZoneType() == 12) then
Sleep(10000);
SetPause(true); ---- to stop Tower in town, untill u get in farm-spot

MoveTo(147661, 26685, -2200, moveDistance);
MoveTo(147213, 25827, -2008, moveDistance);
TargetNpc("Adventurers' Guide", 32327);
Talk();
ClickLinkAndWait("blessing_list001.htm");
ClickText("\"Wizard's Harmony, of course!\"");
ClearTargets();
LearnAllSkills();
MoveTo(147213, 25827, -2008, moveDistance);
Sleep(3000);

if(GetZoneType() == 15) then
Sleep(11000);
SetPause(false);  ------ to reactivate Tower in farm spot.
end;
end;
until false;
2 codes
You need premium account to use "fight.lua" script. Put " -- " at the beggining of
    LUA Programming
dofile (GetDir() .. "\\scripts\\QuestsMystic\\fight.lua");

line.
It will NOT attack, but it's just a matter of testing and debugging. If your CPU works Ok with that, then we know what's the problem.

Also please attach the logs I told you about.
And for god's sake, use [code=lua] to show the script properly.


Thanks
all ok guys .. realy i just need do sleep after repeat )

    LUA Programming
moveDistance = 30;
repeat
Sleep(10000);
if(GetZoneType() == 12) then
Sleep(10000);
SetPause(true); ---- to stop Tower in town, untill u get in farm-spot
Sleep(3000);
if(GetZoneType() == 15) then
Sleep(11000);
SetPause(false); ------ to reactivate Tower in farm spot.
end;
end;
until false;

No need for lua at the end Smile
(10-28-2013 20:20 PM)kreon Wrote: [ -> ]all ok guys .. realy i just need do sleep after repeat )

Really guy? that actually solved it? Despite this forum account creation date, I've been using this bot for god knows how long, and wrote countless scripts and plugins without using almost no sleeps at all, and none of them gave me any sort of CPU problems.

I still don't get how are you able to use "fight.lua" script when it's clearly using premium only functions.

But well, glad you solve your issue.
Pages: 1 2
Reference URL's