An object checking when a olayer is within it's collision box constantly

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
XLightningStormL
Posts: 394
Joined: Mon May 09, 2016 1:38 am
Location: Anywhere but here
Contact:

An object checking when a olayer is within it's collision box constantly

Post by XLightningStormL »

I'm aware of CanCollideWith and CollidedWith; but the issue is that they are one and done affairs if the player stands still within them, what I need is a way to check when the player is within that collided objects collision box constantly - even when standing still, say like Half-Life 1's Alien Healing Pools

Alternatively if this system is too scawy or too hard; A way for said objects Tick() function to get access to a players' inventory (said to check for a health bonus) for the purposes of an increased tick delay or whatever in conjunction with A_RadiusGive, though I'd theoretically imagine such a way may even be harder.
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: An object checking when a olayer is within it's collision box constantly

Post by Kzer-Za »

Maybe, make the said object a non-moving projectile and override its SpecialMissileHit? The wiki article https://zdoom.org/wiki/SpecialMissileHit has an example. If only player needs to be affected, check

Code: Select all

if (victim is PlayerPawn)
User avatar
phantombeta
Posts: 2175
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: An object checking when a olayer is within it's collision box constantly

Post by phantombeta »

Actors don't check for collision if they're not moving. You'll have to do collision checks manually if you want something like this, either by iterating over the players array, or by using a function like TryMove. (Iterating over the players array and doing bounding box checks manually is generally going to be both more reliable and cheaper, though)
XLightningStormL
Posts: 394
Joined: Mon May 09, 2016 1:38 am
Location: Anywhere but here
Contact:

Re: An object checking when a olayer is within it's collision box constantly

Post by XLightningStormL »

This isn't a problem anymore. Ended up getting what I wanted with a BlockThingsIterator in an overridden Tick() void.
Post Reply

Return to “Scripting”