Start adding missing scripts Part5

This commit is contained in:
hondacrx
2022-07-10 14:06:27 -04:00
parent aae75ce85d
commit 10665e4d78
3 changed files with 627 additions and 0 deletions
@@ -0,0 +1,271 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Framework.Constants;
using Game.Entities;
using Game.Maps;
using Game.Scripting;
using System;
namespace Scripts.EasternKingdoms.Deadmines
{
enum DMCannonState
{
CannonNotUsed,
CannonGunpowderUsed,
CannonBlastInitiated,
PiratesAttack,
EventDone
}
enum DMData
{
EventState,
EventRhahkzor
}
struct DataTypes
{
public const uint SmiteChest = 0;
}
struct GameObjectIds
{
public const uint FactoryDoor = 13965;
public const uint IroncladDoor = 16397;
public const uint DefiasCannon = 16398;
public const uint DoorLever = 101833;
public const uint MrSmiteChest = 144111;
}
struct SoundIds
{
public const uint Cannonfire = 1400;
public const uint Destroydoor = 3079;
public const uint MrSmiteAlarm1 = 5775;
public const uint MrSmiteAlarm2 = 5777;
}
struct MiscConst
{
public const uint DataCannonBlastTimer = 3000;
public const uint DataPiratesDelayTimer = 1000;
}
class instance_deadmines : InstanceMapScript
{
public instance_deadmines() : base(nameof(instance_deadmines), 36) { }
class instance_deadmines_InstanceMapScript : InstanceScript
{
ObjectGuid FactoryDoorGUID;
ObjectGuid IronCladDoorGUID;
ObjectGuid DefiasCannonGUID;
ObjectGuid DoorLeverGUID;
ObjectGuid DefiasPirate1GUID;
ObjectGuid DefiasPirate2GUID;
DMCannonState State;
uint CannonBlast_Timer;
uint PiratesDelay_Timer;
ObjectGuid uiSmiteChestGUID;
public instance_deadmines_InstanceMapScript(InstanceMap map) : base(map)
{
SetHeaders("DM");
State = DMCannonState.CannonNotUsed;
CannonBlast_Timer = 0;
PiratesDelay_Timer = 0;
}
public override void Update(uint diff)
{
if (IronCladDoorGUID.IsEmpty() || DefiasCannonGUID.IsEmpty() || DoorLeverGUID.IsEmpty())
return;
GameObject pIronCladDoor = instance.GetGameObject(IronCladDoorGUID);
if (!pIronCladDoor)
return;
switch (State)
{
case DMCannonState.CannonGunpowderUsed:
CannonBlast_Timer = MiscConst.DataCannonBlastTimer;
// it's a hack - Mr. Smite should do that but his too far away
//pIronCladDoor.SetName("Mr. Smite");
//pIronCladDoor.MonsterYell(SayMrSmiteAlarm1, LangUniversal, null);
pIronCladDoor.PlayDirectSound(SoundIds.MrSmiteAlarm1);
State = DMCannonState.CannonBlastInitiated;
break;
case DMCannonState.CannonBlastInitiated:
PiratesDelay_Timer = MiscConst.DataPiratesDelayTimer;
if (CannonBlast_Timer <= diff)
{
SummonCreatures();
ShootCannon();
BlastOutDoor();
LeverStucked();
//pIronCladDoor.MonsterYell(SayMrSmiteAlarm2, LangUniversal, null);
pIronCladDoor.PlayDirectSound(SoundIds.MrSmiteAlarm2);
State = DMCannonState.PiratesAttack;
}
else CannonBlast_Timer -= diff;
break;
case DMCannonState.PiratesAttack:
if (PiratesDelay_Timer <= diff)
{
MoveCreaturesInside();
State = DMCannonState.EventDone;
}
else PiratesDelay_Timer -= diff;
break;
}
}
void SummonCreatures()
{
GameObject pIronCladDoor = instance.GetGameObject(IronCladDoorGUID);
if (pIronCladDoor)
{
Creature DefiasPirate1 = pIronCladDoor.SummonCreature(657, pIronCladDoor.GetPositionX() - 2, pIronCladDoor.GetPositionY() - 7, pIronCladDoor.GetPositionZ(), 0, TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(3));
Creature DefiasPirate2 = pIronCladDoor.SummonCreature(657, pIronCladDoor.GetPositionX() + 3, pIronCladDoor.GetPositionY() - 6, pIronCladDoor.GetPositionZ(), 0, TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(3));
DefiasPirate1GUID = DefiasPirate1.GetGUID();
DefiasPirate2GUID = DefiasPirate2.GetGUID();
}
}
void MoveCreaturesInside()
{
if (DefiasPirate1GUID.IsEmpty() || DefiasPirate2GUID.IsEmpty())
return;
Creature pDefiasPirate1 = instance.GetCreature(DefiasPirate1GUID);
Creature pDefiasPirate2 = instance.GetCreature(DefiasPirate2GUID);
if (!pDefiasPirate1 || !pDefiasPirate2)
return;
MoveCreatureInside(pDefiasPirate1);
MoveCreatureInside(pDefiasPirate2);
}
void MoveCreatureInside(Creature creature)
{
creature.SetWalk(false);
creature.GetMotionMaster().MovePoint(0, -102.7f, -655.9f, creature.GetPositionZ());
}
void ShootCannon()
{
GameObject pDefiasCannon = instance.GetGameObject(DefiasCannonGUID);
if (pDefiasCannon)
{
pDefiasCannon.SetGoState(GameObjectState.Active);
pDefiasCannon.PlayDirectSound(SoundIds.Cannonfire);
}
}
void BlastOutDoor()
{
GameObject pIronCladDoor = instance.GetGameObject(IronCladDoorGUID);
if (pIronCladDoor)
{
pIronCladDoor.SetGoState(GameObjectState.Destroyed);
pIronCladDoor.PlayDirectSound(SoundIds.Destroydoor);
}
}
void LeverStucked()
{
GameObject pDoorLever = instance.GetGameObject(DoorLeverGUID);
if (pDoorLever)
pDoorLever.SetFlag(GameObjectFlags.InteractCond);
}
public override void OnGameObjectCreate(GameObject go)
{
switch (go.GetEntry())
{
case GameObjectIds.FactoryDoor:
FactoryDoorGUID = go.GetGUID();
break;
case GameObjectIds.IroncladDoor:
IronCladDoorGUID = go.GetGUID();
break;
case GameObjectIds.DefiasCannon:
DefiasCannonGUID = go.GetGUID();
break;
case GameObjectIds.DoorLever:
DoorLeverGUID = go.GetGUID();
break;
case GameObjectIds.MrSmiteChest:
uiSmiteChestGUID = go.GetGUID();
break;
}
}
public override void SetData(uint type, uint data)
{
switch ((DMData)type)
{
case DMData.EventState:
if (!DefiasCannonGUID.IsEmpty() && !IronCladDoorGUID.IsEmpty())
State = (DMCannonState)data;
break;
case DMData.EventRhahkzor:
if (data == (uint)EncounterState.Done)
{
GameObject go = instance.GetGameObject(FactoryDoorGUID);
if (go)
go.SetGoState(GameObjectState.Active);
}
break;
}
}
public override uint GetData(uint type)
{
switch ((DMData)type)
{
case DMData.EventState:
return (uint)State;
}
return 0;
}
public override ObjectGuid GetGuidData(uint data)
{
switch (data)
{
case DataTypes.SmiteChest:
return uiSmiteChestGUID;
}
return ObjectGuid.Empty;
}
}
public override InstanceScript GetInstanceScript(InstanceMap map)
{
return new instance_deadmines_InstanceMapScript(map);
}
}
}
@@ -0,0 +1,209 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Framework.Constants;
using Game.AI;
using Game.Entities;
using Game.Maps;
using Game.Scripting;
using Game.Spells;
namespace Scripts.EasternKingdoms.Deadmines
{
struct SpellIds
{
public const uint Trash = 3391;
public const uint SmiteStomp = 6432;
public const uint SmiteSlam = 6435;
}
struct EquipIds
{
public const int Sword = 5191;
public const int Axe = 5196;
public const int Mace = 7230;
}
struct TextIds
{
public const uint SayPhase1 = 2;
public const uint SayPhase2 = 3;
}
[Script]
class boss_mr_smite : ScriptedAI
{
InstanceScript instance;
uint uiTrashTimer;
uint uiSlamTimer;
byte uiHealth;
uint uiPhase;
uint uiTimer;
bool uiIsMoving;
public boss_mr_smite(Creature creature) : base(creature)
{
Initialize();
instance = creature.GetInstanceScript();
}
void Initialize()
{
uiTrashTimer = RandomHelper.URand(5000, 9000);
uiSlamTimer = 9000;
uiHealth = 0;
uiPhase = 0;
uiTimer = 0;
uiIsMoving = false;
}
public override void Reset()
{
Initialize();
SetEquipmentSlots(false, EquipIds.Sword, 0);
me.SetStandState(UnitStandStateType.Stand);
me.SetReactState(ReactStates.Aggressive);
me.SetNoCallAssistance(true);
}
public override void JustEngagedWith(Unit who) { }
bool bCheckChances()
{
uint uiChances = RandomHelper.URand(0, 99);
if (uiChances <= 15)
return false;
else
return true;
}
public override void UpdateAI(uint uiDiff)
{
if (!UpdateVictim())
return;
if (!uiIsMoving) // halt abilities in between phases
{
if (uiTrashTimer <= uiDiff)
{
if (bCheckChances())
DoCast(me, SpellIds.Trash);
uiTrashTimer = RandomHelper.URand(6000, 15500);
}
else uiTrashTimer -= uiDiff;
if (uiSlamTimer <= uiDiff)
{
if (bCheckChances())
DoCastVictim(SpellIds.SmiteSlam);
uiSlamTimer = 11000;
}
else uiSlamTimer -= uiDiff;
}
if ((uiHealth == 0 && !HealthAbovePct(66)) || (uiHealth == 1 && !HealthAbovePct(33)))
{
++uiHealth;
DoCastAOE(SpellIds.SmiteStomp, new CastSpellExtraArgs(false));
SetCombatMovement(false);
me.AttackStop();
me.InterruptNonMeleeSpells(false);
me.SetReactState(ReactStates.Passive);
uiTimer = 2500;
uiPhase = 1;
switch (uiHealth)
{
case 1:
Talk(TextIds.SayPhase1);
break;
case 2:
Talk(TextIds.SayPhase2);
break;
}
}
if (uiPhase != 0)
{
if (uiTimer <= uiDiff)
{
switch (uiPhase)
{
case 1:
{
if (uiIsMoving)
break;
GameObject go = ObjectAccessor.GetGameObject(me, instance.GetGuidData(DataTypes.SmiteChest));
if (go)
{
me.GetMotionMaster().Clear();
me.GetMotionMaster().MovePoint(1, go.GetPositionX() - 1.5f, go.GetPositionY() + 1.4f, go.GetPositionZ());
uiIsMoving = true;
}
break;
}
case 2:
if (uiHealth == 1)
SetEquipmentSlots(false, EquipIds.Axe, EquipIds.Axe);
else
SetEquipmentSlots(false, EquipIds.Mace, 0);
uiTimer = 500;
uiPhase = 3;
break;
case 3:
me.SetStandState(UnitStandStateType.Stand);
uiTimer = 750;
uiPhase = 4;
break;
case 4:
me.SetReactState(ReactStates.Aggressive);
SetCombatMovement(true);
me.GetMotionMaster().MoveChase(me.GetVictim(), me.m_CombatDistance);
uiIsMoving = false;
uiPhase = 0;
break;
}
}
else uiTimer -= uiDiff;
}
DoMeleeAttackIfReady();
}
public override void MovementInform(MovementGeneratorType uiType, uint uiId)
{
if (uiType != MovementGeneratorType.Point)
return;
me.SetFacingTo(5.47f);
me.SetStandState(UnitStandStateType.Kneel);
uiTimer = 2000;
uiPhase = 2;
}
}
}
@@ -0,0 +1,147 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Framework.Constants;
using Game.Entities;
using Game.Maps;
using Game.Scripting;
namespace Scripts.EasternKingdoms.Gnomeregan
{
struct GNOGameObjectIds
{
public const uint CaveInLeft = 146085;
public const uint CaveInRight = 146086;
public const uint RedRocket = 103820;
}
struct GNOCreatureIds
{
public const uint BlastmasterEmiShortfuse = 7998;
public const uint CaverndeepAmbusher = 6207;
public const uint Grubbis = 7361;
public const uint ViciousFallout = 7079;
public const uint Chomper = 6215;
public const uint Electrocutioner = 6235;
public const uint CrowdPummeler = 6229;
public const uint Mekgineer = 7800;
}
struct DataTypes
{
public const uint BlastmasterEvent = 0;
public const uint ViciousFallout = 1;
public const uint Electrocutioner = 2;
public const uint CrowdPummeler = 3;
public const uint Thermaplugg = 4;
public const uint MaxEncounter = 5;
// Additional Objects
public const uint GoCaveInLeft = 6;
public const uint GoCaveInRight = 7;
public const uint NpcBastmasterEmiShortfuse = 8;
}
struct DataTypes64
{
public const uint GoCaveInLeft = 0;
public const uint GoCaveInRight = 1;
public const uint NpcBastmasterEmiShortfuse = 2;
}
class instance_gnomeregan : InstanceMapScript
{
public instance_gnomeregan() : base(nameof(instance_gnomeregan), 90) { }
class instance_gnomeregan_InstanceMapScript : InstanceScript
{
ObjectGuid uiCaveInLeftGUID;
ObjectGuid uiCaveInRightGUID;
ObjectGuid uiBlastmasterEmiShortfuseGUID;
public instance_gnomeregan_InstanceMapScript(InstanceMap map) : base(map)
{
SetHeaders("GNO");
SetBossNumber(DataTypes.MaxEncounter);
}
public override void OnCreatureCreate(Creature creature)
{
switch (creature.GetEntry())
{
case GNOCreatureIds.BlastmasterEmiShortfuse:
uiBlastmasterEmiShortfuseGUID = creature.GetGUID();
break;
}
}
public override void OnGameObjectCreate(GameObject go)
{
switch (go.GetEntry())
{
case DataTypes64.GoCaveInLeft:
uiCaveInLeftGUID = go.GetGUID();
break;
case DataTypes64.GoCaveInRight:
uiCaveInRightGUID = go.GetGUID();
break;
}
}
public override void OnUnitDeath(Unit unit)
{
Creature creature = unit.ToCreature();
if (creature)
switch (creature.GetEntry())
{
case GNOCreatureIds.ViciousFallout:
SetBossState(DataTypes.ViciousFallout, EncounterState.Done);
break;
case GNOCreatureIds.Electrocutioner:
SetBossState(DataTypes.Electrocutioner, EncounterState.Done);
break;
case GNOCreatureIds.CrowdPummeler:
SetBossState(DataTypes.CrowdPummeler, EncounterState.Done);
break;
case GNOCreatureIds.Mekgineer:
SetBossState(DataTypes.Thermaplugg, EncounterState.Done);
break;
}
}
public override ObjectGuid GetGuidData(uint uiType)
{
switch (uiType)
{
case DataTypes64.GoCaveInLeft: return uiCaveInLeftGUID;
case DataTypes64.GoCaveInRight: return uiCaveInRightGUID;
case DataTypes64.NpcBastmasterEmiShortfuse: return uiBlastmasterEmiShortfuseGUID;
}
return ObjectGuid.Empty;
}
}
public override InstanceScript GetInstanceScript(InstanceMap map)
{
return new instance_gnomeregan_InstanceMapScript(map);
}
}
}