[SOLVED] Treat certain monsters as Walls for hit sounds?

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!)

[SOLVED] Treat certain monsters as Walls for hit sounds?

Postby eharper256 » Mon Jun 20, 2022 3:10 pm

See the title. I have a few monsters that are very metallic (i.e. Iron Golem), and it would just make more sense if they were treated as a wall for the purposes of triggering Wall Hit sounds and projectile Crash states.

Is this possible?
Last edited by eharper256 on Tue Jun 21, 2022 12:43 pm, edited 1 time in total.
User avatar
eharper256
Author of Hexen: Walpurgis
 
Joined: 25 Feb 2018
Location: UK

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby Blue Shadow » Mon Jun 20, 2022 3:27 pm

Set HITMASTER flag on the projectile so that the hit actor becomes the projectile's 'master'. Now the projectile has access to that hit actor through the 'master' field, which means you can play different sounds depending on the type of the hit actor.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby eharper256 » Tue Jun 21, 2022 12:39 am

Blue Shadow wrote:Set HITMASTER flag on the projectile so that the hit actor becomes the projectile's 'master'. Now the projectile has access to that hit actor through the 'master' field, which means you can play different sounds depending on the type of the hit actor.

Mm, that's alot of puffs and projectiles I'll have to edit. I already use HITTRACER and stuff in some instances, but I was hoping there was some secret flag that just allowed the engine to treat the monster as a wall for the purposes of playing AttackSound and triggering Crash states without extra complexity.
User avatar
eharper256
Author of Hexen: Walpurgis
 
Joined: 25 Feb 2018
Location: UK

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby Player701 » Tue Jun 21, 2022 1:04 am

eharper256 wrote:Mm, that's alot of puffs and projectiles I'll have to edit. I already use HITTRACER and stuff in some instances, but I was hoping there was some secret flag that just allowed the engine to treat the monster as a wall for the purposes of playing AttackSound and triggering Crash states without extra complexity.

Wouldn't setting the NOBLOOD flag on the "metallic" monsters be sufficient? In case that's out of the question for whatever reason, it is possible to avoid editing every puff/projectile by inheriting them from common base classes and putting the code in there. This would only be possible if using ZScript, of course.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby eharper256 » Tue Jun 21, 2022 1:20 am

Player701 wrote:
eharper256 wrote:Mm, that's alot of puffs and projectiles I'll have to edit. I already use HITTRACER and stuff in some instances, but I was hoping there was some secret flag that just allowed the engine to treat the monster as a wall for the purposes of playing AttackSound and triggering Crash states without extra complexity.

Wouldn't setting the NOBLOOD flag on the "metallic" monsters be sufficient? In case that's out of the question for whatever reason, it is possible to avoid editing every puff/projectile by inheriting them from common base classes and putting the code in there. This would only be possible if using ZScript, of course.

Oh, they already have +NOBLOOD set. The issue is, stuff like the mace and axe hitting the golem and it having fleshy sounds rather than clangy sounds is a bit weird. :)
User avatar
eharper256
Author of Hexen: Walpurgis
 
Joined: 25 Feb 2018
Location: UK

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby Player701 » Tue Jun 21, 2022 1:31 am

In this case, you can use the following code in your base puff class to play the AttackSound (normally played when hitting a wall) instead of the SeeSound (normally played when hitting an actor) upon hitting a non-bleeding actor, as well as enter the Crash state. Note that +HITTRACER is implied.

Code: Select allExpand view
override void PostBeginPlay()
{
    Super.PostBeginPlay();

    if (tracer != null && tracer.bNoBlood)
    {
        A_StartSound(AttackSound);
        let cs = ResolveState('Crash');
        if (cs != null)
        {
            SetState(cs);
        }
    }
}

upd: Added code to enter the Crash state automatically, since it doesn't happen by default.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby eharper256 » Tue Jun 21, 2022 11:29 am

Player701 wrote:In this case, you can use the following code in your base puff class to play the AttackSound (normally played when hitting a wall) instead of the SeeSound (normally played when hitting an actor) upon hitting a non-bleeding actor, as well as enter the Crash state. Note that +HITTRACER is implied.

Code: Select allExpand view
override void PostBeginPlay()
{
    Super.PostBeginPlay();

    if (tracer != null && tracer.bNoBlood)
    {
        A_StartSound(AttackSound);
        let cs = ResolveState('Crash');
        if (cs != null)
        {
            SetState(cs);
        }
    }
}

upd: Added code to enter the Crash state automatically, since it doesn't happen by default.


Yes, that works fine, thanks. :)

The only issue is that when we hit actors that DON'T have +NOBLOOD, it throws "Unknown Flag Noblood in Actor X" errors each time we hit, where X is the monster's class name.
Last edited by eharper256 on Tue Jun 21, 2022 11:39 am, edited 2 times in total.
User avatar
eharper256
Author of Hexen: Walpurgis
 
Joined: 25 Feb 2018
Location: UK

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby Player701 » Tue Jun 21, 2022 11:37 am

eharper256 wrote:The only issue is that when we hit actors that don't have +BLOODLESS, it throws "Unknown Flag Bloodless in Actor X" errors each time we hit, where X is the monster's class name.

Did you mean +NOBLOOD? There is no such flag as BLOODLESS, only BLOODLESSIMPACT, but I'm not sure if you meant that.

I didn't see any error messages while testing my code, so it's likely something on your end. I will try to investigate if you could provide a minimal example that reproduces the issue reliably.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby eharper256 » Tue Jun 21, 2022 11:45 am

Player701 wrote:Did you mean +NOBLOOD? There is no such flag as BLOODLESS, only BLOODLESSIMPACT, but I'm not sure if you meant that.

I didn't see any error messages while testing my code, so it's likely something on your end. I will try to investigate if you could provide a minimal example that reproduces the issue reliably.

Yes sorry I meant NOBLOOD; edited the post after you already saw it. But you can see I got confused because that shows in game:

Image
Here's a screenshot ^
Code: Select allExpand view
Class BaseWalpPuff : Actor
{
 override void PostBeginPlay()
   {
    Super.PostBeginPlay();

    if (tracer != null && tracer.bNoBlood)
    {
        A_StartSound(AttackSound);
        let cs = ResolveState('Crash');
        if (cs != null)
        {
            SetState(cs);
        }
    }
   }
 Default
   {
   +NOBLOCKMAP;
   +NOGRAVITY;
   +PUFFONACTORS;
   +HITTRACER;
   RenderStyle "Translucent";
   Alpha 0.6;
   VSpeed 0.5;
   SeeSound "FighterHammerHitThing";
   AttackSound "FighterHammerHitWall";
   ActiveSound "FighterHammerMiss";
   }
  States
   {
   Spawn:
      FHFX STUVW 4;
      Stop;
   Crash:
      Goto Spawn;
   }
}

^Here's the code used for the base puff which I've set the others to inherit from.
User avatar
eharper256
Author of Hexen: Walpurgis
 
Joined: 25 Feb 2018
Location: UK

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby Player701 » Tue Jun 21, 2022 11:54 am

eharper256 wrote:
Code: Select allExpand view
Class BaseWalpPuff : Actor
{
 override void PostBeginPlay()
   {
    Super.PostBeginPlay();

    if (tracer != null && tracer.bNoBlood)
    {
        A_StartSound(AttackSound);
        let cs = ResolveState('Crash');
        if (cs != null)
        {
            SetState(cs);
        }
    }
   }
 Default
   {
   +NOBLOCKMAP;
   +NOGRAVITY;
   +PUFFONACTORS;
   +HITTRACER;
   RenderStyle "Translucent";
   Alpha 0.6;
   VSpeed 0.5;
   SeeSound "FighterHammerHitThing";
   AttackSound "FighterHammerHitWall";
   ActiveSound "FighterHammerMiss";
   }
  States
   {
   Spawn:
      FHFX STUVW 4;
      Stop;
   Crash:
      Goto Spawn;
   }
}

^Here's the code used for the base puff which I've set the others to inherit from.

Sorry, this code doesn't produce any errors for me. I've replaced the sprite names to be sure the puff indeed gets spawned. If you're using the latest GZDoom version (4.8.0 as of now - if not, please update and re-test), then it's something else in your mod and/or autoloads that's causing this. Looking at the source code, it seems these error messages can only be generated by A_CheckFlag (DECORATE) and CheckFlag (ACS) calls.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby eharper256 » Tue Jun 21, 2022 11:59 am

Well, yes, the monsters in question are in DECORATE. Considering tracer.bNoBlood is the only sign we see of "NOBLOOD" I was thinking it might be some violent interaction between the ZScript puff and DECORATE monster.

But strangely, it works fine on the Steel Golem itself (also DECORATE monster) without throwing any errors, so I suppose +BLOODLESS is seen and assumed to be equivalent to bNoBlood in that case.

Yes I have 4.8.0 GZDoom.

And yes, I know, I should fully convert to ZScript, but I have such a titanic amount of DECORATE code nowadays the idea of adding tens of thousands of semi-colons to it is just a frankly horrifying way to have to spend multiple evenings. :shock:
User avatar
eharper256
Author of Hexen: Walpurgis
 
Joined: 25 Feb 2018
Location: UK

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby Player701 » Tue Jun 21, 2022 12:06 pm

eharper256 wrote:Well, yes, the monsters in question are in DECORATE. Considering tracer.bNoBlood is the only sign we see of "NOBLOOD" I was thinking it might be some violent interaction between the ZScript puff and DECORATE monster.

But strangely, it works fine on the Steel Golem itself (also DECORATE monster) without throwing any errors, so I suppose +BLOODLESS is seen and assumed to be equivalent to bNoBlood in that case.

Yes I have 4.8.0 GZDoom.

The string "BLOODLESS" does not appear in GZDoom's source code (both C++ and ZScript) in any form, except when referring to the BLOODLESSIMPACT flag. Try searching for "BLOODLESS" in the code of your own mod as well as in your autoloads (if you have any), and you will very likely discover the actual source of the problem. Failing that, you could still provide a minimal example mod that actually reproduces the issue (just the puff actor definition alone is not enough for that), and I'll try to investigate further.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby eharper256 » Tue Jun 21, 2022 12:21 pm

Did a full search of all my DECORATE and ZScript, +BLOODLESS is never mentioned, just +BLOODLESSIMPACT a few times (I would imagine GZDoom would alert me about it being a unknown flag on startup anyway if such a thing did make it in anyway, right? And I would quash the bug). Removed everything else from loadorder, still the same.

You can try this Imp replacer I suppose. Spawned it and it does cause the same issue:
Code: Select allExpand view
ACTOR TougherImpW : DoomImp replaces DoomImp
{
   Health 85
   PainChance "Electric", 222
   Meleerange 64
   +CASTSPRITESHADOW
   States
   {
   Missile:
      TROO EF 8 A_FaceTarget
      TNT1 A 0 A_JumpIfCloser(32, "Slash")
      TROO G 6 A_CustomComboAttack("DoomImpBall", 32, random(9,16), "imp/melee")
      Goto See
   Slash:
      TROO G 6 A_MeleeAttack
      Goto See
  }
}

I modified it so it spawns as a replace rather than via the spawner actor and uses old DoomImpBall rather than its new ball so it should work without issue.
User avatar
eharper256
Author of Hexen: Walpurgis
 
Joined: 25 Feb 2018
Location: UK

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby Player701 » Tue Jun 21, 2022 12:27 pm

eharper256 wrote:I would imagine GZDoom would alert me about it being a unknown flag on startup anyway if such a thing did make it in anyway, right? And I would quash the bug

You are correct. The message only appears in the game because GZDoom tries to look up the flag at run-time and doesn't find it.

eharper256 wrote:+BLOODLESS is never mentioned

You should search without the "+".

eharper256 wrote:You can try this Imp replacer I suppose. Spawned it and it does cause the same issue:
Code: Select allExpand view
ACTOR TougherImpW : DoomImp replaces DoomImp
{
   Health 85
   PainChance "Electric", 222
   Meleerange 64
   +CASTSPRITESHADOW
   States
   {
   Missile:
      TROO EF 8 A_FaceTarget
      TNT1 A 0 A_JumpIfCloser(32, "Slash")
      TROO G 6 A_CustomComboAttack("DoomImpBall", 32, random(9,16), "imp/melee")
      Goto See
   Slash:
      TROO G 6 A_MeleeAttack
      Goto See
  }
}

I modified it so it spawns as a replace rather than via the spawner actor and uses old DoomImpBall rather than its new ball so it should work without issue.

Unfortunately, still nothing for me.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Treat certain monsters as Walls for hit sounds/Crash sta

Postby eharper256 » Tue Jun 21, 2022 12:42 pm

Okay, I'm an idiot. It was actually my haemorraging system being an asshat.

Apologies, and thanks again for the code, it works great, I'll obviously credit you for the help.

And I liked Elijah from Unavowed by the way, so nice Avatar.
User avatar
eharper256
Author of Hexen: Walpurgis
 
Joined: 25 Feb 2018
Location: UK

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests