L2Tower Discord Let's keep the community alive with discord. Discussions about plugins and scripts L2Tower Discord

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clear target after kill mobs
Author Message
astalavista Offline
Expired VIP Member
**

Posts: 38
Joined: May 2013
Reputation: 2
Version: 1.4.2.135
Post: #1
Clear target after kill mobs

Hi, here I using Tanking plugin but the problem too slow working, after I kill mob it not targeting anther mob he waiting until mob despair and then he jumps on anther mob, anyone can help me with this? where should I write down this command in between which lines?
ClearTarget();CancelTarget(false);

Code:
TankStatus = false;
TankStatusMass = false;
tankonspot = false;
pvp = false;
AuraOfHateRdy = GetTime();
AgressionRdy = GetTime();
ShieldStrike = GetTime();
movestamp = GetTime();
outspot = nil;
myptidpetlist =    {} ;
AllowedMass = GetTime() + 40000;


function OnCreate()
    this:RegisterCommand("t", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
    this:RegisterCommand("ts", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
    this:RegisterCommand("p", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
    this:RegisterCommand("outspot", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
    this:RegisterCommand("tmass", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
end;


function OnCommand_t(vCommandChatType, vNick, vCommandParam)
    if (TankStatus == false) then
TankStatus = true;
FarmPoint = GetMe():GetLocation();
retreat = false;
ShowToClient("Tank plugin","Tanking Is Activated.");
    else
TankStatus = false;
tankonspot = false;
retreat = false;
ShowToClient("Tank plugin","Tanking Is Is Deactivated.");    
    end;
end;


function OnCommand_tmass(vCommandChatType, vNick, vCommandParam)
    if (TankStatusMass == false) then
TankStatusMass = true;
ShowToClient("Tank plugin","Tanking Mass MODE");
    else
TankStatusMass = false;
ShowToClient("Tank plugin","TANKING Mass MODE OFF");    
    end;
end;


function OnCommand_outspot(vCommandChatType, vNick, vCommandParam)
    if (outspot == nil) then
outspot = GetMe():GetLocation();
ShowToClient("Tank plugin","Safe Position is saved.");
    else
outspot = nil;
ShowToClient("Tank plugin","Safe Position is removed.");
    end;
end;


function OnCommand_p(vCommandChatType, vNick, vCommandParam)
    if (pvp == false) then
pvp = true;
retreat = false;
ShowToClient("Tank plugin","Switched to PvP Tank Mode.");
    else
pvp = false;
retreat = false;
ShowToClient("Tank plugin","Switched to PvE Tank Mode.");    
    end;
end;


function OnCommand_ts(vCommandChatType, vNick, vCommandParam)
    if (TankStatus == false) then
TankStatus = true;
tankonspot = true;
retreat = false;
FarmPoint = GetMe():GetLocation();
ShowToClient("Tank plugin","Tanking Is Activated.");
    else
TankStatus = false;
tankonspot = false;
retreat = false;
ShowToClient("Tank plugin","Tanking Is Is Deactivated.");    
    end;
end;


function CheckSorrounding()
    if (pvp == false) then
if (AnyFlaggedAround() == false) and (IsThereMobsAround()) then
return true;
end;
    else
if (AnyFlaggedAround() == true) then
return true;
end;
    end;
    return false;
end;


function OnLTick500ms()
    CurrentTime = GetTime();
    myself = GetMe();
    MySkills = GetSkills();
    MyCurrentTarget = GetTarget();

if (myself ~= nil) and ((myself:GetClass() == 148) or (myself:GetClass() == 149) or (myself:GetClass() == 150) or (myself:GetClass() == 151)) then
if (TankStatus) then
HateAuraSkill = MySkills:FindById(10027);
if (myself:IsAlikeDeath() == false) and (GetDistanceVector(FarmPoint,myself:GetLocation()) < 5000) then    
if (HateAuraSkill ~= nil) and (HateAuraSkill:IsSkillAvailable()) and (AllowedMass < CurrentTime) and CheckSorrounding() then
local ChainHydra = MySkills:FindById(10016);
if (ChainHydra ~= nil) and (ChainHydra:IsSkillAvailable()) then
if (TankStatusMass) then
UseSkillRaw(10016,false,false);
end;
AllowedMass = CurrentTime + 1000;

else
if (TankStatusMass) then
UseSkillRaw(10027, false, false); -- Superior Hate Aura
end;
end;

elseif (MyCurrentTarget ~= nil) and (MyCurrentTarget:IsAlikeDeath() == false) and ((MyCurrentTarget:IsMonster()) or ((pvp) and (MyCurrentTarget:IsEnemy() and (MyCurrentTarget:GetTarget() ~= myself:GetId()) and (MyCurrentTarget:GetTarget() ~= 0)) and (DoINeedNewTarget() == false))) then
PullSkill = MySkills:FindById(10015); -- Chain Strike
AgroSkill = MySkills:FindById(10026); -- Superior Aggression
if (MyCurrentTarget:GetDistance() < 650) and (MyCurrentTarget:GetDistance() > 100) and (PullSkill ~= nil) and (PullSkill:IsSkillAvailable()) and (MyCurrentTarget:GetTarget() ~= myself:GetId()) and (myself:GetMp() > 2000) then
UseSkillRaw(10015, false, false); -- Chain Strike
elseif (MyCurrentTarget:GetDistance() < 900) and (AgroSkill ~= nil) and (AgroSkill:IsSkillAvailable()) then
UseSkillRaw(10026, false, false); -- Superior Hate
else
movetospot();
end;
else
movetospot();
end;
end;

if (pvp == false) then
if (DoINeedNewTarget()) then
TargetAMobThatNeedAgro();
end;
else
if (DoINeedNewTarget()) or IsMyHealerExposed() then
TargetAnEnemyThatNeedAgro();
end;
end;

end;
if (retreat == true) then
movetospot();
end;
    end;
end;


function movetospot()
    if (retreat == false) then
if (tankonspot == true) and (movestamp +2000 < GetTime()) and (GetDistanceVector(GetMe():GetLocation(),FarmPoint) > 150) and (GetDistanceVector(FarmPoint,GetMe():GetLocation()) < 5000) then
local m = 50;
loc = FarmPoint;
lX = loc.X + math.random(-m, m);
lY = loc.Y + math.random(-m, m);
MoveToNoWait(lX, lY, loc.Z);
movestamp = GetTime();
end;
    elseif (outspot ~= nil) and (movestamp + 500 < GetTime()) and (GetDistanceVector(GetMe():GetLocation(),outspot) > 150) and (GetDistanceVector(outspot,GetMe():GetLocation()) < 5000) then
MoveToNoWait(outspot);
    end;
end;


function IsMyHealerExposed()
    if (MyCurrentTarget ~= nil) then
if (MyCurrentTarget:IsEnemy()) and (MyCurrentTarget:GetDistance() < 1000) then
if (MyCurrentTarget:GetTarget() == findmypthealer()) then
return false;
end;
end;
local playerlist = GetPlayerList();
for player in playerlist.list do
if player:IsEnemy() and player:GetTarget() == findmypthealer() and (player:GetDistance() < 1000) then
return true;
end;
end;
    end;
    return false;
end;


function TargetAnEnemyThatNeedAgro()
    local playerlist = GetPlayerList();
    myptidpetlist = GetMyPartyPetIDList();
    local priority = 0;
    local playerid = nil;
    for player in playerlist.list do
if (player:IsEnemy()) and (player:GetDistance() < 850) then
playertarget = GetUserById(player:GetTarget());
if (playertarget ~= nil) then
if (playertarget:GetId() == findmypthealer()) and (priority <= 5) then
playerid = player:GetId();
priority = 5;
end;
if (playertarget:IsMyPartyMember()) and (priority <= 2) then
playerid = player:GetId();
priority = 2
end;
end;
if CheckIfInsideList(player:GetTarget(),myptidpetlist) and (priority <= 1) then
playerid = player:GetId();
priority = 1;
end;
end;
    end;

    if (playerid ~= nil) then
ClearTargets();
TargetRaw(playerid);
    end;
end;


function findmypthealer()
    local ptmembers = GetPartyList();
    for member in ptmembers.list do
if (member:GetClass() == 179) or (member:GetClass() == 180) or (member:GetClass() == 181) then
return member:GetId();
end;
    end;
    return nil;
end;


function TargetAMobThatNeedAgro()
    myptidpetlist = GetMyPartyPetIDList();
    local moblist = GetMonsterList();
    priority = 0;
    mobid = nil;
    for mob in moblist.list do
targetId = mob:GetTarget();
if (mob:IsValid()) and (targetId ~= nil) and not (targetId == 0) then
mobtarget = GetUserById(targetId);
if (mobtarget ~= nil) and(mobtarget:IsMyPartyMember()) then
if (mob:GetDistance() < 900) and (findmypthealer() ~= nil) and (mobtarget:GetId() == findmypthealer()) then
mobid = mob:GetId();
priority = 7;
end;
if (mob:GetDistance() < 400) and (priority <= 4) then
if (mob:GetDistance() > 100) and (priority <= 5) then
mobid = mob:GetId();
priority = 5;
elseif (priority <= 3) then
mobid = mob:GetId();
priority = 4;
end;
end;
if (mob:GetDistance() < 850) and (priority <= 2) then
if (mob:GetDistance() > 100) then
mobid = mob:GetId();
priority = 3;
else
mobid = mob:GetId();
priority = 2;
end;
end;    
end;
if CheckIfInsideList(mob:GetTarget(),myptidpetlist) and (mob:GetDistance() < 850) and (priority < 1) then
mobid = mob:GetId();
priority = 1;
end;
end;
    end;
    if (mobid ~= nil) then
ClearTargets();
TargetRaw(mobid);
    end;
end;


function GetMyPartyPetIDList()
    local tempreturnlist = {} ;
    local tempptmembersnames = {} ;
    local myptmembers = GetPartyList();
    local petlist = GetPetList();
    for member in myptmembers.list do
tempptmembersnames[#tempptmembersnames+1] = member:GetName();
    end;
    for pet in petlist.list do
if (CheckIfInsideList(pet:GetNickName(),tempptmembersnames)) then    
tempreturnlist[#tempreturnlist+1] = pet:GetId();
end;
    end;    
    return tempreturnlist;
end;


function CheckIfInsideList(thevalue,thelist)
    for x=1,#thelist do
if (thelist[x] == thevalue) then
return true;
end;
    end;
    return false;
end;


function DoINeedNewTarget()
    if (MyCurrentTarget ~= nil) and (MyCurrentTarget:IsValid()) then
if not (MyCurrentTarget:IsAlikeDeath()) then
if ((MyCurrentTarget:IsMonster()) and not (pvp)) or ((MyCurrentTarget:IsEnemy()) and (pvp)) then
if ((MyCurrentTarget:GetDistance() < 600) and (ShieldStrike < CurrentTime)) or (MyCurrentTarget:GetDistance() < 900) then
local MyTargetTarget = GetUserById(MyCurrentTarget:GetTarget());
if (MyTargetTarget ~= nil) and (MyTargetTarget:IsValid()) then
if (MyTargetTarget:IsMyPartyMember()) or CheckIfInsideList(MyTargetTarget:GetId(),myptidpetlist) then
return false;
end;
end;
end;
end;
end;
    end;
    return true;    
end;


function IsThereMobsAround()
    local monsterlist = GetMonsterList();
    local count = 0;
    for mob in monsterlist.list do
if (mob:GetDistance() < 350) then
count = count +1;
end;
    end;
    if (count > 1) then
return true;
    end;
    return false;
end;


function AnyFlaggedAround()
    local playerlist = GetPlayerList();
    for player in playerlist.list do
if (player:IsMyPartyMember() == false) then
if (player:IsPvPFlag() == true) then
if (player:GetDistance() < 1400) then
return true;
end;
end;
end;
    end;
    return false;
end;


function OnMagicSkillUse(user, target, skillId, skillvl, skillHitTime, skillReuse)
    if (user:IsMe()) then    
if (skillId == 10027) then
AuraOfHateRdy = GetTime()+skillReuse;
elseif (skillId == 10026) then
AgressionRdy = GetTime()+skillReuse;
elseif (skillId == 10015) then
ShieldStrike = GetTime()+skillReuse;
end;
    end;    
end;


function FindSubStringInString(thesub,thestring)
    for x = 1, 1 + string.len(thestring)-string.len(thesub),1 do
if (string.sub(thestring,x,x+string.len(thesub)-1) == thesub) then
return true;
end;
    end;
    return false;
end;


function OnChatUserMessage(chatType, nick, msg)
    if (chatType == L2ChatType.CHAT_PARTY) and (outspot ~= nil) then
Message = string.lower(msg); -- Converts message to lower case letters.
Message = Message:gsub("^%s*(.-)%s*$", "%1"); -- Trimming message of spaces on start.
if (tankonspot == true) and (Message == "out") or FindSubStringInString("go out",Message) or FindSubStringInString("come out",Message) then
retreat = true;
TankStatus = false;
end;
if FindSubStringInString("go tank",Message) or FindSubStringInString("tank go",Message) then
retreat = false;
TankStatus = true;
end;
    end;
end;

how to show plugin with lua program?


Attached File(s)
.lua  TankoKomandos.lua (Size: 11.25 KB / Downloads: 55)
(This post was last modified: 06-07-2015 20:54 PM by astalavista.)
06-07-2015 18:46 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  bot will target but not attack. elvis8925 3 3,765 04-09-2018 00:19 AM
Last Post: elvis8925
Star Remove Target canaldextiger 8 4,820 02-10-2018 22:19 PM
Last Post: canaldextiger
  Bot Dont Attack mobs ;/ AtraX69 10 9,029 12-30-2016 21:35 PM
Last Post: sebi7
Information How to get 'PARTY MEMBER TARGET'? Caaioc 9 6,757 01-24-2016 09:57 AM
Last Post: TheQQmaster
  target for self buff manuel16007 1 3,250 01-22-2016 16:31 PM
Last Post: TheQQmaster
  Lag every mob kill maybeoutofrain 2 2,156 11-12-2015 16:50 PM
Last Post: maybeoutofrain
Rainbow Help to cancel target budarox 8 5,967 08-14-2015 06:31 AM
Last Post: budarox
  Guillotine fortress mobs drake182 18 10,774 07-12-2015 10:03 AM
Last Post: botsbotsbotsbots
  Change title to user's target vaskouf 4 4,229 06-28-2015 09:25 AM
Last Post: Vinter
Exclamation Need help with new mobs pl17kv23 2 2,342 03-23-2015 17:26 PM
Last Post: pl17kv23



User(s) browsing this thread: 1 Guest(s)