Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
DFF

ACS Quick Help: Item counter for a door/monster spawns

Recommended Posts

Hey, making a small quickie map but i'm not quite sure how to proceed with the main script for them map.

 

The main goal is for the player('s, but can be made for solo for now) to collect 7 keys (different keys, not all the same) to open a door, and what i want to happen is when a player picks up a key, it spawns a dummy prop of the key by the door (I can do this), however i want certain monsters to spawn when any amount of the 7 keys are collected (at 2, 4 and 7 keys per se) and for a door to open when all 7 are collected (instantly, not by player pressing use).

I'm not terribly great at acs scripting currently, but what would the best way to setup this counter system? would giving the player an inventory item like "collectedkeys" be helpful (given when any key is picked up)? if its co-op could you set it up so it checks all players inventory for a sum of 7?

 

any help would be appreciated.

Share this post


Link to post

Since you're using ACS, you can make a variable for that. Declare the variable outside any script or function, and it will be a map-scope variable, available to all scripts and functions in that map. Every time a player gets any key, add 1 to that variable. Have a script keep looking at that variable and do its thing when the variable reaches the desired number.

 

Refer to https://zdoom.org/wiki/ACS for explanations of what does what and how to do stuff, and ask questions here or in the ZDoom forums when you need more help.

Share this post


Link to post

To be more specific with an example, you'd do something like this:

 

Spoiler

int keysTaken = 0;

script 1 (void)
{
	if(keysTaken >= 7)
	{
		// DOOR OPEN STUFF
	}
	else if(keysTaken == 6)
	{
		// ACTIONS WHEN 6 KEYS ARE TAKEN
	}
	else if(keysTaken == 5)
	{
		// ACTIONS WHEN 5 KEYS ARE TAKEN
	}
	
	etc...
}

script 2 (void)
{
	keysTaken++;
	ACS_Execute(1, 0);
	
	// ACTIONS SPECIFIC WHEN TAKING KEY #1
}

script 3 (void)
{
	keysTaken++;
	ACS_Execute(1, 0);
	
	// ACTIONS SPECIFIC WHEN TAKING KEY #2
}

etc...

 

 

Share this post


Link to post

Thanks for both of the pointers, i'll see if i can make those work to my effect.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×