This elaborate set of triggers does several things. Firstly, it detects whether you are in a fight, and which mob you are attacking. When the fight starts, it sends a message to the active window letting you know that, for example, Tokai is in a fight. It then checks who that mob is attacking and identifies that player as the tank. If the mob switches tanks, the value changes and the prog will alert you. It's not particularly useful on its own, though the big clear notices that the tank has switched are a good precaution for me (one less way to get killed). I mostly use this trigger as a basis for other ones, like one that makes sure I don't automatically re-cast fly if I'm fighting, or one that only quaffs another true sight potion if I'm still in the fight.

This trigger assumes you have a variable, @name, with your character's name in it.

 

To start off with, we set up two large string lists in variables containing all the possible variations of attack messages (armed an unarmed).

#VA attacktype {slash|stab|pierce|hit|whip|claw|blast|pound|crush|bite|pierce|suction|bolt|arrow|dart|stone|pea} {fighting}

#VA attacks {misses|brushes|barely scratches|barely scuffs|scratches|scuffs|grazes|nicks|pelts|cuts|bruises|jolts|hits|strikes|wounds|tears|thrashes|injures|rips|batters|gashes|flogs|jars|lacerates|pummels|hacks|smashes|mauls|decimates|rends|bludgeons|_traumatizes_|_devastates_|_mangles_|_shatters_|_maims_|_demolishes_|_cleaves_|_butchers_|_cripples_|MUTILATES|MASSACRES|DISEMBOWELS|PULVERIZES|DISFIGURES|DESTROYS|GUTS|EVISCERATES|* OBLITERATES *|* SLAUGHTERS *|*** ANNIHILATES ***|**** SMITES ****|miss|brush|barely scratch|barely scuff|scratch|scuff|graze|nick|pelt|cut|bruise|jolt|hit|strike|wound|tear|thrash|injur|rip|batter|gash|flog|jar|lacerate|pummel|hack|smash|maul|decimate|rend|bludgeon|_traumatize_|_devastate_|_mangle_|_shatter_|_maim_|_demolishe_|_cleave_|_butcher_|_cripple_|MUTILATE|MASSACRE|DISEMBOWEL|PULVERIZE|DISFIGURE|DESTROY|GUT|EVISCERATE|* OBLITERATE *|* SLAUGHTER *|*** ANNIHILATE ***|**** SMITE ****} {fighting}

With the variables set up, these triggers fire when you attack an enemy. There's multiples because it allows for you attacking armed or unarmed and also in case of the mob dodging or parrying the attack. It removes the spaces so the full name of the mob you are fighting can be stored neatly in a variable, then checks to see if you were already fighting. If you weren't, it sends an echo alerting you to the fact.

#TRIGGER {^Your (%w) (%w) (*){.|!}} {#IF %ismember(%1,@attacktype) {#IF %ismember(%2,@attacks) {#VA fightingmob %replace( %lower( "%3"), " ", "");#IF (@fighting = 0) {#VA fighting 1; #ECHO @name is in a fight!}}} {fighting}

#TRIGGER {^You (%w) (*){.|!}} {#IF %ismember(%1,@attacks) {#VA fightingmob %replace( %lower( "%2"), " ", "");#IF (@fighting = 0) {#VA fighting 1; #ECHO @name is in a fight!}} {fighting}

#TRIGGER {^(*) dodges your attack.$} {#VA fightingmob %replace( %lower( "%1"), " ", "");#IF (@fighting = 0) {#VA fighting 1; #ECHO @name is in a fight!} {fighting}

#TRIGGER {^(*) parries your attack.$} {#VA fightingmob %replace( %lower( "%1"), " ", "");#IF (@fighting = 0) {#VA fighting 1; #ECHO @name is in a fight!} {fighting}

These two triggers fire when something attacks you and check whether that mob is the same one that you're attacking. If so, it will check who the tank is. Again, there is only two of them because one uses the syntax for an unarmed attack, the other for an armed attack.

#TRIGGER {^(*) (%w) (%w){.|!}} {#IF %ismember(%2,@attacks) {#VA fightingmobcheck %replace( %lower( "%1"), " ", "");#IF (%3 = you) {#VA tankcheck self} {#VA tankcheck %3};#IF (@fightingmobcheck = @fightingmob) {#IF (@tank = "") {#VAR tank @tankcheck} {#IF (@tankcheck != @tank) {#VAR tank @tankcheck;#SAY Tank switch detected!;#SAY The new tank is @tank!}}}}} {fighting}

#TRIGGER {^(*)'s (%w) (%w) (%w){.|!}} {#IF %ismember(%2,@attacktype) {#IF %ismember(%3,@attacks) {#VA fightingmobcheck %replace( %lower( "%1"), " ", "");#IF (%4 = you) {#VA tankcheck self} {#VA tankcheck %4};#IF (@fightingmobcheck = @fightingmob) {#IF (@tank = "") {#VAR tank @tankcheck} {#IF (@tankcheck != @tank) {#VAR tank @tankcheck;#SAY Tank switch detected!;#SAY The new tank is @tank!}}}}}} {fighting}

These two reset the variables if you flee or recall out of combat.

#TRIGGER {^You flee head over heels from combat!$} {#VA fighting 0;#VA fightingmob "";#VA tank ""} {fighting}

#TRIGGER {You recall from combat!$} {#VA fighting 0;#VA fightingmob "";#VA tank ""} {fighting}

This trigger fires upon the death of any mob and checks if it was the one you were fighting, and if so, resets the variables. It checks whether you got the killblow too, just because it's nifty.

#TRIGGER {^(*) is DEAD!!$} {#VA linebefore1 %line2;#VA fightingmobcheck %replace( %lower( "%1"), " ", "");#VA killedit %word( @linebefore1, 1);#IF (%pos( "You", @killedit) > 0) {#SAY You got the killblow.};#IF (@fightingmobcheck = @fightingmob) {#SAY Your target is dead.;#VA fighting 0;#VA fightingmob "";#VA tank "";}} {fighting}