Make player immune to damage during scripted events

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!)

Make player immune to damage during scripted events

Postby AshHouswares » Thu Jun 16, 2022 1:28 pm

How can I make the player immune to damage during a scripted event? The player freezes while the event is happening but is still being harmed by monsters while its happening. Doesnt seem fair design. Is their a good fix maybe a player property or something?
User avatar
AshHouswares
Online Requirements can Go To Hell
 
Joined: 03 Jun 2022
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Not Listed

Re: Make player immune to damage during scripted events

Postby Jarewill » Thu Jun 16, 2022 2:11 pm

The simplest way to do it would be to use GiveInventory and TakeInventory to add and remove the PowerInvulnerable to/from the player.
You could also create a custom powerup inheriting from PowerInvulnerable to prevent the player from losing invulnerability if they had it before the cutscene started.
Jarewill
 
Joined: 21 Jul 2019

Re: Make player immune to damage during scripted events

Postby Enjay » Thu Jun 16, 2022 2:26 pm

There is also SetPlayerProperty, though the invulnerability property there has been deprecated (but it still works) and, even better, SetActorProperty which is now the supported way to do it.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Make player immune to damage during scripted events

Postby Jarewill » Thu Jun 16, 2022 2:29 pm

Ah, I skimmed through the wiki page for SetActorProperty in search for a way to set invulnerability, but I guess I must have missed it.
As Enjay said, using SetActorProperty to set APROP_Invulnerable is the best way to do it in this case.
Jarewill
 
Joined: 21 Jul 2019


Return to Scripting

Who is online

Users browsing this forum: Jimmy and 1 guest