kaan22747
Goblin Grave Robber
Posts: 17
Joined: Jan 2014
Reputation: 2
Version:
1.4.3.143
|
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
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
|
|
01-31-2014 14:09 PM |
|
kaan22747
Goblin Grave Robber
Posts: 17
Joined: Jan 2014
Reputation: 2
Version:
1.4.3.143
|
RE: Targetting faster when stucked
thanks for answers, whatever i got it figured out myself.
|
|
02-01-2014 17:45 PM |
|
capucine
Expired VIP Member
Posts: 1,083
Joined: Jan 2013
Reputation: 208
Version:
1.4.2.142
|
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 |
|
kaan22747
Goblin Grave Robber
Posts: 17
Joined: Jan 2014
Reputation: 2
Version:
1.4.3.143
|
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 ) ..
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 |
|