Breakable Weapons

Is there a script someone could write up where you can only use specific weapons or tools to break things and if you don’t use those and choose to break stuff with a sword for example it breaks that weapon?

For example only a Light Pick or Heavy Pick could break rocks…perhaps a hammer too named: “Chiseling/Sledge Hammer”. Of course the light pick does less damage to the rock and the heavy pick does more.

Axes for wooden doors and trees.

Hammers for bashing in stone doors.

I’d like to penalize my Players for smashing rocks with their swords, axes, spears, etc…it just doesn’t seem right to do that!!..lol

[edit] Throw in a message that says: “Your weapon breaks”…or some such comment.

1 Like

I have a couple of ideas - I have a script where you can use certain long weapons to trigger traps. The weapons (if non-magical) take damage and can break. I’m certain it could be tweaked a little. Also reminds me of my crafting tools. However, those don’t give you the option to do the mining or wood chopping with a regular weapon… Let me take a look.

1 Like

I think I also have something from Universe of Arlandia (abandoned and inherited by me), but I think it just wears all items equipped each round of combat (bashing being the operative action used for mining, tree chopping, and herb cutting), so not what you’re looking for.

It’s been a very long time since I dealt with this, but here is what I used for some prototyping. Note that it was used on a creature and part of it determined the quality of the weapon used, but you should be able to adapt it if you don’t get something better from someone else:

 //This line goes into OnDamaged script of NPC/Monsters
  ExecuteScript("q_weapon_break", GetItemActivator());

The this goes into a script called “q_weapon_break”:

int GetWeaponComposition(object oItem)
// Check the name or tag for the material of weapon, dictates odds of breaking.
{
// Comment out the next line, it's just to let you know it is actually being called and firing
SendMessageToPC(GetFirstPC(),"Breakage Fired");
//  Returns one of the following: None or Error=0, Iron=1, Steel=2, Rubber=3, Magic=4
if (GetStringLeft(GetName(oItem), 4) == "Iron")
    return 1;
if (GetStringLeft(GetName(oItem), 5) == "Steel")
    return 2;
if (GetStringLeft(GetName(oItem), 6) == "Rubber")
    return 3;
if (GetStringRight(GetTag(oItem), 4) == "_mag")
    return 4;
else
    return 0;
}
void DoBreakCheck(object oItem)
{
int nComposition = GetWeaponComposition(oItem);
switch (nComposition)
{
case 1:  //Iron
    if(Random(100)+1 < 3)
        {
        DelayCommand(1.5f,SpeakString("Your weapon is destroyed by the attack!"));
        DestroyObject(oItem);
        }
    break;
case 2:  //Steel
    if(Random(200)+1 < 2)
        {
        DelayCommand(1.5f,SpeakString("Your weapon is destroyed by the attack!"));
        DestroyObject(oItem);
        }
    break;
case 3:  //Rubber
    if(Random(20)+1 < 2)
        {
        DelayCommand(1.5f,SpeakString("Your weapon is destroyed by the attack!"));
        DestroyObject(oItem);
        }
    break;
case 4:  //Magic
    break;
}
}
void main()
{
    object oPrimary = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND);
    object oSecondary = GetItemInSlot(INVENTORY_SLOT_LEFTHAND);
    DoBreakCheck(oPrimary);
    DoBreakCheck(oSecondary);
}
1 Like

Thanks Mannast, If you can create this script for me that would be great. I’m sure others would love it too when you upload it.

I downloaded your weapons .erf that sets off traps. Can’t wait to try it. :slight_smile:

Would you mind putting that into a mod and uploading it here so I can see how it works? I think it sounds great. Just not a scripter here. I could add this script by looking at it and see how it works. Where you put stuff etc. I’m ok at meshing scripts together…if I can see how it works, :slight_smile:

This goes into the OnAttacked script for a creature:
object oAttacker = GetLastDamager();
ExecuteScript(“q_weapon_break”, oAttacker);

The above script I posted goes into a script named “q_weapon_break”. This is the top of the “nw_c2_Defaults” script of my module, I can stick it somewhere, it never got finished:
#include “nw_i0_generic”

void main()
{
object oAttacker = GetLastDamager();
ExecuteScript("q_weapon_break", oAttacker);
    if(GetFleeToExit()) {
        // Run away!
        ActivateFleeToExit();

That’s it, the creature is hit by the player, the script for breakage fires, and rolls randomly for chance of breakage. I’ll fix the script above, I didn’t use the tags right so the formatting got broken.

2 Likes

You know what would be great too would be if for every plus of a weapon “+” that the “+” gives the weapon a saving throw, Like the old PnP D&D for saves with a weapon breaking. Thanks for doing this. :slight_smile:

[edit]

Include that the weapons have less chance of breaking if the weapon is said to be made of Mithral or Dark Iron, or dwarven steel, etc…some of the harder properties included in the weapon properties material it is made from.

It depends on the lore and economy of your world. If magic is rare and +1 is coveted, maybe magic weapons are nearly (or are) unbreakable, they would be greatly prized items.
If magic items are unlimited then go ahead and break them.

I passed up putting it in, but having wear and breakage can help a Player economy if they need to be repaired every so often or crafted to replace. Most places I’ve seen it tend to have ways of checking the wear on your gear, sometimes it’s an Int on the weapon and you use another item to examine your items and objects int he world, sometimes they use Charges so you can simply look at the weapon.

If you’re detecting these kinds of hits on a creature, you might include wear on armor and shields as well, or randomly choose an equipped item. But don’t go overboard, you can seriously piss off your players. If it’s a single player module, you can tell the player what to expect. If it’s a persistent world you can lose players.

It’s cool in theory, but really depends on if you want to introduce a secondary economy in the form of perishable items. If your game isn’t fun, it won’t matter, but I’m saying this can put players off before they’ve even seen what your module has to offer.

1 Like

You can add additional lines easily, just look at the breakage script and see how it works.

For instance, add:
if (GetStringRight(GetTag(oItem), 5) == “_mith”)
return 5;
else
return 0;

and later:

case 5:  //Mithral
    if(Random(2000)+1 < 2)
        {
        DelayCommand(1.5f,SpeakString("Your weapon is destroyed by the attack!"));
        DestroyObject(oItem);
        }
    break;

Above Mithral has a 1 in 2000 chance. I would add points to the weapon so each time it causes wear that can be repaired. Since long odds don’t mean it won’t happen, it means it’s less likely, but your brand new Mithral weapon CAN break on the first hit…

1 Like

I love everything you said. I’m a hardcore ruleset kinda guy. The more realistic the better. Yes it would clean the world of magical weapons and have your PC’s think twice about using a sword for example on a Stone Golem…and have your PC’s have to carry backup weapons and make them purchase more weapons…helping to reduce them of their gold. I love it!

Is there a way you could just create a little mod and .erf to upload so I can see how it works please?

I was thinking of applying it across the board back in 2008, but you should only use it on monsters that make sense, like rust monsters, gelatinous cubes, and stone golems and such. I mean, if magic weapons are valuable, maybe they carry a few other throwaway weapons for the job. Or plan ahead, say skip damage if they are attacking a cube while protected by Resist Elements or something.

1 Like

Here’s a bit of a story mod I was working on, which I abandoned but turned into a test module. Talk to the old lady and buy an Iron Shortsword. The Elven weapons on the floor are magical, I think and won’t break.
Ignore the armors, I had a custom hak to convert the 5/10/etc single point (1/2/3/4/5, etc).

https://mega.nz/file/0mIRma4K#JUIkiXWFGT6056Uy2CHexkEjtgDG-4mIb1S3kfxXWQU

Well, I HAD an Iron shortsword (it shouldprbably be tougher than that, but it was just a proof of concept. Someone wrote that for me way back when I was tinkering like you are now, I forget who:

1 Like

Thanks I had to create an account on MEGAsync in order to download it. Just waiting on the download.

Huh, shouldn’t have needed to make an account, but since you have it I really like them, LOTS of space for free.

1 Like

Hi Mannast

I imported the .erf for your staff that is used for prodding traps. It doesn’t seem to work. Does it not work for NWN:EE? You speak of a “widget”. I can’t find any widget in my toolset under “items” anywhere. And you also speak of :slight_smile:

“staff_trigger”, “staff_end_dam” scripts
“staff_end” npc blueprint
“staff_trigger” item blueprint

I used the blueprint for the staff (staff_trigger). I created a staff with that tag.
I don’t understand the purpose for the npc blueprint. What is that for?
The other script “staff_end_dam” I get…it is the damage the staff gets or PC when setting off the trap possibly.

Is there suppose to be a widget in the inventory that gets the PC to use when he equips the staff?

Hi Qlippoth

I tried your module (and thanks) I got the iron sword but after letting my PC hack the dummy for like 10 min I saw no breakage of the weapon.

But you saw the script was firing in the combat window and my Iron Shortsword broke. It will happen eventually, but the Iron weapons got 100:1 odds (roll 100 sided die, break on a 1). So it can happen the first time, the hundredth time, or improbably the ten thousandth time if the die never hits 100 after 10000 rolls.

That’s why i was saying it might be better to lower the odds, but give multiple opportunities using points Or even allow the object to be repaired after breaking.of some kind to repair it.
Or, use a point system where every 100 hits damages the weapon or straight up have X hits of the weapon (weapon HP) before it breaks, and have HP restored when repaired.

In any case, you have a script that can detect hits, and a method to affect the weapon in some way. Figure out how you want ti to work, and see if you can alter the script to do that. IF you run into trouble come back and ask, someone should be able to help you.

1 Like

Ahh…thanks Qlippoth…I feel dumb…lol…that makes sense if it is a 1 in 100 chance of breaking. Awesome! I am going to implement this into my module. And yes the script does fire. You think it will be ok for PW use?

Really appreciate guys like you helping guys like me out. :slight_smile:

Trust me, it’s normal to feel stupid and helpless. After more than a decade I only feel remotely comfortable scripting, but you can probably learn much faster than I did, since I am averse to doing anything I’m not instantly good at.

Any script that works correctly is fine for a PW. But it also depends on performance, the script is doing pretty simple things every time anything hits a creature with that OnDamaged script addition:

//This line goes into OnDamaged script of NPC/Monsters
  ExecuteScript("q_weapon_break", GetItemActivator());

If it were more complex or intensive then you might consider how much it is doing and how often it fires. AOE spells and scripts have a lot of overhead, but we aren’t doing any of that here.
Be aware that if monsters fight eachother (unlikely) their own weapons can break if it is a weapon with the right Name (or skipped if the Tag ends in _mag for magic weapon).

Look at the module I gave you, note the Name of the weapons I’m using, since those are needed to detect when a breakable weapon is being used to attack a creature. The Elven Weapons should have the _mag on the end of their Tag.

Be sure to comment out the SpeakString line, since you don’t need that, it’s only for testing to make sure it’s actually firing. We know it is, so it’s not needed.
Add // in front of “SendMessageToPC(GetFirstPC(),“Breakage Fired”);”