WCell Wailing Caverns
Bonsoir à tous,

ceci est mon premier script il n'est pas tellement terminé mais je ne compte plus bosser dessus donc je préfère le partager.

Il y a quelques petits trucs à revoir mais je pense que c'est déjà une bonne base, je me suis basé sur ce qu'acid a fait.

[code=csharp]using WCell.Constants.Misc;
using WCell.Constants.NPCs;
using WCell.Core.Initialization;
using WCell.RealmServer.AI.Brains;
using WCell.RealmServer.GameObjects;
using WCell.RealmServer.Instances;
using WCell.RealmServer.NPCs;
using WCell.RealmServer.Spells;
using WCell.RealmServer.Entities;
using WCell.Constants.Spells;
using WCell.Constants;
using WCell.Constants.GameObjects;
using WCell.RealmServer.AI.Actions.Combat;
using System;
using WCell.Util.Graphics;

///
/// This file was automatically created, using WCell's CodeFileWriter
/// Date: 6/11/2009
///

namespace WCell.Addons.Default.Instances
{
public class WailingCaverns : DungeonInstance
{
#region General (Content)
private static NPCEntry DeviateStinglashEntry;
private static NPCEntry DeviateCreeperEntry;
private static NPCEntry DeviateSlayerEntry;
private static NPCEntry MutanustheDevourerEntry;
private static NPCEntry MadMagglishEntry;
private static NPCEntry LordCobrahnEntry;
private static NPCEntry LordPythasEntry;
private static NPCEntry LadyAnacondraEntry;
private static NPCEntry BoahnEntry;
private static NPCEntry LordSerpentisEntry;
private static NPCEntry SkumEntry;
private static NPCEntry DruidoftheFangEntry;
private static NPCEntry DeviateAdderEntry;
private static NPCEntry DeviateCrocoliskEntry;
private static NPCEntry DeviateLasherEntry;
private static NPCEntry DeviateDreadfangEntry;
private static NPCEntry DeviateViperEntry;
private static NPCEntry DeviateVenomwingEntry;
private static NPCEntry DeviateShamblerEntry;
private static NPCEntry VerdanTheEverlivingEntry;

private static Random random = null;

[Initialization]
[DependentInitialization(typeof(NPCMgr))]

public static void InitNPCs()
{
DeviateStinglashEntry = NPCMgr.GetEntry(NPCId.DeviateStinglash);
DeviateStinglashEntry.AddSpell(SpellId.Lash);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(17000, 20000), SpellId.Lash);

DeviateCreeperEntry = NPCMgr.GetEntry(NPCId.DeviateCreeper);
DeviateCreeperEntry.AddSpell(SpellId.InfectedWound);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(12000, 18000), SpellId.InfectedWound);

DeviateSlayerEntry = NPCMgr.GetEntry(NPCId.DeviateSlayer);
DeviateSlayerEntry.Activated += DeviateSlayer =>
{
((BaseBrain)DeviateSlayer.Brain).DefaultCombatAction.Strateg​y = new DeviateSlayerAttackAction(DeviateSlayer);
};

MutanustheDevourerEntry = NPCMgr.GetEntry(NPCId.MutanusTheDevourer);
SpellId[] MutanustheDevourerSpells = new SpellId[3] { SpellId.NaralexsNightmare, SpellId.Terrify, SpellId.ThundercrackRank1 };
MutanustheDevourerEntry.AddSpells(MutanustheDevourerSpells);​
SpellHandler.Apply(spell => spell.CooldownTime = 30000, MutanustheDevourerSpells[0]);
SpellHandler.Apply(spell => spell.CooldownTime = 50000, MutanustheDevourerSpells[1]);
SpellHandler.Apply(spell => { spell.TargetFlags = SpellTargetFlags.Self; spell.CooldownTime = 10000; }, MutanustheDevourerSpells[2]);

MadMagglishEntry = NPCMgr.GetEntry(NPCId.MadMagglish);
MadMagglishEntry.AddSpell(SpellId.SmokeBomb);
SpellHandler.Apply(spell => { spell.TargetFlags = SpellTargetFlags.Self; spell.CooldownTime = 9000; }, SpellId.SmokeBomb);

LordCobrahnEntry = NPCMgr.GetEntry(NPCId.LordCobrahn);
LordCobrahnEntry.BrainCreator = LordCobrahn => new LordCobrahnBrain(LordCobrahn);
LordCobrahnEntry.Activated += LordCobrahn =>
{
((BaseBrain)LordCobrahn.Brain).DefaultCombatAction.Strategy = new LordCobrahnAttackAction(LordCobrahn);
};

LordPythasEntry = NPCMgr.GetEntry(NPCId.LordPythas);
SpellId[] LordPythasSpells = new SpellId[2] { SpellId.ThunderclapRank1, SpellId.SleepRank1 };
LordPythasEntry.AddSpells(LordPythasSpells);
SpellHandler.Apply(spell => { spell.TargetFlags = SpellTargetFlags.Self; spell.CooldownTime = random.Next(6000, 11000); }, LordPythasSpells[0]);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(12000, 20000), LordPythasSpells[1]);
LordPythasEntry.BrainCreator = LordPythas => new LordPythasBrain(LordPythas);
LordPythasEntry.Activated += LordPythas =>
{
((BaseBrain)LordPythas.Brain).DefaultCombatAction.Strategy = new LordPythasAttackAction(LordPythas);
};

LadyAnacondraEntry = NPCMgr.GetEntry(NPCId.LadyAnacondra);
LadyAnacondraEntry.AddSpell(SpellId.SleepRank1);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(12000, 25000), SpellId.SleepRank1);
LadyAnacondraEntry.BrainCreator = LadyAnacondra => new LadyAnacondraBrain(LadyAnacondra);
LadyAnacondraEntry.Activated += LadyAnacondra =>
{
((BaseBrain)LadyAnacondra.Brain).DefaultCombatAction.Strateg​y = new LadyAnacondraAttackAction(LadyAnacondra);
};

BoahnEntry = NPCMgr.GetEntry(NPCId.Boahn);
BoahnEntry.BrainCreator = Boahn => new BoahnBrain(Boahn);
BoahnEntry.Activated += Boahn =>
{
((BaseBrain)Boahn.Brain).DefaultCombatAction.Strategy = new BoahnAttackAction(Boahn);
};

LordSerpentisEntry = NPCMgr.GetEntry(NPCId.LordSerpentis);
LordSerpentisEntry.AddSpell(SpellId.SleepRank1);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(10000, 19000), SpellId.SleepRank1);
LordSerpentisEntry.BrainCreator = LordSerpentis => new LordSerpentisBrain(LordSerpentis);
LordSerpentisEntry.Activated += LordSerpentis =>
{
((BaseBrain)LordSerpentis.Brain).DefaultCombatAction.Strateg​y = new LordSerpentisAttackAction(LordSerpentis);
};

SkumEntry = NPCMgr.GetEntry(NPCId.Skum);
SkumEntry.AddSpell(SpellId.ChainedBolt);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(4000, 6000), SpellId.ChainedBolt);

DruidoftheFangEntry = NPCMgr.GetEntry(NPCId.DruidOfTheFang);
DruidoftheFangEntry.BrainCreator = DruidoftheFang => new DruidoftheFangBrain(DruidoftheFang);
DruidoftheFangEntry.Activated += DruidoftheFang =>
{
((BaseBrain)DruidoftheFang.Brain).DefaultCombatAction.Strate​gy = new DruidoftheFangAttackAction(DruidoftheFang);
};

DeviateAdderEntry = NPCMgr.GetEntry(NPCId.DeviateAdder);
DeviateAdderEntry.AddSpell(SpellId.EffectPoison);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(15000, 25000), SpellId.EffectPoison);

DeviateCrocoliskEntry = NPCMgr.GetEntry(NPCId.DeviateCrocolisk);
DeviateCrocoliskEntry.AddSpell(SpellId.TendonRip);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(10000, 12000), SpellId.TendonRip);

DeviateLasherEntry = NPCMgr.GetEntry(NPCId.DeviateLasher);
DeviateLasherEntry.AddSpell(SpellId.WideSlashRank1);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(8000, 12000), SpellId.WideSlashRank1);

DeviateDreadfangEntry = NPCMgr.GetEntry(NPCId.DeviateDreadfang);
DeviateDreadfangEntry.AddSpell(SpellId.Terrify);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(20000, 25000), SpellId.Terrify);

DeviateViperEntry = NPCMgr.GetEntry(NPCId.DeviateViper);
DeviateViperEntry.AddSpell(SpellId.LocalizedToxin);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(10000, 15000), SpellId.LocalizedToxin);

DeviateVenomwingEntry = NPCMgr.GetEntry(NPCId.DeviateVenomwing);
DeviateVenomwingEntry.AddSpell(SpellId.ToxicSpit);
SpellHandler.Apply(spell => spell.CooldownTime = random.Next(8000, 10000), SpellId.ToxicSpit);

DeviateShamblerEntry = NPCMgr.GetEntry(NPCId.DeviateShambler);
DeviateShamblerEntry.Activated += DeviateShambler =>
{
((BaseBrain)DeviateShambler.Brain).DefaultCombatAction.Strat​egy = new DeviateShamblerAttackAction(DeviateShambler);
};

VerdanTheEverlivingEntry = NPCMgr.GetEntry(NPCId.VerdanTheEverliving);
VerdanTheEverlivingEntry.AddSpell(SpellId.GraspingVines);
SpellHandler.Apply(spell => { spell.TargetFlags = SpellTargetFlags.Self; spell.CooldownTime = random.Next(10000, 13000); }, SpellId.GraspingVines);
}
#endregion

#region Deviate Slayer
public class DeviateSlayerAttackAction : AIAttackAction
{
internal static Spell FatalBite;

private DateTime timeSinceLastInterval;
private const int interVal = 1;
private int FatalBiteTick;

[Initialization(InitializationPass.Second)]
static void InitDeviateSlayer()
{
FatalBite = SpellHandler.Get(SpellId.FatalBite);
}

public DeviateSlayerAttackAction(NPC DeviateSlayer)
: base(DeviateSlayer)
{
}

public override void Start()
{
timeSinceLastInterval = DateTime.Now;
base.Start();
}

public override void Update()
{
var timeNow = DateTime.Now;
var timeBetween = timeNow - timeSinceLastInterval;

if (timeBetween.TotalSeconds >= interVal)
{
timeSinceLastInterval = timeNow;
if (CheckSpellCast())
{
// idle a little after casting a spell
m_owner.Idle(1000);
return;
}
}

base.Update();
}

private bool CheckSpellCast()
{
FatalBiteTick++;

if (m_owner.HealthPct <= 40 && FatalBiteTick >= 10)
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
FatalBiteTick = 0;
m_owner.SpellCast.Start(FatalBite, false, chr);
}
return true;
}
return false;
}
}
#endregion

#region Lord Cobrahn
public class LordCobrahnBrain : MobBrain
{
public LordCobrahnBrain(NPC LordCobrahn)
: base(LordCobrahn)
{
}

public override void OnEnterCombat()
{
var Texts = NPCAiTextMgr.GetEntry("You will never wake the dreamer!");
var CurrentNpcText = Texts[0];
m_owner.PlaySound((uint)CurrentNpcText.Sound); (m_owner as NPC).Yell(CurrentNpcText.Texts);

m_owner.SpellCast.Start(SpellHandler.Get(SpellId.LightningBo​lt), false, m_owner.GetNearbyRandomCharacter());

base.OnEnterCombat();
}
}

public class LordCobrahnAttackAction : AIAttackAction
{
internal static Spell CobrahnSerpentForm, DruidsSlumber, LightningBolt, Poison;

private DateTime timeSinceLastInterval;
private const int interVal = 1;
private int phase = 1;
private bool isCastCobrahnSerpentForm = false;
private int DruidsSlumberTick;
private int LightningBoltTick;
private int PoisonTick;

[Initialization(InitializationPass.Second)]
static void InitLordCobhahn()
{
CobrahnSerpentForm = SpellHandler.Get(SpellId.CobrahnSerpentForm);
DruidsSlumber = SpellHandler.Get(SpellId.DruidsSlumber);
LightningBolt = SpellHandler.Get(SpellId.LightningBolt);
Poison = SpellHandler.Get(SpellId.EffectPoison);
}

public LordCobrahnAttackAction(NPC LordCobrahn)
: base(LordCobrahn)
{
}

public override void Start()
{
timeSinceLastInterval = DateTime.Now;
base.Start();
}

public override void Update()
{
var timeNow = DateTime.Now;
var timeBetween = timeNow - timeSinceLastInterval;

if (m_owner.HealthPct <= 30) { phase = 3; }
if (m_owner.IsEvading) { phase = 0; }

if (timeBetween.TotalSeconds >= interVal)
{
timeSinceLastInterval = timeNow;
if (CheckSpellCast())
{
// idle a little after casting a spell
m_owner.Idle(1000);
return;
}
}

base.Update();
}

private bool CheckSpellCast()
{
DruidsSlumberTick++;
LightningBoltTick++;
PoisonTick++;

if (phase == 1)
{
if ((100 * m_owner.Power) / m_owner.MaxPower <= 15) { phase = 2; }

if (LightningBoltTick >= random.Next(2, 4))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
LightningBoltTick = 0;
m_owner.SpellCast.Start(LightningBolt, false, chr);
return true;
}
}

if (PoisonTick >= random.Next(12, 20))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
PoisonTick = 0;
m_owner.SpellCast.Start(Poison, false, chr);
return true;
}
}
}

else if (phase == 2)
{
if ((100 * m_owner.Power) / m_owner.MaxPower >= 30) { phase = 1; }

if (PoisonTick >= random.Next(12, 20))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
PoisonTick = 0;
m_owner.SpellCast.Start(Poison, false, chr);
return true;
}
}
}

else if (phase == 3)
{
if (!isCastCobrahnSerpentForm)
{
if (m_owner != null)
{
isCastCobrahnSerpentForm = true;
m_owner.SpellCast.Trigger(CobrahnSerpentForm);
return true;
}
}

if (DruidsSlumberTick >= random.Next(13, 20))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
DruidsSlumberTick = 0;
m_owner.SpellCast.Start(DruidsSlumber, false, chr);
return true;
}
}
}
return false;
}
}
#endregion

#region Lord Pythas
public class LordPythasBrain : MobBrain
{
public LordPythasBrain(NPC LordPythas)
: base(LordPythas)
{
}

public override void OnEnterCombat()
{
var Texts = NPCAiTextMgr.GetEntry("The coils of death... Will crush you.");
var CurrentNpcText = Texts[0];
m_owner.PlaySound((uint)CurrentNpcText.Sound); (m_owner as NPC).Yell(CurrentNpcText.Texts);

m_owner.SpellCast.Start(SpellHandler.Get(SpellId.LightningBo​lt), false, m_owner.GetNearbyRandomCharacter());

base.OnEnterCombat();
}
}

public class LordPythasAttackAction : AIAttackAction
{
internal static Spell HealingTouch, LightningBolt;

private DateTime timeSinceLastInterval;
private const int interVal = 1;
private int phase = 1;
private int HealingTouchTick;
private int LightningBoltTick;

[Initialization(InitializationPass.Second)]
static void InitLordPythas()
{
HealingTouch = SpellHandler.Get(SpellId.ClassSkillHealingTouchRank3);
LightningBolt = SpellHandler.Get(SpellId.LightningBolt);
}

public LordPythasAttackAction(NPC LordPythas)
: base(LordPythas)
{
}

public override void Start()
{
timeSinceLastInterval = DateTime.Now;
base.Start();
}

public override void Update()
{
var timeNow = DateTime.Now;
var timeBetween = timeNow - timeSinceLastInterval;

if (m_owner.IsEvading) { phase = 0; }

if (timeBetween.TotalSeconds >= interVal)
{
timeSinceLastInterval = timeNow;
if (CheckSpellCast())
{
// idle a little after casting a spell
m_owner.Idle(1000);
return;
}
}

base.Update();
}

private bool CheckSpellCast()
{
HealingTouchTick++;
LightningBoltTick++;

if (phase == 1)
{
if ((100 * m_owner.Power) / m_owner.MaxPower <= 15) { phase = 2; }

if (LightningBoltTick >= random.Next(2, 4))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
LightningBoltTick = 0;
m_owner.SpellCast.Start(LightningBolt, false, chr);
return true;
}
}
}

if (phase == 2)
{
if ((100 * m_owner.Power) / m_owner.MaxPower >= 30) { phase = 1; }
}

if (m_owner.HealthPct <= 50 && HealingTouchTick >= random.Next(20, 25))
{
if (m_owner != null)
{
HealingTouchTick = 0;
m_owner.SpellCast.Start(HealingTouch, false, m_owner);
return true;
}
}
return false;
}
}
#endregion

#region Lady Anacondra
public class LadyAnacondraBrain : MobBrain
{
public LadyAnacondraBrain(NPC LadyAnacondra)
: base(LadyAnacondra)
{
}

public override void OnEnterCombat()
{
var Texts = NPCAiTextMgr.GetEntry("None can stand against the serpent lords!");
var CurrentNpcText = Texts[0];
m_owner.PlaySound((uint)CurrentNpcText.Sound); (m_owner as NPC).Yell(CurrentNpcText.Texts);

m_owner.SpellCast.Start(SpellHandler.Get(SpellId.ThornsAura_​2), false, m_owner.GetNearbyRandomCharacter());
m_owner.SpellCast.Start(SpellHandler.Get(SpellId.LightningBo​lt), false, m_owner.GetNearbyRandomCharacter());

base.OnEnterCombat();
}
}

public class LadyAnacondraAttackAction : AIAttackAction
{
internal static Spell HealingTouch, LightningBolt;

private DateTime timeSinceLastInterval;
private const int interVal = 1;
private int phase = 1;
private bool isCastHealingTouch = false;
private int LightiningBoltTick;

[Initialization(InitializationPass.Second)]
static void InitLadyAnacondra()
{
HealingTouch = SpellHandler.Get(SpellId.ClassSkillHealingTouchRank3);
LightningBolt = SpellHandler.Get(SpellId.LightningBolt);
}

public LadyAnacondraAttackAction(NPC LadyAnacondra)
: base(LadyAnacondra)
{
}

public override void Start()
{
timeSinceLastInterval = DateTime.Now;
base.Start();
}

public override void Update()
{
var timeNow = DateTime.Now;
var timeBetween = timeNow - timeSinceLastInterval;

if (m_owner.HealthPct <= 15) { phase = 3; }
if (m_owner.IsEvading) { phase = 0; }

if (timeBetween.TotalSeconds >= interVal)
{
timeSinceLastInterval = timeNow;
if (CheckSpellCast())
{
// idle a little after casting a spell
m_owner.Idle(1000);
return;
}
}

base.Update();
}

private bool CheckSpellCast()
{
LightiningBoltTick++;

if (phase == 1)
{
if ((100 * m_owner.Power) / m_owner.MaxPower <= 15) { phase = 2; }

if (LightiningBoltTick >= random.Next(2, 4))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
LightiningBoltTick = 0;
m_owner.SpellCast.Start(LightningBolt, false, chr);
return true;
}
}
}

if (phase == 2)
{
if ((100 * m_owner.Power) / m_owner.MaxPower >= 30) { phase = 1; }
}

if (phase == 3) {}

if (!isCastHealingTouch && m_owner.HealthPct <= 50)
{
if (m_owner != null)
{
isCastHealingTouch = true;
m_owner.SpellCast.Trigger(HealingTouch);
return true;
}
}
return false;
}
}
#endregion

#region Boahn
public class BoahnBrain : MobBrain
{
public BoahnBrain(NPC Boahn)
: base(Boahn)
{
}

public override void OnEnterCombat()
{
m_owner.SpellCast.Start(SpellHandler.Get(SpellId.LightningBo​lt), false, m_owner.GetNearbyRandomCharacter());

base.OnEnterCombat();
}
}

public class BoahnAttackAction : AIAttackAction
{
internal static Spell LightningBolt, HealingTouch;

private DateTime timeSinceLastInterval;
private const int interVal = 1;
private int phase = 1;
private int LightningBoltTick;
private int HealingTouchTick;

[Initialization(InitializationPass.Second)]
static void InitBoahn()
{
LightningBolt = SpellHandler.Get(SpellId.LightningBolt);
HealingTouch = SpellHandler.Get(SpellId.ClassSkillHealingTouchRank3);
}

public BoahnAttackAction(NPC Boahn)
: base(Boahn)
{
}

public override void Start()
{
timeSinceLastInterval = DateTime.Now;
base.Start();
}

public override void Update()
{
var timeNow = DateTime.Now;
var timeBetween = timeNow - timeSinceLastInterval;

if (m_owner.HealthPct <= 15) { phase = 3; }
if (m_owner.IsEvading) { phase = 0; }

if (timeBetween.TotalSeconds >= interVal)
{
timeSinceLastInterval = timeNow;
if (CheckSpellCast())
{
// idle a little after casting a spell
m_owner.Idle(1000);
return;
}
}

base.Update();
}

private bool CheckSpellCast()
{
LightningBoltTick++;
HealingTouchTick++;

if (phase == 1)
{
if ((100 * m_owner.Power) / m_owner.MaxPower <= 15) { phase = 2; }

if (LightningBoltTick >= random.Next(2, 4))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
LightningBoltTick = 0;
m_owner.SpellCast.Start(LightningBolt, false, chr);
return true;
}
}
}

if (phase == 2)
{
if ((100 * m_owner.Power) / m_owner.MaxPower >= 30) { phase = 1; }
}

if (m_owner.HealthPct <= 40 && HealingTouchTick >= random.Next(30, 40))
{
if (m_owner != null)
{
HealingTouchTick = 0;
m_owner.SpellCast.Trigger(HealingTouch);
return true;
}
}
return false;
}
}
#endregion

#region Lord Serpentis
public class LordSerpentisBrain : MobBrain
{
public LordSerpentisBrain(NPC LordSerpentis)
: base(LordSerpentis)
{
}

public override void OnEnterCombat()
{
var Texts = NPCAiTextMgr.GetEntry("I am the serpent king, I can do anything.");
var CurrentNpcText = Texts[0];
m_owner.PlaySound((uint)CurrentNpcText.Sound); (m_owner as NPC).Yell(CurrentNpcText.Texts);

m_owner.SpellCast.Start(SpellHandler.Get(SpellId.LightningBo​lt), false, m_owner.GetNearbyRandomCharacter());

base.OnEnterCombat();
}
}

public class LordSerpentisAttackAction : AIAttackAction
{
internal static Spell HealingTouch, LightningBolt;

private DateTime timeSinceLastInterval;
private const int interVal = 1;
private int phase = 1;
private bool isCastHealingTouch = false;
private int LightningBoltTick;

[Initialization(InitializationPass.Second)]
static void InitLordSerpentis()
{
HealingTouch = SpellHandler.Get(SpellId.ClassSkillHealingTouchRank6);
LightningBolt = SpellHandler.Get(SpellId.LightningBolt);
}

public LordSerpentisAttackAction(NPC LordSerpentis)
: base(LordSerpentis)
{
}

public override void Start()
{
timeSinceLastInterval = DateTime.Now;
base.Start();
}

public override void Update()
{
var timeNow = DateTime.Now;
var timeBetween = timeNow - timeSinceLastInterval;

if (m_owner.IsEvading) { phase = 0; }

if (timeBetween.TotalSeconds >= interVal)
{
timeSinceLastInterval = timeNow;
if (CheckSpellCast())
{
// idle a little after casting a spell
m_owner.Idle(1000);
return;
}
}

base.Update();
}

private bool CheckSpellCast()
{
LightningBoltTick++;

if (phase == 1)
{
if ((100 * m_owner.Power) / m_owner.MaxPower <= 15) { phase = 2; }

if (LightningBoltTick >= random.Next(2, 4))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
LightningBoltTick = 0;
m_owner.SpellCast.Start(LightningBolt, false, chr);
return true;
}
}
}

if (phase == 2)
{
if ((100 * m_owner.Power) / m_owner.MaxPower >= 30) { phase = 1; }
}

if (!isCastHealingTouch && m_owner.HealthPct <= 50)
{
if (m_owner != null)
{
isCastHealingTouch = true;
m_owner.SpellCast.Trigger(HealingTouch);
return true;
}
}
return false;
}
}
#endregion

#region Druid of the Fang
public class DruidoftheFangBrain : MobBrain
{
public DruidoftheFangBrain(NPC DruidoftheFang)
: base(DruidoftheFang)
{
}

public override void OnEnterCombat()
{
m_owner.SpellCast.Start(SpellHandler.Get(SpellId.LightningBo​lt), false, m_owner.GetNearbyRandomCharacter());

base.OnEnterCombat();
}
}

public class DruidoftheFangAttackAction : AIAttackAction
{
internal static Spell LightningBolt, DruidsSlumber, HealingTouch, SerpentForm;

private DateTime timeSinceLastInterval;
private const int interVal = 1;
private int phase = 1;
private int LightningBoltTick;
private int DruidsSlumberTick;
private int HealingTouchTick;
private int SerpentFormTick;

[Initialization(InitializationPass.Second)]
static void InitDruidoftheFang()
{
LightningBolt = SpellHandler.Get(SpellId.LightningBolt);
DruidsSlumber = SpellHandler.Get(SpellId.DruidsSlumber);
HealingTouch = SpellHandler.Get(SpellId.ClassSkillHealingTouchRank3);
SerpentForm = SpellHandler.Get(SpellId.SerpentFormShapeshift);
}

public DruidoftheFangAttackAction(NPC DruidoftheFang)
: base(DruidoftheFang)
{
}

public override void Start()
{
timeSinceLastInterval = DateTime.Now;
base.Start();
}

public override void Update()
{
var timeNow = DateTime.Now;
var timeBetween = timeNow - timeSinceLastInterval;

if (m_owner.HealthPct <= 50) { phase = 3; }
if (m_owner.IsEvading) { phase = 0; }

if (timeBetween.TotalSeconds >= interVal)
{
timeSinceLastInterval = timeNow;
if (CheckSpellCast())
{
// idle a little after casting a spell
m_owner.Idle(1000);
return;
}
}

base.Update();
}

private bool CheckSpellCast()
{
LightningBoltTick++;
DruidsSlumberTick++;
HealingTouchTick++;
SerpentFormTick++;

if (phase == 1)
{
if ((100 * m_owner.Power) / m_owner.MaxPower <= 15) { phase = 2; }

if (LightningBoltTick >= random.Next(2, 4))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
LightningBoltTick = 0;
m_owner.SpellCast.Start(LightningBolt, false, chr);
return true;
}
}

if (DruidsSlumberTick >= random.Next(10, 20))
{
var chr = m_owner.GetNearbyRandomCharacter();
if (chr != null)
{
DruidsSlumberTick = 0;
m_owner.SpellCast.Start(DruidsSlumber, false, chr);
return true;
}
}

if (HealingTouchTick >= random.Next(12, 18))
{
var chr = m_owner.GetRandomAlliedUnit(40);
if (chr != null && chr.Health <= chr.MaxHealth - 450)
{
HealingTouchTick = 0;
m_owner.SpellCast.Start(HealingTouch, false, chr);
return true;
}
}
}

else if (phase == 2)
{
if ((100 * m_owner.Power) / m_owner.MaxPower >= 30) { phase = 1; }
}

else if (phase == 3)
{
if (SerpentFormTick >= random.Next(20, 25))
{
if (m_owner != null)
{
SerpentFormTick = 0;
m_owner.SpellCast.Start(SerpentForm, false, m_owner);
return true;
}
}
}
return false;
}
}
#endregion

#region Deviate Shambler
public class DeviateShamblerAttackAction : AIAttackAction
{
internal static Spell WildRegeneration;

private DateTime timeSinceLastInterval;
private const int interVal = 1;
private int WildRegenerationTick;

[Initialization(InitializationPass.Second)]
static void InitDeviateShambler()
{
WildRegeneration = SpellHandler.Get(SpellId.WildRegeneration);
}

public DeviateShamblerAttackAction(NPC DeviateShambler)
: base(DeviateShambler)
{
}

public override void Start()
{
timeSinceLastInterval = DateTime.Now;
base.Start();
}

public override void Update()
{
var timeNow = DateTime.Now;
var timeBetween = timeNow - timeSinceLastInterval;

if (timeBetween.TotalSeconds >= interVal)
{
timeSinceLastInterval = timeNow;
if (CheckSpellCast())
{
// idle a little after casting a spell
m_owner.Idle(1000);
return;
}
}

base.Update();
}

private bool CheckSpellCast()
{
WildRegenerationTick++;

if (m_owner.HealthPct <= 70 && WildRegenerationTick >= 21)
{
if (m_owner != null)
{
WildRegenerationTick = 0;
m_owner.SpellCast.Start(WildRegeneration, false, m_owner);
return true;
}
}
return false;
}
}
#endregion
}
}[/code]

sur Pastebin
Mea culpa. Tu as raison, je me suis fourvoyé!
http://msdn.microsoft.com/en-us/library/k2604h5s.aspx

Ça m'apprendras à me coucher à des heures pas possible et donc à dire n'importe quoi! x)

--
C'est beau Smile Comparé a moi x) Par contre , petit conseil , il faudrait faire tes incrémentations comme ça :

++tavariable;

C'est plus rapide Clin
Le nom de tes NPCEntry doit commencer par une minuscule.
(26-05-2010 17:16)Skynyrd a écrit :  Le nom de tes NPCEntry doit commencer par une minuscule.

Personnellement je préfère comme ça, si tu préfère avec une minuscule fais le mais ce n'est en aucun cas une erreur.
In C# we always use PascalCase for all publicly accessible members of a class or namespace and camelCase for all local variables
-> var myLocalVariable = someObj.SomePublicProperty;
-> class X { public int Y; }

Tiré du Wiki : http://wiki.wcell.org/index.php?title=Coding_Guide

Il y a des règles et ce n'est pas pour rien Smile

Retourner en haut Accueil