So this is an interesting question for everyone, hopefully someone might have a suggestion or direction to send me. I'm working on a Gor Based server and I need to be able to allow a player to edit another players paper doll , similar as if they were opening their own paper doll. I found all the code referenced in mobile.cs and playermobile.cs that allows the player to open their own doll however I'm honestly not sure how to proceed forward with this.. Once I figure out the method, I can then add in checks to ensure only certain players can edit other players (that is specified) paper dolls.

I did consider the 'viewequip' method however that doesn't really allow seamless adjustments to the other player, and its' clunky at best. It's likely more possible to initiate this from a gump that calls the other players paper doll.
Any suggestions would be greatly appreciated.
 
That might work, so that would be an override in PlayerMobile as well as probably BaseArmor/BaseWeapon/BaseClothing and BaseJewel. Unless I wanted to edit the core which is also doable. That does help, thank you for the direction. :)
 
Okay, so i've made some progress If left unchecked every player and move any players items on their paper doll. So now to set the restrictions. The code below is supposed to do this...

Check the PlayerMobile for an attachment, then check that attachments variable to find a Mobile Listed, then check that Mobile for a secondary attachment, then compare the two attachments which would grant a controlled scenario and allow a specific playermobile only to edit another playermobile with an attachment that passes the checks. Well it makes it half way, it finds the first attachment but then it doesn't find the second attachment. No compile errors, just doesn't work.

Any suggestions by chance? or maybe a better way to reference the secondary mobile.

C#:
        #region Gor Edits
        public override bool CheckNonlocalLift( Mobile from, Item item )
        {
            GorXMLSys xmltarget2 = (GorXMLSys)XmlAttach.FindAttachment(this, typeof(GorXMLSys));
            if (xmltarget2 != null)
            {
                Mobile mtarget = xmltarget2.SlaveSlot1;
                SlaveKolarAtt xmltarget10 = (SlaveKolarAtt)XmlAttach.FindAttachment(mtarget, typeof(SlaveKolarAtt));
                if (xmltarget10 != null)
                {
                    if (xmltarget10.ControlMaster == this)
                        return true;
                }
//                return true;
            }
            
            return false;
        }
        public override bool AllowEquipFrom( Mobile from )
        {
            GorXMLSys xmltarget2 = (GorXMLSys)XmlAttach.FindAttachment(this, typeof(GorXMLSys));
            if (xmltarget2 != null)
            {
                Mobile mtarget = xmltarget2.SlaveSlot1;
                SlaveKolarAtt xmltarget10 = (SlaveKolarAtt)XmlAttach.FindAttachment(mtarget, typeof(SlaveKolarAtt));
                if (xmltarget10 != null)
                {
                    if (xmltarget10.ControlMaster == this)
                        return true;
                }
//                return true;
            }
            // needs to return false, then above add the statements so that a master of his slave can use this.
            return false; //or return base.AllowEquipFrom(from); in case that you have important verifications in BaseCreature.
        }
        #endregion
 
Hmm not sure maybe have the attachment store a Dictionary of people that are allowed to move items on that slave entity, then you would check if the from Mobile is in the dictionary :p
 
Hmm, I've never actually tried doing that before. I suspect that would be a similar function to the party system.
 
OMG . I found a solution finally within PlayerMobile! So simple too, waaay overthinking it..

C#:
        public override bool CheckNonlocalLift( Mobile from, Item item )
        {
            MasterSlaveSystemXML xmlgoratt = (MasterSlaveSystemXML)XmlAttach.FindAttachment(this, typeof(MasterSlaveSystemXML));
            SlaveKolarAtt kolaratt = (SlaveKolarAtt)XmlAttach.FindAttachment(this, typeof(SlaveKolarAtt));
            
            if (kolaratt != null)
            {
                if (kolaratt.ControlMaster == from)
                {
                    return true;
                }
                else if ( xmlgoratt.PlayerName == from)
                {
                    return true;
                }
                else
                {
                    if (from == this)
                        return true;
                }
            }
            if (from == this)
                return true;
            return false;
        }

        public override bool AllowEquipFrom( Mobile from )
        {
            MasterSlaveSystemXML xmlgoratt = (MasterSlaveSystemXML)XmlAttach.FindAttachment(this, typeof(MasterSlaveSystemXML));
            SlaveKolarAtt kolaratt = (SlaveKolarAtt)XmlAttach.FindAttachment(this, typeof(SlaveKolarAtt));
            
            if (kolaratt != null)
            {
                if (kolaratt.ControlMaster == from)
                {
                    return true;
                }
                else if ( xmlgoratt.PlayerName == from)
                {
                    return true;
                }
                else
                {
                    if (from == this)
                        return true;
                }
            }
            if (from == this)
                return true;
            return false;
        }

Thanks guys for pointing me in the right direction ! much appreciated.
 
OMG . I found a solution finally within PlayerMobile! So simple too, waaay overthinking it..

C#:
        public override bool CheckNonlocalLift( Mobile from, Item item )
        {
            MasterSlaveSystemXML xmlgoratt = (MasterSlaveSystemXML)XmlAttach.FindAttachment(this, typeof(MasterSlaveSystemXML));
            SlaveKolarAtt kolaratt = (SlaveKolarAtt)XmlAttach.FindAttachment(this, typeof(SlaveKolarAtt));
           
            if (kolaratt != null)
            {
                if (kolaratt.ControlMaster == from)
                {
                    return true;
                }
                else if ( xmlgoratt.PlayerName == from)
                {
                    return true;
                }
                else
                {
                    if (from == this)
                        return true;
                }
            }
            if (from == this)
                return true;
            return false;
        }

        public override bool AllowEquipFrom( Mobile from )
        {
            MasterSlaveSystemXML xmlgoratt = (MasterSlaveSystemXML)XmlAttach.FindAttachment(this, typeof(MasterSlaveSystemXML));
            SlaveKolarAtt kolaratt = (SlaveKolarAtt)XmlAttach.FindAttachment(this, typeof(SlaveKolarAtt));
           
            if (kolaratt != null)
            {
                if (kolaratt.ControlMaster == from)
                {
                    return true;
                }
                else if ( xmlgoratt.PlayerName == from)
                {
                    return true;
                }
                else
                {
                    if (from == this)
                        return true;
                }
            }
            if (from == this)
                return true;
            return false;
        }

Thanks guys for pointing me in the right direction ! much appreciated.

Awesome that you got it running :) and that you share it


A question though since I am not sure how it is set up internally.
Wouldn't this snippet allow the slave to remove the collar? Assuming the PlayerName is the slave.
C#:
if ( xmlgoratt.PlayerName == from)
{
    return true;
}


Also just in case you want to slightly tweak it.

C#:
            if (kolaratt != null)
            {
                if (kolaratt.ControlMaster == from)
                {
                    return true;
                }
                else if ( xmlgoratt.PlayerName == from)
                {
                    return true;
                }
            }
            return from == this;
 
Awesome that you got it running :) and that you share it


A question though since I am not sure how it is set up internally.
Wouldn't this snippet allow the slave to remove the collar? Assuming the PlayerName is the slave.
C#:
if ( xmlgoratt.PlayerName == from)
{
    return true;
}


Also just in case you want to slightly tweak it.

C#:
            if (kolaratt != null)
            {
                if (kolaratt.ControlMaster == from)
                {
                    return true;
                }
                else if ( xmlgoratt.PlayerName == from)
                {
                    return true;
                }
            }
            return from == this;

It would actually however the Collar itself is set as 'movable false'. so even if they have the ability to do it, the actual collar can only be removed via the master releasing the slave or by a GM or higher. Even the collar is set to re attach to the player upon death and cannot be removed from the player by any traditional means.
Post automatically merged:

I wasn't sure about that tweak, I thought about doing it myself but i was worried that if it wasn't an else if statement it would not work.
 
it will work, if the if "fails" or rather be skipped since the condition isnt true then it goes to the next line after the if's body.

Ah ok, well that is one way to do it I guess, but I guess in that case it wouldnt hurt to still set it to false. Just in case you know ^^
 
Wanted to take this concept one level further, the modification suggestion above worked as well. I want to extend this control into the bank system as well. I tried copying the code from Mobile (canSee) and I made it so the Master call open the slaves bank via gump, they just cannot add or remove things from the bank. Would that also be in the CheckNonlocalLift override as well?
 
I think in that case you need to actually modify the containers. Maybe do it in the base container cs so you can look into the slaves backpack and use them as a packhorse so to say. Including no snooping check and going criminal. There should be a OnLift or something there
 
That is a good starting point, I did consider doing a core mod to the bank entry but I really really rather not.
 
Well.. I did a mod to snooping which lets the master open browse the slave backpack, so that is awesome! lol. still no dice on the bank.. still need to further look into the whole bank thing.

My Snooping code, case interested
C#:
using System;
using Server;
using Server.Misc;
using Server.Items;
using Server.Mobiles;
using Server.Network;
using Server.Regions;
using Server.Engines.XmlSpawner2;/* XmlLevelItemXML */

namespace Server.SkillHandlers
{
    public class Snooping
    {
        public static void Configure()
        {
            Container.SnoopHandler = new ContainerSnoopHandler( Container_Snoop );
        }

        #region Gor Edits
        public static bool CheckMaster (Mobile master, Mobile slave)
        {
            MasterSlaveSystemXML xmlgoratt = (MasterSlaveSystemXML)XmlAttach.FindAttachment(slave, typeof(MasterSlaveSystemXML));
            SlaveKolarAtt kolaratt = (SlaveKolarAtt)XmlAttach.FindAttachment(slave, typeof(SlaveKolarAtt));
            if (kolaratt != null)
            {
                if (kolaratt.ControlMaster == master)
                {
                    return true;
                }
                else if ( xmlgoratt.PlayerName == master)
                {
                    return true;
                }
            }
            else
                return false;
            return false;
        }
        #endregion
        
        public static bool CheckSnoopAllowed( Mobile from, Mobile to )
        {
            Map map = from.Map;

            #region Gor Edits
            MasterSlaveSystemXML xmlgoratt = (MasterSlaveSystemXML)XmlAttach.FindAttachment(to, typeof(MasterSlaveSystemXML));
            SlaveKolarAtt kolaratt = (SlaveKolarAtt)XmlAttach.FindAttachment(to, typeof(SlaveKolarAtt));
            if (kolaratt != null)
            {
                if (kolaratt.ControlMaster == from)
                {
                    return true;
                }
                else if ( xmlgoratt.PlayerName == from)
                {
                    return true;
                }
            }
            #endregion

            if ( to.Player )
                return from.CanBeHarmful( to, false, true ); // normal restrictions

            if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 )
                return true; // felucca you can snoop anybody

            BaseCreature cret = to as BaseCreature;

            if ( to.Body.IsHuman && (cret == null || (!cret.AlwaysAttackable && !cret.AlwaysMurderer)) )
                return false; // in town we cannot snoop blue human npcs

            return true;
        }

        public static void Container_Snoop( Container cont, Mobile from )
        {
            #region GorEdits
            Mobile root2 = cont.RootParent as Mobile;
            if (!CheckMaster(from, root2))
            {
                if ( from.AccessLevel > AccessLevel.Player || from.InRange( cont.GetWorldLocation(), 1 ) )
                {
                    Mobile root = cont.RootParent as Mobile;

                    if ( root != null && !root.Alive )
                        return;

                    if ( root != null && root.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player )
                    {
                        from.SendLocalizedMessage( 500209 ); // You can not peek into the container.
                        return;
                    }

                    if ( root != null && from.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed( from, root ) )
                    {
                        from.SendLocalizedMessage( 1001018 ); // You cannot perform negative acts on your target.
                        return;
                    }

                    if ( root != null && from.AccessLevel == AccessLevel.Player && from.Skills[SkillName.Snooping].Value < Utility.Random( 100 ) )
                    {
                        Map map = from.Map;

                        if ( map != null )
                        {
                            string message = String.Format( "You notice {0} attempting to peek into {1}'s belongings.", from.Name, root.Name );

                            IPooledEnumerable eable = map.GetClientsInRange( from.Location, 8 );

                            foreach ( NetState ns in eable )
                            {
                                if ( ns.Mobile != from )
                                    ns.Mobile.SendMessage( message );
                            }

                            eable.Free();
                        }
                    }

                    if ( from.AccessLevel == AccessLevel.Player )
                        Titles.AwardKarma( from, -4, true );

                    if ( from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill( SkillName.Snooping, cont, 0.0, 100.0 ) )
                    {
                        if ( cont is TrapableContainer && ((TrapableContainer)cont).ExecuteTrap( from ) )
                            return;

                        cont.DisplayTo( from );
                    }
                    else
                    {
                        
                        from.SendLocalizedMessage( 500210 ); // You failed to peek into the container.
                        
                        if ( from.Skills[SkillName.Hiding].Value / 2 < Utility.Random( 100 ) )
                            from.RevealingAction();
                    }
                }
                else
                {
                    from.SendLocalizedMessage( 500446 ); // That is too far away.
                }
            }
            else
                cont.DisplayTo( from );
            #endregion
        }
    }
}
Post automatically merged:

bankbox is a fool quest.. lol found it. Its safely ticked away in the server core files. I would have to mod the core to edit the bank box. Can't override something that is pulled directly from the core..
 
Last edited:
Back