#include "jw_smith_copy" // Put the right enchantment on the armour - returns FALSE if enchantment failed // The PC is the PC who used the statue - this is so we can send him a message // if needed. The heart is the type of heart used - blue heart is 1, red heart is 2 // green heart is 3 // int nEnchantArmour(object oEquip, object oPC, int nHeart); // Put the right enchantment on the melee weapons - returns FALSE if enchantment failed // The PC is the PC who used the statue - this is so we can send him a message // if needed. The heart is the type of heart used - blue heart is 1, red heart is 2 // green heart is 3 // int nEnchantMelee(object oEquip, object oPC, int nHeart); // Put the right enchantment on the ranged weapons - returns FALSE if enchantment failed // The PC is the PC who used the statue - this is so we can send him a message // if needed. The heart is the type of heart used - blue heart is 1, red heart is 2 // green heart is 3 // int nEnchantRanged(object oEquip, object oPC, int nHeart); // Check the item for temporary effects and remove those effects if they exist void RemoveTempEffects (object oEquip); void main() { object oPC=GetPCSpeaker(); AssignCommand(oPC,ClearAllActions()); AssignCommand(oPC,PlayAnimation(ANIMATION_LOOPING_WORSHIP,0.5,180.0)); if (!GetIsObjectValid(GetItemPossessedBy(oPC,"jw_new_note"))) { SendMessageToPC(oPC,"You do not know the words to say"); return; } SendMessageToPC(oPC,"You read the words on the script given to you by the old man in Brighthaven"); AssignCommand(oPC,SpeakString("Discuss ideas and spread them, so that all may see the divine light that is the Wonderbringer")); object oAnvil=GetObjectByTag("jw_andros_anvil"); object oDiamond=GetItemPossessedBy(oAnvil,"jw_huge_dia"); if (!GetIsObjectValid(oDiamond)) { SendMessageToPC(oPC,"Nothing happens - something seems to be missing"); return; } object oHeart=GetItemPossessedBy(oAnvil,"jw_blue_heart"); int nHeart=1; if (!GetIsObjectValid(oHeart)) { oHeart=GetItemPossessedBy(oAnvil,"jw_red_heart"); nHeart=2; } if (!GetIsObjectValid(oHeart)) { oHeart=GetItemPossessedBy(oAnvil,"jw_green_heart"); nHeart=3; } if (!GetIsObjectValid(oHeart)) { SendMessageToPC(oPC,"Nothing happens - something seems to be missing"); return; } // oEquip is the armour or weapon we are looking for object oEquip; object oCycle=GetFirstItemInInventory(oAnvil); int nEquipValid=FALSE; int nBaseItemType; // cycle through the items in the anvil until we find a weapon or armour while (GetIsObjectValid(oCycle)&&nEquipValid==FALSE) { //SendMessageToPC(oPC,"DEBUG - we are looking at this to see if it is valid: "+GetName(oCycle)); nBaseItemType=GetBaseItemType(oCycle); if ((nBaseItemType==BASE_ITEM_ARMOR)||(IPGetIsMeleeWeapon(oCycle))||(IPGetIsRangedWeapon(oCycle))) { //SendMessageToPC(oPC,"DEBUG - we have determined that this is valid: "+GetName(oCycle)); nEquipValid=TRUE; oEquip=oCycle; } else { //SendMessageToPC(oPC,"DEBUG - we think this is NOT valid: "+GetName(oCycle)); } oCycle=GetNextItemInInventory(oAnvil); } if (!GetIsObjectValid(oEquip)) { SendMessageToPC(oPC,"Nothing happens - something seems to be missing"); return; } // DEBUG else { //SendMessageToPC(oPC,"DEBUG - we are going to try to bless "+GetName(oEquip)); } // First of all, remove any temporary effects the item may have RemoveTempEffects(oEquip); int nSuccess=FALSE; // Do the relevant check here if (nBaseItemType==BASE_ITEM_ARMOR) { nSuccess=nEnchantArmour(oEquip,oPC,nHeart); } else if (IPGetIsMeleeWeapon(oEquip)) { nSuccess=nEnchantMelee(oEquip,oPC,nHeart); } else if (IPGetIsRangedWeapon(oEquip)) { nSuccess=nEnchantRanged(oEquip,oPC,nHeart); } // If we have done our enchantments succesfully then we destroy the heart and diamond // and do the special effects if (nSuccess==TRUE) { DestroyObject(oHeart); DestroyObject(oDiamond); DelayCommand(0.3,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_DUR_PROTECTION_GOOD_MAJOR),oAnvil,20.0)); DelayCommand(1.5,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_SCREEN_SHAKE),oAnvil,10.0)); DelayCommand(1.5,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_SUNBEAM),oAnvil,10.0)); } } int nEnchantArmour(object oEquip, object oPC, int nHeart) { itemproperty iAdd; // only armour with at least +1 enhancement can be blessed int nEnhancement=ReturnACBonus(oEquip); if (nEnhancement<1) { SendMessageToPC(oPC, "Your armour or robe must have at least a +1 AC bonus to be blessed in this shrine."); // NOTE - WE RETURN HERE return FALSE; } // We will return false, unless we manage to give the item something int nSuccess=FALSE; // we are checking for ability increases if (GetHasItemProperty(oEquip,ITEM_PROPERTY_ABILITY_BONUS)) { SendMessageToPC(oPC,"This item of armour already gives an ability bonus and cannot give two"); } else if (nHeart==1) { iAdd=ItemPropertyAbilityBonus(ABILITY_CONSTITUTION,1); IPSafeAddItemProperty(oEquip,iAdd,0.0); nSuccess=TRUE; } else if (nHeart==2) { iAdd=ItemPropertyAbilityBonus(ABILITY_DEXTERITY,1); IPSafeAddItemProperty(oEquip,iAdd,0.0); nSuccess=TRUE; } else if (nHeart==3) { iAdd=ItemPropertyAbilityBonus(ABILITY_STRENGTH,1); IPSafeAddItemProperty(oEquip,iAdd,0.0); nSuccess=TRUE; } // add the DR iAdd=ItemPropertyDamageReduction(IP_CONST_DAMAGEREDUCTION_2,IP_CONST_DAMAGESOAK_10_HP); if (IPGetItemHasProperty(oEquip,iAdd,-1)) { SendMessageToPC(oPC,"This item of armour already has the highest level of damage reduction this shrine can give it."); } else { //SendMessageToPC(oPC,"DEBUG - damage reduction OK to go."); IPSafeAddItemProperty(oEquip,iAdd,0.0,X2_IP_ADDPROP_POLICY_REPLACE_EXISTING,FALSE,TRUE); nSuccess=TRUE; } return nSuccess; } int nEnchantMelee(object oEquip, object oPC, int nHeart) { // We will return false, unless we manage to give the item something int nSuccess=FALSE; // we do not bless mage staffs if (GetBaseItemType(oEquip)==BASE_ITEM_MAGICSTAFF) { SendMessageToPC(oPC, "This shrine cannot bless your mage's staff."); return FALSE; } itemproperty iAdd; // Do the +2 enhancement int nEnhancement=IPGetWeaponEnhancementBonus(oEquip); if (nEnhancement>1) { SendMessageToPC(oPC, "This shrine cannot give your weapon a higher enhancement rating more than it is already. However it may be able to give a damage bonus."); } else if (nEnhancement<1) { SendMessageToPC(oPC, "Your melee weapon must have at least a +1 enhancement to be blessed in this shrine."); // NOTE - WE RETURN HERE return FALSE; } else { IPSetWeaponEnhancementBonus(oEquip,2); nSuccess=TRUE; } // we are checking for any elemental damage if (GetHasItemProperty(oEquip,ITEM_PROPERTY_DAMAGE_BONUS)) { SendMessageToPC(oPC,"This weapon already has a damage bonus and cannot have two."); } else if (nHeart==1) { iAdd=ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_ELECTRICAL,IP_CONST_DAMAGEBONUS_1d4); IPSafeAddItemProperty(oEquip,iAdd,0.0); nSuccess=TRUE; } else if (nHeart==2) { iAdd=ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE,IP_CONST_DAMAGEBONUS_1d4); IPSafeAddItemProperty(oEquip,iAdd,0.0); nSuccess=TRUE; } else if (nHeart==3) { iAdd=ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_ACID,IP_CONST_DAMAGEBONUS_1d4); IPSafeAddItemProperty(oEquip,iAdd,0.0); nSuccess=TRUE; } // That's not all, because if we have been succesful so far and we are blessing a whip, // we get even more toys!! if ((nSuccess==TRUE)&&(GetBaseItemType(oEquip)==BASE_ITEM_WHIP)) { iAdd=ItemPropertyOnHitProps(IP_CONST_ONHIT_STUN,IP_CONST_ONHIT_SAVEDC_16,IP_CONST_ONHIT_DURATION_75_PERCENT_1_ROUND); IPSafeAddItemProperty(oEquip,iAdd,0.0); } return nSuccess; } int nEnchantRanged(object oEquip, object oPC, int nHeart) { itemproperty iAdd; // We will return false, unless we manage to give the item something int nSuccess=FALSE; // Check if the item is magical already int nEnhancement=ReturnAttackBonus(oEquip); // if it hasn't been done in the +1 shrine yet, we cannot do it here if (nEnhancement<1) { SendMessageToPC(oPC, "Your ranged weapon must have at least a +1 attack bonus to be blessed in this shrine."); // NOTE - WE RETURN HERE return FALSE; } // if it already has an attack bonus of +2 or more, it cannot be blessed here // if it hasn't been done in the +1 shrine yet, we cannot do it here if (nEnhancement>=2) { SendMessageToPC(oPC, "This shrine cannot enchant your ranged weapon any more than it is already."); // NOTE - WE RETURN HERE return FALSE; } // ok, now we should be okay to go if (nHeart==1) { iAdd=ItemPropertyAttackBonus(2); IPSafeAddItemProperty(oEquip,iAdd,0.0); // Now give it freedom of movement iAdd=ItemPropertyFreeAction(); IPSafeAddItemProperty(oEquip,iAdd,0.0); nSuccess=TRUE; } else if (nHeart==2) { // just give it a +3 attack bonus iAdd=ItemPropertyAttackBonus(3); IPSafeAddItemProperty(oEquip,iAdd,0.0); nSuccess=TRUE; } else if (nHeart==3) { // Give it attack bonus +2 iAdd=ItemPropertyAttackBonus(2); IPSafeAddItemProperty(oEquip,iAdd,0.0); // Now give it cat's grace iAdd=ItemPropertyCastSpell(IP_CONST_CASTSPELL_CATS_GRACE_15,IP_CONST_CASTSPELL_NUMUSES_1_USE_PER_DAY); IPSafeAddItemProperty(oEquip,iAdd,0.0); nSuccess=TRUE; } // Not finished yet, because if everything has worked so far and the bow is mighty, we will // make it VERY mighty if (nSuccess==TRUE) { iAdd=ItemPropertyMaxRangeStrengthMod(5); IPSafeAddItemProperty(oEquip,iAdd,0.0); } return nSuccess; } // Check the item for temporary effects and remove those effects if they exist void RemoveTempEffects (object oEquip) { itemproperty oProperty; object oItem=oEquip; oProperty=GetFirstItemProperty(oItem); while (GetIsItemPropertyValid(oProperty)) { if(GetItemPropertyDurationType(oProperty)==DURATION_TYPE_TEMPORARY) { RemoveItemProperty(oItem,oProperty); } oProperty=GetNextItemProperty(oItem); } }