Jump to content

Feature Request: NpcConfig.CanDamageOtherNpcSpawns

Pending 2.7.8

evict
evict

Posted (edited)

Hi, I`m developing a plugin where players can run a command to spawn a NpcSpawn's NPC that will serve as allies, will follow them and defend.

Here is a sneak peak of the plugin:


Even though NpcSpawn allow CustomScientists to target and damage regular Npcs
I noticed NpcSpawn prevents any damage between two NpcSpawns in this line where it compares the SkinID of the victim and forces a return true in this hook.

private object OnEntityTakeDamage(BaseCombatEntity victim, HitInfo info)
{
    if (victim == null || info == null) return null;

    BaseEntity attacker = info.Initiator;

    if (IsCustomScientist(victim))
    {
        if (attacker == null || attacker.skinID == 11162132011012) return true;
      
      ...
        
    if (IsCustomScientist(attacker))
    {
    	if (victim.skinID == 11162132011012) return true;
        
     ...


The problem is I want recruits from different factions to be able to target and damage each other so players can have bot wars.

Can you add an additional optional flag in NpcConfig, let's say NpcConfig.CanDamageNpcSpawns? (default false so it does not break any current plugins using NpcSpawn)

And then, make this skinId checks only for CustomScientists with the flag set to false so I can spawn my bots with this flag = true and have the ability to damage other NpcSpawns since in my plugin they act as player allies that should be able to fight other player recruits.

Thanks!
 

Edited by evict
Jbird

Posted

21 hours ago, evict said:

Hi, I`m developing a plugin where players can run a command to spawn a NpcSpawn's NPC that will serve as allies, will follow them and defend.

Here is a sneak peak of the plugin:


Even though NpcSpawn allow CustomScientists to target and damage regular Npcs
I noticed NpcSpawn prevents any damage between two NpcSpawns in this line where it compares the SkinID of the victim and forces a return true in this hook.

private object OnEntityTakeDamage(BaseCombatEntity victim, HitInfo info)
{
    if (victim == null || info == null) return null;

    BaseEntity attacker = info.Initiator;

    if (IsCustomScientist(victim))
    {
        if (attacker == null || attacker.skinID == 11162132011012) return true;
      
      ...
        
    if (IsCustomScientist(attacker))
    {
    	if (victim.skinID == 11162132011012) return true;
        
     ...


The problem is I want recruits from different factions to be able to target and damage each other so players can have bot wars.

Can you add an additional optional flag in NpcConfig, let's say NpcConfig.CanDamageNpcSpawns? (default false so it does not break any current plugins using NpcSpawn)

And then, make this skinId checks only for CustomScientists with the flag set to false so I can spawn my bots with this flag = true and have the ability to damage other NpcSpawns since in my plugin they act as player allies that should be able to fight other player recruits.

Thanks!
 

You can already use the following hook to carry out any ideas regarding targeting with those NPCs.

OnCustomNpcTarget
evict

Posted (edited)

@Jbirdmy problem is not with targeting, my problem is with damage.
NpcSpawn is preventing damage if skinId = 11162132011012.

It returns true in OnEntityTakeDamage in the first line (Where returning anything different than null cancels the damage)
Meaning I can make them target each other but they can't damage each other.

I can resort to a messy workaround by changing the HitInfo attacker or by duplicating the hit on my plugin, but this is not ideal.

My suggestion is a new flag CanDamageNpcSpawns
and not anything related to targeting at all

Edited by evict
Jbird

Posted

On 10/17/2024 at 8:19 AM, evict said:

@Jbirdmy problem is not with targeting, my problem is with damage.
NpcSpawn is preventing damage if skinId = 11162132011012.

It returns true in OnEntityTakeDamage in the first line (Where returning anything different than null cancels the damage)
Meaning I can make them target each other but they can't damage each other.

I can resort to a messy workaround by changing the HitInfo attacker or by duplicating the hit on my plugin, but this is not ideal.

My suggestion is a new flag CanDamageNpcSpawns
and not anything related to targeting at all

There are a few ways to go about it. But the developer will add a hook in the next update. I don't have an exact timeline for you but it's been added to our notes.

  • Like 1
evict

Posted

Awesome news, thanks for taking a second look into it.

Cheers

Jbird

Posted

4 hours ago, evict said:

Awesome news, thanks for taking a second look into it.

Cheers

Of course no problem. In my head it was easier haha but it would be a bit more complicated and KpucTaJl is fine with adding a hook next time he sits down to update so you can continue to work on this if needed just knowing that will come most likely with the next update for the plugin.

1.4m

Downloads

Total number of downloads.

6.9k

Customers

Total customers served.

102.3k

Files Sold

Total number of files sold.

2m

Payments Processed

Total payments processed.

×
×
  • 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.