Getting a Weapon's Base Damage Type and apply a similar bonus
Quilistan
Member Posts: 186
I am trying to apply a racial damage bonus to an item and I want the damage type to be the same as the base item damage. Everything so far has only returned Bludgeoning as the damage type when testing........
I have tried:
if (GetDamageDealtByType(DAMAGE_TYPE_SLASHING >= 1)
{
nDamage = DAMAGE_TYPE_SLASHING;
}
I also tried:
I have tried:
if (GetDamageDealtByType(DAMAGE_TYPE_SLASHING >= 1)
{
nDamage = DAMAGE_TYPE_SLASHING;
}
I also tried:
int nDamage; if (GetDamageDealtByType(DAMAGE_TYPE_BASE_WEAPON) == DAMAGE_TYPE_SLASHING) { nDamage = DAMAGE_TYPE_SLASHING; } if (GetDamageDealtByType(DAMAGE_TYPE_BASE_WEAPON) == DAMAGE_TYPE_BLUDGEONING) { nDamage = DAMAGE_TYPE_BLUDGEONING; } if (GetDamageDealtByType(DAMAGE_TYPE_BASE_WEAPON) == DAMAGE_TYPE_PIERCING) { nDamage = DAMAGE_TYPE_PIERCING; } // Check for equiped weapon oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC); if(GetIsObjectValid(oWeapon) ) { // Abort if a skill check (craft weapon) is failed. if ( GetIsSkillSuccessful(oPC, SKILL_CRAFT_WEAPON, 20) ) { //Add Racial Damage Bonus Property switch (d6(1)) { case 1: ipAdd = ItemPropertyDamageBonusVsRace(IP_CONST_RACIALTYPE_HUMANOID_REPTILIAN, nDamage, IP_CONST_DAMAGEBONUS_1d4); break; case 2: ipAdd = ItemPropertyDamageBonusVsRace(IP_CONST_RACIALTYPE_HUMANOID_GOBLINOID, nDamage, IP_CONST_DAMAGEBONUS_1d4); break; case 3: ipAdd = ItemPropertyDamageBonusVsRace(IP_CONST_RACIALTYPE_HUMANOID_ORC, nDamage, IP_CONST_DAMAGEBONUS_1d4); break; case 4: ipAdd = ItemPropertyDamageBonusVsRace(IP_CONST_RACIALTYPE_UNDEAD, nDamage, IP_CONST_DAMAGEBONUS_1d4); break; case 5: ipAdd = ItemPropertyDamageBonusVsRace(IP_CONST_RACIALTYPE_VERMIN, nDamage, IP_CONST_DAMAGEBONUS_1d4); break; case 6: ipAdd = ItemPropertyDamageBonusVsRace(IP_CONST_RACIALTYPE_SHAPECHANGER, nDamage, IP_CONST_DAMAGEBONUS_1d4); break; default: break; } IPSafeAddItemProperty(oWeapon, ipAdd);
0
Comments
More generally, you can use Get2DAString on baseitems.2da to look up WeaponType for the base item type in question. The codes returned are different - 1 = piercing; 2 = bludgeoning; 3 = slashing; 4 = piercing-slashing; 5 = bludgeoning-piercing.
// * return TRUE if baseType is a bludgeoning melee weapon
// * FALSE if else
int isBludWeapon(int baseType){
if( baseType == BASE_ITEM_DIREMACE ||
baseType == BASE_ITEM_HEAVYFLAIL ||
baseType == BASE_ITEM_LIGHTFLAIL ||
baseType == BASE_ITEM_LIGHTHAMMER ||
baseType == BASE_ITEM_LIGHTMACE ||
baseType == BASE_ITEM_MORNINGSTAR ||
baseType == BASE_ITEM_WARHAMMER
){
return TRUE;
}
return FALSE;
}
DAMAGE_TYPE_BLUDGEONING = 1
DAMAGE_TYPE_PIERCING = 2
DAMAGE_TYPE_SLASHING = 4
IP_CONST_DAMAGETYPE_BLUDGEONING = 0
IP_CONST_DAMAGETYPE_PIERCING = 1
IP_CONST_DAMAGETYPE_SLASHING = 2
This script is in the OnDamaged event of a placeable.
I ended up making an #include that tests for slashing, bludgeoning, or pierce in the manner that Calgacus mentions (I knew there was a slashing test is x2_i0_spells), and then made sure my constants were correct like FreshLemonBun mentioned.
I just thought there would have been a simpler or more direct way.
Proleric I will have to learn a bit more about the 2da look up....
In this case you know which 2da you want to check "baseitems" is the 2da you want.
You also know which column you want "WeaponType" which was suggested in the post above.
Lastly you can use the function GetBaseItemType(oItem) to get the constant id for the item. In this case oItem would be the weapon that is equipped.
The value you expect will be an int, the number Proleric indicated.
Put it all together and it will look something like this, excusing typos or minor differences:
Then you map that damage type to the itemproperty constant for damage type.