Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

56 строки
1.1 KiB

  1. define([
  2. ], function (
  3. ) {
  4. return {
  5. type: 'chatter',
  6. chats: null,
  7. cdMax: 50,
  8. cd: 0,
  9. chance: 0.035,
  10. global: false,
  11. init: function (blueprint) {
  12. this.chats = extend(true, [], blueprint.chats);
  13. this.cd = ~~(Math.random() * this.cdMax);
  14. for (var p in blueprint) {
  15. if (p == 'chats')
  16. continue;
  17. this[p] = blueprint[p];
  18. }
  19. },
  20. update: function () {
  21. if ((this.obj.aggro) && (this.obj.aggro.list.length > 0))
  22. return;
  23. else if (this.chats.length == 0)
  24. return;
  25. if ((this.cd == 0) && (Math.random() < this.chance)) {
  26. this.cd = this.cdMax;
  27. var pick = this.chats[~~(Math.random() * this.chats.length)];
  28. if (!this.global)
  29. this.obj.syncer.set(false, 'chatter', 'msg', pick.msg);
  30. else {
  31. //HACK
  32. //This shouldn't always be pink, but only events use this atm so it's fine
  33. this.obj.instance.syncer.queue('onGetMessages', {
  34. messages: {
  35. class: 'color-pinkB',
  36. message: this.obj.name + ': ' + pick.msg
  37. }
  38. });
  39. }
  40. } else if (this.cd > 0)
  41. this.cd--;
  42. }
  43. };
  44. });