1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Camps do not check for valid Z when placing items

Discussion in 'Archived Bug Reports' started by Lokai, May 17, 2018.

  1. Lokai
    Offline

    Moderator ServUO Developer

    Joined:
    Dec 4, 2014
    Messages:
    1,076
    Likes Received:
    155
    When camps spawn in uneven terrain, they are not checking for Z before placing items and mobiles. As a result, things get placed underground.

    The following code in BaseCamp is responsible for adding items to the map:

    Code (C#):
    1.  
    2.  
    3.         public virtual void AddItem(Item item, int xOffset, int yOffset, int zOffset)
    4.         {
    5.             this.m_Items.Add(item);
    6.  
    7.             int zavg = this.Map.GetAverageZ(this.X + xOffset, this.Y + yOffset);
    8.             item.MoveToWorld(new Point3D(this.X + xOffset, this.Y + yOffset, zavg + zOffset), this.Map);
    9.         }

    Should be:

    Code (C#):
    1.  
    2.  
    3.         public virtual void AddItem(Item item, int xOffset, int yOffset, int zOffset)
    4.         {
    5.             this.m_Items.Add(item);
    6.  
    7.             int zavg = this.Map.GetAverageZ(this.X + xOffset, this.Y + yOffset);
    8.  
    9.             if (this.Map.CanFit(this.X + xOffset, this.Y + yOffset, zavg, item.ItemData.Height) == false)
    10.             {
    11.                 for (int z = 1; z <= 39; z++)
    12.                 {
    13.                     if (this.Map.CanFit(this.X + xOffset, this.Y + yOffset, zavg + z, item.ItemData.Height))
    14.                     {
    15.                         zavg += z;
    16.                         break;
    17.                     }
    18.                 }
    19.             }
    20.             item.MoveToWorld(new Point3D(this.X + xOffset, this.Y + yOffset, zavg + zOffset), this.Map);
    21.         }
     
    #1 Lokai, May 17, 2018
    Last edited: May 17, 2018
  2. Dexter_Lexia
    Offline

    Moderator ServUO Developer

    Joined:
    Jul 3, 2014
    Messages:
    3,604
    Likes Received:
    142
    What about SpellHelper GetSurfaceTop?
     
  3. Dexter_Lexia
    Offline

    Moderator ServUO Developer

    Joined:
    Jul 3, 2014
    Messages:
    3,604
    Likes Received:
    142
    Ok, that won't work. I always thought GetAverageZ did this, but it's problematic with large drop offs one time adjacent. I think Map.cs needs a method for finding a spawnable surface that will adjust Z.
     
  4. Tasanar
    Offline

    Moderator

    Joined:
    Oct 16, 2014
    Messages:
    4,332
    Likes Received:
    94
    This issue has been reported a few times, in regards to the camp chests and escortable NPCs.
     
Similar Threads: Camps check
Forum Title Date
Archived Bug Reports NPC Camps - will not always load on-screen Jan 21, 2018
Archived Bug Reports Invisibe houses/camps for a player toons Dec 21, 2017
Archived Bug Reports Unused tiles at new Brigand Camps Nov 19, 2017
Archived Bug Reports BrigandCamps Nov 11, 2017
Archived Bug Reports Players farming Brigand camps @ New Haven - Smart spawning and the new loot system with chests. Mar 22, 2016
Script Support Shard Crash caused by spawners and Camps Jan 26, 2015
Custom Releases Old school prisoner camps Jan 4, 2015