Equinox-SS13 / equinox-sojourn

Other
1 stars 18 forks source link

Shield on Backpack Slot Blocks Attacks & Blocking Issues #68

Open EmilitiaEnnehrt opened 3 weeks ago

EmilitiaEnnehrt commented 3 weeks ago

Backpack Shield Blocks Attacks

As the title says. Many shields can be carried with you outside of your hand by putting it in the backpack slot. However, it still function somehow regardless of the direction it is facine (your face against attack and away from attack). So that it does not need to be carried on hand.

Funnily enough finding this because my character blocked the Church sceptor healing shots by stardustfox with the Church's shield on the character's back.

Behavior replicated and have been semi-known in Sojourn.

Additionally; Shields do not seem to block the following attacks;

SigDoesCode commented 2 weeks ago

Ok, let's look into this a bit. Shield directional checks are handled here.

Lines 159-163 are the ones that handle hits on the back. They are given below:

if(user.get_equipped_item(slot_back) == src)
    if(attack_dir & bad_arc && attack_dir)
        return TRUE
    else
        return FALSE

Here, attack_dir is a directional value depending on the direction of the attack and bad_arc is the directional value where attacks can't be blocked (think the opposite side the shield is held on).

bad_arc is defined a few lines above, on line 98, and is literally the shield user's direction but reversed. That's why we check if the attack direction is from the bad arc while using the shield. Theoretically, all we'd have to do is first check if the attack is coming from the user's facing direction, like so (thought this could probably be cleaned up in testing):

if(user.get_equipped_item(slot_back) == src)
        if(attack_dir == user.dir)
                return FALSE
    if(attack_dir & bad_arc && attack_dir)
        return TRUE
    else
        return FALSE

Regarding the last two, I think that's because of the order of attack effects applied.

The nurse spiders always have an egg inject chance because of the way the proc is written:

/mob/living/carbon/superior_animal/giant_spider/nurse/UnarmedAttack()
    ..()
    var/atom/targetted_mob = (target_mob?.resolve())
    if(ishuman(targetted_mob))
        var/mob/living/carbon/human/H = targetted_mob
        if(prob(egg_inject_chance))
            var/obj/item/organ/external/O = safepick(H.organs)
            if(O && !BP_IS_ROBOTIC(O))
                src.visible_message(SPAN_DANGER("[src] injects something into the [O] of [H]!"))
                var/obj/effect/spider/eggcluster/minor/S = new()
                S.loc = O
                O.implants += S

(From Line139-152 of /code/modules/mob/living/carbon/superior_animal/giant_spider/nurse.dm.

Basically, this means that regardless of damage checks, an egg can be injected. All we'd need to do in there is add a check on the if(prob(egg_inject_chance)) to be an AND check with if the attack wasn't blocked by the shield. For example, turning it into if(prob(egg_inject_chance) && !check_shields(src, damage, damage_source, attacker, def_zone, attack_text)) (Not perfect, just a guess.)

I assume that cellular damage is similar.

EmilitiaEnnehrt commented 2 weeks ago

Making one more comment. Trilby says that this isn't supposed to happen, that prior testing was not giving these results and I haven't had more time to test.

Perhaps look at if this is only affected by "pierce through" projectiles from any direction (full negate) like xray if unable to replicate.

SigDoesCode commented 2 weeks ago

Do you remember what message you got when you were hit and the shield supposedly blocked the bullet?

EmilitiaEnnehrt commented 2 weeks ago

It's a standard "shield negates x"