Advertisement
Guest User

Untitled

a guest
Mar 11th, 2024
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. using System;
  2. using Server;
  3. using Server.Items;
  4. using Server.Mobiles;
  5. using Server.Spells;
  6. using System.Collections.Generic;
  7.  
  8. namespace Server.Mobiles
  9. {
  10. public class MegaDragon : BaseCreature
  11. {
  12. private DateTime m_NextBreathTime;
  13. [Constructable]
  14. public MegaDragon() : base( AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4)
  15. {
  16. Name = "MegaDragon";
  17. Body = 49; // Adjust to appropriate dragon model
  18. BaseSoundID = 362;
  19.  
  20. SetStr(1096, 1185);
  21. SetDex(86, 175);
  22. SetInt(686, 775);
  23.  
  24. SetHits(658, 711);
  25.  
  26. SetDamage(29, 35);
  27.  
  28. m_NextBreathTime = DateTime.UtcNow; // Initialize the cooldown
  29.  
  30. // Adjust skills, stats, and resistances as needed
  31. }
  32.  
  33. public override void OnThink()
  34. {
  35. base.OnThink();
  36.  
  37. // Example trigger for the special attack, adjust as needed
  38. if (Combatant != null && DateTime.UtcNow >= m_NextBreathTime)
  39. {
  40. BreathSpecialAttack();
  41. m_NextBreathTime = DateTime.UtcNow + TimeSpan.FromSeconds(5);
  42. }
  43. }
  44.  
  45. public void BreathSpecialAttack()
  46. {
  47. Map map = this.Map;
  48.  
  49. if (map == null)
  50. return;
  51.  
  52. Direction d = this.Direction;
  53. int range = 10; // Range of the attack in tiles
  54. int damage = 30; // Damage for the breath attack
  55. List<Point3D> targets = new List<Point3D>();
  56.  
  57. // Calculate offsets based on the dragon's direction
  58. int dx = 0, dy = 0;
  59. switch (d & Direction.Mask)
  60. {
  61. case Direction.North:
  62. dy = -1;
  63. break;
  64. case Direction.East:
  65. dx = 1;
  66. break;
  67. case Direction.South:
  68. dy = 1;
  69. break;
  70. case Direction.West:
  71. dx = -1;
  72. break;
  73. // Include cases for other directions if needed (e.g., down, left, up, right)
  74. case Direction.Right: // North-East
  75. dx = 1;
  76. dy = -1;
  77. break;
  78. case Direction.Down: // South-East
  79. dx = 1;
  80. dy = 1;
  81. break;
  82. case Direction.Left: // South-West
  83. dx = -1;
  84. dy = 1;
  85. break;
  86. case Direction.Up: // North-West
  87. dx = -1;
  88. dy = -1;
  89. break;
  90. }
  91.  
  92. for (int i = 1; i <= range; i++)
  93. {
  94. int perpendicularRange = i;
  95. int baseX = this.X + i * dx;
  96. int baseY = this.Y + i * dy;
  97.  
  98. for (int j = -perpendicularRange; j <= perpendicularRange; j++)
  99. {
  100. int targetX = baseX;
  101. int targetY = baseY;
  102.  
  103. if (Math.Abs(dx) != Math.Abs(dy))
  104. {
  105. // Handling cardinal directions (North, East, South, West)
  106. if (dx == 0)
  107. {
  108. targetX += j;
  109. }
  110. else if (dy == 0)
  111. {
  112. targetY += j;
  113. }
  114. }
  115. else
  116. {
  117. // Handling intercardinal directions (NE, SE, SW, NW)
  118. if (dx * dy > 0) // Moving in SE or NW direction
  119. {
  120. targetX += j;
  121. targetY -= j; // Invert the increment for one axis to spread perpendicularly
  122. }
  123. else // Moving in NE or SW direction
  124. {
  125. targetX += j;
  126. targetY += j; // Both axes increment in the same direction for NE and SW
  127. }
  128. }
  129.  
  130. if (map.CanFit(targetX, targetY, this.Z, 16, false, false))
  131. targets.Add(new Point3D(targetX, targetY, this.Z));
  132. else
  133. {
  134. int targetZ = map.GetAverageZ(targetX, targetY);
  135. if (map.CanFit(targetX, targetY, targetZ, 16, false, false))
  136. targets.Add(new Point3D(targetX, targetY, targetZ));
  137. }
  138. }
  139. }
  140.  
  141. foreach (Point3D p in targets)
  142. {
  143. int flameHue = 2543; // Set this to the hue value you want for the flamestrike effect.
  144. Effects.SendLocationEffect(p, map, 0x36BD, 16, 10, flameHue, 0); // Flamestrike animation
  145. IPooledEnumerable eable = map.GetMobilesInRange(p, 0); // Only target mobiles in the same tile
  146. foreach (Mobile m in eable)
  147. {
  148. if (m is PlayerMobile || m is BaseCreature)
  149. {
  150. // We can check if the mobile is a friend or foe before applying damage
  151. // This example will damage all mobiles, but you could check for allegiances or factions as needed
  152. m.Damage(damage, this);
  153. }
  154. }
  155. eable.Free(); // Always free the enumerable when done to avoid memory leaks
  156. }
  157. }
  158.  
  159.  
  160. public MegaDragon(Serial serial) : base(serial)
  161. {
  162. }
  163.  
  164. public override void Serialize(GenericWriter writer)
  165. {
  166. base.Serialize(writer);
  167. writer.Write((int)0);
  168. }
  169.  
  170. public override void Deserialize(GenericReader reader)
  171. {
  172. base.Deserialize(reader);
  173. int version = reader.ReadInt();
  174. }
  175. }
  176. }
  177.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement