For our rp shard we use a class system (magician, warrior, cleric, etccc) We must prohibit certain objects depending on the class

. How can we avoid, for example, that the magician wears a plate or that he can not use certain weapons? (eg plate helm, long sword, etccc)

We use this system found in this forum, here the file: classgump.cs

And in addition we have added a system for the variable ascent of skills, here is the definition of the classes: classtype.cs
 

Attachments

  • ClassGump.cs
    89.3 KB · Views: 4
  • ClassType.cs
    268 bytes · Views: 6
What you want to avoid is placing your custom code all over the place, since it will make it harder to troubleshoot or modify down the road.

Start by creating a ClassSystem class. In this class you can place some stubs as placeholders for future code.

Code:
public static bool canEquip(Item item, Mobile from)
{
     return true;
}

public static bool canCast(Spell spell, Mobile from)
{
     return true;
}

Next, in BaseWeapon.cs, in the OnEquip method, you make a call to the method over in the ClassSystem.

Code:
if (!ClassSystem.canEquip(this, from)) return false;

And you can do the same type of call in Spell if you want to restrict certain spells, etc.

Once these are in place, you can start coding inside the ClassSystem, and start checking to see what type of item they are trying to equip or what spell they are casting, etc. This way all your custom code is located in your new scripts.
 
Back