Spawn decorations depending of texture

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!)
Post Reply
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Spawn decorations depending of texture

Post by Apeirogon »

Essence is simple, after loading map run acs/event/etc which randomly jump on map floor/wall/ceiling check what texture and what dimension of plane with this texture and spawn at this point some decorations.
Like, if it meet computer texture at wall it spawn broken computer part near it, if meet guts/flesh texture spawn eye, if blood pool spawn bloody skeleton, if acid pool spawn bleached to blindingly white skeleton, if fire pool roasted skeleton, if default floor texture gnawed skeleton... skeleton, skeleton everywhere.

But I dont know how make acs/event/etc. radomply pick points on map. How make it?
User avatar
krokots
Posts: 266
Joined: Tue Jan 19, 2010 5:07 pm

Re: Spawn decorations depending of texture

Post by krokots »

It seems it could be made in ZScript.

1) Spawn Actor somewhere (in some random coordinates)
2) Get this actor current sector (CurSector)
3) Get this sector floor texture (native TextureID GetTexture(int pos) from mapdata.txt)
and I don't know how this function works - what is this "pos". I see there is some Enum in there, maybe floor = 0, ceiling = 1. You need to test it.
4) Change this actor sprite to some sprite depending on the texture gotten from function
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: Spawn decorations depending of texture

Post by Gutawer »

ZScript is definitely the way to do it, but there's a better approach than spawning actors randomly - you can iterate through the sectors (level.sectors) and lines (level.lines) to check their textures directly, then spawn stuff depending on the texture. You can see an example of this in the Joy of Mapping 5's weather system - viewtopic.php?f=42&t=58528.
Post Reply

Return to “Scripting”