Page 1 of 1

Mob Count based Ability Selection

Posted: Sun Sep 05, 2021 9:24 pm
by MagicUser
Hello! I apologize in advance for my excitement. Of all the things that were on my bucket list for a combat macro, smart combat was at the top. I got something that appears to work not only well, but reliably, quickly, and elegant.

I have more surrounding it, but that stuff is not important. Might be nice, but I'd rather show this piece off.

These are Orion Sub functions. As I said before these are called from within my script. The point is to show how it can be done in a setting that actually works rather than a hypothetically scenario that might work. The magic line is:

Code: Select all

mobCount = Orion.FindType('any', 'any', "ground", "mobile", distance, 'gray | criminal | enemy | red').length;
The line says to look for any mobile graphic within distance of any color on the ground that is gray, criminal, enemy, or red. Orion has built in friendly protection so with those settings on it wouldn't attack guild mates or attempt to attack other player. If you wanted to turn this into a attack piece... just chance "mobile" to "mobile | near". This selects the nearest mob (only 1).

Code: Select all

/*
  *Description: Attempt to use ability. Smart (based on surounding mobs) or Primitive (goes through selected abilities).
  *Parameters: 	Action - A timer set to the the delay actDelay (Timer).
  *				  	actDelay - Delay before each action (1250 for more than 237 stam) (Int).
  *
  *					smartCombat - Want combat based on mob count (Boolean).
  *					single - Ability to use for single mobs (String). Primary, Secondary, or MomentumStrike.
  *					multiple - Ability to use for multiple mobs (String). Primary, Secondary, or MomentumStrike.
  *
  *					prim - Want to use primary ability (Boolean).
  *					meansPrim - The numerical representation of prim (Int).
  *					sec - Want to use secondary ability (Boolean).
  *					meansSec - The numerical representation of secondary (Int).
  *					mom - Want to use momentum strike (Boolean).
  *					meansMom - The numerical representation of momentum strike (Int).
  *					actCounter - An action counter to keep track of which action should occur (Int).
  *Returns: 		actCounter - An action counter to keep track of which action should occur (Int).
  *					Action - A timer reset to 0 (Timer).
  */
function attemptAbility() {
	if (Orion.Timer('Action') >= actDelay) {
		if (smartCombat) {
			distance = usingMelee ? "1" : "10";
			mobCount = Orion.FindType('any', 'any', "ground", "mobile", distance, 'gray | criminal | enemy | red').length;
			
			useAbility(mobCount > 1 ? multiple : single);
		}
		else {
			counter = Number(Orion.GetGlobal('actCounter'));
			if (prim && counter == Number(Orion.GetGlobal('meansPrim'))) {
				Orion.UseAbility('Primary', true);
			}
			else if (sec && counter == Number(Orion.GetGlobal('meansSec'))) {
				Orion.UseAbility('Secondary', true);
			}
			else if (mom && counter == Number(Orion.GetGlobal('meansMom'))) {
				Orion.Cast('momentum strike');
			}
			
			counter++;
			if (counter >= actCntrMax)
				Orion.SetGlobal('actCounter', '0');
			else {
				Orion.SetGlobal('actCounter', String(counter));
			}
		}
		
		Orion.SetTimer('Action');
	}
}

/*
  *Discription: A helper function to use the ability based on the decided type.
  *Parameters: type - the type of ability to use (String).
  *Returns: None.
  */
function useAbility(type) {
	if (Orion.Contains('Primary', type)) {
		Orion.UseAbility('Primary', true);
	}
	else if (Orion.Contains('Secondary', type)) {
		Orion.UseAbility('Secondary', true);
	}
	else if (Orion.Contains('MomentumStrike', type)) {
		Orion.Cast('momentum strike');
	}
}

/*
  *Description: Assign the primitive integer meaning of an ability based on the abilities desired.
  *Parameters: 	prim - Want to use primary ability (Boolean).
  *					sec - Want to use secondary ability (Boolean).
  *					mom - Want to use momentum strike (Boolean).
  *Returns:		actCounterMax - The maximum value for an ability (Int).
  *					meansPrim - The integer meaning of Primary Ability (Int).
  *					mennsSec - The integer meaning of the Secondary Ability (Int).
  *					meansMom - The integer meaning of Momentum Strike (Int).
  */
function assignMeaning() {
	actCounterMax = prim + sec + mom;
	
	cntr = 0;
	Orion.SetGlobal('meansPrim', String(prim ? cntr++ : 10));
	Orion.SetGlobal('meansSec', String(sec ? cntr++ : 10));
	Orion.SetGlobal('meansMom', String(mom ? cntr++ : 10));

	return actCounterMax;
}
I have just recently got into Orion as well as JavaScript (the language used above). Previously I had been writing my scripts in UOSteam and then helpers in EasyUO. I even had some GUIs, but there were just too many good things that I had heard about Orion to not check it out while I was on break. Let me know if you have questions. I don't intend to share my full script (for various reasons) currently, but I am happy to hear comments, suggestions, and question.

Thank you for humoring my excitement :D.

Re: Mob Count based Ability Selection

Posted: Tue Sep 07, 2021 5:29 am
by PierreDole
Nice one, but what if all these statements are false?

Code: Select all

if (Orion.Contains('Primary', type)) {
      Orion.UseAbility('Primary', true);
   }
   else if (Orion.Contains('Secondary', type)) {
      Orion.UseAbility('Secondary', true);
   }
   else if (Orion.Contains('MomentumStrike', type)) {
      Orion.Cast('momentum strike');
   }
You won't use any ability then. I think it is better to use a single target ability while surrounded by multiple mobs than none. :)

Re: Mob Count based Ability Selection

Posted: Wed Sep 08, 2021 9:55 pm
by MagicUser
mmm, garbage in. Garbage out. Its true that could be added here. I have default and input control elsewhere.
PierreDole wrote:Nice one, but what if all these statements are false?

You won't use any ability then. I think it is better to use a single target ability while surrounded by multiple mobs than none. :)