A huge thanks for those who have worked and continue to work on the spellhooking code.
This is the version for Greater Magic Weapon. Magic Weapon would be the same but with the enhancement set to 1.
case SPELL_GREATER_MAGIC_WEAPON :
//::///////////////////////////////////////////////
//:: Greater Magic Weapon
//:: V1.5
//:: Bioware: X2_S0_GrMagWeap
//:://////////////////////////////////////////////
{
effect eVis = EffectVisualEffect( VFX_IMP_SUPER_HEROISM );
effect eLink = EffectVisualEffect( VFX_DUR_CESSATE_POSITIVE );
int iDuration = iLevel;
int iBonus = iLevel / 4;
//Limit iLevel to 5, so it max out at +5 enhancement to the weapon.
if(iBonus > 5) iBonus = 5;
object oWeapon = SHS_GetTargetedOrEquippedMeleeWeapon(oTarget);
object oOwner = GetItemPossessor(oWeapon);
int iMilitantLevels;
if (MILITANT_LEVEL_BONUSES_ON)
{
iMilitantLevels = SHS_GetMilitantLevels(oOwner);
if (DEBUG) SendMessageToPC(oCaster, "avlis_spellhook:main():SPELL_GREATER_MAGIC_WEAPON: Militant Level: " + IntToString(iMilitantLevels));
}
if (GetWasMetamagicFeatUsed(iMeta, METAMAGIC_EXTEND)) iDuration = iDuration * 2; //Duration is +100%
// Militant Level Bonuses provide better buffs based on the number of
// militant levels a fighter style character has.
if (MILITANT_LEVEL_BONUSES_ON)
{
if (iMilitantLevels >= 6) iBonus++; //Enhancement bonus bump +1
if (iMilitantLevels >= 16) iDuration = iDuration + iDuration / 2; //Duration increased 50% - this stacks with Extend Spell
if (iMilitantLevels >= 26) iBonus++; //Enhancement bonus bump +1, total bump +2
if (iMilitantLevels >= 36) iBonus++; //Enhancement bonus bump +1, total bump +3
}
//Check to see if target is wearing gloves.
if((GetIsObjectValid(oWeapon)) && (GetBaseItemType(oWeapon)==BASE_ITEM_GLOVES))
{
SignalEvent(oOwner, EventSpellCastAt(oCaster, iSpell, FALSE));
if (iDuration>0)
{
//Code to keep people from enchanting weapons held by fighters then switching them.
if (MILITANT_LEVEL_BONUSES_ON && iMilitantLevels >= 6)
{
if (iMilitantLevels >= 6) SetLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON", 1);
if (iMilitantLevels >= 16) SetLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON", 2);
if (iMilitantLevels >= 26) SetLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON", 3);
if (iMilitantLevels >= 36) SetLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON", 4);
DelayCommand(TurnsToSeconds(iDuration), DeleteLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON"));
}
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oWeapon));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, GetItemPossessor(oWeapon), TurnsToSeconds(iDuration));
IPSafeAddItemProperty(oWeapon,ItemPropertyAttackBonus(iBonus), (TurnsToSeconds(iDuration)), X2_IP_ADDPROP_POLICY_REPLACE_EXISTING,FALSE,TRUE);
IPSafeAddItemProperty(oWeapon,ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_BLUDGEONING, iBonus), (TurnsToSeconds(iDuration)), X2_IP_ADDPROP_POLICY_REPLACE_EXISTING,FALSE,TRUE);
}
}
else if(GetIsObjectValid(oWeapon) )
{
SignalEvent(oOwner, EventSpellCastAt(oCaster, iSpell, FALSE));
if (iDuration>0)
{
//Code to keep people from enchanting weapons held by fighters then switching them.
if (MILITANT_LEVEL_BONUSES_ON && iMilitantLevels >= 6)
{
if (iMilitantLevels >= 6) SetLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON", 1);
if (iMilitantLevels >= 16) SetLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON", 2);
if (iMilitantLevels >= 26) SetLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON", 3);
if (iMilitantLevels >= 36) SetLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON", 4);
DelayCommand(TurnsToSeconds(iDuration), DeleteLocalInt(oWeapon, "SPELL_GREATER_MAGIC_WEAPON"));
}
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oWeapon));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, GetItemPossessor(oWeapon), TurnsToSeconds(iDuration));
IPSafeAddItemProperty(oWeapon,ItemPropertyEnhancementBonus(iBonus), (TurnsToSeconds(iDuration)), X2_IP_ADDPROP_POLICY_REPLACE_EXISTING,FALSE,TRUE);
}
}
else
FloatingTextStrRefOnCreature(83615, oCaster);
}
break;