Cockroach effect?
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
-
Enjay
-

- Posts: 27298
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Cockroach effect?
Before I go ahead and make one for myself, does anyone know if there is a cockroach effect out there?
What I'm looking for is something a bit like the Hexen bats - i.e. activate the item and a bunch of cockroaches will spawn, scurry around for a bit and then vanish.
What I'm looking for is something a bit like the Hexen bats - i.e. activate the item and a bunch of cockroaches will spawn, scurry around for a bit and then vanish.
-
neoworm
- Posts: 1751
- Joined: Fri Sep 23, 2005 9:17 am
- Location: Czech Republic
Re: Cockroach effect?
Ashes 2063 have something like that, cocroaches scattering around. I think it uses monster AI with FRIGHTENED tag and despawns after a while. I kinda want something like this for my pack to spawn rats, even have some broken attempt there.
-
Enjay
-

- Posts: 27298
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: Cockroach effect?
Thanks. I'll take a look.
-
AFADoomer
- Posts: 1344
- Joined: Tue Jul 15, 2003 4:18 pm
Re: Cockroach effect?
Here's a version that I put together recently...
Summon the 'RoachSpawner' actor. It's set up to allow you to use arguments to set the number of roaches and spawning radius.
For fun, try 'summon roachspawner 0 0 0 500 64'.
These are best placed in-editor behind closed doors. The roaches all spawn as soon as the map loads, but won't react until they are alerted to the player.
Summon the 'RoachSpawner' actor. It's set up to allow you to use arguments to set the number of roaches and spawning radius.
For fun, try 'summon roachspawner 0 0 0 500 64'.
These are best placed in-editor behind closed doors. The roaches all spawn as soon as the map loads, but won't react until they are alerted to the player.
You do not have the required permissions to view the files attached to this post.
-
Enjay
-

- Posts: 27298
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: Cockroach effect?
Oh wow! That's fantastic. My job today was going to be to look at this, but that file does almost* exactly what I was looking for. Thank you.
*except for the activating it to spawn the roaches, but I can certainly work with this as an alternative.
*except for the activating it to spawn the roaches, but I can certainly work with this as an alternative.
-
Enjay
-

- Posts: 27298
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: Cockroach effect?
Quick question, just to make sure I have got things right, when trying to include the code with a version of 4.7 I got:
The line is:
Actor.isFrozen() didn't work (GZDoom wouldn't start)
So I changed the line to:
That certainly works, in as much as GZDoom starts and the rooaches seem to be doing their thing.
I just want to check that I have done this correctly because my ZScript powers are weak.
Also, to help me understand, what is this line doing? Is it checking to see if a freeze powerup, game pause or similar is active?
Code: Select all
Script warning, "zscript.zs:zscript.zs" line 125:
Accessing deprecated global variable globalfreeze - deprecated since 3.8.0, Use Actor.isFrozen() or Level.isFrozen() insteadCode: Select all
if (IsFrozen() || globalfreeze || health <= 0 || !target) { return;}Code: Select all
Script error, "zscript.zs:zscript.zs" line 125:
Qualified member call to parent class Actor::isFrozen is not yet implementedSo I changed the line to:
Code: Select all
if (IsFrozen() || Level.isFrozen() || health <= 0 || !target) { return;}I just want to check that I have done this correctly because my ZScript powers are weak.
Also, to help me understand, what is this line doing? Is it checking to see if a freeze powerup, game pause or similar is active?
-
AFADoomer
- Posts: 1344
- Joined: Tue Jul 15, 2003 4:18 pm
Re: Cockroach effect?
Sorry, the original code has been migrated across multiple GZDoom versions (originating as DECORATE), so there are some oddities that I missed... That line should just have just been:
IsFrozen() checks Level.IsFrozen() internally, so the second command is redundant here.
You are correct. This Tick function basically says:
- Run the higher-level Actor Tick code
- If the level is frozen, the actor is frozen, the game is paused, or the actor has no health, then stop here
- Otherwise continue on and handle additional movement direction changes and animation
Code: Select all
if (IsFrozen() || health <= 0) { return;}You are correct. This Tick function basically says:
- Run the higher-level Actor Tick code
- If the level is frozen, the actor is frozen, the game is paused, or the actor has no health, then stop here
- Otherwise continue on and handle additional movement direction changes and animation
-
Enjay
-

- Posts: 27298
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: Cockroach effect?
Thanks for the code and the info. I replaced the line and it works just like you said it would. 
[edit]
Actually, I was wondering if it is possible to make it so that only a player can squish the roaches? I've tried them in a few places but on several occasions, if an enemy has been wandering around (I assume that's what has happened) I just find a bunch of squished bugs when I arrive. The other solution/workaround would be for me to disable the ability to squish them all together. I know how to do that, but it is so much more satisfying to be able to crush them beneath my booted heel.
[edit]
Actually, I was wondering if it is possible to make it so that only a player can squish the roaches? I've tried them in a few places but on several occasions, if an enemy has been wandering around (I assume that's what has happened) I just find a bunch of squished bugs when I arrive. The other solution/workaround would be for me to disable the ability to squish them all together. I know how to do that, but it is so much more satisfying to be able to crush them beneath my booted heel.
-
AFADoomer
- Posts: 1344
- Joined: Tue Jul 15, 2003 4:18 pm
Re: Cockroach effect?
Sure!
Replace the +TOUCHY flag with +SOLID, and add this function:
The CanCollideWith function is called when an actor is moving and overlaps with another actor, so this kills the roach when it is on the floor and a player actor moves to overlap with it.
Replace the +TOUCHY flag with +SOLID, and add this function:
Code: Select all
override bool CanCollideWith(Actor other, bool passive)
{
if (passive) // If the check is because of another actor moving into this actor's space
{
if (other.player && pos.z == floorz) // And the other actor is a player and this actor is on the ground
{
// Squish the actor (damage in an amount equal to current health, damagetype of "Squish")
DamageMobj(other, other, health, "Squish", 0, other.angle);
}
}
return true;
}-
Enjay
-

- Posts: 27298
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: Cockroach effect?
Sorry to be obtuse but where should I add that? I've tried several places but each time I get an error and GZDoom can't start: different errors depending on where I put it.
Nevermind. I think I got it. Thanks again.
[edit] and it seems to be doing exactly what was intended.
I *think my earlier problem when I was getting errors was just a copy/paste problem. I think I missed a bit of the code when selecting it. [/edit]
Nevermind. I think I got it. Thanks again.
[edit] and it seems to be doing exactly what was intended.
I *think my earlier problem when I was getting errors was just a copy/paste problem. I think I missed a bit of the code when selecting it. [/edit]
-
AFADoomer
- Posts: 1344
- Joined: Tue Jul 15, 2003 4:18 pm
Re: Cockroach effect?
Glad it worked for you eventually. Just my way of making your ZScript powers stronger. 
-
Enjay
-

- Posts: 27298
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: Cockroach effect?
Believe me, it's needed. 
I think the "problem" is that ZScript is so wide-ranging and powerful - in as much as it opens up many, many genuine programming possibilities for what a modder can do with the engine's capabilities. DECORATE can do that to a certain extent too but, ultimately, most of the time it is just a simple case of a list of actor states with pre-defined pointers attached to each one. ACS also can allow complex stuff but, similarly, most of the time it is just a list of semi-human-readable instructions with an occasional "if" or "while" thrown in there. In other words, both DECORATE and ACS can be engaged with by applying a bit of brute force and some common sense.
ZScript on the other hand requires much more knowledge of the guts of how it works. There was no way, by intuition alone, that I could have figured out how to add the functionality that you posted for the player-only squishing. Sure, I figured out that disabling the +TOUCHY flag would be part of it (i.e. DECORATE-level knowledge), but would not have known where to begin with writing the new function or what or why an "override bool" was the way to go or what it was.
This is not a complaint BTW. ZScript is wonderful and powerful. What modders are doing with it is amazing. However, people with little or no programming experience definitely need a lot more hand-holding while trying to get to grips with it.
So, thank you once again for your input and also the various others that have helped me with my ZScript questions elsewhere. No doubt that there will be more at some point. I'll get there, with help.
I think the "problem" is that ZScript is so wide-ranging and powerful - in as much as it opens up many, many genuine programming possibilities for what a modder can do with the engine's capabilities. DECORATE can do that to a certain extent too but, ultimately, most of the time it is just a simple case of a list of actor states with pre-defined pointers attached to each one. ACS also can allow complex stuff but, similarly, most of the time it is just a list of semi-human-readable instructions with an occasional "if" or "while" thrown in there. In other words, both DECORATE and ACS can be engaged with by applying a bit of brute force and some common sense.
ZScript on the other hand requires much more knowledge of the guts of how it works. There was no way, by intuition alone, that I could have figured out how to add the functionality that you posted for the player-only squishing. Sure, I figured out that disabling the +TOUCHY flag would be part of it (i.e. DECORATE-level knowledge), but would not have known where to begin with writing the new function or what or why an "override bool" was the way to go or what it was.
This is not a complaint BTW. ZScript is wonderful and powerful. What modders are doing with it is amazing. However, people with little or no programming experience definitely need a lot more hand-holding while trying to get to grips with it.
So, thank you once again for your input and also the various others that have helped me with my ZScript questions elsewhere. No doubt that there will be more at some point. I'll get there, with help.