QUOTE |
public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness ) { // ARTEGORDONMOD // allow quest specific attack status for mobs // if the mob has a RestrictAttack xmldata attachment, then the data on that attachment // will give the name of the carried item that will allow the creature to be attacked XmlData a = (XmlData)XmlAttach.FindAttachment(target, typeof(XmlData), "RestrictAttack"); if (a != null) { // if you have the item then you can attack the target, otherwise you cant return (BaseXmlSpawner.SearchMobileForItem(this, a.Data, null, false) != null); } if ( m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null) ) return false; if ( (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier ) { if ( message ) { if ( target.Title == null ) SendMessage( "{0} the vendor cannot be harmed.", target.Name ); else SendMessage( "{0} {1} cannot be harmed.", target.Name, target.Title ); } return false; } return base.CanBeHarmful( target, message, ignoreOurBlessedness ); } |
QUOTE |
public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness ) { // ARTEGORDONMOD // allow quest specific attack status for mobs // if the mob has a RestrictAttack xmldata attachment, then the data on that attachment // will give the name of the carried item that will allow the creature to be attacked XmlData a = (XmlData)XmlAttach.FindAttachment(this, typeof(XmlData), "RestrictAttack"); if (a != null && target is PlayerMobile) { // if the target player is carrying the named item then it can be attacked, otherwise it cant return (BaseXmlSpawner.SearchMobileForItem(target, a.Data, null, false) != null); } // dont allow restricted creatures to attack pets unless the master has the named item if (a != null && target is BaseCreature) { Mobile master = null; BaseCreature btarget = (BaseCreature)target; if (btarget.Controled) master = btarget.ControlMaster; else if (btarget.Summoned) master = btarget.SummonMaster; else if (btarget.BardProvoked) master = btarget.BardMaster; if (master is PlayerMobile) // if the master is carrying the named item then it can be attacked, otherwise it cant return (BaseXmlSpawner.SearchMobileForItem(master, a.Data, null, false) != null); } // make a check on pets to prevent them from attacking mobs that are restricted unless the master has the named item if (Controled || Summoned || BardProvoked) { XmlData atarget = (XmlData)XmlAttach.FindAttachment(target, typeof(XmlData), "RestrictAttack"); if (atarget != null) { Mobile master = null; if (Controled) master = ControlMaster; else if (Summoned) master = SummonMaster; else if (BardProvoked) master = BardMaster; if (master is PlayerMobile) // if the master has the item then it can attack the target, otherwise it cant return (BaseXmlSpawner.SearchMobileForItem(master, atarget.Data, null, false) != null); } } if ( target is BaseFactionGuard ) return false; if ( (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier ) { if ( message ) { if ( target.Title == null ) SendMessage( "{0} the vendor cannot be harmed.", target.Name ); else SendMessage( "{0} {1} cannot be harmed.", target.Name, target.Title ); } return false; } return base.CanBeHarmful( target, message, ignoreOurBlessedness ); } |
QUOTE |
<Spawns> <Points> <Name>DragonQuest</Name> <UniqueId>4c592d6f-2da6-4079-8954-9b36a9c8cf15</UniqueId> <Map>Felucca</Map> <X>5439</X> <Y>1135</Y> <Width>10</Width> <Height>10</Height> <CentreX>5444</CentreX> <CentreY>1140</CentreY> <CentreZ>0</CentreZ> <Range>5</Range> <MaxCount>2</MaxCount> <MinDelay>5</MinDelay> <MaxDelay>10</MaxDelay> <DelayInSec>False</DelayInSec> <Duration>0</Duration> <DespawnTime>0</DespawnTime> <ProximityRange>-1</ProximityRange> <ProximityTriggerSound>500</ProximityTriggerSound> <TriggerProbability>1</TriggerProbability> <InContainer>False</InContainer> <MinRefractory>0</MinRefractory> <MaxRefractory>0</MaxRefractory> <TODStart>0</TODStart> <TODEnd>0</TODEnd> <TODMode>0</TODMode> <KillReset>1</KillReset> <ExternalTriggering>False</ExternalTriggering> <SequentialSpawning>-1</SequentialSpawning> <AllowGhostTriggering>False</AllowGhostTriggering> <SpawnOnTrigger>False</SpawnOnTrigger> <SmartSpawning>False</SmartSpawning> <Team>0</Team> <Amount>1</Amount> <IsGroup>False</IsGroup> <IsRunning>True</IsRunning> <IsHomeRangeRelative>True</IsHomeRangeRelative> <Objects2>dragon/name/OnlyForYou/ATTACH/xmldata,RestrictAttack,Dragon Quest:MX=1:SB=0:RT=0:TO=0:KL=0:RK=0:CA=1:DN=-1:DX=-1:SP=1:PR=-1:OBJ=questholder/name/Dragon Quest/objective1/KILLNAMED,OnlyForYou,dragon:MX=1:SB=0:RT=0:TO=0:KL=0:RK=0:CA=1:DN=-1:DX=-1:SP=1:PR=-1</Objects2> </Points> </Spawns> |
QUOTE (DaLaw @ May 27, 2006 07:06 pm) |
Okay so that makes it compile ![]() But for I can attack the npc and it can attack me even if I dont have the nececary item, even after adding the stuff to the scripts ;/ Any ideas? :< |
CODE |
public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness ) { // ARTEGORDONMOD // allow quest specific attack status for mobs // if the mob has a RestrictAttack xmldata attachment, then the data on that attachment // will give the name of the carried item that will allow the creature to be attacked XmlData a = (XmlData)XmlAttach.FindAttachment(this, typeof(XmlData), "RestrictAttack"); if (a != null && target is PlayerMobile) { // if the target player is carrying the named item then it can be attacked, otherwise it cant return (BaseXmlSpawner.SearchMobileForItem(target, a.Data, null, false) != null); } // dont allow restricted creatur es to attack pets unless the master has the named item if (a != null && target is BaseCreature) { Mobile master = null; BaseCreature btarget = target as BaseCreature; if (btarget.Controled) master = btarget.ControlMaster; else if (btarget.Summoned) master = btarget.SummonMaster; else if (btarget.BardProvoked) master = btarget.BardMaster; if (master is PlayerMobile) // if the master is carrying the named item then it can be attacked, otherwise it cant return (BaseXmlSpawner.SearchMobileForItem(master, a.Data, null, false) != null); } // make a check on pets to prevent them from attacking mobs that are restricted unless the master has the named item if (Controled || Summoned || BardProvoked) { XmlData atarget = (XmlData)XmlAttach.FindAttachment(target, typeof(XmlData), "RestrictAttack"); if (atarget != null) { Mobile master = null; if (Controled) master = ControlMaster; else if (Summoned) master = SummonMaster; else if (BardProvoked) master = BardMaster; if (master is PlayerMobile) // if the master has the item then it can attack the target, otherwise it cant return (BaseXmlSpawner.SearchMobileForItem(master, atarget.Data, null, false) != null); } } if ( target is BaseFactionGuard ) return false; if ( (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier ) { if ( message ) { if ( target.Title == null ) SendMessage( "{0} the vendor cannot be harmed.", target.Name ); else SendMessage( "{0} {1} cannot be harmed.", target.Name, target.Title ); } return false; } return base.CanBeHarmful( target, message, ignoreOurBlessedness ); } |
CODE |
public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness ) { // ARTEGORDONMOD // allow quest specific attack status for mobs // if the mob has a RestrictAttack xmldata attachment, then the data on that attachment // will give the name of the carried item that will allow the creature to be attacked XmlData a = (XmlData)XmlAttach.FindAttachment(target, typeof(XmlData), "RestrictAttack"); if (a != null && target is PlayerMobile) { // if you have the item then you can attack the target, otherwise you cant return (BaseXmlSpawner.SearchMobileForItem(this, a.Data, null, false) != null); } if ( m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null) ) return false; if ( (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier ) { if ( message ) { if ( target.Title == null ) SendMessage( "{0} the vendor cannot be harmed.", target.Name ); else SendMessage( "{0} {1} cannot be harmed.", target.Name, target.Title ); } return false; } return base.CanBeHarmful( target, message, ignoreOurBlessedness ); } |
QUOTE |
public override bool CanBeHarmful(Mobile target, bool message, bool ignoreOurBlessedness) { // ARTEGORDONMOD // allow quest specific attack status for mobs // if the mob has a RestrictAttack xmldata attachment, then the data on that attachment // will give the name of the carried item that will allow the creature to be attacked XmlData a = (XmlData)XmlAttach.FindAttachment(target, typeof(XmlData), "RestrictAttack"); if (a != null) { // if you have the item then you can attack the target, otherwise you cant return (BaseXmlSpawner.SearchMobileForItem(this, a.Data, null, false) != null); } if (m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null)) return false; if ((target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier) { if (message) { if (target.Title == null) SendMessage("{0} the vendor cannot be harmed.", target.Name); else SendMessage("{0} {1} cannot be harmed.", target.Name, target.Title); } return false; } return base.CanBeHarmful(target, message, ignoreOurBlessedness); } |
CODE |
if (btarget.Controled) |
CODE |
if (btarget.Controlled) |