rendered paste body/*
* Created by Troglart
* Date: 12/15/2005
*/
using System;
using System.Collections;
using System.Timers;
using DOL.IPvP;
using DOL.GS;
using DOL.Database;
using DOL.GS.Scripts;
using DOL.Events;
using DOL.GS.PacketHandler;
using DOL.GS.SkillHandler;
using DOL.GS.Spells;
using DOL.GS.Effects;
using DOL.AI.Brain;
namespace DOL.AI.Brain
{
public class HealerBrain : StandardMobBrain
{
protected GameLiving m_Target = null;
public GameLiving CurrentTarget
{
get { return m_Target; }
set { m_Target = value; }
}
public HealerBrain()
: base()
{
ThinkInterval = 3000;
AggroRange = 1500;
AggroLevel = 100;
}
public override void Think()
{
Healer guard = Body as Healer;
if (!CanThink()) return;
CheckArea();
}
public void CheckArea()
{
Healer guard = Body as Healer;
GameLiving CurrentTarget=null;
foreach (GamePlayer closePlayer in guard.GetPlayersInRadius((ushort)AggroRange))
{
// pvp:
// if((this.GuildName!=null)&&(closePlayer.GuildName==this.GuildName))
if (GameServer.ServerRules.IsSameRealm(closePlayer, guard, true))
{
if(!(closePlayer.Alive))
{
CurrentTarget = (GameLiving)closePlayer;
break;
}
if (closePlayer.HealthPercent < 60)
{
CurrentTarget = (GameLiving)closePlayer;
break;
}
}
}
if (CurrentTarget == null)
{
foreach (GameNPC closeNPC in guard.GetPlayersInRadius((ushort)AggroRange))
{
if (closeNPC is GameSiegeWeapon) continue;
// pvp:
// if((this.GuildName!=null)&&(closeNPC.GuildName==this.GuildName))
if (GameServer.ServerRules.IsSameRealm(closeNPC, guard, true))
{
if (closeNPC.HealthPercent < 60)
{
CurrentTarget = (GameLiving)closeNPC;
break;
}
}
}
}
if (CurrentTarget != null)
{
guard.TargetObject = CurrentTarget;
if(!(CurrentTarget.Alive))
Healer.CastRezz(guard.TargetObject);
if(CurrentTarget.HealthPercent<30)
Healer.CastHeal(guard.TargetObject, 2);
if(CurrentTarget.HealthPercent<70)
Healer.CastHeal(guard.TargetObject, 1);
}
foreach(GamePlayer player in guard.GetPlayersInRadius((ushort)AggroRange))
{
// pvp:
// if((this.GuildName!=null)&&(player.GuildName=this.GuildName))
if (!(GameServer.ServerRules.IsSameRealm(player, guard, true)))
{
if ((!(guard.AttackState))&& (!(guard.IsUsingRange)) &&(player.Alive) && (!(player.IsStealthed)))
{
this.AddToAggroList(player ,player.Health);
return;
}
}
}
}
public bool IsAlivePlayersClose()
{
Healer guard = Body as Healer;
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToObject(guard, (ushort)(2000)))
{
if (!player.Alive) continue;
return true;
}
return false;
}
private void Patrol()
{
if (!IsAlivePlayersClose()) return;
Healer guard = Body as Healer;
if (guard.IsUsingRange) return;
if (guard.AttackState) return;
WalkToSpot();
}
private void WalkToSpot()
{
Healer guard = Body as Healer;
int dist = 1000;
int xoff = Util.Random(-dist, dist);
int yoff = Util.Random(-dist, dist);
guard.WalkTo((guard.SpawnX + xoff), (guard.SpawnY + yoff), (guard.SpawnZ), 60);
Random rnd = new Random(guard.ObjectID);
}
public bool CanThink()
{
Healer guard = Body as Healer;
if (guard.AttackState || //if attacking
(guard.Stun) || // or stunned
(guard.Mez) || // or mezzed
(!(guard.Alive)) || // or dead
guard.IsUsingRange
) // or is using range
return false;
return true;
}
}
}
------------------------------------------
/*
* Created by Troglart
* Date: 12/15/2005
*/
using System;
using System.Collections;
using System.Timers;
using DOL.IPvP;
using DOL.GS;
using DOL.Database;
using DOL.GS.Scripts;
using DOL.Events;
using DOL.GS.PacketHandler;
using DOL.GS.SkillHandler;
using DOL.GS.Spells;
using DOL.GS.Effects;
using DOL.AI.Brain;
namespace DOL.IPvP
{
public class Healer : GameMob
{
#region Declarations
protected GameLiving m_Target = null;
protected bool m_CanCast;
protected bool m_isUsingRange;
protected ushort m_spawnHeading;
RegionTimer RangeTimer;
#endregion
#region Acessors
public bool CanCast
{
get { return m_CanCast; }
set { m_CanCast = value; }
}
public bool IsUsingRange
{
get { return m_isUsingRange; }
set { m_isUsingRange = value; }
}
public GameLiving CurrentTarget
{
get { return m_Target; }
set { m_Target = value; }
}
#endregion
#region In-Game
public override bool AddToWorld()
{
switch (Realm)
{
case 1:
Model=50;
Name = "Cleric";
break;
case 2:
Model=50;
Name = "Healer";
break;
case 3:
Model=50;
Name = "Druid";
break;
default:
Name = "healer";
break;
}
Mana = 1000000;
IsUsingRange = false;
MaxSpeedBase = 150;
Level = 50;
GameNpcInventoryTemplate template = new GameNpcInventoryTemplate();
template.AddNPCEquipment(eInventorySlot.Cloak, 676, 43);
template.AddNPCEquipment(eInventorySlot.TorsoArmor, 58, 43);
template.AddNPCEquipment(eInventorySlot.LegsArmor, 140, 43);
template.AddNPCEquipment(eInventorySlot.ArmsArmor, 141, 43);
template.AddNPCEquipment(eInventorySlot.HandsArmor, 142, 43);
template.AddNPCEquipment(eInventorySlot.FeetArmor, 143, 43);
template.AddNPCEquipment(eInventorySlot.HeadArmor, 822, 43);
template.AddNPCEquipment(eInventorySlot.TwoHandWeapon, 19, 43);
Inventory = template.CloseTemplate();
SwitchWeapon(eActiveWeaponSlot.TwoHanded);
this.SetOwnBrain(new HealerBrain());
Brain.Start();
base.AddToWorld();
return true;
}
#endregion
#region Combat
public override int AttackSpeed(params InventoryItem[] weapon)
{
switch (ActiveWeaponSlot)
{
case eActiveWeaponSlot.TwoHanded: return (40 + (Util.Random(11))) * 100;
default: return (25 + (Util.Random(11))) * 100;
}
}
protected virtual int CanRange(RegionTimer timer)
{
CanCast = true;
IsUsingRange = false;
timer.Stop();
timer = null;
return 0;
}
public override void OnAttackedByEnemy(AttackData ad)
{
CanCast = false;
StartRangeTimer();
if ((WorldMgr.GetDistance(this, ad.Attacker) < 250) || (CanCast))
{
StartAttack(ad.Attacker);
}
return;
}
public override void StartAttack(GameObject attackTarget)
{
GameLiving Target = (GameLiving)attackTarget;
if (!Target.Alive || Target.ObjectState!=GameLiving.eObjectState.Active || Target.Realm == this.Realm ) return;
int range = WorldMgr.GetDistance(this, Target);
if (range <= 249)
base.StartAttack(attackTarget);
else
{
if (range <= 1500)
{
if((CanCast) && (!IsUsingRange))
{
switch(this.Realm)
{
case 1: //cast stun & smite
break;
case 2: //cast mezz & stun
break;
case 3: //cast dot& root
break;
default:break;
}
return;
}
else
{
StopAttack();
WalkToSpawn();
return;
}
}
}
}
public void StartRangeTimer()
{
if (RangeTimer != null)
{
RangeTimer.Stop();
}
RangeTimer = null;
RangeTimer = new RegionTimer(this, new RegionTimerCallback(CanRange), 1*1000);
}
public override void EnemyKilled(GameLiving enemy)
{
base.EnemyKilled(enemy);
if (!AttackState && !IsUsingRange)
WalkToSpawn();
IsUsingRange = false;
}
#endregion
#region Spells
public void CastDD(GameLiving target)
{
}
public void CastStun(GameLiving target)
{
}
public void CastRoot(GameLiving target)
{
}
public void CastMezz(GameLiving target)
{
}
public void CastHeal(GameObject Target, int Spell)
{
IsUsingRange = true;
GameLiving TargetObject = (GameLiving)Target;
switch(Spell)
{
case 1: //Big Heal
{
switch (this.Realm)
{
case 1:
{
LaunchSpell("Rebirth (Cleric)",50);
break;
}
case 3:
{
LaunchSpell("Regrowth Druid Spec",50);
break;
}
case 2:
{
LaunchSpell("Healer Mending Spec",50);
break;
}
default: break;
}
break;
}
case 2: // Small Heal
{
switch (this.Realm)
{
case 1:
{
LaunchSpell("Rejuvenation", 46);
break;
}
case 3:
{
LaunchSpell("Regrowth", 46);
break;
}
case 2:
{
LaunchSpell("Mending", 46);
break;
}
default: break;
}
break;
}
default: break;
}
}
public void CastRezz(GameObject Target)
{
GameLiving TargetObject = (GameLiving)Target;
if(!(TargetObject.Alive))
{
IsUsingRange = true;
LaunchSpell("Rejuvenation", 10);
}
}
public void LaunchSpell(string linename, int spellLevel)
{
Spell castSpell = null;
SpellLine castLine = null;
castLine = (SpellLine)SkillBase.GetSpellLine(linename);
IList spells = SkillBase.GetSpellList(castLine.KeyName);
foreach (Spell spell in spells)
{
if (spell.Level == spellLevel)
{
castSpell = spell;
break;
}
}
StopMoving();
TurnTo(TargetObject);
CastSpell(castSpell, castLine);
}
#endregion
}
public class IPvPHealer : Healer { }
}