sahisahi

Member
I deleted every achievement but hunting one:

HunterAchievement.cs:

Code:
using Server;
using Server.Mobiles;
using System;
namespace Scripts.Systems.Achievements
{
    public class HunterAchievement : BaseAchievement
    {
        private Type m_Mobile;
        public HunterAchievement(int id, int catid, int itemIcon, bool hiddenTillComplete, BaseAchievement prereq, int total, string title, string desc, short RewardPoints, Type targets, params Type[] rewards)
            : base(id, catid, itemIcon, hiddenTillComplete, prereq, title, desc, RewardPoints, total, rewards)
        {
            m_Mobile = targets;
           // EventSink.OnKilledBy += EventSink_OnKilledBy;
        }
        private void EventSink_OnKilledBy(OnKilledByEventArgs e)
        {
            var player = e.KilledBy as PlayerMobile;
            if (player != null && e.Killed.GetType() == m_Mobile)
            {
                AchievmentSystem.SetAchievementStatus(player, this, 1);
            }
        }
    }
}

AchievementSystem.cs:

Code:
#define STOREONITEM

using Server;
using System;
using System.Collections.Generic;
using Server.Mobiles;
using Server.Items;
using Server.Commands;
using Server.Misc;

#if STOREONITEM
#else
using Scripts.Mythik.Mobiles;
#endif

using Scripts.Systems.Achievements.Gumps;

namespace Scripts.Systems.Achievements
{
    //TODO
    //subcategories X
    //page limit?
    // Achievement prereq achieve before showing X
    //TODO Skill gain achieves needs event X
    //TODO ITEM crafted event sink X
    //TODO SKILL USE
    //TODO HousePlaced event sink
    /*thought of eating a lemon (and other foods), consume pots,
     *  craft a home,
     *  own home (more for larger homes),
     *  loot x amount of gold,
     *  find a uni,
     *  kill each mob in the game,
     *   enter an event,
     *    tame all tamables,
     *     use a max powerscroll (or skill stone),
     *     ride each type of mount
     */
    public class AchievmentSystem
    {
        public class AchievementCategory
        {
            public int ID { get; set; }
            public int Parent { get; set; }
            public string Name;


            public AchievementCategory(int id, int parent, string v3)
            {
                ID = id;
                Parent = parent;
                Name = v3;
            }
        }
        public static List<BaseAchievement> Achievements = new List<BaseAchievement>();
        public static List<AchievementCategory> Categories = new List<AchievementCategory>();

        public static void Initialize()
        {
          //  Categories.Add(new AchievementCategory(1, 0, "Exploration"));
         //   Categories.Add(new AchievementCategory(2, 1, "Towns"));
          //  Categories.Add(new AchievementCategory(3, 1, "Dungeons"));

          // Categories.Add(new AchievementCategory(4, 0, "Crafting"));
           // Categories.Add(new AchievementCategory(5, 0, "Resource Gathering"));
            Categories.Add(new AchievementCategory(6, 0, "Hunting"));
         //   Categories.Add(new AchievementCategory(7, 0, "Character Development"));
        //    Categories.Add(new AchievementCategory(8, 0, "Other"));

            //Achievements.Add(new DiscoveryAchievement(0, 2, 0, false, null, "Minoc!", "Discover Minoc Township", 5, "Minoc"));
            //Achievements.Add(new DiscoveryAchievement(1, 2, 0, false, null, "Yew!", "Discover the Yew Township", 5, "Yew"));
            //Achievements.Add(new DiscoveryAchievement(2, 2, 0, false, null, "Trinsic!", "Discover the Trinsic Township", 5, "Trinsic"));
            //Achievements.Add(new DiscoveryAchievement(3, 2, 0, false, null, "Cove!", "Discover the Cove Township", 5, "Cove"));
            //Achievements.Add(new DiscoveryAchievement(4, 3, 0, false, null, "Wrong!", "Discover the dungeon of Wrong", 5, "Wrong"));
            //Achievements.Add(new DiscoveryAchievement(5, 3, 0, false, null, "Shame!", "Discover the dungeon of Shame", 5, "Shame"));

          //  Achievements.Add(new ItemCraftedAchievement(50, 4, 0xF52, false, null, 2, "Dagger", "1 Dagger", 1, typeof(Dagger)));

         //   var achieve = new HarvestAchievement(100, 5, 0, false, null, 500, "500 Iron Ore", "Mine 500 Iron Ore", 5, typeof(//IronOre), typeof(AncientSmithyHammer));
         //   Achievements.Add(achieve);
         //   Achievements.Add(new HarvestAchievement(100, 5, 0, false, achieve, 500, "50000 Iron Ore", "Mine 500 Iron Ore", 5, //typeof(IronOre), typeof(AncientSmithyHammer)));

            Achievements.Add(new HunterAchievement(300, 6, 0x25D1, false, null, 5, "Dog Slayer", "Slay 5 Dogs", 5, typeof(Dog)));
            Achievements.Add(new HunterAchievement(301, 6, 0x25D1, false, null, 50, "Dragon Slayer", "Slay 50 Dragon", 5, typeof(Dragon)));

            CommandSystem.Register("feats", AccessLevel.Player, new CommandEventHandler(OpenGump));

        }

        private static void OpenGump(CommandEventArgs e)
        {
            var player = e.Mobile as PlayerMobile;
            if(player != null)
            {
#if STOREONITEM
           if (!AchievementSystemMemoryStone.GetInstance().Achievements.ContainsKey(player.Serial))
                AchievementSystemMemoryStone.GetInstance().Achievements.Add(player.Serial, new Dictionary<int, AchieveData>());
            var achieves = AchievementSystemMemoryStone.GetInstance().Achievements[player.Serial];
                var total = AchievementSystemMemoryStone.GetInstance().GetPlayerPointsTotal(player);
#else
                var achieves = (player as MythikPlayerMobile).Achievements;
                var total = (player as MythikPlayerMobile).AchievementPointsTotal;
#endif
                e.Mobile.SendGump(new AchievementGump(achieves, total));
            }
           
        }

        internal static void SetAchievementStatus(PlayerMobile player, BaseAchievement ach, int progress)
        {
#if STOREONITEM
           if (!AchievementSystemMemoryStone.GetInstance().Achievements.ContainsKey(player.Serial))
                AchievementSystemMemoryStone.GetInstance().Achievements.Add(player.Serial, new Dictionary<int, AchieveData>());
            var achieves = AchievementSystemMemoryStone.GetInstance().Achievements[player.Serial];
#else
            var achieves = (player as MythikPlayerMobile).Achievements;
#endif
            if (achieves.ContainsKey(ach.ID))
            {
                if (achieves[ach.ID].Progress >= ach.CompletionTotal)
                    return;
                achieves[ach.ID].Progress += progress;
            }
            else
            {
                achieves.Add(ach.ID, new AchieveData() { Progress = progress });
            }

            if (achieves[ach.ID].Progress >= ach.CompletionTotal)
            {
                player.SendGump(new AchievementObtainedGump(ach),false);
                achieves[ach.ID].CompletedOn = DateTime.UtcNow;
#if STOREONITEM
                AchievementSystemMemoryStone.GetInstance().AddPoints(player,ach.RewardPoints);
#else
                (player as MythikPlayerMobile).AchievementPointsTotal += ach.RewardPoints;
#endif
                if (ach.RewardItems != null && ach.RewardItems.Length > 0)
                {
                    try
                    {
                        player.SendAsciiMessage("You have recieved an award for completing this achievment!");
                        var item = (Item)Activator.CreateInstance(ach.RewardItems[0]);
                        if (!WeightOverloading.IsOverloaded(player))
                        {
                            player.Backpack.DropItem(item);
                        }
                        else
                        {
                            player.BankBox.DropItem(item);
                        }
                    }
                    catch { }
                }
            }
        }


    }
}


ERRORS:

Errors:
+ KUSTOM/Achievement System/AcheivmentSystem.cs:
CS1729: Line 104: 'Scripts.Systems.Achievements.Gumps.AchievementGump' does
not contain a constructor that takes '2' arguments



This is the method that gives me the error:

Code:
e.Mobile.SendGump(new AchievementGump(achieves, total));

I comment it out, server compiles, but after i kill 5 dogs, nothing happens.


Thanks!
 
You will need to supply the code which contains the AchievementGump class. The issue here is you are trying to instantiate an object with either too many arguments or not enough. When you comment it out of course nothing will happen since you have no path to the code any more.

Also, it would help others if you linked to the system you are using: https://www.servuo.com/threads/achievement-system.5375/
 
You will need to supply the code which contains the AchievementGump class. The issue here is you are trying to instantiate an object with either too many arguments or not enough. When you comment it out of course nothing will happen since you have no path to the code any more.

Also, it would help others if you linked to the system you are using: https://www.servuo.com/threads/achievement-system.5375/


Oops my bad

these are the gump files


Code:
using Server.Gumps;
using System.Collections.Generic;
using Server.Network;
using System.Linq;

namespace Scripts.Systems.Achievements.Gumps
{
    class AchievementGump : Gump
    {
        private int m_curTotal;
        private Dictionary<int, AchieveData> m_curAchieves;

        public AchievementGump(Dictionary<int, AchieveData> achieves, int total,int category ) : base(25, 25)
        {
           
            m_curAchieves = achieves;
            m_curTotal = total;
            this.Closable = true;
            this.Disposable = true;
            this.Dragable = true;
            this.Resizable = false;
            this.AddPage(0);
            this.AddBackground(11, 15, 758, 575, 2600);
            this.AddBackground(57, 92, 666, 478, 9250);
            this.AddBackground(321, 104, 386, 453, 9270);
            this.AddBackground(72, 104, 245, 453, 9270);
            this.AddBackground(72, 34, 635, 53, 9270);
            this.AddBackground(327, 0, 133, 41, 9200);
            this.AddLabel(292, 52, 68, @"Achievement System");
            this.AddLabel(360, 11, 82, total + @" Points");
            this.AddBackground(341, 522, 353, 26, 9200);

            int cnt = 0;
            for(int i = 0;i < AchievmentSystem.Categories.Count; i++)
            {
                int x = 90;
                int bgID = 9200;
                var cat = AchievmentSystem.Categories[i];
                var reqCat = AchievmentSystem.Categories.Where(c => c.ID == category).FirstOrDefault();

                if (cat.Parent != 0 && cat.ID != reqCat.ID && cat.Parent != reqCat.ID && cat.Parent != reqCat.Parent)
                    continue;
                if(cat.Parent != 0)
                    x += 20;
                if(cat.ID == category)
                    bgID = 5120;

                this.AddBackground(x, 123 + (cnt * 31), 18810 / x, 25, bgID);
                if (cat.ID == category) // selected
                    this.AddImage(x + 12, 129 + (cnt * 31), 1210);
                else
                    this.AddButton(x + 12, 129 + (cnt * 31), 1209, 1210, 5000 + cat.ID, GumpButtonType.Reply, 0);
                this.AddLabel(x + 32, 125 + (cnt * 31), 0, cat.Name);
                cnt++;
            }
            cnt = 0;
            foreach( var ac in AchievmentSystem.Achievements)
            {
               
                if (ac.CategoryID == category)
                {
                    if(ac.PreReq != null)
                    {
                        if (!achieves.ContainsKey(ac.PreReq.ID))
                            continue;
                        if(achieves[ac.PreReq.ID].CompletedOn != null)
                            continue;

                    }
                    if (achieves.ContainsKey(ac.ID))
                    {
                        AddAchieve(ac, cnt, achieves[ac.ID]);
                    }
                    else
                    {
                        if (ac.HiddenTillComplete)
                            continue;
                        AddAchieve(ac, cnt,null);
                    }
                    cnt++;
                }               
            }
        }
       
        private void AddAchieve(BaseAchievement ac, int i, AchieveData acheiveData)
        {
            int index = i % 4;
            if(index == 0)
            {
                this.AddButton(658, 524, 4005, 4006, 0, GumpButtonType.Page, (i / 4) + 1);
                AddPage((i / 4) + 1);
                this.AddLabel(484, 526, 32, "Page " + ((i / 4) + 1));
                this.AddButton(345, 524, 4014, 4015, 0, GumpButtonType.Page, i/4);
            }
            int bg = 9350;
            if (acheiveData != null && acheiveData.CompletedOn != null)
                bg = 9300;
            this.AddBackground(340, 122 + (index * 100), 347, 97, bg);
            this.AddLabel(414, 131 + (index * 100), 49, ac.Title);
            if(ac.ItemIcon > 0)
                this.AddItem(357, 147 + (index * 100), ac.ItemIcon);
            this.AddImageTiled(416, 203 + (index * 100), 95, 9, 9750);

            var step = 95.0 / ac.CompletionTotal;
            var progress = 0;
            if (acheiveData != null && acheiveData.CompletedOn != null)
                progress = acheiveData.Progress;

            this.AddImageTiled(416, 203 + (index * 100), (int)(progress * step), 9, 9752);
            this.AddHtml(413, 152 + (index * 100), 194, 47,ac.Desc, (bool)true, (bool)true);
            if (acheiveData != null && acheiveData.CompletedOn != null)
                this.AddLabel(566, 127 + (index * 100), 32, acheiveData.CompletedOn.ToShortDateString());

            if(ac.CompletionTotal > 1)
                this.AddLabel(522, 196 + (index * 100), 0, progress + @" / " + ac.CompletionTotal);

            this.AddBackground(628, 149 + (index * 100), 48, 48, 9200);
            this.AddLabel(648, 163 + (index * 100), 32, ac.RewardPoints.ToString());

        }

        public override void OnResponse(NetState sender, RelayInfo info)
        {
            base.OnResponse(sender, info);
            if (info.ButtonID == 0)
                return;
            var btn = info.ButtonID - 5000;
            if (btn >= 0 && btn < AchievmentSystem.Categories.Count)
                sender.Mobile.SendGump(new AchievementGump(m_curAchieves, m_curTotal, btn));
        }


    }
}


Code:
using Server.Gumps;

namespace Scripts.Systems.Achievements.Gumps
{
    class AchievementObtainedGump : Gump
    {
        private BaseAchievement ach;

        public AchievementObtainedGump(BaseAchievement ach):base(470,389)
        {
            this.ach = ach;

            this.Closable = true;
            this.Disposable = true;
            this.Dragable = true;
            this.Resizable = false;
            this.AddPage(0);
            this.AddBackground(39, 38, 350, 100, 9270);
            this.AddAlphaRegion(48, 45, 332, 86);
            if(ach.ItemIcon > 0)
                this.AddItem(39, 52, ach.ItemIcon);
            this.AddLabel(121, 55, 49, ach.Title);
            this.AddHtml(120, 80, 167, 42, ach.Desc, (bool)true, (bool)true);
            this.AddLabel(275, 51, 61, @"COMPLETE");
            this.AddBackground(320, 72, 44, 47, 9200);
            this.AddLabel(337, 87, 0, ach.RewardPoints.ToString());
        }
    }
}

Props to @darklotus
 
Your code is missing the Categories parameter. It's an integer so would be a whole number. I am not sure of the system as I have not looked at the code but I assume there is some other achievements that do work. You should look at them to see how the category parameter should be assigned.
 
You also have the whole event subscription commented out which means nothing will happen anyway.
 
I had a quick look at the code for the achievement system on github. Why did you remove the = 1 from the gump signature? That creates an optional parameter which means you do not need to set it which is why the instantiation does not have the category parameter. Put =1 back into the signature and remove the comment around the event subscription and it should work.
 
I had a quick look at the code for the achievement system on github. Why did you remove the = 1 from the gump signature? That creates an optional parameter which means you do not need to set it which is why the instantiation does not have the category parameter. Put =1 back into the signature and remove the comment around the event subscription and it should work.

I was getting the next error:
KUSTOM/Achievement System/Gumps/AchievementGump.cs:
CS0241: Line 13: Default parameter specifiers are not permitted

Somebody told me to delete it:


The error just comes from the old version of net framework that is set in runuo 2.2, so the issue is "int category =1". So remove the =1 and I guess you will need to adjust the script further since it may not actually set the category in some places


Okey, let me try it
[doublepost=1475493519][/doublepost]I did everything you told me:


Errors:
+ KUSTOM/Achievement System hunter/Gumps/AchievementGump.cs:
CS0241: Line 13: Default parameter specifiers are not permitted

Yes! im using runuo (No offense) hehe
 
Ahh you are using RunUO.

Then you will need to set the category in the instantiation.

This should be okay since the category is defaulted to one anyway.
Code:
e.Mobile.SendGump(new AchievementGump(achieves, total, 1));

You will still need to uncomment the event subscription.
 
If i put the = 1 back i get the next error:

Errors:
+ KUSTOM/Achievement System hunter/Gumps/AchievementGump.cs:
CS0241: Line 13: Default parameter specifiers are not permitted

if i remove it , this one appears;

CS0642: Line 242: Possible mistaken empty statement
Errors:
+ KUSTOM/Achievement System hunter/AchieveTypes/HunterAchievement.cs:
CS0117: Line 15: 'Server.EventSink' does not contain a definition for 'OnKil
ledBy'

Thanks.
 
Then RunUO does not have the required event in the event sink. You will need to add this yourself. All the code is in the ServUO core.
 
If i put the = 1 back i get the next error:

Errors:
+ KUSTOM/Achievement System hunter/Gumps/AchievementGump.cs:
CS0241: Line 13: Default parameter specifiers are not permitted

if i remove it , this one appears;

CS0642: Line 242: Possible mistaken empty statement
Errors:
+ KUSTOM/Achievement System hunter/AchieveTypes/HunterAchievement.cs:
CS0117: Line 15: 'Server.EventSink' does not contain a definition for 'OnKil
ledBy'

Thanks.
Yes, this is where I found out the system required you to recompile your core with the updated EventSink.cs from ServUO's repo. You'll have to merge their EventSink.cs with yours, recompile the core and you should be fine, assuming there are errors from the recompile.
 
Yes, this is where I found out the system required you to recompile your core with the updated EventSink.cs from ServUO's repo. You'll have to merge their EventSink.cs with yours, recompile the core and you should be fine, assuming there are errors from the recompile.

That is not enough, you also need to invoke the event or subscribed methods will never fire.

Going by the name of the event I am guessing the invocation is in basecreature. Search for EventSink.InvokeOnKilledBy(...);
 
That is not enough, you also need to invoke the event or subscribed methods will never fire.

Going by the name of the event I am guessing the invocation is in basecreature. Search for EventSink.InvokeOnKilledBy(...);
You can be such a buzzkill sometimes Murph :eek: :p LOL
Yeah, he's right, of course, I haven't gotten that far, yet, so I wasn't sure :)
 
boooo.png Server doesnt compile, it just close quickly, i could capture some errors:

Anyway this is what i added to my Basecreature.cs and my EvenSink.cs

Basecreature.cs:


Code:
    public virtual void OnKilledBy( Mobile mob )
         {
           #region Bittiez Kill Point Tracker
           KPTEventSink.InvokeOnKilledBy(new OnKilledByEventArgs(this, mob));
           #endregion
           #region Mondain's Legacy
           if ( GivesMLMinorArtifact )
           {
           if ( MondainsLegacy.CheckArtifactChance( mob, this ) )
           MondainsLegacy.GiveArtifactTo( mob );
           }
           #endregion
        
           else if ( m_Paragon )
          {
          if ( Paragon.CheckArtifactChance( mob, this ) )
           Paragon.GiveArtifactTo( mob );
           }
           //////////////
          // #region invoke
        EventSink.InvokeOnKilledBy(new OnKilledByEventArgs(this, mob));
        //#endreigon
        /////////////
}

EventSink.cs:


Code:
 public static void InvokeOnKilledBy(OnKilledByEventArgs e)
        {
            if (OnKilledBy != null)
            {
                OnKilledBy(e);
            }
        }


Code:
public delegate void OnKilledByEventHandler(OnKilledByEventArgs e);


Code:
public class OnKilledByEventArgs : EventArgs
    {
        private readonly Mobile m_Killed;
        private readonly Mobile m_KilledBy;

        public OnKilledByEventArgs(Mobile killed, Mobile killedBy)
        {
            m_Killed = killed;
            m_KilledBy = killedBy;
        }

        public Mobile Killed { get { return m_Killed; } }
        public Mobile KilledBy { get { return m_KilledBy; } }
    }
 
That is because your core doesn't match your scripts. There were more things added in ServUO, besides the EventSinks that match this Achievement system. If you only add the EventSinks for this system to your EventSink.cs in the Server folder and recompile your core with the above changes you made, I think that will fix it :)
 
You want me to skip the one i added on basecreature?

Well i cant recompile anymore , how bad is not being able to recompile?

Maybe i added too much scripts, have been adding stuff for almost 9 months, theres no way to know whats causing it lol
 
Last edited:

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back