I'm trying to adapt this script to be used on a placeable as opposed to an item unique power. I don't need to lore check or the examine functions tbh, I just would like the recharge functions. If anyone can help out that'd be great!
/*
rchrgitmskl
A script designed to be used inconjuction with a item with a tag name of the
same value as the script name and has the cast spell unique ability set
that can be used to recharge magical items that use charges.
It works by if you have the item to be charged in your packpack it will examine
the item and inform the user of the difficulty, xp loss and gold loss to perfom
the charging. If its on the ground or equiped however it will attempt a charging
process.
The caster must have sufficient Lore to be able to perform a DC check to be
able to perform the operations and in the case of charging a Spellcraft check
is made.
It recharges based a value of the caster level divided by 2, and is set to a
maximum variable in the script currently set to 50.
It is a unlimited use per day item that is undroppable and only useable by
wizards and sorcerers, but I have offset the value of doing this
with balanced xp and gold losses. This is intentional so as not to make the
"skill" to powerful. (The values are open to debate and further testing but
I had lots of fun on a little mod with it, enjoy.)
*/
#include "nw_i0_generic"
void main ()
{
object oItem = GetItemActivated();
object oTarget = GetItemActivatedTarget();
location lTarget = GetItemActivatedTargetLocation();
object oPC = GetItemActivator();
int nMaxCharges = 50; // Maximum recharge value and check
int iDC;
int iEasy = 30; // Easy Charge item DC value
int iNormal = 35; // Normal DC
int iHard = 40; // Hard DC
int ixpweighter = 15; // xp loss is DC * weighter
int igpweighter = 3; // gp loss is DC * weighter
int iValidType = FALSE;
int iExamMode = FALSE;
object oInv = GetFirstItemInInventory(oPC);
// Check to see if the target object is in the inventory or not
// If it is we examine the possibiltiy of success and loss factors and
// display them to the player.
// If not then the target object must be on the floor or elsewhere so
// we use the charging mode.
while (oInv != OBJECT_INVALID)
{
if (oInv == oTarget)
{
iExamMode = TRUE;
oInv = OBJECT_INVALID;
}
else
{
oInv = GetNextItemInInventory(oPC);
}
}
int nCharges = GetItemCharges(oTarget);
// Check that oTarget is a magical item with ability to cast spells
if (GetItemHasItemProperty(oTarget, ITEM_PROPERTY_CAST_SPELL) == TRUE &&
nCharges > 0)
{
// Check that no of current charges < maximum recharge limit
if (nCharges < nMaxCharges)
{
// Check that caster has required Lore and valid item type for action
// Get DC (difficulty check at the same time)
int iPCLore = GetSkillRank(SKILL_LORE, oPC);
int itype = GetBaseItemType(oTarget);
switch(itype)
{
case BASE_ITEM_AMULET:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_ARMOR:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_BASTARDSWORD:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_BATTLEAXE:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_BELT:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_BOOTS:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_BRACER:
iDC = iEasy;
iValidType = TRUE;
break;
case BASE_ITEM_CBLUDGWEAPON:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_CLOAK:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_CLUB:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_CPIERCWEAPON:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_CSLASHWEAPON:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_CSLSHPRCWEAP:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_DAGGER:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_DIREMACE:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_DOUBLEAXE:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_DWARVENWARAXE:
iDC = iHard;
// Perhaps put check for caster to be race dwarf here?
iValidType = TRUE;
break;
case BASE_ITEM_GLOVES:
iDC = iEasy;
iValidType = TRUE;
break;
case BASE_ITEM_GREATAXE:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_GREATSWORD:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_HALBERD:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_HANDAXE:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_HEAVYCROSSBOW:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_HEAVYFLAIL:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_HELMET:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_KAMA:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_KATANA:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_KUKRI:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_LARGESHIELD:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_LIGHTCROSSBOW:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_LIGHTFLAIL:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_LIGHTHAMMER:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_LIGHTMACE:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_LONGBOW:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_LONGSWORD:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_MAGICROD:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_MAGICSTAFF:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_MAGICWAND:
iDC = iEasy;
iValidType = TRUE;
break;
case BASE_ITEM_MORNINGSTAR:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_QUARTERSTAFF:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_RAPIER:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_RING:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_SCIMITAR:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_SCYTHE:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_SHORTBOW:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_SHORTSPEAR:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_SHORTSWORD:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_SICKLE:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_SLING:
iDC = iNormal;
iValidType = TRUE;
break;
case BASE_ITEM_SMALLSHIELD:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_TOWERSHIELD:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_TWOBLADEDSWORD:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_WARHAMMER:
iDC = iHard;
iValidType = TRUE;
break;
case BASE_ITEM_WHIP:
iDC = iHard;
iValidType = TRUE;
break;
}
if (iValidType == TRUE)
{
if ((iPCLore + 20) >= iDC) // Sufficient Lore to do it
{
// Determine xp and gold loss
int ixploss = (iDC * ixpweighter);
int igploss = (iDC * igpweighter);
// Check Mode
// IF examine Mode
if (iExamMode == TRUE)
{
// Display Chance of success and xp/gold amounts
string sExamine = "Charging will be at Spellcraft DC: ";
sExamine = sExamine + IntToString(iDC);
sExamine = sExamine + " and will Cost: ";
sExamine = sExamine + IntToString(ixploss) + " xp";
if (igploss > 0)
{
sExamine = sExamine + " and " + IntToString(igploss) +" gp";
}
sExamine = sExamine + ".";
SendMessageToPC(oPC, sExamine);
// Restore daily use in unique item (OBJECT_SELF)?
}
else
{
// IF charge Mode
// Check player has sufficient gold and xp
int iPCxp = GetXP(oPC);
int iPCgp = GetGold(oPC);
if ((iPCxp - ixploss) > 0)
{
if ((iPCgp - igploss) > 0)
{
// Attempt Charge process
int iSpellCraft = GetSkillRank(SKILL_SPELLCRAFT, oPC);
if (GetIsSkillSuccessful(oPC, SKILL_SPELLCRAFT, iDC) == TRUE)
{
// If successfull
int iWizlvl = GetLevelByclass(class_TYPE_WIZARD, oPC);
int iSorlvl = GetLevelByclass(class_TYPE_SORCERER, oPC);
int itotlvl = iWizlvl + iSorlvl;
int nRecharge = itotlvl / 2;
if (nRecharge == 0)
{
nRecharge = 1;
}
if (nCharges + nRecharge > 50)
{
nRecharge = 50;
}
else
{
nRecharge = nCharges + nRecharge;
}
// play spell animation for effect
FloatingTextStringOnCreature
("Enzur Hirath alka ishdo.", oPC, TRUE);
effect eCharge = EffectDispelMagicAll(itotlvl);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,
eCharge, oTarget, 5.0);
// Recharge item
SetItemCharges(oTarget, nRecharge);
string sRecharge = "Object recharged to value: ";
sRecharge = sRecharge + IntToString(nRecharge);
SendMessageToPC(oPC, sRecharge); // Debug
// reduce xp/gold
int inewxp = iPCxp - ixploss;
SetXP(oPC, inewxp);
if (igploss > 0)
{
TakeGoldFromCreature(igploss, oPC, TRUE);
}
}
else
{
// If unsucssfull check for critical failure, reduce charges and check
// to see whether to destroy item
int ifail = d20(1);
if (ifail == 1)
{
int iReduce = (d4(1) - 1);
nCharges = nCharges - iReduce;
if (nCharges < 0)
{
nCharges = 0;
}
string sfailed = "Critical Failure: Reduced charges by";
sfailed = sfailed + IntToString(iReduce);
SendMessageToPC(oPC, sfailed);
SetItemCharges(oTarget, nCharges);
}
}
}
else
{
SendMessageToPC(oPC, "You do not have enough Gold.");
}
}
else
{
SendMessageToPC(oPC, "You haven't enough experience to do this.");
}
} // Exam Mode
} // Sufficient Lore
else
{
SendMessageToPC(oPC, "You do not have sufficient Lore to do this.");
}
} // Valid Type
else
{
SendMessageToPC(oPC, "Cannot Recharge that Item.");
}
} // Check charges
else
{
SendMessageToPC(oPC, "Item is fully recharged.");
}
} // Check magical
else
{
SendMessageToPC(oPC,"Item is not a spell casting type object that has charges");
}
}
Modifié par Birdman076, 11 septembre 2011 - 03:01 .