Breakable Weapons

Posted a demo. Hope it works - Haven’t had a chance to modify it

1 Like

I posted my demo module. The widget item should be there under “Plot Items”. The widget goes into your PC quick slot. ANY long item - staff, pole, etc. - can be wielded. When near the trap, use the widget and it will use the long item to prod the trap.


Awesome…can’t wait to try it later today :slight_smile: Thanks.

Tested …it works !!..great job! But I thought initially too that it could destroy your item it is prodding the trap with on a failed saving throw and injure the person prodding the trap on that fail. Was I wrong in thinking that it could do that too? When I tested it…nothing broke. On the last trap I could not set off the trap. It doesn’t show any rolls done to demonstrate if I was failing for example. I tried about 15 times never could set off that trap. So I don’t know by the lack of showing rolls how I was faring.

If the staff was taking damage you would be getting feedback about the damage. If it was the magical staff, it resists the damage. I guess you could up the damage on the traps to see if the staff would break or not. When I tested it, my staff broke usually by the last chest.
But you are right, I don’t think the math is shown - I could work that in.

1 Like

I love this whole concept. True to the PNP D&D. Yeah that would be great to see the math. Also, some sort of comment to say your “weapon” is about to break or is broken. Thanks Mannast!

1 Like

Here is the script"staff_end_dam" edited to give feedback - paste it over the one in the toolset and save away

    //"staff_end_dam"  OnDamaged script for the "End of <staff>" tag "staff_end"
    //for the Staff Trigger system v.0.3 by Mannast 9/5/2016
    //Tracks damage made to the staff end creature on the staff object
    //if the staff takes too much damage, the staff is destroyed and the excess damage passed along to the PC
    #include "x2_i0_spells"
    void main()
    int nDamage = GetTotalDamageDealt();
    int nType = GetDamageDealtByType(nDamage);
    object oStaff = GetLocalObject(OBJECT_SELF, "Staff");
    object oPC = GetItemPossessor(oStaff);
    string sMessage = "The trap deals out "+IntToString(nDamage)+" when you prod it!";
    SendMessageToPC(oPC, sMessage);
        SendMessageToPC(oPC, "Your "+GetName(oStaff)+" resists the damage!");
        //magical prods are not damaged
    //Otherwise, we damage the staff and track it on the object
    int nDam = GetLocalInt(oStaff, "ProdDam")+nDamage;
    int nProdDamMax = GetLocalInt(GetModule(), "ProdDamMax");
    if(nProdDamMax==0) nProdDamMax = 20;
    if(nDam>=nProdDamMax)//If the damage is more than the max, the object is destroyed
        SendMessageToPC(oPC, "Your "+GetName(oStaff)+" can't take the damage and explodes in your hands!");
        DestroyObject(oStaff, 0.1);
        int nPCDam = nDam-nProdDamMax;//We will apply the excess damage to the holding PC...
        effect eDam = EffectDamage(nPCDam, nType);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oPC);
    //if not destroyed, we save the damage amount back to the object
    SetLocalInt(oStaff, "ProdDam", nDam);
    string sRemain = IntToString(nProdDamMax-nDam);
    SendMessageToPC(oPC, "Your "+GetName(oStaff)+" was damaged by the trap!  It can only take "+sRemain+" more damage");
    string sName = GetName(oStaff);
    string sOName = GetLocalString(oStaff, "Name");
    if(sOName=="") SetLocalString(oStaff, "Name", sName);
    else sName = sOName;
    SetName(oStaff, "Damaged "+sName);

Awesome!..going to try this out…thanks!!

Tested it…much better :slight_smile:)

But I thought you would include a dice roll to see by how much it saved by. And I wonder…how much damage can the prodding weapon take before it breaks?

So further testing I tried it on a deadly Spike trap. It disarmed it with a non-magical staff in hand it caused the staff 76 points of damage…nothing happened to PC…

All the math is in the script above, except for the attack of the trap against the “end of the staff” which calls the above script. I’ve noticed in testing that it is not always causes damage, even though I reduced the saving throws for the staff end, I think it still saves against damage every so often. In your example, I am not sure why the normal staff did not get destroyed and you receive the other 50+ - it defaults to 20 hits per item.
While reviewing this post, it occurred to me that the traps may kill the staff end outright, which may cause it to vanish before this script runs properly - I suppose it could be in both the OnDamage of the staff end and maybe OnDeath - I will look at it.

Thanks Mannast,

I really appreciate you doing this. I can’t wait to implement this into my module when it is done. :slight_smile:

1 Like

Hi Mannast,

Sorry to bother you - but are you still going to do that?

Sorry - my rl job has me working from home now - which is great, but also has seriously cut into my recently new-found NWN time. I will see what I can do today, though

NP Mannast…but thanks if you can

Okay - this playtested ok for me. Put in the OnDamage slot of the placeable you want to check.

//"weapon_chk" OnDamage script for plaeables
//Checks if weapon used to damage was of an approved type or not.  If not
//it then damages the weapon (with save)
//by Mannast May 2020
#include "x2_i0_spells"

//DoDamage takes the oItem and the nDamage and runs the saving throw.  It will then return the damage amount
//which is dealt to the item in the void main()
int DoDamage(object oItem, int nDamage)
object oPC = GetItemPossessor(oItem);
int nDC = 10;//This is the base saving throw
int nSavMod;
int nSave;
string sItem = GetName(oItem);
//Set up saving throw for item targeted
    if(GetIsMagicalItem(oItem)) nSavMod = nSavMod+5;//Is the item magical?  If so, +5
    if(GetIsItemPropertyValid(GetFirstItemProperty(oItem))!=FALSE) nSavMod = nSavMod+5;//Does it have at least one property?  +5
//Do the saving throw
    int nPlot=GetLocalInt(oItem, "Plot");
    if(nPlot!=1)  nSave = d20(1);
    float fDelay2 = 0.3;
    SendMessageToPC(oPC, "Weapon Saving Throw d20 "+IntToString(nSave)+" + Bonus "+IntToString(nSavMod)+" = "
            +IntToString(nSave+nSavMod)+" against a DC of "+IntToString(nDC));
           SendMessageToPC(oPC, "You damage your "+sItem+"!  It takes "+IntToString(nDamage)+"!");
           DelayCommand(fDelay2, FloatingTextStringOnCreature("The "+sItem+" has resisted the damage.", OBJECT_SELF));
          nDamage = 0;//or could make this 1/2 if you prefer
    return nDamage;

//MAIN script
void main()
object oPC = GetLastDamager();
object oItem = GetLastWeaponUsed(oPC);
int nType = GetBaseItemType(oItem);
int nDam = GetTotalDamageDealt();//Total Damage Dealt - this is apparently after Damage Reduction
int nItemHP = GetLocalInt(oItem, "ItemHP");
if(nItemHP<=0)//If oItem has not been damaged before or if it hsn't been set.
    nItemHP = GetLocalInt(GetModule(), "BASE_ITEM_HP");//can set this on the module
    if(nItemHP==0) nItemHP = 20;//Base HP - to have a higher amount for specific items, set var int "Damaged" to desired number on item
    if(GetIsMagicalItem(oItem)) nItemHP = nItemHP+5;//Is the item magical?  If so, +5
    if(GetIsItemPropertyValid(GetFirstItemProperty(oItem))!=FALSE) nItemHP = nItemHP+5;//Does it have at least one property?  +5
    nType==BASE_ITEM_DIREMACE||nType==BASE_ITEM_CLUB)//Edit these as you see fit - these were all the blunt objects I could find
    //SendMessageToPC(oPC, "Your weapon is doin' fine! Base Type = "+IntToString(nType));//Debug
    return;//This damage is okay
else//All other types
    int nHits = nDam;
    int nDone = DoDamage(oItem, nHits);
    nItemHP = nItemHP-nDone;
    if(nItemHP<=0)//If item reaches zero at this point, it is destroyed
        SendMessageToPC(oPC, "Your weapon is destroyed!");
        //We could create a broken item here, but the PC would likely through it out - why do it then?
        //Rename item to show it is damaged - also give (hp) info to show how it is doing.
        string sDam = "Damaged ";
        int nMin = 5;//Set this to where you want the PC informed their item is about to be destroyed
            SendMessageToPC(oPC, "Your weapon is heavily damaged and won't take much more!");
            sDam = "Heavily Damaged ";
        SetLocalInt(oItem, "ItemHP", nItemHP);//Put the new hps on the item
        string sName = GetName(oItem);
        string sOName = GetLocalString(oItem, "Name");
        if(sOName=="") SetLocalString(oItem, "Name", sName);
        else sName = sOName;
        SetName(oItem, sDam+sName+" ("+IntToString(nItemHP)+" hps)");//Rename the damaged item

Let me know if you got any questions - enjoy!

Thanks Mannast for this weapon breakable script :slight_smile:

I was speaking to the Staff probing script where it shows the damage (rolls are shown) staff takes on setting off traps…(the rolls), but hey I’m grateful for this script too. I am going to test this script out.

I went with the first question - however, the DoDamage function from this script is what I’m putting into the “staff_end_dam” script. That one currently gives magic items a free ride, but the save bonus might allow me to put it in instead. Still messing with that one.

I posted the script and then realized I was backwards on how I displayed damage - I will post again once fixed

1 Like

Thanks Mannast. Of course to just make sure…the script you are referring to is the staff prodding one …right?