You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

84 lines
1.3 KiB

  1. module.exports = {
  2. type: 'cocoon',
  3. cocoon: null,
  4. persist: true,
  5. init: function (source) {
  6. let obj = this.obj;
  7. let syncO = obj.syncer.o;
  8. obj.hidden = true;
  9. obj.nonSelectable = true;
  10. syncO.hidden = true;
  11. syncO.nonSelectable = true;
  12. this.cocoon = obj.instance.objects.buildObjects([{
  13. name: 'cocoon',
  14. sheetName: 'objects',
  15. cell: 54,
  16. x: obj.x,
  17. y: obj.y,
  18. properties: {
  19. cpnAggro: {
  20. faction: source.aggro.faction
  21. },
  22. cpnStats: {
  23. values: {
  24. hpMax: 10,
  25. hp: 10
  26. }
  27. },
  28. cpnEffects: {}
  29. }
  30. }]);
  31. this.cocoon.effects.addEffect({
  32. events: {
  33. afterDeath: this.onDestroyCocoon.bind(this)
  34. }
  35. });
  36. },
  37. onDestroyCocoon: function () {
  38. this.destroyed = true;
  39. },
  40. destroy: function () {
  41. let obj = this.obj;
  42. let syncO = obj.syncer.o;
  43. obj.hidden = false;
  44. obj.nonSelectable = false;
  45. syncO.hidden = false;
  46. syncO.nonSelectable = false;
  47. this.cocoon.destroyed = true;
  48. },
  49. simplify: function () {
  50. return {
  51. type: 'cocoon',
  52. ttl: this.ttl
  53. };
  54. },
  55. events: {
  56. beforeMove: function (targetPos) {
  57. let obj = this.obj;
  58. targetPos.x = obj.x;
  59. targetPos.y = obj.y;
  60. },
  61. beforeDealDamage: function ({ damage }) {
  62. if (damage)
  63. damage.failed = true;
  64. },
  65. beforeCastSpell: function (successObj) {
  66. successObj.success = false;
  67. }
  68. }
  69. };