Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How do you make and use variables?

Featured Replies

I want to randomize my spells / actions a bit by using variables so the bot will look human. This might be very very easy but I dont know how to do it, it may help other new people.

 

This is what I am trying to do:

Var Random = (1-3)
  
 if (Frostbolt.KnownSpell && ObjectManager.Target.GetDistance < 30 && Random = 1)
        {
            Frostbolt.Launch();
  			Random = (1-3);
        }
 if (ArcaneMissiles.KnownSpell && ObjectManager.Target.GetDistance < 30 && Random = 2)
        {
            ArcaneMissiles.Launch();
  			Random = (1-3);
        }
 if (Fireball.KnownSpell && ObjectManager.Target.GetDistance < 30 && Random = 3)
        {
            Fireball.Launch();
  			Random = (1-3);
        }

Does anyone know the proper code to do this?

Do I need to put public bool in the beginning of the script?

var random = new Random().Next(1,4);

You can test it in the dev tools, do this (with execution type set to C#):
 

var random = new Random().Next(1,4);
Logging.Write(random.ToString());

DevTools help:https://marsbars.gitlab.io/unoffical-wrobot-api-docs/articles/devtools.html

Edited by Marsbar

public class Example1
{
  private static var newVarible = "something";
  public static string newVariable
  { 
        get { return name; }
        set { name = value; }
  }
}

public class Example2
{
  if (Example1.newVariable == "something")
  {
    print(Example1.newVariable);
    //Output: something
  }
}

Keep in mind these are very loosely based examples just to depict what is going on

Ugh...stupid edits removed my code examples...im kind of mad I had a quick lesson in variables for you =/. The above one that survived tries to explain how variables can cross "scopes" and be used across multiple classes. If you are just working with variables within a single class, you only need to declare the variable above the code you will use it in:

public class Example3
{
	var newVariable = "something";
	if (1 = 1)
	{
		print(newVariable);
		//output: something
		newVariable = "something else";
		print(newVariable);
		//output: something else
	}
	else
	{
		print(newVariable);
		//output: something
		newVariable = "something new";
	}
	print(newVariable);
	//output: something else as 1 = 1
}

 

Anyway, here's a snipplet that will work for your particular case:

string[] spells = new [] {"frostbolt", "arcane missles", "fireball"};
string[] shuffled = spells.OrderBy(n => Guid.NewGuid()).ToArray();

if (wManager.Wow.Helpers.SpellManager.KnowSpell(shuffled[0]) && ObjectManager.Target.GetDistance < 30)
{
    wManager.Wow.Helpers.SpellManager.CastSpellByNameLUA(shuffled[0]);
}

Arrays are just groups of variables under one umbrella that are given index numbers (starting at 0) so they can be referenced in a plethora of ways. In this snipplet, your spell names populate a string array called "spells". another array "shuffled" takes the values in "spells" and assigns/reorders them with new Guids- which is basically a tricking the array into shuffling the index numbers of the spells. This means every time the code is called, the contents of shuffled[0] changes randomly.

Tip: declaring a "var" simply tells the interpreter it's on it's own when it comes to parsing the value of the variable. var can be replaced with things like string,int,float etc to designate specifically what kind of value you are storing. In the case above, string[] designates the array will consist of strings, where int[] would designate the array consists of numbers/intergers.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.