Results 1 to 3 of 3
  1. #1
    The First Sin's Avatar
    Join Date
    May 2016
    Gender
    male
    Location
    At the Jugg House
    Posts
    54
    Reputation
    10
    Thanks
    16
    My Mood
    Devilish

    Post Cooking & Campfire

    Cooking...self explanatory but I cannot say the same for the coding, I am to lazy to make it simpler but at least it is something to work off if anyone is interested.

     

    This just checks if X and Y is a <Campfire/> don't bother this it isn't really to be changed
    Code:
            public bool IsCampFire(int x, int y)
            {
                var tile = Map[x, y];
                ObjectDesc desc;
                if (Manager.GameData.ObjectDescs.TryGetValue(tile.ObjType, out desc))
                {
                    if (!desc.Campfire)
                        return false;
                }
                return true;
            }


     

    <Cookable/> Add this to your item or it will not "cook"
    Code:
        public bool Cookable { get; private set; }
        Cookable = elem.Element("Cookable") != null;
    <Campfire/> Add this to the non-static object that will be your campfire, the player must stand on top of the campfire for it to work.
    Code:
        public bool Campfire { get; private set; }
        Campfire = elem.Element("Campfire") != null;

     

    You don't have to worry about the command itself, the raw/cooked food item type goes in the cookassociation
    Code:
        internal class Cook : Command
        {
            public Cook() : base("cook"){}
            protected override bool Process(Player player, RealmTime time, string[] args)
            {
                if (args.Length == 0)
                {
                    player.SendHelp("Usage: /cook <Cookable-ItemName>");
                    return false;
                }
                string name = string.Join(" ", args.ToArray()).Trim();
                ushort obj_1;
                 Dictionary<string, ushort> icdatas = new Dictionary<string,  ushort>(player.Manager.GameData.IdToObjectType,
                    StringComparer.OrdinalIgnoreCase);
                if (!icdatas.TryGetValue(name, out obj_1))
                {
                    player.SendError("Unknown type!");
                    return false;
                }
                if (!CookAssociation.CheckForCampfire(player))
                {
                    player.SendError("You must be standing on top of a campfire!");
                    return false;
                }
                if (player.Manager.GameData.Items[obj_1].Cookable)
                {
                    ushort obj_2 = CookAssociation.ItemConversion(obj_1);
                    for (int g = 0; g < player.Inventory.Length; g++)
     
    Code:
                   {
                           if (player.Inventory[g] != player.Manager.GameData.Items[obj_1]) { continue;}
                        player.Inventory[g] = player.Manager.GameData.Items[obj_2];
                           player.UpdateCount++;                       player.SaveToCharacter();
                           player.SendInfo("Success!");
                           break;
                    }
                }
                else
                {
                    player.SendError("The item is not Cookable");
                    return false;
                }
                return true;
            }
        }
    

    It is a two set piece to simplify and shorten the command so it doesn't get filled with spam.
    the ItemConversion is where you will place the raw food to/=> cooked food.
    NOTE : Currently in the case and switch it has case 0x999 and return 0x998 these are not real items it is just there to fill in.
    SECONDARY NOTE : CASE is the RAW food and RETURN is the COOKED food

    Code:
        internal class CookAssociation
        {
            public static bool CheckForCampfire(Player player)
            {
                int x = (int) player.X;
                int y = (int) player.Y;
                return (player.Owner.IsCampFire(x, y));
            }
    
            public static ushort ItemConversion(ushort obj_1)
            {
                switch (obj_1)
                {
                    case 0x999:
                        return 0x998;
                    default:
                        return obj_1;
                }
            }
        }

    There is not suppose to be 2 spoilers of Command.cs MPGH is just being annoying and somehow glitching.

    If I were to use this I would have to stand on top of the campfire, type /cook "item", and it will automatically give me the corresponding item.


    @Riigged Sorry, for taking your idea if you wish I can request the moderators to remove this just pm me.
    @Joe @Nyaro's Panda Close it, anyone with any questions or concerns just pm me.
    Last edited by The First Sin; 05-31-2016 at 05:02 AM.
    Be thankful that you're blessed yet cursed with life and death.
     



    Violence, Bad Words, Scammers, Pornography, Drugs, Discrimination, Gambling, All on the internet.
    PEGI FAQ
    Review Internet Safety and Stay Safe Kids.

     


    ESRB RATINGS GUIDE
    Review Internet Safety and Stay Safe Kids.



    Gaming since 1994
    Microsoft Computing since 2000
    C since 2001
    Java since 2003
    Mobile since 2007
    Python since 2010


  2. #2
    Riigged's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Location
    no
    Posts
    3,846
    Reputation
    401
    Thanks
    10,254
    My Mood
    Devilish
    I dont mind, I shared the idea on the thread for the exact reason: so people can use it.
    I already finished mine, although its done differently, no command is used, its just automatic when you stand on a tile around the campfire (I just use forbidden jungle fire texture xD)

     








  3. #3
    Luis's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Posts
    2,801
    Reputation
    348
    Thanks
    1,846
    My Mood
    Psychedelic
    Requested Close

Similar Threads

  1. AMP Energy Drink Coupon - Free 4 PK of AMP
    By I Am Cornholio in forum General
    Replies: 6
    Last Post: 07-13-2009, 09:00 PM
  2. Selling 115 Rs acc 99Fish/Cook - Paypal
    By Jakeyy in forum Trade Accounts/Keys/Items
    Replies: 11
    Last Post: 08-31-2008, 12:33 PM
  3. Dane Cook-Crying
    By Gourav2122 in forum General
    Replies: 0
    Last Post: 07-16-2008, 12:40 PM
  4. Some steals my dish in cooking class.
    By radnomguywfq3 in forum General
    Replies: 12
    Last Post: 04-26-2008, 05:57 PM
  5. Bow to the almighty Dane Cook
    By NeedHacksBad in forum General
    Replies: 5
    Last Post: 09-14-2007, 02:43 PM