Skip to content

Commit

Permalink
Lots of changes
Browse files Browse the repository at this point in the history
Works with new drops UI.
Skill timer starts with script. Skill and drop timers stop with script.
Fixed shop ID grabber.
Hunt... fixed. All kill/hunts work with * for any monster.
Added grim->script converter (buggy).
Added ability to aggro all monsters in map.
Added toggles for AQLite settings.
Script errors show line numbers.
Added support for referencing other cs files in script.
  • Loading branch information
rodit committed Oct 12, 2021
1 parent e0971d4 commit 47df5c6
Show file tree
Hide file tree
Showing 85 changed files with 1,906 additions and 236 deletions.
105 changes: 80 additions & 25 deletions RBot/ActionScript/rbot/src/xyz/rodit/rbot/Main.as
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ package xyz.rodit.rbot
}

public static function loadGameClient(swfFile: String):void {
if (swfFile != undefined) {
if (swfFile != null) {
Main.instance.clientSwfFile = swfFile;
}

Expand Down Expand Up @@ -280,19 +280,39 @@ package xyz.rodit.rbot
var all:Boolean = whitelist == "*";
var pickup:Array = whitelist.split(",");
var accepted:* = [];
var children:int = instance.game.ui.dropStack.numChildren;
for (var i:int = 0; i < children; i++)
if (instance.game.litePreference.data.bCustomDrops)
{
var child:* = instance.game.ui.dropStack.getChildAt(i);
var type:String = getQualifiedClassName(child);
if (type.indexOf("DFrame2MC") != -1)
var source:* = instance.game.cDropsUI.mcDraggable ? instance.game.cDropsUI.mcDraggable.menu : instance.game.cDropsUI;
for (var i: int = 0; i < source.numChildren; i++)
{
var drop:* = parseDrop(child.cnt.strName.text);
var name:* = drop.name;
if ((all || pickup.indexOf(name) > -1) && accepted.indexOf(name) == -1)
var child:* = source.getChildAt(i);
if (child.itemObj)
{
child.cnt.ybtn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
accepted.push(name);
var itemName:String = child.itemObj.sName.toLowerCase();
if ((all || pickup.indexOf(itemName) > -1) && accepted.indexOf(itemName) == -1)
{
child.btYes.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
accepted.push(itemName);
}
}
}
}
else
{
var children:int = instance.game.ui.dropStack.numChildren;
for (var i:int = 0; i < children; i++)
{
var child:* = instance.game.ui.dropStack.getChildAt(i);
var type:String = getQualifiedClassName(child);
if (type.indexOf("DFrame2MC") != -1)
{
var drop:* = parseDrop(child.cnt.strName.text);
var name:* = drop.name;
if ((all || pickup.indexOf(name) > -1) && accepted.indexOf(name) == -1)
{
child.cnt.ybtn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
accepted.push(name);
}
}
}
}
Expand All @@ -301,18 +321,37 @@ package xyz.rodit.rbot
public static function rejectExcept(whitelist:String):void
{
var pickup:Array = whitelist.split(",");
var children:int = instance.game.ui.dropStack.numChildren;
for (var i:int = 0; i < children; i++)
if (instance.game.litePreference.data.bCustomDrops)
{
var child:* = instance.game.ui.dropStack.getChildAt(i);
var type:String = getQualifiedClassName(child);
if (type.indexOf("DFrame2MC") != -1)
var source:* = instance.game.cDropsUI.mcDraggable ? instance.game.cDropsUI.mcDraggable.menu : instance.game.cDropsUI;
for (var i: int = 0; i < source.numChildren; i++)
{
var drop:* = parseDrop(child.cnt.strName.text);
var name:* = drop.name;
if (pickup.indexOf(name) == -1)
var child:* = source.getChildAt(i);
if (child.itemObj)
{
child.cnt.nbtn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
var itemName:String = child.itemObj.sName.toLowerCase();
if (pickup.indexOf(itemName) == -1)
{
child.btNo.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
}
}
}
else
{
var children:int = instance.game.ui.dropStack.numChildren;
for (var i:int = 0; i < children; i++)
{
var child:* = instance.game.ui.dropStack.getChildAt(i);
var type:String = getQualifiedClassName(child);
if (type.indexOf("DFrame2MC") != -1)
{
var drop:* = parseDrop(child.cnt.strName.text);
var name:* = drop.name;
if (pickup.indexOf(name) == -1)
{
child.cnt.nbtn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
}
}
}
Expand Down Expand Up @@ -467,13 +506,29 @@ package xyz.rodit.rbot
{
var children:int = instance.game.ui.dropStack.numChildren;
var drops:* = [];
for (var i:int = 0; i < children; i++)
if (instance.game.litePreference.data.bCustomDrops)
{
var source:* = instance.game.cDropsUI.mcDraggable ? instance.game.cDropsUI.mcDraggable.menu : instance.game.cDropsUI;
for (var i: int = 0; i < source.numChildren; i++)
{
var child:* = source.getChildAt(i);
if (child.itemObj)
{
var count: int = child.txtDrop.text.split("x ")[1];
drops.push({name: child.itemObj.sName, count: count});
}
}
}
else
{
var child:* = instance.game.ui.dropStack.getChildAt(i);
var type:String = getQualifiedClassName(child);
if (type.indexOf("DFrame2MC") > -1)
for (var i:int = 0; i < children; i++)
{
drops.push(parseDrop(child.cnt.strName.text));
var child:* = instance.game.ui.dropStack.getChildAt(i);
var type:String = getQualifiedClassName(child);
if (type.indexOf("DFrame2MC") > -1)
{
drops.push(parseDrop(child.cnt.strName.text));
}
}
}
return JSON.stringify(drops);
Expand Down
2 changes: 1 addition & 1 deletion RBot/AppRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void Init()

new Option<string>("client.swf", "Client SWF", "The SWF file to be loaded as the game client.", "spider.swf"),

new Option<bool>("secret.zmana", "", "", false)
new Option<bool>("secret.zmana", "Zero Mana Skills", "Skills require zero mana to use.")
});

Options.SetDefaults();
Expand Down
2 changes: 1 addition & 1 deletion RBot/BotConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public CodeStringBuilder EndIf()

public CodeStringBuilder AppendIf(string condition)
{
AppendLine($"if({condition})");
AppendLine($"if ({condition})");
InIf = true;
return this;
}
Expand Down
10 changes: 10 additions & 0 deletions RBot/BotConverters/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace RBot.BotConverters
{
public static class Extensions
{
public static string ToLower(this bool b)
{
return b.ToString().ToLower();
}
}
}
20 changes: 20 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/AcceptQuest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Quest.CmdAcceptQuest", "Grimoire.Botting.Commands.Quest.CmdAcceptQuest2")]
public class AcceptQuest : ICodeGenerator
{
public QuestHolder Quest { get; set; }
public string QuestID { get; set; }

public string Id => Quest?.Id.ToString() ?? QuestID;

public void GenerateCode(CodegenTextWriter code) => code.WriteLine($"bot.Quests.EnsureAccept({Id.GetCode("int")});");
}

public class QuestHolder
{
public int Id { get; set; }
}
}
12 changes: 12 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/Attack.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Combat.CmdAttack")]
public class Attack : ICodeGenerator
{
public string Monster { get; set; }

public void GenerateCode(CodegenTextWriter code) => code.WriteLine($"bot.Player.Attack({Monster.GetCode()});");
}
}
13 changes: 13 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/BankSwap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Item.CmdBankSwap")]
public class BankSwap : ICodeGenerator
{
public string BankItemName { get; set; }
public string InventoryItemName { get; set; }

public void GenerateCode(CodegenTextWriter code) => code.WriteLine($"bot.Bank.Swap({InventoryItemName.GetCode()}, {BankItemName.GetCode()});");
}
}
13 changes: 13 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/BankTransfer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Item.CmdBankTransfer")]
public class BankTransfer : ICodeGenerator
{
public bool TransferFromBank { get; set; }
public string ItemName { get; set; }

public void GenerateCode(CodegenTextWriter code) => code.WriteLine(TransferFromBank ? $"bot.Bank.ToInventory({ItemName.GetCode()});" : $"bot.Inventory.ToBank({ItemName.GetCode()});");
}
}
12 changes: 12 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/Blank.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Misc.CmdBlank", "Grimoire.Botting.Commands.Misc.CmdBlank2", "Grimoire.Botting.Commands.Misc.CmdBlank3")]
public class Blank : ICodeGenerator
{
public string Text { get; set; }

public void GenerateCode(CodegenTextWriter code) => code.WriteLine(string.IsNullOrWhiteSpace(Text) ? "// Blank" : $"// {Text}");
}
}
13 changes: 13 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/Buy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Item.CmdBuy")]
public class Buy : ICodeGenerator
{
public int ShopId { get; set; }
public string ItemName { get; set; }

public void GenerateCode(CodegenTextWriter code) => code.WriteLine($"bot.Shops.BuyItem({ShopId}, {ItemName.GetCode()});");
}
}
13 changes: 13 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/BuyById.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Item.CmdBuyById")]
public class BuyById : ICodeGenerator
{
public string ItemID { get; set; }
public string ShopID { get; set; }

public void GenerateCode(CodegenTextWriter code) => code.WriteLine($"bot.Shops.BuyItem({ShopID.GetCode("int")}, {ItemID.GetCode("int")});");
}
}
12 changes: 12 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/BuyFast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Item.CmdBuyFast")]
public class BuyFast : ICodeGenerator
{
public string ItemName { get; set; }

public void GenerateCode(CodegenTextWriter code) => code.WriteLine($"bot.Shops.BuyItem({ItemName.GetCode()});");
}
}
11 changes: 11 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/BuyFastById.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Item.CmdBuyFastByID")]
public class BuyFastById : ICodeGenerator
{
public string ItemID { get; set; }
public string ShopID { get; set; }

public string GenerateCode() => $"bot.Shops.BuyItem({ShopID}, {ItemID});";
}
}
10 changes: 10 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/CancelAutoAttack.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Combat.CmdCancelAutoAttack")]
public class CancelAutoAttack : ICodeGenerator
{
public void GenerateCode(CodegenTextWriter code) => code.WriteLine("bot.Player.CancelAutoAttack();");
}
}
10 changes: 10 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/CancelTarget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Combat.CmdCancelTarget")]
public class CancelTarget : ICodeGenerator
{
public void GenerateCode(CodegenTextWriter code) => code.WriteLine("bot.Player.CancelTarget()");
}
}
13 changes: 13 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/Change.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Misc.CmdChange")]
public class Change : ICodeGenerator
{
public bool Guild { get; set; }
public string Text { get; set; }

public void GenerateCode(CodegenTextWriter code) => code.WriteLine($"bot.Options.{(Guild ? "CustomGuild" : "CustomName")} = {Text.GetCode()};");
}
}
10 changes: 10 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/ClearTemp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Misc.ClearTemp")]
public class ClearTemp : ICodeGenerator
{
public void GenerateCode(CodegenTextWriter code) => code.WriteLine("bot.Config.SetDefaults();");
}
}
13 changes: 13 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/ClientMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Misc.CmdClientMessage")]
public class ClientMessage : ICodeGenerator
{
public string Messages { get; set; }
public bool IsWarning { get; set; }

public void GenerateCode(CodegenTextWriter code) => code.WriteLine($"bot.SendClientPacket(\"%xt%{(IsWarning ? "warning" : "server")}%-1%{Messages}%\");");
}
}
16 changes: 16 additions & 0 deletions RBot/BotConverters/Grimoire/Commands/CompleteQuest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using CodegenCS;

namespace RBot.BotConverters.Grimoire.Commands
{
[Map("Grimoire.Botting.Commands.Quest.CmdCompleteQuest", "Grimoire.Botting.Commands.Quest.CmdCompleteQuest2")]
public class CompleteQuest : ICodeGenerator
{
public QuestHolder Quest { get; set; }
public string QuestID { get; set; }
public string ItemID { get; set; }

public string Id => Quest?.Id.ToString() ?? QuestID;

public void GenerateCode(CodegenTextWriter code) => code.WriteLine($"bot.Quests.EnsureComplete({Id.GetCode("int")}, {ItemID?.GetCode("int") ?? "-1"});");
}
}
Loading

0 comments on commit 47df5c6

Please sign in to comment.