Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DOL.AI;
- using DOL.AI.Brain;
- using DOL.GS.PacketHandler;
- namespace DOL.GS
- {
- public class MobArea : GameNPC
- {
- public const string ANTI_CAMP = "ANTI_CAMP_KEY";
- public override bool AddToWorld()
- {
- if (!(base.AddToWorld()))
- return false;
- SetOwnBrain(new MobAreaBrain());
- return true;
- }
- public override bool Interact(GamePlayer player)
- {
- SMessage(player, "AGGRO RANGE = AREA RADIUS");
- SMessage(player, "TYPES:\n no_cast, no_style, \n anti_camp, \n safe_timer (Level = seconds), \n"+
- "no_target (can't target anything), \n heal (heal to full)");
- return base.Interact(player);
- }
- public void OnThink(GamePlayer player)
- {
- string check = this.Name;
- if (check.Contains("no_cast"))
- {
- if (player.IsCasting)
- {
- player.StopCurrentSpellcast();
- SMessage(player, "You cannot cast spells here.");
- }
- }
- if (check.Contains("no_target"))
- {
- player.TargetObject = null;
- }
- if (check.Contains("heal"))
- {
- player.Health = player.MaxHealth;
- player.Mana = player.MaxMana;
- player.Endurance = player.MaxEndurance;
- }
- if (check.Contains("no_combat"))
- {
- player.StopAttack(true);
- SMessage(player, "You cannot attack here.");
- }
- if (check.Contains("safe_timer"))
- {
- if (!player.IsInvulnerableToAttack)
- player.StartInvulnerabilityTimer(Level, null);
- }
- if (check.Contains("anti_camp"))
- {
- if (player.TempProperties.getProperty<int>(ANTI_CAMP) <= 0)
- {
- player.TempProperties.setProperty(ANTI_CAMP, player.CurrentRegion.Time);
- }
- if (player.TempProperties.getProperty<int>(ANTI_CAMP) >= 15000) //15 seconds
- {
- SMessage(player, "You are considered Camping a spawn. Please leave!");
- //take 10% damage a second while in the anti-camp zone.
- player.TakeDamage(this, eDamageType.Natural, (player.MaxHealth * 10) / 100, 0);
- }
- }
- }
- public void OnLeaveArea(GamePlayer player)
- {
- player.TempProperties.removeProperty(ANTI_CAMP);
- }
- public void SMessage(GamePlayer player, string msg)
- {
- player.Out.SendMessage(msg, eChatType.CT_Spell, eChatLoc.CL_ChatWindow);
- }
- }
- public class MobAreaBrain : StandardMobBrain
- {
- public MobAreaBrain()
- {
- }
- //we think every second, no matter what.
- public override int ThinkInterval
- {
- get
- {
- return 1000;
- }
- set
- {
- base.ThinkInterval = value;
- }
- }
- public override void Think()
- {
- MobArea area = Body as MobArea;
- //enter
- foreach (GamePlayer player in Body.GetPlayersInRadius((ushort)AggroRange))
- {
- area.OnThink(player);
- }
- //exit
- int leaverange = AggroRange + 300;
- foreach (GamePlayer player in Body.GetPlayersInRadius((ushort)leaverange))
- {
- if (player.GetDistanceTo(Body) >= AggroRange)
- area.OnLeaveArea(player);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment