Getting Base AC value
#1
Posté 21 décembre 2013 - 03:06
So what is another good way to do this?
#2
Posté 21 décembre 2013 - 03:39
Set it to unidentified, get its AC, set it back to identified.
Modifié par MagicalMaster, 21 décembre 2013 - 05:49 .
#3
Posté 21 décembre 2013 - 04:51
#4
Posté 21 décembre 2013 - 05:22
int GetArmorBaseAC(object oArmor)
{
int nAppear = GetItemAppearance(oArmor, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
return StringToInt(Get2DAString("des_crft_appear", "BaseAC", nAppear));
}
Modifié par WhiZard, 21 décembre 2013 - 05:24 .
#5
Posté 21 décembre 2013 - 05:24
#6
Posté 21 décembre 2013 - 05:26
#7
Posté 21 décembre 2013 - 05:44
Modifié par MagicalMaster, 21 décembre 2013 - 05:49 .
#8
Posté 21 décembre 2013 - 05:53
// Returns the base armor type as a number, of oItem
// -1 if invalid, or not armor, or just plain not found.
// 0 to 8 as the value of AC got from the armor - 0 for none, 8 for Full plate.
[url=http://www.nwnlexicon.com/index.php/int]int[/url] GetArmorType([url=http://www.nwnlexicon.com/index.php/object]object[/url] oItem)
{
// Make sure the item is valid and is an armor.
if (![url=http://www.nwnlexicon.com/index.php/GetIsObjectValid]GetIsObjectValid[/url](oItem))
return -1;
if ([url=http://www.nwnlexicon.com/index.php/GetBaseItemType]GetBaseItemType[/url](oItem) != BASE_ITEM_ARMOR)
return -1;
// Get the identified flag for safe keeping.
[url=http://www.nwnlexicon.com/index.php/int]int[/url] bIdentified = [url=http://www.nwnlexicon.com/index.php/GetIdentified]GetIdentified[/url](oItem);
[url=http://www.nwnlexicon.com/index.php/SetIdentified]SetIdentified[/url](oItem,FALSE);
[url=http://www.nwnlexicon.com/index.php/int]int[/url] nType = -1;
switch ([url=http://www.nwnlexicon.com/index.php/GetGoldPieceValue]GetGoldPieceValue[/url](oItem))
{
case 1: nType = 0; break; // None
case 5: nType = 1; break; // Padded
case 10: nType = 2; break; // Leather
case 15: nType = 3; break; // Studded Leather / Hide
case 100: nType = 4; break; // Chain Shirt / Scale Mail
case 150: nType = 5; break; // Chainmail / Breastplate
case 200: nType = 6; break; // Splint Mail / Banded Mail
case 600: nType = 7; break; // Half-Plate
case 1500: nType = 8; break; // Full Plate
}
// Restore the identified flag, and return armor type.
[url=http://www.nwnlexicon.com/index.php/SetIdentified]SetIdentified[/url](oItem,bIdentified);
return nType;
}
Modifié par MagicalMaster, 21 décembre 2013 - 05:54 .
#9
Posté 21 décembre 2013 - 06:03
Funky
#10
Posté 21 décembre 2013 - 06:03
I'm assuming that's the sample code he was talking about. It uses as cost check.MagicalMaster wrote...
Ah-ha! I was half right. NWNLexicon had this code:
Funky
#11
Posté 21 décembre 2013 - 06:55
#12
Posté 21 décembre 2013 - 05:34
#13
Posté 21 décembre 2013 - 07:01
const int iIndex=ITEM_APPR_ARMOR_MODEL_TORSO;
const int CATAGORY_ARMOR = 4;
const int CATAGORY_SHIELD = 3;
int GetBaseAC( object oItem)
{
int nBaseType=GetBaseItemType(oItem);
int nBaseCatagory= StringToInt(Get2DAString("baseitems", "Category",nBaseType));
int BaseAC;
switch( nBaseCatagory)
{
case CATAGORY_SHIELD:
BaseAC= StringToInt(Get2DAString("baseitems", "BaseAC",nBaseType));
break;
case CATAGORY_ARMOR:
{
int nChest = GetItemAppearance(oItem, iType, iIndex );
BaseAC= StringToInt( Get2DAString( "parts_chest","ACBONUS", nChest));
}
}
return BaseAC;
}
Modifié par Lightfoot8, 21 décembre 2013 - 07:03 .
#14
Posté 21 décembre 2013 - 07:17
WhiZard wrote...
I believe I posted this recently for Lazarus. Here is a function for getting the base AC of armor.
int GetArmorBaseAC(object oArmor)
{
int nAppear = GetItemAppearance(oArmor, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
return StringToInt(Get2DAString("des_crft_appear", "BaseAC", nAppear));
}
Why "des_crft_appear" ? The Item format lists "parts_chest" as being the place to look.
P.S. Really wish I would have seen your code before figuring it all out myself again.
#15
Posté 21 décembre 2013 - 08:41
#16
Posté 22 décembre 2013 - 03:24
Lightfoot8 wrote...
Why "des_crft_appear" ? The Item format lists "parts_chest" as being the place to look.
Both work. des_crft_appear is used in looping through the armor torsos when modifying armor (so as not to change the Base AC).
@henesua I did go via the torso, in fact Lightfoot's method is almost identical to my own.
Modifié par WhiZard, 22 décembre 2013 - 03:25 .
#17
Posté 22 décembre 2013 - 03:41
#18
Posté 22 décembre 2013 - 04:09
#19
Posté 31 décembre 2013 - 07:50
object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC); //Or however you are getting the armor item
int baseAC = GetItemACValue(oArmor) - IPGetWeaponEnhancementBonus(oArmor, ITEM_PROPERTY_AC_BONUS);
Hope that helps!
Cheers,
Khuzadrepa
Modifié par Khuzadrepa, 31 décembre 2013 - 08:01 .
#20
Posté 31 décembre 2013 - 08:57
Khuzadrepa wrote...
Not sure if this is similar to what MagicalMaster posted earlier since he removed it, but this is an OLD trick that I am quite certain works:
object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC); //Or however you are getting the armor item
int baseAC = GetItemACValue(oArmor) - IPGetWeaponEnhancementBonus(oArmor, ITEM_PROPERTY_AC_BONUS);
Hope that helps!
Cheers,
Khuzadrepa
For anyone wanting to use this: IPGetWeaponEnhancementBonus is located in x2_inc_itemprop
Modifié par Lightfoot8, 31 décembre 2013 - 09:00 .





Retour en haut







