I modified my lord.cs script so that all of my keep/tower lords would accept BP/RP tokens. You can edit the values however you like, including rewarding something other than bp or rps. The author of the BP/RP script I used is unknown, so unfortunately I cannot give credit.
- Code: Select all
using System;
using DOL.Events;
using DOL.AI.Brain;
using DOL.GS;
using DOL.GS.PacketHandler;
using log4net;
using System.Collections;
using DOL.GS.Effects;
using DOL.GS.Spells;
using System.Timers;
using DOL;
using DOL.GS.GameEvents;
using DOL.GS.Quests;
using DOL.Database;
namespace DOL.GS.Keeps
{
/// <summary>
/// Class for the Lord Guard
/// </summary>
public class GuardLord : GameKeepGuard
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private eRealm m_lastRealm = eRealm.None;
private long m_lastKillTime = 0;
/// <summary>
/// Lord needs more health at the moment
/// </summary>
public override int MaxHealth
{
get
{
return base.MaxHealth * 3;
}
}
public override int RealmPointsValue
{
get
{
// PvE Lords drop stacks of dreaded seals instead of giving RP directly
if (Realm == eRealm.None && GameServer.Instance.Configuration.ServerType == eGameServerType.GST_PvE)
return 0;
long duration = (CurrentRegion.Time - m_lastKillTime) / 1000L;
if (duration < ServerProperties.Properties.LORD_RP_WORTH_SECONDS)
{
return 0;
}
if (this.Component == null || this.Component.AbstractKeep == null)
{
return 5000;
}
else
{
return this.Component.AbstractKeep.RealmPointsValue();
}
}
}
public override int BountyPointsValue
{
get
{
// PvE Lords drop stacks of dreaded seals instead of giving RP directly
if (Realm == eRealm.None && GameServer.Instance.Configuration.ServerType == eGameServerType.GST_PvE)
return 0;
long duration = (CurrentRegion.Time - m_lastKillTime) / 1000L;
if (duration < ServerProperties.Properties.LORD_RP_WORTH_SECONDS)
{
return 0;
}
if (this.Component != null && this.Component.AbstractKeep != null)
{
return this.Component.AbstractKeep.BountyPointsValue();
}
return base.BountyPointsValue;
}
}
public override long ExperienceValue
{
get
{
long duration = (CurrentRegion.Time - m_lastKillTime) / 1000L;
if (duration < ServerProperties.Properties.LORD_RP_WORTH_SECONDS)
{
return 0;
}
if (this.Component != null && this.Component.AbstractKeep != null)
{
return this.Component.AbstractKeep.ExperiencePointsValue();
}
return base.ExperienceValue;
}
}
public override double ExceedXPCapAmount
{
get
{
if (this.Component != null && this.Component.AbstractKeep != null)
{
return this.Component.AbstractKeep.ExceedXPCapAmount();
}
return base.ExceedXPCapAmount;
}
}
public override long MoneyValue
{
get
{
long duration = (CurrentRegion.Time - m_lastKillTime) / 1000L;
if (duration < ServerProperties.Properties.LORD_RP_WORTH_SECONDS)
{
return 0;
}
if (this.Component != null && this.Component.AbstractKeep != null)
{
return this.Component.AbstractKeep.MoneyValue();
}
return base.MoneyValue;
}
}
public override int AttackRangeDistance
{
get
{
return 1200;
}
}
/// <summary>
/// Keep lords are narcissitic; they don't assist themselves or anyone else
/// </summary>
/// <param name="lord"></param>
/// <returns>Whether or not we are responding</returns>
public override bool AssistLord(GuardLord lord)
{
return false;
}
/// <summary>
/// When Lord dies, we update Area Mgr to call the various functions we need
/// And update the player stats
/// </summary>
/// <param name="killer">The killer object</param>
public override void Die(GameObject killer)
{
m_lastRealm = eRealm.None;
if (ServerProperties.Properties.LOG_KEEP_CAPTURES)
{
try
{
if (this.Component != null)
{
DOL.Database.KeepCaptureLog keeplog = new DOL.Database.KeepCaptureLog();
keeplog.KeepName = Component.AbstractKeep.Name;
if (Component.AbstractKeep is GameKeep)
keeplog.KeepType = "Keep";
else
keeplog.KeepType = "Tower";
keeplog.NumEnemies = GetEnemyCountInArea();
keeplog.RPReward = RealmPointsValue;
keeplog.BPReward = BountyPointsValue;
keeplog.XPReward = ExperienceValue;
keeplog.MoneyReward = MoneyValue;
if (Component.AbstractKeep.StartCombatTick > 0)
{
keeplog.CombatTime = (int)((Component.AbstractKeep.CurrentRegion.Time - Component.AbstractKeep.StartCombatTick) / 1000 / 60);
}
keeplog.CapturedBy = GlobalConstants.RealmToName(killer.Realm);
string listRPGainers = "";
foreach (System.Collections.DictionaryEntry de in XPGainers)
{
GameLiving living = de.Key as GameLiving;
if (living != null)
{
listRPGainers += living.Name + ";";
}
}
keeplog.RPGainerList = listRPGainers.TrimEnd(';');
GameServer.Database.AddObject(keeplog);
}
else
{
log.Error("Component null for Guard Lord " + Name);
}
}
catch (System.Exception ex)
{
log.Error("KeepCaptureLog Exception", ex);
}
}
base.Die(killer);
if (this.Component != null)
{
GameServer.ServerRules.ResetKeep(this, killer);
}
m_lastKillTime = CurrentRegion.Time;
}
/// <summary>
/// When we interact with lord, we display all possible options
/// </summary>
/// <param name="player">The player object</param>
/// <returns></returns>
public override bool Interact(GamePlayer player)
{
if (!base.Interact(player))
return false;
if (this.Component == null)
return false;
if (InCombat || Component.AbstractKeep.InCombat)
{
player.Out.SendMessage("You can't talk to the lord while under siege.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
log.DebugFormat("KEEPWARNING: {0} attempted to interact with {1} of {2} while keep or lord in combat.", player.Name, Name, Component.AbstractKeep.Name);
return false;
}
if (GameServer.ServerRules.IsAllowedToClaim(player, CurrentRegion))
{
player.Out.SendMessage("Would you like to [Claim Keep] now? Or maybe [Release Keep]?", eChatType.CT_System, eChatLoc.CL_PopupWindow);
}
return true;
}
public override bool AddToWorld()
{
if (base.AddToWorld())
{
m_lastRealm = Realm;
return true;
}
return false;
}
public override eFlags Flags
{
get { return eFlags.PEACE; }
}
public override bool ReceiveItem(GameLiving source, InventoryItem item)
{
GamePlayer t = source as GamePlayer;
if (WorldMgr.GetDistance(this, source) > WorldMgr.INTERACT_DISTANCE)
{
((GamePlayer)source).Out.SendMessage("You are too far away to give anything to " + GetName(0, false) + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return false;
}
if (t != null && item != null)
{
if ((item.Id_nb == "bptoken500"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(500, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "bptoken1000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(1000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "bptoken5000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(5000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "bptoken10000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(10000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "bptoken50000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(50000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "bptoken100000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(100000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "bptoken500000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(500000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "bptoken1000000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(1000000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "bptoken2000000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(2000000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "bptoken25"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainBountyPoints(25, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken500"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(500, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken1000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(1000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken5000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(5000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken10000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(10000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken50000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(50000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken100000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(100000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken500000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(500000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken1000000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(1000000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken2000000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(2000000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
if ((item.Id_nb == "rptoken5000000"))
{
t.Out.SendMessage("Excellent, you've found a token!\n" +
"Here, please take your reward!", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
t.GainRealmPoints(5000000, false);
t.Inventory.RemoveItem(item); t.Out.SendUpdatePlayerSkills(); t.Out.SendUpdatePlayer(); t.UpdatePlayerStatus();
t.SaveIntoDatabase();
}
}
return base.ReceiveItem(source, item);
}
private void SendReply(GamePlayer target, string msg)
{
target.Out.SendMessage(msg, eChatType.CT_System, eChatLoc.CL_PopupWindow);
}
/// <summary>
/// From a great distance, damage does not harm lord
/// </summary>
/// <param name="source">The source of the damage</param>
/// <param name="damageType">The type of the damage</param>
/// <param name="damageAmount">The amount of the damage</param>
/// <param name="criticalAmount">The critical hit amount of damage</param>
public override void TakeDamage(GameObject source, eDamageType damageType, int damageAmount, int criticalAmount)
{
int distance = 0;
if (this.Component != null && this.Component.AbstractKeep != null && this.Component.AbstractKeep is GameKeep)
distance = 400;
else
distance = 300;
// check to make sure pets and pet casters are in range
GamePlayer attacker = null;
if (source is GamePlayer)
{
attacker = source as GamePlayer;
}
else if (source is GameNPC && (source as GameNPC).Brain != null && (source as GameNPC).Brain is IControlledBrain && (((source as GameNPC).Brain as IControlledBrain).Owner) is GamePlayer)
{
attacker = ((source as GameNPC).Brain as IControlledBrain).Owner as GamePlayer;
}
if ((attacker != null && IsWithinRadius(attacker, distance) == false) || IsWithinRadius(source, distance) == false)
{
if (attacker != null)
attacker.Out.SendMessage(this.Name + " is immune to damage from this range", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow);
return;
}
if (attacker != null && this.Component != null && this.Component.AbstractKeep != null && IsAlive && !GameServer.ServerRules.IsSameRealm(this, attacker, true))
{
if (Realm == m_lastRealm && m_lastRealm != eRealm.None)
this.Component.AbstractKeep.LastAttackedByEnemyTick = CurrentRegion.Time; // light up the keep/tower
}
base.TakeDamage(source, damageType, damageAmount, criticalAmount);
}
public override bool WhisperReceive(GameLiving source, string str)
{
if (InCombat) return false;
if (Component == null) return false;
if (!base.WhisperReceive(source, str)) return false;
if (!(source is GamePlayer)) return false;
GamePlayer player = (GamePlayer)source;
if (!GameServer.ServerRules.IsSameRealm(this, player, true) || !GameServer.ServerRules.IsAllowedToClaim(player, CurrentRegion))
{
return false;
}
byte flag = 0;
switch (str)
{
case "Claim Keep":
{
if (PlayerMgr.IsAllowedToInteract(player, this.Component.AbstractKeep, eInteractType.Claim))
{
player.Out.SendDialogBox(eDialogCode.KeepClaim, (ushort)player.ObjectID, 0, 0, 0, eDialogType.YesNo, false, "Do you wish to claim\n" + this.Component.AbstractKeep.Name + "?");
return true;
}
break;
}
case "Release Keep":
{
if (PlayerMgr.IsAllowedToInteract(player, this.Component.AbstractKeep, eInteractType.Release))
{
flag += 4;
}
break;
}
}
if (flag > 0)
player.Out.SendKeepClaim(this.Component.AbstractKeep, flag);
return true;
}
}
}