How to use "SecActEnter" correctly?

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, 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.
Post Reply
User avatar
crowbars82
Posts: 40
Joined: Sun Nov 05, 2017 6:22 pm
Contact:

How to use "SecActEnter" correctly?

Post by crowbars82 »

Hi,

I've Googled as much as I can, but I think I'm now more confused...

Goal: To create a sector that when walked into by the player will trigger a script. The maps are randomly generated.

Effort for far: I have in my maps an actor with custom number 9769 defined within the DECORATE like so:

Code: Select all

ACTOR ScriptFireTester : SecActEnter 9769
{
	Radius 4
	Height 4
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1 ACS_ExecuteAlways(32452, 0)
		TNT1 A -1
		Stop
	}
}
I have attempted to use the inheritance of the SecActEnter, but I think I am doing this incorrectly.

I know that the SecActEnter thing is number "9998", but if I want to have more than one I assume using inheritance is required?

I am hoping for when the player walks into a sector with this actor inside it, the actor will trigger script number "32452".

I have been able to fire the script using "SetLineSpecial (4510, ACS_Execute, 32452);" within an OPEN script, after setting a line to number "4510" in the maps, but the use of "SecActEnter" has me confused.

Code: Select all

Script 32452 (void)
{
    Print(s:"TEST SCRIPT ACTIVATED");
}
Please can anyone suggest where I may be going wrong with this, or if there is a better method to have a script trigger when the player walks into a sector?

Many thanks!
User avatar
Kappes Buur
 
 
Posts: 4182
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: How to use "SecActEnter" correctly?

Post by Kappes Buur »

ActorEntersSector is a thing with number 9998, so there is no DECORATE involved.
Simply place the thing and attach the script to it

Image

Image
User avatar
crowbars82
Posts: 40
Joined: Sun Nov 05, 2017 6:22 pm
Contact:

Re: How to use "SecActEnter" correctly?

Post by crowbars82 »

Thanks Kappes Buur, the problem that I have is that I am randomly generating maps (my project is a mod for the Oblige level generator) into a Wad. I am not building maps by hand so cannot manually link a script to the ActorEntersSector thing.

I can get the generator to add things to a map, but I have not found a way to link a script to a thing during generation.

I am wondering if there is a way to be able to use DECORATE to create a new thing, but to inherit the functionality of thing 9998 doing something like this:

Code: Select all

ACTOR ScriptFireHeal : SecActEnter 9769
Understandably this this is quite an odd/unique situation where other methods are required for this to work.

Please let me know if this doesn't make any sense and I will try to provide more information!

Much thanks!
User avatar
Kappes Buur
 
 
Posts: 4182
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: How to use "SecActEnter" correctly?

Post by Kappes Buur »

Even if such a specific generator were possible, what would determine into which sectors to place it and which action to take?

As far as I can see, you will have to let Oblige create the levels and after that you have to go in and place the AES things manually to perform the specific task. That being said, it would not hurt to ask andrewj if he were willing to tackle such a generator.
User avatar
crowbars82
Posts: 40
Joined: Sun Nov 05, 2017 6:22 pm
Contact:

Re: How to use "SecActEnter" correctly?

Post by crowbars82 »

So this is how things work currently...

Within the Oblige Prefab.LUA I have a prefab:
Image

and in the X_Doom2.LUA it is defined as:
Image

and in the Builder.LUA a change of tag for this specific prefab happens:
Image

the prefab then generates into maps randomly like so:
Image

where line_type 274 is a walk over once execute script and the line is tagged as 4510:
Image

then once the map is run, an OPEN script sets the line_special for all lines 4510:
Image

which then finally allows each and every line tagged with 4510 to execute script number 4511 - spawn an imp behind the player for a surprise!
Image


What I should really do is learn more LUA to program Oblige to be able to add defined actors into the maps and get them to link to a script number, or even have defined TIDs, however I often find work-arounds to things.
The version of Oblige I am modding is quite old now, but I have managed to get quite far with my project so far...
jdagenet
Posts: 77
Joined: Tue Aug 09, 2011 10:26 pm

Re: How to use "SecActEnter" correctly?

Post by jdagenet »

crowbars82 wrote:I can get the generator to add things to a map, but I have not found a way to link a script to a thing during generation.
By giving it a TID, you can use SetThingSpecial to assign a script to it once it has been spawned in the world.
User avatar
crowbars82
Posts: 40
Joined: Sun Nov 05, 2017 6:22 pm
Contact:

Re: How to use "SecActEnter" correctly?

Post by crowbars82 »

Due to a few restrictions on how the Oblige generator code works and my current inability to properly code some new functionality for adding TIDs to actors during generation... I've finally worked out a slightly different method for a new custom trigger plate!

First I have a prefab coded in the prefab.LUA like so:
Image

then it is referenced in the xdoom2.LUA like this:
Image

at the top of the xdoom2.LUA the thing is defined here:
Image

Oblige then generates the thing inside the prefabs into the maps successfully:
Image

then within the DECORATE file I have 2 custom actors:
Image

and:
Image

so when the player 'bumps' into this invisible thing, a script is fired off:

Code: Select all

script 4511 (void)
{	
	//change the player TID to '0' because Project Brutality changes the player TID to '800' for NET reasons(?)
	SetActivator(0, AAPTR_PLAYER1);
	
	int x = GetActorX (0);
	int y = GetActorY (0);
	int z = GetActorZ (0) + 4.0;
	int angle = GetActorAngle (0);
	int spawnX = x + cos (angle + 0.50) * 64;
	int spawnY = y + sin (angle + 0.50) * 64;
	
	delay(35);
	
	int UniqueWandererTID = UniqueTID();
	//print(s:"UniqueWandererTID = ", d:UniqueWandererTID);
	Spawn ("WanderingSpawnLoc", spawnX, spawnY, z, UniqueWandererTID);
	
	delay(70);
	
	int IMPspawnX = GetActorX (UniqueWandererTID);
	int IMPspawnY = GetActorY (UniqueWandererTID);
	int IMPspawnZ = GetActorZ (UniqueWandererTID) + 4.0;
	int UniqueImpTID = UniqueTID();
	//print(s:"UniqueImpTID = ", d:UniqueImpTID);
	Spawn ("TeleportFog", IMPspawnX, IMPspawnY, IMPspawnZ);
	Spawn ("DoomImp", IMPspawnX, IMPspawnY, IMPspawnZ, UniqueImpTID);
	Thing_Remove(UniqueWandererTID);
	Thing_Hate(UniqueImpTID, 0, 0);
}
The idea is that when the player triggers the script, I found that sometimes the Imps that were spawning sometimes got stuck in the walls!
So to improve on this, with some help from Arctangent's post, the script will spawn an invisible wandering actor who will potter around for a short while, and then the Imp is spawned at the wanderer's X,Y,Z before the wanderer is removed.

Allowing the spawns to have their own unique TIDs allows several spawns to happen in succession (if several trigger-plates happen to spawn near each other), and they are easy to reference in the script.

Thanks to all for your suggestions with all this! :D
Post Reply

Return to “Mapping”