How add damage by feat to polymorphing shape?

Hi i’m new in modding of neverwinter nights 2 have some experience in programming but i don’t know how add damage by feat to custom polymorph i do a custom polymorph in dinosaur shape but for some reason since add something effects as more damage and resistance guiding me in some examples I can not transform

//::///////////////////////////////////////////////
//:: Wild Shape
//:: x2_s2_dinosaurshape
//:://////////////////////////////////////////////
#include “x2_inc_itemprop”
void main()
{
//Declare major variables
object oPC = OBJECT_SELF;
int nSpell = GetSpellId();
object oTarget = GetSpellTargetObject();
effect eVis = EffectVisualEffect(VFX_DUR_POLYMORPH);
eVis = SupernaturalEffect(eVis); // AFW-OEI 12/07/2006: Make it so you can’t dispel the visual effect, which was dispelling wildshape.
effect ePoly;
int nPoly = POLYMORPH_TYPE_COW;
int nMetaMagic = GetMetaMagicFeat();
int nDuration = GetLevelByClass(CLASS_TYPE_DRUID);
//Enter Metamagic conditions
if (nMetaMagic == METAMAGIC_EXTEND)
{
nDuration = nDuration *2; //Duration is +100%
}
nPoly = 208;
if (nDuration >= 12)
{
nPoly = 209;
}
if (nDuration >= 16)
{
nPoly = 210;
}
if (nDuration >= 18)
{
nPoly = 211;
}
if (nDuration >= 20)
{
nPoly = 212;
}
if (nDuration >= 23)
{
nPoly = 213;
}
if (nDuration >= 26)
{
nPoly = 214;
}
if (nDuration >= 30)
{
nPoly = 215;
}

ePoly = EffectPolymorph(nPoly, FALSE, TRUE);	// AFW-OEI 11/27/2006: Use 3rd boolean to say this is a wildshape polymorph.
ePoly = SupernaturalEffect(ePoly);

if (GetHasFeat(3131, oPC, TRUE) == TRUE){
	ePoly = EffectDamageIncrease(1);
	ePoly = SupernaturalEffect(ePoly);
	ePoly = EffectDamageIncrease(DAMAGE_BONUS_1d6,DAMAGE_TYPE_DIVINE);
	ePoly = SupernaturalEffect(ePoly);
}
if (GetHasFeat(3132, oPC, TRUE) == TRUE){
	ePoly = EffectSpellResistanceIncrease(nDuration + 5);
	ePoly = SupernaturalEffect(ePoly);
	if(nDuration >= 12){
		ePoly = EffectDamageReduction(10);	
	} else {
		ePoly = EffectDamageReduction(5);	
	}
	ePoly = SupernaturalEffect(ePoly);
	if(GetGoodEvilValue(oPC)< 50){
		if(nDuration >= 8){
		ePoly=EffectDamageResistance(DAMAGE_TYPE_COLD,5);
		ePoly = SupernaturalEffect(ePoly);
		ePoly=EffectDamageResistance(DAMAGE_TYPE_FIRE,5);
		ePoly = SupernaturalEffect(ePoly);
		} else {
		ePoly=EffectDamageResistance(DAMAGE_TYPE_COLD,10);
		ePoly = SupernaturalEffect(ePoly);
		ePoly=EffectDamageResistance(DAMAGE_TYPE_FIRE,10);
		ePoly = SupernaturalEffect(ePoly);
		}
	} else {
		if(nDuration >= 8){
		ePoly=EffectDamageResistance(DAMAGE_TYPE_COLD,5);
		ePoly = SupernaturalEffect(ePoly);
		ePoly=EffectDamageResistance(DAMAGE_TYPE_ELECTRICAL,5);
		ePoly = SupernaturalEffect(ePoly);
		ePoly=EffectDamageResistance(DAMAGE_TYPE_ACID,5);
		ePoly = SupernaturalEffect(ePoly);
		} else {
		ePoly=EffectDamageResistance(DAMAGE_TYPE_COLD,10);
		ePoly = SupernaturalEffect(ePoly);
		ePoly=EffectDamageResistance(DAMAGE_TYPE_ELECTRICAL,5);
		ePoly = SupernaturalEffect(ePoly);
		ePoly=EffectDamageResistance(DAMAGE_TYPE_ACID,5);
		ePoly = SupernaturalEffect(ePoly);;
		}
	}
	
	ePoly = EffectDamageIncrease(DAMAGE_BONUS_1,DAMAGE_TYPE_DIVINE);
	ePoly = SupernaturalEffect(ePoly);
	ePoly = EffectDamageIncrease(DAMAGE_BONUS_1d6,DAMAGE_TYPE_MAGICAL,RACIAL_TYPE_UNDEAD);
	ePoly = SupernaturalEffect(ePoly);
	ePoly = EffectDamageIncrease(DAMAGE_BONUS_1d6,DAMAGE_TYPE_MAGICAL,RACIAL_TYPE_OUTSIDER);
	ePoly = SupernaturalEffect(ePoly);
}
ePoly = EffectLinkEffects( ePoly, eVis );
ePoly = SupernaturalEffect(ePoly);
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(oPC, SPELLABILITY_WILD_SHAPE, FALSE));

int bWeapon = StringToInt(Get2DAString("polymorph","MergeW",nPoly)) == 1;
int bArmor  = StringToInt(Get2DAString("polymorph","MergeA",nPoly)) == 1;
int bItems  = StringToInt(Get2DAString("polymorph","MergeI",nPoly)) == 1;

object oWeaponOld = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
object oArmorOld = GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
object oRing1Old = GetItemInSlot(INVENTORY_SLOT_LEFTRING,oPC);
object oRing2Old = GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oPC);
object oAmuletOld = GetItemInSlot(INVENTORY_SLOT_NECK,oPC);
object oCloakOld  = GetItemInSlot(INVENTORY_SLOT_CLOAK,oPC);
object oBootsOld  = GetItemInSlot(INVENTORY_SLOT_BOOTS,oPC);
object oBeltOld = GetItemInSlot(INVENTORY_SLOT_BELT,oPC);
object oHelmetOld = GetItemInSlot(INVENTORY_SLOT_HEAD,oPC);
object oShield    = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
if (GetIsObjectValid(oShield))
{
    if (GetBaseItemType(oShield) !=BASE_ITEM_LARGESHIELD &&
        GetBaseItemType(oShield) !=BASE_ITEM_SMALLSHIELD &&
        GetBaseItemType(oShield) !=BASE_ITEM_TOWERSHIELD)
    {
        oShield = OBJECT_INVALID;
    }
}

//Apply the VFX impact and effects
ClearAllActions(); // prevents an exploit
//ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoly, oPC, HoursToSeconds(nDuration));

object oWeaponNew = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
object oArmorNew = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);

if (bWeapon)
{
        IPWildShapeCopyItemProperties(oWeaponOld,oWeaponNew, TRUE);
}
if (bArmor)
{
    IPWildShapeCopyItemProperties(oShield,oArmorNew);
    IPWildShapeCopyItemProperties(oHelmetOld,oArmorNew);
    IPWildShapeCopyItemProperties(oArmorOld,oArmorNew);
}
if (bItems)
{
    IPWildShapeCopyItemProperties(oRing1Old,oArmorNew);
    IPWildShapeCopyItemProperties(oRing2Old,oArmorNew);
    IPWildShapeCopyItemProperties(oAmuletOld,oArmorNew);
    IPWildShapeCopyItemProperties(oCloakOld,oArmorNew);
    IPWildShapeCopyItemProperties(oBootsOld,oArmorNew);
    IPWildShapeCopyItemProperties(oBeltOld,oArmorNew);
}

}

I managed to solve the problem i leave the solution as a posible example

//::///////////////////////////////////////////////
//:: Wild Shape
//:: x2_s2_dinosaurshape
//:://////////////////////////////////////////////
#include “x2_inc_itemprop”

int GetHighestDeflectionValue(int iRing1AC,int iRing2AC,int iCloakAC,int iBeltAC,int iHelmetAC,int iGlovesAC)
{
int nhigh = iRing1AC;
if (iRing2AC > nhigh) nhigh = iRing2AC;
if (iCloakAC > nhigh) nhigh = iCloakAC;
if (iBeltAC > nhigh) nhigh = iBeltAC;
if (iHelmetAC > nhigh) nhigh = iHelmetAC;
if (iGlovesAC > nhigh) nhigh = iGlovesAC;

return nhigh;

}

void IPExcludeACCopyItemProperties(object oOld, object oNew, int bWeapon = FALSE)
{

if (GetIsObjectValid(oOld) && GetIsObjectValid(oNew))
{
	itemproperty ip = GetFirstItemProperty(oOld);
    while (GetIsItemPropertyValid(ip))
    {
    	if (GetItemPropertyType(ip) != ITEM_PROPERTY_AC_BONUS && GetItemPropertyType(ip) != ITEM_PROPERTY_SAVING_THROW_BONUS)
		{
			AddItemProperty(DURATION_TYPE_PERMANENT,ip,oNew);
		}
		ip = GetNextItemProperty(oOld);
    }
}

}
int IPGetArmorBonus(object oArmor, int nEnhancementBonusType = ITEM_PROPERTY_AC_BONUS)
{
itemproperty ip = GetFirstItemProperty(oArmor);
int nFound = 0;
while (nFound == 0 && GetIsItemPropertyValid(ip))
{
if (GetItemPropertyType(ip) == nEnhancementBonusType)
{
nFound = GetItemPropertyCostTableValue(ip);
}
ip = GetNextItemProperty(oArmor);
}
return nFound;
}

void main()
{
//Declare major variables
object oPC = OBJECT_SELF;
int nSpell = GetSpellId();
object oTarget = GetSpellTargetObject();
int nInt = GetAbilityScore(oTarget,3);
int nInt2 = GetAbilityScore(oTarget,3,TRUE);
int nInt3 = nInt-nInt2;
int nWis = GetAbilityScore(oTarget,4);
int nWis2 = GetAbilityScore(oTarget,4,TRUE);
int nWis3 = nWis-nWis2;
int nCha = GetAbilityScore(oTarget,5);
int nCha2 = GetAbilityScore(oTarget,5,TRUE);
int nCha3 = nCha-nCha2;
effect eInt = EffectAbilityIncrease(3,(nInt3));
effect eWis = EffectAbilityIncrease(4,(nWis3));
effect eCha = EffectAbilityIncrease(5,(nCha3));
eInt = ExtraordinaryEffect(eInt);// Don’t want it removed by a Dispel Magic until my delay loop removes it.
eWis = ExtraordinaryEffect(eWis);// Don’t want it removed by a Dispel Magic until my delay loop removes it.
eCha = ExtraordinaryEffect(eCha);// Don’t want it removed by a Dispel Magic until my delay loop removes it.
effect eVis = EffectVisualEffect(VFX_DUR_POLYMORPH);
eVis = SupernaturalEffect(eVis); // AFW-OEI 12/07/2006: Make it so you can’t dispel the visual effect, which was dispelling wildshape.
effect ePoly;
int nPoly = POLYMORPH_TYPE_COW;
int nMetaMagic = GetMetaMagicFeat();
int nDuration = GetLevelByClass(CLASS_TYPE_DRUID);
//Enter Metamagic conditions
if (nMetaMagic == METAMAGIC_EXTEND)
{
nDuration = nDuration *2; //Duration is +100%
}
nPoly = 208;
if (nDuration >= 12)
{
nPoly = 209;
}
if (nDuration >= 16)
{
nPoly = 210;
}
if (nDuration >= 18)
{
nPoly = 211;
}
if (nDuration >= 20)
{
nPoly = 212;
}
if (nDuration >= 23)
{
nPoly = 213;
}
if (nDuration >= 26)
{
nPoly = 214;
}
if (nDuration >= 30)
{
nPoly = 215;
}
ePoly = EffectPolymorph(nPoly, FALSE, TRUE); // AFW-OEI 11/27/2006: Use 3rd boolean to say this is a wildshape polymorph.
ePoly = SupernaturalEffect(ePoly);
ePoly = EffectLinkEffects( ePoly, eVis );
ePoly = SupernaturalEffect(ePoly);

//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(oPC, SPELLABILITY_WILD_SHAPE, FALSE));

int bWeapon = StringToInt(Get2DAString("polymorph","MergeW",nPoly)) == 1;
int bArmor  = StringToInt(Get2DAString("polymorph","MergeA",nPoly)) == 1;
int bItems  = StringToInt(Get2DAString("polymorph","MergeI",nPoly)) == 1;

object oWeaponOld = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
object oArmorOld = GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
object oRing1Old = GetItemInSlot(INVENTORY_SLOT_LEFTRING,oPC);
object oRing2Old = GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oPC);
object oAmuletOld = GetItemInSlot(INVENTORY_SLOT_NECK,oPC);
object oCloakOld  = GetItemInSlot(INVENTORY_SLOT_CLOAK,oPC);
object oBootsOld  = GetItemInSlot(INVENTORY_SLOT_BOOTS,oPC);
object oBeltOld = GetItemInSlot(INVENTORY_SLOT_BELT,oPC);
object oHelmetOld = GetItemInSlot(INVENTORY_SLOT_HEAD,oPC);
object oShield    = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
object oGlovesOld  = GetItemInSlot(INVENTORY_SLOT_ARMS,oPC);
if (GetIsObjectValid(oShield))
{
    if (GetBaseItemType(oShield) !=BASE_ITEM_LARGESHIELD &&
        GetBaseItemType(oShield) !=BASE_ITEM_SMALLSHIELD &&
        GetBaseItemType(oShield) !=BASE_ITEM_TOWERSHIELD)
    {
        oShield = OBJECT_INVALID;
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////
// Modified by Cuteunit 3/10/08
// Ascertain total magical item AC bonuses then apply them as effects after wildshape is applied
//////////////////////////////////////////////////////////////////////////////////////////////////
// Total up deflection AC from oRing1, oRing2, oCloak, oBelt, oHead.
// Add Armor AC from oArmor
// Add Shield AC from oShield.
// Add Natural AC from oAmulet.
// Add Dodge AC from oBoots
int iACDeflect= GetHighestDeflectionValue(IPGetArmorBonus(oRing1Old), IPGetArmorBonus(oRing2Old), IPGetArmorBonus(oCloakOld), IPGetArmorBonus(oBeltOld), IPGetArmorBonus(oHelmetOld), IPGetArmorBonus(oGlovesOld));
int iACArmor= IPGetArmorBonus(oArmorOld);
int iACShield= IPGetArmorBonus(oShield);
int iACNatural= IPGetArmorBonus(oAmuletOld);
int iACDodge= IPGetArmorBonus(oBootsOld);

//  get cumulative saving throw modifications
int iSavesBonus= IPGetArmorBonus(oRing1Old,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oRing2Old,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oCloakOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oBeltOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oHelmetOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oArmorOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oShield,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oAmuletOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oBootsOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oGlovesOld,ITEM_PROPERTY_SAVING_THROW_BONUS);
effect eSavesBonus = EffectSavingThrowIncrease(SAVING_THROW_ALL, iSavesBonus, SAVING_THROW_TYPE_ALL);
//Define final bonuses as effects 
effect eACDeflect = EffectACIncrease(iACDeflect, AC_DEFLECTION_BONUS);
effect eACArmor = EffectACIncrease(iACArmor, AC_ARMOUR_ENCHANTMENT_BONUS);
effect eACShield = EffectACIncrease(iACShield, AC_SHIELD_ENCHANTMENT_BONUS);
effect eACNatural = EffectACIncrease(iACNatural, AC_NATURAL_BONUS);
effect eACDodge = EffectACIncrease(iACDodge, AC_DODGE_BONUS);

effect eACCombined = EffectLinkEffects (eACDeflect, eACArmor);
eACCombined = EffectLinkEffects (eACShield, eACCombined);
eACCombined = EffectLinkEffects (eACNatural, eACCombined);
eACCombined = EffectLinkEffects (eACDodge, eACCombined);
ePoly = EffectLinkEffects(eACCombined, ePoly);
ePoly = EffectLinkEffects(eInt, ePoly);
ePoly = EffectLinkEffects(eWis, ePoly);
ePoly = EffectLinkEffects(eCha, ePoly);
ePoly = EffectLinkEffects(eSavesBonus, ePoly);

if (GetHasFeat(3131) == TRUE){
effect eDamage =  EffectDamageIncrease(DAMAGE_BONUS_1,DAMAGE_TYPE_DIVINE);
effect eDamageVsUndead =  EffectDamageIncrease(DAMAGE_BONUS_1d6,DAMAGE_TYPE_MAGICAL,RACIAL_TYPE_UNDEAD);
effect eDamageVsOutsiders =  EffectDamageIncrease(DAMAGE_BONUS_1d6,DAMAGE_TYPE_MAGICAL,RACIAL_TYPE_OUTSIDER);
effect eDamageCombined = EffectLinkEffects(eDamageVsUndead,eDamageVsOutsiders);
eDamageCombined = EffectLinkEffects(eDamage,eDamageCombined);
ePoly = EffectLinkEffects(eDamageCombined,ePoly);
}
if (GetHasFeat(3132) == TRUE){
	effect eSResistance = EffectSpellResistanceIncrease(nDuration+5);
	effect eDReduction;
	effect eEResistances;
	effect eProtectionsCombined;
	if(nDuration >= 12){
		eDReduction =  EffectDamageReduction(10);
	} else {
		eDReduction =  EffectDamageReduction(5);
	}
	if(GetGoodEvilValue(oPC)< 50){
		effect eCR;
		effect eFR;
		if(nDuration >= 8){
			eCR = EffectDamageResistance(DAMAGE_TYPE_COLD,5);
			eFR = EffectDamageResistance(DAMAGE_TYPE_FIRE,5);
			
		} else {
			eCR = EffectDamageResistance(DAMAGE_TYPE_COLD,10);
			eFR = EffectDamageResistance(DAMAGE_TYPE_FIRE,10);
		}
		eEResistances = EffectLinkEffects(eCR,eFR);
	} else {
		effect eCR;
		effect eER;
		effect eAR;
		if(nDuration >= 8){
			eCR = EffectDamageResistance(DAMAGE_TYPE_COLD,5);
			eER = EffectDamageResistance(DAMAGE_TYPE_ELECTRICAL,5);
			eER = EffectDamageResistance(DAMAGE_TYPE_ACID,5);
		} else {
			eCR = EffectDamageResistance(DAMAGE_TYPE_COLD,10);
			eER = EffectDamageResistance(DAMAGE_TYPE_ELECTRICAL,10);
			eER = EffectDamageResistance(DAMAGE_TYPE_ACID,10);	//ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectDamageResistance(DAMAGE_TYPE_ACID,10),oArmorNew, HoursToSeconds(nDuration));
		}
		eEResistances = EffectLinkEffects(eCR,eER);
		eEResistances = EffectLinkEffects(eAR,eEResistances);
	}
	eProtectionsCombined = EffectLinkEffects(eProtectionsCombined,eSResistance);
	eProtectionsCombined = EffectLinkEffects(eDReduction,eProtectionsCombined);
	eProtectionsCombined = EffectLinkEffects(eEResistances,eProtectionsCombined);
	ePoly = EffectLinkEffects(eProtectionsCombined,ePoly);
}
ePoly = SupernaturalEffect(ePoly);
//Apply the VFX impact and effects
ClearAllActions(); // prevents an exploit
//ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoly, oPC, HoursToSeconds(nDuration));
object oWeaponNew = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
object oArmorNew = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
SetIdentified(oWeaponNew, TRUE);
SetIdentified(oArmorNew, TRUE);

if (bWeapon)
{
        IPWildShapeCopyItemProperties(oWeaponOld,oWeaponNew, TRUE);
}
if (bArmor)
{
    IPWildShapeCopyItemProperties(oShield,oArmorNew);
    IPWildShapeCopyItemProperties(oHelmetOld,oArmorNew);
    IPWildShapeCopyItemProperties(oArmorOld,oArmorNew);
}
if (bItems)
{
    IPWildShapeCopyItemProperties(oRing1Old,oArmorNew);
    IPWildShapeCopyItemProperties(oRing2Old,oArmorNew);
    IPWildShapeCopyItemProperties(oAmuletOld,oArmorNew);
    IPWildShapeCopyItemProperties(oCloakOld,oArmorNew);
    IPWildShapeCopyItemProperties(oBootsOld,oArmorNew);
    IPWildShapeCopyItemProperties(oBeltOld,oArmorNew);
}

}

Since it’s a bit hard to read your code here in your posts, and it seems you made a lot of effort doing this, I made it a bit more readable (at least IMHO):

///////////////////////////////////////////////
//:: Wild Shape
//:: x2_s2_dinosaurshape
//:://////////////////////////////////////////////
#include "x2_inc_itemprop"

int GetHighestDeflectionValue(int iRing1AC,int iRing2AC,int iCloakAC,int iBeltAC,int iHelmetAC,int iGlovesAC)
{
int nhigh = iRing1AC;
if (iRing2AC > nhigh) nhigh = iRing2AC;
if (iCloakAC > nhigh) nhigh = iCloakAC;
if (iBeltAC > nhigh) nhigh = iBeltAC;
if (iHelmetAC > nhigh) nhigh = iHelmetAC;
if (iGlovesAC > nhigh) nhigh = iGlovesAC;

return nhigh;
}

void IPExcludeACCopyItemProperties(object oOld, object oNew, int bWeapon = FALSE)
{

	if (GetIsObjectValid(oOld) && GetIsObjectValid(oNew))
	{
	itemproperty ip = GetFirstItemProperty(oOld);
    		while (GetIsItemPropertyValid(ip))
    		{
				if (GetItemPropertyType(ip) != ITEM_PROPERTY_AC_BONUS && GetItemPropertyType(ip) != ITEM_PROPERTY_SAVING_THROW_BONUS)
				{
				AddItemProperty(DURATION_TYPE_PERMANENT,ip,oNew);
				}
			ip = GetNextItemProperty(oOld);
    		}
	}

}

int IPGetArmorBonus(object oArmor, int nEnhancementBonusType = ITEM_PROPERTY_AC_BONUS)
{
itemproperty ip = GetFirstItemProperty(oArmor);
int nFound = 0;
	while (nFound == 0 && GetIsItemPropertyValid(ip))
	{
		if (GetItemPropertyType(ip) == nEnhancementBonusType)
		{
		nFound = GetItemPropertyCostTableValue(ip);
		}
		ip = GetNextItemProperty(oArmor);
	}
return nFound;
}

void main()
{
//Declare major variables
object oPC = OBJECT_SELF;
int nSpell = GetSpellId();
object oTarget = GetSpellTargetObject();
int nInt = GetAbilityScore(oTarget,3);
int nInt2 = GetAbilityScore(oTarget,3,TRUE);
int nInt3 = nInt-nInt2;
int nWis = GetAbilityScore(oTarget,4);
int nWis2 = GetAbilityScore(oTarget,4,TRUE);
int nWis3 = nWis-nWis2;
int nCha = GetAbilityScore(oTarget,5);
int nCha2 = GetAbilityScore(oTarget,5,TRUE);
int nCha3 = nCha-nCha2;
effect eInt = EffectAbilityIncrease(3,(nInt3));
effect eWis = EffectAbilityIncrease(4,(nWis3));
effect eCha = EffectAbilityIncrease(5,(nCha3));
eInt = ExtraordinaryEffect(eInt);// Don’t want it removed by a Dispel Magic until my delay loop removes it.
eWis = ExtraordinaryEffect(eWis);// Don’t want it removed by a Dispel Magic until my delay loop removes it.
eCha = ExtraordinaryEffect(eCha);// Don’t want it removed by a Dispel Magic until my delay loop removes it.
effect eVis = EffectVisualEffect(VFX_DUR_POLYMORPH);
eVis = SupernaturalEffect(eVis); // AFW-OEI 12/07/2006: Make it so you can’t dispel the visual effect, which was dispelling wildshape.
effect ePoly;
int nPoly = POLYMORPH_TYPE_COW;
int nMetaMagic = GetMetaMagicFeat();
int nDuration = GetLevelByClass(CLASS_TYPE_DRUID);

//Enter Metamagic conditions
	if (nMetaMagic == METAMAGIC_EXTEND)
	{
	nDuration = nDuration *2; //Duration is +100%
	}
	
	nPoly = 208;
	
	if (nDuration >= 12)
	{
	nPoly = 209;
	}
	
	if (nDuration >= 16)
	{
	nPoly = 210;
	}
	
	if (nDuration >= 18)
	{
	nPoly = 211;
	}
	
	if (nDuration >= 20)
	{
	nPoly = 212;
	}
	if (nDuration >= 23)
	{
	nPoly = 213;
	}
	
	if (nDuration >= 26)
	{
	nPoly = 214;
	}
	
	if (nDuration >= 30)
	{
	nPoly = 215;
	}
	
ePoly = EffectPolymorph(nPoly, FALSE, TRUE); // AFW-OEI 11/27/2006: Use 3rd boolean to say this is a wildshape polymorph.
ePoly = SupernaturalEffect(ePoly);
ePoly = EffectLinkEffects( ePoly, eVis );
ePoly = SupernaturalEffect(ePoly);

//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(oPC, SPELLABILITY_WILD_SHAPE, FALSE));

int bWeapon = StringToInt(Get2DAString("polymorph","MergeW",nPoly)) == 1;
int bArmor  = StringToInt(Get2DAString("polymorph","MergeA",nPoly)) == 1;
int bItems  = StringToInt(Get2DAString("polymorph","MergeI",nPoly)) == 1;

object oWeaponOld = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
object oArmorOld = GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
object oRing1Old = GetItemInSlot(INVENTORY_SLOT_LEFTRING,oPC);
object oRing2Old = GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oPC);
object oAmuletOld = GetItemInSlot(INVENTORY_SLOT_NECK,oPC);
object oCloakOld  = GetItemInSlot(INVENTORY_SLOT_CLOAK,oPC);
object oBootsOld  = GetItemInSlot(INVENTORY_SLOT_BOOTS,oPC);
object oBeltOld = GetItemInSlot(INVENTORY_SLOT_BELT,oPC);
object oHelmetOld = GetItemInSlot(INVENTORY_SLOT_HEAD,oPC);
object oShield    = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
object oGlovesOld  = GetItemInSlot(INVENTORY_SLOT_ARMS,oPC);

	if (GetIsObjectValid(oShield))
	{
		if (GetBaseItemType(oShield) !=BASE_ITEM_LARGESHIELD &&
			GetBaseItemType(oShield) !=BASE_ITEM_SMALLSHIELD &&
			GetBaseItemType(oShield) !=BASE_ITEM_TOWERSHIELD)
			{
			oShield = OBJECT_INVALID;
			}
	}

//////////////////////////////////////////////////////////////////////////////////////////////////
// Modified by Cuteunit 3/10/08
// Ascertain total magical item AC bonuses then apply them as effects after wildshape is applied
//////////////////////////////////////////////////////////////////////////////////////////////////
// Total up deflection AC from oRing1, oRing2, oCloak, oBelt, oHead.
// Add Armor AC from oArmor
// Add Shield AC from oShield.
// Add Natural AC from oAmulet.
// Add Dodge AC from oBoots
int iACDeflect= GetHighestDeflectionValue(IPGetArmorBonus(oRing1Old), IPGetArmorBonus(oRing2Old), IPGetArmorBonus(oCloakOld), IPGetArmorBonus(oBeltOld), IPGetArmorBonus(oHelmetOld), IPGetArmorBonus(oGlovesOld));
int iACArmor= IPGetArmorBonus(oArmorOld);
int iACShield= IPGetArmorBonus(oShield);
int iACNatural= IPGetArmorBonus(oAmuletOld);
int iACDodge= IPGetArmorBonus(oBootsOld);

//  get cumulative saving throw modifications
int iSavesBonus= IPGetArmorBonus(oRing1Old,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oRing2Old,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oCloakOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oBeltOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oHelmetOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oArmorOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oShield,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oAmuletOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oBootsOld,ITEM_PROPERTY_SAVING_THROW_BONUS) + IPGetArmorBonus(oGlovesOld,ITEM_PROPERTY_SAVING_THROW_BONUS);
effect eSavesBonus = EffectSavingThrowIncrease(SAVING_THROW_ALL, iSavesBonus, SAVING_THROW_TYPE_ALL);
//Define final bonuses as effects 
effect eACDeflect = EffectACIncrease(iACDeflect, AC_DEFLECTION_BONUS);
effect eACArmor = EffectACIncrease(iACArmor, AC_ARMOUR_ENCHANTMENT_BONUS);
effect eACShield = EffectACIncrease(iACShield, AC_SHIELD_ENCHANTMENT_BONUS);
effect eACNatural = EffectACIncrease(iACNatural, AC_NATURAL_BONUS);
effect eACDodge = EffectACIncrease(iACDodge, AC_DODGE_BONUS);

effect eACCombined = EffectLinkEffects (eACDeflect, eACArmor);
eACCombined = EffectLinkEffects (eACShield, eACCombined);
eACCombined = EffectLinkEffects (eACNatural, eACCombined);
eACCombined = EffectLinkEffects (eACDodge, eACCombined);
ePoly = EffectLinkEffects(eACCombined, ePoly);
ePoly = EffectLinkEffects(eInt, ePoly);
ePoly = EffectLinkEffects(eWis, ePoly);
ePoly = EffectLinkEffects(eCha, ePoly);
ePoly = EffectLinkEffects(eSavesBonus, ePoly);

	if (GetHasFeat(3131) == TRUE)
	{
	effect eDamage =  EffectDamageIncrease(DAMAGE_BONUS_1,DAMAGE_TYPE_DIVINE);
	effect eDamageVsUndead =  EffectDamageIncrease(DAMAGE_BONUS_1d6,DAMAGE_TYPE_MAGICAL,RACIAL_TYPE_UNDEAD);
	effect eDamageVsOutsiders =  EffectDamageIncrease(DAMAGE_BONUS_1d6,DAMAGE_TYPE_MAGICAL,RACIAL_TYPE_OUTSIDER);
	effect eDamageCombined = EffectLinkEffects(eDamageVsUndead,eDamageVsOutsiders);
	eDamageCombined = EffectLinkEffects(eDamage,eDamageCombined);
	ePoly = EffectLinkEffects(eDamageCombined,ePoly);
	}
	
	if (GetHasFeat(3132) == TRUE)
	{
	effect eSResistance = EffectSpellResistanceIncrease(nDuration+5);
	effect eDReduction;
	effect eEResistances;
	effect eProtectionsCombined;
	
		if(nDuration >= 12)
		{
		eDReduction =  EffectDamageReduction(10);
		} 
		
		else 
		{
		eDReduction =  EffectDamageReduction(5);
		}
		
		if(GetGoodEvilValue(oPC)< 50)
		{
		effect eCR;
		effect eFR;
			if(nDuration >= 8)
			{
			eCR = EffectDamageResistance(DAMAGE_TYPE_COLD,5);
			eFR = EffectDamageResistance(DAMAGE_TYPE_FIRE,5);
			} 
			
			else 
			{
			eCR = EffectDamageResistance(DAMAGE_TYPE_COLD,10);
			eFR = EffectDamageResistance(DAMAGE_TYPE_FIRE,10);
			}
		eEResistances = EffectLinkEffects(eCR,eFR);
		} 
		
		else 
		{
		effect eCR;
		effect eER;
		effect eAR;
			if(nDuration >= 8)
			{
			eCR = EffectDamageResistance(DAMAGE_TYPE_COLD,5);
			eER = EffectDamageResistance(DAMAGE_TYPE_ELECTRICAL,5);
			eER = EffectDamageResistance(DAMAGE_TYPE_ACID,5);
			} 
			
			else 
			{
			eCR = EffectDamageResistance(DAMAGE_TYPE_COLD,10);
			eER = EffectDamageResistance(DAMAGE_TYPE_ELECTRICAL,10);
			eER = EffectDamageResistance(DAMAGE_TYPE_ACID,10);	//ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectDamageResistance(DAMAGE_TYPE_ACID,10),oArmorNew, HoursToSeconds(nDuration));
			}
		eEResistances = EffectLinkEffects(eCR,eER);
		eEResistances = EffectLinkEffects(eAR,eEResistances);
		}
		
	eProtectionsCombined = EffectLinkEffects(eProtectionsCombined,eSResistance);
	eProtectionsCombined = EffectLinkEffects(eDReduction,eProtectionsCombined);
	eProtectionsCombined = EffectLinkEffects(eEResistances,eProtectionsCombined);
	ePoly = EffectLinkEffects(eProtectionsCombined,ePoly);
	}
	
ePoly = SupernaturalEffect(ePoly);
//Apply the VFX impact and effects
ClearAllActions(); // prevents an exploit
//ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoly, oPC, HoursToSeconds(nDuration));
object oWeaponNew = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
object oArmorNew = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
SetIdentified(oWeaponNew, TRUE);
SetIdentified(oArmorNew, TRUE);

	if (bWeapon)
	{
        IPWildShapeCopyItemProperties(oWeaponOld,oWeaponNew, TRUE);
	}
	
	if (bArmor)
	{
    IPWildShapeCopyItemProperties(oShield,oArmorNew);
    IPWildShapeCopyItemProperties(oHelmetOld,oArmorNew);
    IPWildShapeCopyItemProperties(oArmorOld,oArmorNew);
	}
	
	if (bItems)
	{
    IPWildShapeCopyItemProperties(oRing1Old,oArmorNew);
    IPWildShapeCopyItemProperties(oRing2Old,oArmorNew);
    IPWildShapeCopyItemProperties(oAmuletOld,oArmorNew);
    IPWildShapeCopyItemProperties(oCloakOld,oArmorNew);
    IPWildShapeCopyItemProperties(oBootsOld,oArmorNew);
    IPWildShapeCopyItemProperties(oBeltOld,oArmorNew);
	}

}
2 Likes