RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

XmlCustomAttacks

ArteGordon

Wanderer
XmlCustomAttacks/XmlCustomDefenses v1.02

XmlCustomAttacks/XmlCustomDefenses
v1.02
updated 11/29/04
ArteGordon

SUMMARY
This set of attachments provides a system for adding custom special attacks to weapons and defenses to shields including combos that require a series of specific special moves to be executed in a timed sequence. Any number of special moves can be enabled on a given weapon/shield, and combos can be made up of sequences of arbitrary length and complexity.


INSTALLATION:

This thread is no longer updated. GO HERE for the latest version
http://www.runuo.com/forum/showthread.php?t=49927

DESCRIPTION:

This system makes use of the XmlSpawner2 attachment system and the XmlSpawner2 package must be installed to support it. You dont need to use the xmlspawners themselves, and it doesnt matter whether you use the standard distribution spawners or any other spawning system but you do need the XmlSpawner2 package installed.

Because the attachment system neither requires nor makes any changes to serialization/deserializations of any item or mobile, it can be safely added and removed at any time now or in the future without interfering with any other systems that you might have installed.

Note, this is intended as more of a development system for people to add custom content to their shards than a full drop-and-play system with a full complement of attacks and combos. While I have included some attacks and combos in the package, they are largely intended to illustrate its features, and are not necessarily balanced for drop-and-play use (although you could certainly do that if you wanted to). Add, fiddle, and most importantly, have fun.

Features:

When a weapon with this attachment is equipped, a gump containing icons for the special attacks that it has available will be displayed.
Attacks can be selected by pressing one of the attack icons. When selected, the icon will turn red until it is activated by a successful hit.
The description and requirements for an attack can be viewed by pressing the small blue button to the right of the attack selection button.
Secret combination attacks can be unleashed by executing the proper sequence of special moves.

Several special attacks and combos have been added to illustrate how to configure moves, but the system can be extended with any number of additional moves.

Examples of included special attacks/combos:

Gift of Health - Restores attacker to full health
Requires - 30 int, 60 Healing
Uses - 40 mana, 20 stamina, 2 ginseng, 2 mandrake, 50 gold.

Puff of Smoke - Makes the attacker invisible
Requires - 40 dex, 50 Stealth, 50 Hiding
Uses - 20 mana, 40 stamina, 2 spiderssilk.

Paralyzing Fear - Paralyzes the target then causes it to flee
Requires - 40 int, 30 Necromancy
Uses - 10 mana, 10 stamina, 5 hits, 10 karma, 1 Head

Thunder Strike - a combo attack activated by the following sequence of custom attacks
TripleSlash + MindDrain + ParalyzingFear + TripleSlash + StamDrain


Customizable special attacks:

- user-definable special attacks can be designed and added to weapons in any combination and number.

- special attacks can be given requirements that include minimum str, dex, int, and skills.

- executing an attack can be defined to consume mana, stamina, hits, karma, and any number and type of reagent.


Customizable combo attacks:

- special combo attacks can be created that are executed when a definable sequence of special attacks has been carried out in the proper order and without interruption.

- The custom attacks gump has an indicator at the top of the gump that signals when a combo sequence has been started and is still in progress. When it goes out, that means that it has been interrupted either due to executing a special move out of sequence, or taking too long between moves.

- Because the end of one combo could be the beginning of another, it is possible to chain multiple combos together.
Combos that share moves can even be executed together for multiple simultaneous combos.


Adding custom attacks to weapons:

Manually to individual weapons

- the custom attacks attachment can be added to weapons in several ways. It can be manually attached to any existing weapon with the "[addatt" command, which is the general command from the XmlSpawner2 package for adding attachments.

For example

"[addatt xmlcustomattacks random 4"

will attach 4 randomly selected custom attacks to a targeted weapon.

"[addatt xmlcustomattacks tartan"

Will add a predefined custom attack configuration that was named "tartan" in the attachment constructor in XmlCustomAttacks.cs

To weapon scripts

- Special attacks can also be added to scripted weapons. See the included script TestCustomWeapon.cs for an example of this.

To spawned weapons

- To add special attacks to spawned weapons use the ATTACH keyword in spawn entries such as this

katana/ATTACH/xmlcustomattacks,random,4

which would spawn a katana with 4 randomly selected custom attacks.

or

orc/ADD/<katana/ATTACH/xmlcustomattacks,random,4>

would spawn an orc carrying the katana with custom attacks.

To try out the inlcuded example spawner .xml file, place the file "customattacks.xml" in your top level RunUO directory and execute the command

"[xmlloadhere customattacks.xml"

Adding custom defenses to shields:

Manually to individual shields

- the custom defenses attachment can be added to shields in several ways. It can be manually attached to any existing shield with the "[addatt" command.

For example

"[addatt xmlcustomdefenses random 4"

will attach 4 randomly selected custom defenses to a targeted shield

"[addatt xmlcustomdefenses brogan"

Will add a predefined custom defense configuration that was named "brogan" in the attachment constructor in XmlCustomDefenses.cs

To shield scripts

- Special defenses can also be added to scripted shields. See the included script TestCustomShield.cs for an example of this.

To spawned shields

- To add special defenses to spawned shields use the ATTACH keyword in spawn entries such as this

buckler/ATTACH/xmlcustomdefenses,random,4

which would spawn a buckler with 4 randomly selected custom defenses

or

orc/ADD/<buckler/ATTACH/xmlcustomdefenses,random,4>

would spawn an orc carrying the buckler with custom defenses.
 

ArteGordon

Wanderer
thanks.

Just a note for those of you using the 3D client, or who would like this to work with the 3D client.

The red huing of the attack icons when selected is not supported by the 3D client. There is an alternate selection highlighting option in the code that you can enable.

around line 930, uncomment this block of code
Code:
                    // flag the attack as being selected
                    /*
                    if(m_attachment != null && m_attachment.m_SelectedAttack != null && m_attachment.m_SelectedAttack == s)
                    {
                        AddImageTiled( 1, y-2, 70, 50, 0xBBC );
                    }
                    */
 

fyggnuuton

Wanderer
i made a custom attack and i think i missed something, it wont let me use it, and it doesnt show the icon, but it shows the button and the info for it. this is what i added to the script:

Code:
         public enum SpecialAttacks
        {
            TripleSlash,
            MindDrain,
            StamDrain,
            ParalyzingFear,
            GiftOfHealth,
            FireShield,
            PuffOfSmoke
        }
------------------------------------------------------------

            AddSpecialAttack("Unleash", "Unleashes dormant energy from your shield",
                SpecialAttacks.FireShield, 0x20aa, TimeSpan.FromSeconds(3.5),
                20, 0, 0, 0,
                0,0,0,
                new SkillName [] { SkillName.Magery },
                new int [] { 40 },
                new Type [] {typeof(FireShield)},
                new int [] { 1 }
            );

----------------------------------------------------------------

                case SpecialAttacks.FireShield:
                {
                    defender.Damage( weapon.MaxDamage*2, attacker );
                    attacker.PlaySound( 0x34A );
                    defender.PlaySound( 0x34A );
                    defender.FixedEffect( 0x36BD, 20, 10 );
                    break;
                }

i also added it in the radomized class, but that is pretty standard. i think i am leaving something out. any idea?
 

ArteGordon

Wanderer
yeah, it is just because you are specifying an itemid instead of a gumpid here and there is no default gump art at 0x20aa

SpecialAttacks.FireShield, 0x20aa, TimeSpan.FromSeconds(3.5),

----------------------------------^

I'll work on an overload of AddSpecialAttack that will let you use item art instead of gump art for the buttons.

You can find the gump art in the Gumps section of InsideUO instead of the Artwork section.
 

fyggnuuton

Wanderer
ArteGordon said:
yeah, it is just because you are specifying an itemid instead of a gumpid here and there is no default gump art at 0x20aa

SpecialAttacks.FireShield, 0x20aa, TimeSpan.FromSeconds(3.5),

----------------------------------^

I'll work on an overload of AddSpecialAttack that will let you use item art instead of gump art for the buttons.

You can find the gump art in the Gumps section of InsideUO instead of the Artwork section.

ohhhh yea that makes perfect sense actually, thank you.
 

LordHogFred

Knight
This looks SOOOOOOO cool.

However when I try and start my server now the scripts compile with no problems whatsoever but once it's running it tries to terinate the server.

This is my crash log:
Code:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.ArrayListEnumeratorSimple.MoveNext()
   at Server.Engines.XmlSpawner2.XmlAttach.Initialize()
   --- End of inner exception stack trace ---
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Server.ScriptCompiler.Compile(Boolean debug)
   at Server.Core.Main(String[] args)

Any ideas?

Chz :),
 

ArteGordon

Wanderer
hmm is this just after you have installed xmlspawner2 for the first time perhaps?

(edit)

I think I have found the problem. It occurs when starting for the first time when there are no attachments to be deserialized.

in the file XmlAttach.cs, in the Load() method around line 308, change this

Code:
if ( !File.Exists( filePath ) )
				return;

to this

Code:
if ( !File.Exists( filePath ) )
			{
                ASerial.serialInitialized = true;
				return;
			}
 

ArteGordon

Wanderer
yeah, I just added support for an OnArmorHit method to the attachment system that will allow armor pieces such as shields to have special moves attached to them that can be executed when the piece gets hit.
It will appear in the next XmlSpawner2 update (along with the bug fix above).

Initially, I will probably restrict the custom attacks to shields until I work out a system for handling the multiple special moves gumps that could potentially be available with different armor pieces.
I'm thinking maybe some paperdoll-like configuration with the move selections appearing at the location of the armor piece.

I'm also finishing up a socketing system that will work with the custom attacks system to allow moves to be added to pieces via socketable augmentation. It will be released as a separate attachment package.
 

ArteGordon

Wanderer
when you say you needed to remove the code again, do you mean that you needed to make a save without this package installed, and then install it again?

It should have simply failed to load any of the initial attachments that might have been saved immediately after installation, and mentioned that it couldnt deserialized them on restart, but still continue loading without a problem.
 

ArteGordon

Wanderer
dstarz20 said:
I think I have everything Loaded Up great, but the Gump does not appear when I equip the Weapon, any ideas?

double check to make sure you completed installation step 9 in the XmlSpawner2 package. It is the one that enables the ability of attachments to make use of the OnEquip and OnRemoved methods that are needed for bringing up the gump.
 

ArteGordon

Wanderer
updated to version 1.01
11/26/04

from the changelog

New to v1.01
updated 11/26/04

- added the option to use item art instead of gump art for the button icons when calling AddSpecialAttack with a new overload of that method. An example of a new attack using item art is included in XmlCustomAttacks.cs. Look at the AddSpecialAttack call for the new VortexWave attack in the Initialize() method.

- added the new XmlCustomDefenses attachment that can be used with shields to enable special defensive moves and combos that are activated when the shield is hit. This attachment has its own special moves gump and combo indicator, and both attack and defense gumps can be used at the same time. Special defense moves and combos are added into XmlCustomDefenses.cs

- to support the new defensive moves, version 2.69 or higher of the XmlSpawner2 package must be installed and step 10 of that installation must be followed.

- updated the .xml example customattacks.xml to include the new defensive attachment, and added a new example script for defensive attachments called TestCustomShield.cs
 

Vertigo

Wanderer
wow nice script

ArteGordon
Hia
Arte any way add in list properties what special on this weapon.

sory for my english :p
 

ArteGordon

Wanderer
Vertigo said:
wow nice script

ArteGordon
Hia
Arte any way add in list properties what special on this weapon.

sory for my english :p

yes, you can add this to the beginning of the GetProperties method in BaseWeapon.cs

around line 2426 change this

Code:
public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );

to this

Code:
		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );

            XmlAttachment a = XmlAttach.FindAttachment(this, typeof(XmlCustomAttacks));
            if(a != null)
                list.Add( 1062613, a.OnIdentify(null));

if you also wanted them to show up on shields, make a similar change in basearmor.cs but refer to XmlCustomDefenses instead of XmlCustomAttacks.

(edit)

oh, and you have to put this at the top of the baseweapon.cs or basearmor.cs script as well

Code:
using Server.Engines.XmlSpawner2;
 
I accidently didn't put anything after [AddAtt and the server crashed, giving me this error:

Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Server.Engines.XmlSpawner2.AttachTarget.OnTarget(Mobile from, Object targeted)
at Server.Targeting.Target.Invoke(Mobile from, Object targeted)
at Server.Network.PacketHandlers.TargetResponse(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)

Works like a charm otherwise ;)
 
Top