updated to version 2.64
- quite a few additions in this one
- scripts have been reorganized.
Note small but important installation changes in steps 2 and 6 for people that have previous versions installed! see notes below.
Version 2.64
update 10/10/04
- added support for the OnAfterSpawned() method that can be defined in any mobile or item class and will be invoked when that item/mobile is spawned and placed in the world and AFTER any spawn entry modifications are applied. This allows individual objects to script in actions that they wish to occur at spawn time that require knowledge of the object's map and location. This differs from the OnSpawned() method that is applied BEFORE spawnentry modifications. This allows the OnAfterSpawned() method to take into account any properties that are changed in the spawn entry.
- a major system has been added that allows dynamic functionality to be added to items/mobs without requiring any modification to the item/mob scripts themselves. The system is called the "attachment" system, and is something like scripted "post-its" that can be stuck onto any item or mob, and can then give them new user-scriptable abilities. Multiple attachments can be added to targets. (thanks to Elementi for the inspiration)
For example, placing the simple xmlhue attachment onto a mobile allows you to change its hue for some duration, after which it gets changed back to its original hue. In order to do this conventionally you would have to modify the playermobile script with additional variables, serialization/deserialization, timers, etc. If you also wanted to be able to do the same thing for creatures, you would have to add the same mods to basecreature, armor... basearmor, etc. With attachments, you can add the hue changing ability to any item or mob with no script modification of the target class. This includes things that are derived directly from inaccessible classes such as statics.
- several new commands have been added for staff support of attachments. [addatt, [getatt, [delatt, [availatt
[addatt attachmenttype [args] - allows attachments of the specified type to be added to targeted objects. For example, to have a door display a message whenever it is approached, you could do "[addatt xmlmessage Welcome!". To also have a sound played you could add "[addatt xmlsound 1048"
[getatt [type] - allows the attachments on a targeted object to be listed. If the optional type argument is given, then only attachments of that type are displayed.
[delatt [type/serial [name]] - allows attachments on a targeted object to be deleted. If no arguments are given, then all attachments on the object are deleted. If the type is specified, then only attachments of that type are deleted. If a serial number is specified, then the specific attachment with that serial number is deleted (use [getatt to see the serial numbers).
[availatt - opens a gump that lists all of the available attachments and their various constructors and arguments. All constructors for objects derived from the XmlAttachment class and flagged with the [Attachable] attribute will be listed.
- a new checkbox has been added in the [xmlfind gump to allow searching for items/mobs with attachments. If the attach box is selected, then an additional filter for objects with attachments associated with them will be applied.
- the new ATTACH keyword has been added to the spawner that allows attachments to be added to spawned items/mobs. It is very similar to the ADD keyword, but instead of adding items, you add attachments. The syntax is "ATTACH[,probability]/attachmenttype". If you further wish to set properties on the attachment that you are adding, you would use the syntax "ATTACH[,probability]/<attachmenttype/prop/value/prop/value...>". For example, the xmlmagicword attachment has a requireidentification property that can be set, that forces players to identify the attachment before it can be used. This property can be set at spawn time with "ATTACH/<xmlmagicword/requireidentification/true>". See attachtest2.xml for an example.
- the GET series of keywords (this includes GET, GETONMOB, GETONTRIGMOB, GETONCARRIED, GETONSPAWN) now supports retrieving properties from attachments. Whereever a property would normally be specified for those keywords, the new property keyword <ATTACHMENT,type,name,property> can be used. For example, to read the value property on an xmlvalue attachment with the name XS on a triggering mob you would specify "GETONTRIGMOB,<ATTACHMENT,xmlvalue,XS,value>" (See attachtest1.xml for examples).
- attachments can also be used as quest rewards by specifying them in the RewardString of a questholder or questnote just as you would in the ATTACH keyword. You should also enable autoreward to have them automatically applied on quest completion. They will be displayed as a "Bonus:" in the quest gump. The details of the attachment cannot be queried at the moment, but I will add that capability (See minionstrike.xml for an example)
- Users can script their own attachments in much the same way that they would script new items or mobs. Attachments have class definitions that look similar to items or mobiles. All attachments are derived from the XmlAttachment class that implements the IXmlAttachment interface. This interface defines support for several features that all attachments have access to, including activation on movement, speech, and weapon hits (see XmlAttachment.cs for the interface specification). See the XmlAttachments folder for example scripts.
- attachments can also be used in other scripts by simply creating new instances of the attachments (e.g. XmlAttachment attachment = new XmlHue(200); ) and then applying them to the target with AttachTo(targetobject, attachment);
Note, that the attachment is achieved via an object/attachment hash table association, so there is no actual modification of the targetobject.
- all attachments are maintained in hashtables that are serialized separately from the item and mobile tables. The save information for attachments can be found in the Saves/Attachments folder.
- attachments support activation via speech or movement using the OnSpeech and OnMovement methods that can be defined in any attachment script. This is accomplished by adding additional speech and movement event handlers. I have done extensive stress test profiling of these handlers up to loads equivalent to 10,000 simultaneous players and have calculated the additional overhead to be around a maximum of 1-3% additional cpu overhead for movement at 10K players, and less than 0.1% for speech, with a proportional decrease in load with fewer players. While it is highly unlikely that anyone would notice any impact of these handlers, they can be disabled if desired (of course, speech/movement attachment triggering will also be disabled) by simply commenting out the EventSink.Speech and EventSink.Movement handler lines in the Initialize method of XmlAttach in XmlAttach.cs.
- note that optional installation steps 2 and 6 have been modified. For those that had the previous modifications, in BaseCreature.cs just change
XmlQuestToken.RegisterKill( this, ds.m_Mobile);
to
XmlQuest.RegisterKill( this, ds.m_Mobile);
and in ReportMurderer.cs change
Server.Items.XmlQuestToken.RegisterKill( m, g);
to
Server.Items.XmlQuest.RegisterKill( m, g);
- a new optional installation step 7 has been added to support the OnWeaponHit attachment method allowing attachments to be triggered when the targeted mob/weapon hits a defender.
- a new optional installation step 8 has been added to support the use of the ItemIdentification skill to reveal attachments on targeted items/mobs.
- the scripts in the package have been reorganized into folders.
- description of the new attachments included in this version:
XmlDex, XmlInt, XmlStr - these attachments simply apply temporary dex/int/str mods to the recipient. The value and duration can be specified.
XmlHue - allow the hue of the target to be temporarily modified. The value and duration can be specified.
XmlSkill - When applied to a mob, allows the specified skill to be temporarily modified. A word can also be specified which is required to activate the modification. If applied to a weapon or armor, the item must be equipped when the word is spoken to activate the skill mod. The skill, value, triggering word, and duration can be specified.
XmlDate, XmlData, XmlValue - these attachments allow bits of information to be added to the target. XmlDate supports DateTime information, XmlValue supports ints, XmlData supports strings. These can be added and read by spawners (see attachtest1.xml for an example).
XmlSound - allows a sound to be played whenever a player comes in range of the object it is attached to or says a triggering word. The sound value, minimum interval between activations, number of uses, and triggering word can be specified.
XmlMessage - allows an overhead message to be displayed whenever a player comes in range of the object it is attached to or says a triggering word. The message value, minimum interval between activations, number of uses, and triggering word can be specified.
XmlFire, XmlLightning - when attached to a weapon, it will apply additional fire/lightning damage on weapon hits. When attached to an object in the world it will apply damage when a player comes in range of the object. The amount of damage, minimum interval between activations, and how long the attachment will last (expiration) can be specified.
XmlMinionStrike - a personal favorite. When attached to a weapon, it allows the specified minions to be spawned with some probability every time the weapon hits a defender. These spawns will be under the control of the weapon owner. When attached to a mob, this ability will be applied to any weapon the mob wields (including fists). The minion type, chance of spawning, minimum interval between activations, and how long the attachment will last (expiration) can be specified (see minionstrike.xml for an example of its use).
XmlMagicWord - this is something of a template for a general speech activated attachment that has different abilities that can be unlocked depending on the word spoken. If it is added to a weapon or armor, the items must be equipped before the words can activate it. 9 words have been added
Lepto - gives a dex mod of +20
Malik - gives a str mod of +20
Shoda - gives an int mod of +20
Vas Malik - gives a str mod of +40
Tarda - gives a tactics skill mod of +20
Marda - gives a magery skill mod of +20
Narto - spawns a tamed drake
Santor - spawns a tamed horse
Velas - make you invisible
The activating word, duration of each effect, the number of uses, and how long the attachment will last (expiration) can be specified (see attachtest2.xml for an example).