Friendly monsters can't damage own species??

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Dan_The_Noob
Posts: 755
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Friendly monsters can't damage own species??

Post by Dan_The_Noob »

Hey guys.

Messing with TwitchyDoom recently and i noticed the Friendly enemies can't damage enemies of the same "Species" as them, even though they are friendly.

The enemies of same species can still damage them.

Is this a GZDoom bug or a TwitchyDoom bug? :?:
Blue Shadow
Posts: 4929
Joined: Sun Nov 14, 2010 12:59 am
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Friendly monsters can't damage own species??

Post by Blue Shadow »

If what you mean, for example, a friendly hell knight can't harm a friendly hell knight, then it's probably not a bug, since there's an actor flag that can be set to override that behavior.
User avatar
Dan_The_Noob
Posts: 755
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Friendly monsters can't damage own species??

Post by Dan_The_Noob »

nah, like.
I have a friendly hellknight and it tries to attack an enemy hellknight.
friendly will do no damage, but will take damage from the enemy hellknight
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48597
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Friendly monsters can't damage own species??

Post by Graf Zahl »

That's definitely a bug. The code has seen lots of changes over the years by many people and apparently someone missed that particular case.

Any target that's considered hostile should be hurt, regardless of species.
Blue Shadow
Posts: 4929
Joined: Sun Nov 14, 2010 12:59 am
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Friendly monsters can't damage own species??

Post by Blue Shadow »

I just tested it (with 4.11pre-22-g7b9a36c8f) by spawning friendly and hostile hell knights; they fought and hurt each just fine. So it could be a mod problem.
User avatar
Dan_The_Noob
Posts: 755
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Friendly monsters can't damage own species??

Post by Dan_The_Noob »

This is the most likely culprit i think?
from Twitchydoom.
oh also it turns out no melee damage works on infight, but projectiles/hitscans work.

Code: Select all

// Spawn a friendly monster
Class TCommand_SpawnFriendlyMonster : Twitchy_Command
{
    Class<Actor> monster;

    override void Command()
    {
        monster = GetParamString("actor");

        if(!monster)
        {
            Twitchy_Handler h = Twitchy_Handler(StaticEventHandler.Find("Twitchy_Handler"));

            monster = h.PickRandomMonster();
        }

        if(!monster)
        {
            Destroy();
            return;
        }

        Actor player = Twitchy_Handler.RandomPlayer();

        Actor a = Actor.Spawn(monster, player.pos);
        if(a.bSHOOTABLE)
        {
            a.bSHOOTABLE = false;
            a.GiveInventory("Twitchy_FriendlySpawnProtection", 1);
            a.GiveInventory("Twitchy_FriendlyFireProtection", 1);
        }

        if(a.bCOUNTKILL)
        {
            a.A_ChangeCountFlags(0);
            a.bCOUNTKILL = false;
        }

        a.bFRIENDLY = true;
        a.bNOBLOCKMONST = true;
        a.bSOLID = false;
        a.target = player;
        a.lastheard = player;
        a.A_SpawnItemEx("TeleportFog");

        if(!GetParamString("nofollow"))
        {
            a.GiveInventory("Twitchy_FriendlyFollower", 1);
        }
        if(GetParamString("showmap"))
        {
            Twitchy_Actor_MapMarker.Show(a);
        }

        Twitchy_Username.Show(a, username .. " (ALLY)");
    }

    override void Notification()
    {
        Console.Printf("\cf" .. username .. " \c-joined the game.");
   
        S_Sound("misc/chat", CHAN_VOICE | CHAN_UI);
        Console.Printf("\cf" .. username .. "\c-: \c*" .. messageRaw);
    }
}


class Twitchy_FriendlyFireProtection : Inventory
{
    override void Tick()
    {
        if(owner)
        {
            owner.bFRIENDLY = true;
        }
        Super.Tick();
    }

    override void ModifyDamage (int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags)
    {
        if((source && (source.player || source.bFRIENDLY)) || inflictor && (inflictor.player || inflictor.bFRIENDLY))
        {
            newdamage = 0;
        }
    }
}

Return to “Scripting”