Jump to content
  • 2

Tile that does not remove items


Worldofjimmy

Question

4 answers to this question

Recommended Posts

  • 0

No idea if this will work or not, but something like this should point you (or someone else) in the right direction:

 

Alright, so core changes...

Spoiler

Open Intersect (Core)/GameObjects/Maps/MapAttribute.cs

Under


                case MapAttributes.Slide:
                    return new MapSlideAttribute();

Add


                case MapAttributes.ItemSkipDespawn:
                    return new MapItemSkipDespawnAttribute();

 

And under


public class MapSlideAttribute : MapAttribute
    {

        public override MapAttributes Type { get; } = MapAttributes.Slide;

        public byte Direction { get; set; }

        public override MapAttribute Clone()
        {
            var att = (MapSlideAttribute) base.Clone();
            att.Direction = Direction;

            return att;
        }

    }

Add


public class MapItemSkipDespawnAttribute : MapAttribute
    {

        public override MapAttributes Type { get; } = MapAttributes.ItemSkipDespawn;

    }

 

 

Server changes...

Spoiler

Open Intersect.Server/Maps/MapInstance.cs

Find


    public void RemoveItem(int index, bool respawn = true)
        {
            if (index < MapItems.Count && MapItems[index] != null)
            {
                MapItems[index].ItemId = Guid.Empty;
                PacketSender.SendMapItemUpdate(Id, index);
                if (respawn)
                {
                    if (MapItems[index].AttributeSpawnX > -1)
                    {
                        ItemRespawns.Add(new MapItemSpawn());
                        ItemRespawns[ItemRespawns.Count - 1].AttributeSpawnX = MapItems[index].AttributeSpawnX;
                        ItemRespawns[ItemRespawns.Count - 1].AttributeSpawnY = MapItems[index].AttributeSpawnY;
                        ItemRespawns[ItemRespawns.Count - 1].RespawnTime =
                            Globals.Timing.TimeMs + Options.ItemRepawnTime;
                    }
                }

                MapItems[index] = null;
            }
        }

And change it to


    public void RemoveItem(int index, bool respawn = true)
        {
            if (index < MapItems.Count && MapItems[index] != null)
            {
                if (Attributes[MapItems[index].X, MapItems[index].Y] != MapAttributes.ItemSkipDespawn)
                {
                    MapItems[index].ItemId = Guid.Empty;
                    PacketSender.SendMapItemUpdate(Id, index);
                    if (respawn)
                    {
                        if (MapItems[index].AttributeSpawnX > -1)
                        {
                            ItemRespawns.Add(new MapItemSpawn());
                            ItemRespawns[ItemRespawns.Count - 1].AttributeSpawnX = MapItems[index].AttributeSpawnX;
                            ItemRespawns[ItemRespawns.Count - 1].AttributeSpawnY = MapItems[index].AttributeSpawnY;
                            ItemRespawns[ItemRespawns.Count - 1].RespawnTime =
                                Globals.Timing.TimeMs + Options.ItemRepawnTime;
                        }
                    }

                    MapItems[index] = null;
                }
            }
        }

 

 

Editor changes...

Spoiler

Open 

 

Under


            else if (rbSlide.Checked == true)
            {
                return (int) MapAttributes.Slide;
            }

Add


            else if (rbItemSkipDespawn.Checked == true)
            {
                return (int) MapAttributes.ItemSkipDespawn;
            }

Then under


            else if (rbSlide.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.Slide);
                ((MapSlideAttribute) tmpMap.Attributes[x, y]).Direction = (byte) cmbSlideDir.SelectedIndex;
            }

Add


            if (rbItemSkipDespawn.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.ItemSkipDespawn);
            }

 

 

Other than that, you'll need to add a radiobutton named rbItemSkipDespawn to the editor form (you'll also need the hide code for it, or you can probably add it to grpItem.

 

 

This code is untested, I wrote it using the github for guidance, so I may be missing something and it won't work, or it'll work fine. Hopefully it's a good starting point for someone :)

Link to comment
Share on other sites

  • 0

I almost think event tiles would work better. Even takes an item, turns into a shelf, and then you can get your item back later. That event would be massive but could then be copied and pasted to like 10 locations in the house or something. 

 

If you're just dropping inventory items you're very limited, and they will vanish on server reboots. @MohenjoDaro is on the right track though for doing what you asked. 

Link to comment
Share on other sites

  • 0

A game I used to play called NexusTK had a system in place where they would just turn off "item sweeps" as they called it for certain maps. Items would not disappear when dropped on those maps unless the server reset or crashed. Typically server resets were scheduled. Players often wanted to decorate the "floors" with items when they held events or gatherings. I imagine it would be more simple to just code a map flag that if marked the sweep system would not delete items on that map.

Spoiler

three.jpg

 

Additionally, like JC said a great way to make a house decoration system would be using events and use items like "Bookshelf" that when used on a tile could be placed and would not disappear on reset, and could give back your item or have another function. It is my hope to eventually code something like this, with map ownership. When a map was assigned to a player they had permission to alter the map to some degree (Stardew valley style with item placement).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...