Change who can activate a line?

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
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Change who can activate a line?

Post by Enjay »

I have a map (UDMF) where a line on the front of a door only has a tag at map startup. An ACS script gives the line a special to run a script. Later on, a different script changes the line to a normal door type.

Here's my issue. When the script is first allocated to the line, I only want the player to be able to activate the script; it flashes lights, plays sounds, puts a message up and spawns things. I definitely do not want any enemies triggering that.

However, once the door is "fixed" (i.e. becomes just a normal door) I want anyone to be able to activate it: players or enemies.

In Hexen mode this was easy because of the lax activation types. If a script was set to be run by the player, monsters wouldn't run it; however, as soon as it became a door, monsters can activate those even if they are not explicitly allowed to do so. No special handling required.

I am aware that I can set lax activation via mapinfo, but I don't want it to apply across the whole map, just on certain doors.

What's the best way to go about dealing with this?

Thanks.
User avatar
22alpha22
Posts: 303
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: Change who can activate a line?

Post by 22alpha22 »

If your player(s) have a unique TID not shared by any monters, you can have the script check the TID of what activated it and if it is not a player who activated it, then the script simply terminates.

Code: Select all

Script "Your_Script_Name" (void)
{
    If (ActivatorTID() == PlayerTID)
     {
         Do stuff...
     }
     Else
     {
         Terminate;
     }
}
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Change who can activate a line?

Post by Blue Shadow »

Could it be that you want [wiki]SetLineActivation[/wiki]?
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Change who can activate a line?

Post by Enjay »

Thanks for the suggestion 22alpha22 (and in this case, the player does already have a tid) but SetLineActivation is exactly what I'm looking for. Thanks. :)
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Change who can activate a line?

Post by Enjay »

Supplementary question:
Wiki wrote: SPAC_MUse — Activated by monsters using it.
SPAC_MPush — Activated by monsters bumping into it.
I went for SPAC_MUse. It works but I wonder what, if any, difference there is in the above two. As far as I know, monsters don't have the ability to actively [use] a line (maybe they do?). So, is SPAC_MUse the usual "door opens when monster is near" and perhaps for SPAC_MPush the monster actually has to make contact with the line?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Change who can activate a line?

Post by Graf Zahl »

Pushing includes being pushed onto the trigger by external force - using requires active involvement.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Change who can activate a line?

Post by Enjay »

Graf Zahl wrote:using requires active involvement.
That's the part that's confusing me: unless active involvement simply means walking towards the trigger when we are dealing with monsters.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Change who can activate a line?

Post by Graf Zahl »

Yes, monsters can *actively* trigger a door when approaching it. But they can also be pushed against the door by a rocket blast, which would be a 'passive' trigger. What's so confusing?
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Change who can activate a line?

Post by Enjay »

Nothing now. :)

I just wasn't sure if a monster walking towards a door (etc) counted as an active engagement with the trigger.
Post Reply

Return to “Scripting”