//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
// Projet: MQ2Melee.cpp     |// 2008-04-02: Updated by Wasted
// Author: s0rCieR          |// 2008-11-08: Updated by Jobey
//                          |// 2008-11-26: Updated by htw
//                          |// 2009-02-21: Updated by pms (MoveUtils 9.x support)
//                          |// 2010-10-21: Updated by maskoi (House of Thule abilities)
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
// SHOW_ABILITY:    0=0ff, 1=Display every ability that plugin use.
// SHOW_ATTACKING:  0=0ff, 1=Display Attacking Target
// SHOW_ENRAGING:   0=0ff, 1=Display Enrage/Infuriate
// SHOW_FEIGN:      0=0ff, 1=Display Fallen Detected
// SHOW_OVERRIDE:   0=0ff, 1=Display Override Warning
// SHOW_STICKING:   0=0ff, 1=Display Stick Arguments
// SHOW_SWITCHING:  0=0ff, 1=Display Switch Melee/Range
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
// Distribution of this code in compile form without source code is prohebited.
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
#define   PLUGIN_NAME  "MQ2Melee"   // Plugin Name
#define   PLUGIN_DATE   20101129    // Plugin Date
#define   PLUGIN_VERS      4.959    // Plugin Version

#define   SHOW_ABILITY         0
#define   SHOW_ATTACKING       1
#define   SHOW_CASTING         0
#define   SHOW_CONTROL         0
#define   SHOW_ENRAGING        1
#define   SHOW_FEIGN           1
#define   SHOW_OVERRIDE        1
#define   SHOW_PROVOKING       0
#define   SHOW_STICKING        0
#define   SHOW_STUNNING        0
#define   SHOW_SWITCHING       1

#define   NOID                -1
#define   delay              250


enum {
    Tiny               =0,    // Container Size - Tiny
    Small              =1,    // Container Size - Small
    Medium             =2,    // Container Size - Medium
    Large              =3,    // Container Size - Large
    Giant              =4,    // Container Size - Giant
    Huge               =5,    // Container Size - Huge
};

enum {
    st_x          =0x0000,    // SpawnType: NONE
    st_cn         =0x0020,    // SpawnType: CORPSENPC
    st_cp         =0x0010,    // SpawnType: CORPSEPLAYER
    st_wn         =0x0008,    // SpawnType: PETNPC
    st_wp         =0x0004,    // SpawnType: PETPLAYER
    st_n          =0x0002,    // SpawnType: NPC
    st_p          =0x0001,    // SpawnType: PLAYER
};

enum {
    inv_range         =11,    // Inventory.Range      Slot ID
    inv_primary       =13,    // Inventory.Primary    Slot ID
    inv_secondary     =14,    // Inventory.Secondary  Slot ID
    inv_ammo          =22,    // Inventory.Ammo       Slot ID
};

#ifndef PLUGIN_API
#include "../MQ2Plugin.h"
PreSetup(PLUGIN_NAME);
PLUGIN_VERSION(PLUGIN_VERS);
#include <map>
#include <string>
#include "../Blech/Blech.h"
#endif PLUGIN_API

#include "../moveitem.h"

//MoveUtils 9.x
void (*fStickCommand)(PSPAWNINFO pChar, char* szLine);
bool* pbStickOn;
PLUGIN_API bool bMULoaded = false;
bool bMUPointers = false;

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

bool      DebugReady    = false;           // Use for debuffing Ability->Ready();
bool      BardClass     = false;           // Bard Class?
bool      Silenced      = false;           // Silenced?
long      BuffMax       = 30;              // Maximum Number of Buffs
long      SongMax       = 12;              // Maximum Number of Songs
long      GemsMax       = 12;              // Maximum Number of Gems
short     PET_BUTTONS   = 14;              // Number of buttons on Pet UI window

long      InvSlot       =NOID;             // slot # where item is found
PCONTENTS InvCont       =NULL;             // slot content pointer

bool      Sticking      =false;            // Stick Saved State On/Off?
char      StickArg[128] ={0};              // Stick Saved Arguments

char      Reserved[MAX_STRING];            // string buffer
char      Workings[MAX_STRING];            // string buffer

typedef   void  (__cdecl *Function)(void);
struct    infodata {long i,t; } *pinfodata;

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

#define   d_assassin1      10898
#define   d_assassin2      10899
#define   d_assassin3      10900
#define   d_ashenhand       4508
#define   d_heelofkanji     8473
#define   d_silentfist      4507
#define   d_thunderkick     4511
#define   d_cleaveanger     5043
#define   d_cleaverage      5037

#define   i_disarm            16
#define   i_forage            27
#define   i_intimidation      71
#define   i_kick              30
#define   i_mend              32
#define   i_taunt             73
#define   i_harmtouch        6000


infodata btlleap = {611   ,4},   // aa: battle leap
asp         = {986   ,4},        // aa: bite of the asp

assault1    = {22540 ,3},        // disc: Assault
assault2    = {22541 ,3},        // disc: Assault Rk. II
assault3    = {22542 ,3},        // disc: Assault Rk. III
assault4    = {26142 ,3},        // disc: Battery
assault5    = {26143 ,3},        // disc: Battery Rk. II
assault6    = {26144 ,3},        // disc: Battery Rk. III

bleed1      = {22540 ,3},        // disc: bleed
bleed2      = {22541 ,3},        // disc: bleed Rk. II
bleed3      = {22542 ,3},        // disc: bleed Rk. III
bleed4      = {26142 ,3},        // disc: Wound
bleed5      = {26143 ,3},        // disc: Wound Rk. II
bleed6      = {26144 ,3},        // disc: Wound Rk. III

bvivi1    	= {27098 ,3},        // disc: Bestial Vivisection 
bvivi2    	= {27099 ,3},        // disc: Bestial Vivisection Rk. II
bvivi3    	= {27100 ,3},        // disc: Bestial Vivisection Rk. III

boastful    = {199   ,4},        // aa: boastful bellow
callchal    = {552   ,4},        // aa: call of challenge
commanding  = {8000  ,3},        // disc: commanding voice

cripple1    = {4928   ,3},       // disc: leg strike
cripple2    = {4929   ,3},       // disc: leg cut
cripple3    = {4930   ,3},       // disc: leg slice
cripple4    = {8205   ,3},       // disc: crippling strike
cripple5    = {10908  ,3},       // disc: tendon cleave
cripple6    = {10909  ,3},       // disc: tendon cleave rk. ii
cripple7    = {10910  ,3},       // disc: tendon cleave rk. iii
cripple8    = {14177  ,3},       // disc: tendon sever
cripple9    = {14178  ,3},       // disc: tendon sever rk. ii
cripple10   = {14179  ,3},       // disc: tendon sever rk. iii
cripple11   = {18198  ,3},       // disc: tendon shear
cripple12   = {18199  ,3},       // disc: tendon shear rk. ii
cripple13   = {18200  ,3},       // disc: tendon shear rk. iii
cripple14   = {27263  ,3},       // disc: tendon lacerate
cripple15   = {27264  ,3},       // disc: tendon lacerate rk. ii
cripple16   = {27265  ,3},       // disc: tendon lacerate rk. iii

cryhavoc    = {8003  ,3},        // disc: cry havoc
cstrike     = {11080 ,4},        // aa: Chameleon Strike

defense1    = {22556 ,3},        // disc: Bracing Defense
defense2    = {22557 ,3},        // disc: Bracing Defense Rk. II
defense3    = {22558 ,3},        // disc: Bracing Defense Rk. III
defense4    = {25051 ,3},        // disc: Staunch Defense
defense5    = {25052 ,3},        // disc: Staunch Defense Rk. II
defense6    = {25053 ,3},        // disc: Staunch Defense Rk. III

escape      = {102   ,4},        // aa: escape
eyegouge    = {470  ,3},         // aa: eye gouge

feignid     = {420   ,4},        // aa: imitate death
feigndp     = {428   ,4},        // aa: death peace
feigns1     = {366   ,5},        // spell: feign death
feigns2     = {3685  ,5},        // spell: comatose
feigns3     = {1460  ,5},        // spell: death peace
feigns4     = {10306 ,5},        // spell: last breath
feigns5     = {10307 ,5},        // spell: last breath rk ii
feigns6     = {10308 ,5},        // spell: last breath rk iii
feigns7     = {15223 ,5},        // spell: rigor mortis
feigns8     = {15224 ,5},        // spell: rigor mortis rk ii
feigns9     = {15225 ,5},        // spell: rigor mortis rk iii
feigns10    = {15190 ,5},        // spell: last gasp
feigns11    = {15191 ,5},        // spell: last gasp rk ii
feigns12    = {15192 ,5},        // spell: last gasp rk iii
feigns13    = {19343 ,5},        // spell: Final Breath
feigns14    = {19344 ,5},        // spell: Final Breath rk ii
feigns15    = {19345 ,5},        // spell: Final Breath rk iii
feigns16    = {25662 ,5},        // spell: Last Breath
feigns17    = {25663 ,5},        // spell: Last Breath rk ii
feigns18    = {25664 ,5},        // spell: Last Breath rk iii

feign_bst   = {11073 ,4},        // aa: playing possum

feign_n1    = {25662 ,5},        // spell: Scapegoat
feign_n2    = {25663 ,5},        // spell: Scapegoat rk ii
feign_n3    = {25664 ,5},        // spell: Scapegoat rk iii

fieldarm1   = {19917 ,3},        // disc: Field Armorer
fieldarm2   = {19918 ,3},        // disc: Field Armorer Rk. II
fieldarm3   = {19919 ,3},        // disc: Field Armorer Rk. III
fieldarm4   = {25036 ,3},        // disc: Field Outfitter
fieldarm5   = {25037 ,3},        // disc: Field Outfitter Rk. II
fieldarm6   = {25038 ,3},        // disc: Field Outfitter Rk. III

feral1      = {247   ,4},        // aa: feral swipe
fistswu     = {8002  ,3},        // disc: fists of wu

fclaw1      = {27119 ,3},        // disc: flurry of claws
fclaw2      = {27120 ,3},        // disc: flurry of claws rk. ii
fclaw3      = {27121 ,3},        // disc: flurry of claws rk. iii

gorillasmash = {988   ,4},       // aa: gorilla smash
gutpunch    = {3732  ,4},        // aa: gut punch
harmtouch   = {6000  ,4},        // aa: harmtouch

honor1      = {10173 ,5},        // spell: challenge for honor
honor2      = {10174 ,5},        // spell: challenge for honor rk ii
honor3      = {10175 ,5},        // spell: challenge for honor rk iii
honor4      = {14954 ,5},        // spell: trial for honor
honor5      = {14955 ,5},        // spell: trial for honor rk ii
honor6      = {14956 ,5},        // spell: trial for honor rk iii
honor7      = {19068 ,5},        // spell: Charge for Honor
honor8      = {19069 ,5},        // spell: Charge for Honor rk ii
honor9      = {19070 ,5},        // spell: Charge for Honor rk iii
honor10     = {25297 ,5},        // spell: Confrontation for Honor
honor11     = {25298 ,5},        // spell: Confrontation for Honor rk ii
honor12     = {25299 ,5},        // spell: Confrontation for Honor rk iii

joltber1    = {4934  ,3},        // disc: diversive strike
joltber2    = {4935  ,3},        // disc: distracting strike
joltber3    = {4936  ,3},        // disc: confusing strike
joltber4    = {6171  ,3},        // disc: baffling strike
joltber5    = {10920 ,3},        // disc: jarring strike
joltber6    = {10921 ,3},        // disc: jarring strike rk ii
joltber7    = {10922 ,3},        // disc: jarring strike rk iii
joltber8    = {14186 ,3},        // disc: jarring smash
joltber9    = {14187 ,3},        // disc: jarring smash rk ii
joltber10   = {14188 ,3},        // disc: jarring smash rk iii
joltber11   = {18207 ,3},        // disc: Jarring Clash
joltber12   = {18208 ,3},        // disc: Jarring Clash rk ii
joltber13   = {18209 ,3},        // disc: Jarring Clash rk iii
joltber14   = {27290 ,3},        // disc: Jarring Slam
joltber15   = {27291 ,3},        // disc: Jarring Slam rk ii
joltber16   = {27292 ,3},        // disc: Jarring Slam rk iii

joltbst1    = {362   ,4},        // aa: roar of thunder

joltrng1    = {1741  ,5},        // spell: jolt
joltrng2    = {1296  ,5},        // spell: cinder jolt

jltkicks1   = {10086 ,3},        // disc: jolting kicks
jltkicks2   = {10087 ,3},        // disc: jolting kicks rk ii
jltkicks3   = {10088 ,3},        // disc: jolting kicks rk iii
jltkicks4   = {15020 ,3},        // disc: Jolting Snapkicks
jltkicks5   = {15021 ,3},        // disc: Jolting Snapkicks rk ii
jltkicks6   = {15022 ,3},        // disc: Jolting Snapkicks rk iii
jltkicks7   = {19152 ,3},        // disc: Jolting Frontkicks
jltkicks8   = {19153 ,3},        // disc: Jolting Frontkicks rk ii
jltkicks9   = {19154 ,3},        // disc: Jolting Frontkicks rk iii
jltkicks10  = {25432 ,3},        // disc: Jolting Hook kicks
jltkicks11  = {25433 ,3},        // disc: Jolting Hook kicks rk ii
jltkicks12  = {25434 ,3},        // disc: Jolting Hook kicks rk iii

kneestrike  = {801   ,4},        // aa: knee strike
layhand     = {6001  ,4},        // aa: lay on hands

leop1       = {6752  ,3},        // disc: leopard claw
leop2       = {6727  ,3},        // disc: dragon fang
leop3       = {10944 ,3},        // disc: clawstriker flurry
leop4       = {10945 ,3},        // disc: clawstriker flurry rk ii
leop5       = {10946 ,3},        // disc: clawstriker flurry rk iii
leop6       = {14796 ,3},        // disc: wheel of fists
leop7       = {14797 ,3},        // disc: wheel of fists rk ii
leop8       = {14798 ,3},        // disc: wheel of fists rk iii
leop9       = {18901 ,3},        // disc: whorl of fists
leop10      = {18902 ,3},        // disc: whorl of fists rk ii
leop11      = {18903 ,3},        // disc: whorl of fists rk iii
leop12      = {25926 ,3},        // disc: Six-Step Pattern
leop13      = {25927 ,3},        // disc: Six-Step Pattern ii
leop14      = {25928 ,3},        // disc: Six-Step Pattern rk iii

mendpet1    = {58    ,4},        // aa: mend companion
mendpet2    = {418   ,4},        // aa: replenish companion

opfrenzy1   = {16918 ,3},        // disc: Overpowering Frenzy 
opfrenzy2   = {16919 ,3},        // disc: Overpowering Frenzy Rk. II
opfrenzy3   = {16920 ,3},        // disc: Overpowering Frenzy Rk. III
opfrenzy4   = {27260 ,3},        // disc: Overwhelming Frenzy 
opfrenzy5   = {27261 ,3},        // disc: Overwhelming Frenzy Rk. II
opfrenzy6   = {27262 ,3},        // disc: Overwhelming Frenzy Rk. III

opstrke1    = {15375 ,3},        // disc: opportunistic strike
opstrke2    = {15376 ,3},        // disc: opportunistic strike rk ii
opstrke3    = {15377 ,3},        // disc: opportunistic strike rk iii
opstrke4    = {25027 ,3},        // disc: Strategic Strike
opstrke5    = {25028 ,3},        // disc: Strategic Strike rk ii
opstrke6    = {25029 ,3},        // disc: Strategic Strike rk iii

potfast0    = {77789 ,7},        // potion: Distillate of Divine Healing I
potfast1    = {77790 ,7},        // potion: Distillate of Divine Healing II
potfast2    = {77791 ,7},        // potion: Distillate of Divine Healing III
potfast3    = {77792 ,7},        // potion: Distillate of Divine Healing IV
potfast4    = {77793 ,7},        // potion: Distillate of Divine Healing V
potfast5    = {77794 ,7},        // potion: Distillate of Divine Healing VI
potfast6    = {77795 ,7},        // potion: Distillate of Divine Healing VII
potfast7    = {77796 ,7},        // potion: Distillate of Divine Healing VIII
potfast8    = {77797 ,7},        // potion: Distillate of Divine Healing IX
potfast9    = {77798 ,7},        // potion: Distillate of Divine Healing X
potfast10   = {35930 ,7},        // potion: Distillate of Divine Healing XI
potfast11   = {35935 ,7},        // potion: Distillate of Divine Healing XII
potfast12   = {35940 ,7},        // potion: Distillate of Divine Healing XIII
potfast13   = {40554 ,7},        // potion: Distillate of Divine Healing XIV
potfast14   = {56941 ,7},        // potion: Distillate of Divine Healing XV

potover0    = {77779 ,7},        // potion: Distillate of Celestial Healing I
potover1    = {77780 ,7},        // potion: Distillate of Celestial Healing II
potover2    = {77781 ,7},        // potion: Distillate of Celestial Healing III
potover3    = {77782 ,7},        // potion: Distillate of Celestial Healing IV
potover4    = {77783 ,7},        // potion: Distillate of Celestial Healing V
potover5    = {77784 ,7},        // potion: Distillate of Celestial Healing VI
potover6    = {77785 ,7},        // potion: Distillate of Celestial Healing VII
potover7    = {77786 ,7},        // potion: Distillate of Celestial Healing VIII
potover8    = {77787 ,7},        // potion: Distillate of Celestial Healing IX
potover9    = {77788 ,7},        // potion: Distillate of Celestial Healing X
potover10   = {35931 ,7},        // potion: Distillate of Celestial Healing XI
potover11   = {35936 ,7},        // potion: Distillate of Celestial Healing XII
potover12   = {35941 ,7},        // potion: Distillate of Celestial Healing XIII
potover13   = {40555 ,7},        // potion: Distillate of Celestial Healing XIV
potover14   = {56942 ,7},        // potion: Distillate of Celestial Healing XV

power1      = {10260 ,5},        // spell: challenge for power
power2      = {10261 ,5},        // spell: challenge for power rk ii
power3      = {10262 ,5},        // spell: challenge for power rk iii
power4      = {15163 ,5},        // spell: trial for power
power5      = {15164 ,5},        // spell: trial for power rk ii
power6      = {15165 ,5},        // spell: trial for power rk iii
power7      = {19316 ,5},        // spell: Charge for Power 
power8      = {19317 ,5},        // spell: Charge for Power rk ii
power9      = {19318 ,5},        // spell: Charge for Power rk iii
power10     = {25586 ,5},        // spell: Confrontation for Power 
power11     = {25587 ,5},        // spell: Confrontation for Power rk ii
power12     = {25588 ,5},        // spell: Confrontation for Powerr rk iii

prowar_1    = {4608  ,3},        // disc: provoke
prowar_2    = {4681  ,3},        // disc: bellow
prowar_3    = {4682  ,3},        // disc: berate
prowar_4    = {4697  ,3},        // disc: incite
prowar_5    = {5015  ,3},        // disc: bellow of the mastruq
prowar_6    = {5016  ,3},        // disc: ancient: chaos cry
prowar_7    = {6173  ,3},        // disc: bazu bellow
prowar_8    = {10974 ,3},        // disc: scowl
prowar_9    = {10975 ,3},        // disc: scowl rk ii
prowar_10   = {10976 ,3},        // disc: scowl rk iii
prowar_11   = {15360 ,3},        // disc: sneer
prowar_12   = {15361 ,3},        // disc: sneer rk ii
prowar_13   = {15362 ,3},        // disc: sneer rk iii
prowar_14   = {19531 ,3},        // disc: jeer rk i
prowar_15   = {19532 ,3},        // disc: jeer rk ii
prowar_16   = {19533 ,3},        // disc: jeer rk iii
prowar_17   = {19537 ,3},        // disc: bazu bluster
prowar_18   = {19538 ,3},        // disc: bazu bluster rk. ii
prowar_19   = {19539 ,3},        // disc: bazu bluster rk. iii
prowar_20   = {25018 ,3},        // disc: bazu roar
prowar_21   = {25019 ,3},        // disc: bazu roar rk. ii
prowar_22   = {25020 ,3},        // disc: bazu roar rk. iii
prowar_23   = {25045 ,3},        // disc: scoff
prowar_24   = {25046 ,3},        // disc: scoff rk. ii
prowar_25   = {25047 ,3},        // disc: scoff rk. iii

rake1       = {8782  ,3},        // disc: rake
rake2       = {14158 ,3},        // disc: harrow
rake3       = {14159 ,3},        // disc: harrow rk ii
rake4       = {14160 ,3},        // disc: harrow rk iii
rake5       = {18170 ,3},        // disc: foray
rake6       = {18171 ,3},        // disc: foray rk ii
rake7       = {18172 ,3},        // disc: foray rk iii
rake8       = {27219 ,3},        // disc: rush
rake9       = {27220 ,3},        // disc: rush rk ii
rake10      = {27221 ,3},        // disc: rush rk iii

rallos1     = {19741 ,3},        // disc: Axe of Rallos 
rallos2     = {19742 ,3},        // disc: Axe of Rallos Rk. II
rallos3     = {19743 ,3},        // disc: Axe of Rallos Rk. III
rallos4     = {27293 ,3},        // disc: Axe of Graster Rk. III
rallos5     = {27294 ,3},        // disc: Axe of Graster Rk. III
rallos6     = {27295 ,3},        // disc: Axe of Graster Rk. III

rightidg1   = {25345 ,3},        // disc: Righteous Indignation
rightidg2   = {25346 ,3},        // disc: Righteous Indignation Rk. II
rightidg3   = {25347 ,3},        // disc: Righteous Indignation Rk. III

ravens      = {987   ,4},        // aa: raven's claw

slapface1   = {27269 ,3},        // disc: slap in the face
slapface2   = {27270 ,3},        // disc: slap in the face rk ii
slapface3   = {27271 ,3},        // disc: slap in the face rk iii

selos       = {8205  ,4},        // aa: selos

strike1     = {4659  ,3},        // disc: sneak attack
strike2     = {4685  ,3},        // disc: thief's vengeance
strike3     = {4686  ,3},        // disc: assasin strike
strike4     = {5017  ,3},        // disc: kyv strike
strike5     = {5018  ,3},        // disc: ancient chaos strike
strike6     = {6174  ,3},        // disc: daggerfall
strike7     = {8470  ,3},        // disc: razor arc
strike8     = {15133, 3},        // disc: swiftblade
strike9     = {15134, 3},        // disc: swiftblade rk ii
strike10    = {15135, 3},        // disc: swiftblade rk iii
strike11    = {19281, 3},        // disc: Daggerlunge
strike12    = {19282, 3},        // disc: Daggerlunge rk ii
strike13    = {19283, 3},        // disc: Daggerlunge rk iii
strike14    = {26148, 3},        // disc: Daggerswipe
strike15    = {26149, 3},        // disc: Daggerswipe rk ii
strike16    = {26150, 3},        // disc: Daggerswipe rk iii

stunber1    = {4931  ,3},        // disc: head strike
stunber2    = {4932  ,3},        // disc: head pummel
stunber3    = {4933  ,3},        // disc: head crush
stunber4    = {6170  ,3},        // disc: mind strike
stunber5    = {10917 ,3},        // disc: temple blow
stunber6    = {10918 ,3},        // disc: temple blow rk ii
stunber7    = {10919 ,3},        // disc: temple blow rk iii
stunber8    = {14183 ,3},        // disc: temple strike
stunber9    = {14184 ,3},        // disc: temple strike rk ii
stunber10   = {14185 ,3},        // disc: temple strike rk iii
stunber11   = {18204 ,3},        // disc: Temple Bash
stunber12   = {18205 ,3},        // disc: Temple Bash rk ii
stunber13   = {18206 ,3},        // disc: Temple Bash rk iii
stunber14   = {27281 ,3},        // disc: Temple Chop
stunber15   = {27282 ,3},        // disc: Temple Chop rk ii
stunber16   = {27283 ,3},        // disc: Temple Chop rk iii

stunmnk1    = {469   ,4},        // aa: stunning kick
stunmnk2    = {600   ,4},        // aa: resounding kick

stunaas1    = {73    ,4},        // aa: divine stun
stunaas2    = {702   ,4},        // aa: hand of disruption
stunaas3    = {3826  ,4},        // aa: force of disruption

stunpal1    = {216   ,5},        // spell: stun
stunpal2    = {123   ,5},        // spell: holy might
stunpal3    = {3975  ,5},        // spell: force of akera
stunpal4    = {3245  ,5},        // spell: force of akilae
stunpal5    = {4977  ,5},        // spell: ancient force of chaos
stunpal6    = {5284  ,5},        // spell: force of piety
stunpal7    = {5299  ,5},        // spell: ancient force of jeron
stunpal8    = {10158 ,5},        // spell: sacred force
stunpal9    = {10159 ,5},        // spell: sacred force rk ii
stunpal10   = {10160 ,5},        // spell: sacred force rk iii
stunpal11   = {11851 ,5},        // spell: force of prexus
stunpal12   = {14942 ,5},        // spell: solemn force
stunpal13   = {14943 ,5},        // spell: solemn force rk ii
stunpal14   = {14944 ,5},        // spell: solemn force rk iii
stunpal15   = {14984 ,5},        // spell: Force of Timorous
stunpal16   = {14985 ,5},        // spell: Force of Timorous  rk ii
stunpal17   = {14986 ,5},        // spell: Force of Timorous  rk iii
stunpal18   = {19056 ,5},        // spell: Devout Force
stunpal19   = {19057 ,5},        // spell: Devout Force rk ii
stunpal20   = {19058 ,5},        // spell: Devout Force rk iii
stunpal21   = {19098 ,5},        // spell: Force of the Crying Seas
stunpal22   = {19099 ,5},        // spell: Force of the Crying Seas ii
stunpal23   = {19100 ,5},        // spell: Force of the Crying Seas rk iii
stunpal24   = {25282 ,5},        // spell: Earnest Force
stunpal25   = {25283 ,5},        // spell: Earnest Force rk ii
stunpal26   = {25284 ,5},        // spell: Earnest Force rk iii
stunpal27   = {25375 ,5},        // spell: Force of Marr
stunpal28   = {25376 ,5},        // spell: Force of Marr rk. ii
stunpal29   = {25377 ,5},        // spell: Force of Marr rk iii

synergy1    = {18895 ,3},        // disc: Calanin's Synergy 
synergy2    = {18896 ,3},        // disc: Calanin's Synergy Rk. II
synergy3    = {18897 ,3},        // disc: Calanin's Synergy Rk. III
synergy4    = {25907 ,3},        // disc: Dreamwalker's Synergy Rk. III
synergy5    = {25908 ,3},        // disc: Dreamwalker's Synergy Rk. III
synergy6    = {25909 ,3},        // disc: Dreamwalker's Synergy Rk. III

terror1     = {1223  ,5},        // spell: terror of death
terror2     = {1224  ,5},        // spell: terror of terris
terror3     = {3405  ,5},        // spell: terror of thule
terror4     = {5329  ,5},        // spell: terror of discord
terror5     = {10257 ,5},        // spell: terror of vergalid
terror6     = {10258 ,5},        // spell: terror of vergalid rk ii
terror7     = {10259 ,5},        // spell: terror of vergalid rk iii
terror8     = {15160 ,5},        // spell: terror of the Soulbleeder
terror9     = {15161 ,5},        // spell: terror of the Soulbleeder rk ii
terror10    = {15162 ,5},        // spell: terror of the Soulbleeder rk iii
terror11    = {19313 ,5},        // spell: Terror of Jelvalak
terror12    = {19314 ,5},        // spell: Terror of Jelvalak rk ii
terror13    = {19315 ,5},        // spell: Terror of Jelvalak rk iii
terror14    = {25580 ,5},        // spell: Terror of Rerekalen
terror15    = {25581 ,5},        // spell: Terror of Rerekalen rk ii
terror16    = {25582 ,5},        // spell: Terror of Rerekalen rk iii

thiefeye    = {8001  ,3},        // disc: thief's eye

throat1     = {10968 ,3},        // disc: throat jab
throat2     = {10969 ,3},        // disc: throat jab rk ii
throat3     = {10970 ,3},        // disc: throat jab rk iii

tstone      = {5225  ,3},        // disc: throw stone
twisted     = {670   ,4},        // aa: twisted shank

volley1     = {6754  ,3},        // disc: rage volley
volley2     = {6729  ,3},        // disc: destroyer's volley
volley3     = {10926 ,3},        // disc: giant slayer's volley
volley4     = {10927 ,3},        // disc: giant slayer's volley rk ii
volley5     = {10928 ,3},        // disc: giant slayer's volley rk iii
volley6     = {11928 ,3},        // disc: annihilator's volley
volley7     = {11929 ,3},        // disc: annihilator's volley rk ii
volley8     = {11930 ,3},        // disc: annihilator's volley rk iii
volley9     = {14195 ,3},        // disc: decimator's volley
volley10    = {14196 ,3},        // disc: decimator's volley rk ii
volley11    = {14197 ,3},        // disc: decimator's volley rk iii
volley12    = {18216 ,3},        // disc: Eradicator's Volley
volley13    = {18217 ,3},        // disc: Eradicator's Volley Rk. II
volley14    = {18218 ,3},        // disc: Eradicator's Volley Rk. III
volley15    = {27287 ,3},        // disc: Savage Volley
volley16    = {27288 ,3},        // disc: Savage Volley Rk. II
volley17    = {27289 ,3},        // disc: Savage Volley Rk. III

vigber1     = {19753 ,3},        // disc: Vigorous Axe Throw
vigber2     = {19754 ,3},        // disc: Vigorous Axe Throw Rk. II
vigber3     = {19755 ,3},        // disc: Vigorous Axe Throw Rk. III
vigber4     = {27278 ,3},        // disc: Energetic Axe Throw
vigber5     = {27279 ,3},        // disc: Energetic Axe Throw Rk. II
vigber6     = {27280 ,3},        // disc: Energetic Axe Throw Rk. III

vigmnk1     = {19826 ,3},        // disc: Vigorous Shuriken
vigmnk2     = {19827 ,3},        // disc: Vigorous Shuriken Rk. II
vigmnk3     = {19828 ,3},        // disc: Vigorous Shuriken Rk. III

vigrog1     = {19871 ,3},        // disc: Vigorous Dagger-Throw
vigrog2     = {19872 ,3},        // disc: Vigorous Dagger-Throw Rk. II
vigrog3     = {19873 ,3},        // disc: Vigorous Dagger-Throw Rk. III
vigrog4     = {26124 ,3},        // disc: Vigorous Dagger-Strike
vigrog5     = {26125 ,3},        // disc: Vigorous Dagger-Strike Rk. II     
vigrog6     = {26126 ,3},        // disc: Vigorous Dagger-Strike Rk. III

withstand1  = {19131 ,3},        // disc: withstand
withstand2  = {19132 ,3},        // disc: withstand Rk. II
withstand3  = {19133 ,3},        // disc: withstand Rk. III
withstand4  = {25264 ,3},        // disc: defy 
withstand5  = {25265 ,3},        // disc: defy Rk. II
withstand6  = {25266 ,3},        // disc: defy Rk. III

sbkstab     = {8     ,2},        // skill: backstab
sbash       = {10    ,2},        // skill: bash
sbegging    = {67    ,2},        // skill: begging
sdisarm     = {16    ,2},        // skill: disarm
sdrpunch    = {21    ,2},        // skill: dragon punch
sestrike    = {23    ,2},        // skill: eagle strike
sfeign      = {25    ,2},        // skill: feign death
sflykick    = {26    ,2},        // skill: flying kick
sforage     = {27    ,2},        // skill: forage
sfrenzy     = {74    ,2},        // skill: frenzy
shide       = {29    ,2},        // skill: hide
sintim      = {71    ,2},        // skill: intimidation
skick       = {30    ,2},        // skill: kick
smend       = {32    ,2},        // skill: mend
sppocket    = {48    ,2},        // skill: pick pockets
srndkick    = {38    ,2},        // skill: round kick
ssensetr    = {62    ,2},        // skill: sense trap
sslam       = {111   ,2},        // skill: slam
ssneak      = {42    ,2},        // skill: sneak
staunt      = {73    ,2},        // skill: taunt
stigclaw    = {52    ,2};        // skill: tigerclaw

char* pAGGRO[]={
    "aggro",
    "[ON/OFF]?",
    "${If[${Select[${Me.Class.ShortName},WAR,PAL,SHD]},1,0]}",
    "${If[${meleemvi[plugin]},1,0]}",
};

char* pAGGRP[]={
    "aggropri",
    "[ID] Primary (Aggro)?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${meleemvi[aggro]},1,0]}",
};

char* pAGGRS[]={
    "aggrosec",
    "[ID] Offhand (Aggro)?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${meleemvi[aggro]} && ${meleemvi[aggropri]},1,0]}",
};

char* pARROW[]={
    "arrow",
    "[ID] item?",
    "0",
    "${If[${meleemvi[plugin]} && (${Me.Skill[archery]} || ${Me.Skill[throwing]}),1,0]}",
};

char* pASSAS[]={
    "assasinate",
    "Sneak/Hide/Behind/Strike/Stab [ON/OFF]?",
    "${If[${Me.Skill[backstab]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${meleemvi[backstab]},1,0]}",
};

char* pASSLT[]={
    "assault",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Assault]} || ${Me.CombatAbility[Assault Rk. II]} || ${Me.CombatAbility[Assault Rk. III]} || ${Me.CombatAbility[Battery]} || ${Me.CombatAbility[Battery Rk. II]} || ${Me.CombatAbility[Battery Rk. III]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Assault]} || ${Me.CombatAbility[Assault Rk. II]} || ${Me.CombatAbility[Assault Rk. III]} || ${Me.CombatAbility[Battery]} || ${Me.CombatAbility[Battery Rk. II]} || ${Me.CombatAbility[Battery Rk. III]}),1,0]}",
};

char* pDEFEN[]={
    "defense",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Bracing Defense]} || ${Me.CombatAbility[Bracing Defense Rk. II]} || ${Me.CombatAbility[Bracing Defense Rk. III]} || ${Me.CombatAbility[Staunch Defense]} || ${Me.CombatAbility[Staunch Defense Rk. II]} || ${Me.CombatAbility[Staunch Defense Rk. III]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Bracing Defense]} || ${Me.CombatAbility[Bracing Defense Rk. II]} || ${Me.CombatAbility[Bracing Defense Rk. III]} || ${Me.CombatAbility[Staunch Defense]} || ${Me.CombatAbility[Staunch Defense Rk. II]} || ${Me.CombatAbility[Staunch Defense Rk. III]}),1,0]}",
};

char* pBKOFF[]={
    "backoff",
    "[#] Life% Below? 0=0ff",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && !${meleemvi[aggro]},1,0]}",
};

char* pBSTAB[]={
    "backstab",
    "[ON/OFF]?",
    "${If[${Me.Skill[backstab]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[backstab]},1,0]}",
};

char* pBTASP[]={
    "asp",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[bite of the asp]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[bite of the asp]},1,0]}",
};

char* pBVIVI[]={
    "bvivi",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Bestial Vivisection]} || ${Me.CombatAbility[Bestial Vivisection Rk. II]} || ${Me.CombatAbility[Bestial Vivisection Rk. III]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Bestial Vivisection]} || ${Me.CombatAbility[Bestial Vivisection Rk. II]} || ${Me.CombatAbility[Bestial Vivisection Rk. III]}),1,0]}",
};

char* pBLEED[]={
    "bleed",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Bleed]} || ${Me.CombatAbility[Bleed Rk. II]} || ${Me.CombatAbility[Bleed Rk. III]} || ${Me.CombatAbility[Wound]} || ${Me.CombatAbility[Wound Rk. II]} || ${Me.CombatAbility[Wound Rk. III]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Bleed]} || ${Me.CombatAbility[Bleed Rk. II]} || ${Me.CombatAbility[Bleed Rk. III]} || ${Me.CombatAbility[Wound]} || ${Me.CombatAbility[Wound Rk. II]} || ${Me.CombatAbility[Wound Rk. III]}),1,0]}",
};

char* pBBLOW[]={
    "boastful",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[boastful bellow]},0,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[boastful bellow]},1,0]}",
};

char* pBASHS[]={
    "bash",
    "[#] Bash 0=0ff",
    "${If[${Me.Skill[bash]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[bash]},1,0]}",
};

char* pBGING[]={
    "begging",
    "[ON/OFF]?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[begging]},1,0]}",
};

char* pBOWID[]={
    "bow",
    "[ID] spell/disc/aa/item?",
    "0",
    "${If[${meleemvi[plugin]} && ${Me.Skill[archery]},1,0]}",
};

char* pCALLC[]={
    "callchallenge",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[call of challenge]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[call of challenge]},1,0]}",
};

char* pCHAMS[]={
    "cstrike",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[Chameleon Strike]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[Chameleon Strike]},1,0]}",
};


char* pCRIPS[]={
    "cripple",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[leg strike]} || ${Me.CombatAbility[leg cut]} || ${Me.CombatAbility[leg slice]} || ${Me.CombatAbility[crippling strike]} || ${Me.CombatAbility[tendon cleave]} || ${Me.CombatAbility[tendon cleave rk. ii]} || ${Me.CombatAbility[tendon cleave rk. iii]} || ${Me.CombatAbility[tendon sever]} || ${Me.CombatAbility[tendon sever rk. ii]} || ${Me.CombatAbility[tendon sever rk. iii]} || ${Me.CombatAbility[tendon shear]} || ${Me.CombatAbility[tendon shear rk. ii]} || ${Me.CombatAbility[tendon shear rk. iii]} || ${Me.CombatAbility[tendon shear]} || ${Me.CombatAbility[tendon shear rk. ii]} || ${Me.CombatAbility[tendon shear rk. iii]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[leg strike]} || ${Me.CombatAbility[leg cut]} || ${Me.CombatAbility[leg slice]} || ${Me.CombatAbility[crippling strike]} || ${Me.CombatAbility[tendon cleave]} || ${Me.CombatAbility[tendon cleave rk. ii]} || ${Me.CombatAbility[tendon cleave rk. iii]} || ${Me.CombatAbility[tendon sever]} || ${Me.CombatAbility[tendon sever rk. ii]} || ${Me.CombatAbility[tendon sever rk. iii]} || ${Me.CombatAbility[tendon shear]} || ${Me.CombatAbility[tendon shear rk. ii]} || ${Me.CombatAbility[tendon shear rk. iii]} || ${Me.CombatAbility[tendon shear]} || ${Me.CombatAbility[tendon shear rk. ii]} || ${Me.CombatAbility[tendon shear rk. iii]}),1,0]}",
};

char* pGTPUN[]={
    "gutpunch",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[gut punch]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[gut punch]},1,0]}",
};

char* pOFREN[]={
    "opfrenzy",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Overpowering Frenzy]} || ${Me.CombatAbility[Overpowering Frenzy Rk. II]} || ${Me.CombatAbility[Overpowering Frenzy Rk. III]} || ${Me.CombatAbility[Axe of Graster]} || ${Me.CombatAbility[Axe of Graster Rk. II]} || ${Me.CombatAbility[Axe of Graster Rk. III]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Overpowering Frenzy]} || ${Me.CombatAbility[Overpowering Frenzy Rk. II]} || ${Me.CombatAbility[Overpowering Frenzy Rk. III]} || ${Me.CombatAbility[Axe of Graster]} || ${Me.CombatAbility[Axe of Graster Rk. II]} || ${Me.CombatAbility[Axe of Graster Rk. III]}),1,0]}",
};

char* pOSTRK[]={
    "opportunisticstrike",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[opportunistic strike]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[opportunistic strike]},1,0]}",
};

char* pRALLO[]={
    "rallos",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Axe of Rallos]} || ${Me.CombatAbility[Axe of Rallos Rk. II]} || ${Me.CombatAbility[Axe of Rallos Rk. III]} || ${Me.CombatAbility[Overwhelming Frenzy]} || ${Me.CombatAbility[Overwhelming Frenzy Rk. II]} || ${Me.CombatAbility[Overwhelming Frenzy Rk. III]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Axe of Rallos]} || ${Me.CombatAbility[Axe of Rallos Rk. II]} || ${Me.CombatAbility[Axe of Rallos Rk. III]} || ${Me.CombatAbility[Overwhelming Frenzy]} || ${Me.CombatAbility[Overwhelming Frenzy Rk. II]} || ${Me.CombatAbility[Overwhelming Frenzy Rk. III]}),1,0]}",
};

char* pSYNGY[]={
    "synergy",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Calanin's Synergy]} || ${Me.CombatAbility[Calanin's Synergy Rk. II]} || ${Me.CombatAbility[Calanin's Synergy Rk. III]} || ${Me.CombatAbility[Dreamwalker's Synergy]} || ${Me.CombatAbility[Dreamwalker's Synergy Rk. II]} || ${Me.CombatAbility[Dreamwalker's Synergy Rk. III]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Calanin's Synergy]} || ${Me.CombatAbility[Calanin's Synergy Rk. II]} || ${Me.CombatAbility[Calanin's Synergy Rk. III]} || ${Me.CombatAbility[Dreamwalker's Synergy]} || ${Me.CombatAbility[Dreamwalker's Synergy Rk. II]} || ${Me.CombatAbility[Dreamwalker's Synergy Rk. III]}),1,0]}",
};

char* pTTJAB[]={
    "throatjab",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[throat jab]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[throat jab]},1,0]}",
};

char* pBTLLP[]={
    "battleleap",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[Battle Leap]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[Battle Leap]},1,0]}",
};

char* pCHFOR[]={
    "challengefor",
    "[ON/OFF]?",
    "${If[${Me.Book[challenge for honor]} || ${Me.Book[challenge for honor rk. ii]} || ${Me.Book[challenge for honor rk. iii]} || ${Me.Book[trial for honor]} || ${Me.Book[trial for honor rk. ii]} || ${Me.Book[trial for honor rk. iii]} || ${Me.Book[charge for honor]} || ${Me.Book[charge for honor rk. ii]} || ${Me.Book[charge for honor rk. iii]} || ${Me.Book[challenge for power]} || ${Me.Book[challenge for power rk. ii]} || ${Me.Book[challenge for power rk. iii]} || ${Me.Book[trial for power]} || ${Me.Book[trial for power rk. ii]} || ${Me.Book[trial for power rk. iii]} || ${Me.Book[charge for honor]} || ${Me.Book[charge for honor rk. ii]} || ${Me.Book[charge for honor rk. iii]} || ${Me.Book[confrontation for power]} || ${Me.Book[confrontation for power rk. ii]} || ${Me.Book[confrontation for power rk. iii]}|| ${Me.Book[confrontation for honor]} || ${Me.Book[confrontation for honor rk. ii]} || ${Me.Book[confrontation for honor rk. iii]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[aggro]} && (${Me.Book[challenge for honor]} || ${Me.Book[challenge for honor rk. ii]} || ${Me.Book[challenge for honor rk. iii]} || ${Me.Book[trial for honor]} || ${Me.Book[trial for honor rk. ii]} || ${Me.Book[trial for honor rk. iii]} || ${Me.Book[charge for honor]} || ${Me.Book[charge for honor rk. ii]} || ${Me.Book[charge for honor rk. iii]} || ${Me.Book[challenge for power]} || ${Me.Book[challenge for power rk. ii]} || ${Me.Book[challenge for power rk. iii]} || ${Me.Book[trial for power]} || ${Me.Book[trial for power rk. ii]} || ${Me.Book[trial for power rk. iii]} || ${Me.Book[charge for honor]} || ${Me.Book[charge for honor rk. ii]} || ${Me.Book[charge for honor rk. iii]} || ${Me.Book[confrontation for power]} || ${Me.Book[confrontation for power rk. ii]} || ${Me.Book[confrontation for power rk. iii]} || ${Me.Book[confrontation for honor]} || ${Me.Book[confrontation for honor rk. ii]} || ${Me.Book[confrontation for honor rk. iii]}),1,0]}",
};

char* pCOMMG[]={
    "commanding",
    "[#] Endu% Above? 0=0ff",
    "${If[${Me.CombatAbility[commanding voice]},60,0]}",
    "${If[${meleemvi[plugin]} && ${Me.CombatAbility[commanding voice]},1,0]}",
};

char* pCRYHC[]={
    "cryhavoc",
    "[#] Endu% Above? 0=0ff",
    "${If[${Me.CombatAbility[cry havoc]},60,0]}",
    "${If[${meleemvi[plugin]} && ${Me.CombatAbility[cry havoc]},1,0]}",
};

char* pDISRM[]={
    "disarm",
    "[ON/OFF]?",
    "${If[${Me.Skill[disarm]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[disarm]},1,0]}",
};

char* pDWNF0[]={
    "downflag0",
    "[ON/OFF] downflag0?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit0].Length},1,0]}",
};

char* pDWNF1[]={
    "downflag1",
    "[ON/OFF] downflag1?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit1].Length},1,0]}",
};

char* pDWNF2[]={
    "downflag2",
    "[ON/OFF] downflag2?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit2].Length},1,0]}",
};

char* pDWNF3[]={
    "downflag3",
    "[ON/OFF] downflag3?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit3].Length},1,0]}",
};

char* pDWNF4[]={
    "downflag4",
    "[ON/OFF] downflag4?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit4].Length},1,0]}",
};

char* pDWNF5[]={
    "downflag5",
    "[ON/OFF] downflag5?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit5].Length},1,0]}",
};

char* pDWNF6[]={
    "downflag6",
    "[ON/OFF] downflag6?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit6].Length},1,0]}",
};

char* pDWNF7[]={
    "downflag7",
    "[ON/OFF] downflag7?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit7].Length},1,0]}",
};

char* pDWNF8[]={
    "downflag8",
    "[ON/OFF] downflag8?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit8].Length},1,0]}",
};

char* pDWNF9[]={
    "downflag9",
    "[ON/OFF] downflag9?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit9].Length},1,0]}",
};

char* pDWNF10[]={
    "downflag10",
    "[ON/OFF] downflag10?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit10].Length},1,0]}",
};

char* pDWNF11[]={
    "downflag11",
    "[ON/OFF] downflag11?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit11].Length},1,0]}",
};

char* pDWNF12[]={
    "downflag12",
    "[ON/OFF] downflag12?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit12].Length},1,0]}",
};

char* pDWNF13[]={
    "downflag13",
    "[ON/OFF] downflag13?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit13].Length},1,0]}",
};

char* pDWNF14[]={
    "downflag14",
    "[ON/OFF] downflag14?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit14].Length},1,0]}",
};

char* pDWNF15[]={
    "downflag15",
    "[ON/OFF] downflag15?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[downshit15].Length},1,0]}",
};

char* pDRPNC[]={
    "dragonpunch",
    "[ON/OFF]?",
    "${If[${Me.Skill[dragon punch]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[dragon punch]},1,0]}",
};

char* pEAGLE[]={
    "eaglestrike",
    "[ON/OFF]?",
    "${If[${Me.Skill[eagle strike]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[eagle strike]},1,0]}",
};

char* pERAGE[]={
    "enrage",
    "[ON/OFF]?",
    "1",
    "${If[${meleemvi[plugin]},1,0]}",
};

char* pESCAP[]={
    "escape",
    "[#] Life% Below? 0=0ff",
    "${If[${Me.AltAbility[escape]},20,0]}",
    "${If[${meleemvi[plugin]} && !${meleemvi[aggro]} && ${Me.AltAbility[escape]},1,0]}",
};

char* pEVADE[]={
    "evade",
    "[#] [ON/OFF]?",
    "${If[${Me.Skill[hide]} && ${Me.Class.ShortName.Equal[ROG]},1,0]}",
    "${If[${meleemvi[plugin]} && !${meleemvi[aggro]} && ${Me.Skill[hide]} && ${Me.Class.ShortName.Equal[ROG]},1,0]}",
};

char* pEYEGO[]={
    "eye gouge",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[eye gouge]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[eye gouge]},1,0]}",
};

char* pFEIGN[]={
    "feigndeath",
    "[#] Life% Below? 0=0ff",
    "${If[${Select[${Me.Class.ShortName},SHD,NEC,MNK]},30,0]}",
    "${If[${meleemvi[plugin]} && !${meleemvi[aggro]} && ${Select[${Me.Class.ShortName},BST,SHD,NEC,MNK]},1,0]}",
};

char* pFACES[]={
    "facing",
    "[ON/OFF] Face Target (Range)?",
    "1",
    "${If[${meleemvi[plugin]} && ${meleemvi[range]},1,0]}",
};

char* pFALLS[]={
    "falls",
    "[ON/OFF] Auto-Feign?",
    "0",
    "${If[${meleemvi[plugin]} && !${meleemvi[aggro]} && ${Me.Class.ShortName.Equal[MNK]},1,0]}",
};

char* pFERAL[]={
    "feralswipe",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[feral swipe]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[feral swipe]},1,0]}",
};

char* pFIELD[]={
    "fieldarm",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Field Armorer]} || ${Me.CombatAbility[Field Armorer Rk. II]} || ${Me.CombatAbility[Field Armorer Rk. III]} || ${Me.CombatAbility[Field Outfitter]} || ${Me.CombatAbility[Field Outfitter Rk. II]} || ${Me.CombatAbility[Field Outfitter Rk. III]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Field Armorer]} || ${Me.CombatAbility[Field Armorer Rk. II]} || ${Me.CombatAbility[Field Armorer Rk. III]} || ${Me.CombatAbility[Field Outfitter]} || ${Me.CombatAbility[Field Outfitter Rk. II]} || ${Me.CombatAbility[Field Outfitter Rk. III]}),1,0]}",
};

char* pFISTS[]={
    "fistsofwu",
    "[#] Endu% Above? 0=0ff",
    "${If[${Me.CombatAbility[fists of wu]},60,0]}",
    "${If[${meleemvi[plugin]} && ${Me.CombatAbility[fists of wu]},1,0]}",
};

char* pFCLAW[]={
    "fclaw",
    "[#] Endu% Above? 0=0ff",
    "${If[${Me.CombatAbility[flurry of claws]} || ${Me.CombatAbility[flurry of claws rk. ii]} || ${Me.CombatAbility[flurry of claws rk. iii]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[flurry of claws]} || ${Me.CombatAbility[flurry of claws rk. ii]} || ${Me.CombatAbility[flurry of claws rk. iii]}),1,0]}",
};

char* pFLYKC[]={
    "flyingkick",
    "[ON/OFF]?",
    "${If[${Me.Skill[flying kick]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[flying kick]},1,0]}",
};

char* pFORAG[]={
    "forage",
    "[ON/OFF]?",
    "0",
    "${If[${meleemvi[plugin]} && ${Me.Skill[forage]},1,0]}",
};

char* pFRENZ[]={
    "frenzy",
    "[ON/OFF]?",
    "${If[${Me.Skill[frenzy]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[frenzy]} && ${Me.Skill[frenzy]},1,0]}",
};

char* pGORSM[]={
    "gorilla smash",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[gorilla smash]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[gorilla smash]},1,0]}",
};

char* pHARMT[]={
    "harmtouch",
    "[ON/OFF]?",
    "${Me.AltAbility[harm touch].ID},10,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[harm touch].ID},1,0]}",
};

char* pHIDES[]={
    "hide",
    "[ON/OFF]?",
    "0",
    "${If[${meleemvi[plugin]} && ${Me.Skill[hide]},1,0]}",
};

char* pHOLF0[]={
    "holyflag0",
    "[ON/OFF] holyflag0?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit0].Length},1,0]}",
};

char* pHOLF1[]={
    "holyflag1",
    "[ON/OFF] holyflag1?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit1].Length},1,0]}",
};

char* pHOLF2[]={
    "holyflag2",
    "[ON/OFF] holyflag2?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit2].Length},1,0]}",
};

char* pHOLF3[]={
    "holyflag3",
    "[ON/OFF] holyflag3?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit3].Length},1,0]}",
};

char* pHOLF4[]={
    "holyflag4",
    "[ON/OFF] holyflag4?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit4].Length},1,0]}",
};

char* pHOLF5[]={
    "holyflag5",
    "[ON/OFF] holyflag5?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit5].Length},1,0]}",
};

char* pHOLF6[]={
    "holyflag6",
    "[ON/OFF] holyflag6?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit6].Length},1,0]}",
};

char* pHOLF7[]={
    "holyflag7",
    "[ON/OFF] holyflag7?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit7].Length},1,0]}",
};

char* pHOLF8[]={
    "holyflag8",
    "[ON/OFF] holyflag8?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit8].Length},1,0]}",
};

char* pHOLF9[]={
    "holyflag9",
    "[ON/OFF] holyflag9?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit9].Length},1,0]}",
};

char* pHOLF10[]={
    "holyflag10",
    "[ON/OFF] holyflag10?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit10].Length},1,0]}",
};

char* pHOLF11[]={
    "holyflag11",
    "[ON/OFF] holyflag11?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit11].Length},1,0]}",
};

char* pHOLF12[]={
    "holyflag12",
    "[ON/OFF] holyflag12?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit12].Length},1,0]}",
};

char* pHOLF13[]={
    "holyflag13",
    "[ON/OFF] holyflag13?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit13].Length},1,0]}",
};

char* pHOLF14[]={
    "holyflag14",
    "[ON/OFF] holyflag14?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit14].Length},1,0]}",
};

char* pHOLF15[]={
    "holyflag15",
    "[ON/OFF] holyflag15?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvs[holyshit15].Length},1,0]}",
};

char* pINFUR[]={
    "infuriate",
    "[ON/OFF]?",
    "1",
    "${If[${meleemvi[plugin]},1,0]}",
};

char* pINTIM[]={
    "intimidation",
    "[ON/OFF]?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[intimidation]},1,0]}",
};

char* pJOLTS[]={
    "jolt",
    "Every [#] of Hits,0=0ff",
    "0",
    "${If[${meleemvi[plugin]} && !${meleemvi[aggro]} && ${Select[${Me.Class.ShortName},BER,BST,RNG]},1,0]}",
};

char* pJKICK[]={
    "jltkicks",
    "[#] Endu% Above? 0=0ff",
    "${If[${Me.CombatAbility[jolting kicks]} || ${Me.CombatAbility[jolting kicks rk. ii]} || ${Me.CombatAbility[jolting kicks rk. iii]} || ${Me.CombatAbility[Jolting Snapkicks]} || ${Me.CombatAbility[Jolting Snapkicks rk. ii]} || ${Me.CombatAbility[Jolting Snapkicks rk. iii]} || ${Me.CombatAbility[Jolting Frontkicks]} || ${Me.CombatAbility[Jolting Frontkicks rk. ii]} || ${Me.CombatAbility[Jolting Frontkicks rk. iii]} || ${Me.CombatAbility[Jolting Hook kicks]} || ${Me.CombatAbility[Jolting Hook kicks rk. ii]} || ${Me.CombatAbility[Jolting Hook kicks rk. iii]},20,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[jolting kicks]} || ${Me.CombatAbility[jolting kicks rk. ii]} || ${Me.CombatAbility[jolting kicks rk. iii]} || ${Me.CombatAbility[Jolting Snapkicks]} || ${Me.CombatAbility[Jolting Snapkicks rk. ii]} || ${Me.CombatAbility[Jolting Snapkicks rk. iii]} || ${Me.CombatAbility[Jolting Frontkicks]} || ${Me.CombatAbility[Jolting Frontkicks rk. ii]} || ${Me.CombatAbility[Jolting Frontkicks rk. iii]} || ${Me.CombatAbility[Jolting Hook kicks]} || ${Me.CombatAbility[Jolting Hook kicks rk. ii]} || ${Me.CombatAbility[Jolting Hook kicks rk. iii]}),1,0]}",
};

char* pKICKS[]={
    "kick",
    "[ON/OFF]?",
    "${If[${Me.Skill[kick]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[kick]},1,0]}",
};

char* pKNEES[]={
    "kneestrike",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[knee strike]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[knee strike]},1,0]}",
};

char* pLHAND[]={
    "layhand",
    "[#] MyLife% Below? 0=0ff",
    "${If[${Me.AltAbility[Lay on Hands].ID},20,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[Lay on Hands].ID},1,0]}",
};

char* pLCLAW[]={
    "leopardclaw",
    "[#] Endu% Above? 0=0ff",
    "${If[${Me.CombatAbility[leopard claw]} || ${Me.CombatAbility[dragon fang]} || ${Me.CombatAbility[clawstriker's flurry]} || ${Me.CombatAbility[clawstriker's flurry rk. ii]} || ${Me.CombatAbility[clawstriker's flurry rk. iii]} || ${Me.CombatAbility[wheel of fists]} || ${Me.CombatAbility[wheel of fists rk. ii]} || ${Me.CombatAbility[wheel of fists rk. iii]} || ${Me.CombatAbility[Six-Step Pattern]} || ${Me.CombatAbility[Six-Step Pattern rk. ii]} || ${Me.CombatAbility[Six-Step Pattern rk. iii]},60,0]}", 
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[leopard claw]} || ${Me.CombatAbility[dragon fang]} || ${Me.CombatAbility[clawstriker's flurry]} || ${Me.CombatAbility[clawstriker's flurry rk. ii]} || ${Me.CombatAbility[clawstriker's flurry rk. iii]} || ${Me.CombatAbility[wheel of fists]} || ${Me.CombatAbility[wheel of fists rk. ii]} || ${Me.CombatAbility[wheel of fists rk. iii]} || ${Me.CombatAbility[Six-Step Pattern]} || ${Me.CombatAbility[Six-Step Pattern rk. ii]} || ${Me.CombatAbility[Six-Step Pattern rk. iii]}),1,0]}",
};

char* pMELEE[]={
    "melee",
    "[ON/OFF] Melee Mode? 0=0ff",
    "${If[${Select[${Me.Class.ShortName},WAR,PAL,RNG,SHD,MNK,BRD,ROG,BST,BER]},1,0]}",
    "${If[${meleemvi[plugin]},1,0]}",
};

char* pMELEP[]={
    "meleepri",
    "[ID] Primary (Melee)?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && !${meleemvi[aggro]},1,0]}",
};

char* pMELES[]={
    "meleesec",
    "[ID] Offhand (Melee)?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && !${meleemvi[aggro]},1,0]} && ${meleemvi[meleepri]}",
};

char* pMENDS[]={
    "mend",
    "[#] MyLife% Below? 0=0ff",
    "${If[${Me.Skill[mend]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.Skill[mend]},1,0]}",
};

char* pPETAS[]={
    "petassist",
    "[ON/OFF] Assist Me?",
    "${If[${Select[${Me.Class.ShortName},SHD,DRU,SHM,NEC,MAG,ENC,BST]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Select[${Me.Class.ShortName},SHD,DRU,SHM,NEC,MAG,ENC,BST]},1,0]}",
};

char* pPETDE[]={
    "petdelay",
    "[#] # Sec Delay Before Engaging?",
    "${If[${Select[${Me.Class.ShortName},SHD,DRU,SHM,NEC,MAG,ENC,BST]},0,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[petassist]} && ${Select[${Me.Class.ShortName},SHD,DRU,SHM,NEC,MAG,ENC,BST]},1,0]}",
};

char* pPETRN[]={
    "petrange",
    "[#] Target/Pet in this range?",
    "${If[${Select[${Me.Class.ShortName},SHD,DRU,SHM,NEC,MAG,ENC,BST]},75,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[petassist]} && ${Select[${Me.Class.ShortName},SHD,DRU,SHM,NEC,MAG,ENC,BST]},1,0]}",
};

char* pPETMN[]={
    "petmend",
    "[#] Mend Pet Life % Below 0=0ff?",
    "${If[${Me.AltAbility[mend companion]},20,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[petassist]} && ${Me.AltAbility[mend companion]},1,0]}",
};

char* pPICKP[]={
    "pickpocket",
    "[ON/OFF]?",
    "${If[${Me.Skill[pick pockets]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[pick pockets]},1,0]}",
};

char* pPLUGS[]={
    "plugin",
    "[ON/OFF]?",
    "1",
    "1",
};

char* pPOKER[]={
    "poker",
    "[ID] item?",
    "0",
    "${If[${meleemvi[plugin]} && ${Me.Skill[backstab]},1,0]}",
};

char* pHFAST[]={
    "pothealfast",
    "[#] MyLife% Below? 0=0ff (FAST)",
    "${If[${meleemvi[idpothealfast]},30,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[idpothealfast]},1,0]}",
};

char* pHOVER[]={
    "pothealover",
    "[#] MyLife% Below? 0=0ff (OVER)",
    "${If[${meleemvi[idpothealover]},60,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[idpothealover]},1,0]}",
};

char* pPRVKO[]={
    "provokeonce",
    "[ON/OFF]?",
    "${If[${Select[${Me.Class.ShortName},WAR,PAL,SHD,MNK,BER]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[aggro]} && ${Select[${Me.Class.ShortName},WAR,PAL,SHD,MNK,BER]},1,0]}",
};

char* pPRVKM[]={
    "provokemax",
    "[#] Counter? ,1=try once, 0=0ff",
    "${If[${Select[${Me.Class.ShortName},WAR,PAL,SHD,MNK,BER]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[aggro]} && ${Select[${Me.Class.ShortName},WAR,PAL,SHD,MNK,BER]},1,0]}",
};

char* pPRVKE[]={
    "provokeend",
    "[#] Stop when Target Life% Below?",
    "${If[${Select[${Me.Class.ShortName},WAR,PAL,SHD,MNK,BER]},20,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[aggro]} && ${meleemvi[provokemax]} && ${Select[${Me.Class.ShortName},WAR,PAL,SHD,MNK,BER]},1,0]}",
};

char* pPRVK0[]={
    "provoke0",
    "[ID] spell/disc/aa/item?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[aggro]} && ${meleemvi[provokemax]} && ${Select[${Me.Class.ShortName},WAR,PAL,SHD,MNK,BER]},1,0]}",
};

char* pPRVK1[]={
    "provoke1",
    "[ID] spell/disc/aa/item?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[aggro]} && ${meleemvi[provokemax]} && ${Select[${Me.Class.ShortName},WAR,PAL,SHD,MNK,BER]},1,0]}",
};

char* pRAVOL[]={
    "ragevolley",
    "[#] Endu% Above? 0=0ff",
    "${If[${Me.CombatAbility[rage volley]} || ${Me.CombatAbility[destroyer's volley]} || ${Me.CombatAbility[giantslayer's volley]} || ${Me.CombatAbility[giantslayer's volley rk. ii]} || ${Me.CombatAbility[giantslayer's volley rk. iii]} || ${Me.CombatAbility[annihilator's volley]} || ${Me.CombatAbility[annihilator's volley rk. ii]} || ${Me.CombatAbility[annihilator's volley rk. iii]} || ${Me.CombatAbility[decimator's volley]} || ${Me.CombatAbility[decimator's volley rk. ii]} || ${Me.CombatAbility[decimator's volley rk. iii]} || ${Me.CombatAbility[Eradicator's Volley]} || ${Me.CombatAbility[Eradicator's Volley rk. ii]} || ${Me.CombatAbility[Eradicator's Volley rk. iii]} || ${Me.CombatAbility[Savage Volley]} || ${Me.CombatAbility[Savage Volley rk. ii]} || ${Me.CombatAbility[Savage Volley rk. iii]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[rage volley]} || ${Me.CombatAbility[destroyer's volley]} || ${Me.CombatAbility[giantslayer's volley]} || ${Me.CombatAbility[giantslayer's volley rk. ii]} || ${Me.CombatAbility[giantslayer's volley rk. iii]} || ${Me.CombatAbility[annihilator's volley]} || ${Me.CombatAbility[annihilator's volley rk. ii]} || ${Me.CombatAbility[annihilator's volley rk. iii]} || ${Me.CombatAbility[decimator's volley]} || ${Me.CombatAbility[decimator's volley rk. ii]} || ${Me.CombatAbility[decimator's volley rk. iii]} || ${Me.CombatAbility[Eradicator's Volley]} || ${Me.CombatAbility[Eradicator's Volley rk. ii]} || ${Me.CombatAbility[Eradicator's Volley rk. iii]} || ${Me.CombatAbility[Savage Volley]} || ${Me.CombatAbility[Savage Volley rk. ii]} || ${Me.CombatAbility[Savage Volley rk. iii]}),1,0]}",
};

char* pRAKES[]={
    "rake",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[rake]} || ${Me.CombatAbility[harrow]} || ${Me.CombatAbility[harrow rk. ii]} || ${Me.CombatAbility[harrow rk. iii]} || ${Me.CombatAbility[foray]} || ${Me.CombatAbility[foray rk. ii]} || ${Me.CombatAbility[foray rk. iii]} || ${Me.CombatAbility[rush]} || ${Me.CombatAbility[rush rk. ii]} || ${Me.CombatAbility[rush rk. iii]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[rake]} || ${Me.CombatAbility[harrow]} || ${Me.CombatAbility[harrow rk. ii]} || ${Me.CombatAbility[harrow rk. iii]} || ${Me.CombatAbility[foray]} || ${Me.CombatAbility[foray rk. ii]} || ${Me.CombatAbility[foray rk. iii]} || ${Me.CombatAbility[rush]} || ${Me.CombatAbility[rush rk. ii]} || ${Me.CombatAbility[rush rk. iii]}),1,0]}",
};

char* pRANGE[]={
    "range",
    "[#] Max Range? 0=0ff",
    "0",
    "${If[${meleemvi[plugin]},1,0]}",
};

char* pRAVEN[]={
    "ravens",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[raven's claw]},1,0]}",
    "${If[${meleemvi[plugin]} && ${Me.AltAbility[raven's claw]},1,0]}",
};

char* pRESUM[]={
    "resume",
    "[#] Life% Above? 100=0ff",
    "20",
    "${If[${meleemvi[plugin]} && !${meleemvi[aggro]},1,0]}",
};

char* pRGHTI[]={
    "rightidg",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Righteous Indignation]} || ${Me.CombatAbility[Righteous Indignation rk. ii]} || ${Me.CombatAbility[Righteous Indignation rk. iii]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Righteous Indignation]} || ${Me.CombatAbility[Righteous Indignation rk. ii]} || ${Me.CombatAbility[Righteous Indignation rk. iii]}),1,0]}",
};

char* pRKICK[]={
    "roundkick",
    "[ON/OFF]?",
    "${If[${Me.Skill[round kick]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[round kick]},1,0]}",
};

char* pSELOK[]={
    "selos",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[selo's kick]},1,0]}",
    "${If[${meleemvi[plugin]}  && ${Me.AltAbility[selo's kick]},1,0]}",
};

char* pSENSE[]={
    "sensetraps",
    "[ON/OFF]?",
    "0",
    "${If[${meleemvi[plugin]} && ${Me.Skill[sensetraps]},1,0]}",
};

char* pSHIEL[]={
    "shield",
    "[ID] item?",
    "0",
    "${If[${meleemvi[plugin]} && ${Me.Skill[bash]},0,0]}",
};

char* pSLAMS[]={
    "slam",
    "[ON/OFF]?",
    "${If[${Select[${Me.Race.ID},2,9,10]},1,0]}", // 2=barbarian 9=troll 10=ogre  
    "${If[${meleemvi[plugin]} && ${${Select[${Me.Race.ID},2,9,10]},1,0]}",
};

char* pSLAPF[]={
    "slapface",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[Slap in the Face]} || ${Me.CombatAbility[Slap in the Face rk. ii]} || ${Me.CombatAbility[Slap in the Face rk. iii]},20,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[Slap in the Face]} || ${Me.CombatAbility[Slap in the Face rk. ii]} || ${Me.CombatAbility[Slap in the Face rk. iii]}),1,0]}",
};

char* pSNEAK[]={
    "sneak",
    "[ON/OFF]?",
    "0",
    "${If[${meleemvi[plugin]} && ${Me.Skill[sneak]},1,0]}",
};

char* pSTAND[]={
    "standup",
    "[ON/OFF] Authorize to StandUp?",
    "0",
    "${If[${meleemvi[plugin]},1,0]}",
};

char* pSTIKKB[]={
    "stickbreak",
    "0=Normal, 1=Allow BreakOnKB",
    "0",
    "${If[${meleemvi[plugin]} && ${Stick.Status.NotEqual[NULL]},1,0]}",
};

char* pSTIKNR[]={
    "sticknorange",
    "0=Normal, 1=No Range Check",
    "0",
    "${If[${meleemvi[plugin]} && ${Stick.Status.NotEqual[NULL]},1,0]}",
};

char* pSTIKR[]={
    "stickrange",
    "[#] Target in Range? 0=0ff",
    "${If[${Stick.Status.NotEqual[NULL]},75,0]}",
    "${If[${meleemvi[plugin]} && ${Stick.Status.NotEqual[NULL]} && ${meleemvi[stickrange]},1,0]}",
};

char* pSTIKD[]={
    "stickdelay",
    "[#] Sec to Wait Target in Range?",
    "0",
    "${If[${meleemvi[plugin]} && ${Stick.Status.NotEqual[NULL]},1,0]}",
};

char* pSTIKM[]={
    "stickmode",
    "[ON/OFF] Use stickcmd from ini?",
    "0",
    "${If[${meleemvi[plugin]} && ${Stick.Status.NotEqual[NULL]},1,0]}",
};

char* pSTRIK[]={
    "strike",
    "Use best sneak attack disc [ON/OFF]?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${meleemvi[backstab]} && ${meleemvi[idstrike]},1,0]}",
};

char* pSTRIKM[]={
    "strikemode",
    "[ON/OFF] Use strikecmd from ini?",
    "0",
    "${If[${meleemvi[plugin]} && ${Stick.Status.NotEqual[NULL]},1,0]}",
};

char* pSTUNS[]={
    "stunning",
    "[#] Target Life% Below? 0=0ff",
    "0",
    "${If[${meleemvi[plugin]},1,0]}",
};

char* pSTUN0[]={
    "stun0",
    "[ID] spell/disc/aa/item?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[stunning]},1,0]}",
};

char* pSTUN1[]={
    "stun1",
    "[ID] spell/disc/aa/item?",
    "0",
    "${If[${meleemvi[plugin]} && ${meleemvi[stunning]},1,0]}",
};

char* pTAUNT[]={
    "taunt",
    "[ON/OFF]?",
    "${If[${Me.Skill[taunt]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${meleemvi[aggro]} && ${Me.Skill[taunt]},1,0]}",
};

char* pTHIEF[]={
    "thiefeye",
    "[#] Endu% Above? 0=0ff",
    "${If[${Me.CombatAbility[thief's eye]},60,0]}",
    "${If[${meleemvi[plugin]} && ${Me.CombatAbility[thief's eye]},1,0]}",
};

char* pTHROW[]={
    "throwstone",
    "[#] Endu% Above? 0=0ff",
    "0",
    "${If[${meleemvi[plugin]} && ${Me.CombatAbility[throw stone]},1,0]}",
};

char* pTIGER[]={
    "tigerclaw",
    "[ON/OFF]?",
    "${If[${Me.Skill[tiger claw]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.Skill[tiger claw]},1,0]}",
};

char* pTWIST[]={
    "twistedshank",
    "[ON/OFF]?",
    "${If[${Me.AltAbility[twisted shank]},1,0]}",
    "${If[${meleemvi[plugin]} && ${meleemvi[melee]} && ${Me.AltAbility[twisted shank]},1,0]}",
};

char* pVIGOR[]={
    "vig",
    "[#] Endu% Above? 0=Off",
    "0",
    "${If[${meleemvi[plugin]} && ${Select[${Me.Class.ShortName},BER,MNK,ROG]},1,0]}",
};

char* pWITHS[]={
    "withstand",
    "[#] Endu% Above? 0=Off",
    "${If[${Me.CombatAbility[withstand]} || ${Me.CombatAbility[withstand rk. ii]} || ${Me.CombatAbility[withstand rk. iii]} || ${Me.CombatAbility[defy]} || ${Me.CombatAbility[defy rk. ii]} || ${Me.CombatAbility[defy rk. iii]} && ${Select[${Me.Class.ShortName},PAL,SHD]},60,0]}",
    "${If[${meleemvi[plugin]} && (${Me.CombatAbility[withstand]} || ${Me.CombatAbility[withstand rk. ii]} || ${Me.CombatAbility[withstand rk. iii]} || ${Me.CombatAbility[defy]} || ${Me.CombatAbility[defy rk. ii]} || ${Me.CombatAbility[defy rk. iii]} && ${Select[${Me.Class.ShortName},PAL,SHD]}),1,0]}",
};

char* UI_PetBack = "back";
char* UI_PetAttk = "attack";

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

unsigned long   AACheck(unsigned long id);
unsigned long   AAPoint(unsigned long index);
int             AAReady(unsigned long index);
long            Aggroed(unsigned long id);
FLOAT           AngularDistance(float h1, float h2);
DOUBLE          AngularHeading(PSPAWNINFO t, PSPAWNINFO s);
int             CACheck(unsigned long id);
int             CAPress(unsigned long id);
int             Casting(char* command);
int             CursorEmpty();
long            Discipline();
int             Equip(unsigned long ID, long SlotID);
int             Equipped(unsigned long id);
long            Evaluate(char* zFormat, ...);
long            OkayToEquip(long Size=NOID);
PMQPLUGIN       Plugin(char* PluginName);
void*           PluginEntry(char* PluginName, char* FuncName);
int             SKCheck(unsigned long id);
int             SKReady(unsigned long id);
int             SKPress(unsigned long id);
long            SpawnMask(PSPAWNINFO x);
int             SpellCheck(unsigned long id);
long            SpellGemID(unsigned long ID, long slotid=NOID);
int             SpellReady(unsigned long ID, long SlotID=NOID);
int             Stick(char* command);
long            Unequip(long SlotID);
//void            WinClick(CXWnd *Wnd, char* ScreenID, char* ClickNotification, unsigned long KeyState);
PSTR            WinTexte(CXWnd *Wnd, char* ScreenID, PSTR Buffer);

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

void Announce(unsigned long Wanted, char* Format, ...) {
    char Output[MAX_STRING]={0}; va_list vaList; va_start(vaList,Format); vsprintf(Output,Format,vaList);
    if(Output[0]) {
        unsigned long Result=0; PMQPLUGIN pPlugin=pPlugins;
        while(pPlugin) {
            fMQIncomingChat Request=(fMQIncomingChat)GetProcAddress(pPlugin->hModule,"OnMeleeChat");
            if(Request) Result|=Request(Output,Wanted);
            pPlugin=pPlugin->pNext;
        }
        if(!Result && Wanted) WriteChatf(Output);
    }
}

#define GetSpawnID(spawnid) (PSPAWNINFO)GetSpawnByID(spawnid)
#define TargetIT(X) *(PSPAWNINFO*)ppTarget=X

static inline int WinState(CXWnd *Wnd) {
    return (Wnd && ((PCSIDLWND)Wnd)->Show);
}

static inline PSPAWNINFO Target() {
    if(ppTarget) return (PSPAWNINFO)pTarget;
    return NULL;
}

static inline int TargetType(unsigned long mask) {
    return (SpawnMask(Target())&mask);
}

static inline int TargetID(unsigned long ID) {
    if(ID && pTarget) return (ID==Target()->SpawnID);
    return false;
}

static inline float SpeedRun(PSPAWNINFO x) {
    if(x && x->Mount) return x->Mount->SpeedRun;
    if(x) return x->SpeedRun;
    return 0.0f;
}

static inline int SpawnType(PSPAWNINFO x, unsigned long mask) {
    return (SpawnMask(x)&mask);
}

static inline PSPAWNINFO SpawnMe() {
    return GetCharInfo()->pSpawn;
}

static inline PSPAWNINFO SpawnMount() {
    return SpawnMe()?SpawnMe()->Mount:NULL;
}

static inline PSPAWNINFO SpawnPet() {
    return (SpawnMe() && (long)SpawnMe()->PetID>0)?(PSPAWNINFO)GetSpawnByID(SpawnMe()->PetID):NULL;
}

static inline unsigned long StandState() {
    return SpawnMe()?SpawnMe()->StandState:0;
}

static inline int Stackable(PCONTENTS Item) {
    return (Item && Item->Item->Type==ITEMTYPE_NORMAL && ((EQ_Item*)Item)->IsStackable());
}

static inline long StackUnit(PCONTENTS Item) {
    return (!Stackable(Item))?1:Item->StackCount;
}

static inline int IsStunned() {
    return (GetCharInfo() && GetCharInfo()->Stunned);
}

static inline int IsStanding() {
    if(SpawnMount()) return true;
    return StandState()==STANDSTATE_STAND;
}

static inline int IsSneaking() {
    return (SpawnMe() && SpawnMe()->Sneak);
}

static inline int IsInvisible() {
    return (SpawnMe() && SpawnMe()->HideMode);
}

static inline int IsGrouped() {
    return (GetCharInfo() && GetCharInfo()->pGroupInfo);
}

static inline int IsFeigning() {
    return StandState()==STANDSTATE_FEIGN;
}

static inline int InRange(PSPAWNINFO a, PSPAWNINFO b, float d) {
    if(!a || !b) return false;
    return (DistanceToSpawn(a,b)<=d);
}

static inline int InGame() {
    return (gbInZone && gGameState==GAMESTATE_INGAME && SpawnMe() && GetCharInfo2() && GetCharInfo() && GetCharInfo()->Stunned!=3);
}

static inline CXWnd* XMLChild(CXWnd* window, char* screenid) {
    if(window) return window->GetChildItem(screenid);
    return NULL;
}

static inline int XMLEnabled(CXWnd* window) {
    return (window && ((PCSIDLWND)window)->Enabled);
}

static inline PCONTENTS ContAmmo() {
    if(PCHARINFO2 Me=GetCharInfo2()) return Me->pInventoryArray->Inventory.Ammo;
    return NULL;
}

static inline PCONTENTS ContPrimary() {
    if(PCHARINFO2 Me=GetCharInfo2()) return Me->pInventoryArray->Inventory.Primary;
    return NULL;
}

static inline PCONTENTS ContRange() {
    if(PCHARINFO2 Me=GetCharInfo2()) return Me->pInventoryArray->Inventory.Range;
    return NULL;
}

static inline PCONTENTS ContSecondary() {
    if(PCHARINFO2 Me=GetCharInfo2()) return Me->pInventoryArray->Inventory.Secondary;
    return NULL;
}

static inline int PokerType(PCONTENTS item) {
    return (item && item->Item->ItemType==2);
}

static inline int ShieldType(PCONTENTS item) {
    return(item && item->Item->ItemType==8);
}

static inline int TwohandType(PCONTENTS item) {
    if(item) {
        if(item->Item->ItemType==1)   return true;
        if(item->Item->ItemType==4)   return true;
        if(item->Item->ItemType==35)  return true;
    }
    return false;
}

unsigned long AACheck(unsigned long id) {
    if(pAltAdvManager)
        if(PCHARINFO2 Me=GetCharInfo2())
            if(_AALIST* AAList=Me->AAList)
                if(id)
                    for(unsigned long nAbility=0; nAbility<AA_CHAR_MAX_REAL; nAbility++)
                        if(long AAIndex=AAList[nAbility].AAIndex)
                            if(PALTABILITY ability=pAltAdvManager->GetAltAbility(AAIndex))
                                if(ability->ID==id) return AAIndex;
    return false;
}

unsigned long AAPoint(unsigned long index) {
    if(PCHARINFO2 Me=GetCharInfo2())
        if(_AALIST* AAList=Me->AAList)
            if(index)
                for(unsigned long nAbility=0; nAbility<AA_CHAR_MAX_REAL; nAbility++)
                    if(index==AAList[nAbility].AAIndex)
                        return  AAList[nAbility].PointsSpent;
    return 0;
}

int AAReady(unsigned long index) {
    int result = 0;
    if (pAltAdvManager)
    {
        if (index)
            if (PALTABILITY ability = pAltAdvManager->GetAltAbility(index))
            {
                //unsigned long i = 0;
                //i = pAltAdvManager->GetCalculatedTimer(pPCData, ability);
                //DebugSpew("ability timer: %d", i);
                if (pAltAdvManager->GetCalculatedTimer(pPCData, ability) > 0)
                {
                    pAltAdvManager->IsAbilityReady(pPCData,ability,&result);
                    //DebugSpew("result: %d", result);
                }
            }
    }
    return (result < 0);
}

long Aggroed(unsigned long id) {
    if(PSPAWNINFO self=SpawnMe())
        if(PSPAWNINFO kill=GetSpawnID(id))
            if(PSPAWNINFO targ=Target()) {
                if(targ==kill && self->SpawnID==self->TargetOfTarget)  return  1; // im on hott
                if(fabs(AngularHeading(kill,self))<8.0f)       return  1; // it's facing me
                if(FindSpeed(kill)>0.0f && kill->HPCurrent<20) return -1; // it's moving
                if(InRange(self,targ,25.0f))                   return -1; // close enough
            }
            return 0;
}

FLOAT AngularDistance(float h1, float h2) {
    if(h1 == h2) return 0.0;
    if(fabs(h1 - h2) > 256.0) * (h1 < h2?&h1:&h2) += 512.0;
    return (fabs(h1 - h2) > 256.0)?(h2 - h1):(h1 - h2);
}

DOUBLE AngularHeading(PSPAWNINFO t, PSPAWNINFO s) {
    double Head=t->Heading-(float)atan2(s->X - t->X, s->Y - t->Y) * 256.0 / PI;
    if(Head > 256.0f) Head -= 512.0f; else if(Head < -256.0f) Head += 512.0f;
    return Head;
}

int CACheck(unsigned long id) {
    if(PCHARINFO2 Me=GetCharInfo2())
        if(unsigned long* CombatAbilities=Me->CombatAbilities)
            if(id)
                for(unsigned long nCombat=0; nCombat<NUM_COMBAT_ABILITIES; nCombat++)
                    if(id==CombatAbilities[nCombat]) return true;
    return false;
}

int CAPress(unsigned long id) {
    pCharData->DoCombatAbility(id);
    return true;
}

int Casting(char* command) {
    typedef void (__cdecl *fCALL)(PSPAWNINFO,char*);
    if(fCALL request=(fCALL)PluginEntry("mq2cast","CastCommand")) {
        Announce(SHOW_CASTING,"%s::Casting [\ay%s\ax].",PLUGIN_NAME,command);
        request(NULL,command);
        return true;
    }
    return false;
}

void Command(char* zFormat,...) {
    CHAR zOutput[MAX_STRING]={0}; va_list vaList; va_start(vaList,zFormat);
    vsprintf(zOutput,zFormat,vaList);
    if(zOutput[0]) EzCommand(zOutput);
}

int CursorEmpty() {
    if(PCHARINFO2 Me=GetCharInfo2())
        if(!Me->pInventoryArray->Inventory.Cursor)
            if(!Me->CursorPlat)
                if(!Me->CursorGold)
                    if(!Me->CursorSilver)
                        if(!Me->CursorCopper)
                            return true;
    return false;
}

long Discipline() {
    char temps[MAX_STRING];
    PSPELL spell=GetSpellByName(WinTexte((CXWnd*)pCombatAbilityWnd,"CAW_CombatEffectLabel",temps));
    return (spell)?spell->ID:0;
}

int Equipped(unsigned long id) {
    if(id)
        for(int i=0; i<BAG_SLOT_START; i++)
            if(PCONTENTS Cont=GetCharInfo2()->pInventoryArray->InventoryArray[i])
                if(id==Cont->Item->ItemNumber) return true;
    return false;
}

long Evaluate(char* zFormat, ...) {
    char zOutput[MAX_STRING]={0}; va_list vaList; va_start(vaList,zFormat);
    vsprintf(zOutput,zFormat,vaList); if(!zOutput[0]) return 1;
    //DebugSpewAlways("E[%s]",zOutput);
    ParseMacroData(zOutput);
    //DebugSpewAlways("R[%s]",zOutput);
    return atoi(zOutput);
}

long ItemTimer(PCONTENTS pItem) {
    if(pItem->Item->Clicky.TimerID!=0xFFFFFFFF) return GetItemTimer(pItem);
    if(pItem->Item->Clicky.SpellID!=0xFFFFFFFF) return 0;
    return 999999;
}

PMQPLUGIN Plugin(char* PluginName) {
    long Length=strlen(PluginName)+1;
    PMQPLUGIN pLook=pPlugins;
    while(pLook && strnicmp(PluginName,pLook->szFilename,Length)) pLook=pLook->pNext;
    return pLook;
}

void* PluginEntry(char* PluginName, char* FuncName) {
    if(PMQPLUGIN pLook=Plugin(PluginName))
        if(void* entry=GetProcAddress(pLook->hModule,FuncName))
            return entry;
    return NULL;
}

int SKCheck(unsigned long id) {
    if(id<100 && (pSkillMgr->pSkill[id]->Activated && GetCharInfo2()->Skill[id]))     return true;
    if(id>100 && id<128 && GetCharInfo2()->Skill[id]!=0xFF && strlen(szSkills[id])>3) return true;
    return false;
}

int SKReady(unsigned long id) {
    if(id<100)
    {
        // 15 = disarm, 25=fd
        //DebugSpew("id %d alttimer: %d", id, pSkillMgr->pSkill[id]->AltTimer);
        if(pSkillMgr->pSkill[id]->AltTimer == 2)
        {
            //DebugSpew("gbAltTimerReady: %s", gbAltTimerReady ? "true" : "false");
            return gbAltTimerReady ? true : false;
        }
        //DebugSpew("id %d - EQADDR_DOABILITYAVAIL: %s", id, EQADDR_DOABILITYAVAILABLE[id] ? "true" : "false");
        return EQADDR_DOABILITYAVAILABLE[id] ? true : false;
    }
    if(id==111) return gbAltTimerReady?true:false;
    if(id==105 || id==107) return LoH_HT_Ready();
    return false;
}

int SKPress(unsigned long id) {
    pCharData1->UseSkill((unsigned char)id,(EQPlayer*)pCharData1);
    return true;
}

long SpawnMask(PSPAWNINFO x) {
    if(!x)                        return st_x;
    if(x->Type==SPAWN_PLAYER)     return st_p;
    if(x->Type==SPAWN_CORPSE)     return x->Deity?st_cp:st_cn;
    if(x->Type!=SPAWN_NPC)        return st_x;
    if(strstr(x->Name,"s_Mount")) return st_x;
    if(!x->MasterID)              return st_n;
    PSPAWNINFO m=GetSpawnID(x->MasterID);
    return (!m || m->Type!=SPAWN_PLAYER)?st_wn:st_wp;
}

int SpellCheck(unsigned long ID) {
    if(ID)
        if(PCHARINFO2 Me=GetCharInfo2())
            for(unsigned long nSlot=0; nSlot<NUM_BOOK_SLOTS; nSlot++)
                if(ID==Me->SpellBook[nSlot])
                    return true;
    return false;
}

long SpellGemID(unsigned long ID, long SlotID) {
    if(PCHARINFO2 Me=GetCharInfo2()) {
        if(SlotID!=NOID && ID==Me->MemorizedSpells[SlotID]) return SlotID;
        for(long GEM=0; GEM<GemsMax; GEM++)
            if(ID==Me->MemorizedSpells[GEM])
                return GEM;
    }
    return NOID;
}

int SpellReady(unsigned long ID, long SlotID) {
    if(pCastSpellWnd)
        if(PCHARINFO2 Me=GetCharInfo2()) {
            unsigned long GemID=(SlotID!=NOID)?SlotID:SpellGemID(ID);
            if(GemID<(unsigned long)GemsMax)
                if(Me->MemorizedSpells[GemID]==ID)
                    if((long)((PEQCASTSPELLWINDOW)pCastSpellWnd)->SpellSlots[GemID]->spellicon!=NOID)
                        if(BardClass || (long)((PEQCASTSPELLWINDOW)pCastSpellWnd)->SpellSlots[GemID]->spellstate!=1)
                            return true;
        }
        return false;
}

bool HandleMoveUtils(void)
{
    bMUPointers = false;
    fStickCommand = NULL;
    pbStickOn = NULL;
    if (PMQPLUGIN pLook=Plugin("mq2moveutils"))
    {
        fStickCommand = (void (*)(PSPAWNINFO pChar, char* szLine))GetProcAddress(pLook->hModule, "StickCommand");
        pbStickOn = (bool *)GetProcAddress(pLook->hModule, "bStickOn");
    }
    if (fStickCommand && pbStickOn) 
    {
        bMUPointers = true;
        return true;
    }
    return false;
}

unsigned char PetButtonEnabled(char* pszButtonName)
{
    int i = 0;
    for (i = 0; i < PET_BUTTONS; i++)
    {
        if (((PEQPETINFOWINDOW)pPetInfoWnd)->pButton[i])
        {
            if (((PEQPETINFOWINDOW)pPetInfoWnd)->pButton[i]->Wnd.WindowText->Text[0])
            {
                if (!stricmp(((PEQPETINFOWINDOW)pPetInfoWnd)->pButton[i]->Wnd.WindowText->Text, pszButtonName))
                {
                    return ((PEQPETINFOWINDOW)pPetInfoWnd)->pButton[i]->Wnd.Enabled;
                }
            }
        }
    }
    return 0;
}

int Stick(char* command)
{
    char szPasser[MAX_STRING] = {0};
    //typedef void (__cdecl *fCALL)(PSPAWNINFO, char*);
    //if (fCALL request = (fCALL)PluginEntry("mq2moveutils", "StickCommand"))
    if (bMULoaded && bMUPointers)
    {
        if (command[0])
        {
            Announce(SHOW_STICKING, "%s::Sticking [\ay%s\ax].", PLUGIN_NAME, command);
            fStickCommand(SpawnMe(), command);
            sprintf(szPasser, "/stick %s", command);
            //DebugSpew("MQ2Melee Stick call: %s", command);
        }
        else if (*pbStickOn)
        {
            fStickCommand(SpawnMe(), "off");
            sprintf(szPasser, "/stick off");
            //DebugSpew("MQ2Melee Stick call: off");
        }
        Sticking = *pbStickOn;
        //Sticking = (command[0]) ? true : false;
        strcpy(StickArg, *pbStickOn ? command : "OFF");
        return true;
    }
    return false;
}

unsigned long TimeSince(unsigned long Timer) {
    if(Timer) return (unsigned long)clock()-Timer;
    return 0;
}

PSTR WinTexte(CXWnd *Wnd, char* ScreenID, PSTR Buffer) {
    Buffer[0]=0;
    if(Wnd)
        if(CXWnd *Child=(CXWnd*)Wnd->GetChildItem(ScreenID))
            GetCXStr(Child->WindowText,Buffer,2047);
    return Buffer;
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
// item related

long FitInPack(long Size)
{
    //long pSIZE = 20; 
    //long pSLOT = 0;
    unsigned char ucSlot = 0;
    for (ucSlot = BAG_SLOT_START; ucSlot < NUM_INV_SLOTS; ucSlot++)
    {
        if (PCONTENTS pInvSlot = GetCharInfo2()->pInventoryArray->InventoryArray[ucSlot])
        {
            if (TypePack(pInvSlot) && pInvSlot->Item->Combine != 2 && Size <= pInvSlot->Item->SizeCapacity)// && (!pSLOT || pInvSlot->Item->SizeCapacity < pSIZE))
            {
                if (!pInvSlot->pContentsArray) return TRUE;
                unsigned char ucPack = 0;
                for (ucPack = 0; ucPack < pInvSlot->Item->Slots; ucPack++)
                {
                    if (!pInvSlot->pContentsArray->Contents[ucPack])
                    {
                        //pSIZE = cSlot->Item->SizeCapacity;
                        //break;
                        return TRUE;
                    }
                }
            }
        }
        //else
        //{
        //    return ucSlot;
        //}
    }
    return FALSE;
}

long OkayToEquip(long Size)
{
    if (!CursorEmpty() || IsCasting() || !BagWndLoaded()) return false;
    if (Size != NOID) return FitInPack(Size);
    return true;
}

long Unequip(long SlotID)
{
    if (SlotID < NUM_INV_SLOTS)
    {
        PCONTENTS uCONT = GetCharInfo2()->pInventoryArray->InventoryArray[SlotID];
        if(!uCONT) return true;

        CItemLocation cUnequipTo;
        if (!PackFind(&cUnequipTo, uCONT)) return false;

        char szTempSlot[25] = {0};
        sprintf(szTempSlot, "InvSlot%d", SlotID);
        SendWornClick(szTempSlot, SHIFTKEY);
        SendInvClick(cUnequipTo.pEQInvSlot, SHIFTKEY);
        return true;
    }
    return false;
}

int Equip(unsigned long ID, long SlotID)
{
    if(!(SlotID < NUM_INV_SLOTS)) return false;                   // invalid destination slot id for equipping item to
    if(!OkayToEquip())      return false;                         // can't equip item right casting or cursor not free

    char szTempItem[25] = {0};
    sprintf(szTempItem, "%d", ID);
    CItemLocation cMoveItem;
    CItemLocation cUnequipTo;
    CItemLocation* cFinalMove = NULL;

    if (!ItemFind(&cMoveItem, szTempItem, BAG_SLOT_START, NUM_INV_SLOTS)) // assume that equipping item is in a backpack first
    {
        if (!ItemFind(&cMoveItem, szTempItem, 0, BAG_SLOT_START)) // wasnt found, check if already equipped somewhere
        {
            return false; // wasnt found, can't equip something we dont have
        }
    }
    if (SlotID == cMoveItem.InvSlot) return true; // item already in place

    // check class, level, deity and race to see if we have rights to equip this items.
    PCONTENTS fITEM = cMoveItem.pBagSlot;
    if(!(fITEM->Item->Classes&(1<<((GetCharInfo2()->Class)-1))))                      return false;
    if(fITEM->Item->RequiredLevel > GetCharInfo2()->Level)                            return false;
    if(fITEM->Item->Diety && !(fITEM->Item->Diety&(1<<(GetCharInfo2()->Deity-200))))  return false;
    long MyRace=(unsigned long)GetCharInfo2()->Race;
    switch((unsigned long)MyRace)
    {
      case 128: MyRace=12;    break;
      case 130: MyRace=13;    break;
      case 330: MyRace=14;    break;
      case 522: MyRace=15;    break;
      default:  MyRace--;
    }
    if(!(fITEM->Item->Races&(1<<MyRace))) return false;
    if(SlotID==inv_primary && TwohandType(fITEM) && ContSecondary()) if(!Unequip(inv_secondary)) return false;
    if(SlotID==inv_secondary && TwohandType(ContPrimary()))           if(!Unequip(inv_primary))   return false;

    // if wearing something
    if(PCONTENTS dCONT=GetCharInfo2()->pInventoryArray->InventoryArray[SlotID])
    {
        if (cMoveItem.InvSlot >= NUM_INV_SLOTS) // if not a main inv slot
        {
            if (!PackFind(&cUnequipTo, dCONT)) return false; // search bags, if bags cant fit it, return false
            cFinalMove = &cUnequipTo;
        }
        else
        {
            cFinalMove = &cMoveItem;
        }
    }

    sprintf(szTempItem, "InvSlot%d", SlotID);
    SendInvClick(cMoveItem.pEQInvSlot, SHIFTKEY);
    SendWornClick(szTempItem, SHIFTKEY);
    if (cFinalMove) SendInvClick(cFinalMove->pEQInvSlot, SHIFTKEY);
    return true;
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

class Ability {
    CHAR   COMM[16];    // Ability Cast Command
    unsigned long  REUSE;       // Ability Reuse Time
    unsigned long  READY;       // Ability Ready
    long   INDEX;       // Ability Index
    PSPELL EFFECT;      // Ability Spell Effect
    enum { UNKNOWN, ITEM, SKILL, DISC, AA, SPELL, CLICKY, POTION };


public:
    long   ID;          // Ability ID
    long   TYPE;        // Ability Type
    CHAR   NAME[128];   // Ability Name
    int   SEARCH;      // Ability Searched

    int Avail() {
        SEARCH=1;
        EFFECT=0;
        if(ID>NOID) {
            if(TYPE==SKILL || TYPE==UNKNOWN) {
                if(SKCheck(ID)) {
                    strcpy(NAME,szSkills[ID]);
                    REUSE=(ID==i_forage)?101750:delay*3;
                    TYPE=SKILL;
                    return true;
                }
            }
            if(TYPE==DISC || TYPE==UNKNOWN) {
                if(CACheck(ID)) {
                    if(PSPELL spell=GetSpellByID(ID)) {
                        strcpy(NAME,spell->Name);
                        EFFECT=spell;
                        REUSE=spell->CastTime+spell->RecastTime+delay*6;
                        TYPE=DISC;
                        return true;
                    }
                }
            }
            if(TYPE==AA || TYPE==UNKNOWN) {
                if(long AAIndex=AACheck(ID)) {
                    if(PALTABILITY ability=pAltAdvManager->GetAltAbility(AAIndex)) {
                        if(PSPELL spell=GetSpellByID(ability->SpellID)) {
                            strcpy(NAME,pCDBStr->GetString(ability->nName,1,NULL));
                            sprintf(COMM,"%d|ALT",ID);
                            EFFECT=spell;
                            REUSE=pAltAdvManager->GetCalculatedTimer(pPCData,ability)*1000+spell->CastTime+delay*3;
                            INDEX=AAIndex;
                            TYPE=AA;
                            return true;
                        }
                    }
                }
            }
            if(TYPE==SPELL || TYPE==UNKNOWN) {
                if(SpellCheck(ID)) {
                    if(PSPELL spell=GetSpellByID(ID)) {
                        strcpy(NAME,spell->Name);
                        sprintf(COMM,"%d|GEM5",ID);
                        EFFECT=spell;
                        REUSE=spell->CastTime+spell->RecastTime+delay*3;
                        TYPE=SPELL;
                        return true;
                    }
                }
            }
            if(TYPE==POTION || TYPE==CLICKY || TYPE==ITEM || TYPE==UNKNOWN)
            {
                char szTempItem[25] = {0};
                sprintf(szTempItem, "%d", ID);
                CItemLocation cFindItem;
                if (ItemFind(&cFindItem, szTempItem))
                {
                    if (PCONTENTS find = cFindItem.pBagSlot)
                    {
                        INDEX = cFindItem.InvSlot;
                        strcpy(NAME, find->Item->Name);
                        TYPE = ITEM;
                        if(PSPELL spell = GetSpellByID(find->Item->Clicky.SpellID))
                        {
                            sprintf(COMM, "%d|ITEM", ID);
                            EFFECT = spell;
                            REUSE = find->Item->Clicky.TimerID * 1000 + find->Item->CastTime + delay*3;
                            TYPE = (find->Item->ItemType == 21) ? POTION : CLICKY;
                        }
                        return true;
                    }
                }
            }
        }
        return false;
    }

    int Found() {
        if(!SEARCH) Avail();
        return (ID>0 && TYPE != UNKNOWN) ? true : false;
    }

    long Check(string test) {
        if(!Found())                return 0x01;  // Ability Not Found
        if((unsigned long)clock() <= READY) return 0x02;  // Ability Not Refreshed
        if(TYPE==SKILL)
        {
            if(SpawnMount())
            {
                switch(ID)
                {
                    case i_disarm:        break;
                    case i_harmtouch:     break;
                    case i_intimidation:  break;
                    case i_kick:          break;
                    case i_mend:          break;
                    case i_taunt:         break;
                    default:              return 0x03;  // Ability Do Not Work on Mount
                }
            }
            if(!SKReady(ID))        return 0x13;  // Ability Not Ready
        }
        else if(EFFECT)
        {
            if(!IsStanding())       return 0x05;  // Not Standing
            if(IsStunned())         return 0x06;  // Stunned
            if(TYPE > DISC)
            {
                if(IsInvisible())     return 0x04;  // Will Break Invisiblity
                if(Silenced)          return 0x07;  // Silenced
            }
            if(!BardClass && IsCasting())         return 0x08;  // already casting
            if(WinState((CXWnd*)pSpellBookWnd)) return 0x09;  // spellbook open
            if (EFFECT->CARecastTimerID && TYPE != AA && EFFECT->CARecastTimerID != -1)
            {
                //DebugSpew("EFFECT->CARecastTimerID Name: %s  ID: %d Type: %dVal: %d", NAME, ID, TYPE, EFFECT->CARecastTimerID);
                if(((unsigned long)pPCData->GetCombatAbilityTimer(EFFECT->CARecastTimerID) - (unsigned long)time(NULL)) < 0) return 0x16; // dicipline timer not ready
            }
            if((long)EFFECT->ReagentId[0]>0 && (long)CountItemByID(EFFECT->ReagentId[0]) < (long)EFFECT->ReagentCount[0])        return 0x0A;  // out of reagent
            if(EFFECT->EnduranceCost && GetCharInfo2()->Endurance < EFFECT->EnduranceCost)                              return 0x0B;  // out of endurance
            if(EFFECT->Mana && GetCharInfo2()->Mana < EFFECT->Mana)                                                     return 0x0C;  // out of mana
            if(!EFFECT->SpellType)
            {
                if(!pTarget)                                                                                              return 0x0D;  // no target
                float SpellRange=(EFFECT->Range)?EFFECT->Range:EFFECT->AERange;
                if(SpellRange && !InRange(SpawnMe(),(PSPAWNINFO)pTarget,SpellRange))                                      return 0x0E;  // out of range
            }
            else if(EFFECT->DurationValue1>0)
            {
                if(EFFECT->DurationWindow)
                {
                    for(int s=0; s<SongMax; s++)
                    {
                        if(PSPELL buff=GetSpellByID(GetCharInfo2()->ShortBuff[s].SpellID))
                        {
                            if(EFFECT->ID==buff->ID)        return 0x0F; // already have
                            if(!BuffStackTest(EFFECT,buff)) return 0x10; // not stacking
                        }
                    }
                }
                else
                {
                    for(int b=0; b<BuffMax; b++)
                    {
                        if(PSPELL buff=GetSpellByID(GetCharInfo2()->Buff[b].SpellID))
                        {
                            if(EFFECT->ID==buff->ID)        return 0x0F; // already have
                            if(!BuffStackTest(EFFECT,buff)) return 0x10; // not stacking
                        }
                    }
                }
            }
            if(TYPE>DISC && !Evaluate("${If[${Cast.Ready[%s]},1,0]}",COMM)) return 0x11; // mq2cast not ready
            if(TYPE==AA) {
                if(!AAReady(INDEX))       return 0x13;  // Ability Not Ready
            } else if(TYPE==SPELL) {
                if(!pCastSpellWnd)        return 0x12;  // No Casting Spell Bar
                INDEX=SpellGemID(ID,INDEX);
                if(!SpellReady(ID,INDEX)) return 0x13;  // Ability Not Ready
            }
            else if (TYPE==POTION || TYPE==CLICKY)
            {
                //PCONTENTS find=ItemLocate(ID,0,NUM_INV_SLOTS,INDEX);
                char szTempItem[25] = {0};
                sprintf(szTempItem, "%d", ID);
                CItemLocation cFindItem;
                if (ItemFind(&cFindItem, szTempItem))
                {
                    PCONTENTS find = cFindItem.pBagSlot;
                    INDEX = cFindItem.InvSlot;
                    //INDEX=InvSlot;
                    if(!find || !find->Charges || ItemTimer(find)) return 0x13;  // Ability Not Ready
                    if(!CursorEmpty())        return 0x14;  // Cursor Not Empty
                }
            }
        }
        if(!test.empty() && !Evaluate((char*)test.c_str())) return 0x15; // User Condition Abort
        return 0x00;
    }

    int Ready(string test) {
        long Result=Check(test);
        if(DebugReady && Result) {
            char* Message="";
            switch(Result) {
        case 0x01:  Message="NOT FOUND";                break;
        case 0x02:  Message="NOT REFRESHED";            break;
        case 0x03:  Message="NOT WORKING ON MOUNT";     break;
        case 0x04:  Message="WILL BREAK INVISIBILITY";  break;
        case 0x05:  Message="NOT STANDING";             break;
        case 0x06:  Message="STUNNED";                  break;
        case 0x07:  Message="SILENCED";                 break;
        case 0x08:  Message="ALREADY CASTING";          break;
        case 0x09:  Message="SPELLBOOK OPEN";           break;
        case 0x0A:  Message="OUT OF REAGENT";           break;
        case 0x0B:  Message="OUT OF ENDURANCE";         break;
        case 0x0C:  Message="OUT OF MANA";              break;
        case 0x0D:  Message="NO TARGET";                break;
        case 0x0E:  Message="OUT OF RANGE";             break;
        case 0x0F:  Message="ALREADY BUFFED WITH THIS"; break;
        case 0x10:  Message="BUFF NOT STACKING";        break;
        case 0x11:  Message="MQ2CAST NOT READY/FOUND";  break;
        case 0x12:  Message="NO SPELL BAR";             break;
        case 0x13:  Message="ABILITY NOT READY";        break;
        case 0x14:  Message="CURSOR NOT EMPTY";         break;
        case 0x15:  Message="USER CONDITION ABORT";     break;
        case 0x16:  Message="TIMER NOT READY";          break;
            }
            Announce(DebugReady,"Ability[%d][%d][%s] <<%s>>.",ID,TYPE,NAME,Message);
        }
        return (!Result);
    }

    int Press() {
        int Casted=false;
        if(Found() && (unsigned long)clock()>READY) {
            Announce(SHOW_ABILITY,"%s::Activate [\ay%s\ax].",PLUGIN_NAME,NAME);
            if(TYPE==SKILL)     Casted=SKPress(ID);
            else if(TYPE==DISC) Casted=CAPress(ID);
            else if(TYPE>=AA)   Casted=Casting(COMM);
            if(Casted) READY=(unsigned long)clock()+REUSE;
        }
        return Casted;
    }

    void Setup(long id, long type) {
        ID=id;            // Ability ID?
        TYPE=type;        // Ability Type?
        NAME[0]=0;        // Ability Name?
        COMM[0]=0;        // Ability Command?
        SEARCH=false;     // Ability Searched?
        READY=0;          // Ability Ready Time
        INDEX=NOID;       // Ability Index
        EFFECT=NULL;      // Ability Spell Effect
    }

    Ability(long id, long type) {
        Setup(id,type);
    }

    Ability() {
        Setup(0,UNKNOWN);
    }
};

class Option {
public:
    char*    K;  // key?
    char*    H;  // help?
    char*    D;  // default?
    char*    S;  // show?
    string  *C;  // condition?
    Ability *A;  // ability?
    long    *V;  // value?
    Function F;  // function?
    int     U;  // update?

    Option(char* k, char* h, char* d, char* s, Function f, string *c) {
        K=k; H=h; D=d; S=s; F=f; U=false; C=c; A=NULL; V=NULL;
    }

    Option(char* k, char* h, char* d, char* s, Function f, Ability *a) {
        K=k; H=h; D=d; S=s; F=f; U=false; C=NULL; A=a; V=NULL;
    }

    Option(char* k, char* h, char* d, char* s, Function f, long *v) {
        K=k; H=h; D=d; S=s; F=f; U=false; C=NULL; A=NULL; V=v;
    }

    void Write() {
        if(K[0] && !C && Evaluate(S)) {
            long value=(A)?A->ID:(V)?*V:0;
            if(value>0) WriteChatf("%s::%s (\ag%d\ax) \ay%s\ax.",PLUGIN_NAME,K,value,H);
            else        WriteChatf("%s::%s (\ar0\ax) \ay%s\ax." ,PLUGIN_NAME,K,H);
        }
    }

    void Setup(char* value) {
        if(C) *C=value;
        else if(A) A->Setup(atol(value),0);
        else if(V) {
            if(!stricmp("false",value) || !stricmp("off",value))    *V=0;
            else if(!stricmp("true",value) || !stricmp("on",value)) *V=1;
            else *V=atol(value);
        }
        if(F) this->F();
    }

    void *Value() {
        if(A) return &A->ID;
        else if(V) return V;
        else if(C) return C;
        return NULL;
    }

    long Ready() {
        if(A) return A->Ready("");
        return NOID;
    }

    void Reset() {
        if(K[0]) {
            if(C) *C=D;
            else {
                strcpy(Reserved,D);
                if(Reserved[0]) ParseMacroData(Reserved);
                long value=atol(Reserved);
                if(A) A->Setup(value,0);
                else if(V) *V=value;

            }
            if(F) this->F();
        }
    }
};

typedef map<string,Option> Liste;     // declare a type so more easy to refer
Liste     CmdListe;                   // settings from command or ini
Liste     IniListe;                   // settings from ini only
Liste     VarListe;                   // settings from var liste

CHAR      section[256];               // ini section

long      doAGGRO,
doASP,
doASSASINATE,
doASSAULT,
doBACKOFF,
doBACKSTAB,
doBASH,
doBATTLELEAP,
doBEGGING,
doBLEED,
doBOASTFUL,
doBVIVI,
doCALLCHALLENGE,
doCHALLENGEFOR,
doCOMMANDING,
doCRIPPLE,
doCRYHAVOC,
doCSTRIKE,
doDEFENSE,
doDISARM,
doDOWNFLAG[16],
doDRAGONPUNCH,
doEAGLESTRIKE,
doENRAGE,
doESCAPE,
doEVADE,
doEYEGOUGE,
doFACING,
doFALLS,
doFEIGNDEATH,
doFERALSWIPE,
doFIELDARM,
doFISTSOFWU,
doFCLAW,
doFLYINGKICK,
doFORAGE,
doFRENZY,
doGORILLASMASH,
doGUTPUNCH,
doHARMTOUCH,
doHIDE,
doHOLYFLAG[16],
doINFURIATE,
doINTIMIDATION,
doJLTKICKS,
doJOLT,
doKICK,
doKNEESTRIKE,
doLAYHAND,
doLEOPARDCLAW,
doMELEE,
doMEND,
doOPFRENZY,
doOPPORTUNISTICSTRIKE,
doPETASSIST,
doPETDELAY,
doPETMEND,
doPETRANGE,
doPICKPOCKET,
doPOTHEALFAST,
doPOTHEALOVER,
doPROVOKEEND,
doPROVOKEMAX,
doPROVOKEONCE,
doRAGEVOLLEY,
doRAKE,
doRALLOS,
doRANGE,
doRAVENS,
doRESUME,
doRIGHTIND,
doROUNDKICK,
doSELOS,
doSENSETRAP,
doSKILL,
doSLAM,
doSLAPFACE,
doSNEAK,
doSTAB,
doSTAND,
doSTICKBREAK,
doSTICKDELAY,
doSTICKMODE,
doSTICKNORANGE,
doSTICKRANGE,
doSTRIKE,
doSTRIKEMODE,
doSTUNNING,
doSYNERGY,
doTAUNT,
doTHIEFEYE,
doTHROATJAB,
doTHROWSTONE,
doTIGERCLAW,
doTWISTEDSHANK,
doVIG,
doWITHSTAND;

long      elARROWS,
elAGGROPRI,
elAGGROSEC,
elMELEEPRI,
elMELEESEC,
elPOKER,
elRANGED,
elSHIELD;

string    ifASP,
ifASSAULT,
ifBACKSTAB,
ifBASH,
ifBATTLELEAP,
ifBEGGING,
ifBOASTFUL,
ifBLEED,
ifBVIVI,
ifCALLCHALLENGE,
ifCHALLENGEFOR,
ifCOMMANDING,
ifCRIPPLE,
ifCRYHAVOC,
ifCSTRIKE,
ifDEFENSE,
ifDISARM,
ifDRAGONPUNCH,
ifEAGLESTRIKE,
ifEVADE,
ifEYEGOUGE,
ifFALLS,
ifFERALSWIPE,
ifFIELDARM,
ifFISTSOFWU,
ifFCLAW,
ifFLYINGKICK,
ifFORAGE,
ifFRENZY,
ifGORILLASMASH,
ifGUTPUNCH,
ifHARMTOUCH,
ifHIDE,
ifINTIMIDATION,
ifJLTKICKS,
ifJOLT,
ifKICK,
ifKNEESTRIKE,
ifLAYHAND,
ifLEOPARDCLAW,
ifMEND,
ifOPFRENZY,
ifOPPORTUNISTICSTRIKE,
ifPICKPOCKET,
ifPOTHEALFAST,
ifPOTHEALOVER,
ifPROVOKE,
ifRAGEVOLLEY,
ifRAKE,
ifRALLOS,
ifRAVENS,
ifRIGHTIND,
ifROUNDKICK,
ifSELOS,
ifSENSETRAP,
ifSLAM,
ifSLAPFACE,
ifSNEAK,
ifSTRIKE,
ifSTUNNING,
ifSYNERGY,
ifTAUNT,
ifTHIEFEYE,
ifTHROATJAB,
ifTHROWSTONE,
ifTIGERCLAW,
ifTWISTEDSHANK,
ifVIG,
ifWITHSTAND,
DOWNSHIT[16],
HOLYSHIT[16],
StickCMD,
StrikeCMD;

Ability  idASP,
idASSAULT,
idBACKSTAB,
idBASH,
idBATTLELEAP,
idBEGGING,
idBLEED,
idBOASTFUL,
idBVIVI,
idCALLCHALLENGE,
idCSTRIKE,
idCHALLENGEFOR,
idCOMMANDING,
idCRIPPLE,
idCRYHAVOC,
idDEFENSE,
idDISARM,
idDRAGONPUNCH,
idEAGLESTRIKE,
idESCAPE,
idEYEGOUGE,
idFEIGN[2],
idFERALSWIPE,
idFIELDARM,
idFISTSOFWU,
idFCLAW,
idFLYINGKICK,
idFORAGE,
idFRENZY,
idGORILLASMASH,
idGUTPUNCH,
idHARMTOUCH,
idHIDE,
idINTIMIDATION,
idJLTKICKS,
idJOLT,
idKICK,
idKNEESTRIKE,
idLAYHAND,
idLEOPARDCLAW,
idMEND,
idOPFRENZY,
idOPPORTUNISTICSTRIKE,
idPETMEND,
idPICKPOCKET,
idPOTHEALFAST,
idPOTHEALOVER,
idPROVOKE[2],
idRAGEVOLLEY,
idRAKE,
idRALLOS,
idRAVENS,
idRIGHTIND,
idROUNDKICK,
idSELOS,
idSENSETRAP,
idSLAM,
idSLAPFACE,
idSNEAK,
idSTRIKE,
idSTUN[2],
idSYNERGY,
idTAUNT,
idTHIEFEYE,
idTHROATJAB,
idTHROWSTONE,
idTIGERCLAW,
idTWISTEDSHANK,
idVIG,
idWITHSTAND;

unsigned long     Shrouded       =false;        // True when shrouded.
bool      Binded         =false;        // Attack Key is Binded?
bool      Loaded         =false;        // Loaded?
bool      Moving         =false;        // Moving?
bool      Immobile       =false;        // Immobilized?
bool      AutoFire       =false;        // True when autofire is on.
bool      HaveBash       =false;        // Have Two Hand Bash?
bool      HaveHold       =false;        // Have Pet Hold?
unsigned long     BrokenFD       =0;            // Timer for Broken Feign Death

float     Travel         =0.0f;         // Travel Speed?
long      Health         =0;            // Current Health

unsigned long     MeleeTime      =0;            // Melee Pulse Timer
long      MeleeTarg      =0;            // Melee Target ID
long      MeleeType      =0;            // Melee Target Type
long      MeleeFlee      =0;            // Melee Target Fleeing?
long      MeleeLife      =0;            // Melee Target Life %
long      MeleeCast      =0;            // Melee Target Cast ?
long      MeleeSize      =0;            // Melee Name Size
char      MeleeName[64]  ={0};          // Melee Name

double    MeleeSpeed     =0.0f;         // Melee Target Speed
double    MeleeBack      =0.0f;         // Melee Target Angle Back
double    MeleeView      =0.0f;         // Melee Target Angle View
double    MeleeDist      =0.0f;         // Melee Distance to Target
double    MeleeKill      =0.0f;         // Melee Distance to Use Ability

long      onEVENT        =false;        // Ranged=0x8000,Begging=0x2000,PickPocket=0x1000,Feign=0x0040,Hide=0x0020,Backoff=0x0010,Infuriate=0x0002,Enrage=0x0001
long      onSTICK        =false;        // Do Stick? (turn false when stick command is issue)
long      onBELOW        =false;        // Below Flag? (turn false when no more provoke counter)
long      onCHALLENGEFOR =false;        // Challenge Flag? (turn to false when use once)

unsigned long     NPC_TYPE       =0x000A;       // NPC TYPE
char      MeleeKey[32];                 // Plugin Melee Key
char      RangeKey[32];                 // Plugin Range Key

unsigned long     PetInDist      =0;            // Pet Target in Range
unsigned long     PetOnAttk      =0;            // Pet Seen Attacking TimeStamp?
unsigned long     PetOnHold      =0;            // Pet Hold?
unsigned long     PetOnWait      =0;            // Pet Wait Assist Delay TimeStamp
unsigned long     PetTarget      =0;            // Pet Target ID

unsigned long     TimerAttk      =0;            // Timer Attk
unsigned long     TimerBack      =0;            // Timer BackOff/Escape/Feign
unsigned long     TimerMove      =0;            // Timer Move
unsigned long     TimerLife      =0;            // Timer Life (Target his dieing)
unsigned long     TimerFace      =0;            // Face Time Stamp when started
unsigned long     TimerStik      =0;            // Stik Time Stamp when started
unsigned long     TimerStun      =0;            // Timer Stun

long      SwingHits      =0;            // Total Hits
long      TakenHits      =0;            // Under Hits

long      doHOLY=0;                     // Holy Shits while meleeing?
long      doDOWN=0;                     // Down Shits while downtime?

Blech    *pMeleeEvent=0;                // blech event list
bool      ColorArray[512];              // blech color filtering
bool      IdlingArray[256];             // animation array while idle
bool      AttackArray[256];             // animation array while attacking

long      SaveList[50];                 // saved event list
long      SaveIndx;                     // saved event counters

unsigned long     HiddenTimer     =0;           // Last TimeStamp for Hide
unsigned long     SilentTimer     =0;           // Last TimeStamp for Sneak

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

class MQ2MeleeType *pMeleeTypes=0;
class MQ2MeleeType : public MQ2Type {
private:
    long isKill;
    char Tempos[MAX_STRING];
public:
    enum Information {
        Enable=1,
        Combat=2,
        Casted=3,
        Engage=4,
        Status=5,
        Target=6,
        DiscID=7,
        Enrage=8,
        Infuriate=9,
        AggroMode=10,
        MeleeMode=11,
        RangeMode=12,
        BackAngle=13,
        ViewAngle=14,
        Immobilize=15,
        Ammunition=16,
        BackStabbing=17,
        GotAggro=18,
        Hidden=19,
        Silent=20,
        NumHits=21,
    };
    MQ2MeleeType():MQ2Type("Melee") {
        TypeMember(Enable);
        TypeMember(Combat);
        TypeMember(Casted);
        TypeMember(Status);
        TypeMember(Target);
        TypeMember(DiscID);
        TypeMember(GotAggro);
        TypeMember(AggroMode);
        TypeMember(MeleeMode);
        TypeMember(RangeMode);
        TypeMember(Enrage);
        TypeMember(Infuriate);
        TypeMember(BackAngle);
        TypeMember(ViewAngle);
        TypeMember(Immobilize);
        TypeMember(Ammunition);
        TypeMember(BackStabbing);
        TypeMember(Hidden);
        TypeMember(Silent);
        TypeMember(NumHits);
    }
    bool GetMember(MQ2VARPTR VarPtr, char* Member, char* Index, MQ2TYPEVAR &Dest) {
        PMQ2TYPEMEMBER pMember=MQ2MeleeType::FindMember(Member);
        isKill=false; if(doSKILL) if(MeleeTarg) isKill=true;
        if(pMember) switch((Information)pMember->ID) {
    case Enable:
        Dest.DWord=doSKILL;
        Dest.Type=pBoolType;
        return true;
    case Combat:
        Dest.DWord=isKill;
        Dest.Type=pBoolType;
        return true;
    case Casted:
        Dest.Int=(isKill && MeleeCast)?labs((unsigned long)clock()-MeleeCast):60000;
        Dest.Type=pIntType;
        return true;
    case Status:
        Tempos[0]=0;
        if(isKill) strcat(Tempos,"ENGAGED ");
        else strcat(Tempos,"WAITING ");
        if(*EQADDR_ATTACK) strcat(Tempos, "MELEE ");
        else if(onEVENT&0x8000) strcat(Tempos,"RANGE ");
        if(onEVENT&0x0001) strcat(Tempos,"ENRAGE ");
        if(onEVENT&0x0002) strcat(Tempos,"INFURIATE ");
        if(onEVENT&0x0010) strcat(Tempos,"BACKING ");
        if(onEVENT&0x0020) strcat(Tempos,"ESCAPING ");
        if(onEVENT&0x0040) strcat(Tempos,"FEIGNING ");
        if(onEVENT&0x0200) strcat(Tempos,"EVADING ");
        if(onEVENT&0x0400) strcat(Tempos,"FALLING ");
        if(onEVENT&0x1000) strcat(Tempos,"STEALING ");
        if(onEVENT&0x2000) strcat(Tempos,"BEGGING ");
        Dest.Type=pStringType;
        Dest.Ptr=Tempos;
        return true;
    case Target:
        Dest.Int=isKill?MeleeTarg:0;
        Dest.Type=pIntType;
        return true;
    case DiscID:
        Dest.DWord=Discipline();
        Dest.Type=pIntType;
        return true;
    case GotAggro:
        Dest.DWord=(Aggroed(MeleeTarg)>0);
        Dest.Type=pBoolType;
        return true;
    case AggroMode:
        Dest.DWord=doAGGRO;
        Dest.Type=pBoolType;
        return true;
    case MeleeMode:
        Dest.DWord=doMELEE;
        Dest.Type=pBoolType;
        return true;
    case RangeMode:
        Dest.DWord=doRANGE;
        Dest.Type=pBoolType;
        return true;
    case Enrage:
        Dest.DWord=onEVENT&0x0001;
        Dest.Type=pBoolType;
        return true;
    case Infuriate:
        Dest.DWord=onEVENT&0x0002;
        Dest.Type=pBoolType;
        return true;
    case BackAngle:
        Dest.Float=pTarget?AngularDistance(((PSPAWNINFO)pTarget)->Heading,SpawnMe()->Heading):0.0f;
        Dest.Type=pFloatType;
        return true;
    case ViewAngle:
        Dest.Float=pTarget?(float)AngularHeading(SpawnMe(),(PSPAWNINFO)pTarget):0.0f;
        Dest.Type=pFloatType;
        return true;
    case Immobilize:
        Dest.DWord=Immobile;
        Dest.Type=pBoolType;
        return true;
    case Ammunition:
        Dest.DWord=CountItemByID(elARROWS);
        if(PCONTENTS r=GetCharInfo2()->pInventoryArray->Inventory.Ammo)
            if(r->Item->ItemNumber != elARROWS)
                if(r->Item->ItemType==7 || r->Item->ItemType==19 || r->Item->ItemType==27)
                    Dest.DWord=CountItemByID(r->Item->ItemNumber);
        Dest.Type=pIntType;
        return true;
    case BackStabbing:
        Dest.DWord=doBACKSTAB;
        Dest.Type=pBoolType;
        return true;
    case Hidden:
        Dest.Int=TimeSince(HiddenTimer);
        Dest.Type=pIntType;
        return true;
    case Silent:
        Dest.Int=TimeSince(SilentTimer);
        Dest.Type=pIntType;
        return true;
    case NumHits:
        Dest.DWord=SwingHits;
        Dest.Type=pIntType;
        return true;
        }
        strcpy(Tempos,"NULL");
        Dest.Type=pStringType;
        Dest.Ptr=Tempos;
        return true;
    }
    bool ToString(MQ2VARPTR VarPtr, char* Destination) {
        strcpy(Destination,"TRUE");
        return true;
    }
    bool FromData(MQ2VARPTR &VarPtr, MQ2TYPEVAR &Source) {
        return false;
    }
    bool FromString(MQ2VARPTR &VarPtr, char* Source) {
        return false;
    }
    ~MQ2MeleeType() { }
};

int DataMelee(char* Index, MQ2TYPEVAR &Dest) {
    Dest.Type=pMeleeTypes;
    Dest.DWord=1;
    return true;
}

int datameleemvb(char* Index, MQ2TYPEVAR &Dest) {
    Dest.Type=pIntType;
    Dest.Int=NOID;
    Liste::iterator c;
    if(VarListe.end()!=(c=VarListe.find(Index)))
        Dest.Int=(*c).second.Ready();
    return true;
}

int datameleemvi(char* Index, MQ2TYPEVAR &Dest) {
    Dest.Type=pIntType;
    Dest.DWord=0;
    Liste::iterator c;
    if(CmdListe.end()!=(c=CmdListe.find(Index))) {
        if(long *V=(long*)(*c).second.Value()) Dest.DWord=*V;
        return true;
    }
    if(VarListe.end()!=(c=VarListe.find(Index))) {
        if(long *V=(long*)(*c).second.Value()) Dest.DWord=*V;
        return true;
    }
    return true;
}

int datameleemvs(char* Index, MQ2TYPEVAR &Dest) {
    Dest.Type=pStringType;
    Dest.Ptr=&Workings;
    Liste::iterator c=IniListe.find(Index);
    if(IniListe.end()!=c) {
        if(string *S=(string*)(*c).second.Value())
            strcpy(Workings,S->c_str());
    } else Workings[0]=0;
    return true;
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

void AbilityFind(Ability *thisone, infodata *first, ...) {
    infodata *c=first;
    va_list  marker;
    va_start(marker,first);
    while(c) {
        thisone->Setup(c->i,c->t);
        if(thisone->Avail()) break;
        thisone->ID=0;
        c=va_arg(marker,infodata *);
    }
    va_end(marker);
}

void AttackON() {
    if(*EQADDR_ATTACK || onEVENT&0xFFF7 || IsFeigning() || !doMELEE || !TargetID(MeleeTarg)) return;
    EzCommand("/attack on");
    TimerAttk=(unsigned long)clock();
}

void AttackOFF() {
    if(*EQADDR_ATTACK) EzCommand("/attack off");
}

bool BashCheck() {
    if(ShieldType(ContSecondary())) return true;
    if(TwohandType(ContPrimary()))  return HaveBash;
    return (elSHIELD && CountItemByID(elSHIELD) && OkayToEquip(Giant));
}

void BashPress() {
    long savedpri=0; long savedoff=0; int got2hand=false;
    if(PCONTENTS pri=ContPrimary()) {
        got2hand=TwohandType(pri);
        savedpri=pri->Item->ItemNumber;
    }
    if(PCONTENTS off=ContSecondary()) savedoff=off->Item->ItemNumber;
    if(elSHIELD && CountItemByID(elSHIELD) && OkayToEquip(Giant)) Equip(elSHIELD,inv_secondary);
    if(ShieldType(ContSecondary()) || (got2hand && HaveBash)) idBASH.Press();
    if(savedoff) Equip(savedoff,inv_secondary);
    if(savedpri) Equip(savedpri,inv_primary);
}

void Configure() {
    long Class=GetCharInfo2()->Class;
    long Races=GetCharInfo2()->Race;
    long Level=GetCharInfo2()->Level;
    sprintf(INIFileName,"%s\\%s_%s.ini",gszINIPath,EQADDR_SERVERNAME,GetCharInfo()->Name);
    sprintf(section,"%s_%d_%s_%s",PLUGIN_NAME,Level,pEverQuest->GetRaceDesc(Races),pEverQuest->GetClassDesc(Class));
    Shrouded=GetCharInfo2()->Shrouded; if(!Shrouded) section[strlen(PLUGIN_NAME)]=0;
    BuffMax=15;
    if(GetAAIndexByName("Embrace of the Dark Reign"))   BuffMax++;
    else if(GetAAIndexByName("Embrace of the Keepers")) BuffMax++;
    BuffMax+=(AAPoint(GetAAIndexByName("Mystical Attuning")))/5;
    if(SpawnMe()->Level>71) BuffMax++;
    if(SpawnMe()->Level>74) BuffMax++;
    HaveHold=GetAAIndexByName("Pet Discipline")?true:false;
    HaveBash=GetAAIndexByName("2 Hand Bash")?true:false;
    BardClass=false;
    char keys[MAX_STRING*5];
    char temp[MAX_STRING];
    Liste::iterator c,i;
    Liste::iterator ec=CmdListe.end();
    Liste::iterator ei=IniListe.end();
    for(c=CmdListe.begin(); c!=ec; c++) (*c).second.Reset();
    for(i=IniListe.begin(); i!=ei; i++) (*i).second.Reset();

    idASP.Setup(0,0); 
    idBLEED.Setup(0,0); 
    idASSAULT.Setup(0,0);
    idBACKSTAB.Setup(0,0);
    idBASH.Setup(0,0);
    idBATTLELEAP.Setup(0,0);
    idBEGGING.Setup(0,0);
    idBOASTFUL.Setup(0,0);
    idBVIVI.Setup(0,0);
    idCALLCHALLENGE.Setup(0,0);
    idCHALLENGEFOR.Setup(0,0);
    idCSTRIKE.Setup(0,0);
    idCOMMANDING.Setup(0,0);
    idCRIPPLE.Setup(0,0);
    idCRYHAVOC.Setup(0,0);
    idDEFENSE.Setup(0,0);
    idDISARM.Setup(0,0);
    idDRAGONPUNCH.Setup(0,0);
    idEAGLESTRIKE.Setup(0,0);
    idESCAPE.Setup(0,0);
    idEYEGOUGE.Setup(0,0);
    idFEIGN[0].Setup(0,0);
    idFEIGN[1].Setup(0,0);
    idFIELDARM.Setup(0,0);
    idFISTSOFWU.Setup(0,0);
    idFCLAW.Setup(0,0);
    idFLYINGKICK.Setup(0,0);
    idFORAGE.Setup(0,0);
    idFRENZY.Setup(0,0);
    idGORILLASMASH.Setup(0,0);
    idGUTPUNCH.Setup(0,0);
    idHARMTOUCH.Setup(0,0);
    idHIDE.Setup(0,0);
    idINTIMIDATION.Setup(0,0);
    idJLTKICKS.Setup(0,0);
    idJOLT.Setup(0,0);
    idKICK.Setup(0,0);
    idKNEESTRIKE.Setup(0,0);
    idLAYHAND.Setup(0,0);
    idLEOPARDCLAW.Setup(0,0);
    idMEND.Setup(0,0);
    idOPFRENZY.Setup(0,0);
    idOPPORTUNISTICSTRIKE.Setup(0,0);
    idPETMEND.Setup(0,0);
    idPICKPOCKET.Setup(0,0);
    idPOTHEALFAST.Setup(0,0);
    idPOTHEALOVER.Setup(0,0);
    idPROVOKE[0].Setup(0,0);
    idPROVOKE[1].Setup(0,0);
    idRAGEVOLLEY.Setup(0,0);
    idRAKE.Setup(0,0);
    idRALLOS.Setup(0,0);
    idRAVENS.Setup(0,0);
    idRIGHTIND.Setup(0,0);
    idROUNDKICK.Setup(0,0);
    idSELOS.Setup(0,0);
    idSENSETRAP.Setup(0,0);
    idSLAM.Setup(0,0);
    idSLAPFACE.Setup(0,0);
    idSNEAK.Setup(0,0);
    idSTRIKE.Setup(0,0);
    idSYNERGY.Setup(0,0);
    idSTUN[0].Setup(0,0);
    idSTUN[1].Setup(0,0);
    idTAUNT.Setup(0,0);
    idTHIEFEYE.Setup(0,0);
    idTHROATJAB.Setup(0,0);
    idTHROWSTONE.Setup(0,0);
    idTIGERCLAW.Setup(0,0);
    idTWISTEDSHANK.Setup(0,0);
    idVIG.Setup(0,0);
    idWITHSTAND.Setup(0,0);

    AbilityFind(&idBACKSTAB,&sbkstab,0);
    AbilityFind(&idBASH,&sbash,0);
    AbilityFind(&idBEGGING,&sbegging,0);
    AbilityFind(&idDISARM,&sdisarm,0);
    AbilityFind(&idFORAGE,&sforage,0);
    AbilityFind(&idFRENZY,&sfrenzy,0);
    AbilityFind(&idHIDE,&shide,0);
    AbilityFind(&idINTIMIDATION,&sintim,0);
    AbilityFind(&idKICK,&skick,0);
    AbilityFind(&idLAYHAND,&layhand,0);
    AbilityFind(&idMEND,&smend,0);
    AbilityFind(&idPICKPOCKET,&sppocket,0);
    AbilityFind(&idSENSETRAP,&ssensetr,0);
    AbilityFind(&idSLAM,&sslam,0);
    AbilityFind(&idSNEAK,&ssneak,0);
    AbilityFind(&idTAUNT,&staunt,0);
    AbilityFind(&idBATTLELEAP,&btlleap,0);
    AbilityFind(&idTHROWSTONE,&tstone,0);

    AbilityFind(&idPOTHEALOVER,&potover14,&potover13,&potover12,&potover11,&potover10,&potover9,&potover8,&potover7,&potover6,&potover5,&potover4,&potover3,&potover2,&potover1,&potover0,0);
    AbilityFind(&idPOTHEALFAST,&potfast14,&potfast13,&potfast12,&potfast11,&potfast10,&potfast9,&potfast8,&potfast7,&potfast6,&potfast5,&potfast4,&potfast3,&potfast2,&potfast1,&potfast0,0);
    doSTAB=0;
    switch(Class) {
    case  1: // WAR
        AbilityFind(&idPROVOKE[1],&prowar_25,&prowar_24,&prowar_23,&prowar_22,&prowar_21,&prowar_20,&prowar_19,&prowar_18,&prowar_17,&prowar_16,&prowar_15,&prowar_14,&prowar_13,&prowar_12,&prowar_11,&prowar_10,&prowar_9,&prowar_8,&prowar_7,&prowar_6,&prowar_5,&prowar_4,&prowar_3,&prowar_2,&prowar_1,0);
        AbilityFind(&idOPPORTUNISTICSTRIKE,&opstrke6,&opstrke5,&opstrke4,&opstrke3,&opstrke2,&opstrke1,0);
        AbilityFind(&idFIELDARM,&fieldarm6,&fieldarm5,&fieldarm4,&fieldarm3,&fieldarm2,&fieldarm1,0);
        AbilityFind(&idDEFENSE,&defense6,&defense5,&defense4,&defense3,&defense2,&defense1,0);
        AbilityFind(&idTHROATJAB,&throat3,&throat2,&throat1,0);
        AbilityFind(&idKNEESTRIKE,&kneestrike,0);
        AbilityFind(&idGUTPUNCH,&gutpunch,0);
	    AbilityFind(&idCALLCHALLENGE,&callchal,0);
		AbilityFind(&idCOMMANDING,&commanding,0);
        break;
    case  3: // PAL
        AbilityFind(&idCHALLENGEFOR,&honor12,&honor11,&honor10,&honor9,&honor8,&honor7,&honor6,&honor5,&honor4,&honor3,&honor2,&honor1,0);
        AbilityFind(&idPROVOKE[0],&stunaas3,&stunaas2,&stunaas1,0);
        AbilityFind(&idPROVOKE[1],&stunpal29,&stunpal28,&stunpal27,&stunpal26,&stunpal25,&stunpal24,&stunpal23,&stunpal22,&stunpal21,&stunpal20,&stunpal19,&stunpal18,&stunpal17,&stunpal16,&stunpal15,&stunpal14,&stunpal13,&stunpal12,&stunpal11,&stunpal10,&stunpal9,&stunpal8,&stunpal7,&stunpal6,&stunpal5,&stunpal4,&stunpal3,&stunpal2,&stunpal1,0);
        AbilityFind(&idSTUN[0],&stunaas3,&stunaas2,&stunaas1,0);
        AbilityFind(&idSTUN[1],&stunpal29,&stunpal28,&stunpal27,&stunpal26,&stunpal25,&stunpal24,&stunpal23,&stunpal22,&stunpal21,&stunpal20,&stunpal19,&stunpal18,&stunpal17,&stunpal16,&stunpal15,&stunpal14,&stunpal13,&stunpal12,&stunpal11,&stunpal10,&stunpal9,&stunpal8,&stunpal7,&stunpal6,&stunpal5,&stunpal4,&stunpal3,&stunpal2,&stunpal1,0);
        AbilityFind(&idWITHSTAND,&withstand6,&withstand5,&withstand4,&withstand3,&withstand2,&withstand1,0);
        AbilityFind(&idRIGHTIND,&rightidg1,&rightidg2,&rightidg3,0);
		
        break;
    case  4: // RNG
        AbilityFind(&idJOLT,&joltrng2,&joltrng1,0);
        AbilityFind(&idJLTKICKS,&jltkicks12,&jltkicks11,&jltkicks10,&jltkicks9,&jltkicks8,&jltkicks7,&jltkicks6,&jltkicks5,&jltkicks4,&jltkicks3,&jltkicks2,&jltkicks1,0);
   
    break;
    case  5: // SHD
        AbilityFind(&idFEIGN[0],&feigns18,&feigns17,&feigns16,&feigns15,&feigns14,&feigns13,&feigns12,&feigns11,&feigns10,&feigns9,&feigns8,&feigns7,&feigns6,&feigns5,&feigns4,&feigns3,&feigns2,&feigns1,0);
        AbilityFind(&idFEIGN[1],&feigndp,0);
		AbilityFind(&idHARMTOUCH,&harmtouch,0);
        AbilityFind(&idCHALLENGEFOR,&power12,&power11,&power10,&power9,&power8,&power7,&power6,&power5,&power4,&power3,&power2,&power1,0);
        AbilityFind(&idPROVOKE[1],&terror16,&terror15,&terror14,&terror13,&terror12,&terror11,&terror10,&terror9,&terror8,&terror7,&terror6,&terror5,&terror4,&terror3,&terror2,&terror1,0);
        AbilityFind(&idWITHSTAND,&withstand6,&withstand5,&withstand4,&withstand3,&withstand2,&withstand1,0);
        break;
    case  7: // MNK
	    AbilityFind(&idFISTSOFWU,&fistswu,0);
	    AbilityFind(&idDRAGONPUNCH,&sdrpunch,0);
		AbilityFind(&idEAGLESTRIKE,&sestrike,0);
		AbilityFind(&idTIGERCLAW,&stigclaw,0);
	    AbilityFind(&idROUNDKICK,&srndkick,0);
		AbilityFind(&idFLYINGKICK,&sflykick,0);
        AbilityFind(&idFEIGN[0],&sfeign,0);
        AbilityFind(&idFEIGN[1],&feignid,0);
        AbilityFind(&idPROVOKE[0],&stunmnk2,&stunmnk1,0);
        AbilityFind(&idSTUN[0],&stunmnk2,&stunmnk1,0);
        AbilityFind(&idLEOPARDCLAW,&leop14,&leop13,&leop12,&leop11,&leop10,&leop9,&leop8,&leop7,&leop6,&leop5,&leop4,&leop3,&leop2,&leop1,0);
        AbilityFind(&idVIG,&vigmnk3,&vigmnk2,&vigmnk1,0);
        AbilityFind(&idSYNERGY,&synergy6,&synergy5,&synergy4,&synergy3,&synergy2,&synergy1,0);
        break;
    case  8: // BRD
        BardClass = true;
        AbilityFind(&idSELOS,&selos,0);
        AbilityFind(&idBOASTFUL,&boastful,0);
        break;
    case  9: // ROG
        AbilityFind(&idTHIEFEYE,&thiefeye,0);
        AbilityFind(&idSTRIKE,&strike16,&strike15,&strike14,&strike13,&strike12,&strike11,&strike10,&strike9,&strike8,&strike7,&strike6,&strike5,&strike4,&strike3,&strike2,&strike1,0);
        AbilityFind(&idVIG,&vigrog6,&vigrog5,&vigrog4,&vigrog3,&vigrog2,&vigrog1,0);
        AbilityFind(&idASSAULT,&assault6,&assault5,&assault4,&assault3,&assault2,&assault1,0);
        AbilityFind(&idBLEED,&bleed6,&bleed5,&bleed4,&bleed3,&bleed2,&bleed1,0);
		AbilityFind(&idESCAPE,&escape,0);
		AbilityFind(&idTWISTEDSHANK,&twisted,0);
        switch(AAPoint(GetAAIndexByName("Seized Opportunity")))
        {
        case 74:
            doSTAB=512;
            break;
        case 60:
            doSTAB=256;
            break;
        case 39:
            doSTAB=192;
            break;
        case 18:
            doSTAB=128;
            break;
        default:
            doSTAB=64;
            break;
        }
        break;
    case 11: // NEC
        AbilityFind(&idFEIGN[0],&feign_n3,&feign_n2,&feign_n1,&feigns3,&feigns2,&feigns1,0);
        AbilityFind(&idFEIGN[1],&feigndp,0);
        AbilityFind(&idPETMEND,&mendpet2,&mendpet1,0);
        break;
    case 13: // MAG
        AbilityFind(&idPETMEND,&mendpet2,&mendpet1,0);
        break;
    case 15: // BST
        AbilityFind(&idRAKE,&rake10,&rake9,&rake8,&rake7,&rake6,&rake5,&rake4,&rake3,&rake2,&rake1,0);
        AbilityFind(&idFERALSWIPE,&feral1,0);
        AbilityFind(&idPETMEND,&mendpet1,&mendpet2,0);
        AbilityFind(&idJOLT,&joltbst1,0);
        AbilityFind(&idFEIGN[0],&feign_bst,0);
        AbilityFind(&idASP,&asp,0);
        AbilityFind(&idCSTRIKE,&cstrike,0);
        AbilityFind(&idRAVENS,&ravens,0);
        AbilityFind(&idFCLAW,&fclaw3,&fclaw2,&fclaw1,0);
        AbilityFind(&idBVIVI,&bvivi3,&bvivi2,&bvivi1,0);
		AbilityFind(&idGORILLASMASH,&gorillasmash,0);
        break;
    case 16: // BER
        AbilityFind(&idJOLT,&joltber16,&joltber15,&joltber14,&joltber13,&joltber12,&joltber11,&joltber10,&joltber9,&joltber8,&joltber7,&joltber6,&joltber5,&joltber4,&joltber3,&joltber2,&joltber1,0);
        AbilityFind(&idRAGEVOLLEY,&volley17,&volley16,&volley15,&volley14,&volley13,&volley12,&volley11,&volley10,&volley9,&volley8,&volley7,&volley6,&volley5,&volley4,&volley3,&volley2,&volley1,0);
        AbilityFind(&idPROVOKE[1],&stunber16,&stunber15,&stunber14,&stunber13,&stunber12,&stunber11,&stunber10,&stunber9,&stunber8,&stunber7,&stunber6,&stunber5,&stunber4,&stunber3,&stunber2,&stunber1,0);
        AbilityFind(&idSTUN[1],&stunber16,&stunber15,&stunber14,&stunber13,&stunber12,&stunber11,&stunber10,&stunber9,&stunber8,&stunber7,&stunber6,&stunber5,&stunber4,&stunber3,&stunber2,&stunber1,0);
        AbilityFind(&idCRIPPLE,&cripple16,&cripple15,&cripple14,&cripple13,&cripple12,&cripple11,&cripple10,&cripple9,&cripple8,&cripple7,&cripple6,&cripple5,&cripple4,&cripple3,&cripple2,&cripple1,0);
        AbilityFind(&idCRYHAVOC,&cryhavoc,0);
        AbilityFind(&idSLAPFACE,&slapface3,&slapface2,&slapface1,0);
        AbilityFind(&idVIG,&vigber6,&vigber5,&vigber4,&vigber3,&vigber2,&vigber1,0);
        AbilityFind(&idOPFRENZY,&opfrenzy6,&opfrenzy5,&opfrenzy4,&opfrenzy3,&opfrenzy2,&opfrenzy1,0);
        AbilityFind(&idRALLOS,&rallos6,&rallos5,&rallos4,&rallos3,&rallos2,&rallos1,0);
        break;
    }

    if (GetPrivateProfileString(section, NULL, "", keys, sizeof(keys), INIFileName))
    {
        char* pKeys = keys;
        while (pKeys[0])
        {
            if (GetPrivateProfileString(section, pKeys, "", temp, sizeof(temp), INIFileName))
            {
                _strlwr(pKeys);
                if (ec != (c = CmdListe.find(pKeys)))      (*c).second.Setup(temp);
                else if (ei != (i = IniListe.find(pKeys))) (*i).second.Setup(temp);
            }
            pKeys += strlen(pKeys) + 1;
        }
    }

    Loaded = true;
}

void Exporting() {
    char output[MAX_STRING];
    char defval[MAX_STRING];
    Liste::iterator c,e;
    WritePrivateProfileString(section,NULL,NULL,INIFileName);
    e=CmdListe.end();
    for(c=CmdListe.begin(); c!=e; c++) {
        output[0]=0;
        if((*c).second.C)
            if(string *S=(string*)(*c).second.Value())
                strcpy(output,S->c_str());
        if((*c).second.A || (*c).second.V)
            if(long *V=(long*)(*c).second.Value())
                itoa(*V,output,10);
        if(output[0]) {
            strcpy(defval,(*c).second.D);
            if(defval[0]) ParseMacroData(defval);
            if(strcmp(output,"0") || strcmp(output,defval))
                WritePrivateProfileString(section,(*c).second.K,output,INIFileName);
        }
    }
    e=IniListe.end();
    for(c=IniListe.begin(); c!=e; c++) {
        output[0]=0;
        if((*c).second.C)
            if(string *S=(string*)(*c).second.Value())
                strcpy(output,S->c_str());
        if((*c).second.A || (*c).second.V)
            if(long *V=(long*)(*c).second.Value())
                itoa(*V,output,10);
        if(output[0]) {
            strcpy(defval,(*c).second.D);
            if(defval[0]) ParseMacroData(defval);
            if(strcmp(output,"0") || strcmp(output,defval))
                WritePrivateProfileString(section,(*c).second.K,output,INIFileName);
        }
    }
    sprintf(output,"%1.3f",PLUGIN_VERS); WritePrivateProfileString(section,"version",output,INIFileName);
}

void MapInsert(Liste *MyList, Option MyOption)
{
    MyList->insert(Liste::value_type(MyOption.K, MyOption));
}

void MeleeHelp()
{
    WriteChatf("%s::-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", PLUGIN_NAME);
    WriteChatf("%s::Version [\ag%1.3f\ax] Loaded!", PLUGIN_NAME, PLUGIN_VERS);
    WriteChatf("%s::-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", PLUGIN_NAME);
    for (Liste::iterator i=CmdListe.begin(); i != CmdListe.end(); i++) (*i).second.Write();
    WriteChatf("%s::-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", PLUGIN_NAME);
    if (NULL == PluginEntry("mq2cast", "CastCommand"))
    {
        WriteChatf("%s::Required Latest [\arMQ2Cast\ax] for AA/SPELL/ITEM casting.", PLUGIN_NAME);
    }
    if (NULL == PluginEntry("mq2moveutils", "StickCommand"))
    {
        WriteChatf("%s::Required Latest [\arMQ2MoveUtils\ax] for MOVEMENT.", PLUGIN_NAME);
    }
}

void PetSEEN()
{
    PetOnAttk = (unsigned long)clock() + 6000;
    PetOnHold = false;
}

void PetBACK()
{
    PetOnHold = true;
    if (doPETASSIST && pPetInfoWnd && PetButtonEnabled(UI_PetBack))
    {
        Announce(SHOW_CONTROL, "%s::Command [\ay%s\ax].", PLUGIN_NAME, "/pet back off");
        EzCommand("/pet back off");
    }
}

void PetATTK()
{
    PetSEEN();
    if (doPETASSIST && pPetInfoWnd && !(onEVENT&0x0003) && MeleeTarg && PetButtonEnabled(UI_PetAttk))
    {
        Announce(SHOW_CONTROL,"%s::Command [\ay%s\ax].",PLUGIN_NAME,"/pet attack");
        if (!TargetID(MeleeTarg))
        {
            PSPAWNINFO Current = Target();
            TargetIT(GetSpawnID(MeleeTarg));
            EzCommand("/pet attack");
            if (Current) Command("/squelch /target id %d", Current->SpawnID);
        }
        else
        {
            EzCommand("/pet attack");
        }
        PetTarget = MeleeTarg;
    }
}

void StickReset(void)
{
    TimerStik = 0;
    if (Sticking) Stick("");
    StickArg[0] = 0;
    onSTICK = (doMELEE && !(onEVENT&0x8000) && (doSTICKRANGE || doSTICKNORANGE) && bMULoaded); // x && x && !ranged && moveutils_loaded
}

void RangeReset()
{
    if (!doRANGE && AutoFire) EzCommand("/autofire");
    if (!doRANGE && (onEVENT&0x8000)) onEVENT&=0x7FFF;
}

void OtherReset()
{
    MeleeTarg = 0;
    MeleeType = 0;
    MeleeLife = 0;
    MeleeCast = 0;
    MeleeFlee = 0;
    TimerBack = 0;
    TimerLife = 0;
    TimerFace = 0;
    TimerStun = 0;
    PetTarget = 0;
    PetOnWait = 0;
    SwingHits = 0;
    TakenHits = 0;
    onEVENT   = 0;
    doDOWN    = 0;
    doHOLY    = 0;
}

void MeleeReset()
{
    if (!doMELEE && *EQADDR_ATTACK)
    {
        AttackOFF();
        StickReset();
    }
}

void AggroReset()
{
    int onAGGRO    = (doAGGRO && IsGrouped());
    onCHALLENGEFOR = (onAGGRO && idCHALLENGEFOR.Found());
    onBELOW        = (onAGGRO && doPROVOKEMAX) ? doPROVOKEMAX : 0;

    if (doMELEE)
    {
        if (long PW = (IsGrouped() && doAGGRO) ? elAGGROPRI : elMELEEPRI) Equip(PW, inv_primary);
        if (long SW = (IsGrouped() && doAGGRO) ? elAGGROSEC : elMELEESEC) Equip(SW, inv_secondary);
    }
}

void SneakOFF() {
    if(IsSneaking() && idSNEAK.Found()) idSNEAK.Press();
}

void HideOFF() {
    if(IsInvisible() && idHIDE.Found()) idHIDE.Press();
}

int StabCheck()
{
    if (elPOKER && OkayToEquip(Giant))
    {
        char szTempItem[25] = {0};
        sprintf(szTempItem, "%d", elPOKER);
        CItemLocation cFindItem;
        if (ItemFind(&cFindItem, szTempItem))
        {
            if (PokerType(cFindItem.pBagSlot)) return true;
        }
    }
    return PokerType(ContPrimary());
}

void StabPress() {
    long saveid=0;
    CItemLocation cMoveItem;
    char szTempItem[25] = {0};
    sprintf(szTempItem, "%d", elPOKER);
   if(elPOKER && OkayToEquip(Giant) && ItemFind(&cMoveItem, szTempItem))
   {
        if(PCONTENTS pri=ContPrimary())
            if(pri->Item->ItemNumber!=elPOKER) {
                saveid=pri->Item->ItemNumber;
                Equip(elPOKER,inv_primary);
            }
    }
    if(PokerType(ContPrimary())) {
        idBACKSTAB.Press();
        SwingHits++;
    }
    if(saveid) Equip(saveid,inv_primary);
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

PLUGIN_API void ThrowIT(PSPAWNINFO pChar, char* Cmd) {
    if(gbRangedAttackReady && pTarget && TargetType(NPC_TYPE) &&
        !InRange(SpawnMe(),(PSPAWNINFO)pTarget,35) &&
        fabs(AngularHeading(SpawnMe(),(PSPAWNINFO)pTarget))<50 &&
        LineOfSight(SpawnMe(),(PSPAWNINFO)pTarget)) {

            unsigned long ulSlot = 0;
            char szTempItem[25] = {0};
            CItemLocation cMoveItem;

            // test if we could do ranged with current ammo/range configuration
            long crT=99; long crI=0; long caT=99; long caI=0; long caQ=0;
            if(PCONTENTS r=ContRange()) {
                crI=r->Item->ItemNumber;
                crT=r->Item->ItemType;
            }
            if(PCONTENTS a=ContAmmo()) {
                caI=a->Item->ItemNumber;
                caT=a->Item->ItemType;
                if(caT == 7 || caT == 19 || caT == 27) caQ=CountItemByID(caI);
            }
            if(!(caI && ((caT == 27 && crT == 5) || (caI == crI && (caT == 7 || caT == 19))))) {
                if(!OkayToEquip(Giant)) return;

                // grab information about user defined range/ammunition
                long erT=99; long eaT=99; long eaQ=0;

                PCONTENTS r = NULL;
                PCONTENTS a = NULL;

                //if(PCONTENTS r=ItemLocate(elRANGED)) erT=r->Item->ItemType;
                sprintf(szTempItem, "%d", elRANGED);
                if (ItemFind(&cMoveItem, szTempItem))
                {
                    r = cMoveItem.pBagSlot;
                    erT = r->Item->ItemType;
                }

                //if(PCONTENTS a=ItemLocate(elARROWS)) {
                //    eaT=a->Item->ItemType;
                //    if(eaT == 7 || eaT == 19 || eaT == 27) eaQ=ItemCounts(elARROWS);
                //}
                sprintf(szTempItem, "%d", elARROWS);
                if (ItemFind(&cMoveItem, szTempItem))
                {
                    a = cMoveItem.pBagSlot;
                    eaT = a->Item->ItemType;
                    if(eaT == 7 || eaT == 19 || eaT == 27) eaQ=CountItemByID(elARROWS);
                }


                // find equipping scenario (bow+arrow) or (throw/throw).
                long EquipRangeID=0; long EquipArrowID=0;
                if((crT == 5 || erT == 5) && (caT == 27 || eaT == 27)) {
                    EquipRangeID=(crT== 5)?crI:elRANGED;
                    EquipArrowID=(caT==27)?caI:elARROWS;
                }
                else if((caQ > 2 && (caT == 7 || caT == 19)) || (eaQ > 2 && (eaT == 7 || eaT == 19)))
                {
                    EquipRangeID=(caQ>2 &&(caT==7 || caT==19))?caI:elARROWS;
                    EquipArrowID=(caQ>2 &&(caT==7 || caT==19))?caI:elARROWS;
                }
                else return;

                // load equipping scenario found!
                if(EquipRangeID && EquipArrowID) {
                    if(crI!=EquipRangeID) Equip(EquipRangeID,inv_range);
                    if(caI!=EquipArrowID) Equip(EquipArrowID,inv_ammo);
                    if(EquipArrowID==EquipRangeID && !ContRange()) {
                        sprintf(szTempItem, "InvSlot%d", SlotFind("ammo"));
                        SendWornClick(szTempItem, CTRLKEY); // pick one from ammo
                        sprintf(szTempItem, "InvSlot%d", SlotFind("ranged"));
                        SendWornClick(szTempItem, SHIFTKEY); // fill one in range
                    }
                }
            }

            // more sanity double check in case we didnt exchange stuff
            PCONTENTS rSlot=ContRange();  if(!rSlot) return;
            PCONTENTS aSlot=ContAmmo();   if(!aSlot) return;
            long rType=rSlot->Item->ItemType; if(!(rType == 5 || rType == 7  || rType == 19)) return;
            long aType=aSlot->Item->ItemType; if(!(aType == 7 || aType == 19 || aType == 27)) return;
            long aKind=aSlot->Item->ItemNumber; long rKind=rSlot->Item->ItemNumber;
            if(!((aType == 27 && rType == 5) || (aType!=27 && rKind == aKind))) return;

            // good time to reload ammunitions?
            if(OkayToEquip()) {
               while(aSlot->StackCount < 80 && CountItemByID(aKind, BAG_SLOT_START)>0)
               {
                   sprintf(szTempItem, "%d", aKind);
                   if (!ItemFind(&cMoveItem, szTempItem, BAG_SLOT_START)) break; // find pack slot of item
                   //ItemLocate(aKind,BAG_SLOT_START);
                   SendInvClick(cMoveItem.pEQInvSlot, SHIFTKEY); // click on found slot to pick up stack
                    //pInvSlotMgr->MoveItem(InvSlot,NUM_INV_SLOTS,1,1,0,0);
                   sprintf(szTempItem, "InvSlot%d", SlotFind("ammo"));
                   SendWornClick(szTempItem, SHIFTKEY); // place that stack on the ammo slot
                    //WinClick((CXWnd*)pInventoryWnd,"InvSlot22","leftmouseup",Shiftkey);
                    //if(!CursorEmpty()) pInvSlotMgr->MoveItem(NUM_INV_SLOTS,InvSlot,1,1,0,0);
                   if (!CursorEmpty()) SendInvClick(cMoveItem.pEQInvSlot, SHIFTKEY); // place any remaining ammo back into slot
                } 
                if(aType != 27 && aKind == rKind) {
                   while(rSlot->StackCount < 80 && CountItemByID(aKind, BAG_SLOT_START)>0)
                   {
                       sprintf(szTempItem, "%d", aKind);
                       if (!ItemFind(&cMoveItem, szTempItem, BAG_SLOT_START)) break; // find pack slot of item
                        //ItemLocate(aKind,BAG_SLOT_START);
                       SendInvClick(cMoveItem.pEQInvSlot, SHIFTKEY); // click on found slot to pick up stack
                        //pInvSlotMgr->MoveItem(InvSlot,NUM_INV_SLOTS,1,1,0,0);
                        //WinClick((CXWnd*)pInventoryWnd,"InvSlot22","leftmouseup",Shiftkey);
                        //WinClick((CXWnd*)pInventoryWnd,"InvSlot11","leftmouseup",Shiftkey);
                       sprintf(szTempItem, "InvSlot%d", SlotFind("ammo"));
                       SendWornClick(szTempItem, SHIFTKEY); // place that stack on the ammo slot
                       sprintf(szTempItem, "InvSlot%d", SlotFind("ranged"));
                       SendWornClick(szTempItem, SHIFTKEY); // place that stack on the ranged slot
                        //if(!CursorEmpty()) pInvSlotMgr->MoveItem(NUM_INV_SLOTS,InvSlot,1,1,0,0);
                       if (!CursorEmpty()) SendInvClick(cMoveItem.pEQInvSlot, SHIFTKEY); // place any remaining ammo back into slot
                    } 
                }
            }

            // fire ranged attack if NPC on Target still in range and preserve the range slot.
            do_ranged(SpawnMe(),"");
            if(crI) if(rKind!=crI) if(OkayToEquip()) Equip(crI,inv_range);
    }
}

PLUGIN_API void Override(PSPAWNINFO pChar, char* Cmd)
{
    Announce(SHOW_OVERRIDE, Cmd, PLUGIN_NAME);
    MeleeTime = (unsigned long)clock() + delay;
    AttackOFF();
    if(AutoFire)
    {
        AutoFire = false;
        EzCommand("/autofire");
    }
    PetBACK();
    StickReset();
    OtherReset();
}

PLUGIN_API void Melee(PSPAWNINFO pChar, char* Cmd)
{
    char Tmp[MAX_STRING]; char Var[MAX_STRING]; char Set[MAX_STRING]; BYTE Parm=1; bool Help=true;
    Liste::iterator c; Liste::iterator ec=CmdListe.end();
    do {
        GetArg(Tmp,Cmd,Parm++); _strlwr(Tmp);
        GetArg(Var,Tmp,1,FALSE,FALSE,FALSE,'=');
        GetArg(Set,Tmp,2,FALSE,FALSE,FALSE,'=');
        if(Var[0]) {
            c=CmdListe.find(Var);
            if(ec!=c) {
                (*c).second.Setup(Set);
                (*c).second.Write();
                Help=false;
            } else if(!Set[0] && (!stricmp(Var,"on") || !stricmp(Var,"off"))) {
                if(ec!=(c=CmdListe.find("plugin"))) (*c).second.Setup(Var);
                Help=false;
            } else if(!Set[0] && (!stricmp(Var,"reload") || !stricmp(Var,"load"))) {
                WriteChatf("%s::Loading...",PLUGIN_NAME);
                Configure();
                Help=false;
            } else if(!Set[0] && !stricmp(Var,"save")) {
                WriteChatf("%s::Saving...",PLUGIN_NAME);
                Exporting();
                Help=false;
            } else if(!Set[0] && !stricmp(Var,"key")) {
                char buffer[MAX_STRING]; KeyCombo combo;
                DescribeKeyCombo(pKeypressHandler->NormalKey[FindMappableCommand("AUTOPRIM")],buffer);
                WriteChatf("%s::\ayATTACK\ax binded to [\ay%s\ax]",PLUGIN_NAME,buffer);
                GetMQ2KeyBind("MELEE",false,combo);
                DescribeKeyCombo(combo,buffer);
                WriteChatf("%s::\ayMELEE\ax  binded to [\ay%s\ax]",PLUGIN_NAME,buffer);
                GetMQ2KeyBind("RANGE",false,combo);
                DescribeKeyCombo(combo,buffer);
                WriteChatf("%s::\ayRANGE\ax  binded to [\ay%s\ax]",PLUGIN_NAME,buffer);
                Help=false;
            } else if(!Set[0] && !stricmp(Var,"reset")) {
                Override(NULL,"%s::Resetting...");
                Help=false;
            } else {
                WriteChatf("%s::Unsupported Argument <\ar%s\ax>",PLUGIN_NAME,Var);
                break;
            }
        }
    } while(strlen(Tmp));
    if(Help) MeleeHelp();
}

PLUGIN_API void KillThis(PSPAWNINFO pChar, char* Cmd)
{
    if (doSKILL && pTarget && !TargetID(MeleeTarg) && TargetType(NPC_TYPE) && InGame())
    {
        if (IsFeigning()) EzCommand("/stand");
        StickReset();
        OtherReset();
        AggroReset();
        MeleeTarg = ((PSPAWNINFO)pTarget)->SpawnID;
        strcpy(MeleeName,((PSPAWNINFO)pTarget)->DisplayedName);
        MeleeSize = strlen(MeleeName)+1;
        MeleeType = SpawnMask((PSPAWNINFO)pTarget);
        onEVENT|=0x0008;
        Announce(SHOW_ATTACKING,"%s::Attacking [\ay%s\ax].",PLUGIN_NAME,MeleeName);
    }
}

PLUGIN_API void EnrageON(PSPAWNINFO pChar, char* Cmd) {
    if(long val=atol(Cmd)) if(val!=MeleeTarg) return;
    if(doSKILL && doENRAGE && MeleeTarg && InGame()) {
        PSPAWNINFO KillTarg=GetSpawnID(MeleeTarg);
        if(!(onEVENT&0x0001)) {
            if(!(onEVENT&0x0002)) PetBACK();
            onEVENT|=0x0001;
            Announce(SHOW_ENRAGING,"MQ2Melee::\arENRAGE\ax detected, taking action!");
        }
        if(*EQADDR_ATTACK && onEVENT&0x0003 && SpawnType(KillTarg,NPC_TYPE)) {
            double Back=fabs(AngularDistance(KillTarg->Heading,SpawnMe()->Heading));
            double View=fabs(AngularHeading(SpawnMe(),KillTarg));
            if(Back > 92 || View > 60 || onEVENT&0x0002) {
                onEVENT|=0x0008;
                AttackOFF();
            }
        }
    }
}

PLUGIN_API void EnrageOFF(PSPAWNINFO pChar, char* Cmd) {
    if(long val=atol(Cmd)) if(val!=MeleeTarg) return;
    if(doSKILL && doENRAGE && MeleeTarg && onEVENT&0x0001 && InGame()) {
        onEVENT&=0xFFFE;
        if(TargetID(PetTarget)) PetATTK();
        Announce(SHOW_ENRAGING,"MQ2Melee:: \agENRAGE\ax ended, taking action!");
    }
}

PLUGIN_API void InfuriateON(PSPAWNINFO pChar, char* Cmd) {
    if(long val=atol(Cmd)) if(val!=MeleeTarg) return;
    if(doSKILL && doINFURIATE && MeleeTarg && InGame()) {
        if(!(onEVENT&0x0002)) {
            if(!(onEVENT&0x0001)) PetBACK();
            onEVENT|=0x0002;
            Announce(SHOW_ENRAGING,"MQ2Melee::\arINFURIATE\ax detected, taking action!");
        }
        if(*EQADDR_ATTACK) {
            AttackOFF();
            onEVENT|=0x0008;
        }
    }
}

PLUGIN_API void InfuriateOFF(PSPAWNINFO pChar, char* Cmd) {
    if(long val=atol(Cmd)) if(val!=MeleeTarg) return;
    if(doSKILL && doINFURIATE && MeleeTarg && onEVENT&0x0002 && InGame()) {
        onEVENT&=0xFFFD;
        if(TargetID(PetTarget)) PetATTK();
        Announce(SHOW_ENRAGING,"MQ2Melee:\agINFURIATE\ax ended, taking action!");
    }
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

void DowntimeHandle()
{
    if(doSENSETRAP && idSENSETRAP.Ready(ifSENSETRAP)) idSENSETRAP.Press();
    if(!MeleeTarg && (unsigned long)clock()>TimerAttk && Immobile) {
        if(doDOWNFLAG[doDOWN] && DOWNSHIT[doDOWN].size()) EzCommand((char*)DOWNSHIT[doDOWN].c_str());
        for(long x=1; x<16; x++) {
            long n=(x+doDOWN)&15;
            if(doDOWNFLAG[n]) {
                doDOWN=n;
                break;
            }
        }
        if (doFORAGE && idFORAGE.Ready(ifFORAGE))
        {
            idFORAGE.Press();
        }
        else if (doSNEAK && !IsSneaking() && idSNEAK.Ready(ifSNEAK))
        {
            idSNEAK.Press();
        }
        else if (doHIDE && !IsInvisible() && idHIDE.Ready(ifHIDE))
        {
            idHIDE.Press();
        }
    }
}

void MeleeHandle()
{
    // check opened windows that wont let us perform any melee actions.
    if(!BardClass  && WinState((CXWnd*)pCastingWnd))  return;
    if(WinState((CXWnd*)pSpellBookWnd))               return;
    if(WinState((CXWnd*)pLootWnd))                    return;
    if(WinState((CXWnd*)pBankWnd))                    return;
    if(WinState((CXWnd*)pMerchantWnd))                return;
    if(WinState((CXWnd*)pTradeWnd))                   return;
    if(WinState((CXWnd*)pGiveWnd))                    return;
    Silenced=false;

    // check detrimental buff that wont let ya perform melee actions.
    for(int b=0; b<BuffMax; b++) {
        long SpellID=GetCharInfo2()->Buff[b].SpellID;
        if(SpellID<1) continue;
        if(PSPELL spell=GetSpellByID(SpellID))
            for(int a=0; a<12; a++) switch(spell->Attrib[a]) {
        case 22: return;        // charmed
        case 23: return;        // feared
        case 31: return;        // mesmerized
        case 40: return;        // invulnerable
        case 96: Silenced=true; // silenced
            }
    }

    // check detrimental song that wont let ya perform melee actions.
    for(int s=0; s<SongMax; s++) {
        long SpellID=GetCharInfo2()->ShortBuff[s].SpellID;
        if(SpellID<1) continue;
        if(PSPELL spell=GetSpellByID(SpellID))
            for(int a=0; a<12; a++) switch(spell->Attrib[a]) {
        case 22: return;        // charmed
        case 23: return;        // feared
        case 31: return;        // mesmerized
        case 40: return;        // invulnerable
        case 96: Silenced=true; // silenced
            }
    }

    // check our health and perform some healing action if we can
    if((Health=GetCurHPS()*100/GetMaxHPS())<100) {
        Ability *UseThis=NULL;
        if(doMEND && Health<=doMEND && idMEND.Ready(ifMEND))                  UseThis=&idMEND;
        else if(doLAYHAND && Health<=doLAYHAND && idLAYHAND.Ready(ifLAYHAND)) UseThis=&idLAYHAND;
        else if(doPOTHEALFAST && Health<=doPOTHEALFAST && idPOTHEALFAST.Ready(ifPOTHEALFAST)) UseThis=&idPOTHEALFAST;
        else if(doPOTHEALOVER && Health<=doPOTHEALOVER && idPOTHEALOVER.Ready(ifPOTHEALOVER)) UseThis=&idPOTHEALOVER;
        if(UseThis) {
            if(UseThis->ID == idLAYHAND.ID) {
                PSPAWNINFO TargetSave=pTarget?(PSPAWNINFO)pTarget:NULL;
                *(PSPAWNINFO*)ppTarget=SpawnMe();
                idLAYHAND.Press();
                *(PSPAWNINFO*)ppTarget=TargetSave;
            } else UseThis->Press();
        }
    }

    // check if we are stunned, if so we can't perform any melee actions
    if (IsStunned()) return;

    // check if we still have a killing target or we acquiring a new one
    if ((pTarget && TargetType(NPC_TYPE)) && (*EQADDR_ATTACK || onEVENT&0x8000))
    {
        if (!MeleeTarg)
        {
            KillThis(NULL, "");
        }
        else if (!TargetID(MeleeTarg))
        {
            Override(NULL,"%s::\arTARGET SWITCH\ax taking actions.");
            return;
        }
        TimerAttk = (unsigned long)clock()+delay*12;
    }
    if (MeleeTarg)
    {
        if (PSPAWNINFO Tar = GetSpawnID(MeleeTarg))
        {
            if (!MeleeLife || Tar->HPCurrent < MeleeLife) TimerLife = (unsigned long)clock() + 1500;
            MeleeLife = Tar->HPCurrent;
        }
    }

    // check if we should standup from an interrupted feign death
    if(BrokenFD && (unsigned long)clock()>BrokenFD) {
        BrokenFD=false;
        if(IsFeigning()) {
            Announce(SHOW_FEIGN,"%s::\arFAILED FEIGN DEATH\ax taking action!",PLUGIN_NAME);
            EzCommand("/stand");
            return;
        }
    }

    // check it's a good time to perform some downtime actions?
    if(!IsCasting()) DowntimeHandle();

    // check it's a good time to drop combat?
    Ability *FeignDeath=NULL;
    if(idFEIGN[0].Ready(""))      FeignDeath=&idFEIGN[0];
    else if(idFEIGN[1].Ready("")) FeignDeath=&idFEIGN[1];
    Health=GetCurHPS()*100/GetMaxHPS();
    if(!doAGGRO && !(onEVENT&0x0FF0) && !IsFeigning() && !IsInvisible()) {
        bool fTime=(doFEIGNDEATH && Health<=doFEIGNDEATH && FeignDeath);
        bool eTime=(doESCAPE     && Health<=doESCAPE     && idESCAPE.Ready(""));
        bool bTime=(doBACKOFF    && Health<=doBACKOFF);

        if(fTime || eTime || bTime) {
            if(*EQADDR_ATTACK) {
                onEVENT|=0x0008;
                AttackOFF();
            } else {
                if(fTime)      onEVENT|=0x0040;
                else if(eTime) onEVENT|=0x0020;
                else if(bTime) onEVENT|=0x0010;
                if(onEVENT&0x0020)      idESCAPE.Press();
                else if(onEVENT&0x0040) FeignDeath->Press();
            }
            return;
        }
    }

    // check it's a good time to resume combat?
    if((IsFeigning() || IsInvisible() || onEVENT&0x0FF0) && !(onEVENT&0x4000))
    {
        if(!TimerBack) TimerBack=(unsigned long)clock()+delay;
        else if((unsigned long)clock()>TimerBack && (doAGGRO || (onEVENT&0x0FF0 && Health>doRESUME)))
        {
            if((IsInvisible() || onEVENT&0x0220) && (!IsInvisible() || !(onEVENT&0x0020))) onEVENT&=0xFDDF;
            if((IsFeigning()  || onEVENT&0x0440) && (!IsFeigning() || (IsFeigning() && doSTAND)))
            {
                onEVENT&=0xFBBF;
                EzCommand("/stand");
                StickReset();
                return;
            }
            onEVENT&=0xF99F;
            TimerBack=false;
        }
    }
    // end resume

    // time to handle dummy pet, check mending, check we have target in range, etc...
    if (doPETASSIST && MeleeTarg )
    {
        PSPAWNINFO Pet=SpawnPet();
        PSPAWNINFO Tar=GetSpawnID(MeleeTarg);
        if ( Pet && Tar )
        {
            if ( doPETMEND && Pet->HPCurrent<=doPETMEND && idPETMEND.Ready("") ) idPETMEND.Press();
            PetInDist=( !doPETRANGE || InRange(Pet,Tar,(FLOAT)doPETRANGE) );
            if ( !PetOnWait && PetInDist ) PetOnWait=(unsigned long)clock()+doPETDELAY*1000;
            if ( PetOnWait && (unsigned long)clock()>PetOnWait && PetInDist )
            {
                if ( (unsigned long)clock()>TimerLife || !IdlingArray[Tar->Animation & 0xFF] )
                {
                    if ( (unsigned long)clock()>PetOnAttk ) PetATTK();
                }
            }
        }
    }
    // end pet

    // hold on?
    if(!MeleeTarg || !TargetID(MeleeTarg) || !IsStanding() || onEVENT&0x0FF2) // this event is never referenced elsewhere
    {
        if(*EQADDR_ATTACK) AttackOFF();
        return;
    }

    // target is in range? could we engage and kill it?  
    // ***** hard-coded override if we are more than 250 away  ****
    if((MeleeDist = DistanceToSpawn(SpawnMe(), (PSPAWNINFO)pTarget)) > 250)
    {
        Override(NULL, "");
        return;
    }
    // end 250 range enforce

    MeleeSpeed = fabs(FindSpeed((PSPAWNINFO)pTarget));
    MeleeBack  = fabs(AngularDistance(((PSPAWNINFO)pTarget)->Heading,SpawnMe()->Heading));
    MeleeView  = fabs(AngularHeading(SpawnMe(),(PSPAWNINFO)pTarget));
    MeleeFlee  = (MeleeFlee || (MeleeLife<=85 && MeleeSpeed>25.0f && IsMobFleeing(SpawnMe(),(PSPAWNINFO)pTarget)));
    MeleeKill  = ((PSPAWNINFO)pTarget)->AvatarHeight+12.0f;
    //Sticking=Evaluate("$If[$Stick.Active},1,0]}");
    if (bMULoaded && bMUPointers) Sticking = *pbStickOn;

    // are we discing? if so time to promote some actions?
    long disc = Discipline();
    if(disc && !(onEVENT&0x7007)) switch(disc)
    {
    case d_ashenhand:      // Ashenhand Discipline?
        if(doMELEE && MeleeDist<MeleeKill && idEAGLESTRIKE.Ready("")) idEAGLESTRIKE.Press(); break;
    case d_silentfist:     // Silentfist Discipline?
        if(doMELEE && MeleeDist<MeleeKill && idDRAGONPUNCH.Ready("")) idDRAGONPUNCH.Press(); break;
    case d_thunderkick:    // Thunderkick Discipline?
    case d_heelofkanji:    // Heel of Kanji?
        if(doMELEE && MeleeDist<MeleeKill && idFLYINGKICK.Ready("")) idFLYINGKICK.Press(); break;
    case d_assassin1:
    case d_assassin2:
    case d_assassin3:
        if(doMELEE && MeleeDist<MeleeKill && MeleeView<60 && MeleeBack<doSTAB && idBACKSTAB.Ready("") && StabCheck()) StabPress(); break;
    }

    // scripted rogue sequence striking/assasination codes
    if(doASSASINATE && doBACKSTAB && doMELEE && onSTICK>0 && !SwingHits && !TakenHits && MeleeSpeed<2.0f && !*EQADDR_ATTACK && StabCheck())
    {
        if(!Moving && Immobile)
        {
            if(!IsSneaking() && idSNEAK.Ready("")) idSNEAK.Press();
            if(!IsInvisible() && idHIDE.Ready("")) idHIDE.Press();
            if(IsSneaking() && TimeSince(SilentTimer)>1000 && IsInvisible() && TimeSince(HiddenTimer)>1000)
            {
                if (doSTRIKEMODE)    /// strikemode = 1
                {
                    strcpy(Reserved,StrikeCMD.c_str()); // copy our strike ini command to Reserved
                    ParseMacroData(Reserved); // parse out TLO evaluations
                }
                else   // strikemode not set
                {
                    if(doSTAB>191) sprintf(Reserved,"%2.2f id %d !front"    ,MeleeKill-3.0f,MeleeTarg);
                    else           sprintf(Reserved,"%2.2f id %d behindonce",MeleeKill-3.0f,MeleeTarg);
                }
                if(!Sticking && strcmp(Reserved,StickArg))
                {
                    Stick(Reserved);
                    return;
                }
                if(MeleeDist>MeleeKill || MeleeView>60 || MeleeBack>doSTAB)
                {
                    SwingHits++;
                }
                else if(idBACKSTAB.Ready("") && TimeSince(HiddenTimer)>3000)
                {
                    if (Sticking) Stick("");
                    if (doSTRIKE && idSTRIKE.Ready(ifSTRIKE)) idSTRIKE.Press();
                    else StabPress();
                }
            }
        }
        if(Sticking && (SwingHits || TakenHits || !IsSneaking() || !IsInvisible())) Stick("");
        return;
    }
    // end rogue striking/assasination

    // jolting times!
    if(doJOLT && !doAGGRO && SwingHits>doJOLT && idJOLT.Ready(ifJOLT))
    {
        idJOLT.Press();
        SwingHits=1;
    }
    //end jolt

    // handle melee
    if(doMELEE && !(onEVENT&0x8000))
    {
        if(onEVENT&0x0008 && !(onEVENT&0xF007) && !*EQADDR_ATTACK) AttackON();

        // start stick processing
        if(onSTICK)      // would have value if StickReset called, or set by itself
        {
            if(onSTICK > 0) // value would be positive from StickReset
            {
                // if no timer (set here) -- if (no range set or distance to target less than stick range, set timer
                if(!TimerStik) if(!doSTICKRANGE || doSTICKNORANGE || MeleeDist<doSTICKRANGE) TimerStik=(unsigned long)clock()+doSTICKDELAY*1000;
                // if not moving and not sticking and (no delay or timer is up) and no range set or distance to target less than stick range
                // set onstick negative so below if is processed
                // *** if a range is set and we are greater than this range, this may cause those "open space" problems
                if(Immobile && !Sticking && (!doSTICKDELAY || (unsigned long)clock()>TimerStik) && (!doSTICKRANGE || doSTICKNORANGE || MeleeDist<doSTICKRANGE)) onSTICK=-1;
            }
            if(onSTICK<0)        // set negative by above in cases where we should stick
            {
                if(doSTICKMODE)        // if we have a custom stick command, use this
                {
                    strcpy(Reserved,StickCMD.c_str()); // copy our ini command to Reserved
                    ParseMacroData(Reserved);          // parse out TLO evaluations
                }
                else       // else melee decides how to process stick as follows
                {
                    long type=Aggroed(MeleeTarg); // set to 1 if cases acceptable to attack (on hott, within range)
                    bool swim=(SpawnMe()->UnderWater==5); // use "uw" arg if underwater
                    bool stab=(type<1 && doBACKSTAB && doSTAB<192); // use "behind" if not aggro and strike option enabled, else !front
                    bool tank=(type>0 || (!IsInvisible() && (doAGGRO || !GetCharInfo()->pGroupInfo))); // use "moveback" if tank and aggro, else process stab
                    double dist=MeleeKill-3.0f-(MeleeFlee*3.0f); // stick numeric parameter for distance
                    sprintf(Reserved,"%2.2f id %d%s%s", dist, MeleeTarg, MeleeFlee ? "" : (tank ? " moveback" : (!stab ? " !front" : " behind")), swim ? " uw" : "");
                }
                //if(strcmp(Reserved,StickArg)) Stick(Reserved); // issue command if its not the same as the last issued (stickarg set to last arg given to Stick()??
                // most likely because if we are sticking and want to change the type of stick we issue, but this will fail if stick got
                // shut off and the arg never reset properly, so lets check also if we are not sticking by checking moveutils actual status
                if (bMULoaded && bMUPointers)  // if moveutils is loaded
                {
                    if (strcmp(Reserved, StickArg) || (!doSTICKBREAK && !*pbStickOn)) Stick(Reserved);
                }
            }
        }
        // end stick processing

        // not behind enraged/infuriated target?
        if(onEVENT&0x0003 && *EQADDR_ATTACK)
        {
            if(MeleeBack > 92 || onEVENT&0x0002)
            {
                if(MeleeBack > 92) Announce(SHOW_ENRAGING,"%s::\arNOT BEHIND\ax enraged target, taking action!",PLUGIN_NAME);
                onEVENT|=0x0008;
                AttackOFF();
                return;
            }
        }

        // check target is in melee range?
        if(MeleeDist<MeleeKill)
        {
            // attack is off, good time for stealing/begging or evading?
            if(!*EQADDR_ATTACK)
            {
                onEVENT&=0xBFFF;
                if(!MeleeFlee)
                {
                    if(doPICKPOCKET && idPICKPOCKET.Ready(ifPICKPOCKET))
                    {
                        idPICKPOCKET.Press();
                        onEVENT|=0x1008;
                    }
                    else if(doBEGGING && !IsInvisible() && idBEGGING.Ready(ifBEGGING))
                    {
                        idBEGGING.Press();
                        onEVENT|=0x2008;
                    }
                    if(doEVADE && !doAGGRO && Immobile && !IsInvisible() && idHIDE.Ready(ifEVADE))
                    {
                        idHIDE.Press();
                        onEVENT|=0x0208;
                    }
                    else if(doFALLS && !doAGGRO && FeignDeath->Ready(ifFALLS))
                    {
                        FeignDeath->Press();
                        onEVENT|=0x0408;
                    }
                }
                if(onEVENT&0x0001 && !(onEVENT&0xFFF6) && MeleeBack<92)
                {
                    Announce(SHOW_ENRAGING,"%s::\agBEHIND\ax TARGET kicking attack ON!!!",PLUGIN_NAME);
                    onEVENT&=0xFFF6; AttackON(); onEVENT|=0x0009;
                }
            }
            else   // attack is on so lets do some dps?
            {
                if(doBACKSTAB && MeleeBack<doSTAB && MeleeView<60 && idBACKSTAB.Ready(ifBACKSTAB) && StabCheck()) StabPress();
                if(doFLYINGKICK && idFLYINGKICK.Ready(ifFLYINGKICK)) idFLYINGKICK.Press();
                if(doDRAGONPUNCH && idDRAGONPUNCH.Ready(ifDRAGONPUNCH)) idDRAGONPUNCH.Press();
                if(doEAGLESTRIKE && idEAGLESTRIKE.Ready(ifEAGLESTRIKE)) idEAGLESTRIKE.Press();
                if(doTIGERCLAW && idTIGERCLAW.Ready(ifTIGERCLAW)) idTIGERCLAW.Press();
                if(doROUNDKICK && idROUNDKICK.Ready(ifROUNDKICK)) idROUNDKICK.Press();
                if(doBASH && idBASH.Ready(ifBASH) && BashCheck()) BashPress();
                if(doSLAM && idSLAM.Ready(ifSLAM)) idSLAM.Press();
                if(doFRENZY && idFRENZY.Ready(ifFRENZY)) idFRENZY.Press();
                if(doKICK && idKICK.Ready(ifKICK)) idKICK.Press();
                if(!disc && Immobile && !IsInvisible() && !MeleeFlee)
                {
                    if(doPICKPOCKET   && idPICKPOCKET.Ready(ifPICKPOCKET))                    onEVENT|=0x4008;
                    if(doBEGGING      && idBEGGING.Ready(ifBEGGING))                          onEVENT|=0x4008;
                    if(doFALLS        && !doAGGRO && FeignDeath->Ready(ifFALLS))              onEVENT|=0x4008;
                    if(doEVADE        && !(doAGGRO || !IsGrouped()) && idHIDE.Ready(ifEVADE)) onEVENT|=0x4008;
                    if(onEVENT&0x4000 && *EQADDR_ATTACK) AttackOFF();
                }

                if(MeleeDist < 15)
                {
                    if(doDISARM && idDISARM.Ready(ifDISARM)) idDISARM.Press();
                }
            }
            if(doINTIMIDATION && idINTIMIDATION.Ready(ifINTIMIDATION)) idINTIMIDATION.Press();
            if(doTAUNT && doAGGRO && idTAUNT.Ready(ifTAUNT)) idTAUNT.Press();
        }
        //end target is in range

        if(MeleeFlee) SneakOFF();
        if(onEVENT&0x3000) onEVENT&=0xCFFF;
    }
    // end handle melee

    // handle ranged?
    if(doRANGE || onEVENT&0x8000)
    {
        // should we face target? not moving, stopped >2sec, facing>2sec and not sticking?
        if(doFACING && Immobile && (unsigned long)clock()>TimerFace && !Sticking)
        {
            if(MeleeView>30) Face(SpawnMe(),"");
            TimerFace=(unsigned long)clock()+delay*8;
        }
        // are we in good ranged for ranged?
        if(MeleeDist<(doRANGE?doRANGE:250) && MeleeDist>35 && MeleeDist>MeleeKill+20)
        {
            if(!AutoFire && gbRangedAttackReady) ThrowIT(NULL,"");
            if(*EQADDR_ATTACK)
            {
                if(Sticking) Stick("");
                onEVENT|=0x8000;
                AttackOFF();
                Announce(SHOW_SWITCHING,"%s::Switching [\ayRange\ax].",PLUGIN_NAME);
            }
        }
        else if(!*EQADDR_ATTACK) // target too close? or too far?
        {
            if(AutoFire)
            {
                EzCommand("/autofire");
                AutoFire=false;
            }
            if(Immobile && onEVENT&0x8000)
            {
                onEVENT&=0x7FF7;
                if(doMELEE)
                {
                    StickReset();
                    onEVENT|=0x0008;
                    AttackON();
                    Announce(SHOW_SWITCHING,"%s::Switching [\ayMelee\ax].",PLUGIN_NAME);
                }
            }
        }
    }

    // time to handle spell casting?
    if(!TargetID(MeleeTarg) || MeleeDist>200) return;
    long MyEndu=GetCharInfo2()->Endurance*100/GetMaxEndurance();

    // should we stun that target?
    if(doSTUNNING && MeleeLife<=doSTUNNING)
    {
        Ability *UseThis=NULL;
        if(idSTUN[0].Ready(ifSTUNNING))      UseThis=&idSTUN[0];
        else if(idSTUN[1].Ready(ifSTUNNING)) UseThis=&idSTUN[1];
        if(UseThis)
        {
            Announce(SHOW_STUNNING,"%s::Stunning [\ay%s\ax].",PLUGIN_NAME,MeleeName);
            UseThis->Press();
        }
    }

    // are we grouped?
    if(IsGrouped())
    {
        // Time to build and maintain aggro?
        if(doAGGRO)
        {
            long HaveAggro=Aggroed(MeleeTarg);

            // should we challenge for to maintain aggro over time?
            if(doCHALLENGEFOR && onCHALLENGEFOR && HaveAggro==1 && idCHALLENGEFOR.Ready(ifCHALLENGEFOR)) {
                Announce(SHOW_PROVOKING,"%s::Challenging [\ay%s\ax].",PLUGIN_NAME,MeleeName);
                idCHALLENGEFOR.Press();
                onCHALLENGEFOR--;
            }

            // should we provoke at least once and/or when aggro is lost?
            if(onBELOW && MeleeLife>doPROVOKEEND && MeleeDist<100 && (HaveAggro<1 || (doPROVOKEONCE && onBELOW==doPROVOKEMAX)))
            {
                Ability *UseThis=NULL;
                if(idPROVOKE[0].Ready(ifPROVOKE))      UseThis=&idPROVOKE[0];
                else if(idPROVOKE[1].Ready(ifPROVOKE)) UseThis=&idPROVOKE[1];
                if(UseThis)
                {
                    Announce(SHOW_PROVOKING,"%s::Provoking [\ay%s\ax].",PLUGIN_NAME,MeleeName);
                    UseThis->Press();
                    onBELOW--;
                }
            }
        }

        // should we use short duration melee buff?
        if(GetCharInfo2()->Endurance>200)
        {
            if(doCOMMANDING && MyEndu>doCOMMANDING && idCOMMANDING.Ready(ifCOMMANDING)) idCOMMANDING.Press();
            if(doFISTSOFWU  && MyEndu>doFISTSOFWU  && idFISTSOFWU.Ready(ifFISTSOFWU))   idFISTSOFWU.Press();
            if(doCRYHAVOC   && MyEndu>doCRYHAVOC   && idCRYHAVOC.Ready(ifCRYHAVOC) && disc!=d_cleaverage && disc!=d_cleaveanger) idCRYHAVOC.Press();
            if(doTHIEFEYE   && MyEndu>doTHIEFEYE   && idTHIEFEYE.Ready(ifTHIEFEYE))     idTHIEFEYE.Press();
        }
    }

    // should we use zerker volley?
    if(doRAGEVOLLEY && MyEndu>doRAGEVOLLEY && MeleeDist<175 && idRAGEVOLLEY.Ready(ifRAGEVOLLEY)) idRAGEVOLLEY.Press();

    // is target close enough for those?
    if(MeleeDist < 50)
    {
        // ON/OFF switch
        if(doBATTLELEAP             && idBATTLELEAP.Ready(ifBATTLELEAP))                    idBATTLELEAP.Press();
        if(doASP                    && idASP.Ready(ifASP))                                  idASP.Press();   
        if(doBOASTFUL               && idBOASTFUL.Ready(ifBOASTFUL))                        idBOASTFUL.Press();   
        if(doCALLCHALLENGE          && idCALLCHALLENGE.Ready(ifCALLCHALLENGE))              idCALLCHALLENGE.Press();
        if(doCSTRIKE                && idCSTRIKE.Ready(ifCSTRIKE))                          idCSTRIKE.Press();
        if(doSELOS                  && idSELOS.Ready(ifSELOS))                              idSELOS.Press();
        if(doEYEGOUGE               && idEYEGOUGE.Ready(ifEYEGOUGE))                        idEYEGOUGE.Press(); 
        if(doFERALSWIPE             && idFERALSWIPE.Ready(ifFERALSWIPE))                    idFERALSWIPE.Press();
        if(doGORILLASMASH           && idGORILLASMASH.Ready(ifGORILLASMASH))                idGORILLASMASH.Press(); 
        if(doGUTPUNCH               && idGUTPUNCH.Ready(ifGUTPUNCH))                        idGUTPUNCH.Press();
        if(doKNEESTRIKE             && idKNEESTRIKE.Ready(ifKNEESTRIKE))                    idKNEESTRIKE.Press(); 
        if(doOPPORTUNISTICSTRIKE    && idOPPORTUNISTICSTRIKE.Ready(ifOPPORTUNISTICSTRIKE))  idOPPORTUNISTICSTRIKE.Press();
        if(doRAVENS                 && idRAVENS.Ready(ifRAVENS))                            idRAVENS.Press(); 
        if(doTWISTEDSHANK           && idTWISTEDSHANK.Ready(ifTWISTEDSHANK))                idTWISTEDSHANK.Press();

        // Endurance above disc switch 
        if(doASSAULT     && MyEndu>doASSAULT        && idASSAULT.Ready(ifASSAULT))          idASSAULT.Press(); 
        if(doBLEED       && MyEndu>doBLEED          && idBLEED.Ready(ifBLEED))              idBLEED.Press(); 
        if(doBVIVI       && MyEndu>doBVIVI          && idBVIVI.Ready(ifBVIVI))              idBVIVI.Press(); 
        if(doCRIPPLE     && MyEndu>doCRIPPLE        && idCRIPPLE.Ready(ifCRIPPLE))          idCRIPPLE.Press();
        if(doDEFENSE     && MyEndu>doDEFENSE        && idDEFENSE.Ready(ifDEFENSE))          idDEFENSE.Press();
        if(doFCLAW       && MyEndu>doFCLAW          && idFCLAW.Ready(ifFCLAW))              idFCLAW.Press(); 
        if(doLEOPARDCLAW && MyEndu>doLEOPARDCLAW    && idLEOPARDCLAW.Ready(ifLEOPARDCLAW))  idLEOPARDCLAW.Press();
        if(doOPFRENZY    && MyEndu>doOPFRENZY       && idOPFRENZY.Ready(ifOPFRENZY))        idOPFRENZY.Press();
        if(doFIELDARM    && MyEndu>doFIELDARM       && idFIELDARM.Ready(ifFIELDARM))        idFIELDARM.Press();
        if(doRAKE        && MyEndu>doRAKE           && idRAKE.Ready(ifRAKE))                idRAKE.Press();
        if(doRALLOS      && MyEndu>doRALLOS         && idRALLOS.Ready(ifRALLOS))            idRALLOS.Press();
        if(doRIGHTIND    && MyEndu>doRIGHTIND       && idRIGHTIND.Ready(ifRIGHTIND))        idRIGHTIND.Press();   
        if(doSLAPFACE    && MyEndu>doSLAPFACE       && idSLAPFACE.Ready(ifSLAPFACE))        idSLAPFACE.Press();
        if(doSYNERGY     && MyEndu>doSYNERGY        && idSYNERGY.Ready(ifSYNERGY))          idSYNERGY.Press();
        if(doTHROWSTONE  && MyEndu>doTHROWSTONE     && idTHROWSTONE.Ready(ifTHROWSTONE))    idTHROWSTONE.Press();
        if(doVIG         && MyEndu>doVIG            && idVIG.Ready(ifVIG))                  idVIG.Press(); 
        if(doWITHSTAND   && MyEndu>doWITHSTAND      && idWITHSTAND.Ready(ifWITHSTAND))      idWITHSTAND.Press(); 
          
    }

    // time to handle holy shit?
    if(doHOLYFLAG[doHOLY] && HOLYSHIT[doHOLY].size()) EzCommand((char*)HOLYSHIT[doHOLY].c_str());
    for(long x=1; x<16; x++)
    {
        long n=(x+doHOLY)&15;
        if(doHOLYFLAG[n])
        {
            doHOLY=n;
            break;
        }
    }
}

void KeyMelee(char* NAME, int Down)
{
    if(Down && pTarget)
    {
        if(!doSKILL) EzCommand("/keypress AUTOPRIM");
        else if(!MeleeTarg) KillThis(NULL,"");
        else Override(NULL,"%s::\arOVERRIDE\ax taking actions!");
    }
}

void KeyRange(char* NAME, int Down)
{
    if(Down && pTarget)
    {
        if(!doSKILL) EzCommand("/keypress RANGED");
        else ThrowIT(NULL,"");
    }
}

void Bindding(bool BindMode)
{
    if(BindMode)
    {
        if(!Binded)
        {
            KeyCombo  MeleeCombo, RangeCombo;
            RemoveMQ2KeyBind("MELEE"); AddMQ2KeyBind("MELEE",KeyMelee); ParseKeyCombo(MeleeKey,MeleeCombo); SetMQ2KeyBind("MELEE",false,MeleeCombo);
            RemoveMQ2KeyBind("RANGE"); AddMQ2KeyBind("RANGE",KeyRange); ParseKeyCombo(RangeKey,RangeCombo); SetMQ2KeyBind("RANGE",false,RangeCombo);
            Binded=true;
        }
    }
    else if(Binded)
    {
        RemoveMQ2KeyBind("MELEE");
        RemoveMQ2KeyBind("RANGE");
        Binded=false;
    }
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

void __stdcall AUTOFIREOFF(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    AutoFire=false;
    if(AutoFire) KeyMelee("",true);
}

void __stdcall AUTOFIREON(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(pTarget && TargetType(NPC_TYPE) && InGame()) AutoFire=true;
}

void __stdcall CASTING(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(doSKILL && MeleeTarg && !strnicmp(pValues->Value,MeleeName,MeleeSize)) MeleeCast=(unsigned long)clock();
}

void __stdcall ENRAGEON(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(MeleeTarg && !strnicmp(pValues->Value,MeleeName,MeleeSize)) EnrageON(NULL,"");
}

void __stdcall ENRAGEOFF(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(MeleeTarg && !strnicmp(pValues->Value,MeleeName,MeleeSize)) EnrageOFF(NULL,"");
}

void __stdcall INFURIATEON(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(MeleeTarg && !strnicmp(pValues->Value,MeleeName,MeleeSize)) InfuriateON(NULL,"");
}

void __stdcall INFURIATEOFF(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(MeleeTarg && !strnicmp(pValues->Value,MeleeName,MeleeSize)) InfuriateOFF(NULL,"");
}

void __stdcall PETATTK(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    PetSEEN();
}

void __stdcall PETBACK(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(HaveHold) {
        Announce(SHOW_CONTROL,"%s::Command [\ay%s\ax].",PLUGIN_NAME,"/pet hold on");
        EzCommand("/pet hold on");
        if(PetOnAttk) PetOnAttk=(unsigned long)clock()+1000;
        PetOnHold=true;
    }
}

void __stdcall PETHOLD(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    PetOnHold=true;
}

void __stdcall FALLEN(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(!doSKILL || ((long)pData && strnicmp(pValues->Value,GetCharInfo()->Name,strlen(GetCharInfo()->Name)+1))) return;
    Announce(SHOW_FEIGN,"%s::\arFAILED FEIGN DEATH\ax taking action!",PLUGIN_NAME);
    EzCommand("/stand");
}

void __stdcall BROKEN(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(doSKILL) BrokenFD=(unsigned long)clock()+1;
}

void __stdcall RESUME(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    if(doSKILL) BrokenFD=0;
}

void __stdcall SNEAKON(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    SilentTimer=(unsigned long)clock();
}

void __stdcall SNEAKOFF(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    SilentTimer=0;
}

void __stdcall HIDEON(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    HiddenTimer=(unsigned long)clock();
}

void __stdcall HIDEOFF(unsigned int ID, void *pData, PBLECHVALUE pValues) {
    HiddenTimer=0;
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

PLUGIN_API void InitializePlugin()
{
    NPC_TYPE = GetPrivateProfileInt("Settings", "SpawnType", 0x000A, INIFileName);
    GetPrivateProfileString("Settings", "MeleeKeys", "z", MeleeKey, sizeof(MeleeKey), INIFileName);
    GetPrivateProfileString("Settings", "RangeKeys", "x", RangeKey, sizeof(RangeKey), INIFileName);

    CmdListe.clear();
    MapInsert(&CmdListe, Option(pAGGRO[0],  pAGGRO[1],  pAGGRO[2],  pAGGRO[3],  AggroReset, &doAGGRO));
    MapInsert(&CmdListe, Option(pAGGRP[0],  pAGGRP[1],  pAGGRP[2],  pAGGRP[3],  NULL      , &elAGGROPRI));
    MapInsert(&CmdListe, Option(pAGGRS[0],  pAGGRS[1],  pAGGRS[2],  pAGGRS[3],  NULL      , &elAGGROSEC));
    MapInsert(&CmdListe, Option(pARROW[0],  pARROW[1],  pARROW[2],  pARROW[3],  NULL      , &elARROWS));
    MapInsert(&CmdListe, Option(pASSLT[0],  pASSLT[1],  pASSLT[2],  pASSLT[3],  NULL      , &doASSAULT));
    MapInsert(&CmdListe, Option(pASSAS[0],  pASSAS[1],  pASSAS[2],  pASSAS[3],  NULL      , &doASSASINATE));
    MapInsert(&CmdListe, Option(pBKOFF[0],  pBKOFF[1],  pBKOFF[2],  pBKOFF[3],  NULL      , &doBACKOFF));
    MapInsert(&CmdListe, Option(pBSTAB[0],  pBSTAB[1],  pBSTAB[2],  pBSTAB[3],  NULL      , &doBACKSTAB));
    MapInsert(&CmdListe, Option(pBASHS[0],  pBASHS[1],  pBASHS[2],  pBASHS[3],  NULL      , &doBASH));
    MapInsert(&CmdListe, Option(pBGING[0],  pBGING[1],  pBGING[2],  pBGING[3],  NULL      , &doBEGGING));
    MapInsert(&CmdListe, Option(pBTASP[0],  pBTASP[1],  pBTASP[2],  pBTASP[3],  NULL      , &doASP));
    MapInsert(&CmdListe, Option(pBLEED[0],  pBLEED[1],  pBLEED[2],  pBLEED[3],  NULL      , &doBLEED));
    MapInsert(&CmdListe, Option(pBVIVI[0],  pBVIVI[1],  pBVIVI[2],  pBVIVI[3],  NULL      , &doBVIVI));
    MapInsert(&CmdListe, Option(pBBLOW[0],  pBBLOW[1],  pBBLOW[2],  pBBLOW[3],  NULL      , &doBOASTFUL));
    MapInsert(&CmdListe, Option(pCALLC[0],  pCALLC[1],  pCALLC[2],  pCALLC[3],  NULL      , &doCALLCHALLENGE));
    MapInsert(&CmdListe, Option(pCHAMS[0],  pCHAMS[1],  pCHAMS[2],  pCHAMS[3],  NULL      , &doCSTRIKE));
    MapInsert(&CmdListe, Option(pGTPUN[0],  pGTPUN[1],  pGTPUN[2],  pGTPUN[3],  NULL      , &doGUTPUNCH));
    MapInsert(&CmdListe, Option(pOSTRK[0],  pOSTRK[1],  pOSTRK[2],  pOSTRK[3],  NULL      , &doOPPORTUNISTICSTRIKE));
    MapInsert(&CmdListe, Option(pTTJAB[0],  pTTJAB[1],  pTTJAB[2],  pTTJAB[3],  NULL      , &doTHROATJAB));
    MapInsert(&CmdListe, Option(pBTLLP[0],  pBTLLP[1],  pBTLLP[2],  pBTLLP[3],  NULL      , &doBATTLELEAP));
    MapInsert(&CmdListe, Option(pCHFOR[0],  pCHFOR[1],  pCHFOR[2],  pCHFOR[3],  NULL      , &doCHALLENGEFOR));
    MapInsert(&CmdListe, Option(pCOMMG[0],  pCOMMG[1],  pCOMMG[2],  pCOMMG[3],  NULL      , &doCOMMANDING));
    MapInsert(&CmdListe, Option(pCRIPS[0],  pCRIPS[1],  pCRIPS[2],  pCRIPS[3],  NULL      , &doCRIPPLE));
    MapInsert(&CmdListe, Option(pCRYHC[0],  pCRYHC[1],  pCRYHC[2],  pCRYHC[3],  NULL      , &doCRYHAVOC));
    MapInsert(&CmdListe, Option(pDEFEN[0],  pDEFEN[1],  pDEFEN[2],  pDEFEN[3],  NULL      , &doDEFENSE));
    MapInsert(&CmdListe, Option(pDISRM[0],  pDISRM[1],  pDISRM[2],  pDISRM[3],  NULL      , &doDISARM));
    MapInsert(&CmdListe, Option(pDWNF0[0],  pDWNF0[1],  pDWNF0[2],  pDWNF0[3],  NULL      , &doDOWNFLAG[0]));
    MapInsert(&CmdListe, Option(pDWNF1[0],  pDWNF1[1],  pDWNF1[2],  pDWNF1[3],  NULL      , &doDOWNFLAG[1]));
    MapInsert(&CmdListe, Option(pDWNF2[0],  pDWNF2[1],  pDWNF2[2],  pDWNF2[3],  NULL      , &doDOWNFLAG[2]));
    MapInsert(&CmdListe, Option(pDWNF3[0],  pDWNF3[1],  pDWNF3[2],  pDWNF3[3],  NULL      , &doDOWNFLAG[3]));
    MapInsert(&CmdListe, Option(pDWNF4[0],  pDWNF4[1],  pDWNF4[2],  pDWNF4[3],  NULL      , &doDOWNFLAG[4]));
    MapInsert(&CmdListe, Option(pDWNF5[0],  pDWNF5[1],  pDWNF5[2],  pDWNF5[3],  NULL      , &doDOWNFLAG[5]));
    MapInsert(&CmdListe, Option(pDWNF6[0],  pDWNF6[1],  pDWNF6[2],  pDWNF6[3],  NULL      , &doDOWNFLAG[6]));
    MapInsert(&CmdListe, Option(pDWNF7[0],  pDWNF7[1],  pDWNF7[2],  pDWNF7[3],  NULL      , &doDOWNFLAG[7]));
    MapInsert(&CmdListe, Option(pDWNF8[0],  pDWNF8[1],  pDWNF8[2],  pDWNF8[3],  NULL      , &doDOWNFLAG[8]));
    MapInsert(&CmdListe, Option(pDWNF9[0],  pDWNF9[1],  pDWNF9[2],  pDWNF9[3],  NULL      , &doDOWNFLAG[9]));
    MapInsert(&CmdListe, Option(pDWNF10[0], pDWNF10[1], pDWNF10[2], pDWNF10[3], NULL      , &doDOWNFLAG[10]));
    MapInsert(&CmdListe, Option(pDWNF11[0], pDWNF11[1], pDWNF11[2], pDWNF11[3], NULL      , &doDOWNFLAG[11]));
    MapInsert(&CmdListe, Option(pDWNF12[0], pDWNF12[1], pDWNF12[2], pDWNF12[3], NULL      , &doDOWNFLAG[12]));
    MapInsert(&CmdListe, Option(pDWNF13[0], pDWNF13[1], pDWNF13[2], pDWNF13[3], NULL      , &doDOWNFLAG[13]));
    MapInsert(&CmdListe, Option(pDWNF14[0], pDWNF14[1], pDWNF14[2], pDWNF14[3], NULL      , &doDOWNFLAG[14]));
    MapInsert(&CmdListe, Option(pDWNF15[0], pDWNF15[1], pDWNF15[2], pDWNF15[3], NULL      , &doDOWNFLAG[15]));
    MapInsert(&CmdListe, Option(pDRPNC[0],  pDRPNC[1],  pDRPNC[2],  pDRPNC[3],  NULL      , &doDRAGONPUNCH));
    MapInsert(&CmdListe, Option(pEAGLE[0],  pEAGLE[1],  pEAGLE[2],  pEAGLE[3],  NULL      , &doEAGLESTRIKE));
    MapInsert(&CmdListe, Option(pERAGE[0],  pERAGE[1],  pERAGE[2],  pERAGE[3],  NULL      , &doENRAGE));
    MapInsert(&CmdListe, Option(pESCAP[0],  pESCAP[1],  pESCAP[2],  pESCAP[3],  NULL      , &doESCAPE));
    MapInsert(&CmdListe, Option(pEVADE[0],  pEVADE[1],  pEVADE[2],  pEVADE[3],  NULL      , &doEVADE));
    MapInsert(&CmdListe, Option(pEYEGO[0],  pEYEGO[1],  pEYEGO[2],  pEYEGO[3],  NULL      , &doEYEGOUGE));
    MapInsert(&CmdListe, Option(pFEIGN[0],  pFEIGN[1],  pFEIGN[2],  pFEIGN[3],  NULL      , &doFEIGNDEATH));
    MapInsert(&CmdListe, Option(pFACES[0],  pFACES[1],  pFACES[2],  pFACES[3],  NULL      , &doFACING));
    MapInsert(&CmdListe, Option(pFALLS[0],  pFALLS[1],  pFALLS[2],  pFALLS[3],  NULL      , &doFALLS));
    MapInsert(&CmdListe, Option(pFERAL[0],  pFERAL[1],  pFERAL[2],  pFERAL[3],  NULL      , &doFERALSWIPE));
    MapInsert(&CmdListe, Option(pFIELD[0],  pFIELD[1],  pFIELD[2],  pFIELD[3],  NULL      , &doFIELDARM));
    MapInsert(&CmdListe, Option(pFISTS[0],  pFISTS[1],  pFISTS[2],  pFISTS[3],  NULL      , &doFISTSOFWU));
    MapInsert(&CmdListe, Option(pFCLAW[0],  pFCLAW[1],  pFCLAW[2],  pFCLAW[3],  NULL      , &doFCLAW));
    MapInsert(&CmdListe, Option(pFLYKC[0],  pFLYKC[1],  pFLYKC[2],  pFLYKC[3],  NULL      , &doFLYINGKICK));
    MapInsert(&CmdListe, Option(pFORAG[0],  pFORAG[1],  pFORAG[2],  pFORAG[3],  NULL      , &doFORAGE));
    MapInsert(&CmdListe, Option(pFRENZ[0],  pFRENZ[1],  pFRENZ[2],  pFRENZ[3],  NULL      , &doFRENZY));
    MapInsert(&CmdListe, Option(pGORSM[0],  pGORSM[1],  pGORSM[2],  pGORSM[3],  NULL      , &doGORILLASMASH));
    MapInsert(&CmdListe, Option(pHARMT[0],  pHARMT[1],  pHARMT[2],  pHARMT[3],  NULL      , &doHARMTOUCH));
    MapInsert(&CmdListe, Option(pHIDES[0],  pHIDES[1],  pHIDES[2],  pHIDES[3],  NULL      , &doHIDE));
    MapInsert(&CmdListe, Option(pHOLF0[0],  pHOLF0[1],  pHOLF0[2],  pHOLF0[3],  NULL      , &doHOLYFLAG[0]));
    MapInsert(&CmdListe, Option(pHOLF1[0],  pHOLF1[1],  pHOLF1[2],  pHOLF1[3],  NULL      , &doHOLYFLAG[1]));
    MapInsert(&CmdListe, Option(pHOLF2[0],  pHOLF2[1],  pHOLF2[2],  pHOLF2[3],  NULL      , &doHOLYFLAG[2]));
    MapInsert(&CmdListe, Option(pHOLF3[0],  pHOLF3[1],  pHOLF3[2],  pHOLF3[3],  NULL      , &doHOLYFLAG[3]));
    MapInsert(&CmdListe, Option(pHOLF4[0],  pHOLF4[1],  pHOLF4[2],  pHOLF4[3],  NULL      , &doHOLYFLAG[4]));
    MapInsert(&CmdListe, Option(pHOLF5[0],  pHOLF5[1],  pHOLF5[2],  pHOLF5[3],  NULL      , &doHOLYFLAG[5]));
    MapInsert(&CmdListe, Option(pHOLF6[0],  pHOLF6[1],  pHOLF6[2],  pHOLF6[3],  NULL      , &doHOLYFLAG[6]));
    MapInsert(&CmdListe, Option(pHOLF7[0],  pHOLF7[1],  pHOLF7[2],  pHOLF7[3],  NULL      , &doHOLYFLAG[7]));
    MapInsert(&CmdListe, Option(pHOLF8[0],  pHOLF8[1],  pHOLF8[2],  pHOLF8[3],  NULL      , &doHOLYFLAG[8]));
    MapInsert(&CmdListe, Option(pHOLF9[0],  pHOLF9[1],  pHOLF9[2],  pHOLF9[3],  NULL      , &doHOLYFLAG[9]));
    MapInsert(&CmdListe, Option(pHOLF10[0], pHOLF10[1], pHOLF10[2], pHOLF10[3], NULL      , &doHOLYFLAG[10]));
    MapInsert(&CmdListe, Option(pHOLF11[0], pHOLF11[1], pHOLF11[2], pHOLF11[3], NULL      , &doHOLYFLAG[11]));
    MapInsert(&CmdListe, Option(pHOLF12[0], pHOLF12[1], pHOLF12[2], pHOLF12[3], NULL      , &doHOLYFLAG[12]));
    MapInsert(&CmdListe, Option(pHOLF13[0], pHOLF13[1], pHOLF13[2], pHOLF13[3], NULL      , &doHOLYFLAG[13]));
    MapInsert(&CmdListe, Option(pHOLF14[0], pHOLF14[1], pHOLF14[2], pHOLF14[3], NULL      , &doHOLYFLAG[14]));
    MapInsert(&CmdListe, Option(pHOLF15[0], pHOLF15[1], pHOLF15[2], pHOLF15[3], NULL      , &doHOLYFLAG[15]));
    MapInsert(&CmdListe, Option(pINFUR[0],  pINFUR[1],  pINFUR[2],  pINFUR[3],  NULL      , &doINFURIATE));
    MapInsert(&CmdListe, Option(pINTIM[0],  pINTIM[1],  pINTIM[2],  pINTIM[3],  NULL      , &doINTIMIDATION));
    MapInsert(&CmdListe, Option(pJOLTS[0],  pJOLTS[1],  pJOLTS[2],  pJOLTS[3],  NULL      , &doJOLT));
    MapInsert(&CmdListe, Option(pJKICK[0],  pJKICK[1],  pJKICK[2],  pJKICK[3],  NULL      , &doJLTKICKS));
    MapInsert(&CmdListe, Option(pKICKS[0],  pKICKS[1],  pKICKS[2],  pKICKS[3],  NULL      , &doKICK));
    MapInsert(&CmdListe, Option(pKNEES[0],  pKNEES[1],  pKNEES[2],  pKNEES[3],  NULL      , &doKNEESTRIKE));
    MapInsert(&CmdListe, Option(pLHAND[0],  pLHAND[1],  pLHAND[2],  pLHAND[3],  NULL      , &doLAYHAND));
    MapInsert(&CmdListe, Option(pLCLAW[0],  pLCLAW[1],  pLCLAW[2],  pLCLAW[3],  NULL      , &doLEOPARDCLAW));
    MapInsert(&CmdListe, Option(pMELEE[0],  pMELEE[1],  pMELEE[2],  pMELEE[3],  NULL      , &doMELEE));
    MapInsert(&CmdListe, Option(pMELEP[0],  pMELEP[1],  pMELEP[2],  pMELEP[3],  NULL      , &elMELEEPRI));
    MapInsert(&CmdListe, Option(pMELES[0],  pMELES[1],  pMELES[2],  pMELES[3],  NULL      , &elMELEESEC));
    MapInsert(&CmdListe, Option(pMENDS[0],  pMENDS[1],  pMENDS[2],  pMENDS[3],  NULL      , &doMEND));
    MapInsert(&CmdListe, Option(pBOWID[0],  pBOWID[1],  pBOWID[2],  pBOWID[3],  NULL      , &elRANGED));
    MapInsert(&CmdListe, Option(pOFREN[0],  pOFREN[1],  pOFREN[2],  pOFREN[3],  NULL      , &doOPFRENZY));
    MapInsert(&CmdListe, Option(pPETAS[0],  pPETAS[1],  pPETAS[2],  pPETAS[3],  NULL      , &doPETASSIST));
    MapInsert(&CmdListe, Option(pPETDE[0],  pPETDE[1],  pPETDE[2],  pPETDE[3],  NULL      , &doPETDELAY));
    MapInsert(&CmdListe, Option(pPETRN[0],  pPETRN[1],  pPETRN[2],  pPETRN[3],  NULL      , &doPETRANGE));
    MapInsert(&CmdListe, Option(pPETMN[0],  pPETMN[1],  pPETMN[2],  pPETMN[3],  NULL      , &doPETMEND));
    MapInsert(&CmdListe, Option(pPICKP[0],  pPICKP[1],  pPICKP[2],  pPICKP[3],  NULL      , &doPICKPOCKET));
    MapInsert(&CmdListe, Option(pPOKER[0],  pPOKER[1],  pPOKER[2],  pPOKER[3],  NULL      , &elPOKER));
    MapInsert(&CmdListe, Option(pHFAST[0],  pHFAST[1],  pHFAST[2],  pHFAST[3],  NULL      , &doPOTHEALFAST));
    MapInsert(&CmdListe, Option(pHOVER[0],  pHOVER[1],  pHOVER[2],  pHOVER[3],  NULL      , &doPOTHEALOVER));
    MapInsert(&CmdListe, Option(pPRVKM[0],  pPRVKM[1],  pPRVKM[2],  pPRVKM[3],  AggroReset, &doPROVOKEMAX));
    MapInsert(&CmdListe, Option(pPRVKE[0],  pPRVKE[1],  pPRVKE[2],  pPRVKE[3],  NULL      , &doPROVOKEEND));
    MapInsert(&CmdListe, Option(pPRVKO[0],  pPRVKO[1],  pPRVKO[2],  pPRVKO[3],  NULL      , &doPROVOKEONCE));
    MapInsert(&CmdListe, Option(pPRVK0[0],  pPRVK0[1],  pPRVK0[2],  pPRVK0[3],  NULL      , &idPROVOKE[0]));
    MapInsert(&CmdListe, Option(pPRVK1[0],  pPRVK1[1],  pPRVK1[2],  pPRVK1[3],  NULL      , &idPROVOKE[1]));
    MapInsert(&CmdListe, Option(pRAVOL[0],  pRAVOL[1],  pRAVOL[2],  pRAVOL[3],  NULL      , &doRAGEVOLLEY));
    MapInsert(&CmdListe, Option(pRAKES[0],  pRAKES[1],  pRAKES[2],  pRAKES[3],  NULL      , &doRAKE));
    MapInsert(&CmdListe, Option(pRALLO[0],  pRALLO[1],  pRALLO[2],  pRALLO[3],  NULL      , &doRALLOS));
    MapInsert(&CmdListe, Option(pRANGE[0],  pRANGE[1],  pRANGE[2],  pRANGE[3],  RangeReset, &doRANGE));
    MapInsert(&CmdListe, Option(pRAVEN[0],  pRAVEN[1],  pRAVEN[2],  pRAVEN[3],  NULL      , &doRAVENS));
    MapInsert(&CmdListe, Option(pRESUM[0],  pRESUM[1],  pRESUM[2],  pRESUM[3],  NULL      , &doRESUME));
    MapInsert(&CmdListe, Option(pRGHTI[0],  pRGHTI[1],  pRGHTI[2],  pRGHTI[3],  NULL      , &doRIGHTIND));
    MapInsert(&CmdListe, Option(pRKICK[0],  pRKICK[1],  pRKICK[2],  pRKICK[3],  NULL      , &doROUNDKICK));
    MapInsert(&CmdListe, Option(pSENSE[0],  pSENSE[1],  pSENSE[2],  pSENSE[3],  NULL      , &doSENSETRAP));
    MapInsert(&CmdListe, Option(pPLUGS[0],  pPLUGS[1],  pPLUGS[2],  pPLUGS[3],  NULL      , &doSKILL));
    MapInsert(&CmdListe, Option(pSELOK[0],  pSELOK[1],  pSELOK[2],  pSELOK[3],  NULL      , &doSELOS));
    MapInsert(&CmdListe, Option(pSLAMS[0],  pSLAMS[1],  pSLAMS[2],  pSLAMS[3],  NULL      , &doSLAM));
    MapInsert(&CmdListe, Option(pSLAPF[0],  pSLAPF[1],  pSLAPF[2],  pSLAPF[3],  NULL      , &doSLAPFACE));
    MapInsert(&CmdListe, Option(pSNEAK[0],  pSNEAK[1],  pSNEAK[2],  pSNEAK[3],  NULL      , &doSNEAK));
    MapInsert(&CmdListe, Option(pSTAND[0],  pSTAND[1],  pSTAND[2],  pSTAND[3],  NULL      , &doSTAND));
    MapInsert(&CmdListe, Option(pSTIKR[0],  pSTIKR[1],  pSTIKR[2],  pSTIKR[3],  StickReset, &doSTICKRANGE));
    MapInsert(&CmdListe, Option(pSTIKKB[0], pSTIKKB[1], pSTIKKB[2], pSTIKKB[3], StickReset, &doSTICKBREAK));
    MapInsert(&CmdListe, Option(pSTIKNR[0], pSTIKNR[1], pSTIKNR[2], pSTIKNR[3], StickReset, &doSTICKNORANGE));
    MapInsert(&CmdListe, Option(pSTIKD[0],  pSTIKD[1],  pSTIKD[2],  pSTIKD[3],  StickReset, &doSTICKDELAY));
    MapInsert(&CmdListe, Option(pSTIKM[0],  pSTIKM[1],  pSTIKM[2],  pSTIKM[3],  NULL      , &doSTICKMODE));
    MapInsert(&CmdListe, Option(pSTRIKM[0], pSTRIKM[1], pSTRIKM[2], pSTRIKM[3], NULL      , &doSTRIKEMODE));
    MapInsert(&CmdListe, Option(pSTUNS[0],  pSTUNS[1],  pSTUNS[2],  pSTUNS[3],  NULL      , &doSTUNNING));
    MapInsert(&CmdListe, Option(pSTUN0[0],  pSTUN0[1],  pSTUN0[2],  pSTUN0[3],  NULL      , &idSTUN[0]));
    MapInsert(&CmdListe, Option(pSTUN1[0],  pSTUN1[1],  pSTUN1[2],  pSTUN1[3],  NULL      , &idSTUN[1]));
    MapInsert(&CmdListe, Option(pSTRIK[0],  pSTRIK[1],  pSTRIK[2],  pSTRIK[3],  NULL      , &doSTRIKE));
    MapInsert(&CmdListe, Option(pSYNGY[0],  pSYNGY[1],  pSYNGY[2],  pSYNGY[3],  NULL      , &doSYNERGY));
    MapInsert(&CmdListe, Option(pTAUNT[0],  pTAUNT[1],  pTAUNT[2],  pTAUNT[3],  NULL      , &doTAUNT));
    MapInsert(&CmdListe, Option(pTHIEF[0],  pTHIEF[1],  pTHIEF[2],  pTHIEF[3],  NULL      , &doTHIEFEYE));
    MapInsert(&CmdListe, Option(pTHROW[0],  pTHROW[1],  pTHROW[2],  pTHROW[3],  NULL      , &doTHROWSTONE));
    MapInsert(&CmdListe, Option(pTIGER[0],  pTIGER[1],  pTIGER[2],  pTIGER[3],  NULL      , &doTIGERCLAW));
    MapInsert(&CmdListe, Option(pTWIST[0],  pTWIST[1],  pTWIST[2],  pTWIST[3],  NULL      , &doTWISTEDSHANK));
    MapInsert(&CmdListe, Option(pSHIEL[0],  pSHIEL[1],  pSHIEL[2],  pSHIEL[3],  NULL      , &elSHIELD));
    MapInsert(&CmdListe, Option(pVIGOR[0],  pVIGOR[1],  pVIGOR[2],  pVIGOR[3],  NULL      , &doVIG));
    MapInsert(&CmdListe, Option(pWITHS[0],  pWITHS[1],  pWITHS[2],  pWITHS[3],  NULL      , &doWITHSTAND));

    IniListe.clear();
    MapInsert(&IniListe, Option("assaultif"        , "", "", "", NULL, &ifASSAULT));
    MapInsert(&IniListe, Option("backstabif"       , "", "", "", NULL, &ifBACKSTAB));
    MapInsert(&IniListe, Option("bashif"           , "", "", "", NULL, &ifBASH));
    MapInsert(&IniListe, Option("beggingif"        , "", "", "", NULL, &ifBEGGING));
    MapInsert(&IniListe, Option("aspif"            , "", "", "", NULL, &ifASP));
    MapInsert(&IniListe, Option("bviviif"          , "", "", "", NULL, &ifBVIVI));
    MapInsert(&IniListe, Option("boastfulif"       , "", "", "", NULL, &ifBOASTFUL));
    MapInsert(&IniListe, Option("bleedif"          , "", "", "", NULL, &ifBLEED));
    MapInsert(&IniListe, Option("callchallengeif"  , "", "", "", NULL, &ifCALLCHALLENGE));
    MapInsert(&IniListe, Option("cstrikeif"        , "", "", "", NULL, &ifCSTRIKE));
    MapInsert(&IniListe, Option("crippleif"        , "", "", "", NULL, &ifCRIPPLE));
    MapInsert(&IniListe, Option("gutpunchif"       , "", "", "", NULL, &ifGUTPUNCH));
    MapInsert(&IniListe, Option("opstrikeif"       , "", "", "", NULL, &ifOPPORTUNISTICSTRIKE));
    MapInsert(&IniListe, Option("throatjabif"      , "", "", "", NULL, &ifTHROATJAB));
    MapInsert(&IniListe, Option("battleleapif"     , "", "", "", NULL, &ifBATTLELEAP));
    MapInsert(&IniListe, Option("challengeforif"   , "", "", "", NULL, &ifCHALLENGEFOR));
    MapInsert(&IniListe, Option("commandingif"     , "", "", "", NULL, &ifCOMMANDING));
    MapInsert(&IniListe, Option("cryhavocif"       , "", "", "", NULL, &ifCRYHAVOC));
    MapInsert(&IniListe, Option("defenseif"        , "", "", "", NULL, &ifDEFENSE));
    MapInsert(&IniListe, Option("disarmif"         , "", "", "", NULL, &ifDISARM));
    MapInsert(&IniListe, Option("dragonpunchif"    , "", "", "", NULL, &ifDRAGONPUNCH));
    MapInsert(&IniListe, Option("eaglestrikeif"    , "", "", "", NULL, &ifEAGLESTRIKE));
    MapInsert(&IniListe, Option("eyegougeif"       , "", "", "", NULL, &ifEYEGOUGE));
    MapInsert(&IniListe, Option("evadeif"          , "", "", "", NULL, &ifEVADE));
    MapInsert(&IniListe, Option("fallsif"          , "", "", "", NULL, &ifFALLS));
    MapInsert(&IniListe, Option("feralswipeif"     , "", "", "", NULL, &ifFERALSWIPE));
    MapInsert(&IniListe, Option("fieldarmif"       , "", "", "", NULL, &ifFIELDARM));
    MapInsert(&IniListe, Option("fistofwuif"       , "", "", "", NULL, &ifFISTSOFWU));
    MapInsert(&IniListe, Option("fclaw"            , "", "", "", NULL, &ifFCLAW));
    MapInsert(&IniListe, Option("flyingkickif"     , "", "", "", NULL, &ifFLYINGKICK));
    MapInsert(&IniListe, Option("forageif"         , "", "", "", NULL, &ifFORAGE));
    MapInsert(&IniListe, Option("frenzyif"         , "", "", "", NULL, &ifFRENZY));
    MapInsert(&IniListe, Option("gorillasmashif"   , "", "", "", NULL, &ifGORILLASMASH));
    MapInsert(&IniListe, Option("harmtouchif"      , "", "", "", NULL, &ifHARMTOUCH));
    MapInsert(&IniListe, Option("pothealfastif"    , "", "", "", NULL, &ifPOTHEALFAST));
    MapInsert(&IniListe, Option("pothealoverif"    , "", "", "", NULL, &ifPOTHEALOVER));
    MapInsert(&IniListe, Option("hideif"           , "", "", "", NULL, &ifHIDE));
    MapInsert(&IniListe, Option("intimidationif"   , "", "", "", NULL, &ifINTIMIDATION));
    MapInsert(&IniListe, Option("joltif"           , "", "", "", NULL, &ifJOLT));
    MapInsert(&IniListe, Option("jltkicksif"       , "", "", "", NULL, &ifJLTKICKS));
    MapInsert(&IniListe, Option("kickif"           , "", "", "", NULL, &ifKICK));
    MapInsert(&IniListe, Option("kneestrikeif"     , "", "", "", NULL, &ifKNEESTRIKE));
    MapInsert(&IniListe, Option("layhandif"        , "", "", "", NULL, &ifLAYHAND));
    MapInsert(&IniListe, Option("leopardclawif"    , "", "", "", NULL, &ifLEOPARDCLAW));
    MapInsert(&IniListe, Option("mendif"           , "", "", "", NULL, &ifMEND));
    MapInsert(&IniListe, Option("opfrenzyif"       , "", "", "", NULL, &ifOPFRENZY));
    MapInsert(&IniListe, Option("pickpocketif"     , "", "", "", NULL, &ifPICKPOCKET));
    MapInsert(&IniListe, Option("provokeif"        , "", "", "", NULL, &ifPROVOKE));
    MapInsert(&IniListe, Option("ragevolleyif"     , "", "", "", NULL, &ifRAGEVOLLEY));
    MapInsert(&IniListe, Option("rakeif"           , "", "", "", NULL, &ifRAKE));
    MapInsert(&IniListe, Option("rallosif"         , "", "", "", NULL, &ifRALLOS));
    MapInsert(&IniListe, Option("ravensif"         , "", "", "", NULL, &ifRAVENS));
    MapInsert(&IniListe, Option("rightindif"       , "", "", "", NULL, &ifRIGHTIND));
    MapInsert(&IniListe, Option("roundkickif"      , "", "", "", NULL, &ifROUNDKICK));
    MapInsert(&IniListe, Option("sensetrapif"      , "", "", "", NULL, &ifSENSETRAP));
    MapInsert(&IniListe, Option("selosif"          , "", "", "", NULL, &ifSELOS));
    MapInsert(&IniListe, Option("slamif"           , "", "", "", NULL, &ifSLAM));
    MapInsert(&IniListe, Option("slapfaceif"       , "", "", "", NULL, &ifSLAPFACE));
    MapInsert(&IniListe, Option("sneakif"          , "", "", "", NULL, &ifSNEAK));
    MapInsert(&IniListe, Option("strikeif"         , "", "", "", NULL, &ifSTRIKE));
    MapInsert(&IniListe, Option("stunningif"       , "", "", "", NULL, &ifSTUNNING));
    MapInsert(&IniListe, Option("synergyif"        , "", "", "", NULL, &ifSYNERGY));
    MapInsert(&IniListe, Option("tauntif"          , "", "", "", NULL, &ifTAUNT));
    MapInsert(&IniListe, Option("thiefeyeif"       , "", "", "", NULL, &ifTHIEFEYE));
    MapInsert(&IniListe, Option("throwstoneif"     , "", "", "", NULL, &ifTHROWSTONE));
    MapInsert(&IniListe, Option("tigerclawif"      , "", "", "", NULL, &ifTIGERCLAW));
    MapInsert(&IniListe, Option("twistedshankif"   , "", "", "", NULL, &ifTWISTEDSHANK));
    MapInsert(&IniListe, Option("vigif"            , "", "", "", NULL, &ifVIG));
    MapInsert(&IniListe, Option("withstandif"      , "", "", "", NULL, &ifWITHSTAND));
    MapInsert(&IniListe, Option("stickcmd"         , "", "", "", NULL, &StickCMD));
    MapInsert(&IniListe, Option("strikecmd"        , "", "", "", NULL, &StrikeCMD));
    MapInsert(&IniListe, Option("downshit0"        , "", "", "", NULL, &DOWNSHIT[0]));
    MapInsert(&IniListe, Option("downshit1"        , "", "", "", NULL, &DOWNSHIT[1]));
    MapInsert(&IniListe, Option("downshit2"        , "", "", "", NULL, &DOWNSHIT[2]));
    MapInsert(&IniListe, Option("downshit3"        , "", "", "", NULL, &DOWNSHIT[3]));
    MapInsert(&IniListe, Option("downshit4"        , "", "", "", NULL, &DOWNSHIT[4]));
    MapInsert(&IniListe, Option("downshit5"        , "", "", "", NULL, &DOWNSHIT[5]));
    MapInsert(&IniListe, Option("downshit6"        , "", "", "", NULL, &DOWNSHIT[6]));
    MapInsert(&IniListe, Option("downshit7"        , "", "", "", NULL, &DOWNSHIT[7]));
    MapInsert(&IniListe, Option("downshit8"        , "", "", "", NULL, &DOWNSHIT[8]));
    MapInsert(&IniListe, Option("downshit9"        , "", "", "", NULL, &DOWNSHIT[9]));
    MapInsert(&IniListe, Option("downshit10"       , "", "", "", NULL, &DOWNSHIT[10]));
    MapInsert(&IniListe, Option("downshit11"       , "", "", "", NULL, &DOWNSHIT[11]));
    MapInsert(&IniListe, Option("downshit12"       , "", "", "", NULL, &DOWNSHIT[12]));
    MapInsert(&IniListe, Option("downshit13"       , "", "", "", NULL, &DOWNSHIT[13]));
    MapInsert(&IniListe, Option("downshit14"       , "", "", "", NULL, &DOWNSHIT[14]));
    MapInsert(&IniListe, Option("downshit15"       , "", "", "", NULL, &DOWNSHIT[15]));
    MapInsert(&IniListe, Option("holyshit0"        , "", "", "", NULL, &HOLYSHIT[0]));
    MapInsert(&IniListe, Option("holyshit1"        , "", "", "", NULL, &HOLYSHIT[1]));
    MapInsert(&IniListe, Option("holyshit2"        , "", "", "", NULL, &HOLYSHIT[2]));
    MapInsert(&IniListe, Option("holyshit3"        , "", "", "", NULL, &HOLYSHIT[3]));
    MapInsert(&IniListe, Option("holyshit4"        , "", "", "", NULL, &HOLYSHIT[4]));
    MapInsert(&IniListe, Option("holyshit5"        , "", "", "", NULL, &HOLYSHIT[5]));
    MapInsert(&IniListe, Option("holyshit6"        , "", "", "", NULL, &HOLYSHIT[6]));
    MapInsert(&IniListe, Option("holyshit7"        , "", "", "", NULL, &HOLYSHIT[7]));
    MapInsert(&IniListe, Option("holyshit8"        , "", "", "", NULL, &HOLYSHIT[8]));
    MapInsert(&IniListe, Option("holyshit9"        , "", "", "", NULL, &HOLYSHIT[9]));
    MapInsert(&IniListe, Option("holyshit10"       , "", "", "", NULL, &HOLYSHIT[10]));
    MapInsert(&IniListe, Option("holyshit11"       , "", "", "", NULL, &HOLYSHIT[11]));
    MapInsert(&IniListe, Option("holyshit12"       , "", "", "", NULL, &HOLYSHIT[12]));
    MapInsert(&IniListe, Option("holyshit13"       , "", "", "", NULL, &HOLYSHIT[13]));
    MapInsert(&IniListe, Option("holyshit14"       , "", "", "", NULL, &HOLYSHIT[14]));
    MapInsert(&IniListe, Option("holyshit15"       , "", "", "", NULL, &HOLYSHIT[15]));

    VarListe.clear();
    MapInsert(&VarListe, Option("idassault"        , "", "", "", NULL, &idASSAULT));
    MapInsert(&VarListe, Option("idbackstab"       , "", "", "", NULL, &idBACKSTAB));
    MapInsert(&VarListe, Option("idbash"           , "", "", "", NULL, &idBASH));
    MapInsert(&VarListe, Option("idbattleleap"     , "", "", "", NULL, &idBATTLELEAP));
    MapInsert(&VarListe, Option("idbvivi"          , "", "", "", NULL, &idBVIVI));
    MapInsert(&VarListe, Option("idbleed"          , "", "", "", NULL, &idBLEED));
    MapInsert(&VarListe, Option("idboastful"       , "", "", "", NULL, &idBOASTFUL));
    MapInsert(&VarListe, Option("idbegging"        , "", "", "", NULL, &idBEGGING));
    MapInsert(&VarListe, Option("idASP"            , "", "", "", NULL, &idASP));
    MapInsert(&VarListe, Option("idcallchallenge"  , "", "", "", NULL, &idCALLCHALLENGE));
    MapInsert(&VarListe, Option("idcstrike"        , "", "", "", NULL, &idCSTRIKE));
    MapInsert(&VarListe, Option("idcommanding"     , "", "", "", NULL, &idCOMMANDING));
    MapInsert(&VarListe, Option("idCRIPPLE"        , "", "", "", NULL, &idCRIPPLE));
    MapInsert(&VarListe, Option("idcryhavoc"       , "", "", "", NULL, &idCRYHAVOC));
    MapInsert(&VarListe, Option("iddefense"        , "", "", "", NULL, &idDEFENSE));
    MapInsert(&VarListe, Option("iddisarm"         , "", "", "", NULL, &idDISARM));
    MapInsert(&VarListe, Option("iddragonpunch"    , "", "", "", NULL, &idDRAGONPUNCH));
    MapInsert(&VarListe, Option("ideaglestrike"    , "", "", "", NULL, &idEAGLESTRIKE));
    MapInsert(&VarListe, Option("ideyegouge"       , "", "", "", NULL, &idEYEGOUGE));
    MapInsert(&VarListe, Option("idescape"         , "", "", "", NULL, &idESCAPE));
    MapInsert(&VarListe, Option("idferalswipe"     , "", "", "", NULL, &idFERALSWIPE));
    MapInsert(&VarListe, Option("idfieldarm"       , "", "", "", NULL, &idFIELDARM));
    MapInsert(&VarListe, Option("idfistsofwu"      , "", "", "", NULL, &idFISTSOFWU));
    MapInsert(&VarListe, Option("idfclaw"          , "", "", "", NULL, &idFCLAW));
    MapInsert(&VarListe, Option("idflyingkick"     , "", "", "", NULL, &idFLYINGKICK));
    MapInsert(&VarListe, Option("idforage"         , "", "", "", NULL, &idFORAGE));
    MapInsert(&VarListe, Option("idfrenzy"         , "", "", "", NULL, &idFRENZY));
    MapInsert(&VarListe, Option("idgorillasmash"   , "", "", "", NULL, &idGORILLASMASH));
    MapInsert(&VarListe, Option("idgutpunch"       , "", "", "", NULL, &idGUTPUNCH));
    MapInsert(&VarListe, Option("idharmtouch"      , "", "", "", NULL, &idHARMTOUCH));
    MapInsert(&VarListe, Option("idhide"           , "", "", "", NULL, &idHIDE));
    MapInsert(&VarListe, Option("idintimidation"   , "", "", "", NULL, &idINTIMIDATION));
    MapInsert(&VarListe, Option("idjltkicks"       , "", "", "", NULL, &ifJLTKICKS));
    MapInsert(&VarListe, Option("idjolt"           , "", "", "", NULL, &idJOLT));
    MapInsert(&VarListe, Option("idkick"           , "", "", "", NULL, &idKICK));
    MapInsert(&VarListe, Option("idkneestrike"     , "", "", "", NULL, &idKNEESTRIKE));
    MapInsert(&VarListe, Option("idlayhand"        , "", "", "", NULL, &idLAYHAND));
    MapInsert(&VarListe, Option("idleopardclaw"    , "", "", "", NULL, &idLEOPARDCLAW));
    MapInsert(&VarListe, Option("idmend"           , "", "", "", NULL, &idMEND));
    MapInsert(&VarListe, Option("idopfrenzy"       , "", "", "", NULL, &idOPFRENZY));
    MapInsert(&VarListe, Option("idpickpocket"     , "", "", "", NULL, &idPICKPOCKET));
    MapInsert(&VarListe, Option("idoppstrike"      , "", "", "", NULL, &idOPPORTUNISTICSTRIKE));
    MapInsert(&VarListe, Option("idragevolley"     , "", "", "", NULL, &idRAGEVOLLEY));
    MapInsert(&VarListe, Option("idrake"           , "", "", "", NULL, &idRAKE));
    MapInsert(&VarListe, Option("idrallos"         , "", "", "", NULL, &idRALLOS));
    MapInsert(&VarListe, Option("idravens"         , "", "", "", NULL, &idRAVENS));
    MapInsert(&VarListe, Option("idroundkick"      , "", "", "", NULL, &idROUNDKICK));
    MapInsert(&VarListe, Option("idrightidg"       , "", "", "", NULL, &idRIGHTIND));
    MapInsert(&VarListe, Option("idselos"          , "", "", "", NULL, &idSELOS));
    MapInsert(&VarListe, Option("idsensetrap"      , "", "", "", NULL, &idSENSETRAP));
    MapInsert(&VarListe, Option("idslam"           , "", "", "", NULL, &idSLAM));
    MapInsert(&VarListe, Option("idslapface"       , "", "", "", NULL, &idSLAPFACE));
    MapInsert(&VarListe, Option("idsneak"          , "", "", "", NULL, &idSNEAK));
    MapInsert(&VarListe, Option("idstrike"         , "", "", "", NULL, &idSTRIKE));
    MapInsert(&VarListe, Option("idsynergy"        , "", "", "", NULL, &idSYNERGY));
    MapInsert(&VarListe, Option("idtaunt"          , "", "", "", NULL, &idTAUNT));
    MapInsert(&VarListe, Option("idthroatjab"      , "", "", "", NULL, &idTHROATJAB));
    MapInsert(&VarListe, Option("idthiefeye"       , "", "", "", NULL, &idTHIEFEYE));
    MapInsert(&VarListe, Option("idthrowstone"     , "", "", "", NULL, &idTHROWSTONE));
    MapInsert(&VarListe, Option("idtigerclaw"      , "", "", "", NULL, &idTIGERCLAW));
    MapInsert(&VarListe, Option("idvig"            , "", "", "", NULL, &idVIG));
    MapInsert(&VarListe, Option("idwithstand"      , "", "", "", NULL, &idWITHSTAND));
    MapInsert(&VarListe, Option("idfeign0"         , "", "", "", NULL, &idFEIGN[0]));
    MapInsert(&VarListe, Option("idfeign1"         , "", "", "", NULL, &idFEIGN[1]));
    MapInsert(&VarListe, Option("idpetmend"        , "", "", "", NULL, &idPETMEND));
    MapInsert(&VarListe, Option("idpothealfast"    , "", "", "", NULL, &idPOTHEALFAST));
    MapInsert(&VarListe, Option("idpothealover"    , "", "", "", NULL, &idPOTHEALOVER));
    MapInsert(&VarListe, Option("idprovoke0"       , "", "", "", NULL, &idPROVOKE[0]));
    MapInsert(&VarListe, Option("idprovoke1"       , "", "", "", NULL, &idPROVOKE[1]));
    MapInsert(&VarListe, Option("idstun0"          , "", "", "", NULL, &idSTUN[0]));
    MapInsert(&VarListe, Option("idstun1"          , "", "", "", NULL, &idSTUN[1]));

    ZeroMemory(ColorArray,sizeof(ColorArray));
    ColorArray[13]   = true; // Attack/AutoFire/Enrage/Infuriate
    ColorArray[265]  = true; // Hits Target
    ColorArray[267]  = true; // Miss Target
    ColorArray[266]  = true; // Hits me
    ColorArray[268]  = true; // Miss me
    ColorArray[270]  = true; // Failed Hide/Sneak
    ColorArray[273]  = true; // Failed FD????
    ColorArray[288]  = true; // Target begin to cast
    ColorArray[289]  = true; // Spells results, broken fd
    ColorArray[306]  = true; // NPC Enrage/Infuriate
    ColorArray[328]  = true; // Pet Hits Target
    ColorArray[337]  = true; // Pet Messages

    ZeroMemory(AttackArray,sizeof(AttackArray));
    AttackArray[0]   = true;
    AttackArray[1]   = true;
    AttackArray[2]   = true;
    AttackArray[3]   = true;
    AttackArray[4]   = true;
    AttackArray[5]   = true; // hit with main hand
    AttackArray[6]   = true;
    AttackArray[7]   = true;
    AttackArray[8]   = true; // punch
    AttackArray[9]   = true;
    AttackArray[10]  = true;
    AttackArray[11]  = true;
    AttackArray[12]  = true; // hit with offhand
    AttackArray[42]  = true; // casting type 1
    AttackArray[43]  = true; // casting type 2
    AttackArray[44]  = true; // casting type 3
    AttackArray[80]  = true; // attacking
    AttackArray[129] = true; // attacking
    AttackArray[144] = true; // attacking

    ZeroMemory(IdlingArray,sizeof(IdlingArray));
    IdlingArray[26]  = true; // mezzed maybe?
    IdlingArray[32]  = true; // sitting
    IdlingArray[71]  = true; // standing after sitting
    IdlingArray[110] = true; // standing still

    SaveIndx    = 0;
    pMeleeEvent = new Blech('#');

    ZeroMemory(SaveList,sizeof(SaveList));
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("Auto fire off#*#"                                                     , AUTOFIREOFF  , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("Auto fire on#*#"                                                      , AUTOFIREON   , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#Attacking #*# Master.#*#"                                          , PETATTK      , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#Sorry#*#calming down.#*#"                                          , PETBACK      , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#Waiting for your order to attack, Master.#*#"                      , PETHOLD      , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#Now Holding#*#I will not attack until ordered.#*#"                 , PETHOLD      , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*# begins casting a spell#*#"                                        , CASTING      , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*# begins to cast#*#"                                                , CASTING      , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*# has become ENRAGED#*#"                                            , ENRAGEON     , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*# is no longer enraged#*#"                                          , ENRAGEOFF    , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*# is infuriated#*#"                                                 , INFURIATEON  , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*# no longer infuriated#*#"                                          , INFURIATEOFF , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*# has fallen to the ground#*#"                                      , FALLEN       , (void *)1);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#You are no longer feigning death#*#"                               , BROKEN       , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#Your body aches from a wave of pain#*#"                            , BROKEN       , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#The strength of your will allows you to resume feigning death#*#"  , RESUME       , (void *)0); 

    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#You failed to hide yourself#*#"                                    , HIDEOFF      , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#You stop hiding#*#"                                                , HIDEOFF      , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#You have moved and are no longer hidden#*#"                        , HIDEOFF      , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#You have hidden yourself from view#*#"                             , HIDEON       , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#You are as quiet as a herd of running elephants#*#"                , SNEAKOFF     , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#You stop sneaking#*#"                                              , SNEAKOFF     , (void *)0);
    SaveList[SaveIndx++] = pMeleeEvent->AddEvent("#*#You are as quiet as a cat stalking its prey#*#"                    , SNEAKON      , (void *)0);

    pMeleeTypes = new MQ2MeleeType;
    AddMQ2Data("Melee",    DataMelee);
    AddMQ2Data("meleemvb", datameleemvb);
    AddMQ2Data("meleemvi", datameleemvi);
    AddMQ2Data("meleemvs", datameleemvs);

    AddCommand("/enrageon",     EnrageON);
    AddCommand("/enrageoff",    EnrageOFF);
    AddCommand("/infuriateon",  InfuriateON);
    AddCommand("/infuriateoff", InfuriateOFF);
    AddCommand("/killthis",     KillThis);
    AddCommand("/melee",        Melee);
    AddCommand("/throwit",      ThrowIT);

    bMULoaded = HandleMoveUtils();
}

PLUGIN_API void SetGameState(unsigned long GameState)
{
    Bindding(GameState == GAMESTATE_INGAME);

    if (GameState == GAMESTATE_INGAME)
    {
        if (!Loaded)
        {
            Configure();
            DebugSpew("MQ2Melee SetGameState GAMESTATE_INGAME & NOT LOADED, calling Configure()");
        }
        else
        {
            DebugSpew("MQ2Melee SetGameState GAMESTATE_INGAME & LOADED=true, not calling anything");
        }
    }
    else if (GameState != GAMESTATE_LOGGINGIN)
    {
        if (Loaded)
        {
            DebugSpew("MQ2Melee SetGameState not INGAME or LOGGINGIN & LOADED=true, setting LOADED false");
            Loaded = false;
        }
        else
        {
            DebugSpew("MQ2Melee SetGameState not INGAME and *is* LOGGINGIN, not changing loaded");
        }
    }
    DebugSpew("MQ2Melee SetGameState Loaded == %s", Loaded ? "true" : "false");
}

PLUGIN_API unsigned long OnIncomingChat(char* Line, unsigned long Color)
{
    if (ColorArray[Color & 0x1FF] && doSKILL && gbInZone && pMeleeEvent)
    {
        switch(Color)
        {
        case 265:
        case 267:
            SwingHits++;
            break;
        case 266:
        case 268:
            TakenHits++;
            break;
        default:
            pMeleeEvent->Feed(Line);
        }
    }
    return 0;
}

PLUGIN_API void OnPulse()
{
    if (doSKILL && Loaded && gbInZone && SpawnMe())
    {
        if (PCHARINFO2 Me = GetCharInfo2())
        {
            if (GetCharInfo2()->Shrouded != Shrouded)
            {
                SetGameState(GAMESTATE_UNLOADING);
                SetGameState(GAMESTATE_INGAME);
            }
            if (!HiddenTimer && IsInvisible()) HiddenTimer = (unsigned long)clock();
            if (!SilentTimer && IsSneaking())  SilentTimer = (unsigned long)clock();
            Travel = SpeedRun(SpawnMe());
            if (Moving = (Travel > 0.05 || Travel < -0.05)) TimerMove = (unsigned long)clock() + delay * 5;
            Immobile = (!(MQ2Globals::gbMoving) && (!TimerMove || (unsigned long)clock() > TimerMove));
            if (doPETASSIST)
            {
                if (PSPAWNINFO Pet = SpawnPet())
                {
                    if (AttackArray[Pet->Animation & 0xFF]) PetSEEN();
                    else if (!PetOnHold && (unsigned long)clock() > PetOnAttk && IdlingArray[Pet->Animation & 0xFF]) PetBACK();
                }
            }
            if (MeleeTarg && (!pTarget || MeleeType != SpawnMask(GetSpawnID(MeleeTarg)))) Override(NULL, "");
            if ((unsigned long)clock() > MeleeTime)
            {
                MeleeTime = (unsigned long)clock() + delay;
                MeleeHandle();
            }
        }
    }
    if ((bMULoaded && !bMUPointers) || (bMUPointers && !bMULoaded))
    {
        bMULoaded = HandleMoveUtils();
    }
}

PLUGIN_API void ShutdownPlugin()
{
    SetGameState(GAMESTATE_UNLOADING);

    RemoveCommand("/enrageon");
    RemoveCommand("/enrageoff");
    RemoveCommand("/infuriateon");
    RemoveCommand("/infuriateoff");
    RemoveCommand("/killthis");
    RemoveCommand("/melee");
    RemoveCommand("/throwit");

    RemoveMQ2Data("Melee");
    RemoveMQ2Data("meleemvs");
    RemoveMQ2Data("meleemvi");
    RemoveMQ2Data("meleemvb");

    pMeleeEvent->Reset();
    delete pMeleeEvent;
    delete pMeleeTypes;

    Bindding(false);
}
