Moderators: Project Admin, Support Team
private static void SetGuardRespawn(GameKeepGuard guard)
{
if (guard is FrontierHastener)
{
guard.RespawnInterval = 150000; // 15 minutes
}
else if (guard is GuardLord)
{
if (guard.Component != null)
{
guard.RespawnInterval = guard.Component.Keep.LordRespawnTime;
}
else
{
guard.RespawnInterval = 300000; // 30 minutes
}foreach (GamePlayer player in this.GetPlayersInRadius(5000)) // maybe set that lower.. or higher..
{
//get spawn at a local portal keep
foreach (AbstractGameKeep keep in KeepMgr.GetKeepsOfRegion(CurrentRegionID))
{
if (keep.IsPortalKeep && keep.Realm == Realm)
{
ushort region = keep.CurrentRegion.ID;
int X = keep.X;
int Y = keep.Y;
int Z = keep.Z;
player.MoveTo(region, X, Y, Z, 0);
//maybe add a message here to let the player know what happened ..
break;
}
}
} public class StormRegionPvEDoorCloseTimer : GameTimer
{
private AbstractGameKeep m_keep;
public StormRegionPvEDoorCloseTimer(AbstractGameKeep keep, StormRegion i)
: base(i.TimeManager)
{
m_keep = keep;
}
protected override void OnTick()
{
foreach (GameKeepDoor door in m_keep.Doors.Values)
{
door.Reset(0);
}
Stop();
}
}
/// <summary>
/// A keep located in D2
/// </summary>
public class StormRegionGameKeep_D2 : StormRegionGameKeep
{
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private StormRegionPvEDoorCloseTimer m_doorTimer = null;
public override Type TemplateManager
{
get
{
return typeof(D2KeepTemplateMgr);
}
}
public const int KEEP_RESPAWN_TIME = 600000;
/// <summary>
/// Respawn time for the lord of this keep (milliseconds)
/// </summary>
public override int LordRespawnTime
{
get { return KEEP_RESPAWN_TIME + 60000; }
}
public override long ExperiencePointsValue()
{
return GameServer.ServerRules.GetExperienceForLiving(BaseLevel) * 10;
}
public override double ExceedXPCapAmount()
{
return 10.0;
}
public override int RealmPointsValue()
{
return base.RealmPointsValue();
}
public override int BountyPointsValue()
{
return 1;
}
public override void Load(DBKeep keep)
{
CurrentRegion = WorldMgr.GetRegion((ushort)keep.Region);
StormRegion_D2 d2Region = CurrentRegion as StormRegion_D2;
InitialiseTimers();
keep.Realm = 0;
BaseLevel = keep.BaseLevel;
LoadFromDatabase(keep);
GameEventMgr.AddHandler(CurrentRegion, RegionEvent.PlayerEnter, new DOLEventHandler(SendKeepInit));
KeepArea area = null;
//see if any keep areas for this keep have already been added via DBArea
foreach (AbstractArea a in CurrentRegion.GetAreasOfSpot(keep.X, keep.Y, keep.Z))
{
if (a is KeepArea && a.Description == keep.Name)
{
log.Debug("Found a DBArea entry for D2 " + keep.Name + " in region " + CurrentRegion.ID + ", loading that instead of creating a new one.");
area = a as KeepArea;
area.Keep = this;
break;
}
}
if (area == null)
{
area = new KeepArea(this);
area.CanBroadcast = true;
area.CheckLOS = true;
if (CurrentRegion.AddArea(area) == null)
{
log.Debug("StormRegion_D2: failed to add area to region " + CurrentRegion.Description);
}
else
{
log.DebugFormat("StormRegion_D2: Added keep area to region {0} at x{1}, y{2}, z{3}", CurrentRegion.ID, area.X, area.Y, area.Z);
}
}
area.Keep = this;
this.Area = area;
}
public override void Reset(eRealm realm)
{
StormRegion_D2 d2Region = CurrentRegion as StormRegion_D2;
if (d2Region == null)
{
base.Reset(realm);
return;
}
// always realm 0
realm = eRealm.None;
LastAttackedByEnemyTick = 0;
StartCombatTick = 0;
Realm = realm;
PlayerMgr.BroadcastCapture(this);
Level = (byte)4;
//we repair all keep components, but not if it is a tower and is raised
foreach (GameKeepComponent component in this.KeepComponents)
{
if (!component.IsRaized)
component.Repair(component.MaxHealth - component.Health);
foreach (GameKeepHookPoint hp in component.HookPoints.Values)
{
if (hp.Object != null)
hp.Object.Die(null);
}
}
//change realm
foreach (GameClient client in WorldMgr.GetClientsOfRegion(this.CurrentRegion.ID))
{
client.Out.SendKeepComponentUpdate(this, false);
}
//we reset all doors
if (Realm != eRealm.None)
{
foreach (GameKeepDoor door in Doors.Values)
{
door.Reset(realm);
}
}
else
{
StopTimers();
m_doorTimer = new StormRegionPvEDoorCloseTimer(this, d2Region);
m_doorTimer.Start(KEEP_RESPAWN_TIME);
}
//we make sure all players are not in the air
ResetPlayersOfKeep();
//we reset the guards
foreach (GameKeepGuard guard in Guards.Values)
{
if (guard is GuardLord == false)
{
guard.Die(guard);
}
}
//we reset the banners
foreach (GameKeepBanner banner in Banners.Values)
{
banner.ChangeRealm();
}
GameEventMgr.Notify(KeepEvent.KeepTaken, new KeepEventArgs(this));
SetGuardLevels();
}
public void SetGuardLevels()
{
foreach (GameKeepGuard guard in Guards.Values)
{
SetGuardLevel(guard);
}
}
public override void SetGuardLevel(GameKeepGuard guard)
{
if (guard is FrontierHastener)
{
guard.Level = 1;
}
else
{
guard.Level = (byte)(GetBaseLevel(guard));
}
}
public override byte GetBaseLevel(GameKeepGuard guard)
{
if (guard.Component == null)
{
if (guard is GuardLord)
{
return 120;
}
else
{
return 85;
}
}
else
{
if (guard is GuardLord)
{
return (byte)(guard.Component.Keep.BaseLevel + 25);
}
else
{
return guard.Component.Keep.BaseLevel;
}
}
}
protected void StopTimers()
{
if (m_doorTimer != null)
{
m_doorTimer.Stop();
m_doorTimer = null;
}
}
}
public override bool AddToWorld()
{
if (base.AddToWorld())
{
m_lastRealm = eRealm.None;
foreach (GamePlayer player in this.GetPlayersInRadius(4000)) // maybe set that lower.. or higher..
{
//get spawn at a local border keep
foreach (AbstractGameKeep keep in GameServer.KeepManager.GetKeepsOfRegion(CurrentRegionID))
{
if (keep.OriginalRealm == eRealm.Albion)
{
//sauvage
X = 653811;
Y = 616998;
Z = 9560;
break;
}
if (keep.OriginalRealm == eRealm.Midgard)
{
//svas
X = 651460;
Y = 313758;
Z = 9432;
break;
}
if (keep.OriginalRealm == eRealm.Hibernia)
{
//ligen
X = 396519;
Y = 618017;
Z = 9838;
break;
}
player.MoveTo(163, X, Y, Z, 0);
player.Out.SendMessage("This area isn't currently secure and you are being transported to a safer location.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
}
}
return true;
}
return false;
}
public override bool AddToWorld()
{
if (base.AddToWorld())
{
m_lastRealm = eRealm.None;
foreach (GamePlayer player in this.GetPlayersInRadius(4000)) // maybe set that lower.. or higher..
{
//get spawn at a local border keep
foreach (AbstractGameKeep keep in GameServer.KeepManager.GetKeepsOfRegion(CurrentRegionID))
{
if (keep is GameKeep)
{
switch (keep.OriginalRealm)
{
case eRealm.Albion:
//sauvage
player.MoveTo(163, 31258, 59345, 9559, 229);
break;
case eRealm.Midgard:
//svas
player.MoveTo(163, 61494, 18804, 9420, 156);
break;
case eRealm.Hibernia:
//ligen
player.MoveTo(163, 36053, 60900, 9839, 226);
break;
}
player.Out.SendMessage("This area isn't currently secure and you are being transported to a safe location.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
}
}
}
return true;
}
return false;
} public override bool AddToWorld()
{
if (base.AddToWorld())
{
m_lastRealm = eRealm.None;
foreach (GamePlayer player in this.GetPlayersInRadius(4000)) // maybe set that lower.. or higher..
{
int currentZoneID = player.CurrentZone.ID;
// player.Out.SendMessage("Before checking Zone ID. " + currentZoneID , eChatType.CT_System, eChatLoc.CL_ChatWindow);
switch (currentZoneID)
{
case 167: // Odin's gate
player.MoveTo(163, 651611, 315012, 9432, 1934);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Uppland.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 168: // Jamtland Mountains
player.MoveTo(163, 651611, 315012, 9432, 1934);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Uppland.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 169: // Yggdra Forest
player.MoveTo(163, 651611, 315012, 9432, 1934);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Uppland.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 170: // Uppland
player.MoveTo(163, 651611, 315012, 9432, 1934);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Uppland.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 171: // Emain Macha
player.MoveTo(163, 395861, 618238, 9816, 2548);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Cruachan Gorge.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 172: // Breifine
player.MoveTo(163, 395861, 618238, 9816, 2548);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Cruachan Gorge.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 173: // Crauchan Gorge
player.MoveTo(163, 395861, 618238, 9816, 2548);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Cruachan Gorge.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 174: // Mount Collory
player.MoveTo(163, 395861, 618238, 9816, 2548);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Cruachan Gorge.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 175: // Snowdonia
player.MoveTo(163, 652700, 617189, 9560, 2815);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Forest Sauvage.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 176: // Forest Sauvage
player.MoveTo(163, 652700, 617189, 9560, 2815);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Forest Sauvage.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 177: // Pennine Mountains
player.MoveTo(163, 652700, 617189, 9560, 2815);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Forest Sauvage.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 178: // Hadrian's Wall
player.MoveTo(163, 652700, 617189, 9560, 2815);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Forest Sauvage.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
}
}
return true;
}
return false;
}
public override bool AddToWorld()
{
if (base.AddToWorld())
{
m_lastRealm = eRealm.None;
#region Keep Lord
// is this a Keep Lord
if (this.Component != null && this.Component.Keep != null && this.Component.Keep is GameKeep)
{
BroadcastUpdate();
Yell("Get out of my Keep.");
foreach (GamePlayer player in this.GetPlayersInRadius(4000)) // maybe set that lower.. or higher..
{
int currentZoneID = player.CurrentZone.ID;
// player.Out.SendMessage("Before checking Zone ID. " + currentZoneID , eChatType.CT_System, eChatLoc.CL_ChatWindow);
switch (currentZoneID)
{
case 167: // Odin's gate
player.MoveTo(163, 651611, 315012, 9432, 1934);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Uppland.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 168: // Jamtland Mountains
player.MoveTo(163, 651611, 315012, 9432, 1934);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Uppland.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 169: // Yggdra Forest
player.MoveTo(163, 651611, 315012, 9432, 1934);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Uppland.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 170: // Uppland
player.MoveTo(163, 651611, 315012, 9432, 1934);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Uppland.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 171: // Emain Macha
player.MoveTo(163, 395861, 618238, 9816, 2548);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Cruachan Gorge.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 172: // Breifine
player.MoveTo(163, 395861, 618238, 9816, 2548);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Cruachan Gorge.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 173: // Crauchan Gorge
player.MoveTo(163, 395861, 618238, 9816, 2548);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Cruachan Gorge.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 174: // Mount Collory
player.MoveTo(163, 395861, 618238, 9816, 2548);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Cruachan Gorge.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 175: // Snowdonia
player.MoveTo(163, 652700, 617189, 9560, 2815);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Forest Sauvage.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 176: // Forest Sauvage
player.MoveTo(163, 652700, 617189, 9560, 2815);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Forest Sauvage.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 177: // Pennine Mountains
player.MoveTo(163, 652700, 617189, 9560, 2815);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Forest Sauvage.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
case 178: // Hadrian's Wall
player.MoveTo(163, 652700, 617189, 9560, 2815);
player.Out.SendMessage("This area isn't currently secure and you are being transported to Forest Sauvage.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
break;
}
}
}
#endregion KeepLord
#region Tower Lord
// is this a Tower captain
if (this.Component != null && this.Component.Keep != null && this.Component.Keep is GameKeepTower)
{
foreach (GamePlayer player in this.GetPlayersInRadius(700)) // Just outside of tower radius
{
int newX = this.X + 2500;
int newY = this.Y + 2500;
int newZ = this.Z - 300;
BroadcastUpdate();
Yell("Get out of my Tower.");
// player.Out.SendMessage("Get out of my Tower.", eChatType.CT_System, eChatLoc.CL_ChatWindow);
player.MoveTo(163, newX, newY, newZ, 1934);
}
}
#endregion Tower Lord
return true;
}
return false;
} //we reset tower door
foreach (GameKeepDoor door in this.GetDoorsInRadius(1000)) // 1000 for tower 4000 for keep
{
door.Reset(Realm);
} //we reset all keep doors
foreach (GameKeepDoor door in this.GetDoorsInRadius(4000))
{
door.Reset(Realm);
}
Users browsing this forum: No registered users and 1 guest