Making a monster that blocks attacks?
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!)
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!)
-
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
Making a monster that blocks attacks?
Like the centaurs from Hexen, how would I go about editing my monsters DECORATE code so that it can block attacks?
Thanks in advance.
Thanks in advance.
-
- 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?
Look at the centaur class and learn how it's done.
https://zdoom.org/wiki/Classes:Centaur
Also,you should bookmark the zdoom wiki,as you can find there anything you are asking for.
https://zdoom.org/wiki/Classes:Centaur
Also,you should bookmark the zdoom wiki,as you can find there anything you are asking for.
-
- Posts: 296
- Joined: Tue Jan 19, 2010 5:07 pm
Re: Making a monster that blocks attacks?
Like Ramon said, Centaur is good source. Basicly, to block, you need to turn on flags "INVULNERABLE" and "REFLECTIVE" to add the effect of repulsing missiles. You also can specify what kind of repulsion happens by adding other flags. Be sure to unset those flags after the block is complete.
In ZScript, you could do also some more advanced stuff, like being invulnerable only from front, etc.
In ZScript, you could do also some more advanced stuff, like being invulnerable only from front, etc.
-
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
Re: Making a monster that blocks attacks?
Ok thank you all so much, I have a perfectly working monster that blocks now. But I'm having trouble getting it to have a "block" sound effect. It carries two daggers and blocks with them, and I want a bullet richochet sound when it blocks... I can't get it to work. Can anyone advise me on this please?
Thank you very much in advance.
Thank you very much in advance.
-
- Posts: 296
- Joined: Tue Jan 19, 2010 5:07 pm
Re: Making a monster that blocks attacks?
You got the sound already? If yes, just use "A_PlaySound("...")
"..." is the defined path to the sound in the SNDINFO lump. Check out info on this here
Example:
SNDINFO
Monster code:
"..." is the defined path to the sound in the SNDINFO lump. Check out info on this here
Example:
SNDINFO
Code: Select all
MySounds/BlockSound "sound/monsters/block.ogg"
Code: Select all
(...)
States
{
Block:
TNT1 A 0 A_PlaySound("MySounds/BlockSound", CHAN_WEAPON)
(...)
-
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
Re: Making a monster that blocks attacks?
So in my monster code, where would I put that exactly? I don't have a Block section but I have it like this: Maybe you can help tell me where I should put the A_Playsound code.krokots wrote:You got the sound already? If yes, just use "A_PlaySound("...")
"..." is the defined path to the sound in the SNDINFO lump. Check out info on this here
Example:
SNDINFOMonster code:Code: Select all
MySounds/BlockSound "sound/monsters/block.ogg"
Code: Select all
(...) States { Block: TNT1 A 0 A_PlaySound("MySounds/BlockSound", CHAN_WEAPON) (...)
Code: Select all
ACTOR KlinkBrother3 32711
{
//$Category Monsters
//$Title KlinkBrother3
//$Sprite KLKGA2A8
Health 400
PainChance 135
Speed 13
Height 64
Mass 120
Scale 1.2
Monster
+FLOORCLIP
+TELESTOMP
+SHIELDREFLECT
SeeSound "KlinkSight"
AttackSound "KlinkAttack"
PainSound "KlinkPain"
DeathSound "KlinkDeath"
ActiveSound "KlinkActive"
HowlSound "KlinkHowl"
Obituary "You were stabbed to death by the Klink Brothers."
DamageFactor "Electric", 3
States
{
Spawn:
KLKG AB 10 A_Look
Loop
See:
KLKG ABCD 4 A_Chase
Loop
Pain:
KLKG G 6 A_Pain
KLKG H 6 A_SetReflectiveInvulnerable
KLKG H 15 A_CentaurDefend
KLKG A 1 A_UnsetReflectiveInvulnerable
Goto See
Melee:
KLKG E 5 A_FaceTarget
KLKG F 7 A_CustomMeleeAttack(random[CentaurAttack](3, 9))
Goto See
Death:
KLKG I 4
KLKG J 4 A_Scream
KLKG K 4
KLKG L 4 A_NoBlocking
KLKG M 4
KLKG N 4 A_QueueCorpse
KLKG N 4
KLKG N -1
Stop
XDeath:
KLKG I 4
KLKG J 4 A_Scream
KLKG K 4
KLKG L 4 A_NoBlocking
KLKG M 4
KLKG N 4 A_QueueCorpse
KLKG N 4
KLKG N -1
}
}
-
- 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?
Hidden hands, you should think a little, also, you should understand what you are doing. You have to put the blocking sound where the blocking action occurs.
EDIT: No, I was not drunk. Just used tablet to type
EDIT: No, I was not drunk. Just used tablet to type

Last edited by ramon.dexter on Sun Jan 07, 2018 4:18 am, edited 1 time in total.
-
- Posts: 296
- Joined: Tue Jan 19, 2010 5:07 pm
Re: Making a monster that blocks attacks?
Inside the "Pain" state:
Code: Select all
Pain:
KLKG G 3 A_Pain
KLKG G 3 A_PlaySound("MySounds/Block", CHAN_WEAPON)
KLKG H 6 A_SetReflectiveInvulnerable
KLKG H 15 A_CentaurDefend
KLKG A 1 A_UnsetReflectiveInvulnerable
Goto See
-
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
Re: Making a monster that blocks attacks?
I was a little worried that putting the playsound code next to the reflecting code would cause conflicting errors. Sorry I just like to make sure everything is being done right. Thank you for the advice I'll try to experiment more but I like to be careful.ramon.dexter wrote:Hidden hands, you hsould think a little, also, you should undersfand what you are doing. You have to put the blocking sound where the blocking action occurs.
Thank you I'll do this as soon as I get home. Will this make the sound play everytime they are hit or only when blocking? How does it know? Thank you again.krokots wrote:Inside the "Pain" state:Code: Select all
Pain: KLKG G 3 A_Pain KLKG G 3 A_PlaySound("MySounds/Block", CHAN_WEAPON) KLKG H 6 A_SetReflectiveInvulnerable KLKG H 15 A_CentaurDefend KLKG A 1 A_UnsetReflectiveInvulnerable Goto See
-
- 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?
Hidden Hands wrote:I was a little worried that putting the playsound code next to the reflecting code would cause conflicting errors. Sorry I just like to make sure everything is being done right. Thank you for the advice I'll try to experiment more but I like to be careful.ramon.dexter wrote:Hidden hands, you hsould think a little, also, you should undersfand what you are doing. You have to put the blocking sound where the blocking action occurs.
The point is to be not afraid to experiment. The worst thing that could happen is that you could crash you OS. But the more frequent crashes I encounter while experimenting are either during compilantion (its not compiled because of some mistake I made), or a crash of gzdoom because of some hard error I did. Nothing major, just minor crashes. Also, this kind of errors tells me what NOT to do.
Just dont be afraid

-
- Posts: 296
- Joined: Tue Jan 19, 2010 5:07 pm
Re: Making a monster that blocks attacks?
This will be played everytime this monster enters "Pain" state. You need to understand DECORADE code a little bit more, basicly, If an actor enters a state (say, Pain state), it will run through all the functions from top to bottom. Well, they are called "frames". So, it starts with KLKG G 3 A_Pain, then, after 3 tics, it goes to KLKG G A_PlaySound, and so on. Of course, this can be stopped if something happenend in between, eg. actor died. Check this page which describes states, these are very important information for anyone wishing to make own monsters.Hidden Hands wrote:I was a little worried that putting the playsound code next to the reflecting code would cause conflicting errors. Sorry I just like to make sure everything is being done right. Thank you for the advice I'll try to experiment more but I like to be careful.ramon.dexter wrote:Hidden hands, you hsould think a little, also, you should undersfand what you are doing. You have to put the blocking sound where the blocking action occurs.
Thank you I'll do this as soon as I get home. Will this make the sound play everytime they are hit or only when blocking? How does it know? Thank you again.krokots wrote:Inside the "Pain" state:Code: Select all
Pain: KLKG G 3 A_Pain KLKG G 3 A_PlaySound("MySounds/Block", CHAN_WEAPON) KLKG H 6 A_SetReflectiveInvulnerable KLKG H 15 A_CentaurDefend KLKG A 1 A_UnsetReflectiveInvulnerable Goto See
-
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
Re: Making a monster that blocks attacks?
So what's my solution then? Surely there's a way to make that sound play only when they are blocking the bullets?krokots wrote:This will be played everytime this monster enters "Pain" state. You need to understand DECORADE code a little bit more, basicly, If an actor enters a state (say, Pain state), it will run through all the functions from top to bottom. Well, they are called "frames". So, it starts with KLKG G 3 A_Pain, then, after 3 tics, it goes to KLKG G A_PlaySound, and so on. Of course, this can be stopped if something happenend in between, eg. actor died. Check this page which describes states, these are very important information for anyone wishing to make own monsters.Hidden Hands wrote:I was a little worried that putting the playsound code next to the reflecting code would cause conflicting errors. Sorry I just like to make sure everything is being done right. Thank you for the advice I'll try to experiment more but I like to be careful.ramon.dexter wrote:Hidden hands, you hsould think a little, also, you should undersfand what you are doing. You have to put the blocking sound where the blocking action occurs.
Thank you I'll do this as soon as I get home. Will this make the sound play everytime they are hit or only when blocking? How does it know? Thank you again.krokots wrote:Inside the "Pain" state:Code: Select all
Pain: KLKG G 3 A_Pain KLKG G 3 A_PlaySound("MySounds/Block", CHAN_WEAPON) KLKG H 6 A_SetReflectiveInvulnerable KLKG H 15 A_CentaurDefend KLKG A 1 A_UnsetReflectiveInvulnerable Goto See
-
- 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?
What are you asking for? The solution for your request is already there, alongside the explanation, how decorate works. What is your question now.?
I understand that you better ask five times for something. But now, you have everything you asked for...
I understand that you better ask five times for something. But now, you have everything you asked for...
-
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
Re: Making a monster that blocks attacks?
The ricochet sound doesn't only play when the monster blocks, it plays whenever the monster enters a pain state. This makes no sense. It should only play when the bullet hits the blades it is blocking with.ramon.dexter wrote:What are you asking for? The solution for your request is already there, alongside the explanation, how decorate works. What is your question now.?
I understand that you better ask five times for something. But now, you have everything you asked for...
-
- Posts: 296
- Joined: Tue Jan 19, 2010 5:07 pm
Re: Making a monster that blocks attacks?
You did put the block inside Pain state, so that's where the sound plays. So what type of block you want to make? When is the block is supposed to happen?
1) Block always when enters pain state (like Centaurs) - the code is already here
2) Block sometimes when enters pain state - you need to put a random chance inside pain state, that will change the state to, eg. "block" state. That will be a separate state you need to define.
But I say I'm a bit confused by your answers.
1) Block always when enters pain state (like Centaurs) - the code is already here
2) Block sometimes when enters pain state - you need to put a random chance inside pain state, that will change the state to, eg. "block" state. That will be a separate state you need to define.
But I say I'm a bit confused by your answers.