Take the DarkDoomZ flashlight with ACS?

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!)
User avatar
Enjay
 
 
Posts: 26403
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Take the DarkDoomZ flashlight with ACS?

Post by Enjay »

When working on a map that has a section which plunges the player into darkness at a particular point, I noticed that using TakeInventory in ACS to take away the DarkDoomZ flashlight (version 1.9b I think) left it active (with no way to switch it off) if the player had the flashlight switched on when the script took it. i.e. there was still a dynamic light attached to the player after the inventory item had gone.

Is there any way to take this item away from the player and have its effects (i.e. the beam of light) deactivated at the same time?

I'd prefer to do it from the ACS side, but I'm happy to add something to the ZScript if that can address it.
Jarewill
Posts: 1326
Joined: Sun Jul 21, 2019 8:54 am

Re: Take the DarkDoomZ flashlight with ACS?

Post by Jarewill »

I don't know if ACS can find the flashlight spotlight actors and remove them, but if you don't mind altering ZScript code, you can add this to the flashlight item:

Code: Select all

    override void DetachFromOwner() {
        if(SelfLight1) { SelfLight1.Destroy(); }
        if(SelfLight2) { SelfLight2.Destroy(); }
        super.DetachFromOwner();
    }
The flashlight item is called DarkDoomZ_Flashlight, so you will need to put that snippet somewhere inside the class definition.
For example, this was put at the very end, after ToggleActive function definition:
User avatar
Enjay
 
 
Posts: 26403
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Take the DarkDoomZ flashlight with ACS?

Post by Enjay »

Thank you kindly. Nice clear instructions and it does the job perfectly. :thumb:

Return to “Scripting”