public override void OnDoubleClick(Mobile from)
{
Account acct = (Account)from.Account;
acct.SetTag((from.Name) + ("PVP"), "true");
from.SendMessageSendMessage("You are now PVP");
}
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///////////
}
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;
}
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;
}
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; }
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;
}
}
// 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;
}
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.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.
We use essential cookies to make this site work, and optional cookies to enhance your experience.