I've been toying around with the idea of making reptile/arachnid based pets which can heal themselves by "molting" their skin.

Its easy enough to create the logic to cause them to heal themselves by "molting", but what I want to do is also make it create a corpse when they do it, renamed to "molted skin".

It would produce a really cool effect, but I've absolutely no idea how to accomplish it, and I can't think of any scripts that do something like that already. It doesn't even need to function as a corpse, just needs to look like it.
 
If I were doing something like that I would:

Make a new item based on the desired corpse that self deletes after x amount of time.
then in the "molting" creatures script when it molts just

var molt = new MoltItemNameHere();
molt.MoveToWorld(this.Location, this.Map)
 
If I were doing something like that I would:

Make a new item based on the desired corpse that self deletes after x amount of time.
then in the "molting" creatures script when it molts just

var molt = new MoltItemNameHere();
molt.MoveToWorld(this.Location, this.Map)

See I think that would proably work - but it would require me to create a corpse "script" for every single type of animal that I have using that function. Seems much more reasonable to just figure out how to hook in and use the corpse generation code that already exists, which automatically determines what corpse id to create and would use the same hue, ect.
 
Corpse generation is a weird one, because they all use the same ItemID - the thing that changes is the Body, based on the creature that died.

It should be possible to manually invoke the CreateCorpseHandler in order to create new corpses at will - I believe there is already a specific mod in place that covers one special mob's corpse creation so that it produces a non-standard corpse class derived from the stock Corpse class.
This is likely what you'd need to do. If you don't want it to function like an actual corpse, you can probably just set IsDecorationContainer to true.
 
Thanks Voxpire, if you recall what the mod is that I might be able to look at let me know. For now this is on the backburner anyway, more of a flavour thing than a necessity.
 
This is the mod, it's been in stock RunUO for as long as I can remember - in the stock Mobile_CreateCorpseHandler method in Corpse.cs:

(Line 475~~)
Code:
            Corpse c;

            if (owner is MilitiaFighter)
                c = new MilitiaFighterCorpse(owner, hair, facialhair, face, equipItems);
            else
                c = new Corpse(owner, hair, facialhair, face, equipItems);

You could add whatever logic you need to here for your custom mobile, perhaps setting corpse to 'new MyCustomCorpse( ... )' for example, which contains further logic for the corpse' behaviour.

You may have to compensate for scenarios where your mob is naturally killed, or when you've manually called the handler.
 
Ah yea I had noticed that while rooting around the corpse.cs, I just wouldn't know how to force it to happen. I'm using basecreature.cs with a custom "molting" ability, I'd somehow need to make that section of basecreation.cs spawn the corpse if possible.
 
I suppose you can skip the CorpseCreationHandler actually, and just do something like this:

Code:
// 'this' represents the current BaseCreature instance
// This code could be called from wherever you need it - in the method that controls the Molting ability execution.

var corpse = new MyCustomCorpse(this, hair, facialhair, face, equipItems);

corpse.MoveToWorld( this.Location, this.Map );

You'd need to make sure you create a MyCustomCorpse class that derives from Corpse for this to work.
Essentially the only big change in your MyCustomCorpse should be the IsDecorationContainer (false) mod.

'hair', 'facialhair', 'face' and 'equipItems' will all have to be resolved properly, you can probably get away with supplying dummy values:

Code:
var corpse = new MyCustomCorpse(this, new HairInfo(0), new FacialHairInfo(0), new FaceInfo(0), new List<Item>());
 
Amazing, so simple :D

I did a quick test of it with out creating a custom class (just used Corpse), and I omitted the new FaceInfo portion because it would seem that isn't necessary, at least not using JustUO 2.5. Works flawlessly.

I'm guessing the reason you suggested creating the custom class is so I could set the corpse to decorative? Or is there a more important reason to do that?
 
Creating the new corpse class would allow you to easily identify its type, making life easier in the future when developing new features that may tie-in with it.
However, it's not necessary as you've found out :)

If you do want to set the IsDecorationContainer value to true, it isn't a settable property, so it has to be overridden in a base class. I can't remember if its default value is true already (though I doubt it).
 
Creating the new corpse class would allow you to easily identify its type, making life easier in the future when developing new features that may tie-in with it.
However, it's not necessary as you've found out :)

If you do want to set the IsDecorationContainer value to true, it isn't a settable property, so it has to be overridden in a base class. I can't remember if its default value is true already (though I doubt it).

I can absolutely see why you are correct in your logic there. But, being the armchair "doing this for fun not actually running a server" developer that I am, this method works just fine for me :D. I'm able to set the corpse.MaxItems to 0 so people can't mistakenly drop items on it or something - and if that doesn't solve the issue of people skinning the corpse, i can always set it to IsCarved true as well on spawn.
[doublepost=1483685261][/doublepost]Seems like I'm slightly off with my logic though, setting the name and maxitems in the logic compiles - and even in game using [props displays the correct maxitems of 0 and name "molted skin" - but it doesn't actually seem to be having an impact.

Obviously missing something with how that logic works, which means its probably best to just create a custom class for it. No biggie.
 
Back