Making a monster that blocks attacks?

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
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Making a monster that blocks attacks?

Post by ramon.dexter »

Hidden Hands, again, I'm advising you that you should head over to zdoom wiki and LEARN things. Like, open the dcorate reference and start learning. You cannot make things without learning anything, by just asking people.

https://zdoom.org/wiki/Actor_states You are interested in this. You should learn how the states work and how to do advanced stuff with them. But, like I said, this is reachable in wiki. So, whenyou find a problem, head over to wiki and try to solve by yourself. WHEN you are not able t solve by yourself, ask on forum. But I can say that I am able to solv2 like 80% things on by myself, only by looking at wiki.

For the pain state issues, since you havent described how it should behave, we cannot advice you more... Also, as I said, you should learn and understand how decorate works.
If you want the sound to be played only on the blocking action, you can do this:

Code: Select all

 Pain:
    KLKG G 3 A_Pain
    KLKG G 3 
    KLKG H 6 
    {
        A_SetReflectiveInvulnerable;
        A_PlaySound("MySounds/Block", CHAN_WEAPON);
    }
    KLKG H 15 A_CentaurDefend
    KLKG A 1 A_UnsetReflectiveInvulnerable
    Goto See
But, since you didnt specified anything, I cannot advice you more. But you have to understand that the states happen from begginning to "goto", one line after the last.
~ax~
Posts: 6
Joined: Mon Jan 15, 2018 8:32 am

Re: Making a monster that blocks attacks?

Post by ~ax~ »

if you past a part of the code, maybe i can make it work... it´s confusing because you only talk about it, but we can´t see the decorate...
User avatar
Virathas
Posts: 254
Joined: Thu Aug 10, 2017 9:38 am

Re: Making a monster that blocks attacks?

Post by Virathas »

Hey, i think i know what is that you actually want - for the sound to play only when successfully blocking, right? As i don't have your monster code i will base the code on the good old Centaur:

I have added comments to things that are important

Code: Select all

ACTOR CentaurBlockSounder : Centaur
{
  +ALLOWPAIN // This flag allows the monster to go to pain frames when invulnerable. Not exactly sure if it forces a pain frame always though.
  States
  {
  Pain:
    TROO A 0 A_CheckFlag("INVULNERABLE", "PainBlocker", AAPTR_DEFAULT) // We are checking if the monsters is invulnerable: if it is, we go to PainBlocker state. AAPTR_DEFAULT references the monster itself.
    CENT G 6 A_Pain
    CENT G 6 A_SetReflectiveInvulnerable
    CENT EEE 15 A_CentaurDefend
    CENT E 1 A_UnsetReflectiveInvulnerable
    Goto See
  PainBlocker: // This state is basicly a copy of the Painframe with an additional A_PlaySound
    CENT E 5 A_PlaySound(BattlecruiserFire,CHAN_WEAPON)
    CENT EEE 15 A_CentaurDefend
    CENT E 1 A_UnsetReflectiveInvulnerable
    Goto See
  }
}
Of course this is unrefined monster i whipped up in like 10 minutes, so it might need some work.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England

Re: Making a monster that blocks attacks?

Post by Hidden Hands »

Virathas wrote:Hey, i think i know what is that you actually want - for the sound to play only when successfully blocking, right? As i don't have your monster code i will base the code on the good old Centaur:

I have added comments to things that are important

Code: Select all

ACTOR CentaurBlockSounder : Centaur
{
  +ALLOWPAIN // This flag allows the monster to go to pain frames when invulnerable. Not exactly sure if it forces a pain frame always though.
  States
  {
  Pain:
    TROO A 0 A_CheckFlag("INVULNERABLE", "PainBlocker", AAPTR_DEFAULT) // We are checking if the monsters is invulnerable: if it is, we go to PainBlocker state. AAPTR_DEFAULT references the monster itself.
    CENT G 6 A_Pain
    CENT G 6 A_SetReflectiveInvulnerable
    CENT EEE 15 A_CentaurDefend
    CENT E 1 A_UnsetReflectiveInvulnerable
    Goto See
  PainBlocker: // This state is basicly a copy of the Painframe with an additional A_PlaySound
    CENT E 5 A_PlaySound(BattlecruiserFire,CHAN_WEAPON)
    CENT EEE 15 A_CentaurDefend
    CENT E 1 A_UnsetReflectiveInvulnerable
    Goto See
  }
}
Of course this is unrefined monster i whipped up in like 10 minutes, so it might need some work.
Thank you so much for your efforts. I will try this soon and let you know my results.

Return to “Scripting”