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

30 строки
537 B

  1. define([
  2. ], function(
  3. ) {
  4. return {
  5. type: 'chatter',
  6. chats: null,
  7. cdMax: 50,
  8. cd: 0,
  9. chance: 0.035,
  10. init: function(blueprint) {
  11. this.chats = extend(true, [], blueprint.chats);
  12. this.cd = ~~(Math.random() * this.cdMax);
  13. },
  14. update: function() {
  15. if ((this.cd == 0) && (Math.random() < this.chance)) {
  16. this.cd = this.cdMax;
  17. var pick = this.chats[~~(Math.random() * this.chats.length)];
  18. this.obj.syncer.set(false, 'chatter', 'msg', pick.msg);
  19. }
  20. else if (this.cd > 0)
  21. this.cd--;
  22. }
  23. };
  24. });