(Greater) Magic Fang
Posted: Sun Jun 27, 2004 11:24 am
Hi all,
I have created a fix to the (Greater) Magic Fang script. It now works according to PnP (3.5) rules, this means:
- ALL creatures can be targetted (also the casters themself, the summons, polymorphed druids, etc)
- Magic Fang works 1 turn/level and Greater Magic Fang 1 hour/level
- The enhancement bonus for Greater Magic Fang is 1 per 4 levels, instead of 1 per 3 levels
- I have removed the damage reduction as it is not in the PnP spell description
- The enhancement is on the creature weapons and not a general enhancement as it was (so a polymorphed PC will have an enhancement bonus fighting unarmed if he has a creature weapon, but wont if he wields a weapon in that form)
There is one difference from PnP. In PnP you can choose to have either 1 creature weapon enhanced with a maximum of 5, or you can have all creature weapons enhanced with 1. In this implementation you can't choose and all creature weapons will always be enhanced with a maximum of 5.
The problem:
It requires a spells.2da fix as it currently doesn't allow targetting anything. So perhaps this could be included in the next CoPaP hak.
I have created a fix to the (Greater) Magic Fang script. It now works according to PnP (3.5) rules, this means:
- ALL creatures can be targetted (also the casters themself, the summons, polymorphed druids, etc)
- Magic Fang works 1 turn/level and Greater Magic Fang 1 hour/level
- The enhancement bonus for Greater Magic Fang is 1 per 4 levels, instead of 1 per 3 levels
- I have removed the damage reduction as it is not in the PnP spell description
- The enhancement is on the creature weapons and not a general enhancement as it was (so a polymorphed PC will have an enhancement bonus fighting unarmed if he has a creature weapon, but wont if he wields a weapon in that form)
There is one difference from PnP. In PnP you can choose to have either 1 creature weapon enhanced with a maximum of 5, or you can have all creature weapons enhanced with 1. In this implementation you can't choose and all creature weapons will always be enhanced with a maximum of 5.
The problem:
It requires a spells.2da fix as it currently doesn't allow targetting anything. So perhaps this could be included in the next CoPaP hak.
Code: Select all
#include "x2_inc_switches"
#include "x2_inc_itemprop"
void DoFixedMagicFang(int bGreater);
void main()
{
int nSpell=GetSpellId();
switch (nSpell)
{
case SPELL_MAGIC_FANG:
case SPELL_GREATER_MAGIC_FANG:
DoFixedMagicFang(nSpell == SPELL_GREATER_MAGIC_FANG);
SetModuleOverrideSpellScriptFinished();
break;
}
}
void DoFixedMagicFang(int bGreater)
{
int nCasterLevel = GetCasterLevel(OBJECT_SELF);
int nEnhancement = 1;
float fDuration;
object oTarget = GetSpellTargetObject();
if (!GetIsObjectValid(oTarget))
return;
// Greater magic fang gives an enhancement bonus of 1 per 4 levels
if (bGreater)
{
nEnhancement = nCasterLevel / 4;
if (nEnhancement > 5)
nEnhancement = 5;
}
itemproperty ipEnhancement = ItemPropertyEnhancementBonus(nEnhancement);
// Duration is 1 turn/level for magic fang and 1 hour/level for greater
if (bGreater)
fDuration = TurnsToSeconds(nCasterLevel);
else
fDuration = HoursToSeconds(nCasterLevel);
if (GetMetaMagicFeat() == METAMAGIC_EXTEND)
fDuration *= 2;
// Add the enhancement bonus to the creature weapons
object oWeapon = GetItemInSlot(INVENTORY_SLOT_CWEAPON_B, oTarget);
if (GetIsObjectValid(oWeapon))
IPSafeAddItemProperty(oWeapon, ipEnhancement, fDuration, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING, FALSE, TRUE);
oWeapon = GetItemInSlot(INVENTORY_SLOT_CWEAPON_L, oTarget);
if (GetIsObjectValid(oWeapon))
IPSafeAddItemProperty(oWeapon, ipEnhancement, fDuration, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING, FALSE, TRUE);
oWeapon = GetItemInSlot(INVENTORY_SLOT_CWEAPON_R, oTarget);
if (GetIsObjectValid(oWeapon))
IPSafeAddItemProperty(oWeapon, ipEnhancement, fDuration, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING, FALSE, TRUE);
//Fire spell cast at event for target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId(), FALSE));
// Visual effects
effect eVis = EffectVisualEffect(VFX_IMP_HOLY_AID);
effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, oTarget, fDuration);
}