Exemple #1
0
 void Ammo(object sender, CommandEventArgs e)
 {
     if (e.length != 1)
     {
         PrintError("Syntax: ammo <item ID>");
         return;
     }
     int ammo;
     if (!int.TryParse(e[0], out ammo))
     {
         PrintError("Invalid ammo.");
         return;
     }
     Main.currItem.useAmmo = ammo;
     PrintNotification("Set selected item's ammo to " + ammo + ".");
 }
Exemple #2
0
 /// <summary>
 /// Executes a string as a command.
 /// </summary>
 public static void Execute(string str, bool repeat = true)
 {
     CommandEventArgs args = new CommandEventArgs(str);
     foreach (Command c in commands)
     {
         if (args[0].ToLower() == c.name || (c.aliases != null && c.aliases.Contains<string>(args[0].ToLower())))
         {
             if (c.name != "repeat" && repeat)
             {
                 lastCommand = str;
             }
             c.callback(c, new CommandEventArgs(str.Substring(args[0].Length)));
             if (c.alert)
             {
                 NetMessage.SendData(25, "*ALERT*: used " + str);
             }
             return;
         }
     }
     Client.PrintError("Invalid command.");
 }
Exemple #3
0
 static void NetSend(object sender, CommandEventArgs e)
 {
     if (e.length < 1 || e.length > 7)
     {
         PrintError("Syntax: netsend <packet ID> [<arg1>] [<arg2>] [<arg3>] [<arg4>] [<arg5>] [<arg6>]");
         return;
     }
     int packet;
     if (!int.TryParse(e[0], out packet))
     {
         PrintError("Invalid packet ID.");
         return;
     }
     int num1 = 0, num5 = 0;
     float num2 = 0, num3 = 0, num4 = 0;
     string str = "";
     try
     {
         if (!int.TryParse(e[2], out num1))
         {
             PrintError("Invalid integer.");
             return;
         }
         if (!float.TryParse(e[3], out num2) || !float.TryParse(e[4], out num3) || !float.TryParse(e[5], out num4))
         {
             PrintError("Invalid float.");
             return;
         }
         if (!int.TryParse(e[6], out num5))
         {
             PrintError("Invalid integer.");
             return;
         }
     }
     catch (IndexOutOfRangeException)
     {
     }
     finally
     {
         NetMessage.SendData(packet, str, num1, num2, num3, num4, num5);
         PrintNotification("Sent " + packet + ", " + (str == "" ? "\"\"" : str) + ", " + num1 + ", " + num2 + ", " + num3 + ", " + num4 + ", " + num5);
     }
 }
Exemple #4
0
 void Track(object sender, CommandEventArgs e)
 {
     track = !track;
     PrintNotification((track ? "En" : "Dis") + "abled player tracking.");
 }
Exemple #5
0
 void ShootSpeed(object sender, CommandEventArgs e)
 {
     if (e.length != 1)
     {
         PrintError("Syntax: shootspeed <speed>");
         return;
     }
     float shootSpeed;
     if (!float.TryParse(e[0], out shootSpeed))
     {
         PrintError("Invalid shoot speed.");
         return;
     }
     Main.currItem.shootSpeed = shootSpeed;
     PrintNotification("Set selected item's shoot speed to " + shootSpeed + ".");
 }
Exemple #6
0
 void Ruler(object sender, CommandEventArgs e)
 {
     ruler = !ruler;
     PrintNotification((ruler ? "En" : "Dis") + "abled ruler.");
 }
Exemple #7
0
 void MaxStack(object sender, CommandEventArgs e)
 {
     if (e.length > 1)
     {
         PrintError("Syntax: maxstack [all|ammo]");
         return;
     }
     if (e.length == 0)
     {
         Main.currItem.stack = Main.currItem.maxStack;
         PrintNotification("Maximized selected item's stack size.");
     }
     else
     {
         switch (e[0])
         {
             case "all":
                 for (int i = 0; i < Main.currPlayer.inventory.Length; i++)
                 {
                     Main.currPlayer.inventory[i].stack = Main.currPlayer.inventory[i].maxStack;
                 }
                 PrintNotification("Maximized all items' stack size.");
                 break;
             case "ammo":
                 for (int i = 0; i < Main.currPlayer.inventory.Length; i++)
                 {
                     if (Main.currPlayer.inventory[i].ammo != 0)
                     {
                         Main.currPlayer.inventory[i].stack = Main.currPlayer.inventory[i].maxStack;
                     }
                 }
                 PrintNotification("Maximized all ammos' stack size.");
                 break;
             default:
                 PrintError("Invalid maxstack option.");
                 return;
         }
     }
 }
Exemple #8
0
 void Jump(object sender, CommandEventArgs e)
 {
     Main.currPlayer.position = Main.screenPosition + new Vector2(Input.mX, Input.mY);
 }
Exemple #9
0
 void Fullbright(object sender, CommandEventArgs e)
 {
     fullbright = !fullbright;
     PrintNotification((fullbright ? "En" : "Dis") + "abled fullbright.");
 }
Exemple #10
0
 void Damage(object sender, CommandEventArgs e)
 {
     if (e.length != 1)
     {
         PrintError("Syntax: damage <damage>");
         return;
     }
     int damage;
     if (!int.TryParse(e[0], out damage) || damage <= 0)
     {
         PrintError("Invalid damage.");
         return;
     }
     Main.currItem.damage = damage;
     PrintNotification("Set selected item's damage to " + damage + ".");
 }
Exemple #11
0
 void ClearInv(object sender, CommandEventArgs e)
 {
     for (int i = 10; i < Main.currPlayer.inventory.Length; i++)
     {
         Main.currPlayer.inventory[i] = TerrariAPI.Hooking.Item.New();
     }
     PrintNotification("Cleared inventory.");
 }
Exemple #12
0
 void Buff(object sender, CommandEventArgs e)
 {
     if (e.length != 1 && e.length != 2)
     {
         PrintError("Syntax: buff <buff> [<time>]");
         return;
     }
     Match match = Command.GetBuff(e[0]);
     if (match.ID > 0)
     {
         int time = 300;
         if (e.length == 2 && !int.TryParse(e[1], out time))
         {
             PrintError("Invalid time.");
             return;
         }
         Main.currPlayer.AddBuff(match.ID, time * 60);
         PrintNotification("Buffed " + match.name + " for " + time + " seconds.");
     }
 }
Exemple #13
0
 static void Say(object sender, CommandEventArgs e)
 {
     if (e.plainText == "")
     {
         PrintError("No text to send.");
         return;
     }
     if (Main.multiplayer)
     {
         NetMessage.SendData(25, e.plainText.Substring(1));
     }
     else
     {
         PrintError("Not connected to a server.");
     }
 }
Exemple #14
0
 static void Repeat(object sender, CommandEventArgs e)
 {
     if (Command.lastCommand == null)
     {
         PrintError("No last command.");
         return;
     }
     Command.Execute(Command.lastCommand);
 }
Exemple #15
0
 void Item(object sender, CommandEventArgs e)
 {
     if (e.length != 1 && e.length != 2)
     {
         PrintError("Syntax: item <item> [<stack>]");
         return;
     }
     Match match = Command.GetItem(e[0]);
     if (match.ID > 0)
     {
         dynamic item = TerrariAPI.Hooking.Item.New();
         item.SetDefaults(match.ID);
         int stack = item.maxStack;
         if (e.length == 2 && !int.TryParse(e[1], out stack))
         {
             PrintError("Invalid stack size.");
             return;
         }
         int index = TerrariAPI.Hooking.Item.NewItem((int)Main.currPlayer.position.X, (int)Main.currPlayer.position.Y,
             Main.currPlayer.width, Main.currPlayer.height, match.ID, stack);
         Main.items[index] = Main.currPlayer.GetItem(Main.playerIndex, Main.items[index]);
         PrintNotification("Spawned " + stack + " " + match.name + "(s).");
     }
 }
Exemple #16
0
 void God(object sender, CommandEventArgs e)
 {
     godMode = !godMode;
     PrintNotification((godMode ? "En" : "Dis") + "abled god mode.");
 }
Exemple #17
0
 void ItemPickup(object sender, CommandEventArgs e)
 {
     pickupItems = !pickupItems;
     PrintNotification((pickupItems ? "Dis" : "En") + "abled item pickups.");
 }
Exemple #18
0
 void GPS(object sender, CommandEventArgs e)
 {
     gps = !gps;
     PrintNotification((gps ? "En" : "Dis") + "abled GPS.");
 }
Exemple #19
0
 void ListInv(object sender, CommandEventArgs e)
 {
     if (e.length != 1)
     {
         PrintError("Syntax: listinv <player>");
         return;
     }
     Match match = Command.GetPlayer(e[0]);
     if (match.ID >= 0)
     {
         for (int i = 0; i < Main.players[match.ID].inventory.Length; i++)
         {
             dynamic item = Main.players[match.ID].inventory[i];
             PrintNotification("Index " + i + ": " + item.stack + " " + item.name + ".");
         }
     }
 }
Exemple #20
0
 void Heal(object sender, CommandEventArgs e)
 {
     PrintNotification("Healed " + (Main.currPlayer.statLifeMax - Main.currPlayer.statLife) + " HP.");
     if (Main.currPlayer.statLife != Main.currPlayer.statLifeMax)
     {
         for (int i = 0; i <= (Main.currPlayer.statLifeMax - Main.currPlayer.statLife) / 20; i++)
         {
             int index = TerrariAPI.Hooking.Item.NewItem((int)Main.currPlayer.position.X, (int)Main.currPlayer.position.Y,
                 Main.currPlayer.width, Main.currPlayer.height, 58);
         }
     }
 }
Exemple #21
0
 void Noclip(object sender, CommandEventArgs e)
 {
     noclip = !noclip;
     PrintNotification((noclip ? "En" : "Dis") + "abled noclip.");
 }
Exemple #22
0
 void InfBuff(object sender, CommandEventArgs e)
 {
     if (e.length != 1 && e.length != 2)
     {
         PrintError("Syntax: infbuff <buff>");
         return;
     }
     Match match = Command.GetBuff(e[0]);
     if (match.ID > 0)
     {
         infBuff[match.ID] = !infBuff[match.ID];
         PrintNotification((infBuff[match.ID] ? "En" : "Dis") + "abled infinite buff for " + match.name + ".");
     }
 }
Exemple #23
0
 void Shoot(object sender, CommandEventArgs e)
 {
     if (e.length != 1)
     {
         PrintError("Syntax: shoot <projectile>");
         return;
     }
     Match match = Command.GetProjectile(e[0]);
     if (match.ID >= 0)
     {
         Main.currItem.shoot = match.ID;
         PrintNotification("Set selected item to shoot " + match.name + ".");
     }
 }
Exemple #24
0
 void InfMana(object sender, CommandEventArgs e)
 {
     infMana = !infMana;
     PrintNotification((infMana ? "En" : "Dis") + "abled infinite mana.");
 }
Exemple #25
0
 void Tp(object sender, CommandEventArgs e)
 {
     if (e.length != 1)
     {
         PrintError("Syntax: tp <player>");
         return;
     }
     Match match = Command.GetPlayer(e[0]);
     if (match.ID >= 0)
     {
         Main.currPlayer.position = Main.players[match.ID].position;
         NetMessage.SendData(13, "", Main.playerIndex);
         PrintNotification("Teleported to " + match.name + ".");
     }
 }
Exemple #26
0
 void InfRange(object sender, CommandEventArgs e)
 {
     bool infRange = Player.tileRangeX == 10000;
     infRange = !infRange;
     if (infRange)
     {
         Player.tileRangeX = Player.tileRangeY = 10000;
     }
     else
     {
         Player.tileRangeX = 5;
         Player.tileRangeY = 4;
     }
     PrintNotification((infRange ? "En" : "Dis") + "abled infinite range.");
 }
Exemple #27
0
 void Usetime(object sender, CommandEventArgs e)
 {
     if (e.length != 1)
     {
         PrintError("Syntax: usetime <time>");
         return;
     }
     int useTime;
     if (!int.TryParse(e[0], out useTime))
     {
         PrintError("Invalid usetime.");
         return;
     }
     Main.currItem.useTime = useTime;
     PrintNotification("Set selected item's usetime to " + useTime + ".");
 }
Exemple #28
0
 void InfWings(object sender, CommandEventArgs e)
 {
     infWings = !infWings;
     PrintNotification((infWings ? "En" : "Dis") + "abled infinite wings.");
 }
Exemple #29
0
 void AutoReuse(object sender, CommandEventArgs e)
 {
     Main.currItem.autoReuse = !Main.currItem.autoReuse;
     PrintNotification((Main.currItem.autoReuse ? "En" : "Dis") + "abled autoreuse for the selected item.");
 }
Exemple #30
0
 static void Macro(object sender, CommandEventArgs e)
 {
     if (e.length == 0)
     {
         PrintError("Syntax: macro <name> [<args>]");
         return;
     }
     if (!File.Exists(e[0] + ".macro"))
     {
         PrintError("Invalid macro.");
         return;
     }
     string[] args = new string[e.length - 1];
     for (int i = 0; i < args.Length; i++)
     {
         args[i] = e[i + 1];
     }
     using (StreamReader reader = new StreamReader(e[0] + ".macro"))
     {
         string line;
         while ((line = reader.ReadLine()) != null)
         {
             Command.Execute(string.Format(line, args));
         }
     }
     PrintNotification("Executed macro '" + e[0] + ".'");
 }