[ZSCRIPT] How do I make a monster that gibs itself & explodes when it touches a living Actor?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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!)
Post Reply
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

[ZSCRIPT] How do I make a monster that gibs itself & explodes when it touches a living Actor?

Post by yum13241 »

+TOUCHY won't really work as that would make the monster die from falling 1 unit, which while hilarious, is not what I want. I want it to gib itself and cause splash damage. (using A_Explode)

How can I tell when this monster touches a living Actor?

(The monster is a suicide bomber)
Okgo5555
Posts: 89
Joined: Thu Mar 23, 2017 11:18 am

Re: [ZSCRIPT] How do I make a monster that gibs itself & explodes when it touches a living Actor?

Post by Okgo5555 »

Basically, make his melee state jump to a Xdeath or custom death state that spawns a rocket explosion something like

Code: Select all

...
 Melee:
	POSS C 1
goto XDeath
...

  XDeath:
    POSS M 5
    POSS N 5 A_XScream
    MISL B 8 Bright A_Explode
    MISL C 6 Bright
    MISL D 4 Bright
    Stop
...    
You can make it fancier with SpawnItemEX and make a new actor that is the actual explosion if you want. This essentially gets you what you are looking for. I would change the monster's melee range to something short like 32.
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: [ZSCRIPT] How do I make a monster that gibs itself & explodes when it touches a living Actor?

Post by yum13241 »

My suicide bomber isn't damaging the player. (This is all ZScript)

SShotgunGuy:
Spoiler:


SuicdeBomb:
Spoiler:


BaseMonster:
Spoiler:


BaseActor:
Spoiler:


BaseProjectile:
Spoiler:


What's going on? I spawn the explosion 5 units away from the zombie, and telefrag the player if they get in its way. Why am I taking almost no damage?
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: [ZSCRIPT] How do I make a monster that gibs itself & explodes when it touches a living Actor?

Post by Player701 »

I think you need to add NoDelay to the state where you make the A_Explode call since it is technically the first state your actor enters, and functions in the first state are not called by default. E.g.

Code: Select all

Death:
    MISL B 8 NoDelay Bright A_Explode;
    ...
Note that you could just put the "Spawn:" label directly above "Death:", it'll work the same, no need for the "Goto Death"+"Stop" part.
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: [ZSCRIPT] How do I make a monster that gibs itself & explodes when it touches a living Actor?

Post by yum13241 »

Thanks, I forgot about that Doom-ism.
Post Reply

Return to “Scripting”