Page 1 of 1

[DONE] unarmed stab on mobs with weapon resistance

Posted: 16 Nov 2019, 06:40
by uriel
Hey Ilmarninen, you're idle so I'll put the details here. I'd like to offer up a bugfix to /cmds/mortal/_stab.c

Issue: stabs have damage set to 0 if a MOB has "weapon resistance" (i.e. Intruder) and no weapon is wielded.

Solution: An update can be found in /realms/uriel/_stab.uriel.15Nov19.

Logic: if a weapon is not wielded, check COMBAT_D->unarmed_enchantment(player). If enchantment < resistance, damage = 0, as per a wielded weapon.

Here's the diff from the 30Aug version:

Code: Select all

188d187
<     int enchantment, resistance;
254,258c253,254
<             enchantment = 0; //default 0
<             resistance = (int) victim->query_property("weapon resistance");
<             if(!objectp(weapon)) {enchantment = (int) COMBAT_D->unarmed_enchantment(stabber);}
<             else if(objectp(weapon)) {enchantment = (int) weapon->query_property("enchantment");}
<             if (enchantment < resistance) { damage = 0; }
---
>             if(!objectp(weapon)) { damage = 0; }
>             else if (weapon->query_property("enchantment") < victim->query_property("weapon resistance")) { damage = 0; } 
316d311
<     int enchantment, resistance;
373,377c368,369
<             enchantment = 0; //default 0
<             resistance = (int) target->query_property("weapon resistance");
<             if(!objectp(weapon)) {enchantment = (int) COMBAT_D->unarmed_enchantment(player);}
<             else if(objectp(weapon)) {enchantment = (int) weapon->query_property("enchantment");}
<           if (enchantment < resistance) { damage = 0; } 
---
>           if(!objectp(weapon)) { damage = 0; }
>           else if (weapon->query_property("enchantment") < target->query_property("weapon resistance")) { damage = 0; }                                                                       

Re: unarmed stab on mobs with weapon resistance

Posted: 16 Nov 2019, 06:43
by yves
Doesn't the precise strikes feat fix this issue, or is the issue is that it isn't being applied to stabs?

Re: unarmed stab on mobs with weapon resistance

Posted: 16 Nov 2019, 06:49
by uriel
No, the code checks for a weapon wielded, and if no weapon wielded, sets damage to 0.

Here's the offending code line 251-255:

Code: Select all

        if(victim->query_property("weapon resistance"))
        {
            if(!objectp(weapon)) { damage = 0; } 
            else if (weapon->query_property("enchantment") < victim->query_property("weapon resistance")) { damage = 0; }
        }
And again offending code line 366-370:

Code: Select all

        if(target->query_property("weapon resistance"))
        {
            if(!objectp(weapon)) { damage = 0; }
            else if (weapon->query_property("enchantment") < target->query_property("weapon resistance")) { damage = 0; }
        }

Re: unarmed stab on mobs with weapon resistance

Posted: 16 Nov 2019, 12:09
by beshaba
So the issue is that if you're stabbing something with your bare hands, and it has damage resistance, you deal no damage? That doesn't sound broken to me, it makes sense. Unless I'm missing your point?

Re: unarmed stab on mobs with weapon resistance

Posted: 16 Nov 2019, 16:37
by uriel
beshaba wrote:
16 Nov 2019, 12:09
So the issue is that if you're stabbing something with your bare hands, and it has damage resistance, you deal no damage? That doesn't sound broken to me, it makes sense. Unless I'm missing your point?
Yes you are missing the point but that's okay, it took me a while to figure out what was going wrong too :)

If a player is a monk or has the feat Precise Strikes, the unarmed attacks have enchantment of +1/6 levels or +1/8 levels respectively. However, the old stab code only checks for enchantment on weapons. The old stab code does not check for enchantment on unarmed attacks from monk or precise strikes feat because those are relatively new features.

So the bug fix just compares unarmed enchantment versus the weapon resistance, using the same exact process for wielded weapons.

Please have a look at the unarmed_enchantment function in COMBAT_D:

Code: Select all

int unarmed_enchantment(object who)
{
    int mod = 0;
    if(!objectp(who)) return mod;
    if(who->is_class("monk")) mod += (int)"/std/class/monk.c"->effective_enchantment(who);
    else if(FEATS_D->usable_feat(who, "precise strikes")) { mod += ((int)who->query_base_character_level() / 8); }
    return mod;
}
For kicks, you can do this as an eval to find out what enchantment a player has unarmed:

Code: Select all

eval return COMBAT_D->unarmed_enchantment(find_player("beshaba"))

Re: [DONE] unarmed stab on mobs with weapon resistance

Posted: 17 Nov 2019, 01:31
by ilmarinen
The patch applied.

If you use `diff -u first second` I can then use `patch` to apply it easily.
Alternatively, you should have right to do this yourself :P