Jump to content

New EntityTakeDamage logic based on CanTargetEntity is causing issues for me

Pending 3.3.6

evict
evict

Posted

Hi! First of all, thank you very much for this plugin. All the recent updates are great.

For context, I'm using NpcSpawn integrated to my plugin to allow players to recruit bots to fight by their side.

The thing is, since the recent changes on NpcSpawn, I'm unable to allow players to damage their own allied bots because of this logic you implemented inside the OnEntityTakeDamage hook

if (victimNpc.CanTargetEntity(attacker))
{
    if (info.isHeadshot && victimNpc.Config.InstantDeathIfHitHead && attacker is BasePlayer basePlayer && basePlayer.IsPlayer()) info.damageTypes.ScaleAll(victimNpc.health / info.damageTypes.Total());
    else
    {
        info.damageTypes.ScaleAll(info.boneArea switch
        {
            HitArea.Head => victimNpc.Config.HeadDamageScale,
            HitArea.Chest or HitArea.Stomach or HitArea.Arm or HitArea.Hand => victimNpc.Config.BodyDamageScale,
            HitArea.Foot or HitArea.Leg => victimNpc.Config.LegDamageScale,
            _ => 1f
        });
        if (attacker is CustomScientistNpc attackerNpc && IsCustomScientist(attackerNpc)) info.damageTypes.ScaleAll(attackerNpc.Config.NpcDamageScale);
        victimNpc.SetKnown(attacker);
        victimNpc.TrySendTargetGroup(attacker);
    }
    return null;
}
else
{
    if (attacker is BasePlayer player && player.IsPlayer() && (player.limitNetworking || player.isInvisible)) return null;
    return true;
}

 

The problem is, I want the allied bots to not be able to target their allied players, but the players must be able to damage their own bots even though the bots can't target them back. (so players can kill their own bots if they get stuck somewhere or even accidentaly during fights).

But with this condition if (victimNpc.CanTargetEntity(attacker)) you implemented this seems to be impossible now.

Is there a possibility that you can add another config inside NpcConfig like: bool CanBeDamagedByAnySources false by default but if true, ignore this condition here and allow any damages from any sources (return null in the hook)?

About Us

Codefling is the largest marketplace for plugins, maps, tools, and more, making it easy for customers to discover new content and for creators to monetize their work.

Downloads
2.7m
Total downloads
Customers
11.5k
Customers served
Files Sold
164k
Total sales
Payments
3.5m
Processed total
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.