Sun goggles and laser scope bonuses[message #102231]
|
Sun, 04 September 2005 11:26
|
|
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)
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 #102242]
|
Thu, 01 December 2005 10:48
|
|
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
|
|
|