Implement generic script loaders to greatly reduce code duplication

This commit is contained in:
hondacrx
2017-07-20 19:43:24 -04:00
parent 19220d29d9
commit 2db988576a
89 changed files with 28255 additions and 36473 deletions
+82 -122
View File
@@ -155,63 +155,53 @@ namespace Scripts.World.BossEmeraldDragons
}
[Script]
class npc_dream_fog : CreatureScript
class npc_dream_fog : ScriptedAI
{
public npc_dream_fog() : base("npc_dream_fog") { }
class npc_dream_fogAI : ScriptedAI
public npc_dream_fog(Creature creature) : base(creature)
{
public npc_dream_fogAI(Creature creature) : base(creature)
{
Initialize();
}
Initialize();
}
void Initialize()
{
_roamTimer = 0;
}
void Initialize()
{
_roamTimer = 0;
}
public override void Reset()
{
Initialize();
}
public override void Reset()
{
Initialize();
}
public override void UpdateAI(uint diff)
{
if (!UpdateVictim())
return;
public override void UpdateAI(uint diff)
{
if (!UpdateVictim())
return;
if (_roamTimer == 0)
if (_roamTimer == 0)
{
// Chase target, but don't attack - otherwise just roam around
Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true);
if (target)
{
// Chase target, but don't attack - otherwise just roam around
Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true);
if (target)
{
_roamTimer = RandomHelper.URand(15000, 30000);
me.GetMotionMaster().Clear(false);
me.GetMotionMaster().MoveChase(target, 0.2f);
}
else
{
_roamTimer = 2500;
me.GetMotionMaster().Clear(false);
me.GetMotionMaster().MoveRandom(25.0f);
}
// Seeping fog movement is slow enough for a player to be able to walk backwards and still outpace it
me.SetWalk(true);
me.SetSpeedRate(UnitMoveType.Walk, 0.75f);
_roamTimer = RandomHelper.URand(15000, 30000);
me.GetMotionMaster().Clear(false);
me.GetMotionMaster().MoveChase(target, 0.2f);
}
else
_roamTimer -= diff;
{
_roamTimer = 2500;
me.GetMotionMaster().Clear(false);
me.GetMotionMaster().MoveRandom(25.0f);
}
// Seeping fog movement is slow enough for a player to be able to walk backwards and still outpace it
me.SetWalk(true);
me.SetSpeedRate(UnitMoveType.Walk, 0.75f);
}
uint _roamTimer;
else
_roamTimer -= diff;
}
public override CreatureAI GetAI(Creature creature)
{
return new npc_dream_fogAI(creature);
}
uint _roamTimer;
}
[Script]
@@ -334,36 +324,26 @@ namespace Scripts.World.BossEmeraldDragons
}
[Script]
class npc_spirit_shade : CreatureScript
class npc_spirit_shade : PassiveAI
{
public npc_spirit_shade() : base("npc_spirit_shade") { }
public npc_spirit_shade(Creature creature) : base(creature) { }
class npc_spirit_shadeAI : PassiveAI
public override void IsSummonedBy(Unit summoner)
{
public npc_spirit_shadeAI(Creature creature) : base(creature) { }
public override void IsSummonedBy(Unit summoner)
{
_summonerGuid = summoner.GetGUID();
me.GetMotionMaster().MoveFollow(summoner, 0.0f, 0.0f);
}
public override void MovementInform(MovementGeneratorType moveType, uint data)
{
if (moveType == MovementGeneratorType.Follow && data == _summonerGuid.GetCounter())
{
me.CastSpell((Unit)null, Spells.DarkOffering, false);
me.DespawnOrUnsummon(1000);
}
}
ObjectGuid _summonerGuid;
_summonerGuid = summoner.GetGUID();
me.GetMotionMaster().MoveFollow(summoner, 0.0f, 0.0f);
}
public override CreatureAI GetAI(Creature creature)
public override void MovementInform(MovementGeneratorType moveType, uint data)
{
return new npc_spirit_shadeAI(creature);
if (moveType == MovementGeneratorType.Follow && data == _summonerGuid.GetCounter())
{
me.CastSpell((Unit)null, Spells.DarkOffering, false);
me.DespawnOrUnsummon(1000);
}
}
ObjectGuid _summonerGuid;
}
[Script]
@@ -547,75 +527,55 @@ namespace Scripts.World.BossEmeraldDragons
}
[Script]
class spell_dream_fog_sleep : SpellScriptLoader
class spell_dream_fog_sleep : SpellScript
{
public spell_dream_fog_sleep() : base("spell_dream_fog_sleep") { }
class spell_dream_fog_sleep_SpellScript : SpellScript
void FilterTargets(List<WorldObject> targets)
{
void FilterTargets(List<WorldObject> targets)
targets.RemoveAll(obj =>
{
targets.RemoveAll(obj =>
{
Unit unit = obj.ToUnit();
if (unit)
return unit.HasAura(Spells.Sleep);
return true;
});
}
public override void Register()
{
OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy));
}
Unit unit = obj.ToUnit();
if (unit)
return unit.HasAura(Spells.Sleep);
return true;
});
}
public override SpellScript GetSpellScript()
public override void Register()
{
return new spell_dream_fog_sleep_SpellScript();
OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy));
}
}
[Script]
class spell_mark_of_nature : SpellScriptLoader
class spell_mark_of_nature : SpellScript
{
public spell_mark_of_nature() : base("spell_mark_of_nature") { }
class spell_mark_of_nature_SpellScript : SpellScript
public override bool Validate(SpellInfo spellInfo)
{
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(Spells.MarkOfNature, Spells.AuraOfNature);
}
void FilterTargets(List<WorldObject> targets)
{
targets.RemoveAll(obj =>
{
// return those not tagged or already under the influence of Aura of Nature
Unit unit = obj.ToUnit();
if (unit)
return !(unit.HasAura(Spells.MarkOfNature) && !unit.HasAura(Spells.AuraOfNature));
return true;
});
}
void HandleEffect(uint effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit().CastSpell(GetHitUnit(), Spells.AuraOfNature, true);
}
public override void Register()
{
OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy));
OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 0, SpellEffectName.ApplyAura));
}
return ValidateSpellInfo(Spells.MarkOfNature, Spells.AuraOfNature);
}
public override SpellScript GetSpellScript()
void FilterTargets(List<WorldObject> targets)
{
return new spell_mark_of_nature_SpellScript();
targets.RemoveAll(obj =>
{
// return those not tagged or already under the influence of Aura of Nature
Unit unit = obj.ToUnit();
if (unit)
return !(unit.HasAura(Spells.MarkOfNature) && !unit.HasAura(Spells.AuraOfNature));
return true;
});
}
void HandleEffect(uint effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit().CastSpell(GetHitUnit(), Spells.AuraOfNature, true);
}
public override void Register()
{
OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy));
OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 0, SpellEffectName.ApplyAura));
}
}
}
+1 -1
View File
@@ -107,7 +107,7 @@ namespace Scripts.World
if (onStartDuel)
{
// remove cooldowns on spells that have < 10 min CD > 30 sec and has no onHold
player.GetSpellHistory().ResetCooldowns(pair =>
player.GetSpellHistory().ResetCooldowns(pair =>
{
DateTime now = DateTime.Now;
uint cooldownDuration = pair.Value.CooldownEnd > now ? (uint)(pair.Value.CooldownEnd - now).TotalMilliseconds : 0;
+1 -6
View File
@@ -313,7 +313,7 @@ namespace Scripts.World
{
FactionTemplateRecord pFaction = creature.GetFactionTemplateEntry();
if (pFaction != null)
{
{
uint Spell = 0;
switch (pFaction.Faction)
@@ -737,11 +737,6 @@ namespace Scripts.World
return false;
}
}
public override GameObjectAI GetAI(GameObject go)
{
return new go_soulwellAI(go);
}
}
[Script] //go_dragonflayer_cage
+241 -271
View File
@@ -47,336 +47,306 @@ namespace Scripts.World
}
[Script]
class guard_generic : CreatureScript
class guard_generic : GuardAI
{
public guard_generic() : base("guard_generic") { }
public guard_generic(Creature creature) : base(creature) { }
class guard_genericAI : GuardAI
public override void Reset()
{
public guard_genericAI(Creature creature) : base(creature) { }
globalCooldown = 0;
buffTimer = 0;
}
public override void Reset()
{
public override void EnterCombat(Unit who)
{
if (me.GetEntry() == CreatureIds.CenarionHoldIndantry)
Talk(GuardsConst.SaySilAggro, who);
SpellInfo spell = me.reachWithSpellAttack(who);
if (spell != null)
DoCast(who, spell.Id);
}
public override void UpdateAI(uint diff)
{
//Always decrease our global cooldown first
if (globalCooldown > diff)
globalCooldown -= diff;
else
globalCooldown = 0;
buffTimer = 0;
}
public override void EnterCombat(Unit who)
//Buff timer (only buff when we are alive and not in combat
if (me.IsAlive() && !me.IsInCombat())
{
if (me.GetEntry() == CreatureIds.CenarionHoldIndantry)
Talk(GuardsConst.SaySilAggro, who);
SpellInfo spell = me.reachWithSpellAttack(who);
if (spell != null)
DoCast(who, spell.Id);
}
public override void UpdateAI(uint diff)
{
//Always decrease our global cooldown first
if (globalCooldown > diff)
globalCooldown -= diff;
else
globalCooldown = 0;
//Buff timer (only buff when we are alive and not in combat
if (me.IsAlive() && !me.IsInCombat())
if (buffTimer <= diff)
{
if (buffTimer <= diff)
{
//Find a spell that targets friendly and applies an aura (these are generally buffs)
SpellInfo info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Aura);
//Find a spell that targets friendly and applies an aura (these are generally buffs)
SpellInfo info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Aura);
if (info != null && globalCooldown == 0)
{
//Cast the buff spell
if (info != null && globalCooldown == 0)
{
//Cast the buff spell
DoCast(me, info.Id);
//Set our global cooldown
globalCooldown = GuardsConst.CreatureCooldown;
//Set our timer to 10 minutes before rebuff
buffTimer = 600000;
} //Try again in 30 seconds
else buffTimer = 30000;
}
else buffTimer -= diff;
}
//Return since we have no target
if (!UpdateVictim())
return;
// Make sure our attack is ready and we arn't currently casting
if (me.isAttackReady() && !me.IsNonMeleeSpellCast(false))
{
//If we are within range melee the target
if (me.IsWithinMeleeRange(me.GetVictim()))
{
bool healing = false;
SpellInfo info = null;
//Select a healing spell if less than 30% hp
if (me.HealthBelowPct(30))
info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Healing);
//No healing spell available, select a hostile spell
if (info != null)
healing = true;
else
info = SelectSpell(me.GetVictim(), 0, 0, SelectTargetType.AnyEnemy, 0, 0, SelectEffect.DontCare);
//20% chance to replace our white hit with a spell
if (info != null && RandomHelper.IRand(0, 99) < 20 && globalCooldown == 0)
{
//Cast the spell
if (healing)
DoCast(me, info.Id);
else
DoCastVictim(info.Id);
//Set our global cooldown
globalCooldown = GuardsConst.CreatureCooldown;
//Set our timer to 10 minutes before rebuff
buffTimer = 600000;
} //Try again in 30 seconds
else buffTimer = 30000;
//Set our global cooldown
globalCooldown = GuardsConst.CreatureCooldown;
}
else buffTimer -= diff;
else
me.AttackerStateUpdate(me.GetVictim());
me.resetAttackTimer();
}
//Return since we have no target
if (!UpdateVictim())
return;
// Make sure our attack is ready and we arn't currently casting
if (me.isAttackReady() && !me.IsNonMeleeSpellCast(false))
}
else
{
//Only run this code if we arn't already casting
if (!me.IsNonMeleeSpellCast(false))
{
//If we are within range melee the target
if (me.IsWithinMeleeRange(me.GetVictim()))
bool healing = false;
SpellInfo info = null;
//Select a healing spell if less than 30% hp ONLY 33% of the time
if (me.HealthBelowPct(30) && 33 > RandomHelper.IRand(0, 99))
info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Healing);
//No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE)
if (info != null)
healing = true;
else
info = SelectSpell(me.GetVictim(), 0, 0, SelectTargetType.AnyEnemy, SharedConst.NominalMeleeRange, 0, SelectEffect.DontCare);
//Found a spell, check if we arn't on cooldown
if (info != null && globalCooldown == 0)
{
bool healing = false;
SpellInfo info = null;
//Select a healing spell if less than 30% hp
if (me.HealthBelowPct(30))
info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Healing);
//No healing spell available, select a hostile spell
if (info != null)
healing = true;
else
info = SelectSpell(me.GetVictim(), 0, 0, SelectTargetType.AnyEnemy, 0, 0, SelectEffect.DontCare);
//20% chance to replace our white hit with a spell
if (info != null && RandomHelper.IRand(0, 99) < 20 && globalCooldown == 0)
//If we are currently moving stop us and set the movement generator
if (me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Idle)
{
//Cast the spell
if (healing)
DoCast(me, info.Id);
else
DoCastVictim(info.Id);
//Set our global cooldown
globalCooldown = GuardsConst.CreatureCooldown;
}
else
me.AttackerStateUpdate(me.GetVictim());
me.resetAttackTimer();
}
}
else
{
//Only run this code if we arn't already casting
if (!me.IsNonMeleeSpellCast(false))
{
bool healing = false;
SpellInfo info = null;
//Select a healing spell if less than 30% hp ONLY 33% of the time
if (me.HealthBelowPct(30) && 33 > RandomHelper.IRand(0, 99))
info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Healing);
//No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE)
if (info != null)
healing = true;
else
info = SelectSpell(me.GetVictim(), 0, 0, SelectTargetType.AnyEnemy, SharedConst.NominalMeleeRange, 0, SelectEffect.DontCare);
//Found a spell, check if we arn't on cooldown
if (info != null && globalCooldown == 0)
{
//If we are currently moving stop us and set the movement generator
if (me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Idle)
{
me.GetMotionMaster().Clear(false);
me.GetMotionMaster().MoveIdle();
}
//Cast spell
if (healing)
DoCast(me, info.Id);
else
DoCastVictim(info.Id);
//Set our global cooldown
globalCooldown = GuardsConst.CreatureCooldown;
} //If no spells available and we arn't moving run to target
else if (me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Chase)
{
//Cancel our current spell and then mutate new movement generator
me.InterruptNonMeleeSpells(false);
me.GetMotionMaster().Clear(false);
me.GetMotionMaster().MoveChase(me.GetVictim());
me.GetMotionMaster().MoveIdle();
}
//Cast spell
if (healing)
DoCast(me, info.Id);
else
DoCastVictim(info.Id);
//Set our global cooldown
globalCooldown = GuardsConst.CreatureCooldown;
} //If no spells available and we arn't moving run to target
else if (me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Chase)
{
//Cancel our current spell and then mutate new movement generator
me.InterruptNonMeleeSpells(false);
me.GetMotionMaster().Clear(false);
me.GetMotionMaster().MoveChase(me.GetVictim());
}
}
DoMeleeAttackIfReady();
}
public void DoReplyToTextEmote(TextEmotes emote)
{
switch (emote)
{
case TextEmotes.Kiss:
me.HandleEmoteCommand(Emote.OneshotBow);
break;
case TextEmotes.Wave:
me.HandleEmoteCommand(Emote.OneshotWave);
break;
case TextEmotes.Salute:
me.HandleEmoteCommand(Emote.OneshotSalute);
break;
case TextEmotes.Shy:
me.HandleEmoteCommand(Emote.OneshotFlex);
break;
case TextEmotes.Rude:
case TextEmotes.Chicken:
me.HandleEmoteCommand(Emote.OneshotPoint);
break;
}
}
public override void ReceiveEmote(Player player, TextEmotes textEmote)
{
switch (me.GetEntry())
{
case CreatureIds.StormwindCityGuard:
case CreatureIds.StormwindCityPatroller:
case CreatureIds.OrgimmarGrunt:
break;
default:
return;
}
if (!me.IsFriendlyTo(player))
return;
DoReplyToTextEmote(textEmote);
}
uint globalCooldown;
uint buffTimer;
DoMeleeAttackIfReady();
}
public override CreatureAI GetAI(Creature creature)
public void DoReplyToTextEmote(TextEmotes emote)
{
return new guard_genericAI(creature);
switch (emote)
{
case TextEmotes.Kiss:
me.HandleEmoteCommand(Emote.OneshotBow);
break;
case TextEmotes.Wave:
me.HandleEmoteCommand(Emote.OneshotWave);
break;
case TextEmotes.Salute:
me.HandleEmoteCommand(Emote.OneshotSalute);
break;
case TextEmotes.Shy:
me.HandleEmoteCommand(Emote.OneshotFlex);
break;
case TextEmotes.Rude:
case TextEmotes.Chicken:
me.HandleEmoteCommand(Emote.OneshotPoint);
break;
}
}
public override void ReceiveEmote(Player player, TextEmotes textEmote)
{
switch (me.GetEntry())
{
case CreatureIds.StormwindCityGuard:
case CreatureIds.StormwindCityPatroller:
case CreatureIds.OrgimmarGrunt:
break;
default:
return;
}
if (!me.IsFriendlyTo(player))
return;
DoReplyToTextEmote(textEmote);
}
uint globalCooldown;
uint buffTimer;
}
[Script]
class guard_shattrath_scryer : CreatureScript
class guard_shattrath_scryer : GuardAI
{
public guard_shattrath_scryer() : base("guard_shattrath_scryer") { }
public guard_shattrath_scryer(Creature creature) : base(creature) { }
class guard_shattrath_scryerAI : GuardAI
public override void Reset()
{
public guard_shattrath_scryerAI(Creature creature) : base(creature) { }
playerGUID.Clear();
canTeleport = false;
public override void Reset()
_scheduler.Schedule(TimeSpan.FromSeconds(5), task =>
{
playerGUID.Clear();
canTeleport = false;
_scheduler.Schedule(TimeSpan.FromSeconds(5), task =>
Unit temp = me.GetVictim();
if (temp && temp.IsTypeId(TypeId.Player))
{
Unit temp = me.GetVictim();
if (temp && temp.IsTypeId(TypeId.Player))
{
DoCast(temp, Spells.BanishedA);
playerGUID = temp.GetGUID();
if (!playerGUID.IsEmpty())
canTeleport = true;
DoCast(temp, Spells.BanishedA);
playerGUID = temp.GetGUID();
if (!playerGUID.IsEmpty())
canTeleport = true;
task.Repeat(TimeSpan.FromSeconds(9));
}
});
task.Repeat(TimeSpan.FromSeconds(9));
}
});
_scheduler.Schedule(TimeSpan.FromSeconds(8.5), task =>
{
if (canTeleport)
{
Unit temp = Global.ObjAccessor.GetUnit(me, playerGUID);
if (temp)
{
temp.CastSpell(temp, Spells.Exile, true);
temp.CastSpell(temp, Spells.BanishTeleport, true);
}
playerGUID.Clear();
canTeleport = false;
task.Repeat();
}
});
}
public override void UpdateAI(uint diff)
_scheduler.Schedule(TimeSpan.FromSeconds(8.5), task =>
{
if (!UpdateVictim())
return;
if (canTeleport)
{
Unit temp = Global.ObjAccessor.GetUnit(me, playerGUID);
if (temp)
{
temp.CastSpell(temp, Spells.Exile, true);
temp.CastSpell(temp, Spells.BanishTeleport, true);
}
playerGUID.Clear();
canTeleport = false;
_scheduler.Update(diff);
DoMeleeAttackIfReady();
}
ObjectGuid playerGUID;
bool canTeleport;
task.Repeat();
}
});
}
public override CreatureAI GetAI(Creature creature)
public override void UpdateAI(uint diff)
{
return new guard_shattrath_scryerAI(creature);
if (!UpdateVictim())
return;
_scheduler.Update(diff);
DoMeleeAttackIfReady();
}
ObjectGuid playerGUID;
bool canTeleport;
}
[Script]
class guard_shattrath_aldor : CreatureScript
class guard_shattrath_aldor : GuardAI
{
public guard_shattrath_aldor() : base("guard_shattrath_aldor") { }
public guard_shattrath_aldor(Creature creature) : base(creature) { }
class guard_shattrath_aldorAI : GuardAI
public override void Reset()
{
public guard_shattrath_aldorAI(Creature creature) : base(creature) { }
playerGUID.Clear();
canTeleport = false;
public override void Reset()
_scheduler.Schedule(TimeSpan.FromSeconds(5), task =>
{
playerGUID.Clear();
canTeleport = false;
_scheduler.Schedule(TimeSpan.FromSeconds(5), task =>
Unit temp = me.GetVictim();
if (temp && temp.IsTypeId(TypeId.Player))
{
Unit temp = me.GetVictim();
if (temp && temp.IsTypeId(TypeId.Player))
{
DoCast(temp, Spells.BanishedA);
playerGUID = temp.GetGUID();
if (!playerGUID.IsEmpty())
canTeleport = true;
DoCast(temp, Spells.BanishedA);
playerGUID = temp.GetGUID();
if (!playerGUID.IsEmpty())
canTeleport = true;
task.Repeat(TimeSpan.FromSeconds(9));
}
});
task.Repeat(TimeSpan.FromSeconds(9));
}
});
_scheduler.Schedule(TimeSpan.FromSeconds(8.5), task =>
{
if (canTeleport)
{
Unit temp = Global.ObjAccessor.GetUnit(me, playerGUID);
if (temp)
{
temp.CastSpell(temp, Spells.Exile, true);
temp.CastSpell(temp, Spells.BanishTeleport, true);
}
playerGUID.Clear();
canTeleport = false;
task.Repeat();
}
});
}
public override void UpdateAI(uint diff)
_scheduler.Schedule(TimeSpan.FromSeconds(8.5), task =>
{
if (!UpdateVictim())
return;
if (canTeleport)
{
Unit temp = Global.ObjAccessor.GetUnit(me, playerGUID);
if (temp)
{
temp.CastSpell(temp, Spells.Exile, true);
temp.CastSpell(temp, Spells.BanishTeleport, true);
}
playerGUID.Clear();
canTeleport = false;
_scheduler.Update(diff);
DoMeleeAttackIfReady();
}
ObjectGuid playerGUID;
bool canTeleport;
task.Repeat();
}
});
}
public override CreatureAI GetAI(Creature creature)
public override void UpdateAI(uint diff)
{
return new guard_shattrath_aldorAI(creature);
if (!UpdateVictim())
return;
_scheduler.Update(diff);
DoMeleeAttackIfReady();
}
ObjectGuid playerGUID;
bool canTeleport;
}
}
+4 -2
View File
@@ -331,9 +331,11 @@ namespace Scripts.World
{
pLeviroth.GetAI().AttackStart(player);
return false;
} else
}
else
player.SendEquipError(InventoryResult.OutOfRange, item, null);
} else
}
else
player.SendEquipError(InventoryResult.ClientLockedOut, item, null);
return true;
}
+12 -16
View File
@@ -23,25 +23,21 @@ using System;
namespace Scripts.World
{
[Script]
class trigger_periodic : CreatureScript
{
public trigger_periodic() : base("trigger_periodic") { }
class trigger_periodicAI : NullCreatureAI
class trigger_periodic : NullCreatureAI
{
public trigger_periodicAI(Creature creature) : base(creature)
public trigger_periodic(Creature creature) : base(creature)
{
var interval = me.GetBaseAttackTime(Framework.Constants.WeaponAttackType.BaseAttack);
_scheduler.Schedule(TimeSpan.FromMilliseconds(interval), task =>
{
var interval = me.GetBaseAttackTime(Framework.Constants.WeaponAttackType.BaseAttack);
_scheduler.Schedule(TimeSpan.FromMilliseconds(interval), task =>
{
me.CastSpell(me, me.m_spells[0], true);
task.Repeat(TimeSpan.FromMilliseconds(interval));
});
}
me.CastSpell(me, me.m_spells[0], true);
task.Repeat(TimeSpan.FromMilliseconds(interval));
});
}
public override void UpdateAI(uint diff)
{
_scheduler.Update();
public override void UpdateAI(uint diff)
{
_scheduler.Update();
}
}
+62 -72
View File
@@ -53,87 +53,77 @@ namespace Scripts.World
}
[Script] //start menu multi profession trainer
class npc_multi_profession_trainer : CreatureScript
class npc_multi_profession_trainer : ScriptedAI
{
public npc_multi_profession_trainer() : base("npc_multi_profession_trainer") { }
public npc_multi_profession_trainer(Creature creature) : base(creature) { }
class npc_multi_profession_trainerAI : ScriptedAI
public override void sGossipSelect(Player player, uint menuId, uint gossipListId)
{
public npc_multi_profession_trainerAI(Creature creature) : base(creature) { }
public override void sGossipSelect(Player player, uint menuId, uint gossipListId)
switch ((GossipOptionIds)gossipListId)
{
switch ((GossipOptionIds)gossipListId)
{
case GossipOptionIds.Alchemy:
case GossipOptionIds.Blacksmithing:
case GossipOptionIds.Enchanting:
case GossipOptionIds.Engineering:
case GossipOptionIds.Herbalism:
case GossipOptionIds.Inscription:
case GossipOptionIds.Jewelcrafting:
case GossipOptionIds.Leatherworking:
case GossipOptionIds.Mining:
case GossipOptionIds.Skinning:
case GossipOptionIds.Tailoring:
SendTrainerList(player, (GossipOptionIds)gossipListId);
break;
case GossipOptionIds.Multi:
case GossipOptionIds.Alchemy:
case GossipOptionIds.Blacksmithing:
case GossipOptionIds.Enchanting:
case GossipOptionIds.Engineering:
case GossipOptionIds.Herbalism:
case GossipOptionIds.Inscription:
case GossipOptionIds.Jewelcrafting:
case GossipOptionIds.Leatherworking:
case GossipOptionIds.Mining:
case GossipOptionIds.Skinning:
case GossipOptionIds.Tailoring:
SendTrainerList(player, (GossipOptionIds)gossipListId);
break;
case GossipOptionIds.Multi:
{
switch ((GossipMenuIds)menuId)
{
switch ((GossipMenuIds)menuId)
{
case GossipMenuIds.Herbalism:
SendTrainerList(player, GossipOptionIds.Herbalism);
break;
case GossipMenuIds.Mining:
SendTrainerList(player, GossipOptionIds.Mining);
break;
case GossipMenuIds.Skinning:
SendTrainerList(player, GossipOptionIds.Skinning);
break;
case GossipMenuIds.Alchemy:
SendTrainerList(player, GossipOptionIds.Alchemy);
break;
case GossipMenuIds.Blacksmithing:
SendTrainerList(player, GossipOptionIds.Blacksmithing);
break;
case GossipMenuIds.Enchanting:
SendTrainerList(player, GossipOptionIds.Enchanting);
break;
case GossipMenuIds.Engineering:
SendTrainerList(player, GossipOptionIds.Engineering);
break;
case GossipMenuIds.Inscription:
SendTrainerList(player, GossipOptionIds.Inscription);
break;
case GossipMenuIds.Jewelcrafting:
SendTrainerList(player, GossipOptionIds.Jewelcrafting);
break;
case GossipMenuIds.Leatherworking:
SendTrainerList(player, GossipOptionIds.Leatherworking);
break;
case GossipMenuIds.Tailoring:
SendTrainerList(player, GossipOptionIds.Tailoring);
break;
default:
break;
}
case GossipMenuIds.Herbalism:
SendTrainerList(player, GossipOptionIds.Herbalism);
break;
case GossipMenuIds.Mining:
SendTrainerList(player, GossipOptionIds.Mining);
break;
case GossipMenuIds.Skinning:
SendTrainerList(player, GossipOptionIds.Skinning);
break;
case GossipMenuIds.Alchemy:
SendTrainerList(player, GossipOptionIds.Alchemy);
break;
case GossipMenuIds.Blacksmithing:
SendTrainerList(player, GossipOptionIds.Blacksmithing);
break;
case GossipMenuIds.Enchanting:
SendTrainerList(player, GossipOptionIds.Enchanting);
break;
case GossipMenuIds.Engineering:
SendTrainerList(player, GossipOptionIds.Engineering);
break;
case GossipMenuIds.Inscription:
SendTrainerList(player, GossipOptionIds.Inscription);
break;
case GossipMenuIds.Jewelcrafting:
SendTrainerList(player, GossipOptionIds.Jewelcrafting);
break;
case GossipMenuIds.Leatherworking:
SendTrainerList(player, GossipOptionIds.Leatherworking);
break;
case GossipMenuIds.Tailoring:
SendTrainerList(player, GossipOptionIds.Tailoring);
break;
default:
break;
}
break;
default:
break;
}
}
void SendTrainerList(Player player, GossipOptionIds Index)
{
player.GetSession().SendTrainerList(me.GetGUID(), (uint)Index + 1);
}
break;
default:
break;
}
}
public override CreatureAI GetAI(Creature creature)
void SendTrainerList(Player player, GossipOptionIds Index)
{
return new npc_multi_profession_trainerAI(creature);
player.GetSession().SendTrainerList(me.GetGUID(), (uint)Index + 1);
}
}
}
}
+1055 -1224
View File
File diff suppressed because it is too large Load Diff