Home » PLAYER'S HQ 1.13 » JA2 Complete Mods & Sequels » Stracciatella Project (Platform Independent JA2) » [Patch] Armour attachments
[Patch] Armour attachments[message #235213] Thu, 15 October 2009 23:37
mgl is currently offline mgl

 
Messages:255
Registered:December 2007
Location: France
Provided that you are able to build the stracciatella executable yourself, this patch will allow you to store items on your kevlar or spectra armour at no AP cost:

- either sun goggles or night goggles or UV goggles on the helmet (mimic 1.13 ?)
- a camo kit, canteen and either a gas mask or sun goggles on the leggings

Everything at no AP cost in turn-based mode, like for moving items in your inventory. A side effect of the no AP cost is that attaching ceramic plates or treat your armor in turn-based mode won't cost you any AP either. But who does that while fighting ?

The sun goggles / night goggles / gas mask combinations should let you use one on them on your face and store the two others on your armor. Conflicting items are automatically swapped when clicked. For instance if you open the helmet's detailed description box with attached sun goggles while your mouse pointer holds night goggles, the items will be swapped when you will click on any slot.

To run the patch, save the contents of the quoted text below in a an "armour_attachments.diff" file, cd in the root directory of stracciatella and run:
patch -p0 < armour_attachments.diff
(the "patch" program should be available on any GNU machine that you had to set up to compile stracciatella).
Then build the executable.


armour_attachments.diff:
Index: Build/Tactical/Interface_Items.cc
===================================================================
--- Build/Tactical/Interface_Items.cc	(revision 7055)
+++ Build/Tactical/Interface_Items.cc	(working copy)
@@ -2125,8 +2125,14 @@
 		// require as many APs as to reload
 		if ( gpItemPointer != NULL )
 		{
+			/* mgl: Armour attachments
+			 * mgl: You don't need to have enough APs
+			 * mgl: to attach things to armour.
+			 */
+			INT16 ap_cost = (gpItemDescObject && Item[gpItemDescObject->usItem].usItemClass == IC_ARMOUR)
+			                ? 0 : AP_RELOAD_GUN;
 			// nb pointer could be NULL because of inventory manipulation in mapscreen from sector inv
-			if ( !gpItemPointerSoldier || EnoughPoints( gpItemPointerSoldier, AP_RELOAD_GUN, 0, TRUE ) )
+			if ( !gpItemPointerSoldier || EnoughPoints( gpItemPointerSoldier, ap_cost, 0, TRUE ) )
 			{
 				if ( (Item[ gpItemPointer->usItem ].fFlags & ITEM_INSEPARABLE) && ValidAttachment( gpItemPointer->usItem, gpItemDescObject->usItem ) )
 				{
@@ -2140,7 +2146,13 @@
 		else
 		{
       // ATE: Make sure we have enough AP's to drop it if we pick it up!
-			if ( EnoughPoints( gpItemDescSoldier, ( AP_RELOAD_GUN + AP_PICKUP_ITEM ), 0, TRUE ) )
+			/* mgl: Armour attachments
+			 * mgl: You don't need to have enough APs
+			 * mgl: to detach things from armour.
+			 */
+			INT16 ap_cost = (gpItemDescObject && Item[gpItemDescObject->usItem].usItemClass == IC_ARMOUR)
+			                ? 0 : AP_RELOAD_GUN + AP_PICKUP_ITEM;
+			if (EnoughPoints(gpItemDescSoldier, ap_cost, 0, TRUE ))
 			{
 				// Get attachment if there is one
 				// The follwing function will handle if no attachment is here
@@ -2662,7 +2674,16 @@
 	// check for any AP costs
 	if ( ( gTacticalStatus.uiFlags & TURNBASED ) && ( gTacticalStatus.uiFlags & INCOMBAT ) )
 	{
-		if (gpAttachSoldier)
+		/* mgl: Armour attachments
+		 * mgl: Test on the item class of the object ("gpItemDescObject") added.
+		 * mgl: If it's an armour, no AP cost.
+		 * mgl: I want the armor to work like an inventory slot
+		 * mgl: and let the player freely move items to and out of it.
+		 */
+		if (gpAttachSoldier
+		    && gpItemDescObject
+		    && Item[gpItemDescObject->usItem].usItemClass != IC_ARMOUR 
+		   )
 		{
 			// check for change in attachments, starting with removed attachments
 			fAllFound = TRUE;
Index: Build/Tactical/Items.cc
===================================================================
--- Build/Tactical/Items.cc	(revision 7055)
+++ Build/Tactical/Items.cc	(working copy)
@@ -706,6 +706,69 @@
 	{CHEWING_GUM,			FUMBLE_PAK},
 	{BATTERIES,				XRAY_DEVICE},
 	{COPPER_WIRE,			LAME_BOY},
+
+	/* mgl: Armour attachments 
+	 * mgl: night_goggles xor UV_goggles xor sun_goggles -> helmet
+	 * mgl: camo kit, canteen ->leggings
+	 * mgl: gas_mask xor sun_goggles -> leggings
+	 * mgl: regen booster xor adrenaline booster -> leggings
+	 * mgl: 7.62 NATO 5 clips -> helmet for fun
+	 */
+	{CAMOUFLAGEKIT,	KEVLAR_LEGGINGS},
+	{CAMOUFLAGEKIT,	KEVLAR_LEGGINGS_18},
+	{CAMOUFLAGEKIT,	KEVLAR_LEGGINGS_Y},
+	{CAMOUFLAGEKIT,	SPECTRA_LEGGINGS},
+	{CAMOUFLAGEKIT,	SPECTRA_LEGGINGS_18},
+	{CAMOUFLAGEKIT,	SPECTRA_LEGGINGS_Y},
+	{CANTEEN,	KEVLAR_LEGGINGS},
+	{CANTEEN,	KEVLAR_LEGGINGS_18},
+	{CANTEEN,	KEVLAR_LEGGINGS_18},
+	{CANTEEN,	SPECTRA_LEGGINGS},
+	{CANTEEN,	SPECTRA_LEGGINGS_18},
+	{CANTEEN,	SPECTRA_LEGGINGS_Y},
+	{GASMASK,	KEVLAR_LEGGINGS},
+	{GASMASK,	KEVLAR_LEGGINGS_18},
+	{GASMASK,	KEVLAR_LEGGINGS_Y},
+	{GASMASK,	SPECTRA_LEGGINGS},
+	{GASMASK,	SPECTRA_LEGGINGS_18},
+	{GASMASK,	SPECTRA_LEGGINGS_Y},
+	{SUNGOGGLES,	KEVLAR_LEGGINGS},
+	{SUNGOGGLES,	KEVLAR_LEGGINGS_18},
+	{SUNGOGGLES,	KEVLAR_LEGGINGS_Y},
+	{SUNGOGGLES,	SPECTRA_LEGGINGS},
+	{SUNGOGGLES,	SPECTRA_LEGGINGS_18},
+	{SUNGOGGLES,	SPECTRA_LEGGINGS_Y},
+	{SUNGOGGLES,	KEVLAR_HELMET},
+	{SUNGOGGLES,	KEVLAR_HELMET_18},
+	{SUNGOGGLES,	KEVLAR_HELMET_Y},
+	{SUNGOGGLES,	SPECTRA_HELMET},
+	{SUNGOGGLES,	SPECTRA_HELMET_18},
+	{SUNGOGGLES,	SPECTRA_HELMET_Y},
+	{NIGHTGOGGLES,	KEVLAR_HELMET},
+	{NIGHTGOGGLES,	KEVLAR_HELMET_18},
+	{NIGHTGOGGLES,	KEVLAR_HELMET_Y},
+	{NIGHTGOGGLES,	SPECTRA_HELMET},
+	{NIGHTGOGGLES,	SPECTRA_HELMET_18},
+	{NIGHTGOGGLES,	SPECTRA_HELMET_Y},
+	{UVGOGGLES,	KEVLAR_HELMET},
+	{UVGOGGLES,	KEVLAR_HELMET_18},
+	{UVGOGGLES,	KEVLAR_HELMET_Y},
+	{UVGOGGLES,	SPECTRA_HELMET},
+	{UVGOGGLES,    	SPECTRA_HELMET_18},
+	{UVGOGGLES,    	SPECTRA_HELMET_Y},
+	{CLIP762N_5_AP, KEVLAR_HELMET},
+	{CLIP762N_5_AP, KEVLAR_HELMET_18},
+	{CLIP762N_5_AP, KEVLAR_HELMET_Y},
+	{CLIP762N_5_AP, SPECTRA_HELMET},
+	{CLIP762N_5_AP, SPECTRA_HELMET_18},
+	{CLIP762N_5_AP, SPECTRA_HELMET_Y},
+	{CLIP762N_5_HP, KEVLAR_HELMET},
+	{CLIP762N_5_HP, KEVLAR_HELMET_18},
+	{CLIP762N_5_HP, KEVLAR_HELMET_Y},
+	{CLIP762N_5_HP, SPECTRA_HELMET},
+	{CLIP762N_5_HP, SPECTRA_HELMET_18},
+	{CLIP762N_5_HP, SPECTRA_HELMET_Y},
+
 	{0, 0}
 };
 
@@ -875,6 +938,14 @@
 	{ 0,								0							 }
 };
 
+/* mgl: Armour attachments
+ * mgl: static variable to store the attach position in the armour
+ * mgl: with which the item on the mouse pointer must be swapped.
+ * mgl: The swap works as long as there are at most 3 items on the armour piece.
+ */
+static INT8 armour_attach_swap = ITEM_NOT_FOUND;
+
+
 BOOLEAN ItemIsLegal( UINT16 usItemIndex )
 {
 	//if the user has selected the reduced gun list
@@ -1385,6 +1456,9 @@
 	BOOLEAN		fSameItem = FALSE, fSimilarItems = FALSE;
 	UINT16		usSimilarItem = NOTHING;
 
+	/* mgl: Armour attachments: clear swap variable */
+	armour_attach_swap = ITEM_NOT_FOUND;
+
 	if ( !ValidAttachment( usAttachment, pObj->usItem ) )
 	{
 		// check for an underslung grenade launcher attached to the gun
@@ -1471,6 +1545,32 @@
 				fSameItem = TRUE;
 			}
 			break;
+
+		/* mgl: Armour attachments
+		 * mgl: To express that:
+		 * mgl: 1) the helmet can store only one of the 3 goggles,
+		 * mgl: 2) sun goggles conflict with a gas mask on the leggings,
+		 * mgl: we write that any face item excludes the others.
+		 * mgl: We also store the slot
+		 * mgl: where the conflicting item was found
+		 * mgl: so that the caller swaps them.
+		 */
+		case GASMASK:
+		case UVGOGGLES:
+		case NIGHTGOGGLES:
+		case SUNGOGGLES:
+			armour_attach_swap = FindAttachmentByClass(pObj, IC_FACE);
+			break;
+		/* mgl: Armour attachments
+		 * mgl: 7.62N AP/HP clips on the helmet exclude each other.
+		 */
+		case CLIP762N_5_AP:
+		case CLIP762N_5_HP:
+			usSimilarItem = (usAttachment == CLIP762N_5_AP)
+			                ? CLIP762N_5_HP : CLIP762N_5_AP;
+			armour_attach_swap = FindAttachment(pObj,
+			                                    usSimilarItem);
+			break;
 	}
 
 	if (fAttemptingAttachment)
@@ -2421,13 +2521,26 @@
 				INVTYPE const& tgt_item = Item[target.usItem];
 				SoundID const  sound    =
 					tgt_item.usItemClass & IC_WEAPON ? ATTACH_TO_GUN         :
+					/* mgl: Armour attachments
+					 * mgl: Disable the (never heard) sound
+					 * mgl: of ceramic plates
+					 */
+					#if 0
 					tgt_item.usItemClass & IC_ARMOUR ? ATTACH_CERAMIC_PLATES :
+					#endif
 					tgt_item.usItemClass & IC_BOMB   ? ATTACH_DETONATOR      :
 					NO_SOUND;
 				if (sound != NO_SOUND) PlayLocationJA2Sample(s->sGridNo, sound, MIDVOLUME, 1);
 			}
 		}
 
+		/* mgl: Armour attachments
+		 * mgl: Request to swap items if needed 
+		 */
+		if (armour_attach_swap != ITEM_NOT_FOUND)
+		{ 	attach_pos = armour_attach_swap;
+		}
+		
 		UINT16 const temp_item   = target.usAttachItem[attach_pos];
 		UINT16 const temp_status = target.bAttachStatus[attach_pos];
 


This patch was done against subversion release 7055 of stracciatella.

--------
Edit 2009-10-25:
Fixed: Although it didn't cost any AP to attach or detach items from armour, you couldn't do it if you had 5 APs or less.
Oops: I let the small 7.62 NATO clips be an attachment for the helmet in this fix. It's for fun only, it doesn't work: attach a clip with 1 bullet, detach it and you get a full clip!

[Updated on: Sun, 25 October 2009 22:09] by Moderator

Report message to a moderator

Master Sergeant
 
Read Message
Previous Topic: A PowerPC port was already released?
Next Topic: 0.11 800x600 binaries
Goto Forum:
  


Current Time: Sun Jan 12 11:26:22 GMT+2 2025

Total time taken to generate the page: 0.01001 seconds