Advertisement
imk0tter

Untitled

Jul 15th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.62 KB | None | 0 0
  1. /*
  2.  * Created by SharpDevelop.
  3.  * User: Administrator
  4.  * Date: 7/14/2011
  5.  * Time: 11:23 PM
  6.  *
  7.  * To change this template use Tools | Options | Coding | Edit Standard Headers.
  8.  */
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using Delta9;
  13. using pwnagebot.LotroInterface;
  14. namespace SiegeOfGondomon
  15. {
  16.     /// <summary>
  17.     /// Description of MyClass.
  18.     /// </summary>
  19.     public class SiegeOfGondamon : Delta9Methods, Delta9Method
  20.     {   ArrayList loadedSkills;
  21.         ArrayList loadedNpcs;  
  22.         SkillContainer summonSoldier;
  23.         bool findNewTarget = false;
  24.         int maxRange = 35;
  25.         int maxMathiDist = 20;
  26.         public SiegeOfGondamon(Delta9Instance i,string args) : base(i,args) {
  27.             scriptName = "Siege of Gondomon";
  28.         }
  29.         public override void Run() {
  30.             Initialize();
  31.             while (KeepGoing()) {
  32.                 if (KeepGoing()) WalkToMathi();
  33.                 if (KeepGoing()) KillNearestNpc();
  34.                 if (KeepGoing()) SummonSoldier();
  35.             }
  36.             Debug("Stopped script!");
  37.         }
  38.         void WalkToMathi() {
  39.             LotroEntity e = GetEntityByName("Mathi",100);
  40.             if (e != null) {
  41.                 if (e.DistanceTo(GetMe()) > maxMathiDist) {
  42.                     Debug("Walking to Mathi");
  43.                     WalkToWait(e,5);
  44.                 }
  45.             }
  46.         }
  47.         void KillNearestNpc() {
  48.             LotroEntity e = GetEntityByName(loadedNpcs,maxRange);
  49.             if (e != null) {
  50.                 Debug("Killing Nearest NPC: "+e.Name);
  51.                 while (e.Dead != true && !findNewTarget) {
  52.                     foreach (SkillContainer f in loadedSkills) {
  53.                         f.Cast(e);
  54.                     }
  55.                 }
  56.                 if (findNewTarget) {
  57.                     findNewTarget = false;
  58.                 }
  59.                 else if (e.Lootable) {
  60.                     Debug("Looting coorpse");
  61.                     WalkToWait(e,2);
  62.                     SelectTarget(e);
  63.                     Face(e);
  64.                     Wait(200);
  65.                     Loot(e);
  66.                     WalkToMathi();
  67.                     Wait(1000);
  68.                 }
  69.             }
  70.         }
  71.         void SummonSoldier() {
  72.             LotroEntity e = GetEntityByName("Warrior",50);
  73.             if (e == null && GetMe().CombatActive == false) {
  74.                 Wait(1000);
  75.                 summonSoldier.Cast();
  76.             }
  77.         }
  78.        
  79.         private void Initialize() {
  80.             Debug("Loaded script...");
  81.             LoadConfig();
  82.             Interface.OnLineOfSight += new EventHandler<EventArgs>(NewTarget);
  83.             Interface.OnInvalidTarget += new EventHandler<EventArgs>(NewTarget);
  84.         }
  85.         private void LoadConfig() {
  86.             // Create a dictionary of Section elements called
  87.             // configSections
  88.             loadedSkills = new ArrayList();
  89.             loadedNpcs = new ArrayList();
  90.             Dictionary<string, Dictionary<string,string>>
  91.                 configSections =
  92.                 ParseConfig("scripts/SiegeOfGondamon.ini");
  93.            
  94.             if (configSections.ContainsKey("Skills")) {
  95.                 Dictionary<string, string> skillSection = null;
  96.                 configSections.TryGetValue("Skills",out skillSection);
  97.                 if (skillSection != null) {
  98.                     string val = "";
  99.                     for (int i = 1; i < 10; ++i) {
  100.                         bool result = skillSection.TryGetValue("Skill" + i, out val);
  101.                         if (result) {
  102.                             string name = val;
  103.                             skillSection.TryGetValue("Skill"+i+"Focus",out val);
  104.                             int focus = int.Parse(val);
  105.                             skillSection.TryGetValue("Skill"+i+"Delay",out val);
  106.                             int delay = int.Parse(val);
  107.                             skillSection.TryGetValue("Skill"+i+"Hotkey",out val);
  108.                             int hotkey = int.Parse(val);
  109.                             skillSection.TryGetValue("Skill"+i+"Range",out val);
  110.                             int range = int.Parse(val);
  111.                             skillSection.TryGetValue("Skill"+i+"Induction",out val);
  112.                             int induction = int.Parse(val);
  113.                             loadedSkills.Add(
  114.                                 new SkillContainer(
  115.                                     this,name,hotkey,delay,focus,range,induction
  116.                                 )
  117.                             );
  118.                             Debug("Skill loaded: Name="+name+", Hotkey="+hotkey+", Delay="+delay+", Range="+range);
  119.                         }
  120.                     }
  121.                     if (skillSection.TryGetValue("SkillSoldier",out val)) {
  122.                         string name = val;
  123.                         skillSection.TryGetValue("SkillSoldierFocus",out val);
  124.                         int focus = int.Parse(val);
  125.                         skillSection.TryGetValue("SkillSoldierDelay",out val);
  126.                         int delay = int.Parse(val);
  127.                         skillSection.TryGetValue("SkillSoldierHotkey",out val);
  128.                         int hotkey = int.Parse(val);
  129.                         skillSection.TryGetValue("SkillSoldierRange",out val);
  130.                         int range = int.Parse(val);
  131.                         skillSection.TryGetValue("SkillSoldierInduction",out val);
  132.                         int induction = int.Parse(val);
  133.                         summonSoldier = new SkillContainer(
  134.                             this,name,hotkey,delay,focus,range,induction
  135.                         );
  136.                         Debug("Summon Soldier Loaded: Name="+name+", Hotkey="+hotkey+", Delay="+delay+", Range="+range);
  137.                     }  
  138.                 }
  139.                 Dictionary<string, string> configSection = null;
  140.                 configSections.TryGetValue("Config",out configSection);
  141.                 if (configSection != null) {
  142.                     string val = "false";
  143.                     configSection.TryGetValue("Melee",out val);
  144.                     if (bool.Parse(val)) {
  145.                         maxRange = 4;
  146.                     }
  147.                     else {
  148.                         maxRange = 35;
  149.                     }
  150.                     val = "20";
  151.                     configSection.TryGetValue("MaxMathiDist",out val);
  152.                     maxMathiDist = int.Parse(val);
  153.                 }
  154.                 Dictionary<string, string> npcSection = null;
  155.                 configSections.TryGetValue("Npcs",out npcSection);
  156.                 if (npcSection != null) {
  157.                     foreach (string s in npcSection.Values) {
  158.                         if (s != null) {
  159.                             loadedNpcs.Add(s);
  160.                             Debug("Loaded NPC: "+s);
  161.                         }
  162.                     }
  163.                 }
  164.             }
  165.             else {
  166.                 Debug("Error loading config.. Termininating script..");
  167.                 Stop();
  168.             }
  169.         }
  170.         private bool KeepGoing() {
  171.             if (Running) {
  172.                 Wait(1000);
  173.                 return true;
  174.             }
  175.             return false;
  176.         }
  177.         #region Event Handlers
  178.         public override void OnDeath(object o, EventArgs e) {
  179.            
  180.         }
  181.         public void NewTarget(object o, EventArgs e) {
  182.             findNewTarget = true;
  183.         }
  184.         #endregion
  185.     }
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement