Jump to content
  • 0

ACS randomised teleport targets and SAVES


smeghammer

Question

Hi all,

 

I have an ACS routine that on ENTER determines a randomised target sector for a number of teleports; and a script triggered on a number of linedefs to actually teleport. The 80 action special on the relevant linedefs trigger this teleport script with an int (0 to 11) and this represents an array index. This refers to a working array of sector targets that is randomised into `randomIndexAssigned`.

 

This works as intended:

 

int arrayLength = 12;
int randomIndexAssigned[12] = {0,0,0,0,0,0,0,0,0,0,0,0};	//store the teleTargetSector ID index as they are chosen 
script 1 ENTER {
	/* 
	set up random array of teleport target sector IDs:
	*/
	int teleTargetSectors[12] = {1,2,3,4,5,6,7,8,9,10,11,12};
	int assigned = 0;
	
	/* iterate over sector ID array */
	for (int a = 0;a < arrayLength; a++){
		log(i:teleTargetSectors[a]);
		int entryDone = 0;
		while(!(entryDone)){
			/* if it is not already in place, proceed to get it */
			/* so we need to get a RANDOM index of the input and put it at the CURRENT index of the output: */
			int rnd = Random(0,11);
			/* test if this random index has been used already */
			if(!(randomIndexAssigned[rnd])){
				randomIndexAssigned[rnd] = teleTargetSectors[a];
				entryDone = 1;
			}
		}
 	}
}

/* triggered on linedef crossing, teleport to randomised sector assigned to this index: */
script 2 (int target){
	log(s:"triggering teleport at ");
	log(i:target);
	Teleport(0,randomIndexAssigned[target],0);
}

Now, the question I have is this - is there a way to persist the randomised assignment across saves? I could of course assign this script to a W1 linedef action somewhere the player will definitely cross (starting teleport sector lines for example), but them presumably it will not be re-triggered after loading a savegame. 

 

Could I do something with a set of hidden linedefs that could be used to store these values? DO values assigned to linedefs at runtime by an ACS script persist across saves at all?

 

I was planning that the order of visiting the areas reached by the various teleports would not be dependent on an earlier visit to another, so re-ordering the randomised set will not materially matter, but it would be neater if the order was persisted across a save.


 

Edited by smeghammer

Share this post


Link to post

5 answers to this question

Recommended Posts

  • 1

Why don't you store a map-scope variable that indicates whether the random assignment has been initialized already?

Edited by JadingTsunami

Share this post


Link to post
  • 0

I could, but the same question applies - do map-scope variables persist across saves? I may be missing something here of course...

Share this post


Link to post
  • 1
8 minutes ago, smeghammer said:

I could, but the same question applies - do map-scope variables persist across saves? I may be missing something here of course...

 

Yes, they do.

Share this post


Link to post
  • 0

Everything is stored in saves. You don't have to change anything about what you already have and it will still be saved. The enter script won't be rerun on load, and the variables it changed will still remain. 

Edited by Edward850

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...