//wowGetLootables() return all lootable corpses near me
//wowRunTo(x,y,timeoutInSeconds, noFreeFight, reachTo)  timeoutInSeconds specifiy timeout in seconds.  noFreeFight: if 0, your toon will try to pick a fight or find herbs/mines.  if 1, reach to position without actively looking for a fight.  reachTo: default 5, specify how close to the position you want to stop.  Don't make it too small.
//wowDoLoot(corpse)

//following is example of how to check for corpses that are lootable or skinable around your toon and go loot.
var allcorps = me.wowGetLootables();
for (var i in allcorps) {
  var corp = allcorps[i];  
  if (corp.lootable || corp.skinable) {
    var x = (me.x - corp.x);
    var y = (me.y - corp.y);
    var dist = Math.sqrt(  x*x + y*y );
    if (dist < me.itemLootDist) {
      me.wowRunTo(corp.x, corp.y, 6, 1);
      me.wowDoLoot(corp);
    }
  }
}





//// the following code is to use waypoint notes:
if (me.waypointNoteComment != "") {
    //stop at noted waypoint and turn to recorded angle.
    me.wowStopRun();
    me.wowTurnToRad(me.waypointNoteHeading);
}



//emulate press key x down then up
me.wowSendKey(me.wowGetKeyCode("x"), 1);   
me.wowSleep(100);
me.wowSendKey(me.wowGetKeyCode("x"), 0);



//play sound
me.wowPlaySound("whisper.wav");



//fishing
var res = me.wowDoFishing();
if (res) me.wowLog("Caught Fish");


//combat
me.wowOneFight();


//execute a file and read it's output and return code:
      var procHandle = me.wowExec("screencapture.exe","D:\\images",true);      
      var reads = me.wowExecReadOutput(procHandle);
      me.wowLog("exec returns " + reads);
      var ret = me.wowExecRetVal(procHandle);
      me.wowLog("return value " + ret);



//get list of npc's near you
for (var i = 0; i < me.toonCount; i++) {
    var npc = me.wowGetToon(i);
    me.wowLog(npc.name);
}


//turn to a npc (npc is obtained in the above example
   me.wowTurnTo(npc.x,npc.y);


//move mouse
      me.wowMoveMouse(213+me.wowScreenX, 561+me.wowScreenY);

//click mouse
      me.wowMouseClick(0);  //0 is left, default is right


//get/send from sockets.
var sockets = me.wowGetRemoteSockets();
 
  for (var i in cmbMsgs) {
    me.wowLog("combatlog " + cmbMsgs[i]);
    for (var j in sockets) {
      me.wowSendRemoteMsg(sockets[j], cmbMsgs[i]+"\r\n");
    }
  }
 
for (var i in sockets) {
    var remoteCommand = me.wowGetRemoteMsg(sockets[i]);
    if (remoteCommand != "") {
      me.wowLog("Got remote command " + remoteCommand);
      if (remoteCommand = "screenshoot") {
        me.wowExec("d:\\screencap.exe");
      }
    }
  }






/// v0.9.7.10 

//send a talk string via clipboard.
me.wowTalkViaClipboard("got to go");

//send the string again by enter, past, enter again.
me.wowSendString("\n");
me.wowSendKeys(0x11, 86,1); //control char and V char.
me.wowSendKeys(0x11, 86,0);
me.wowSendString("\n");


var ary = me.wowGetBuffs(); //get list of my buffs

var hasBuf = me.wowGetBuff(110); //returns true if player has that buf



// var ary = me.wowGetAttackingMobs();  //return mobs that are attacking you in an array
// var ary = me.wowGetTagingPlayers();  //return players that are checking on you (have you selected) in an array.



  //just an example.  if it is after fight, and not enough mana, and my level >40, execute darkpact.
  //Note, you must define it correctly in your config file
  //if (me.curState == "afterFight") {
    //wowClassName is the <name> part of bindings_<name>.cfg, forexample, bindings_afwarlock.cfg, wowClassName is afworlock.
  //  if (me.wowClassName.indexOf("warlock") >= 0) {
  //    var manaPrecent = me.mana/me.maxmana;
  //    if (manaPrecent < 0.8) {
  //      if (me.level > 40) {
  //        me.wowDoFightAction("darkpact");
  //      }
  //    }
  //  }
  //}

  // if you specify SRVPORT:# in settings.txt file, you can telnet to that port and issue commands (enter to send a line).
  // and you can accept them here and do some special processing.
  //var rmtMsg = me.wowGetRemoteMsg();
  //if (rmtMsg != null) {
  //  me.wowLog("got Remote Msg " + rmtMsg);    
  //  me.wowSendRemoteMsg("OK");
  //}

  

  /////////////// Examples of how to check bullets for hunter
  //var free = me.wowGetContainerFreeSlots();
  //var arrows = me.wowGetAllContainerItemCount("YourArrowNameHere");
  //me.wowLog("free slot " + free + " arrows " + arrows);
  //if (arrows == 0) {
  //   doStone();
  //}

  ///////////////  example of how to check if your main weapon is going bad.
  //var mainWeapon = me.wowGetContainerItemByName("MainWeapon");
  //if (mainWeapon != null) {
  //  me.wowLog("weapon Durability " + mainWeapon.itemDurability+" max "+ mainWeapon.itemMaxDurability);
  //  if (mainWeapon.itemDurability == 0) 
  //  {
  //    doStone();
  //  }
  //} else me.wowLog("Can't find item");


  ///////////////  example of how to get players near you
  //var playersNearMe = me.wowGetPlayers();
  //for (var i in playersNearMe) {
  //  var player = playersNearMe[i];
  //  if (player != null) {
  //    me.wowLog("player " + player.name + " pos " + player.x+" "+player.y);
  //  }
  //}

  //me.wowSendString(" ");
  //me.wowSendString("\nhahahaha\n");
  //me.wowClearMsgs();  //clear out messages sot the build 

  //if (count > 2) {
  //  me.wowBotStop();
  //}

  
//me.wowLog("number of messages " + me.numMsgs);


  //play sound if there are messages, commented out, use DTK's message only
  //if (me.numMsgs > 0) {
  //  me.wowPlaySound("msg.wav");
  //}