Orion Attack Script Needed

Discussion about the technical aspects of scripting. Ask about all issues involving your freelance projects here.
Post Reply
User avatar
showxxl
Adept Scribe
Posts: 48
Joined: Sat Sep 20, 2014 1:32 pm

Orion Attack Script Needed

Post by showxxl »

Trying out Orion, anyone have a script that targets enemy, casts divine fury when needed, conserate weapon and weapon primary ability?


TY Mucho
vempa
Expert Scribe
Posts: 35
Joined: Thu Apr 04, 2013 7:31 pm

Re: Orion Attack Script Needed

Post by vempa »

Hey,

Here's an ugly little one I use.
It's far from ideal but good enough for my needs and I'm too lazy to revamp.

You can replace PET_IDS with your own pet IDs, if you use any.

V

P.S - there are a couple of config values in there like:

const LOOP_INTERVAL = 400;
const ITERATIONS_FOR_DIV_FURY = 29;
const ITERATIONS_FOR_CONSC_WEP = 15;

or
"if (Player.Mana() > 75) {"

Cast interval is roughly LOOP_INTERVAL * ITERATIONS.
This should work for 115 chiv/max karma.

Code: Select all

function autoAttacker() {
	const PET_IDS = ['0x0021A2CA', '0x002CEA5C', '0x002CEA94', '0x002CEB2A', '0x002CEA9C'];
	
	const ALREADY_DISCORDED_MSG = 'That creature is already in discord.';
	const DISCORD_SUCEEDED = "You play jarring music, suppressing your target's strength.";
	const DISCORD_FAILED = 'You attempt to disrupt your target, but fail';
	const CANNOT_DISCORD = ' A song of discord would have no effect on that';

	const USE_DISCORD = true;
	
	function waitHook() {
		while (Player.Dead() || Player.Hidden() || !Orion.WaitWhileTargeting(10)) {
			Orion.Wait(100);
		}
	}

	function tryDiscordTarget(target) {
		waitHook();
		const discordTime = Orion.Now() - 100;
		Orion.UseSkill('Discordance', target);
		for (var i = 0; i < 10; i++) {
			if (Orion.InJournal(DISCORD_SUCEEDED + '|' + ALREADY_DISCORDED_MSG, 'normal|my|sys', 0, 'any', discordTime)) {
				return true;
			}
			
			if (Orion.InJournal(CANNOT_DISCORD, 'normal|my|sys', 0, 'any', discordTime)) {
				Orion.Ignore(target);
				return true;
			}

			if (Orion.InJournal(DISCORD_FAILED, 'normal|my|sys', 0, 'any', discordTime)) {
				return false;
			}
			
			Orion.Wait(100);
		}
		return false;
	}

	function activateBestAbility() {
		waitHook();
		const names = Orion.GetCurrentAbilityNames();
		if (names[0] === 'Whirlwind Attack' || names[0] === 'Double Shot') {
			Orion.UseAbility('Primary', true);
		} else {
            Orion.UseAbility('Secondary', true);
		}
	}

	function attackTarget(target) {
		waitHook();
		if (Player.Mana() > 75) {
			activateBestAbility();
		}
		Orion.TargetObject(target);
		Orion.Attack(target);
		if (USE_DISCORD) {
			tryDiscordTarget(target);
		}
	}


	const LOOP_INTERVAL = 400;

	const ITERATIONS_FOR_DIV_FURY = 29;
	const ITERATIONS_FOR_CONSC_WEP = 15;

	var divFuryTicks = 0;
	var conscWepTicks = 0;

	Orion.IgnoreReset();
	Orion.Ignore('self', true);
	while (true) {
		for (var i = 0; i < PET_IDS.length; i++) {
			Orion.Ignore(PET_IDS[i], true);
		}

		const enemies = Orion.FindType('-1|!0x00C8', '-1|!0x0A03', "ground", "mobile|near|ignorefriends|live|inlos", "15", "gray|criminal|enemy|red");
		waitHook();
		if (enemies.length > 0) {
			if (divFuryTicks >= ITERATIONS_FOR_DIV_FURY || Player.Stam() <= 200) {
				Orion.Cast('Divine Fury');
				divFuryTicks = 0;
			}
	
			if (conscWepTicks >= ITERATIONS_FOR_CONSC_WEP) {
				Orion.Cast('Consecrate Weapon');
				conscWepTicks = 0;
			}
	
			attackTarget(enemies[0])
		}
		Orion.Wait(LOOP_INTERVAL);
		divFuryTicks++;
		conscWepTicks++;
	}
}

Post Reply