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

Post Reply 
 
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Targetting faster when stucked
Author Message
kaan22747 Offline
Goblin Grave Robber
*

Posts: 17
Joined: Jan 2014
Reputation: 2
Version: 1.4.3.143
Post: #1
Targetting faster when stucked

Hey guys, i am using script for targeting another mob when my character get stucked, but it takes about 20 to 30 seconds for script to change the target.. can't i make it faster? i mean when my character get stucked, to make it change target faster.. its too slow Sad

here is the script
Code:
TimeTillRequestChangeTarget = 1000*30 ; -- in mile seconds
TimeTillTryFixMovement = 1000*5 ; -- in mile seconds

TargetFixStatus = false;
unstuckingstatus = false;
mytargetid = 0;
MyTargetTimeStamp = GetTime();
unstuckmovementstamp = GetTime();

function OnCreate()
    this:RegisterCommand("targetfix", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
end;

function OnCommand_targetfix(vCommandChatType, vNick, vCommandParam)
    if (TargetFixStatus == false) then
TargetFixStatus = true;
ShowToClient("Auto Fix","Target Fix Is Activated.");
    else
TargetFixStatus = false;
ShowToClient("Auto Fix","Target Fix Is Is Deactivated.");    
    end;
end;



function OnChatSystemMessage(id, msg)
    if (id == 181) then --cannot see target
if (GetMe():GetTarget() ~= 0) then
ShowToClient("Auto Fix"," Cannot See Target");
GetTarget():SetBlock(true);
CancelTargets();
end;
    end;
end;

function OnLTick1s()
if (TargetFixStatus == true) then
    if (mylastcordcheck ~= nil) then
if (IsMoving() == false) then
if (GetTarget() ~= nil) and (GetMe():GetTarget() ~= 0) then
if (GetTarget():IsAlikeDeath() == false) and (GetTarget():IsMonster()) then
if (mytargetid ~= GetTarget():GetId()) then
mytargetid = GetTarget():GetId();
MyTargetTimeStamp = GetTime();
end;
end;
end;
else
MyTargetTimeStamp = GetTime();
end;
    end;    
if (GetTarget() ~= nil) and (GetMe():GetTarget() ~= 0) then
    if GetTarget():IsMonster() and (GetTarget():IsAlikeDeath() == false) then
if (MyTargetTimeStamp + TimeTillRequestChangeTarget < GetTime()) then
ShowToClient("Auto Fix"," Char Didnt Move/Hit/Nuke for the last " .. tostring(TimeTillRequestChangeTarget/1000) .. " seconds, so Changing Target!");
GetTarget():SetBlock(true);
CancelTargets();
elseif (MyTargetTimeStamp + TimeTillTryFixMovement < GetTime()) and (unstuckingstatus == false) then
SetPause(true);
unstuckmovementstamp = GetTime();
unstuckingstatus = true;
MovePerpendicularlyFromUser(GetTarget(),200);
end;
    end;
end;

end;
mylastcordcheck = GetMe():GetLocation();

if (GetTarget() == nil) or (GetMe():GetTarget() == 0) or (GetMe():IsBlocked(true)) then
    MyTargetTimeStamp = GetTime();
end;

if (unstuckmovementstamp +2000 < GetTime()) and (unstuckingstatus == true) then
unstuckingstatus = false;
SetPause(false);
ShowToClient("Auto Fix","char should be unstuck by now");
end;


end;


function MovePerpendicularlyFromUser(user,dist) -- took me an hour to write this down!
    YQ = user:GetLocation().Y
    YP = GetMe():GetLocation().Y
    XQ = user:GetLocation().X
    XP = GetMe():GetLocation().X
    Mp = -1/((YQ-YP)/(XQ-XP))
    if ((-2*XP-2*Mp*Mp*XP)*(-2*XP-2*Mp*Mp*XP) -4*(Mp*Mp+1)*(Mp*Mp*XP*XP + XP*XP-dist*dist) > 0) then
undersqrt = (-2*XP-2*Mp*Mp*XP)*(-2*XP-2*Mp*Mp*XP) -4*(Mp*Mp+1)*(Mp*Mp*XP*XP + XP*XP-dist*dist);
    else
undersqrt = (-2*XP-2*Mp*Mp*XP)*(-2*XP-2*Mp*Mp*XP) -4*(Mp*Mp+1)*(Mp*Mp*XP*XP + XP*XP+dist*dist);
    end;
    XN = (-1*(-2*XP-2*Mp*Mp*XP)+math.sqrt(undersqrt))/(2*(Mp*Mp+1));
    YN = YP + Mp*(XN-XP)
    MoveToNoWait(XN,YN,GetMe():GetLocation().Z);
end;


function IsMoving()
    if (GetDistanceVector(GetMe():GetLocation(),mylastcordcheck) > 100) then
return true;
    end;
return false;
end;

function OnMagicSkillUse(user, target, skillId, skillvl, skillHitTime, skillReuse)
    if (user:IsMe()) then
MyTargetTimeStamp = GetTime();
    end;
end;

function OnAttack(user, target)
    if (user:IsMe()) or (target:IsMe()) then
MyTargetTimeStamp = GetTime();
    end;
end;

function CancelTargets()
ClearTargets();
CancelTarget(true);
end;

and i also tried to change this values

TimeTillRequestChangeTarget = 1000*30 ; -- in mile seconds
TimeTillTryFixMovement = 1000*5 ; -- in mile seconds

but it seems no difference..

Thanks, waiting for a reply Smile
01-31-2014 14:09 PM
Find all posts by this user Quote this message in a reply
kaan22747 Offline
Goblin Grave Robber
*

Posts: 17
Joined: Jan 2014
Reputation: 2
Version: 1.4.3.143
Post: #2
RE: Targetting faster when stucked

thanks for answers, whatever i got it figured out myself.
02-01-2014 17:45 PM
Find all posts by this user Quote this message in a reply
capucine Offline
Expired VIP Member
**

Posts: 1,083
Joined: Jan 2013
Reputation: 208
Version: 1.4.2.142
Post: #3
RE: Targetting faster when stucked

I use this on mine and works fine... What was YOUR solution to fix it?? pls share it!

TimeTillRequestChangeTarget = 1000*7 ; -- in mile seconds
TimeTillTryFixMovement = 1000*4 ; -- in mile seconds
02-01-2014 18:04 PM
Find all posts by this user Quote this message in a reply
kaan22747 Offline
Goblin Grave Robber
*

Posts: 17
Joined: Jan 2014
Reputation: 2
Version: 1.4.3.143
Post: #4
RE: Targetting faster when stucked

Well as i am newbie here when i used that i tought i was using it but actually i was not Smile) ..

Simply coppy and paste the codes that i posted in l2tower folder / plugin folder and rename it to targetfix.lua

Then just restart your l2tower relog in your account and ingame set your configurations using //cfg after that type //targetfix and should be done.
02-01-2014 18:15 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Targetting Problem at Guillottine alexspan123 1 2,080 10-03-2013 08:07 AM
Last Post: onisoru
  Help on targetting pls Charuto 2 2,257 11-05-2012 16:54 PM
Last Post: Charuto
  Bot not targetting TooEarly 0 1,725 01-01-2012 07:26 AM
Last Post: TooEarly
  Targetting?whats the logic amiroooo 1 2,492 12-17-2011 23:46 PM
Last Post: ClockMan
  Flagged players targetting tomukas10 3 3,130 08-05-2011 14:30 PM
Last Post: tomukas10



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