Full Version : custom treasure maps
xmlspawner >>XMLSpawner Mods and Tips >>custom treasure maps


<< Prev | Next >>

ArteGordon- 07-05-2006
QUOTE (Corbomite)
Wanted to spawn a treasure map that points to a specific tmap location.  Getting the map to spawn using treasuremap,4,trammel works fine.  But the location seems to be a random draw.  Is there a way to spawn the same tmap each time using an xmlspawner?


To do that would require a slight modification to TreasureMap.cs to support changing the chest location and updating the map accordingly.

Around line 37, just make this change

change this
CODE

 [CommandProperty( AccessLevel.GameMaster )]
 public Point2D ChestLocation{ get{ return m_Location; } set{ m_Location = value; } }



to this

CODE

 [CommandProperty( AccessLevel.GameMaster )]
 public Point2D ChestLocation{
  get{ return m_Location; }
  set
  {
   m_Location = value;
   int width = 600;
   int height = 600;

   int x1 = m_Location.X - Utility.RandomMinMax(width / 4, (width / 4) * 3);
   int y1 = m_Location.Y - Utility.RandomMinMax(height / 4, (height / 4) * 3);

   if (x1 < 0)
    x1 = 0;

   if (y1 < 0)
    y1 = 0;

   int x2 = x1 + width;
   int y2 = y1 + height;

   if (x2 >= 5120)
    x2 = 5119;

   if (y2 >= 4096)
    y2 = 4095;

   x1 = x2 - width;
   y1 = y2 - height;

   Bounds = new Rectangle2D(x1, y1, width, height);
   ClearPins();
   AddWorldPin(m_Location.X, m_Location.Y);
  }
 }


and then around line 200 change this

CODE

 [Constructable]
 public TreasureMap( int level, Map map )
 {
  m_Level = level;
  m_Map = map;

  if ( level == 0 )
   m_Location = GetRandomHavenLocation();
  else
   m_Location = GetRandomLocation();

  Width = 300;
  Height = 300;

  int width = 600;
  int height = 600;

  int x1 = m_Location.X - Utility.RandomMinMax( width / 4, (width / 4) * 3 );
  int y1 = m_Location.Y - Utility.RandomMinMax( height / 4, (height / 4) * 3 );

  if ( x1 < 0 )
   x1 = 0;

  if ( y1 < 0 )
   y1 = 0;

  int x2 = x1 + width;
  int y2 = y1 + height;

  if ( x2 >= 5120 )
   x2 = 5119;

  if ( y2 >= 4096 )
   y2 = 4095;

  x1 = x2 - width;
  y1 = y2 - height;

  Bounds = new Rectangle2D( x1, y1, width, height );
  Protected = true;

  AddWorldPin( m_Location.X, m_Location.Y );
 }


to this

CODE

 [Constructable]
 public TreasureMap( int level, Map map )
 {
  m_Level = level;
  m_Map = map;

  if ( level == 0 )
   ChestLocation = GetRandomHavenLocation();
  else
   ChestLocation = GetRandomLocation();

  Width = 300;
  Height = 300;

  Protected = true;

 }

and then you will be able to change the treasure location any time you like and the map will automatically change to reflect the new location even after the map has already been decoded.

treasuremap,4,trammel/chestlocation/(800,456)

the old constructor will still work as well if you want normal maps with the standard locations, like

treasuremap,4,trammel