Hi everyone. Just wondering. Let’s say I’ve custom-made this magic item which I intend only certain player classes to be able to use. Now as you all know bards and rogues can use their ‘Use Magic Device’ skill to get around this. My question is: is there any way I can enforce the limitation ruling so that, sorry, you can’t get around it even with the ‘Use Magic Device’ skill? Or can I at least make it necessary for a bard or rogue to up his UMD skill so high before he can use it that he’ll most probably say, ‘Naaaahh, it’s not worth it’ ?
You could check for whether the user has class levels in any of the permitted classes, and abort the script with a custom error message if they don’t. That should be pretty surefire. UMD would still let bards and rogues activate the item, but at that point, they’d run into the class levels abort check.
if (!GetLevelByClass(CLASS_TYPE_WIZARD, oPC) &&
!GetLevelByClass(CLASS_TYPE_SORCERER, oPC))
{
SendMessageToPC(oPC, "You need to have class levels in Wizard or Sorcerer to use this!");
return;
}
Sounds great! Where do I slot the script?
What kind of magic item is it? Example above supposes a tagbased scripting item, with an activatable unique power.
If you want the stuff that would normally happen on activation of the item to be constrained by a class check, you’d put the class check abort into the X2_ITEM_EVENT_ACTIVATE section. Reactions to being equipped by someone with the wrong class (like auto-unequipping) would go into X2_ITEM_EVENT_EQUIP.
Wow, didn’t know anything at all about tagbased item scripting until you revealed it to me. So much to learn! Will have to go through and slowly absorb it all – and, hey, maybe I can use it to go around the problem I’m still facing (sigh) with my intelligent item… (Fingers crossed…)
Basically my item is just a magic item that has the item property of enabling its user to cast a certain spell once a day – and cannot (I intend) be used by bards. Just find it kind of unfair that bards and rogues can basically get to use any magic item with the UMD skill – a skill no others classes can have. So I want an item that only non-bards can use!
You could also, on ITEM_ACTIVATE,(Module Properties) notate an ‘if’ script; following the PC’s use magic device skill and set your own DC rank. for Ex…
object oitem, = (" item ");
if (GetIsSkillSuccessful(oPC, SKILL_USE_MAGIC_DEVICE, 10))
{ //This happens
else
{
//Do nothing
}
}
The game engine will automatically roll your DC check for PC’s use magic device on tagged item.
Thanks for the help, mate!
::silently tosses over commented example of how to set up tagbased activatable spell-casting magic items with class level check aborts, doing an “ingame day/month” check rather than one that gets reset on player rest, for TEH SPREAD OF KNOWLEDGS::
#include "x2_inc_switches"
void main()
{
int nEvent = GetUserDefinedItemEventNumber();
object oPC, oItem, oTarget;
int nCurrentDay, nCurrentMonth, nUsedDay, nUsedMonth;
location lTarget;
// If the user defined item event that is triggering this script is
// the "item has been activated" event:
if (GetUserDefinedItemEventNumber() == X2_ITEM_EVENT_ACTIVATE)
{
// Find the object who activated the item, the item that was activated,
// and the target that the item was activated at.
oPC = GetItemActivator();
oItem = GetItemActivated();
oTarget = GetItemActivatedTarget();
lTarget = GetItemActivatedTargetLocation();
// Check for whether the activator has class levels in bard or rogue.
if (GetLevelByClass(CLASS_TYPE_BARD, oPC) ||
GetLevelByClass(CLASS_TYPE_ROGUE, oPC))
{
// Abort if they do.
SendMessageToPC(oPC, "Bards and rogues cannot use this item!");
return;
}
else
{
// If they don't have class levels in bard or rogue...
// Check current and stored month and day.
nCurrentDay = GetCalendarDay();
nCurrentMonth = GetCalendarMonth();
nUsedDay = GetLocalInt(oItem, "LAST_USED_ON_DAY");
nUsedMonth = GetLocalInt(oItem, "LAST_USED_ON_MONTH");
// If the stored day and month are equal to the current day and month,
// then this item has already been used today.
if (nUsedDay == nCurrentDay && nUsedMonth == nCurrentMonth)
{
SendMessageToPC(oPC, "The item has already been used today.");
}
else
{
// Otherwise, the activator should use it.
SendMessageToPC(oPC, "Casting spell.");
AssignCommand(oPC, ClearAllActions());
if (oTarget != OBJECT_INVALID)
AssignCommand(oPC, ActionCastSpellAtObject(SPELL_SUMMON_CREATURE_I, oTarget, METAMAGIC_ANY, TRUE, 1, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
else
AssignCommand(oPC, ActionCastSpellAtLocation(SPELL_SUMMON_CREATURE_I, lTarget, METAMAGIC_ANY, TRUE, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
// Store current day and month.
SetLocalInt(oItem, "LAST_USED_ON_DAY", nCurrentDay);
SetLocalInt(oItem, "LAST_USED_ON_MONTH", nCurrentMonth);
}
}
}
}
You’re a real pal, Barbie. Will be trying this out!
Though first I must familiarise myself with tag-based scripting, to which I’m still very new…
My new custom item is intended to be called a ‘Lute of Vengeful Storms’, by the way. No need to guess what it does.