Home » MODDING HQ 1.13 » v1.13 General Development Talk » HAM SVN
Re: HAM SVN[message #255713] Thu, 08 July 2010 10:59 Go to previous messageGo to previous message
silversurfer

 
Messages:2793
Registered:May 2009
@Headrock

Got me! Wink

Of course I had to alter the code because it wouldn't work right away. I had to adjust references and perform some additional checks.


@Dieter

Thank you for that info. It showed me some things which I needed to improve. First thing - it didn't show hidden attachments like the Rod&Spring and Trigger Group. I removed that check. Second - it only showed one ACOG 4x scope and not scope and combo. I don't know why. Their short names are not the same. :headscratch:
Also I used the short attachment name at first but decided to switch to long names now.

I corrected the issues and this is what it shows for the HK 416 14":

http://img340.imageshack.us/img340/4183/screen006l.th.jpg


It works in strategic as well as tactical screen and yes, the list shows when the mouse arrow is over an empty slot. Occupied slots will show the attachments name.

It only works with weapons and "BOBBY_RAY_TOOLTIPS_SHOW_POSSIBLE_ATTACHMENTS" has to be TRUE. Otherwise it will just show the default "Attachment".


Here is the code just in case that anybody is interested in it:

In "Ja2_Options.ini" add a new parameter in section [Item Property Settings]:

WEAPONS_SHOW_POSSIBLE_ATTACHMENTS = TRUE

The default is TRUE.

In "GameSettings.h" insert new line 808:

BOOLEAN fWeaponsShowPossibleAttachments;	// shows possible attachments when moving mouse over empty attachment slot in inventory screen



In "GameSettings.cpp" insert the following lines (I have them at 1200 to 1201):

// Weapons show possible attachments?
gGameExternalOptions.fWeaponsShowPossibleAttachments	= iniReader.ReadBoolean("Item Property Settings", "WEAPONS_SHOW_POSSIBLE_ATTACHMENTS", TRUE);



In "Tactical\Interface Items.cpp" insert between line 3350 and 3352:

// Variables for "Possible Attachment List"
BOOLEAN		fAttachmentsFound = FALSE;
// Contains entire string of attachment names
CHAR16		attachStr[3900];
// Contains current attachment string
CHAR16		attachStr2[80];
UINT16		usAttachment;

swprintf( attachStr, L"" );
swprintf( attachStr2, L"" );
	if (gGameExternalOptions.fWeaponsShowPossibleAttachments)
{
	// Generate list of possible attachments to a gun (Guns only!)
	if ( Item[ pObject->usItem ].usItemClass==IC_GUN || Item[ pObject->usItem ].usItemClass==IC_LAUNCHER)
	{
		// Check entire attachment list
		UINT16 iLoop = 0;
	while( 1 )
		{
			usAttachment = Attachment[iLoop][0];
			// Does this fit on the weapon?
			if ( ValidAttachment( usAttachment, pObject->usItem ))
			{
				// If the attachment is not in the list yet
				if ( wcsstr(attachStr,Item[usAttachment].szLongItemName) == NULL)
				{
					if (wcslen( attachStr ) + wcslen(Item[usAttachment].szLongItemName) > 3800)
					{
						// End list early to avoid stack overflow
						wcscat( attachStr, L"
..." );
						break;
					}
					else
					{
						// Add the attachment's name to the list.
						if (!fAttachmentsFound)
							// add a header to the list
							swprintf( attachStr, L"Possible Attachments:
 
" );
						fAttachmentsFound = TRUE;
						swprintf( attachStr2, L"
%s", Item[usAttachment].szLongItemName );
						wcscat( attachStr, attachStr2);
					}
				}
			}
			iLoop++;
			if (Attachment[iLoop][0] == 0)
			{
				// Reached end of list
				break;
			}
		}
	}
}
	
// If no attachment was found set the string to the default text
if (!fAttachmentsFound)
	wcscat( attachStr, Message[ STR_ATTACHMENTS ]);

It runs through all attachments and checks if they can be attached to the weapon. The name of every valid attachment is appended to the string "attachStr". If no attachment is found "attachStr" will be set to the default text "Attachment".


Replace line 3385 with this one:
SetRegionFastHelpText( &(gItemDescAttachmentRegions[ cnt ]), attachStr );

Depending on a valid attachment found this is where the default string or the attachment list is displayed ingame.


For me this is a temporary solution. NAS can do this even better because it shows which slots are available for a certain weapon and when hovering the mouse over a certain slot it shows what can be attached there. Unfortunately the source for NAS is not available and I doubt that it will be in the near future. I just didn't want to wait any longer.


edit: changed the code a bit and added a separate ini setting.

[Updated on: Mon, 12 July 2010 22:12] by Moderator

Report message to a moderator

Lieutenant
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Matchsight, making gun worse?
Next Topic: How do I re pack tileset.slf
Goto Forum:
  


Current Time: Sun May 05 16:10:03 GMT+3 2024

Total time taken to generate the page: 0.03633 seconds