/// <summary> /// Load the guard from the database /// </summary> /// <param name="mobobject">The database mobobject</param> public override void LoadFromDatabase(DataObject mobobject) { base.LoadFromDatabase(mobobject); foreach (AbstractArea area in this.CurrentAreas) { if (area is KeepArea) { AbstractGameKeep keep = (area as KeepArea).Keep; Component = new GameKeepComponent(); Component.AbstractKeep = keep; m_dataObjectID = mobobject.ObjectId; // mob reload command might be reloading guard, so check to make sure it isn't already added if (Component.AbstractKeep.Guards.ContainsKey(m_dataObjectID) == false) { Component.AbstractKeep.Guards.Add(m_dataObjectID, this); } break; } } if (Component != null && Component.AbstractKeep != null) { Component.AbstractKeep.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { this }); } else { TemplateMgr.RefreshTemplate(this); } }
/// <summary> /// Load the guard from the database /// </summary> /// <param name="mobobject">The database mobobject</param> public override void LoadFromDatabase(DataObject mobobject) { if (mobobject == null) { return; } base.LoadFromDatabase(mobobject); string sKey = mobobject.ObjectId; foreach (AbstractArea area in this.CurrentAreas) { if (area is KeepArea keepArea) { Component = new GameKeepComponent(); Component.AbstractKeep = keepArea.Keep; m_dataObjectID = mobobject.ObjectId; // mob reload command might be reloading guard, so check to make sure it isn't already added if (Component.AbstractKeep.Guards.ContainsKey(sKey) == false) { Component.AbstractKeep.Guards.Add(sKey, this); } // break; This is a bad idea. If there are multiple KeepAreas, we should put a guard on each } } if (Component != null && Component.AbstractKeep != null) { Component.AbstractKeep.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { this }); } else { TemplateMgr.RefreshTemplate(this); } }
/// <summary> /// When guards respawn we refresh them, if a patrol guard respawns we /// call a special function to update leadership /// </summary> /// <param name="respawnTimer"></param> /// <returns></returns> protected override int RespawnTimerCallback(RegionTimer respawnTimer) { int temp = base.RespawnTimerCallback(respawnTimer); if (Component != null && Component.AbstractKeep != null) { Component.AbstractKeep.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { this }); } else { TemplateMgr.RefreshTemplate(this); } return(temp); }
/// <summary> /// Load the guard from a position /// </summary> /// <param name="pos">The position for the guard</param> /// <param name="component">The component it is being spawned on</param> public void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component) { m_templateID = pos.TemplateID; m_component = component; component.AbstractKeep.Guards[m_templateID] = this; PositionMgr.LoadGuardPosition(pos, this); if (Component != null && Component.AbstractKeep != null) { Component.AbstractKeep.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { this }); } else { TemplateMgr.RefreshTemplate(this); } this.AddToWorld(); }
private void CreatePatrolGuard(int type) { Assembly asm = Assembly.GetAssembly(typeof(GameServer)); if (type < 0) { type = 0; } if (type > GuardTypes.Length - 1) { type = GuardTypes.Length - 1; } GameKeepGuard guard = (GameKeepGuard)asm.CreateInstance(GuardTypes[type].FullName, true); guard.TemplateID = PatrolID; guard.Component = Component; guard.PatrolGroup = this; PositionMgr.LoadGuardPosition(SpawnPosition, guard); if (Component != null && Component.AbstractKeep != null) { Component.AbstractKeep.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { guard }); } else { TemplateMgr.RefreshTemplate(guard); } PatrolGuards.Add(guard); Component.AbstractKeep.Guards.Add(DOL.Database.UniqueID.IDGenerator.GenerateID(), guard); guard.AddToWorld(); if (ServerProperties.Properties.ENABLE_DEBUG) { guard.Name += " PatrolID " + PatrolID; } }
/// <summary> /// reset the realm when the lord have been killed /// </summary> /// <param name="realm"></param> public virtual void Reset(eRealm realm) { LastAttackedByEnemyTick = 0; StartCombatTick = 0; Realm = realm; PlayerMgr.BroadcastCapture(this); Level = (byte)ServerProperties.Properties.STARTING_KEEP_LEVEL; //if a guild holds the keep, we release it if (Guild != null) { Release(); } //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.KeepHookPoints.Values) { if (hp.Object != null && hp.Object.IsAlive) { hp.Object.Die(null); } } } //change realm foreach (GameClient client in WorldMgr.GetClientsOfRegion(this.CurrentRegion.ID)) { client.Out.SendKeepComponentUpdate(this, false); } //we reset all doors foreach (GameKeepDoor door in Doors.Values) { door.Reset(realm); } //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 && guard.IsAlive) { TemplateMgr.RefreshTemplate(guard); } else if (guard is GuardLord == false) { guard.Die(guard); } } //we reset the banners foreach (GameKeepBanner banner in Banners.Values) { banner.ChangeRealm(); } //update guard level for every keep if (!IsPortalKeep && ServerProperties.Properties.USE_KEEP_BALANCING) { GameServer.KeepManager.UpdateBaseLevels(); } //update the counts of keeps for the bonuses if (ServerProperties.Properties.USE_LIVE_KEEP_BONUSES) { KeepBonusMgr.UpdateCounts(); } SaveIntoDatabase(); GameEventMgr.Notify(KeepEvent.KeepTaken, new KeepEventArgs(this)); }