Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

224 рядки
5.2 KiB

  1. define([
  2. 'config/animations',
  3. 'items/generator',
  4. 'combat/combat'
  5. ], function(
  6. animations,
  7. itemGenerator,
  8. combat
  9. ) {
  10. return {
  11. build: function(mob, blueprint, scaleDrops, type) {
  12. var typeDefinition = blueprint[type] || blueprint;
  13. var drops = typeDefinition.drops;
  14. mob.isMob = true;
  15. mob.scaleDrops = scaleDrops;
  16. if (blueprint.nonSelectable)
  17. mob.nonSelectable = true;
  18. mob.addComponent('effects');
  19. if (type) {
  20. if (type != 'regular') {
  21. mob.effects.addEffect({
  22. type: type
  23. });
  24. mob['is' + type[0].toUpperCase() + type.substr(1)] = true;
  25. mob.baseName = mob.name;
  26. mob.name = typeDefinition.name || mob.baseName;
  27. }
  28. }
  29. mob.addComponent('stats', {
  30. values: {
  31. level: blueprint.level
  32. }
  33. });
  34. var cpnMob = mob.addComponent('mob');
  35. cpnMob.walkDistance = blueprint.walkDistance;
  36. cpnMob.hpMult = typeDefinition.hpMult;
  37. cpnMob.dmgMult = typeDefinition.dmgMult;
  38. cpnMob.grantRep = blueprint.grantRep;
  39. cpnMob.deathRep = blueprint.deathRep;
  40. var spells = extend(true, [], blueprint.spells);
  41. spells.forEach(function(s) {
  42. if (!s.animation) {
  43. if ((mob.sheetName == 'mobs') && (animations.mobs[mob.cell])) {
  44. s.animation = 'basic';
  45. }
  46. }
  47. });
  48. mob.addComponent('spellbook', {
  49. spells: spells,
  50. dmgMult: typeDefinition.dmgMult
  51. });
  52. var attackable = blueprint.attackable;
  53. if ((attackable === undefined) || (attackable === true)) {
  54. mob.addComponent('aggro', {
  55. faction: blueprint.faction
  56. });
  57. }
  58. mob.addComponent('equipment');
  59. mob.addComponent('inventory', drops);
  60. if (this.zone) {
  61. var chats = this.zone.chats;
  62. if ((chats) && (chats[mob.name.toLowerCase()])) {
  63. mob.addComponent('chatter', {
  64. chats: chats[mob.name.toLowerCase()]
  65. });
  66. }
  67. var dialogues = this.zone.dialogues;
  68. if ((dialogues) && (dialogues[mob.name.toLowerCase()])) {
  69. mob.addComponent('dialogue', {
  70. config: dialogues[mob.name.toLowerCase()]
  71. });
  72. }
  73. }
  74. if ((blueprint.properties) && (blueprint.properties.cpnTrade))
  75. mob.addComponent('trade', blueprint.properties.cpnTrade);
  76. this.scale(mob, blueprint.level);
  77. },
  78. scale: function(mob, level) {
  79. if ((mob.aggro) && (mob.aggro.list > 0))
  80. return;
  81. var drops = mob.inventory.blueprint || {};
  82. var statValues = mob.stats.values;
  83. var preferStat = ['str', 'dex', 'int'][~~(Math.random() * 3)];
  84. var elementType = ['physical', 'poison', 'frost', 'fire', 'holy', 'arcane'][~~(Math.random() * 6)];
  85. mob.equipment.unequipAll();
  86. mob.inventory.clear();
  87. var hp = 10 + (level * 120);
  88. statValues.hpMax = hp;
  89. statValues.level = level;
  90. if (!drops.blueprints) {
  91. [
  92. 'head',
  93. 'chest',
  94. 'neck',
  95. 'hands',
  96. 'waist',
  97. 'legs',
  98. 'feet',
  99. 'finger',
  100. 'trinket',
  101. 'twoHanded'
  102. ].forEach(function(slot) {
  103. var item = itemGenerator.generate({
  104. noSpell: true,
  105. level: level,
  106. slot: slot,
  107. forceStats: [preferStat]
  108. });
  109. mob.inventory.getItem(item);
  110. mob.equipment.autoEquip(item.id);
  111. }, this);
  112. } else {
  113. //TODO: Don't give the mob these items: he'll drop them anyway
  114. drops.blueprints.forEach(function(d) {
  115. var drop = extend(true, {}, d);
  116. d.level = level;
  117. mob.inventory.getItem(itemGenerator.generate(drop));
  118. }, this);
  119. }
  120. var spellCount = (mob.isRare ? 1 : 0) + (mob.isChampion ? 2 : 0);
  121. for (var i = 0; i < spellCount; i++) {
  122. var rune = itemGenerator.generate({
  123. spell: true
  124. });
  125. rune.eq = true;
  126. if (i == 0)
  127. rune.spell.cdMult = 5;
  128. mob.inventory.getItem(rune);
  129. }
  130. /*var rune = itemGenerator.generate({
  131. spell: true,
  132. spellName: 'crystal spikes',
  133. spellProperties: {
  134. radius: 4,
  135. attackTemplate: '0 x x x x x x x 0 x 1 x x x x x 1 x x x 2 x x x 2 x x x x x 3 x 3 x x x x x x x 4 x x x x x x x 3 x 3 x x x x x 2 x x x 2 x x x 1 x x x x x 1 x 0 x x x x x x x 0'
  136. }
  137. });
  138. rune.eq = true;
  139. if (i == 0)
  140. rune.spell.cdMult = 1;
  141. mob.inventory.getItem(rune);
  142. rune = itemGenerator.generate({
  143. spell: true,
  144. spellName: 'magic missile'
  145. });
  146. rune.eq = true;
  147. if (i == 0)
  148. rune.spell.cdMult = 1;
  149. mob.inventory.getItem(rune);*/
  150. var dmgMult = 4;
  151. var hpMult = 1;
  152. if (level < 10) {
  153. hpMult *= [0.005, 0.01, 0.1, 0.2, 0.5, 0.65, 0.75, 0.85, 0.95][level - 1];
  154. dmgMult *= [0.2, 0.45, 0.7, 0.8, 0.9, 0.92, 0.94, 0.96, 0.98][level - 1]
  155. }
  156. if (mob.isRare) {
  157. dmgMult *= 1.25;
  158. hpMult *= 1.25;
  159. }
  160. if (mob.isChampion) {
  161. dmgMult *= 2;
  162. hpMult *= 3;
  163. }
  164. statValues.hpMax *= hpMult;
  165. statValues.hp = statValues.hpMax;
  166. statValues.mana = statValues.manaMax;
  167. mob.spellbook.spells.forEach(function(s) {
  168. s.dmgMult = dmgMult;
  169. s.statType = preferStat;
  170. s.element = elementType;
  171. s.manaCost = 0;
  172. var damage = combat.getDamage({
  173. source: mob,
  174. target: mob,
  175. damage: (s.damage || s.healing) * (s.dmgMult || 1),
  176. cd: s.cdMax,
  177. element: s.element,
  178. statType: s.statType,
  179. statMult: s.statMult,
  180. noMitigate: false
  181. });
  182. }, this);
  183. ['hp', 'hpMax', 'mana', 'manaMax', 'level'].forEach(function(s) {
  184. mob.syncer.setObject(false, 'stats', 'values', s, statValues[s]);
  185. });
  186. }
  187. };
  188. });