Windower: PL Script (In progress) - Windower

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

PL Script (In progress)

#1 User is offline   monk 

  • Script Kiddy
  • Group: New Members
  • Posts: 3
  • Joined: 09-March 10

Posted 10 March 2010 - 05:06 PM

It may not work right now as i have added new features in it and have not tested them yet.
But this is the Script in progress.

require("common\\common")
--
-- Example PLBot.
--

--
-- Configuration
--

-- Target your pling.
TargetName = "";

-- PL Class And Level, The one PLing.
PLClass = "";
PLLevel = 75;

-- This part of the configuration sets up the PL to use certain Cures
-- at a certain percent of hp of the Target your PLing.
Cure1Percent = 90;
Cure2Percent = 75;
Cure3Percent = 60;
Cure4Percent = 55;
Cure5Percent = 40;

-- Do not edit below this line.

 TargetPlayer = FindPlayer(TargetName);
 Player = GetPlayer()

 -- List of Healing Spells
 local Cures = { { Name = "Cure V", RequiredMP = 135 }, 
     { Name = "Cure IV", RequiredMP = 88 },
     { Name = "Cure III", RequiredMP = 46 },     
     { Name = "Cure II", RequiredMP = 24 },
     { Name = "Cure", RequiredMP = 8 } };

 -- List of Protectra Spells
 local protectras = { { Name = "Protectra V", RequiredMP = 84 }, 
     { Name = "Protectra IV", RequiredMP = 65 },
     { Name = "Protectra III", RequiredMP = 46 },     
     { Name = "Protectra II", RequiredMP = 28 },
     { Name = "Protectra", RequiredMP = 9 } };

 -- List of Shellra Spells
 local shellras = { { Name = "Shellra V", RequiredMP = 93 }, 
     { Name = "Shellra IV", RequiredMP = 75 },
     { Name = "Shellra III", RequiredMP = 56 },     
     { Name = "Shellra II", RequiredMP = 37 },
     { Name = "Shellra", RequiredMP = 18 } };

 -- List of Protect Spells
 local protects = { { Name = "Protect IV", RequiredMP = 65 },
     { Name = "Protect III", RequiredMP = 46 },     
     { Name = "Protect II", RequiredMP = 28 },
     { Name = "Protect", RequiredMP = 9 } };
 -- List of Shell Spells
 local shells = { { Name = "Shell IV", RequiredMP = 75 },
     { Name = "Shell III", RequiredMP = 56 },     
     { Name = "Shell II", RequiredMP = 37 },
     { Name = "Shell", RequiredMP = 18 } };

 function PLBot()
 
  if(PLClass == "White Mage" then
   if(TargetPlayer:GetHitPointPercentage() <= Cure5Percent && PLLevel >= 61) then
    Cure5()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure4Percent && PLLevel >= 41) then
    Cure4()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure3Percent && PLLevel >= 21) then
    Cure3()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure2Percent && PLLevel >= 11) then
    Cure2()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure1Percent && PLLevel >= 1) then
    Cure1()
   end
   
  elseif(PLClass == "Red Mage" then
   if(TargetPlayer:GetHitPointPercentage() <= Cure4Percent && PLLevel >= 48) then
    Cure4()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure3Percent && PLLevel >= 26) then
    Cure3()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure2Percent && PLLevel >= 14) then
    Cure2()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure1Percent && PLLevel >= 3) then
    Cure1()
   end
   
  elseif(PLClass == "Scholar" then
   if(TargetPlayer:GetHitPointPercentage() <= Cure4Percent && PLLevel >= 55) then
    Cure4()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure3Percent && PLLevel >= 30) then
    Cure3()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure2Percent && PLLevel >= 17) then
    Cure2()
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure1Percent && PLLevel >= 5) then
    Cure1()
   end
  
  end
  
 end
 
 function Cure1()
  if(Player:GetMagicPoints() >= Cures[4].RequiredMP) then
   SendInput("/ma \""..Cures[4].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function Cure2()
  if(Player:GetMagicPoints() >= Cures[3].RequiredMP) then
   SendInput("/ma \""..Cures[3].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function Cure3()
  if(Player:GetMagicPoints() >= Cures[2].RequiredMP) then
   SendInput("/ma \""..Cures[2].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function Cure4()
  if(Player:GetMagicPoints() >= Cures[1].RequiredMP) then
   SendInput("/ma \""..Cures[1].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function Cure5()
  if(Player:GetMagicPoints() >= Cures[0].RequiredMP) then
   SendInput("/ma \""..Cures[0].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function PLBotStart()
  timer = CTimer();
  timer:GetOnTick():Connect(PLBot);
  timer:Start(5000);
 end
 
 function PLBotStop()
  timer:Stop();
 end
 
 Alias("PLStart", PLBotStart);
 Alias("PLStop", PLBotStop);

0

#2 User is offline   monk 

  • Script Kiddy
  • Group: New Members
  • Posts: 3
  • Joined: 09-March 10

Posted 10 March 2010 - 06:54 PM

Update: old code had some error's. Heres a new and improved version and it works been tested :)

require("common\\common")
--
-- Example PLBot.
--

--
-- Configuration
--

-- Target your pling.
TargetName = "";

-- PL Class And Level, The one PLing. Class's supported so far are White Mage, Red Mage, Scholar
PLClass = "Red Mage";
PLLevel = 75;

-- This part of the configuration sets up the PL to use certain Cures
-- at a certain percent of hp of the Target your PLing.
Cure1Percent = 90;
Cure2Percent = 75;
Cure3Percent = 60;
Cure4Percent = 55;
Cure5Percent = 40;

-- Do not edit below this line.

 TargetPlayer = FindPlayer(TargetName);
 Player = GetPlayer()

 -- List of Healing Spells
 local Cures = { { Name = "Cure V", RequiredMP = 135 }, 
     { Name = "Cure IV", RequiredMP = 88 },
     { Name = "Cure III", RequiredMP = 46 },     
     { Name = "Cure II", RequiredMP = 24 },
     { Name = "Cure", RequiredMP = 8 } };

 -- List of Protectra Spells
 local protectras = { { Name = "Protectra V", RequiredMP = 84 }, 
     { Name = "Protectra IV", RequiredMP = 65 },
     { Name = "Protectra III", RequiredMP = 46 },     
     { Name = "Protectra II", RequiredMP = 28 },
     { Name = "Protectra", RequiredMP = 9 } };

 -- List of Shellra Spells
 local shellras = { { Name = "Shellra V", RequiredMP = 93 }, 
     { Name = "Shellra IV", RequiredMP = 75 },
     { Name = "Shellra III", RequiredMP = 56 },     
     { Name = "Shellra II", RequiredMP = 37 },
     { Name = "Shellra", RequiredMP = 18 } };

 -- List of Protect Spells
 local protects = { { Name = "Protect IV", RequiredMP = 65 },
     { Name = "Protect III", RequiredMP = 46 },     
     { Name = "Protect II", RequiredMP = 28 },
     { Name = "Protect", RequiredMP = 9 } };
 -- List of Shell Spells
 local shells = { { Name = "Shell IV", RequiredMP = 75 },
     { Name = "Shell III", RequiredMP = 56 },     
     { Name = "Shell II", RequiredMP = 37 },
     { Name = "Shell", RequiredMP = 18 } };

 function PLBot()
 
  if(PLClass == "White Mage") then
   if(TargetPlayer:GetHitPointPercentage() <= Cure5Percent) then
    if(PLLevel >= 61) then
     Cure5()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure4Percent) then
    if(PLLevel >= 41) then
     Cure4()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure3Percent) then
    if(PLLevel >= 21) then
     Cure3()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure2Percent) then
    if(PLLevel >= 11) then
     Cure2()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure1Percent) then
    if(PLLevel >= 1) then
     Cure1()
    end
   end
   
  elseif(PLClass == "Red Mage") then
   if(TargetPlayer:GetHitPointPercentage() <= Cure4Percent) then
    if(PLLevel >= 48) then
     Cure4()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure3Percent) then
    if(PLLevel >= 26) then
     Cure3()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure2Percent) then
    if(PLLevel >= 14) then
     Cure2()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure1Percent) then
    if(PLLevel >= 3) then
     Cure1()
    end
   end
   
  elseif(PLClass == "Scholar") then
   if(TargetPlayer:GetHitPointPercentage() <= Cure4Percent) then
    if(PLLevel >= 55) then
     Cure4()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure3Percent) then
    if(PLLevel >= 30) then
     Cure3()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure2Percent) then
    if(PLLevel >= 17) then
     Cure2()
    end
   elseif(TargetPlayer:GetHitPointPercentage() <= Cure1Percent) then
    if(PLLevel >= 5) then
     Cure1()
    end
   end
  
  end
  
 end
 
 function Cure1()
  if(Player:GetMagicPoints() >= Cures[5].RequiredMP) then
   SendInput("/ma \""..Cures[5].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function Cure2()
  if(Player:GetMagicPoints() >= Cures[4].RequiredMP) then
   SendInput("/ma \""..Cures[4].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function Cure3()
  if(Player:GetMagicPoints() >= Cures[3].RequiredMP) then
   SendInput("/ma \""..Cures[3].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function Cure4()
  if(Player:GetMagicPoints() >= Cures[2].RequiredMP) then
   SendInput("/ma \""..Cures[2].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function Cure5()
  if(Player:GetMagicPoints() >= Cures[1].RequiredMP) then
   SendInput("/ma \""..Cures[1].Name.."\" "..TargetPlayer:GetName().."");
  end
 end
 
 function PLBotStart()
  timer = CTimer();
  timer:GetOnTick():Connect(PLBot);
  timer:Start(5000);
 end
 
 function PLBotStop()
  timer:Stop();
 end
 
 Alias("PLStart", PLBotStart);
 Alias("PLStop", PLBotStop);



0

#3 User is offline   Pawelz 

  • Script Kiddy
  • Group: New Members
  • Posts: 4
  • Joined: 06-March 10
  • Gender:Male
  • Server: Asura
  • Race: Tarutaru Male

Posted 15 March 2010 - 12:53 PM

You know the DRY rule? Why are you doing Cure1, Cure2 etc. functions? Cure(n) would be enough.
0

#4 User is offline   Azaril 

  • Developer
  • PipPip
  • Group: +Windower Developers
  • Posts: 48
  • Joined: 19-April 05
  • Location:Redmond, WA

Posted 16 March 2010 - 05:54 PM

The whitemage script is pretty functional from the AI code I wrote a while back. It's not the most straight forward code to understand since it implements a full hierachial decision tree to decide what actions to take, but it works pretty well.

http://github.com/Az...dowerluaprivate
Azaril
recvbuf[4]--;
0

#5 User is offline   monk 

  • Script Kiddy
  • Group: New Members
  • Posts: 3
  • Joined: 09-March 10

Posted 17 March 2010 - 01:34 AM

View PostAzaril, on 16 March 2010 - 06:54 PM, said:

The whitemage script is pretty functional from the AI code I wrote a while back. It's not the most straight forward code to understand since it implements a full hierachial decision tree to decide what actions to take, but it works pretty well.

http://github.com/Az...dowerluaprivate



yea nit was wanting me to take a loot at it so i may see what it can do and see how to expand on it :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users