/d2bs/kolbot/tools/Party.js

https://github.com/stoicaflorian/d2bot-with-kolbot · JavaScript · 83 lines · 57 code · 17 blank · 9 comment · 19 complexity · b884e3894e88a2468162f0a41f49217b MD5 · raw file

  1. /**
  2. * @filename Party.js
  3. * @author kolton
  4. * @desc handle party procedure ingame
  5. */
  6. function main() {
  7. include("OOG.js");
  8. include("json2.js");
  9. include("common/Config.js");
  10. include("common/Cubing.js");
  11. include("common/Runewords.js");
  12. include("common/Misc.js");
  13. Config.init();
  14. var myPartyId, player, otherParty, shitList,
  15. partyTick = getTickCount();
  16. print("˙c2Party thread loaded. Mode: " + (Config.PublicMode > 1 ? "Accept" : "Invite"));
  17. if (Config.ShitList) {
  18. shitList = ShitList.read();
  19. print(shitList.length + " entries in shit list.");
  20. }
  21. // Main loop
  22. while (true) {
  23. player = getParty();
  24. if (player) {
  25. myPartyId = player.partyid;
  26. while (player.getNext()) {
  27. switch (Config.PublicMode) {
  28. case 1:
  29. if (getPlayerFlag(me.gid, player.gid, 8)) {
  30. if (Config.ShitList && shitList.indexOf(player.name) === -1) {
  31. say(player.name + " has been shitlisted.");
  32. shitList.push(player.name);
  33. ShitList.add(player.name);
  34. }
  35. if (player.partyflag === 4) {
  36. clickParty(player, 2); // cancel invitation
  37. delay(100);
  38. }
  39. break;
  40. }
  41. if (Config.ShitList && shitList.indexOf(player.name) > -1) {
  42. break;
  43. }
  44. if (player.partyflag !== 4 && player.partyid === 65535) {
  45. clickParty(player, 2);
  46. delay(100);
  47. }
  48. break;
  49. case 2:
  50. /*if (myPartyId !== 65535) {
  51. return;
  52. }*/
  53. if (player.partyid !== 65535 && player.partyid !== myPartyId) {
  54. otherParty = player.partyid;
  55. }
  56. if (player.partyflag === 2 && (!otherParty || player.partyid === otherParty) && (getTickCount() - partyTick >= 2000)) {
  57. clickParty(player, 2);
  58. delay(100);
  59. }
  60. break;
  61. }
  62. }
  63. }
  64. delay(500);
  65. }
  66. }