Jump to content

Adding a PauseGame() in dialogues that include Enemy() for multiplayer games

Recommended Posts

In a normal game, if you have the game set up to pause when you see an enemy, the pause works fine when an NPC turns hostile during a dialogue.  However, it doesn't pause in multiplayer games. I'd like to add a PauseGame() to the end of the action list in these cases.

I can't use a simple search and replace for ~Enemy()~ ~Enemy() PauseGame()~ because it could be inside an ActionOverride.

I'm at a loss on how to accomplish this.  Any ideas?

Link to comment

I guess I can go through all the actions in each file directly without using a normal .d file to update, do some sort of string comparison on each action, then if found, append 'PauseGame()' to the end.

I'll try this.

Link to comment

You could use regular expressions to first deal with ActionOverride, then make a second pass for the rest. Or make your life hard and do both with one complicated expression.

Before reviewing all the changes, of course.

But wait, it this over the whole game or your mod files?

Link to comment
Just now, lynx said:

But wait, it this over the whole game or your mod files?

All dialogue files.

I have it working.  Here's the code:

	// Go through all the dialogue files
	COPY_EXISTING_REGEXP GLOB ~.+\.dlg~ ~override~
		// Go through all the file's actions
		READ_LONG (0x0028) offset_actions
		READ_LONG (0x002c) num_actions
		FOR (idx_action = 0; idx_action < num_actions; ++idx_action) BEGIN
			// Get the start and length of the action string
			READ_LONG (offset_actions + (idx_action * 0x0008)) offset_string 
			READ_LONG (offset_actions + 0x0004 + (idx_action * 0x0008)) len_string

			// Fetch the current action string
			READ_ASCII offset_string cur_string (len_string)
			// See if it contains the word 'Enemy()'
			PATCH_IF ("%cur_string%" STRING_CONTAINS_REGEXP "Enemy()") = 0 BEGIN				
				// Add 'PauseGame()' to the end of the command string
				INSERT_BYTES (offset_string + len_string) 0x000b
				WRITE_ASCII (offset_string + len_string) "PauseGame()"
				// Update the string length in the section header
				WRITE_LONG (offset_actions + 0x0004 + (idx_action * 0x0008)) (len_string + 0x000b)
				// Update all the following string starting positions
				FOR (next_action = (idx_action + 1); next_action < num_actions; ++next_action) BEGIN
					READ_LONG (offset_actions + (next_action * 0x0008)) offset_next
					WRITE_LONG (offset_actions + (next_action * 0x0008)) (offset_next + 0x000b)



Link to comment

Correction: Sort of works - I mean the dialogue files are all updated correctly, however the pause doesn't happen.  The PauseGame() action might not work in dialogues.  I've only used it in scripts before.  So I'll change my code to call a cut scene script that pauses the game instead.  That would work better anyway.  I can test for multiplayer that way.

Link to comment
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...