zones.xml and zone bonuses

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

Re: zones.xml and zone bonuses

Postby stephenxpimentel » Wed Jul 21, 2010 6:12 am

yes i got it :) ty!


heres the zone bonus patch + sql to match it.

SQL:
zones.rar
(17.44 KiB) Downloaded 24 times

Patch:
ZoneBonuses.patch
(37.06 KiB) Downloaded 21 times
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: zones.xml and zone bonuses

Postby Tolakram » Wed Jul 21, 2010 9:00 am

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 :P

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. :)
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: zones.xml and zone bonuses

Postby stephenxpimentel » Wed Jul 21, 2010 2:59 pm

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 :P

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. :)


[EDIT]: About WorldMgr, i had to move a few things around, for example i needed regions to be loaded before zones, and i changed the constructor for Zone, so this is why it looks odd, but everything that is red is because i moved it

As for refreshing while server is up, i'm not sure. If there was a way to reload zones before then they can most certainly be reloaded. Or maybe if no one is inside the zone, then someone enters it, maybe it refreshes, i'm not sure how it works, and i'm not sure if the zone can really be reloaded when there is people inside it.

Class Member names i over thought it i think, because the reason i did them capitals is because once the zone is loaded it is basically a constant value, but i will change it to m_bonusXX

As for instances, i'm not 100% sure how those will work.
Last edited by stephenxpimentel on Wed Jul 21, 2010 3:07 pm, edited 1 time in total.
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: zones.xml and zone bonuses

Postby Tolakram » Wed Jul 21, 2010 3:07 pm

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.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: zones.xml and zone bonuses

Postby stephenxpimentel » Wed Jul 21, 2010 4:02 pm

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.


i'm glad u like it, and i think honestly now that i'm looking at it, instances SHOULD have the same ZoneID's assigned to them, so i think the bonuses would persist into them. So i hope that answers your question. I'm working on the command now, and i fixed the things u mentioned (extra comments, bad variable names, added english translations to all lang files.)
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: zones.xml and zone bonuses

Postby Tolakram » Wed Jul 21, 2010 4:19 pm

I think defaulting 0 for instances is the right way to go for now, since an instance is just a skin of the region. People can use custom code if they want to apply bonuses to instances. Also, by defaulting to 0, it won't change behavior unexpectedly.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: zones.xml and zone bonuses

Postby stephenxpimentel » Wed Jul 21, 2010 4:23 pm

True, now about the command u want added.

/zonebonus <zoneID/current> <xpBonus> <rpBonus> <bpBonus> <coinBonus> <save? true/fase>

would that be acceptable? as with yours BonusType etc, u can only add 1 bonus to the zone, where this way u can do all 4 in 1 easy step. Thoughts?
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: zones.xml and zone bonuses

Postby Tolakram » Wed Jul 21, 2010 4:34 pm

Fine by me.

Might need a way to list current bonuses or a way to indicate no change??? So they don't get wiped out accidentally.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: zones.xml and zone bonuses

Postby stephenxpimentel » Thu Jul 22, 2010 2:49 am

How does this look? :D

Code: Select all
/*
 * 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");
        }
    }
}
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: zones.xml and zone bonuses

Postby Tolakram » Thu Jul 22, 2010 2:57 am

Good. I'd feel safer if you updated the zone rather than delete and re-add though. Just in case, if something goes wrong, zone goes poof.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: zones.xml and zone bonuses

Postby stephenxpimentel » Thu Jul 22, 2010 3:23 am

ok then, reworked to update instead. (i think). SaveObject would do that yes?

Code: Select all
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");
        }
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: zones.xml and zone bonuses

Postby stephenxpimentel » Thu Jul 22, 2010 4:17 am

Patch and SQL :)

ZoneBonuses.rar
(25.76 KiB) Downloaded 22 times
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: zones.xml and zone bonuses

Postby baradien » Thu Jul 22, 2010 11:45 am

nice one ^^
baradien
Server Team
 
Posts: 950
Joined: Wed Jan 23, 2008 3:17 pm
Location: Belguim

Re: zones.xml and zone bonuses

Postby Tolakram » Thu Jul 22, 2010 12:28 pm

Save looks good, but you should only have to update the columns that changed.

Code: Select all
Zones dbZone = GameServer.Database.SelectObject<Zones>("`ZoneID` = '" + zone.ID + "' AND `RegionID` = '" + zone.ZoneRegion.ID + "'");


Check to see if null (found) before updating.

When updating just change the columns whose value changed, and save the object.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: zones.xml and zone bonuses

Postby stephenxpimentel » Thu Jul 22, 2010 10:28 pm

Hows this? :) i added another check to make sure when u use a ZoneID instead of "current" it will check to make sure the zone exists first. changed it so it only saves the zone bonuses aswell. Let me know of any changes or if i can commit Zone Bonuses! :)

Code: Select all
/*
 * 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");
        }
    }
}
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest