Tolakram wrote:WorldMgr has a bunch of changes not related to zone bonuses? Looks like an indent change?
The table is taken from the very latest zones.xml file, correct?
Can these be refreshed while the server is running, if I wanted to change a zone bonus, for example?
You should add language stubs for all language files, even if the text is still in English.
You copied extra comments that can be deleted in Zone Bonus
Class member names need to follow our standards.
+ private int BONUS_XP = 0;
+ private int BONUS_RP = 0;
+ private int BONUS_BP = 0;
+ private int BONUS_COIN = 0;
should be m_bonusXP, m_bonusRP etc.
Creating an instance is interesting. I think you have it right, passing all 0's to the bonuses ... but an interesting way to make an instance that also allows for bonuses.
Thanks.
Tolakram wrote:For zone bonuses, if you place accessors on the bonus numbers then they can certainly be changed via a command.
/zonebonus <ZoneID> <BonusType> <BonusAmount> <Save? (True, False)> would change it live and optionally save the new value in the db for the next restart.
Instances will be very cool, especially for Storm Arenas. Heck, I could even have prerequisite for making an arena have a larger bonus than normal. I'm liking this.
/*
* DAWN OF LIGHT - The first free open source DAoC server emulator
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using DOL.GS;
using DOL.GS.ServerProperties;
using DOL.GS.PacketHandler;
using DOL.Language;
using DOL.GS.Utils;
using DOL.Database;
namespace DOL.GS.Commands
{
[CmdAttribute(
"&zonebonus",
ePrivLevel.GM,
"/zonebonus <zoneID|current> <xpBonus> <rpBonus> <bpBonus> <coinBonus> <Save? (true/false)>")]
public class ZoneBonus : AbstractCommandHandler, ICommandHandler
{
public void OnCommand(GameClient client, string[] args)
{
if (args.Length < 6)
{
DisplaySyntax(client);
return;
}
//make sure that only numbers are used to avoid errors.
foreach (char c in string.Join(" ", args, 2, 5))
{
if (char.IsLetter(c))
{
DisplaySyntax(client);
return;
}
}
Zone zone;
switch (args[1].ToString().ToLower())
{
case "current":
{
zone = WorldMgr.GetZone(client.Player.CurrentZone.ID);
}
break;
default: zone = WorldMgr.GetZone(ushort.Parse(args[1])); break;
}
zone.BonusExperience = int.Parse(args[1]);
zone.BonusRealmpoints = int.Parse(args[2]);
zone.BonusBountypoints = int.Parse(args[3]);
zone.BonusCoin = int.Parse(args[4]);
if (args[5].ToLower().StartsWith("t"))
{
client.Player.TempProperties.setProperty("ZONE_BONUS_SAVE", zone);
client.Player.Out.SendCustomDialog("Are you sure you wan't to replace this zone in the database?", new CustomDialogResponse(AreYouSure));
}
else
{
client.Player.Out.SendCustomDialog("The zone settings will be reverted back to database settings on server restart.", null);
}
}
public static void AreYouSure(GamePlayer player, byte response)
{
if (response != 0x01)
{
player.TempProperties.removeProperty("ZONE_BONUS_SAVE");
return;
}
//here we get the zones new info.
Zone zone = player.TempProperties.getProperty<Zone>("ZONE_BONUS_SAVE");
//here we delete the zone.
Zones findZone = GameServer.Database.SelectObject<Zones>("`ZoneID` = '" + zone.ID + "' AND `RegionID` = '" + zone.ZoneRegion.ID + "'");
GameServer.Database.DeleteObject(findZone);
//Here we add the zone.
Zones dbZone = new Zones();
dbZone.Bountypoints = zone.BonusBountypoints;
dbZone.Realmpoints = zone.BonusRealmpoints;
dbZone.Coin = zone.BonusCoin;
dbZone.Experience = zone.BonusExperience;
dbZone.RegionID = zone.ZoneRegion.ID;
dbZone.OffsetX = zone.XOffset;
dbZone.OffsetY = zone.YOffset;
dbZone.Name = zone.Description;
dbZone.Height = zone.Height;
dbZone.IsLava = zone.IsLava;
dbZone.WaterLevel = zone.Waterlevel;
dbZone.Width = zone.Width;
dbZone.ZoneID = zone.ID;
GameServer.Database.AddObject(dbZone);
//remove the property.
player.TempProperties.removeProperty("ZONE_BONUS_SAVE");
}
}
}
public static void AreYouSure(GamePlayer player, byte response)
{
if (response != 0x01)
{
player.TempProperties.removeProperty("ZONE_BONUS_SAVE");
return;
}
//here we get the zones new info.
Zone zone = player.TempProperties.getProperty<Zone>("ZONE_BONUS_SAVE");
//find the zone.
Zones dbZone = GameServer.Database.SelectObject<Zones>("`ZoneID` = '" + zone.ID + "' AND `RegionID` = '" + zone.ZoneRegion.ID + "'");
//update the zone.
dbZone.Bountypoints = zone.BonusBountypoints;
dbZone.Realmpoints = zone.BonusRealmpoints;
dbZone.Coin = zone.BonusCoin;
dbZone.Experience = zone.BonusExperience;
dbZone.RegionID = zone.ZoneRegion.ID;
dbZone.OffsetX = zone.XOffset;
dbZone.OffsetY = zone.YOffset;
dbZone.Name = zone.Description;
dbZone.Height = zone.Height;
dbZone.IsLava = zone.IsLava;
dbZone.WaterLevel = zone.Waterlevel;
dbZone.Width = zone.Width;
dbZone.ZoneID = zone.ID;
GameServer.Database.SaveObject(dbZone);
//remove the property.
player.TempProperties.removeProperty("ZONE_BONUS_SAVE");
}
Zones dbZone = GameServer.Database.SelectObject<Zones>("`ZoneID` = '" + zone.ID + "' AND `RegionID` = '" + zone.ZoneRegion.ID + "'");
/*
* DAWN OF LIGHT - The first free open source DAoC server emulator
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using DOL.GS;
using DOL.GS.ServerProperties;
using DOL.GS.PacketHandler;
using DOL.Language;
using DOL.GS.Utils;
using DOL.Database;
using log4net;
namespace DOL.GS.Commands
{
[CmdAttribute(
"&zonebonus",
ePrivLevel.GM,
"/zonebonus <zoneID|current> <xpBonus> <rpBonus> <bpBonus> <coinBonus> <Save? (true/false)>")]
public class ZoneBonus : AbstractCommandHandler, ICommandHandler
{
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public void OnCommand(GameClient client, string[] args)
{
if (args.Length < 5)
{
DisplaySyntax(client);
return;
}
//make sure that only numbers are used to avoid errors.
foreach (char c in string.Join(" ", args, 2, 4))
{
if (char.IsLetter(c))
{
DisplaySyntax(client);
return;
}
}
Zone zone;
switch (args[1].ToString().ToLower())
{
case "c":
case "cu":
case "cur":
case "curr":
case "curre":
case "current":
{
zone = WorldMgr.GetZone(client.Player.CurrentZone.ID);
}
break;
default:
{
//make sure that its a number again.
foreach (char c in args[1])
{
if (!(char.IsNumber(c)))
{
DisplaySyntax(client);
return;
}
}
if (WorldMgr.GetZone(ushort.Parse(args[1])) == null)
{
DisplayMessage(client, "No Zone with that ID was found!");
return;
}
zone = WorldMgr.GetZone(ushort.Parse(args[1]));
}
break;
}
zone.BonusExperience = int.Parse(args[2]);
zone.BonusRealmpoints = int.Parse(args[3]);
zone.BonusBountypoints = int.Parse(args[4]);
zone.BonusCoin = int.Parse(args[5]);
if (args[6].ToLower().StartsWith("t"))
{
client.Player.TempProperties.setProperty("ZONE_BONUS_SAVE", zone);
client.Player.Out.SendCustomDialog("Are you sure you wan't to replace this zone in the database?", new CustomDialogResponse(AreYouSure));
}
else
{
client.Player.Out.SendCustomDialog("The zone settings will be reverted back to database settings on server restart.", null);
}
}
public static void AreYouSure(GamePlayer player, byte response)
{
if (response != 0x01)
{
player.TempProperties.removeProperty("ZONE_BONUS_SAVE");
return;
}
//here we get the zones new info.
Zone zone = player.TempProperties.getProperty<Zone>("ZONE_BONUS_SAVE");
//find the zone.
Zones dbZone = GameServer.Database.SelectObject<Zones>("`ZoneID` = '" + zone.ID + "' AND `RegionID` = '" + zone.ZoneRegion.ID + "'");
//update the zone bonuses.
dbZone.Bountypoints = zone.BonusBountypoints;
dbZone.Realmpoints = zone.BonusRealmpoints;
dbZone.Coin = zone.BonusCoin;
dbZone.Experience = zone.BonusExperience;
GameServer.Database.SaveObject(dbZone);
//remove the property.
player.TempProperties.removeProperty("ZONE_BONUS_SAVE");
}
}
}
Return to “%s” DOL Code Contributions
Users browsing this forum: No registered users and 1 guest