Battledale_PRC8/_module/nss/jw_fp_armrit_new.nss
Jaysyn904 7b9e44ebbb Initial upload
Initial upload.  PRC8 has been added.  Module compiles, PRC's default AI & treasure scripts have been integrated.  Started work on top hak for SLA / Ability / Scripting modifications.
2024-03-11 23:44:08 -04:00

238 lines
6.7 KiB
Plaintext

#include "prc_x2_itemprop"
// * Returns total AC bonus for the item
int ReturnACBonus(object oItem);
void main()
{
object oPC = GetPCSpeaker();
object oAnvil = GetNearestObjectByTag("NK_FP_ANVIL", OBJECT_SELF, 1);
object oArmor = GetFirstItemInInventory(oAnvil);
itemproperty iTest;
string sPedestalTag;
int i;
int nRightItemCount = 0;
int nRightItemCount2 = 0;
int nRightItemCount3 = 0;
//check pedestals
for (i = 1; i <= 8; i++)
{
sPedestalTag = "NK_FP_PEDESTAL0" + IntToString(i);
if (GetLocalInt(oAnvil, sPedestalTag) == 1)
{
nRightItemCount++;
}
else if (GetLocalInt(oAnvil, sPedestalTag) == 2)
{
nRightItemCount2++;
}
else if (GetLocalInt(oAnvil, sPedestalTag) == 3)
{
nRightItemCount3++;
}
}
//check anvil
// is it armour?
if (GetBaseItemType(oArmor)!=BASE_ITEM_ARMOR)
{
SendMessageToPC(oPC, "You do not appear to have placed a piece of armour into the anvil.");
return;
}
else
{
nRightItemCount++;
nRightItemCount2++;
nRightItemCount3++;
}
// Start off by assuming no enhancements
int nEnhancement=ReturnACBonus(oArmor);
/* if (nEnhancement==1)
{
SendMessageToPC(oPC, "DEBUG this is +1 armour.");
}
if (nEnhancement==2)
{
SendMessageToPC(oPC, "DEBUG this is +2 armour.");
}
if (nEnhancement==3)
{
SendMessageToPC(oPC, "DEBUG this is +3 armour.");
}
*/
//Send error message if needed
if (nEnhancement>=3)
{
SendMessageToPC(oPC,"You cannot enchant your armour any more at this altar");
return;
}
else if (nRightItemCount >= 8 && nEnhancement>=1)
{
SendMessageToPC(oPC,"You cannot enchant your armour any more using those gems");
return;
}
else if (nRightItemCount2 >= 8 && nEnhancement>=2)
{
SendMessageToPC(oPC,"You cannot enchant your armour any more using those gems");
return;
}
//check brazier
int nClass1 = GetClassByPosition(1, oPC);
int nClass2 = GetClassByPosition(2, oPC);
int nClass3 = GetClassByPosition(3, oPC);
string sClass1Num;
string sClass2Num;
string sClass3Num;
if (nClass2 == CLASS_TYPE_INVALID)
{
nClass2 = nClass1;
}
if (nClass3 == CLASS_TYPE_INVALID)
{
nClass3 = nClass1;
}
nClass1 = nClass1 + 1;
nClass2 = nClass2 + 1;
nClass3 = nClass3 + 1;
if (nClass1 < 10)
{
sClass1Num = "0"+IntToString(nClass1);
}
else
{
sClass1Num = IntToString(nClass1);
}
if (nClass2 < 10)
{
sClass2Num = "0"+IntToString(nClass2);
}
else
{
sClass2Num = IntToString(nClass2);
}
if (nClass3 < 10)
{
sClass3Num = "0"+IntToString(nClass3);
}
else
{
sClass3Num = IntToString(nClass3);
}
string sTag1 = "NK_FP_STONE" + sClass1Num;
string sTag2 = "NK_FP_STONE" + sClass2Num;
string sTag3 = "NK_FP_STONE" + sClass3Num;
string sStoneTag = GetLocalString(oAnvil, "STONE");
if ((sStoneTag == sTag1) || (sStoneTag == sTag2) || (sStoneTag == sTag3))
{
nRightItemCount++;
nRightItemCount2++;
nRightItemCount3++;
}
//pray
AssignCommand(oPC, ActionSpeakString("*prays*", TALKVOLUME_TALK));
AssignCommand(oPC, ActionPlayAnimation( ANIMATION_LOOPING_WORSHIP, 1.0, 20.0));
//all items placed correctly
if ((nRightItemCount == 10) || (nRightItemCount2 == 10) || (nRightItemCount3 == 10))
{
//destroy items
object oPedestal;
object oBrazier = GetNearestObjectByTag("NK_FP_BRAZIER", OBJECT_SELF, 1);
int m;
//DestroyObject(GetFirstItemInInventory(oAnvil), 0.0);
DestroyObject(GetFirstItemInInventory(oBrazier), 0.0);
for (m = 1; m <= 8; m++)
{
sPedestalTag = "NK_FP_PEDESTAL0" + IntToString(m);
oPedestal= GetNearestObjectByTag(sPedestalTag, OBJECT_SELF, 1);
DestroyObject(GetFirstItemInInventory(oPedestal), 0.0);
}
//create armor
if (nRightItemCount == 10)
{
// +1
iTest=ItemPropertyACBonus(1);
IPSafeAddItemProperty(oArmor,iTest,0.0);
}
else if (nRightItemCount2 == 10)
{
iTest=ItemPropertyACBonus(2);
IPSafeAddItemProperty(oArmor,iTest,0.0);
}
else if (nRightItemCount3 == 10)
{
iTest=ItemPropertyACBonus(3);
IPSafeAddItemProperty(oArmor,iTest,0.0);
}
//visual effects
int n;
float fBeamDuration = 15.0;
float fBeamDelay = 3.0;
effect eBeam = EffectBeam(VFX_BEAM_HOLY, OBJECT_SELF, BODY_NODE_HAND, FALSE);
effect eBeam2 = EffectBeam(VFX_BEAM_FIRE_LASH, OBJECT_SELF, BODY_NODE_HAND, FALSE);
effect eStrike = EffectVisualEffect(VFX_IMP_SUPER_HEROISM);
effect eShake = EffectVisualEffect(VFX_FNF_SCREEN_SHAKE);
for (n = 1; n <= 8; n++)
{
sPedestalTag = "NK_FP_PEDESTAL0" + IntToString(n);
oPedestal= GetNearestObjectByTag(sPedestalTag, OBJECT_SELF, 1);
DelayCommand(fBeamDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oPedestal, fBeamDuration));
fBeamDelay = fBeamDelay + (IntToFloat(n) / 10);
fBeamDuration = fBeamDuration - (IntToFloat(n) / 10);
}
DelayCommand(fBeamDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam2, oAnvil, fBeamDuration));
DelayCommand((fBeamDuration + fBeamDelay - 1.0), ApplyEffectToObject(DURATION_TYPE_INSTANT, eShake, oAnvil));
DelayCommand((fBeamDuration + fBeamDelay + 0.5), ApplyEffectToObject(DURATION_TYPE_INSTANT, eStrike, oAnvil));
}
}
// * Returns total AC bonus for the item
int ReturnACBonus(object oItem)
{
itemproperty ipFirst = GetFirstItemProperty(oItem);
int nBonus = 0;
while (GetIsItemPropertyValid(ipFirst) == TRUE)
{
if (GetItemPropertyType(ipFirst) == ITEM_PROPERTY_AC_BONUS)
{
int nSubType = GetItemPropertyCostTableValue(ipFirst);
//SpeakString("Found an attack bonus! SubType = " + IntToString(nSubType));
nBonus = nBonus + (nSubType);
return nBonus; // * Quick exit. Got what I need
}
ipFirst = GetNextItemProperty(oItem);
}
//SpeakString("Attack Bonus = " + IntToString(nBonus));
return nBonus;
}