Full Version : XmlIsEnemy
xmlspawner >>Scripting Support >>XmlIsEnemy
<< Prev | Next >>
Kin-Kran- 10-08-2007
[QUOTE]
public virtual bool IsEnemy(Mobile m)
{
XmlIsEnemy a = (XmlIsEnemy)XmlAttach.FindAttachment(this, typeof(XmlIsEnemy));
if (a != null)
{
return a.IsEnemy(m);
}
OppositionGroup g = this.OppositionGroup;
if (g != null && g.IsEnemy(this, m))
return true;
[/QUOTE]
add the mod in red to the beginning of the IsEnemy method as shown above in BaseCreature.cs around line 810.
Then you can use the XmlIsEnemy attachment to specify the conditions that will determine which mobs are enemies of the creature it is attached to.
For example a spawn entry like
orc/ATTACH/<xmlisenemy/test/@GETONCARRIED,orcwar,longsword,visible=true>
would spawn an orc that would only attack people that carried the longsword named 'orcwar'
and an entry like
orc/ATTACH/<xmlisenemy/test/@~GETONCARRIED,orcwar,longsword,visible=true>
would do just the opposite and protect people carrying the sword.
The Test property on the attachment can be set to any valid xmlspawner condition.
[/QUOTE]
I asked if it would also work with RunUO 1.0 as well and you stated it would. My next question is if using XMLSpawner 3.11 would give me errors on this.

CODE
RunUO - [www.runuo.com] Version 1.0.0, Build 36918 Scripts: Compiling C# scripts...failed (3 errors, 0 warnings) - Error: Scripts\Engines\AI\Creature\BaseCreature.cs: CS0246: (line 573, column 13) The type or namespace name 'XmlIsEnemy' could not be found (are you missing
a using directive or an assembly reference?)
- Error: Scripts\Engines\AI\Creature\BaseCreature.cs: CS0103: (line 574, column
17) The name 'a' does not exist in the class or namespace 'Server.Mobiles.BaseC
reature'
- Error: Scripts\Engines\AI\Creature\BaseCreature.cs: CS0246: (line 576, column
24) The type or namespace name 'a' could not be found (are you missing a using
directive or an assembly reference?)
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

This is my edit

CODE
public virtual bool IsEnemy( Mobile m ) { XmlIsEnemy a = (XmlIsEnemy)XmlAttach.FindAttachment(this, typeof(XmlIsEnemy)); ////////// if (a != null) { //////////// Added for XMLSpawner XmlIsenemy.cs
return a.IsEnemy(m);
} ////////////
OppositionGroup g = this.OppositionGroup;
if ( g != null && g.IsEnemy( this, m ) )
return true;
if ( m is BaseGuard )
return false;

Thx Arte, srry to be a pest.
ArteGordon- 10-08-2007
you will need to add this to the top of basecreature.cs

CODE
using Server.Engines.XmlSpawner2;

Kin-Kran- 10-08-2007
No excuse on my end. That has hurt me before.
ArteGordon- 10-08-2007
I tend to forget about it since once you have it there for one mod, you dont have to think about again for any others.