Hi all, I write here because I need some help to make an script for an skill called Magical Charge from a Feoh SoulTaker.
Well, first of all I don't know programming, but reading some threats, I tried and made my own scripts, until now.
What I want or expect with this script?, well, when a monster approaching less 200 from my wizard, He executes that skill called Magical Charge.
Just as I said, I tried to make this script (attached here), but inside L2TowerScript says that all is ok, but in game I get this message:
"Script Error: Lua error (Script not valid) - No matching overload found, candidates: Skill* FindByID(SkillList&,int)"
So, Can anyone help me to fix that please? I'm so sorry if is easy, but honestly I don't know how.
Quote:MagicalChargeSkillID = 11094;
MagicalChargeSkill = GetSkills():FindById(ResSkillId);
TargetInRange = 200;
function MagicalCharge()
if (GetMe():IsAlikeDeath() == false) and (MagicalChargeSkill ~= nil) and (MagicalChargeSkill:CanBeUsed()) and (GetMe():GetRangeTo(Target) < TargetInRange) then
UseSkillRaw(MagicalChargeSkillID, false, false)
Sleep(500);
end;
repeat
MagicalCharge()
until (GetMe():GetRangeTo(Target) > TargetInRange)
Sleep(1000);
end;
(08-08-2015 20:32 PM)ExoDo Wrote: [ -> ] LUA Programming
MagicalChargeSkill = GetSkills():FindById(MagicalChargeSkillID);
like this should work
Thank you very much, I didn't see my fault. I corrected it and in game doesn't show me any error, but it doesn't work.
The monster approaching and my char doesn't execute the skill. Can you help me with that?
LUA Programming
MagicalChargeSkillID = 11094;
MagicalChargeSkill = GetSkills():FindById(MagicalChargeSkillID);
TargetInRange = 200;
function MagicalCharge(targetds)
if targetds ~= nil then
if (GetMe():IsAlikeDeath() == false) and (MagicalChargeSkill ~= nil) and (MagicalChargeSkill:CanBeUsed()) and (GetMe():GetRangeTo(targetds) < TargetInRange) then
UseSkillRaw(MagicalChargeSkillID, false, false)
Sleep(500);
end;
end;
repeat
MyTRG = nil;
MyTRG = GetMe():GetTarget;
MagicalCharge(MyTRG)
until (GetMe():GetRangeTo(MyTRG) > TargetInRange)
Sleep(1000);
end;
mby smth like thisd coz u dont have defined "Target"
(08-09-2015 08:03 AM)TheQQmaster Wrote: [ -> ] LUA Programming
MagicalChargeSkillID = 11094;
MagicalChargeSkill = GetSkills():FindById(MagicalChargeSkillID);
TargetInRange = 200;
function MagicalCharge(targetds)
if targetds ~= nil then
if (GetMe():IsAlikeDeath() == false) and (MagicalChargeSkill ~= nil) and (MagicalChargeSkill:CanBeUsed()) and (GetMe():GetRangeTo(targetds) < TargetInRange) then
UseSkillRaw(MagicalChargeSkillID, false, false)
Sleep(500);
end;
end;
repeat
MyTRG = nil;
MyTRG = GetMe():GetTarget;
MagicalCharge(MyTRG)
until (GetMe():GetRangeTo(MyTRG) > TargetInRange)
Sleep(1000);
end;
mby smth like thisd coz u dont have defined "Target"
Hi TheQQmaster
Thanks for answer me. I want to tell you that I copied this script, pasted on mine and saved it of course.
In game doesn't show any error but my char doesn't do the skill....He stays casting others skills but when a monster approach him, doesn't do the action
Please help me with that...I will appreciate it
Thanks again
(08-09-2015 10:14 AM)versutia4 Wrote: [ -> ] (08-09-2015 08:03 AM)TheQQmaster Wrote: [ -> ] LUA Programming
MagicalChargeSkillID = 11094;
MagicalChargeSkill = GetSkills():FindById(MagicalChargeSkillID);
TargetInRange = 200;
function MagicalCharge(targetds)
if targetds ~= nil then
if (GetMe():IsAlikeDeath() == false) and (MagicalChargeSkill ~= nil) and (MagicalChargeSkill:CanBeUsed()) and (GetMe():GetRangeTo(targetds) < TargetInRange) then
UseSkillRaw(MagicalChargeSkillID, false, false)
Sleep(500);
end;
end;
repeat
MyTRG = nil;
MyTRG = GetMe():GetTarget;
MagicalCharge(MyTRG)
until (GetMe():GetRangeTo(MyTRG) > TargetInRange)
Sleep(1000);
end;
mby smth like thisd coz u dont have defined "Target"
Hi TheQQmaster
Thanks for answer me. I want to tell you that I copied this script, pasted on mine and saved it of course.
In game doesn't show any error but my char doesn't do the skill....He stays casting others skills but when a monster approach him, doesn't do the action
Please help me with that...I will appreciate it
Thanks again
Atm not in home. Will check when i be in home
Sent from my Galaxy S5 via TAPTALK
try to debugg it
LUA Programming
ShowToClient(tostring(os.date("%X")),"Magical Charge ON",3); -- debugger - can remowe if all is working
MagicalChargeSkillID = 11094; -- check if correct ID of skill, coz there lot skills by name magical charge (11094,23752)
MagicalChargeSkill = GetSkills():FindById(MagicalChargeSkillID);
TargetInRange = 200;
function MagicalCharge(targetds)
local Me = GetMe();
if targetds ~= nil then
ShowToClient(tostring(os.date("%X")),"if my target is not empty",3); -- debugger - can remowe if all is working
if not (Me:IsAlikeDeath()) and (Me:GetRangeTo(targetds) < TargetInRange) and
ShowToClient(tostring(os.date("%X")),"i am not dead and my target is in good range",3); -- debugger - can remowe if all is working
if (MagicalChargeSkill ~= nil) and (MagicalChargeSkill:CanBeUsed()) then
ShowToClient(tostring(os.date("%X")),"i can use skill",3); -- debugger - can remowe if all is working
UseSkillRaw(MagicalChargeSkillID, false, false)
Sleep(500);
end;
end;
end;
end;
repeat
MyTRG = nil;
MyTRG = GetMe():GetTarget;
MagicalCharge(MyTRG)
Sleep(1000);
until false;
(08-09-2015 12:36 PM)TheQQmaster Wrote: [ -> ] (08-09-2015 10:14 AM)versutia4 Wrote: [ -> ] (08-09-2015 08:03 AM)TheQQmaster Wrote: [ -> ] LUA Programming
MagicalChargeSkillID = 11094;
MagicalChargeSkill = GetSkills():FindById(MagicalChargeSkillID);
TargetInRange = 200;
function MagicalCharge(targetds)
if targetds ~= nil then
if (GetMe():IsAlikeDeath() == false) and (MagicalChargeSkill ~= nil) and (MagicalChargeSkill:CanBeUsed()) and (GetMe():GetRangeTo(targetds) < TargetInRange) then
UseSkillRaw(MagicalChargeSkillID, false, false)
Sleep(500);
end;
end;
repeat
MyTRG = nil;
MyTRG = GetMe():GetTarget;
MagicalCharge(MyTRG)
until (GetMe():GetRangeTo(MyTRG) > TargetInRange)
Sleep(1000);
end;
mby smth like thisd coz u dont have defined "Target"
Hi TheQQmaster
Thanks for answer me. I want to tell you that I copied this script, pasted on mine and saved it of course.
In game doesn't show any error but my char doesn't do the skill....He stays casting others skills but when a monster approach him, doesn't do the action
Please help me with that...I will appreciate it
Thanks again
Atm not in home. Will check when i be in home
Sent from my Galaxy S5 via TAPTALK
try to debugg it
LUA Programming
ShowToClient(tostring(os.date("%X")),"Magical Charge ON",3); -- debugger - can remowe if all is working
MagicalChargeSkillID = 11094; -- check if correct ID of skill, coz there lot skills by name magical charge (11094,23752)
MagicalChargeSkill = GetSkills():FindById(MagicalChargeSkillID);
TargetInRange = 200;
function MagicalCharge(targetds)
local Me = GetMe();
if targetds ~= nil then
ShowToClient(tostring(os.date("%X")),"if my target is not empty",3); -- debugger - can remowe if all is working
if not (Me:IsAlikeDeath()) and (Me:GetRangeTo(targetds) < TargetInRange) and
ShowToClient(tostring(os.date("%X")),"i am not dead and my target is in good range",3); -- debugger - can remowe if all is working
if (MagicalChargeSkill ~= nil) and (MagicalChargeSkill:CanBeUsed()) then
ShowToClient(tostring(os.date("%X")),"i can use skill",3); -- debugger - can remowe if all is working
UseSkillRaw(MagicalChargeSkillID, false, false)
Sleep(500);
end;
end;
end;
end;
repeat
MyTRG = nil;
MyTRG = GetMe():GetTarget;
MagicalCharge(MyTRG)
Sleep(1000);
until false;
Hi TheQQmaster
Honestly I used your suggestion, but I got some errors in game with that script.
However, I was testing some things and I get one that works regularly
And I said regularly because sometimes take too time to activate that skill, either when target is near my char and the skill is available to use
Can you check please? Thanks
(08-09-2015 23:42 PM)TheQQmaster Wrote: [ -> ] LUA Programming
repeat
user = nil;
user = GetTarget();
if(user ~= nil) and not (user:IsAlikeDeath()) and (GetMe():GetRangeTo(user)< 250) then
UseSkillRaw(11094,false,false); -- Feoh Soultaker Magical Charge Skill
end;
Sleep(1*1000)
until false
Thank you very much, I will taste it shortly......and I'll tell you how is working.
Hey TheQQmaster
That Script works fine, as much as I wanted. Infact, I did another script called Magical Evasion, is the same thing, only change Skill ID (I'll share here)
Only thing I could see, is when both skills are availables and target is near, in some cases my char executes both skills and doesn't move........practicaly, stays in the same position
For that case, in one script I use Sleep by 1 second, and in the other one, Sleep by 2 seconds.
Again, thank you very much for your time and help.
for that add condition if it is like buff type skill
if skill not nil and skill can be used and dont have 2nd skill buff on me use it