Help expanding automacro trigger conditions

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

Message
Author
Historm
Human
Human
Posts: 27
Joined: 01 Jun 2011, 01:59
Noob?: No

Help expanding automacro trigger conditions

#1 Post by Historm »

I want to make my kore-operated support cast Lex on the same target that I cast a skill on.

For example, as soon as I begin casting Gfist, I want my priest to lex the target.

Attackskillslot has no triggers for when a party member casts a spell, neither does docommand. It seems that a macro is my only option.

However, the automacro trigger "spell" only supports triggering when the self or party member is the target if a spell. It does not seem to support triggering for skills cast by your party on other monsters or players.

I do not know how to rewrite the "if" statements in the code, or even which lines I need to edit. I understand the developers are busy and can't be expected to rewrite the code for me. I do understand C++ programming, however, and if someone could point me in the right direction I can edit the code myself.

I believe the following code is responsible for the "spell" trigger in automacro, please correct me if I am wrong.

Code: Select all

# checks for a spell casted on us/party members #########################
# uses: distance, judgeSkillArea (Utils?)
sub checkCast {
	my ($cast, $args) = @_;
	return 0 if $args->{sourceID} eq $accountID;
	
	$cast = lc($cast);
	my $party = ($cast =~ s/^party +//)?1:0;
	my $pos = calcPosition($char);
	my $target = (defined $args->{targetID})?$args->{targetID}:0;
	my $source = $args->{sourceID};
	return 0 if $target eq $source;

	if (($target eq $accountID || ($pos->{x} == $args->{x} && $pos->{y} == $args->{y}) || distance($pos, $args) <= judgeSkillArea($args->{skillID})) && existsInList($cast, lc(Skill->new(idn => $args->{skillID})->getName()))) {
		if (my $actor = $monstersList->getByID($source)) {
			$varStack{".caster"} = "monster";
			$varStack{".casterName"} = $actor->{name};
			$varStack{".casterID"} = $actor->{binID};
			$varStack{".casterPos"} = $actor->{pos_to}{x} ." ". $actor->{pos_to}{y};
			$varStack{".casterDist"} = sprintf("%.1f", distance($pos, calcPosition($actor)))

		}
		elsif (my $actor = $playersList->getByID($source)) {
			$varStack{".caster"} = "player";
			$varStack{".casterName"} = (defined $actor->{name})?$actor->{name}:"Unknown";
			$varStack{".casterID"} = $actor->{binID};
			$varStack{".casterPos"} = $actor->{pos_to}{x} ." ". $actor->{pos_to}{y};
			$varStack{".casterDist"} = sprintf("%.1f", distance($pos, calcPosition($actor)));

		}
		else {return 0}
		$varStack{".casterSkill"} = Skill->new(idn => $args->{skillID})->getName();
		$varStack{".casterTarget"} = $args->{x} ." ". $args->{y};
		$varStack{".casterTargetName"} = $char->{name};
		return 1
	}
	elsif ($party && existsInList($cast, lc(Skill->new(idn => $args->{skillID})->getName()))) {
		return 0 if !$char->{'party'} || !%{$char->{'party'}};
		if (my $actor = $monstersList->getByID($source)) {
			foreach my Actor::Player $player (@{$playersList->getItems()}) {
				next unless sameParty($player->{name});
				if ($target eq $player->{ID} || ($player->{pos_to}{x} == $args->{x} && $player->{pos_to}{y} == $args->{y}) || distance($player->{pos}, $args) <= judgeSkillArea($args->{skillID})) {
					$varStack{".caster"} = "monster";
					$varStack{".casterName"} = $actor->{name};
					$varStack{".casterID"} = $actor->{binID};
					$varStack{".casterPos"} = $actor->{pos_to}{x} ." ". $actor->{pos_to}{y};
					$varStack{".casterSkill"} = Skill->new(idn => $args->{skillID})->getName();
					$varStack{".casterTarget"} = $args->{x} ." ". $args->{y};
					$varStack{".casterTargetName"} = $player->{name};
					$varStack{".casterDist"} = sprintf("%.1f", distance($pos, calcPosition($actor)));
					return 1
				}
			}

		}
		elsif (my $actor = $playersList->getByID($source)) {
			return 0 if sameParty($actor->{name});
			foreach my Actor::Player $player (@{$playersList->getItems()}) {
				next unless sameParty($player->{name});
				if ($target eq $player->{ID} || ($player->{pos_to}{x} == $args->{x} && $player->{pos_to}{y} == $args->{y}) || distance($player->{pos}, $args) <= judgeSkillArea($args->{skillID})) {
					$varStack{".caster"} = "player";
					$varStack{".casterName"} = (defined $actor->{name})?$actor->{name}:"Unknown";
					$varStack{".casterID"} = $actor->{binID};
					$varStack{".casterPos"} = $actor->{pos_to}{x} ." ". $actor->{pos_to}{y};
					$varStack{".casterSkill"} = Skill->new(idn => $args->{skillID})->getName();
					$varStack{".casterTarget"} = $args->{x} ." ". $args->{y};
					$varStack{".casterTargetName"} = $player->{name};
					$varStack{".casterDist"} = sprintf("%.1f", distance($pos, calcPosition($actor)));
					return 1
				}
			}
		}
		else {return 0}
	} 
	else {return 0}
}

wang1337
Noob
Noob
Posts: 12
Joined: 18 May 2011, 21:12
Noob?: No

Re: Help expanding automacro trigger conditions

#2 Post by wang1337 »

I don't think your best bet is editing the checkCast sub. You could do a few easier things first.

1. Just have your priest cast lex every 3 seconds. Just make it not use a weapon to attack, attack party aggressive monsters only and set up an attackskillslot with conditions like which monsters and not too many aggressives so it won't put you in postdelay when you need to heal.

2. Some people suggest having your main damage dealer follow your priest and do the same thing as above except your priest attacks first and your monk assists, this option means the first hit will always be lex'd. This is more aimed towards mages though.

3. Write an automacro to just read the console and check for:

Player Monkname (0) is casting Guillotine Fist on Monster Mobname (1) (Delay: xxxms)

And that triggers the macro to cast lex on Mobname (1).

Something like:

Code: Select all

automacro lex {
  console /Player (.*) \((\d+)\) is casting Guillotine Fist on Monster (.*) \((\d+)\).*/i

  call {
    do sm 78 $.lastMatch4
  }
}
For this to work however you need a decent ping for it to trigger and cast in time. Macro is untested.

vitriol
Plain Yogurt
Plain Yogurt
Posts: 61
Joined: 19 Apr 2011, 23:26
Noob?: No

Re: Help expanding automacro trigger conditions

#3 Post by vitriol »

just use the console condition to detect when gfist is cast

Code: Select all

console ("<text>" | /<regexp>/[i])
iirc, the console message will contain the monster id. so you can call a macro to cast lex on the monster using their id


so in pseudo-code

Code: Select all

automacro detect {
console /player (name) (ID) has cast gfist on monster (name) (ID)
call castLex
}

macro castLex {
do sp # (ID)
}
use $.lastMatch# to get teh monster id



EDIT: whoops, the post above mine already gave that method. if only it didnt take so long for the admins to approve a post, i wouldnt have posted this, as its redundant -.-

Post Reply