Home » SIRTECH CLASSICS » Jagged Alliance: Unfinished Business » Vanilla Modding » Sun goggles and laser scope bonuses
Sun goggles and laser scope bonuses[message #102231] Sun, 04 September 2005 11:26 Go to next message
Snap is currently offline Snap

 
Messages:286
Registered:September 2000
Location: USA (by way of the Old Wo...
Sun goggles extend the visual range in bright sunlight. It would make sense if they also reduced the visual range at night!

DistanceVisible opplist.cpp(1101) -- in Madd Mugsy's version
else if (bLightLevel > NORMAL_LIGHTLEVEL_DAY + 5)
{
	// Snap: penalise for wearing sun goggles
	if (pSoldier->inv[HEAD1POS].usItem == SUNGOGGLES || pSoldier->inv[HEAD2POS].usItem == SUNGOGGLES)
	{
		// decrease sighting distance by up to 2 tiles
		sDistVisible -= STRAIGHT_RATIO;
		if (bLightLevel > NORMAL_LIGHTLEVEL_NIGHT)
		{
			sDistVisible -= STRAIGHT_RATIO;
		}
	}
Did you know that sun goggles also act as a miniature sniper scope? They reduce the effective range by 10%. However, the code likewise doesn't check for lighting conditions. Here is a correction:

CalcChanceToHitGun Weapons.cpp(3121) -- in Madd Mugsy's version
// Snap: check the light level when calculating a bonus due to sun goggles or laser scope
// NB: Higher is darker!
UINT8 bLightLevel = LightTrueLevel(sGridNo, pSoldier->bTargetLevel);

if ( (pSoldier->inv[HEAD1POS].usItem == SUNGOGGLES || pSoldier->inv[HEAD2POS].usItem == SUNGOGGLES)
	&& bLightLevel < (NORMAL_LIGHTLEVEL_NIGHT + NORMAL_LIGHTLEVEL_DAY)/2 )  // Snap
{
	// decrease effective range by 10% when using sungoggles (w or w/o scope)
	iSightRange -= iRange / 10;	//basically, +1% to hit per every 2 squares
}
Further in the CTH calculation for guns, there is this comment left by developers:

// laser scope isn't of much use in high light levels; add something for that

This was never done, so I went ahead and added code that reduces the bonus depending on the target brightness, as well as range (can't see the dot very well at long ranges).

This needs to be double-checked and tested!

CalcChanceToHitGun Weapons.cpp(3171) -- in Madd Mugsy's version
bAttachPos = FindAttachment( pInHand, LASERSCOPE );
if (usInHand == ROCKET_RIFLE || usInHand == AUTO_ROCKET_RIFLE || bAttachPos != NO_SLOT) // rocket rifle has one built in
{
	// Snap: Reduce laser scope bonus at long ranges and high light levels
	// #define NORMAL_RANGE ... world units considered an 'avg' shot

	if (iSightRange <= NORMAL_RANGE) {
		// No penalty within this range
		iScopeBonus = LASERSCOPE_BONUS;
	}
	else {
		// Figure out max. visible distance for the laser dot.
		// Day: 1.5*NORMAL_RANGE, night: 2.5*NORMAL_RANGE
		// iMaxLaserRange = NORMAL_RANGE * ( 1.5 + ( bLightLevel - NORMAL_LIGHTLEVEL_DAY )
		//                               / ( NORMAL_LIGHTLEVEL_NIGHT - NORMAL_LIGHTLEVEL_DAY ) )
		// (bLightLevel was calculated above for sun goggles)
		INT32 iMaxLaserRange = ( NORMAL_RANGE*( 2*bLightLevel + 3*NORMAL_LIGHTLEVEL_NIGHT - 5*NORMAL_LIGHTLEVEL_DAY ) )
		                     / ( 2 * ( NORMAL_LIGHTLEVEL_NIGHT - NORMAL_LIGHTLEVEL_DAY ) );

		// Beyond NORMAL_RANGE laser bonus drops linearly to 0
		iScopeBonus = ( LASERSCOPE_BONUS * (iMaxLaserRange - iSightRange) )
		            / ( iMaxLaserRange - NORMAL_RANGE );
		if (iScopeBonus < 0) iScopeBonus = 0;
	}

	INT8 bLaserStatus;

	if ( usInHand == ROCKET_RIFLE || usInHand == AUTO_ROCKET_RIFLE )
	{
		bLaserStatus = WEAPON_STATUS_MOD(pInHand->bGunStatus);
	}
	else
	{
		bLaserStatus = WEAPON_STATUS_MOD(pInHand->bAttachStatus[ bAttachPos ]);
	}

	// laser scope in bad condition creates aim penalty!
	//   Snap: refactored some ugly code here :)
	iScopeBonus = ( iScopeBonus * (bLaserStatus - 50) ) / 50;

	iChance += iScopeBonus;
}
BTW, earlier in this function I was a bit puzzled by this line:

CalcChanceToHitGun Weapons.cpp(3067)
iSightRange *= 2;
What is the meaning of this? It seems like the distance to target is doubled for some reason. The comment above says "Because we multiply max distance by 2, we must divide by 2 later." I don't think this relates to iSightRange, which BTW is never divided by 2.

Report message to a moderator

Master Sergeant
Re: Sun goggles and laser scope bonuses[message #102232] Fri, 23 September 2005 02:09 Go to previous messageGo to next message
Cal is currently offline Cal

 
Messages:17
Registered:March 2004
Sorry if this is off-topic to your actual question. I know my comment probably doesn't belong here since I'm not involved in this mod, but my QA instinct is kickin' in.

I'm assuming here, that the reduction of the vision is an addition by your coding team?

I'm just wondering at the feasibility of penalizing people for using Night Vision/Sun Goggles at the wrong time of day.

To me, it makes sense that a Merc or soldier would know well enough to at least slide the goggles up to his forehead when the time of day doesn't match.

Worst case scenario, I don't think the AI is set to check whether or not an active soldier is using one of these items. By sheer dumb luck, if you attack a unit at night and half of them have spawned with sun goggles, the AI wouldn't know to take them off and thus they'd be sitting ducks for no good reason?

I'd be interested in hearing how wrong I am!

Report message to a moderator

Private
Re: Sun goggles and laser scope bonuses[message #102233] Fri, 23 September 2005 11:08 Go to previous messageGo to next message
Snap is currently offline Snap

 
Messages:286
Registered:September 2000
Location: USA (by way of the Old Wo...
Cal, you have good points. Sun goggle and NVG penalties might amount to little more than frustration... And I certainly wouldn't want to penalise the unwitting enemy AI. As far as the latter goes, I'll see if I can make automatically generated AI use the right gear for the time of day - that would be an improvement regardless of whether there are penalties.

As for the implementation of penalties, my OP is outdated: currently in the 1.13 mod item bonuses and penalties are no longer hard-coded. They are externalized into easily editable text files, so that you can choose yourself what bonuses or penalties you want to have.

Report message to a moderator

Master Sergeant
Re: Sun goggles and laser scope bonuses[message #102234] Fri, 23 September 2005 15:16 Go to previous messageGo to next message
DurtyDan is currently offline DurtyDan

 
Messages:103
Registered:November 2001
Location: Oregon, USA
Quote:
To me, it makes sense that a Merc or soldier would know well enough to at least slide the goggles up to his forehead when the time of day doesn't match.
I completely agree. It is tedious to move the sunglasses/masks/NVGs/etc around. It would be nice if the bonus would apply automatically, if the item is carried by the merc or in its pocket or bag.

Report message to a moderator

Sergeant
Re: Sun goggles and laser scope bonuses[message #102235] Fri, 23 September 2005 16:42 Go to previous messageGo to next message
Snap is currently offline Snap

 
Messages:286
Registered:September 2000
Location: USA (by way of the Old Wo...
Quote:
Originally posted by DurtyDan:
It would be nice if the bonus would apply automatically, if the item is carried by the merc or in its pocket or bag.
Uh, no, I don't think so. There is more gear than there are head slots, and some gear isn't even compatible (gas masks and sun goggles, for instance). You'll have to decide what to wear.

Report message to a moderator

Master Sergeant
Re: Sun goggles and laser scope bonuses[message #102236] Sat, 24 September 2005 03:57 Go to previous messageGo to next message
lynxlynxlynx is currently offline lynxlynxlynx

 
Messages:109
Registered:September 2005
Location: Slovenija
mhm, like weapon sets in icewind dale. Now that'd be cool. Can't imagine an easy way to implement it though. :/

Report message to a moderator

Sergeant
Re: Sun goggles and laser scope bonuses[message #102237] Sat, 24 September 2005 08:52 Go to previous messageGo to next message
Cal is currently offline Cal

 
Messages:17
Registered:March 2004
Frankly, it just sounds like it'd be easier to leave it as "If daytime, apply bonuses. If not, nothing."

Report message to a moderator

Private
Re: Sun goggles and laser scope bonuses[message #102238] Tue, 11 October 2005 23:24 Go to previous messageGo to next message
Skyrage is currently offline Skyrage

 
Messages:16
Registered:April 2004
Location: Sweden
Was wondering if it'd be possible to have some option in the menu which would have the game automatically equip the best items for the current situation? Maybe have a popup asking the player before combat starts whether he'd want to automatically equip/change items which fit the current conditions?

Report message to a moderator

Private
Re: Sun goggles and laser scope bonuses[message #102239] Wed, 12 October 2005 18:45 Go to previous messageGo to next message
Snap is currently offline Snap

 
Messages:286
Registered:September 2000
Location: USA (by way of the Old Wo...
Nah, too much work for too little benefit. (That's my personal take - if someone else feels like doing it, they are welcome.)

Report message to a moderator

Master Sergeant
Re: Sun goggles and laser scope bonuses[message #102240] Thu, 13 October 2005 11:59 Go to previous messageGo to next message
KIA is currently offline KIA

 
Messages:92
Registered:November 2002
Location: Virginia (USA)
Hello??? Hotkeys! Said it before... Smile

Report message to a moderator

Corporal 1st Class
Re: Sun goggles and laser scope bonuses[message #102241] Sun, 16 October 2005 14:15 Go to previous messageGo to next message
Kaiden is currently offline Kaiden

 
Messages:502
Registered:September 2003
KIA, Volunteering to code it?

Report message to a moderator

First Sergeant

Re: Sun goggles and laser scope bonuses[message #102242] Thu, 01 December 2005 10:48 Go to previous message
ghost16825 is currently offline ghost16825
Messages:2
Registered:December 2005
How about:

(On moving to enemy territory)

if (is_daytime == TRUE) {
//do nothing
}

else {
if (has_night_googles == TRUE) {
put night googles on, put sun googles in empty slot

else {
if (merc_has_empty_slot == TRUE) {
put sun googles in empty slot
}
}

Report message to a moderator

Civilian
Previous Topic: Compiling and debugging the C++ project
Next Topic: Wishlist stuff
Goto Forum:
  


Current Time: Sun Jan 05 00:34:36 GMT+2 2025

Total time taken to generate the page: 0.01393 seconds