Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Getting a Weapon's Base Damage Type and apply a similar bonus

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:
	 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);

Comments

  • ProlericProleric Member Posts: 863
    GetDamageDealtByType is a function for the OnDamaged event only.

    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.

  • CalgacusCalgacus Member Posts: 272
    edited November 2020
    I think the GetDamageDealtByType will only work when fired in an onDamaged event - meaning you can't use it in an onActivated type script. You need to look up the weapon type in the basetiems.2da and find the damage type in there or just script it all up and base it off the base_item_type. eg
    // * 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;
    }

  • FreshLemonBunFreshLemonBun Member Posts: 906
    Also be aware that you are using the incorrect constants, as itemproperties usually always have their own set of constants you will need to map them correctly. So even if damage were to be processed hypothetically in an ondamage event and then award some temporary item property it needs to set the correct value by using the correct constants.

    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

  • QuilistanQuilistan Member Posts: 110
    Thanks Everyone!

    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....

  • FreshLemonBunFreshLemonBun Member Posts: 906
    A 2da lookup with Get2DAString isn't too complicated.

    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:
    object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND);
    int nRow = GetBaseItemType(oItem);
    string sFileName = "baseitems";
    string sColumn = "WeaponType";
    string sField = Get2DAString(sFileName, sColumn, nRow);
    int nDamageType = StringToInt(sField);
    

    Then you map that damage type to the itemproperty constant for damage type.

  • QuilistanQuilistan Member Posts: 110
    Cool! Thanks for explaining that

Sign In or Register to comment.