Guest User

Untitled

a guest
May 7th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using DOL.AI;
  6. using DOL.AI.Brain;
  7. using DOL.GS.PacketHandler;
  8.  
  9. namespace DOL.GS
  10. {
  11. public class MobArea : GameNPC
  12. {
  13. public const string ANTI_CAMP = "ANTI_CAMP_KEY";
  14.  
  15. public override bool AddToWorld()
  16. {
  17. if (!(base.AddToWorld()))
  18. return false;
  19.  
  20. SetOwnBrain(new MobAreaBrain());
  21.  
  22. return true;
  23. }
  24.  
  25. public override bool Interact(GamePlayer player)
  26. {
  27. SMessage(player, "AGGRO RANGE = AREA RADIUS");
  28. SMessage(player, "TYPES:\n no_cast, no_style, \n anti_camp, \n safe_timer (Level = seconds), \n"+
  29. "no_target (can't target anything), \n heal (heal to full)");
  30.  
  31.  
  32. return base.Interact(player);
  33. }
  34. public void OnThink(GamePlayer player)
  35. {
  36. string check = this.Name;
  37.  
  38. if (check.Contains("no_cast"))
  39. {
  40. if (player.IsCasting)
  41. {
  42. player.StopCurrentSpellcast();
  43. SMessage(player, "You cannot cast spells here.");
  44. }
  45. }
  46. if (check.Contains("no_target"))
  47. {
  48. player.TargetObject = null;
  49. }
  50. if (check.Contains("heal"))
  51. {
  52. player.Health = player.MaxHealth;
  53. player.Mana = player.MaxMana;
  54. player.Endurance = player.MaxEndurance;
  55. }
  56. if (check.Contains("no_combat"))
  57. {
  58. player.StopAttack(true);
  59. SMessage(player, "You cannot attack here.");
  60. }
  61. if (check.Contains("safe_timer"))
  62. {
  63. if (!player.IsInvulnerableToAttack)
  64. player.StartInvulnerabilityTimer(Level, null);
  65. }
  66. if (check.Contains("anti_camp"))
  67. {
  68. if (player.TempProperties.getProperty<int>(ANTI_CAMP) <= 0)
  69. {
  70. player.TempProperties.setProperty(ANTI_CAMP, player.CurrentRegion.Time);
  71. }
  72.  
  73. if (player.TempProperties.getProperty<int>(ANTI_CAMP) >= 15000) //15 seconds
  74. {
  75. SMessage(player, "You are considered Camping a spawn. Please leave!");
  76.  
  77. //take 10% damage a second while in the anti-camp zone.
  78. player.TakeDamage(this, eDamageType.Natural, (player.MaxHealth * 10) / 100, 0);
  79. }
  80. }
  81. }
  82. public void OnLeaveArea(GamePlayer player)
  83. {
  84. player.TempProperties.removeProperty(ANTI_CAMP);
  85. }
  86.  
  87. public void SMessage(GamePlayer player, string msg)
  88. {
  89. player.Out.SendMessage(msg, eChatType.CT_Spell, eChatLoc.CL_ChatWindow);
  90. }
  91. }
  92.  
  93.  
  94. public class MobAreaBrain : StandardMobBrain
  95. {
  96. public MobAreaBrain()
  97. {
  98. }
  99.  
  100. //we think every second, no matter what.
  101. public override int ThinkInterval
  102. {
  103. get
  104. {
  105. return 1000;
  106. }
  107. set
  108. {
  109. base.ThinkInterval = value;
  110. }
  111. }
  112. public override void Think()
  113. {
  114. MobArea area = Body as MobArea;
  115.  
  116. //enter
  117. foreach (GamePlayer player in Body.GetPlayersInRadius((ushort)AggroRange))
  118. {
  119. area.OnThink(player);
  120. }
  121.  
  122. //exit
  123. int leaverange = AggroRange + 300;
  124. foreach (GamePlayer player in Body.GetPlayersInRadius((ushort)leaverange))
  125. {
  126. if (player.GetDistanceTo(Body) >= AggroRange)
  127. area.OnLeaveArea(player);
  128. }
  129. }
  130. }
  131. }
Add Comment
Please, Sign In to add comment