Lemke

Member
Hello,im looking to get my players choose between PVM or PVP when create the character with just one limitation:
*PVP player cant attack PVMplayer.

Is that possible?Thank you!
 
It is possible, you can use XML tags and one distro edit to notoriety. Add an XML attachment to every player that has an attribtue stating PVP and PVM then dive into Notoriety.cs, add in a statement to check for the attachment in Mobile_AllowHarmful , and simply state something to effect of

If Target Has Attachment and the attachment value of BattleType is PVP then return true.
If Target Has attachment and the attachment value of BattleType is PVM then return false.

Then for fairness
If Target Has attachment and the attachment value of BattleType is PVP and the Mobile*from* attachment BattleType is PVM then return false
This would prevent the PVM from attacking the PVP players that could not attack back.

The code should be simple enough to contruct. Can use other items other then the XML attachment but I would find that easier. Don't forget to add in a logineventhandler that causes the attachment, if not present to be attached to every player upon login, and don't forget the null checks. :)

Also maybe create an item, that generates a gump, that allows the player to pick their mode of battletype, that item could then trigger their attachment to the preferred type.

Well, anyways, that is how I would do it.. lol
Post automatically merged:

Maybe if i get bored and need a break from my current project I will toss something together.
 
Im trying to find a bit more easy way to do that just for the character tag,now im creating a pair of items on character created,one PVP,one PVM,with the next code:

C#:
public override void OnDoubleClick(Mobile from)
        {
        Account acct = (Account)from.Account;
        acct.SetTag((from.Name) + ("PVP"), "true");
        from.SendMessageSendMessage("You are now PVP");
        }
I think the character takes this account tag based on his name,so you can create other character and give him the PVM tag on double click the pvm item.Is any method to comprobe the tag on character using a command?
Thank you!
 
I would add something to either method.

Make sure that if they are allowed to switch between PVP and PVM, that you enforce a cool-down period, otherwise, people could attack in PVP mode and quickly switch to PVM to prevent counter-attack. The cool-down could either be strictly time-based or could be connected to their grey status, Karma, or kill-count.
 
Im thinking to do this player tag forever,now i need help to see what i need to change in Notoriety,to do correctly this:

C#:
PlayerMobile from = m as PlayerMobile;
  Account acct = (Account)from.Account;
  if ( (acct.GetTag((from.Name) + ("PVM"))) == "true" )
  {
  ///////cant damage this player////////With spells,melee,and creatures///////////
  }
Looking at "public static bool Mobile_AllowHarmful".
C#:
    public static bool Mobile_AllowHarmful(Mobile from, IDamageable damageable)
        {
            var target = damageable as Mobile;

            if (from == null || target == null || from.IsStaff() || target.IsStaff())
                return true;

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                if (Gregorio.IsMurderer(from))
                    return true;

                from.SendLocalizedMessage(1075456); // You are not allowed to damage this NPC unless your on the Guilty Quest
                return false;
            }
            #endregion

            var map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
                return true; // In felucca, anything goes

            // Summons should follow the same rules as their masters
            if (from is BaseCreature && ((BaseCreature)from).Summoned && ((BaseCreature)from).SummonMaster != null)
                from = ((BaseCreature)from).SummonMaster;

            if (target is BaseCreature && ((BaseCreature)target).Summoned && ((BaseCreature)target).SummonMaster != null)
                target = ((BaseCreature)target).SummonMaster;

            var bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().IsPlayer()))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile &&
                    ((PlayerMobile)target).CheckYoungProtection(from))
                    return false;

                return true; // Uncontrolled NPCs are only restricted by the young system
            }

            var fromGuild = GetGuildFor(from.Guild as Guild, from);
            var targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null)
            {
                if (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild))
                    return true; // Guild allies or enemies can be harmful
            }

            if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.EnhancedRules && ViceVsVirtueSystem.IsEnemy(from, damageable))
                return true;

            if (target is BaseCreature)
            {
                if (((BaseCreature)target).Controlled)
                    return false; // Cannot harm other controlled mobiles

                if (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster)
                    return false; // Cannot harm other controlled mobiles
            }

            if (target.Player)
                return false; // Cannot harm other players

            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                    return false; // Cannot harm innocent mobiles
            }

            return true;
        }
Any way to prevent attack/damage?Looking at young system too,cause it seems what i want for pvmrs,but nothing to do with this flag.
 
Try something like this:

C#:
    public static bool Mobile_AllowHarmful(Mobile from, IDamageable damageable)
        {
            var target = damageable as Mobile;

            if (from == null || target == null || from.IsStaff() || target.IsStaff())
                return true;
            
            Account from_acct;
            Account target_acct;
            
            PlayerMobile playerfrom = from as PlayerMobile;
            PlayerMobile playertarget = target as PlayerMobile;
            
            if (playerfrom != null) from_acct = (Account)playerfrom.Account;
            if ( playertarget != null && from_acct != null && (from_acct.GetTag((playerfrom.Name) + ("PVM"))) == "true" )
            {
                from.SendMessage("You are not a PVP player, so you are not permitted to attack other players.");
                return false;
            }
            
            if (playertarget != null) target_acct = (Account)playertarget.Account;
            if ( target_acct != null && (target_acct.GetTag((playertarget.Name) + ("PVM"))) == "true" )
            {
                from.SendMessage("You are not permitted to attack players who are not PVP players.");
                return false;
            }

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                if (Gregorio.IsMurderer(from))
                    return true;

                from.SendLocalizedMessage(1075456); // You are not allowed to damage this NPC unless your on the Guilty Quest
                return false;
            }
            #endregion

            var map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
                return true; // In felucca, anything goes

            // Summons should follow the same rules as their masters
            if (from is BaseCreature && ((BaseCreature)from).Summoned && ((BaseCreature)from).SummonMaster != null)
                from = ((BaseCreature)from).SummonMaster;

            if (target is BaseCreature && ((BaseCreature)target).Summoned && ((BaseCreature)target).SummonMaster != null)
                target = ((BaseCreature)target).SummonMaster;

            var bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().IsPlayer()))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile &&
                    ((PlayerMobile)target).CheckYoungProtection(from))
                    return false;

                return true; // Uncontrolled NPCs are only restricted by the young system
            }

            var fromGuild = GetGuildFor(from.Guild as Guild, from);
            var targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null)
            {
                if (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild))
                    return true; // Guild allies or enemies can be harmful
            }

            if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.EnhancedRules && ViceVsVirtueSystem.IsEnemy(from, damageable))
                return true;

            if (target is BaseCreature)
            {
                if (((BaseCreature)target).Controlled)
                    return false; // Cannot harm other controlled mobiles

                if (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster)
                    return false; // Cannot harm other controlled mobiles
            }

            if (target.Player)
                return false; // Cannot harm other players

            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                    return false; // Cannot harm innocent mobiles
            }

            return true;
        }
 
Last edited:
Try something like this:

C#:
    public static bool Mobile_AllowHarmful(Mobile from, IDamageable damageable)
        {
            var target = damageable as Mobile;

            if (from == null || target == null || from.IsStaff() || target.IsStaff())
                return true;
           
            Account from_acct;
            Account target_acct;
           
            PlayerMobile playerfrom = from as PlayerMobile;
            PlayerMobile playertarget = target as PlayerMobile;
           
            if (playerfrom != null) from_acct = (Account)playerfrom.Account;
            if ( playertarget != null && from_acct != null && (from_acct.GetTag((playerfrom.Name) + ("PVM"))) == "true" )
            {
                from.SendMessage("You are not a PVP player, so you are not permitted to attack other players.");
                return false;
            }
           
            if (playertarget != null) target_acct = (Account)playertarget.Account;
            if ( target_acct != null && (target_acct.GetTag((playertarget.Name) + ("PVM"))) == "true" )
            {
                from.SendMessage("You are not permitted to attack players who are not PVP players.");
                return false;
            }

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                if (Gregorio.IsMurderer(from))
                    return true;

                from.SendLocalizedMessage(1075456); // You are not allowed to damage this NPC unless your on the Guilty Quest
                return false;
            }
            #endregion

            var map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
                return true; // In felucca, anything goes

            // Summons should follow the same rules as their masters
            if (from is BaseCreature && ((BaseCreature)from).Summoned && ((BaseCreature)from).SummonMaster != null)
                from = ((BaseCreature)from).SummonMaster;

            if (target is BaseCreature && ((BaseCreature)target).Summoned && ((BaseCreature)target).SummonMaster != null)
                target = ((BaseCreature)target).SummonMaster;

            var bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().IsPlayer()))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile &&
                    ((PlayerMobile)target).CheckYoungProtection(from))
                    return false;

                return true; // Uncontrolled NPCs are only restricted by the young system
            }

            var fromGuild = GetGuildFor(from.Guild as Guild, from);
            var targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null)
            {
                if (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild))
                    return true; // Guild allies or enemies can be harmful
            }

            if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.EnhancedRules && ViceVsVirtueSystem.IsEnemy(from, damageable))
                return true;

            if (target is BaseCreature)
            {
                if (((BaseCreature)target).Controlled)
                    return false; // Cannot harm other controlled mobiles

                if (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster)
                    return false; // Cannot harm other controlled mobiles
            }

            if (target.Player)
                return false; // Cannot harm other players

            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                    return false; // Cannot harm innocent mobiles
            }

            return true;
        }

Yea I would probably go for the same, but I felt like reordering your added part :p hope you dont mind

C#:
            if(from is PlayerMobile && target is PlayerMobile)
            {
                Account accountcheck = (Account)((PlayerMobile)from).Account;
                if (accountcheck.GetTag(from.Name + "PVM") == "true")
                {
                    from.SendMessage("You are not a PVP player, so you are not permitted to attack other players.");
                    return false;
                }
                accountcheck = (Account)((PlayerMobile)target).Account;
                if (accountcheck.GetTag(((PlayerMobile)target).Name + "PVM") == "true")
                {
                    from.SendMessage("You are not permitted to attack players who are not PVP players.");
                    return false;
                }
            }
 
You'll have to extend your checks to include pets and summons so PvP players can't command them to attack non-PVP players.
Post automatically merged:

Let me also add that you'll need to handle all permutations of that check as well:

- pets/summons of non-PVP players cannot attack PVP players since their owners have chosen not to participate.
- pets of PVP players cannot attack pets of non-PVP, and vice-versa
- non-PVP players cannot heal pets of PVPers while in Fel.

There is a LOT of logic to think through in a consensual PVP environment. I use a different system (and RunUO 2.0) but this snippet will give you an idea of how much went into just the check for Pets vs Non-PVP players:

Code:
    // Pets can't attack PvM players
            if (  ( (from is BaseCreature && ((BaseCreature)from).Controlled ) ||  from is BaseBioCreature)  &&  target is PlayerMobile )
                {
                BaseCreature attkr = from as BaseCreature;
                PlayerMobile attacked = target as PlayerMobile;

                if ( map != null && map != Map.Felucca )  // No fighting outside Fel!
                    {
                    attkr.ControlOrder = OrderType.Stop;  // Stops pet's attack
                        if (attkr.ControlMaster !=null )
                        (attkr.ControlMaster).SendMessage( 33, "Your pet cannot attack that target on this facet." );

                    return false;
                    }

                if ( (attkr.ControlMaster !=null ) && ( ((PlayerMobile)attkr.ControlMaster).NONPK == NONPK.PK ) && ( ((PlayerMobile)attacked).NONPK == NONPK.PK ) )
                    return true; // It's ok - in Fel and pet owner and target are both PvP

                if (attkr.ControlMaster !=null)
                    (attkr.ControlMaster).SendMessage( 33, "Your pet cannot attack that target." ); // Both aren't PvP so pet can't attack
                attkr.ControlOrder = OrderType.Stop;  // Stops pet's attack or message will keep repeating
                return false;
                }

After all of this work, exactly zero players on our shard have tried PvP. I learned a major lesson: know your audience! The ServUO shard I'm tinkering with now will not have such a system because my target audience will be those with zero interest in PvP. There are plenty of shards out there that cater to that already.
 
Last edited:
You'll have to extend your checks to include pets and summons so PvP players can't command them to attack non-PVP players.
Post automatically merged:

Let me also add that you'll need to handle all permutations of that check as well:

- pets/summons of non-PVP players cannot attack PVP players since their owners have chosen not to participate.
- pets of PVP players cannot attack pets of non-PVP, and vice-versa
- non-PVP players cannot heal pets of PVPers while in Fel.

There is a LOT of logic to think through in a consensual PVP environment. I use a different system (and RunUO 2.0) but this snippet will give you an idea of how much went into just the check for Pets vs Non-PVP players:

Code:
    // Pets can't attack PvM players
            if (  ( (from is BaseCreature && ((BaseCreature)from).Controlled ) ||  from is BaseBioCreature)  &&  target is PlayerMobile )
                {
                BaseCreature attkr = from as BaseCreature;
                PlayerMobile attacked = target as PlayerMobile;

                if ( map != null && map != Map.Felucca )  // No fighting outside Fel!
                    {
                    attkr.ControlOrder = OrderType.Stop;  // Stops pet's attack
                        if (attkr.ControlMaster !=null )
                        (attkr.ControlMaster).SendMessage( 33, "Your pet cannot attack that target on this facet." );

                    return false;
                    }

                if ( (attkr.ControlMaster !=null ) && ( ((PlayerMobile)attkr.ControlMaster).NONPK == NONPK.PK ) && ( ((PlayerMobile)attacked).NONPK == NONPK.PK ) )
                    return true; // It's ok - in Fel and pet owner and target are both PvP

                if (attkr.ControlMaster !=null)
                    (attkr.ControlMaster).SendMessage( 33, "Your pet cannot attack that target." ); // Both aren't PvP so pet can't attack
                attkr.ControlOrder = OrderType.Stop;  // Stops pet's attack or message will keep repeating
                return false;
                }

After all of this work, exactly zero players on our shard have tried PvP. I learned a major lesson: know your audience! The ServUO shard I'm tinkering with now will not have such a system because my target audience will be those with zero interest in PvP. There are plenty of shards out there that cater to that already.
Thank you for the add,we are thinking on a server level based under AOS expansion where PVPs cant attack PVMs in Felucca,people want come to a server and ready to play,so just coding to give PVPs some starter set,some resources,and ready to go,,we are going top be pvp,pvm,crafter,or standard character based on character tag.
Thank you so much for this add mate,its so important!.On s
 
I've uploaded the NONPK system I used as a base:


It is for RunUO but you may find parts of it useful in what you're working on.
 
Would there be a way to make it so whenever youre flagged PVP everyone who is also flagged PVP is orange to you? (Except guildmates and party)
 

Active Shards

Donations

Total amount
$50.00
Goal
$1,000.00
Back