Bug when setting no item loss on death to occur.

ParanoiaPhD

Well-Known Member
May 2, 2019
120
13
32
California
www.iceyou.org
Shard Name
Central USA
So I changed the code in playermobile.cs regarding what happens to your stuff when you die. Basically I made it so all your stuff goes into your back pack so you dont have to worry about item insurance anymore.

Everything was working fine! I thought I succeeded and moved on.

So today I decided to test it again to make sure but this time i was riding a swamp dragon that I had tamed. When I died everything went to my backpack perfectly but swamp dragon disappeared. I thought oh thats odd. When I checked my backpack there was a "Rudder" dyed the hue of the dragon barding deed I previously applied to the swamp dragon. I couldn't move the "rudder" and nothing happened when I double clicked it.

I tested this again with an ethereal lama. It disappeared like its supposed to but it didn't appear in my backpack. instead another boat part dyed black appeared. I couldn't move it but clicking it resulted in the ethereal mount casting animation but it just ended without riding the mount. the boat part in the case of ethereal mounts retains the name of the ethereal mount item.

So what could be causing this? Here is the code that I changed.

ORIGINAL
C#:
        public override DeathMoveResult GetParentMoveResultFor(Item item)
{
if (CheckInsuranceOnDeath(item) && !Young)
{
return DeathMoveResult.MoveToBackpack;
   }
   DeathMoveResult res = base.GetParentMoveResultFor(item);
   if (res == DeathMoveResult.MoveToCorpse && item.Movable && Young)
{
res = DeathMoveResult.MoveToBackpack;
   }
   return res;
  }
  public override DeathMoveResult GetInventoryMoveResultFor(Item item)
{
if (CheckInsuranceOnDeath(item) && !Young)
{
return DeathMoveResult.MoveToBackpack;
   }
   DeathMoveResult res = base.GetInventoryMoveResultFor(item);
   if (res == DeathMoveResult.MoveToCorpse && item.Movable && Young)
{
res = DeathMoveResult.MoveToBackpack;
   }
EDITED
C#:
        public override DeathMoveResult GetParentMoveResultFor(Item item)
        {
                                            
    
                                                                            
    

                                                                                                

                return DeathMoveResult.MoveToBackpack;
    
                                                      
    

                              
        }

        public override DeathMoveResult GetInventoryMoveResultFor(Item item)
        {
            
    
            return DeathMoveResult.MoveToBackpack;
    

            DeathMoveResult res = base.GetInventoryMoveResultFor(item);

            if (res == DeathMoveResult.MoveToCorpse && item.Movable)
            {
                res = DeathMoveResult.MoveToBackpack;
            }
13590
Post automatically merged:

well that was easy I fixed it...

C#:
        public override DeathMoveResult GetParentMoveResultFor(Item item)
        {
            if (CheckInsuranceOnDeath(item) && !Young)
            {
                return DeathMoveResult.MoveToBackpack;
            }

            DeathMoveResult res = base.GetParentMoveResultFor(item);

            if (res == DeathMoveResult.MoveToBackpack && item.Movable && Young)
            {
                res = DeathMoveResult.MoveToBackpack;
            }

            return res;
        }

        public override DeathMoveResult GetInventoryMoveResultFor(Item item)
        {
            if (CheckInsuranceOnDeath(item) && !Young)
            {
                return DeathMoveResult.MoveToBackpack;
            }

            DeathMoveResult res = base.GetInventoryMoveResultFor(item);

            if (res == DeathMoveResult.MoveToBackpack && item.Movable && Young)
            {
                res = DeathMoveResult.MoveToBackpack;
            }
 
Last edited:

ParanoiaPhD

Well-Known Member
May 2, 2019
120
13
32
California
www.iceyou.org
Shard Name
Central USA
Actually the last post I did seemed to work at the time for some reason... but I tried again today with pvp combat and it didn't work so I got to work on it again and figured this out. Now it for sure is working.

C#:
        public override DeathMoveResult GetParentMoveResultFor(Item item)
        {
            if (item.Movable)
            {
                return DeathMoveResult.MoveToBackpack;
            }

            DeathMoveResult res = base.GetParentMoveResultFor(item);

            if (res == DeathMoveResult.MoveToBackpack && item.Movable)
            {
                res = DeathMoveResult.MoveToBackpack;
            }

            return res;
        }

        public override DeathMoveResult GetInventoryMoveResultFor(Item item)
        {
            if (item.Movable)
            {
                return DeathMoveResult.MoveToBackpack;
            }

            DeathMoveResult res = base.GetInventoryMoveResultFor(item);

            if (res == DeathMoveResult.MoveToBackpack && item.Movable)
            {
                res = DeathMoveResult.MoveToBackpack;
            }

            return res;
        }
 

Dexter_Lexia

Moderator
ServUO Developer
Jul 3, 2014
3,935
169
43
Shard Name
Alexandria
Donate
Donate money to this user
This is not the proper spot to edit for this function. This checks for items that are newbied, blessed, etc. You'll need a check in that doesn't move invalid items to your pack, such as your mount (thats what these ship items are), hair, facial hair, face (for EC), etc.
 

ParanoiaPhD

Well-Known Member
May 2, 2019
120
13
32
California
www.iceyou.org
Shard Name
Central USA
Yeah so what was causing it was the fact that I removed this line of code. If it's gone the bug happens... I guess Im not sure if this is actually a bug because I actually caused it.

C#:
            if (CheckInsuranceOnDeath(item) && !Young)
So I managed to fix it by instead of removing this line of code I replaced it with...

C#:
            if (item.Movable)
Post automatically merged:

it works like a charm. your pack basically remains unchanged when you are ressurected it is exactly like you left it.