98 lines
3.0 KiB
Plaintext
98 lines
3.0 KiB
Plaintext
|
#include "x2_inc_switches"
|
||
|
#include "prc_x2_itemprop"
|
||
|
|
||
|
//This function is used to create a proc system whereby weapons with onhitcastspell will only fire spell some of the time.
|
||
|
|
||
|
int GetHasOnHitCastSpell(object oItem);
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
int iRandom;
|
||
|
int iChance;
|
||
|
int iChanceMod;
|
||
|
int iChanceMod1;
|
||
|
int iChanceMod2;
|
||
|
object oItem;
|
||
|
object oPC;
|
||
|
|
||
|
oItem = GetSpellCastItem();
|
||
|
oPC = GetItemPossessor(oItem);
|
||
|
|
||
|
if (GetIsObjectValid(oItem))
|
||
|
{
|
||
|
if (GetBaseItemType(oItem) == BASE_ITEM_MAGICSTAFF || GetBaseItemType(oItem) == BASE_ITEM_MAGICWAND || GetBaseItemType(oItem) == BASE_ITEM_MAGICROD)
|
||
|
return;
|
||
|
if (GetHasOnHitCastSpell(oItem) == FALSE)
|
||
|
return;
|
||
|
if (IPGetIsMeleeWeapon(oItem) || GetBaseItemType(oItem) == BASE_ITEM_ARMOR || GetBaseItemType(oItem) == BASE_ITEM_GLOVES)
|
||
|
{
|
||
|
iChance = 7 + GetLocalInt(oPC,"ProcChanceBonus");
|
||
|
if (GetSkillRank(SKILL_LORE,oPC)>4)
|
||
|
iChanceMod1 = GetSkillRank(SKILL_LORE)/5;
|
||
|
if (GetSkillRank(SKILL_USE_MAGIC_DEVICE,oPC)>3)
|
||
|
iChanceMod2 = GetSkillRank(SKILL_USE_MAGIC_DEVICE)/4;
|
||
|
if (iChanceMod1 > iChanceMod2)
|
||
|
iChanceMod = iChanceMod1;
|
||
|
else
|
||
|
iChanceMod = iChanceMod2;
|
||
|
|
||
|
iChanceMod = iChanceMod + GetAbilityModifier(ABILITY_DEXTERITY,oPC)/2;
|
||
|
iChance = iChance + iChanceMod;
|
||
|
|
||
|
if (GetLevelByClass(CLASS_TYPE_FIGHTER,oPC) > 0)
|
||
|
iChance = iChance + 2;
|
||
|
|
||
|
if (GetLocalInt(GetModule(),"WildMagic") > 0)
|
||
|
iChance = iChance * 3;
|
||
|
|
||
|
if (GetLocalInt(oPC,"Lucky") == 1)
|
||
|
iChance = iChance * 2;
|
||
|
|
||
|
iRandom=Random(100)+1;
|
||
|
|
||
|
//debug line
|
||
|
//SendMessageToPC(GetFirstPC(),GetName(oPC) + " Proc: Random = " + IntToString(iRandom) + " Chance = " + IntToString(iChance));
|
||
|
//if gloves or armor check to see if in combat (to account for cast spell properties to work out of combat)
|
||
|
|
||
|
if (GetBaseItemType(oItem) == BASE_ITEM_GLOVES || GetBaseItemType(oItem) == BASE_ITEM_ARMOR)
|
||
|
if (!GetIsInCombat(oPC))
|
||
|
iRandom = 1;
|
||
|
if (iRandom > iChance)
|
||
|
SetModuleOverrideSpellScriptFinished();
|
||
|
} else {
|
||
|
if (GetLocalInt(GetModule(),"WildMagic") > 0)
|
||
|
if (Random(5)==0)
|
||
|
{
|
||
|
oPC = GetItemPossessor(oItem);
|
||
|
SendMessageToPC(oPC,"The wild magic disrupts your use of the " + GetName(oItem));
|
||
|
SetModuleOverrideSpellScriptFinished();
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
if (GetLocalInt(GetModule(),"WildMagic") > 0)
|
||
|
if (Random(10)==0)
|
||
|
{
|
||
|
oPC = GetItemPossessor(oItem);
|
||
|
SendMessageToPC(oPC,"The wild magic disrupts your spellcasting.");
|
||
|
SetModuleOverrideSpellScriptFinished();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int GetHasOnHitCastSpell(object oItem)
|
||
|
{
|
||
|
int iResult;
|
||
|
|
||
|
iResult = FALSE;
|
||
|
|
||
|
itemproperty ip = GetFirstItemProperty(oItem);
|
||
|
while (GetIsItemPropertyValid(ip))
|
||
|
{
|
||
|
if (GetItemPropertyType(ip) == ITEM_PROPERTY_ONHITCASTSPELL)
|
||
|
iResult = TRUE;
|
||
|
ip = GetNextItemProperty(oItem);
|
||
|
}
|
||
|
|
||
|
return iResult;
|
||
|
}
|