Full Version : Corpse Name Change?
xmlspawner >>XMLSpawner Mods and Tips >>Corpse Name Change?


<< Prev | Next >>

DrussRob- 01-16-2006
One more then I promise to leave you alone for the day tongue.gif

Can that be done? Changing the name of a scripted creatures corpse?
As you can tell I'm experimenting with making totally new creatures in the spawner itself outside of scripting them. Almost like scripting on the fly wink.gif
I love it hehe

ArteGordon- 01-16-2006
the corpse name is actually an attribute of the class type, so by default, you cannot change the name of the corpse for individual instances of creatures.

But a simple modification to the GetCorpseName method in Corpse.cs will let you do it smile.gif

For this sort of thing I make use of the XmlData attachment that allows you to dynamically add a new data to objects. In this case you would add a new CorpseName property that can be checked in GetCorpseName.

Just make this change in Corpse.cs

QUOTE

  public static string GetCorpseName( Mobile m )
  {

  XmlData x = (XmlData)XmlAttach.FindAttachment(m, typeof(XmlData), "CorpseName");
  if (x != null)
  {
    return x.Data;
  }

  Type t = m.GetType();

  object[] attrs = t.GetCustomAttributes( typeof( CorpseNameAttribute ), true );

  if ( attrs != null && attrs.Length > 0 )
  {
    CorpseNameAttribute attr = attrs[0] as CorpseNameAttribute;

    if ( attr != null )
    return attr.Name;
  }

  return null;
  }


and add this to the beginning of Corpse.cs

CODE

using Server.Engines.XmlSpawner2;


Then when you spawn a creature, you can give the corpse any name you want. Like

orc/ATTACH/xmldata,CorpseName,a slimy little corpse

where CorpseName is the name of the attachment, and "a slimy little corpse" is the string data.

user posted image

To get a highly personalized corpse name like that (each orc will have his own named corpse), place these two spawn entries in subgroup 1

orc
SETONSPAWN,1/ATTACH/xmldata,CorpseName,the slimy little corpse of the miserable {GETONSPAWN,1,name}


the first entry spawns the orc, and the second adds the CorpseName with the actual name of the orc in the first entry substituted at the end.

DrussRob- 01-16-2006
my god man... this system is unreal. I cant say well done enough.

LowCastle- 01-18-2006
I must agree! I am constantly being amazed.

godfood- 01-18-2006
So show your appreciation by Posting in the "Coffee Table". Help us build a true community around this system smile.gif. I think Arte's been getting a little bit worn out between RunUO Orb And here. Not to mention he had a system meltdown recently. All he's been getting lately from this site is questions. (I too am guilty of this). Let's all make an effort to show our appreciation by being more active on these forums smile.gif.


(BTW, Yes, i am drunk....waht do you want? I need to have a good time too tongue.gif)