[Decorate/ZScript] Item that sticks to a door

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [Decorate/ZScript] Item that sticks to a door

Re: [Decorate/ZScript] Item that sticks to a door

by Matt » Tue Jun 04, 2019 9:25 am

The way I've been doing it is kinda brute-force so if anyone's got a better method I'd like to know as well.

1. Get the linedef that got hit.
2. Get the floor and ceiling heights of the sector on the other side.
3. Get whether the actor is under that floor or above that ceiling retrieved in #2.
4. Get the absolute height of the floor/ceiling in question, plus or minus the actor's own Z position, and save it in the actor's variables.
5. From that point on, call SetZ every tick to set the actor's Z position in the position that is equal to the current floor/ceiling height of the opposite sector, plus or minus the stored difference. If at any time this goes above the actor's own ceiling or below its own floor, clear the variable and stop calling SetZ.

Separate checks would be required for if the arrow were to hit the bottom of the door or the top of a platform, but those are simple enough.

Re: [Decorate/ZScript] Item that sticks to a door

by gramps » Mon Jun 03, 2019 10:51 pm

Just spitballing here, but you could try something like this:

- First, make sure the "arrow in wall" actor is actually in the moving sector. Make sure the tip of the arrow sprite is its world origin, and push it forward a little bit when it hits the wall.

- Next, check if it's below the floor or above the ceiling. If it's above the ceiling, it's in a door, and needs to move relative to ceiling. If it's below the floor, it's in a lift, and needs to move relative to floor. If it's between the floor and ceiling, it's probably
on a regular wall, so leave it there and stop here. *

- Store the distance between the arrow and the floor/ceiling, and whether it's in a door or lift. After you've stored it, update the position every tick so that it maintains the same distance to the floor/ceiling. Make it disappear after a while so you don't have too many of them stacking up.

Maybe there are better ways to peg it to a certain distance from floor/ceiling, not sure about that. I think the first step is the key to getting this to work.

* Maybe it's on a blocking midtexture line though, and that could be part of a moving platform. Not sure what to do about that.

[Decorate/ZScript] Item that sticks to a door

by Mere_Duke » Mon Jun 03, 2019 9:40 pm

Hello!
There is a Crossbow weapon in my Decorate. It fires +RIPPER projectiles. When projectile dies (on impact with a wall/floor/ceiling etc.), it spawns a static item representing an "arrow in a wall" prop. When it's stuck in a door (default doom up/down sliding door), the arrow won't move with that door when it opens up; instead, it will hang in air. How should I avoid this behavior? I need either make an arrow to move alongside a door, or make it fall to the ground. Or even stop it from spawning if it hits a door...
Preferably the case where it moves with the door it sticks in.

Flying arrow code:
Spoiler:
Spawned arrow:
Spoiler:

Top