Thes
Member
- ServUO Version
- Publish Unknown
- Ultima Expansion
- High Seas
Hi everyone!
I'm relatively new to writing / editing ServUO files, so this may be a bit more of an undertaking than I'm imagining here. I attempted to search for something similar, but couldn't seem to find anything. Most threads seem to mention editing properties for items.
I am attempting to add new properties / values to the Mobile.cs class for use with a few items within the server. The first and perhaps most simple concept is to have a value of "MagicUser". This value would be accessed from SpellScroll OnDoubleClick() and similar items to check if a Player or Mobile is able to use magic.
So far I've added the following to Mobile.cs:
Then in my SpellScroll.cs file I added a check for MagicUser
The two issues that are being had are:
The MagicUser property doesn't show up in [Props, which the GMs should be able to see / edit to enable it for players.
On compile, SpellScroll.cs is stating that from.MagicUser doesn't exist.
Thank you for any help!
[Edited to fix the code blocks for easier reading]
I'm relatively new to writing / editing ServUO files, so this may be a bit more of an undertaking than I'm imagining here. I attempted to search for something similar, but couldn't seem to find anything. Most threads seem to mention editing properties for items.
I am attempting to add new properties / values to the Mobile.cs class for use with a few items within the server. The first and perhaps most simple concept is to have a value of "MagicUser". This value would be accessed from SpellScroll OnDoubleClick() and similar items to check if a Player or Mobile is able to use magic.
So far I've added the following to Mobile.cs:
Mobile.cs changes:
public class Mobile : IEntity, IHued, IComparable<Mobile>, ISerializable, ISpawnable, IDamageable
{
// My understanding is this would allow calls to MagicUser for Mobile types.
private bool _magic_user;
[CommandProperty(AccessLevel.GameMaster)]
public bool MagicUser{ get { return _magic_user; } set { _magic_user= value; } }
// ... normal Mobile.cs things here
// This is attempting to get MagicUser to show up in [Props
public virtual void AddCustomProperties(ObjectPropertyList list)
{
// Adding Properties Specific to Imperius
list.Add("MagicUser", _magic_user);
}
}
Then in my SpellScroll.cs file I added a check for MagicUser
SpellScroll.cs OnDoubleClick:
public override void OnDoubleClick(Mobile from)
{
if (!Multis.DesignContext.Check(from))
return; // They are customizing
if (!this.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
return;
}
// If the user is unable to use magic, notify and exit
if (!from.MagicUser)
{
from.SendMessage("You aren't quite sure what to do with this.");
return;
}
#region SA
else if (from.Flying && from is PlayerMobile && BaseMount.OnFlightPath(from))
{
from.SendLocalizedMessage(1113749); // You may not use that while flying over such precarious terrain.
return;
}
#endregion
Spell spell = SpellRegistry.NewSpell(this.m_SpellID, from, this);
if (spell != null)
spell.Cast();
else
from.SendLocalizedMessage(502345); // This spell has been temporarily disabled.
}
}
}
The two issues that are being had are:
The MagicUser property doesn't show up in [Props, which the GMs should be able to see / edit to enable it for players.
On compile, SpellScroll.cs is stating that from.MagicUser doesn't exist.
Thank you for any help!
[Edited to fix the code blocks for easier reading]
Last edited: