Home » MODDING HQ 1.13 » v1.13 Coding Talk » New Stealth Mechanics
New Stealth Mechanics[message #297174] Tue, 24 January 2012 07:56 Go to next message
Teh_Az
Messages:2
Registered:December 2011
A friend of mine is working on some new stealth mechanics for JA inspired by Splinter Cell, Metal Gear, and Assassin's Creed. Any ideas? So far he's been able to build some shadow mechanics but so far the sprites disappear once they leave the shadows. It isn't graphical, just the crunch, but pretty soon we're hoping to implement moving with your back against the wall and peering behind corners and so forth. Oh, and yeah, stealth kills and backstabs.
Re: New Stealth Mechanics[message #297177] Tue, 24 January 2012 11:37 Go to previous messageGo to next message
The_Bob

 
Messages:405
Registered:May 2009
Location: Behind you.
Any details? JA2 already supports most of that. I wrote a silent kill mod some time back too - look in the real time sneaking thread - basically it didn't interrupt realtime if you knifed an enemy without being spotted.

Anyhow, make sure to post the code, regardless of whether you get anywhere or not - in case you get bored with the project or hit by a truck (which happens a lot to JA2 coders) someone might be interested in continuing what you started.

Re: New Stealth Mechanics[message #297212] Wed, 25 January 2012 02:41 Go to previous messageGo to next message
Teh_Az
Messages:2
Registered:December 2011
I'm getting the code from my friend as we speak. The problem I'm getting here is that he says he finds it easier to mess around with vanilla than with 1.13. Egads.
Re: New Stealth Mechanics[message #297352] Fri, 27 January 2012 19:41 Go to previous messageGo to next message
RoWa21

 
Messages:2039
Registered:October 2005
Location: Austria
Teh_Az
The problem I'm getting here is that he says he finds it easier to mess around with vanilla than with 1.13. Egads.


Thats not good if he makes those changes to the vanilla source code, because it will be a pain for us to integrate that in the 1.13 source code.
Tell your friend he should download (with TortoiseSVN) the latest 1.13 source code from here:
https://ja2svn.dyndns.org/source/ja2/branches/Wanne/JA2%201.13%20MP/Build


Re: New Stealth Mechanics[message #339993 is a reply to message #297352] Tue, 10 March 2015 16:21 Go to previous messageGo to next message
sevenfm

 
Messages:1634
Registered:December 2012
Location: Soviet Russia
Don't want to make a new thread, so will use this dead one instead :-)

A small IDEA/REQUEST

Currently, <StealthBonus> tag in items.xml works both for night camo and noise reduction when moving.
So we cannot make armour with good night camo without giving it big noise stealth bonus.
Is it possible to separate them, so we have <StealthBonus> for noise reduction (or negative value which will produce additional noise when moving), and <NightCamo> only for cover (sight reduction at low light or cover penalty for lasers, for example) ?

[Updated on: Tue, 10 March 2015 16:22]




7609+fix | 7609+AI (r750) | 7609 unofficial modpack | Win8+ fix | Experimental project | Vengeance:Reloaded | Youtube

"I like sharks. They're soothing"


Re: New Stealth Mechanics[message #339994 is a reply to message #339993] Tue, 10 March 2015 16:43 Go to previous messageGo to next message
silversurfer

 
Messages:2372
Registered:May 2009
Stealth is not night camo. There is no "night camo". Stealth a general reduction in possibility of being spotted or heard. That's why it takes precedence over any camo type.



Wildfire Maps Mod 6.07 on SVN: https://ja2svn.mooo.com/source/ja2/branches/Wanne/JA2%201.13%20Wildfire%206.06%20-%20Maps%20MOD

Re: New Stealth Mechanics[message #339995 is a reply to message #339994] Tue, 10 March 2015 16:49 Go to previous messageGo to next message
sevenfm

 
Messages:1634
Registered:December 2012
Location: Soviet Russia
silversurfer wrote on Tue, 10 March 2015 19:43
Stealth is not night camo. There is no "night camo". Stealth a general reduction in possibility of being spotted or heard. That's why it takes precedence over any camo type.


Stealth from equipment works the same way as camo bonus for calculating cover (sight reduction), but only in low light.
So it's exactly a night camo.

	// general stuff (independant of soldier)
	iSightAdjustment += GetSightAdjustmentThroughStance( bStance );

	// context sensitive (needs soldier)
	iSightAdjustment += GetSightAdjustmentBasedOnLBE( pSoldier );

	// context sensitive stuff with 2nd parameter (needs soldier for attributes but can be given a second parameter)
	iSightAdjustment += GetSightAdjustmentThroughMovement( pSoldier, pSoldier->bTilesMoved, ubLightLevel );
	iSightAdjustment += GetSightAdjustmentStealthAtLightLevel( pSoldier, ubLightLevel );

	if(gGameExternalOptions.fAdditionalTileProperties)
	{
		iSightAdjustment += GetDetailedSightAdjustmentCamouflageOnTerrain( pSoldier, bStance, zGivenTileProperties );
	}
	else
	{
		iSightAdjustment += GetSightAdjustmentCamouflageOnTerrain( pSoldier, bStance, ubTerrainType );
	}

[Updated on: Tue, 10 March 2015 16:53]




7609+fix | 7609+AI (r750) | 7609 unofficial modpack | Win8+ fix | Experimental project | Vengeance:Reloaded | Youtube

"I like sharks. They're soothing"


Re: New Stealth Mechanics[message #340001 is a reply to message #339995] Tue, 10 March 2015 19:48 Go to previous messageGo to next message
silversurfer

 
Messages:2372
Registered:May 2009
Stealth works also during the day. That's why I wouldn't call it a night camo.



Wildfire Maps Mod 6.07 on SVN: https://ja2svn.mooo.com/source/ja2/branches/Wanne/JA2%201.13%20Wildfire%206.06%20-%20Maps%20MOD

Re: New Stealth Mechanics[message #340002 is a reply to message #340001] Tue, 10 March 2015 19:56 Go to previous messageGo to next message
sevenfm

 
Messages:1634
Registered:December 2012
Location: Soviet Russia
silversurfer wrote on Tue, 10 March 2015 22:48
Stealth works also during the day.


Vision cover (enemy sight reduction) from worn stealth works only at night (only at low light level).
It works this way in the game, and it's the way it implemented in the code.

Let's call it not 'camo', but 'night vision cover'.
And the same tag defines the noise reduction when moving.

So, if the modder wants to make a vest/lbe which is good to take cover in the night (very black), in the result soldier receives huge bonus to stealth movement.
And this modifier can be negative, so if the modder makes a shining bright cap or something that is bad to wear at night, in the result merc starts to produce more noise when moving, even if he is behind the wall and enemy's LOS is blocked.



7609+fix | 7609+AI (r750) | 7609 unofficial modpack | Win8+ fix | Experimental project | Vengeance:Reloaded | Youtube

"I like sharks. They're soothing"


Re: New Stealth Mechanics[message #340006 is a reply to message #340002] Tue, 10 March 2015 21:43 Go to previous messageGo to next message
sevenfm

 
Messages:1634
Registered:December 2012
Location: Soviet Russia
BTW there is funny bug in stealth cover mechanics

INT8 GetSightAdjustmentStealthAtLightLevel( SOLDIERTYPE* pSoldier, const UINT8& ubLightLevel )
{
	if (gGameExternalOptions.ubStealthEffectiveness == 0) {
		return 0;
	}

	// set scaler to scale with light level (dark = 100%)
	UINT8 ubScaler = GetBrightness( ubLightLevel );

	// last term corresponds to the maximum of ubScaler before
	ubScaler *= gGameExternalOptions.ubStealthEffectiveness / 100;

	INT8 ibStealthInPercent = GetStealth( pSoldier );

	return MINMAX100N( - ibStealthInPercent * ubScaler / 100);
}


Wrong integer calculation ubScaler *= gGameExternalOptions.ubStealthEffectiveness / 100; results in no stealth bonus at all when COVER_SYSTEM_STEALTH_EFFECTIVENESS is not 100
;-)



7609+fix | 7609+AI (r750) | 7609 unofficial modpack | Win8+ fix | Experimental project | Vengeance:Reloaded | Youtube

"I like sharks. They're soothing"


Re: New Stealth Mechanics[message #340007 is a reply to message #340006] Tue, 10 March 2015 22:16 Go to previous messageGo to next message
sevenfm

 
Messages:1634
Registered:December 2012
Location: Soviet Russia
Also, it looks like moving in the dark gives more cover penalty than moving in the bright light

INT8 GetSightAdjustmentThroughMovement( SOLDIERTYPE* pSoldier, const INT8& bTilesMoved, const UINT8& ubLightLevel  )
{
	if (gGameExternalOptions.ubMovementEffectiveness == 0) {
		return 0;
	}

	INT8 stealth = GetStealth(pSoldier);

	INT8 bMovementAdjustment = bTilesMoved * ( 100 - stealth ) / 100;

	// SANDRO - added reduction of penalty for moving for Stealthy trait with new traits
	if ( gGameOptions.fNewTraitSystem && HAS_SKILL_TRAIT( pSoldier, STEALTHY_NT ))
		bMovementAdjustment = max(0, (bMovementAdjustment * (100 - gSkillTraitValues.ubSTStealthPenaltyForMovingReduction) / 100) );

	UINT8 ubBrightness = GetBrightness( ubLightLevel );

	return MINMAX100N( bMovementAdjustment * ubBrightness / 100 * gGameExternalOptions.ubMovementEffectiveness / 100 );
}

because GetBrightness( ubLightLevel ); is actually opposite and should be named GetDarkness, because it returns 100% at zero light level.



7609+fix | 7609+AI (r750) | 7609 unofficial modpack | Win8+ fix | Experimental project | Vengeance:Reloaded | Youtube

"I like sharks. They're soothing"


Re: New Stealth Mechanics[message #340017 is a reply to message #340002] Wed, 11 March 2015 13:58 Go to previous messageGo to next message
silversurfer

 
Messages:2372
Registered:May 2009
sevenfm wrote on Tue, 10 March 2015 18:56
silversurfer wrote on Tue, 10 March 2015 22:48
Stealth works also during the day.


Vision cover (enemy sight reduction) from worn stealth works only at night (only at low light level).
It works this way in the game, and it's the way it implemented in the code.

I don't think so. Stealth works even at bright daylight. When you look at the function GetSightAdjustmentStealthAtLightLevel() ubScaler will be 14 at ubLightLevel 3 (normal daylight).
If there wasn't the bug ubScaler would be adjusted to 7 (default stealth effectiveness is 50).
If the soldier had for example 20% stealth, sight adjustment would be -20 * 7 / 100 = 1.

So yes, the bug in GetSightAdjustmentStealthAtLightLevel() should be fixed for stealth to have the proper effect.
Also function GetSightAdjustmentThroughMovement() should be fixed. ubBrightness should be 100 - GetBrightness() so the darker it get the smaller the penalty.



Wildfire Maps Mod 6.07 on SVN: https://ja2svn.mooo.com/source/ja2/branches/Wanne/JA2%201.13%20Wildfire%206.06%20-%20Maps%20MOD

Re: New Stealth Mechanics[message #340025 is a reply to message #340017] Wed, 11 March 2015 21:46 Go to previous messageGo to next message
silversurfer

 
Messages:2372
Registered:May 2009
I commited both fixes in r7780.

Btw. some players may not be aware of the fact that being in the shadows helps stealthy characters from being spotted even during broad daylight. Of course solid cover is always better in terms of bullet protection. ;)



Wildfire Maps Mod 6.07 on SVN: https://ja2svn.mooo.com/source/ja2/branches/Wanne/JA2%201.13%20Wildfire%206.06%20-%20Maps%20MOD

Re: New Stealth Mechanics[message #340026 is a reply to message #340025] Wed, 11 March 2015 22:13 Go to previous message
sevenfm

 
Messages:1634
Registered:December 2012
Location: Soviet Russia
BTW COVER_SYSTEM_MOVEMENT_EFFECTIVENESS description in ja2_options.ini is not 100% correct - if set to 100%, only bTilesMoved is used as % of cover penalty, so 'Running around crazy' is usually no more than 20 tiles which translates to 40 tiles because of running, so COVER_SYSTEM_MOVEMENT_EFFECTIVENESS=100% gives no more than 40% for average 'crazy running' soldier.
And with default value of 20% it's only 8% of cover penalty.
Hope this may be useful for players/modders trying to balance cover system.

Maybe there should be some cover/stealth indicator like in some games. Very hepful for sneaking approach.



7609+fix | 7609+AI (r750) | 7609 unofficial modpack | Win8+ fix | Experimental project | Vengeance:Reloaded | Youtube

"I like sharks. They're soothing"


Previous Topic: Strategic Map load in source code
Next Topic: (New) Common Attachment Framework (new title; was The NAS Receiver)
Goto Forum:
  


Current Time: Sat Sep 22 08:35:44 EEST 2018

Total time taken to generate the page: 0.01545 seconds