Home » PLAYER'S HQ 1.13 » JA2 Complete Mods & Sequels » Stracciatella Project (Platform Independent JA2) » [Mod] Recruit Maria using the Playable Characters Mod
[Mod] Recruit Maria using the Playable Characters Mod[message #318099] Sat, 27 April 2013 19:02 Go to next message
mgl is currently offline mgl

 
Messages:255
Registered:December 2007
Location: France
This mod/patch makes stracciatella set a foot in the Playable Characters Mod.

It's still against Tron's original JA2-Stracciatella code. I think I will use Gennady's JA2-Stracciatella Continued in the future but it will take me hours before I am able to move all my patches/mods there. It means several months of ja2 time.

Maria is the only character I made available from the PCM. I don't plan to do the others but if someone wants to do them, this mod/patch is a good start.


There are two steps to follow:

1- Make the data files from the PCM pack compatible with straciatella.
Most of my time was spent on this task.
You need SoX for the sound files.

2- Patch the code.

Report message to a moderator

Master Sergeant
Re: [Mod] Recruit Maria using the Playable Characters Mod[message #318100] Sat, 27 April 2013 19:04 Go to previous messageGo to next message
mgl is currently offline mgl

 
Messages:255
Registered:December 2007
Location: France
First part: Make the data files from the PCM pack compatible with straciatella.

A pain to write.

First you need to download a Playable Characters Mod (PCM) pack and uncompress it. I got mine from kermi's archive *looking for a link*. I don't remember which one I downloaded, there are several of them.

Then this shell script below will fetch the files about Maria from the PCM pack, convert them to lower case and convert the sound files to a format compatible with what stracciatella can play, using the sox package, and put them in the "data" folder where the game is installed. So you need SoX on your computer, its soxi program more precisely.

fetch_maria.sh:
#! /bin/sh
#
# This script uses sox

$(which soxi > /dev/null)
if [ $? -ne 0 ]; then
	echo "Error: this script requires the sox program to work."
	exit 2
fi

if [ $# -ne 2 ]; then
	echo Usage:
	echo $0 source_data_root_dir dest_data_root_dir
	echo Copy files from the PCM mod pack and convert them to lower case
	echo "source_data_root_dir = case-sensitive path to the data folder in the mod pack E.g /tmp/PCM/data"
	echo "dest_data_root_dir = path to the data folder on your system e.g \$HOME/ja2/data"
	exit 1
fi

# Path to the root folders (remove trailing '/')
src_data=$(echo $1 | sed -e 's#/$##')
dst_data=$(echo $2 | sed -e 's#/$##')

# Exit if the source root dir doesn't exist
if (! test -d $src_data); then
	echo "Error: Source data tree \"$src_data\" doesn't exist."
	exit 2
fi

# Exit if the destination root dir doesn't exist
# It should be where the game data is installed system-wide
# or the user's root dir for ja2
if (! test -d $dst_data); then
	echo "Error: destination root tree \"$dst_data\" doesn't exist."
	exit 2
fi

audio_count=0
ms_count=0

for src_file in $(find $src_data -iname '*88*'); do
	# Build the destination file name
	# And convert it to lower case
	tmp=$(echo $src_file | sed -e s#$src_data#$dst_data#)
	dst_file=$(echo $tmp | tr [:upper] [:lower])

	# Create the destination folder if it doesn't exist
	dst_dir=$(dirname $dst_file)	
	(! test -d $dst_dir) && (mkdir --parents $dst_dir || exit 2)

	# Copy the file
	#
	
	encoding=$(soxi -V0 -e $src_file)
	if test $? -ne 0; then
		# the file is not a sound file. Copy it
		cp -a --force $src_file $dst_file || exit 2
		echo $dst_file
	else
		# Sound file.
		audio_count=$(expr $audio_count + 1)
		# Convert it to IMA ADPCM if it is a MS ADPCM encoding
		if test "$encoding" = "MS ADPCM"; then
			ms_count=$(expr $ms_count + 1)
			sox -V0 $src_file -e ima-adpcm $dst_file || exit 2
			echo "$dst_file converted to ima-adpcm encoding"
		else
			# copy it
			cp -a --force $src_file $dst_file || exit 2
			echo $dst_file
		fi
	fi
done


echo "
Success"
echo "$ms_count / $audio_count audio files were converted from Microsoft ADPCM encoding."


Give this scrip execution rights
$ chmod +x fetch_maria.sh


Run it with the right parameters.
It needs the case-sensitive path to the "data" folder in the PCM pack.
And the case-sensitive path to the "data" folder where you installed your ja2 data files.
In my case I downloaded the PCM pack to "$HOME/ja2/mods/PCM" and it unpacked a "pcm/data" folder there.
And my destination folder is "$HOME/ja2/install/data". It's the folder you put in your "ja2.ini" file needed to play stracciatella with "data" appended to it.
$ ./fetch_maria.sh $HOME/games/ja2/mods/PCM/pcm/data $HOME/games/ja2/install/data


The script should give you an output like:
Success
56 / 64 audio files were converted from Microsoft ADPCM encoding.


Then the data is ready to be used by stracciatella.

Report message to a moderator

Master Sergeant
Re: [Mod] Recruit Maria using the Playable Characters Mod[message #318101] Sat, 27 April 2013 19:05 Go to previous messageGo to next message
mgl is currently offline mgl

 
Messages:255
Registered:December 2007
Location: France
Second part: Update the source code for the mod.

The diff file for this mod assumes that the Consistency Fix for the Maria Quest patch has been applied. Apply it first if you need to.


This is the diff file for the mod:

recruit_maria.diff:
Index: Build/Tactical/Interface_Dialogue.cc
===================================================================
--- Build/Tactical/Interface_Dialogue.cc	(revision 7072)
+++ Build/Tactical/Interface_Dialogue.cc	(working copy)
@@ -2497,6 +2497,9 @@
 						TriggerNPCRecord( MARIA, 10 );
 					}
 				}
+				/* mgl: Recruit Maria using PCM data */
+				gMercProfiles[MARIA].ubBodyType = REGFEMALE;
 				break;
 
 			case NPC_ACTION_ANGEL_LEAVES_DEED:

Index: Build/Strategic/StrategicMap.cc
===================================================================
--- Build/Strategic/StrategicMap.cc	(revision 7072)
+++ Build/Strategic/StrategicMap.cc	(working copy)
@@ -1089,10 +1089,22 @@
 	if (sector == SEC_C6 && gubQuest[QUEST_RESCUE_MARIA] == QUESTDONE)
 	{
 		// make sure Maria and Angel are gone
-		gMercProfiles[ MARIA ].sSectorX = 0;
+		
+		/* mgl: Recruit Maria using PCM data
+		 * Maria could be elsewhere, waiting to be recruited.
+		 * Don't change her coordinates if she's not here and don't change them
+		 * if she's here in the player's team.
+		 * We simply look at her body type: if it's a fighting body type
+		 * then she is available as a merc.
+		 */
+		if (gMercProfiles[MARIA].ubBodyType != REGFEMALE)
+		{
+			gMercProfiles[ MARIA ].sSectorX = 0;
+			gMercProfiles[ MARIA ].sSectorY = 0;
+		}
+		
+		gMercProfiles[ ANGEL ].sSectorX = 0;
 		gMercProfiles[ ANGEL ].sSectorY = 0;
-		gMercProfiles[ MARIA ].sSectorX = 0;
-		gMercProfiles[ ANGEL ].sSectorY = 0;
 	}
 
 	if (sector == SEC_D5)

Index: Build/Strategic/Strategic_Merc_Handler.cc
===================================================================
--- Build/Strategic/Strategic_Merc_Handler.cc	(revision 7072)
+++ Build/Strategic/Strategic_Merc_Handler.cc	(working copy)
@@ -36,11 +36,44 @@
 #include "Soldier_Macros.h"
 #include "Finances.h"
 #include "Quests.h"
+#include "Animation_Data.h" /* mgl: Recruit Maria using PCM data */
 
 
 #define		NUM_DAYS_TILL_UNPAID_RPC_QUITS				3
 
 
+static void HandleMariaAsRPC()
+{
+	/* mgl: Recruit Maria using "Playable Characters Mod" (PCM) data
+	 * If her quest is done (she must be alive then), we use a daily update function
+	 * to prepare her to be added in Omerta, A10, starting the following day of her quest.
+	 */
+	if (   (gubQuest[QUEST_RESCUE_MARIA] == QUESTDONE)
+	    && (!(gMercProfiles[MARIA].ubMiscFlags & PROFILE_MISC_FLAG_RECRUITED))
+	   )
+	{
+		MERCPROFILESTRUCT& maria = GetProfile(MARIA);
+		
+		// Tell the game not to use her profile from a map (I think it's already done).
+		maria.ubMiscFlags3 |= PROFILE_MISC_FLAG3_PERMANENT_INSERTION_CODE;
+		maria.fUseProfileInsertionInfo = TRUE;
+
+		// Give her a fighting body type.
+		maria.ubBodyType = REGFEMALE;
+		
+		// Set her near the rebels' house in A10
+		maria.sSectorX = 10;
+		maria.sSectorY = MAP_ROW_A;
+		maria.ubStrategicInsertionCode = INSERTION_CODE_GRIDNO;
+		maria.usStrategicInsertionData = 7897;
+ 		
+		// Make her stationary
+		SOLDIERTYPE* const s = FindSoldierByProfileID(MARIA);
+		if (s && (s->bLife >= OKLIFE)) { s->bOrders = STATIONARY; }
+	}
+}
+
+
 void StrategicHandlePlayerTeamMercDeath(SOLDIERTYPE& s)
 {
 	UINT32 const now = GetWorldTotalMin();
@@ -356,6 +383,9 @@
 
 	HandleSlayDailyEvent();
 	ReBuildCharactersList();
+ 	
+	/* mgl: Recruit Maria using PCM data */
+	HandleMariaAsRPC();
 }
 
 
Index: Build/TacticalAI/NPC.cc
===================================================================
--- Build/TacticalAI/NPC.cc	(revision 7072)
+++ Build/TacticalAI/NPC.cc	(working copy)
@@ -627,6 +627,19 @@
 	SOLDIERTYPE const* const s = FindSoldierByProfileID(ubNPC);
 	if (!s) return 0;
 
+	/* mgl: Recruit Maria using PCM (Playable Characters Mod) data
+	 * When approached to be recruited, her lines are either that she's eager to meet her brother
+	 * or that she fears guns. We don't bother triggering them and recruit her without speech. 
+	 */
+	if (ubNPC == MARIA
+	    && gMercProfiles[MARIA].ubBodyType == REGFEMALE
+	    && approach == APPROACH_RECRUIT
+	    && gubQuest[QUEST_RESCUE_MARIA] == QUESTDONE)
+	{
+		RecruitRPC(MARIA);
+		return 0;
+	}
+
 	if (ppResultQuoteInfo) *ppResultQuoteInfo = 0;
 	if (pubQuoteNum)       *pubQuoteNum       = 0;
 

The last, empty line is required, it's an important context line for the "patch" program.

Go to the root folder of the source code, save the diff file "recruit_maria.diff" there and patch the code:
patch -p0 < recruit_maria.diff

The patch program may complain but work because the line numbers don't match yours. It's because I have other mods/patches in the same files that I removed to create the diff file for this mod.


Recompile.

Report message to a moderator

Master Sergeant
Re: [Mod] Recruit Maria using the Playable Characters Mod[message #318102] Sat, 27 April 2013 19:06 Go to previous messageGo to next message
mgl is currently offline mgl

 
Messages:255
Registered:December 2007
Location: France
The files from the PCM pack do mostly everything with Maria. Of course I didn't know because I'm unable to understand them and I overdid her when I started coding.

The only things required were to give her a fighting body type, which is done in the conversation with her brother when you complete her quest, and stop the code from constantly trying to remove her from San Mona when her quest is done.

When you complete her quest, she will join your team with no code required (I couldn't even succesfully write code to prevent her from joining). If you don't want her, you must quickly go to the strategic screen and move your mercs to another sector from there.

If she doesn't join right after her quest is done, or if you already rescued her in your current game, one of the daily update functions will add her with a fighting body type the next day at Omerta A10 on a hardcoded gridno near the place where Dimitri is when you first meet him. Use the dialogue box to recruit her. Since she only answers that she fears guns or wonders about her brother or something like that when you click "recruit", I made her join without talking.

Maria is a great merc ... compared to Shank.
She has no trait in the PCM pack I took.
The funny part with her is that Kingpin's boys will attack you in San Mona if you come with her.

Report message to a moderator

Master Sergeant
Re: [Mod] Recruit Maria using the Playable Characters Mod[message #329772] Tue, 14 January 2014 23:47 Go to previous message
Jakub is currently offline Jakub

 
Messages:40
Registered:January 2014
Maria ? Not Tina Elzan ?

Report message to a moderator

Corporal
Previous Topic: High resolutions support added
Next Topic: JA2-Stracciatella Q&A
Goto Forum:
  


Current Time: Fri Mar 29 07:15:24 GMT+2 2024

Total time taken to generate the page: 0.00877 seconds