Home » MODDING HQ 1.13 » v1.13 Coding Talk » Real Time Mode Mod
Re: Real Time Mode Mod[message #218616] Mon, 01 June 2009 14:44 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
Making it an option would definitely help, I also plan to implement (maybe with borys762's help) some refinements:
Center the screen on the spotted enemy/merc who spotted the enemy
Slow down game speed by 1/3 (or even more) in the real time sneaking mode (actually make it a mode the game goes into/out of)
Preferably allow this to be turned on/off on per-merc basis rather then for everyone / have an option to limit this to the currently selected merc(s). Maybe add a third state to the sneaking button that triggers this.
Maybe pause the game for 1sec upon spotting the enemy (or slow it down 3/4)

Of course as I am new to this, I don't really know how to (properly) do all these things, so any help is welcome. For starters:
where should I look to add this as an option (to the opts screen/triggered by a hotkey)
how would I go about inserting my events into the flow of things
can real time speed be easily manipulated (or is that broken) ?

Reading through the code I'll eventually find the answers myself but I'd rather spend that time writing code and debugging it.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218670] Mon, 01 June 2009 20:12 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
I've refined this mod a bit:
- toggle RT sneaking on/off (ctrl-shift-x)
- enter turn-based only when you see enemies in real-time (ctrl-x)
- disabled after enemies have been alerted (spotted/loud shots fired)
- added .ini file setting (not tested)


Built on latest HAM3.4 (source included)

Still dunno how to go about the real-time slowdown or make a more elaborate on/off system. Adding new options to the options screen is kinda awkward.

[Updated on: Fri, 04 June 2021 05:32] by Moderator

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218673] Mon, 01 June 2009 20:27 Go to previous messageGo to next message
Shanga is currently offline Shanga

 
Messages:3482
Registered:January 2000
Location: Danubia
PS: The wiki site isn't under my control. No idea who set it up, must be someone from the v1.13 dev team.

Report message to a moderator

Captain
Re: Real Time Mode Mod[message #218675] Mon, 01 June 2009 20:46 Go to previous messageGo to next message
Borys762 is currently offline Borys762

 
Messages:7
Registered:March 2009
Location: Poland
I'm sorry for not replying earlier. I've forgotten absolutely about this project due to work, studying and other life worries Wink Unfortunately, recently I've scratched the sources as well, but retracing back from memory I can tell you I did something similar to Bob's code.

Quote:

if (MercPtrs[gubBestToMakeSighting[ 0 ]]->bTeam == OUR_TEAM)
{
//check if merc is sneaking
if (MercPtrs[gubBestToMakeSighting[ 0 ]]->this->bStealthMode) return; // if so, do nothing
else EnterCombatMode( MercPtrs[gubBestToMakeSighting[ 0 ]]->bTeam ); // if not, showtime
}


It was something as above. Basically it is a sloppy workaround that I tried and surprisingly it worked the way I intended. Bob also added the selection code which I don't know how exactly makes the game behave, but I guess it's another improvement. I found it crucial to check if the merc is sneaking, cause it was the whole point of the mod.

Anyway, I don't know how many bugs this spawns and I can't actually take responsibility for any of them Razz I encourage Bob or anyone interested to continue working with the code and improving it as I am not intending to. With too much stuff going on right now I don't have enough time to play around with it.

@The_Bob
I'm glad you've put effort to improve this feature as I think it really adds to gameplay. As I am not really a skilled/experienced coder (I just did it because nobody else wanted to/would try Razz), I don't think I can help you with anything more, at least not without spending a lot of time studying JA2 source, and unfortunately time is smg I don't have. I wish you the best of luck, feel free to carry on the torch Wink I really hope this feature will be toggable in future releases of 1.13

Report message to a moderator

Private
Re: Real Time Mode Mod[message #218677] Mon, 01 June 2009 21:20 Go to previous messageGo to next message
wanne (aka RoWa21) is currently offline wanne (aka RoWa21)

 
Messages:1961
Registered:October 2005
Location: Austria
it is not included into the svn trunk. Maybe in the near future...

Report message to a moderator

Sergeant Major

Re: Real Time Mode Mod[message #218678] Mon, 01 June 2009 21:24 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
Too bad, I'm not sure if I can go through with this on my own. I'll definitely need tips and pointers from experienced JA2 coders, as well as some support on the mod itself.

Come on people, it's easier then you think - I'm still new at this and the project is just taking off, it's a great opportunity to learn how to hack JA2. One thing for sure is that someone should port the most recent version back to the original 1.13, pretty much a matter of ctrl-c/ctrl-v and building it for all the non-coders out there. Hurry up and jump on before it becomes too complicated !

@anyone with some experience, could you please look through my modifications and tell me if I'm doing it wrong at some point ? I can post the parts I've changed on pastebin if anyone is interested in helping me.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218679] Mon, 01 June 2009 21:26 Go to previous messageGo to next message
Maalstroom is currently offline Maalstroom

 
Messages:340
Registered:December 2008
Location: en route to San Hermanos
"I never think of the future. It comes soon enough." Albert Einstein
for me the future is now!

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218680] Mon, 01 June 2009 21:31 Go to previous messageGo to next message
wanne (aka RoWa21) is currently offline wanne (aka RoWa21)

 
Messages:1961
Registered:October 2005
Location: Austria
I can include this MOD into official 1.13 source code if it is an optional feature (ja2_options.ini or option screen).
I need:

- Source code files (only the ones that are changed) which are currently merged with the latest svn source code (The new HAM 3.x code should not be included)
- Source code should contain a comment with the name of the coder for each code block
- A description how this modification works, keyboard shortcuts, INI settings, ...

You can upload the content as a ZIP-Package or send it to me (wannebox@gmx.at)

[Updated on: Mon, 01 June 2009 21:31] by Moderator

Report message to a moderator

Sergeant Major

Re: Real Time Mode Mod[message #218689] Mon, 01 June 2009 23:38 Go to previous messageGo to next message
Randok is currently offline Randok

 
Messages:321
Registered:March 2004
Quote:
I can include this MOD into official 1.13 source code if it is an optional feature (ja2_options.ini or option screen).

Yes. Please. Smile In option screen.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218690] Mon, 01 June 2009 23:52 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
Randok
Quote:
I can include this MOD into official 1.13 source code if it is an optional feature (ja2_options.ini or option screen).

Yes. Please. Smile In option screen.


Adding things to the option screen is a bit too much of a hassle for now. I'll probably implement that in the next version, you'll have to go with .ini option or activating it every time with the hotkey. Considering the rough behavior of this young mod, you'd probably want it off by default anyway.

I'll post the complete list of changes made by this mod as soon as it (successfully) finishes compiling, along with the SVN proposal .zip .

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218692] Tue, 02 June 2009 00:28 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.

mod info:

What it does:
allows the player to stay in real time while unnoticed by the enemy. While observing enemies in real time, the player may enter turn-based at will.

Relevant key shortcuts:
[ctrl]-[x] : while observing enemies in real time, enter turn-based mode. Does not work if no enemies are seen, inactive if RT sneaking is disabled.
[shift]-[ctrl]-[x] : toggle the real-time sneaking mode on/off. Enters turn-based if the player can see an enemy. Toggling it back on in turn-based, while stil unseen by the enemy does NOT revert to real time - turn-based will continue until the player no longer sees any enemies.

Relevant ini file entries:
[JA2 Real Time Sneaking Settings]
ALLOW_REAL_TIME_SNEAK = FALSE
QUIET_REAL_TIME_SNEAK = FALSE

<font size="">Modified files:</font>

GameSettings.cpp
Change description:
Added handlers for loading two .ini settings, near the end of the LoadGameExternalOptions() function.
Changes:
void LoadGameExternalOptions()
{
/*...*/
	// The_Bob - real time sneaking code 01/06/09
	// Suport disabling real time sneaking via external .ini file
	gGameExternalOptions.fAllowRealTimeSneak					= iniReader.ReadBoolean("JA2 Real Time Sneaking Settings","ALLOW_REAL_TIME_SNEAK", FALSE);
	// Silence the RT sneaking messages
	gGameExternalOptions.fQuietRealTimeSneak					= iniReader.ReadBoolean("JA2 Real Time Sneaking Settings","QUIET_REAL_TIME_SNEAK", FALSE);
/*...*/
}
GameSettings.h
Change description:
Added two boolean variables at the end of the GAME_EXTERNAL_OPTIONS struct
Changes:
typedef struct
{
/*...*/
	// The_Bob - real time sneaking code 01/06/09
	// Suport disabling/silencing real time sneaking via external .ini file
	BOOLEAN fAllowRealTimeSneak;
	BOOLEAN fQuietRealTimeSneak;
} GAME_EXTERNAL_OPTIONS;

Tactical/opplist.cpp
Change description:
Added two extern declarations at the beginning of the file and the actual RT sneaking code in the HandleBestSightingPositionInRealtime() function.
The code, in its current version, checks if the RT Sneak is enabled, if the merc is on our team and if the enemy wasn't alerted. If the conditions are met
the item under cursor (if anything is currently picked up) is put back, the merc that spotted the enemy is selected amd a message is displayed.
Changes:
/*...*/
// The_Bob - real time sneaking code 01/06/09
extern void CancelItemPointer(void);
extern BOOLEAN NobodyAlerted(void);
/*...*/
void HandleBestSightingPositionInRealtime( void )
{
/*...*/
			if (gubBestToMakeSighting[ 1 ] == NOBODY)
			{	// The_Bob - real time sneaking code 01/06/09
				// if real time sneaking conditions are met...
				if (gGameExternalOptions.fAllowRealTimeSneak && MercPtrs[gubBestToMakeSighting[ 0 ]]->bTeam == OUR_TEAM && NobodyAlerted() )
					{
						// get rid of the item under cursor (we gotta react FAST)
						CancelItemPointer();
						// select (and center screen on) the merc who saw the enemy
						if (gusSelectedSoldier != (UINT16)MercPtrs[gubBestToMakeSighting[ 0 ]]->ubID)
							SelectSoldier (MercPtrs[gubBestToMakeSighting[ 0 ]]->ubID, false, true);
						// if not quiet, emit a message warning the player
						if (!gGameExternalOptions.fQuietRealTimeSneak)
							ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Enemy spotted! (ctrl-x to enter turn based)");

						return;	// and do nothing
					}
				else
					// otherwise, simply award the turn to the team that saw the enemy first
					EnterCombatMode( MercPtrs[gubBestToMakeSighting[ 0 ]]->bTeam );
			}
/*...*/
}

Tactical/Turn Based Input.cpp
Change description:
Added key bindings, as described above. They come with a bunch of checks, which explains the volume of the code. Also, added the WeSeeNoOne() function on the top of the file to facilitate checks when entering combat via ctrl-x.
Changes:
/*...*/
// The_Bob - real time sneaking, 01-06-09
extern BOOLEAN WeSeeNoOne(void); // Needed to control entering turn-based with ctrl-x
/*...*/
void GetKeyboardInput( UINT32 *puiNewEvent )
{
/*...*/
			switch( InputEvent.usParam )
			{
			/*...*/
			case 'x':
				if ( !fCtrl && !fAlt )
				{
				/*...*/
				}
				else if ( fCtrl )	// The_Bob - real time sneaking, 01-06-09
				{	// ctrl-x: enter turn based while sneaking - check if RT sneak is on, iw we're not already in combat and if we actually see any enemies
					if (gGameExternalOptions.fAllowRealTimeSneak)
					{
						BOOLEAN fSneakingInRealTime = true;

						if( gTacticalStatus.uiFlags & INCOMBAT )
						{	// Don't allow this in combat
							if (!gGameExternalOptions.fQuietRealTimeSneak)
								ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"In combat already !");
							fSneakingInRealTime = false;
						}

						if( WeSeeNoOne() )
						{	// Don't allow this if no enemies are seen - we have the forced turn mode for that
							if (!gGameExternalOptions.fQuietRealTimeSneak)
								ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"No enemies in sight !");
							fSneakingInRealTime = false;
						}
						
						if (fSneakingInRealTime)
							EnterCombatMode(OUR_TEAM);
					}
				}
				break;
						// The_Bob - real time sneaking, 01-06-09
			case 'X':	// shift-ctrl-x: toggle real time sneaking
				if ( fCtrl )
				{
					if (gGameExternalOptions.fAllowRealTimeSneak)
					{
						gGameExternalOptions.fAllowRealTimeSneak = false;
						ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Real-time sneaking OFF");
						
						if( !WeSeeNoOne() )	// if we're sneaking up on someone, enter turn-based
							EnterCombatMode(OUR_TEAM);
					}
					else
					{
						gGameExternalOptions.fAllowRealTimeSneak = true;
						ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Real-time sneaking ON");
					}

				}
				break;
			/*...*/
			}
/*...*/
}

[Updated on: Fri, 04 June 2021 05:33] by Moderator

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218737] Tue, 02 June 2009 12:34 Go to previous messageGo to next message
wanne (aka RoWa21) is currently offline wanne (aka RoWa21)

 
Messages:1961
Registered:October 2005
Location: Austria
@the_bob: Thanks for the files and description. I will add it to the main svn source code.

Report message to a moderator

Sergeant Major

Re: Real Time Mode Mod[message #218740] Tue, 02 June 2009 12:54 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
RoWa21
@the_bob: Thanks for the files and description. I will add it to the main svn source code.

Very Happy Great !

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218749] Tue, 02 June 2009 13:27 Go to previous messageGo to next message
wanne (aka RoWa21) is currently offline wanne (aka RoWa21)

 
Messages:1961
Registered:October 2005
Location: Austria
@all: I added the Real Time Mode to the actual source code. The only thing I changed was the section of the new INI entries. I moved them to [JA2 Tactical Settings].

Report message to a moderator

Sergeant Major

Re: Real Time Mode Mod[message #218756] Tue, 02 June 2009 14:30 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
That was fast Very Happy

The new functionality also allows players to observe the enemies in real time - I was always curious what these buggers were up to. Now I can take a comfy position in the bushes, grab a pair of binoculars and watch the AI in it's native environment... even though watching them through a scope on a DSR-1 is significantly more enjoyable Very Happy

As for plans for the future, I'm currently looking into:
- a better notification for when a merc notices an enemy in real time.
- one-time override that enters turn-based on contact (to catch enemies visible for 0.5sec).
- slowing down real-time while the player sees enemies.

Of course, I'm open to suggestions and ideas regarding what would make this mod better. In it's rough state it's actually quite challenging to use.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218760] Tue, 02 June 2009 14:58 Go to previous messageGo to next message
threewings is currently offline threewings

 
Messages:16
Registered:September 2006
Location: Hong Kong
Some suggestions, possibly already in your mind:

-you can enter real time again if you take down a enemy silently and without other's notice, by any mean ranging from knifes or guns.

Report message to a moderator

Private
Re: Real Time Mode Mod[message #218762] Tue, 02 June 2009 15:24 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
threewings
Some suggestions, possibly already in your mind:

-you can enter real time again if you take down a enemy silently and without other's notice, by any mean ranging from knifes or guns.


I take it you mean that the player should be allowed to skip an enemy turn entirely if the kill was unnoticed... I think I could implement a 'silent kill' feature that reverts to real time after killing an enemy, as long as nobody noticed that. Or maybe not enter turn-based at all if the kill wasn't registered, that would certainly contribute to the flow of the game. I'm a bit worried about the implications that would have on the overall game balance however.

I'll try to track down the condition for entering turn-based after killing an enemy and see if I can play around with it. On that matter, what was the original purpose of entering turn-based after, say, finishing off a dying enemy ?

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218764] Tue, 02 June 2009 15:28 Go to previous messageGo to next message
Starwalker is currently offline Starwalker

 
Messages:759
Registered:October 2005
Location: Hannover, Germany
After killing an enemy unnoticed by others, the standard-game changed to realtime immediately when the turn ended, so the function should be already there.

Report message to a moderator

First Sergeant

Re: Real Time Mode Mod[message #218768] Tue, 02 June 2009 16:14 Go to previous messageGo to next message
wanne (aka RoWa21) is currently offline wanne (aka RoWa21)

 
Messages:1961
Registered:October 2005
Location: Austria
@The_Bob: If you use new text messages, please externalize them in the language specific text files (_EnglishText.cpp, _GermanText.cpp, ...). No need for translation. Just put them in English in every text file. I already changed this for the 5 new Real-Time Mode text messages. You can add new texts to the New113Message[] string array in the different language files.

Report message to a moderator

Sergeant Major

Re: Real Time Mode Mod[message #218810] Tue, 02 June 2009 21:48 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
RoWa21
@The_Bob: If you use new text messages, please externalize them in the language specific text files (_EnglishText.cpp, _GermanText.cpp, ...). No need for translation. Just put them in English in every text file. I already changed this for the 5 new Real-Time Mode text messages. You can add new texts to the New113Message[] string array in the different language files.

Will do.

I'm trying to implement the 'silent kill' feature that basically prevents entering turn-based if an enemy was killed without alerting anyone.

What I found out is that turn-based is entered after most attacks by default - the ProcessImplicationsOfPCAttack() function called whenever the player attacks someone prevents entering combat mode only if we attacked friendly units or animals (and they didn't go hostile)... And maybe in some other cases I don't remember now. Of course at this point, entering turn-based has nothing to do with anyone being aware of player's presence, no checks are made for that or even whether the victim survived the attack. That's what I want to change - if the RT sneaking is on, turn-based will only start if the enemies have been alerted by the player's attack.

I've had some (but little) success be adding the NobodyAlerted() check to the end of HandleSoldierDeath() function, but that's an ugly workaround, not very reliable if I understand it correctly. Optimally, I should check if any enemies have been alerted by specific aspects of the attack - player's gun's noise, killing a soldier, bullet impacts from misses etc. Otherwise checking 1sec after the victim's death should work as well, as any nearby enemies ought to be alarmed by then.

My question is where and how should I check if anyone was alerted ? Or where should I add code that would break sneaking in real time upon detection ? Can I use the JA2 event system for that ?

I got to the point where silent attacks work however, as long as they were silent and no one was alerted - otherwise the enemies run to where the noise came from and usually find the player. That is to say that, surprisingly, it works as it should. Of course if the soldier who was attacked survives, the merc gets packed full of lead.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218814] Tue, 02 June 2009 23:48 Go to previous messageGo to next message
Maalstroom is currently offline Maalstroom

 
Messages:340
Registered:December 2008
Location: en route to San Hermanos
you should check this out: night mission with silinced fn p90 - after killing someone the game goes to real time. then you should decide what to do.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218828] Wed, 03 June 2009 03:14 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
Maalstroom
you should check this out: night mission with silinced fn p90 - after killing someone the game goes to real time. then you should decide what to do.

The way it should be in the original game is that after any kill, or attack, no matter how silent, the game goes into turn-based. If the attack was not noticed by other enemies, then the game will go back to real time as soon as the player finishes the turn.

What my mod attempts to do - after a silent kill (currently limited to knives/throwing knives) the game doesn't leave real time, as long as no enemies have been alerted.

Here's a sample, built on a currently outdated version of JA2:

http://www.fileden.com/files/2008/7/29/2025585/ja2_silent_death.zip

Keys:
shift-x : enable silent death (off by default)
ctrl-shift-x : enable real time sneaking
$ : shows if the above options are enabled.

ctrl-x : enter turn based while seeing enemies

The changes can, or their relevant parts, amount to adding this to the end of the ProcessImplicationsOfPCAttack() function :
	if (gfRTSneakMode && gfRTSilentDeath)
	{
		if (pTarget->stats.bLife < OKLIFE 
		&& 	!AM_A_ROBOT( pTarget ) 
		&& 	bReason == REASON_NORMAL_ATTACK )
		{
			if (gusSelectedSoldier == (UINT16)pTarget->ubAttackerID
			&& (Item[ MercPtrs[gusSelectedSoldier ]->usAttackingWeapon ].usItemClass == IC_BLADE
			||	Item[ MercPtrs[gusSelectedSoldier ]->usAttackingWeapon ].usItemClass == IC_THROWING_KNIFE) )
			{	
				fEnterCombat = FALSE;
				gfRTSilentKillAttempted = TRUE;
			}	
		}	
	}


And this tiny check appended to the end of the HandleSoldierDeath() function :

	if (gfRTSilentKillAttempted)
		if ( NobodyAlerted() )
			ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Silent Kill!");
		else
			EnterCombatMode(OUR_TEAM);


Other modifications involve propagating the global variables, adding some new hotkeys and setting gfRTSneakMode to true in the load-game function. It doesn't affect savegame compatibility.

As you can see, it's a rather messy hack but so far it works pretty well with knives. Heck, it put back the fun into knifing - you can walk up to an enemy, slit his throat and walk away without interruptions or delays.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #218863] Wed, 03 June 2009 12:29 Go to previous messageGo to next message
Sandro is currently offline Sandro

 
Messages:420
Registered:November 2008
Location: Mars
This is indeed excellent feature. I have placed it into my mod and give the real time sneaking an option checkbox inside the preferences.
First I thought this is some insane crap.. "real time mod"?? Bt now I see it is absolutely cool stuff, yet so simple. Silent kill adds even more coolness to it. Thanks for that Bob.

Report message to a moderator

Master Sergeant

Re: Real Time Mode Mod[message #219125] Thu, 04 June 2009 21:26 Go to previous messageGo to next message
Off_Topic is currently offline Off_Topic

 
Messages:999
Registered:January 2009
This is where the thread was at before it was Trolled. I moved & locked the rest to Mod General discussions.

Report message to a moderator

First Sergeant

Re: Real Time Mode Mod[message #219127] Thu, 04 June 2009 21:51 Go to previous messageGo to next message
Native_Elder is currently offline Native_Elder

 
Messages:56
Registered:April 2009
The_Bob


I'm trying to implement the 'silent kill' feature that basically prevents entering turn-based if an enemy was killed without alerting anyone.

What I found out is that turn-based is entered after most attacks by default - the ProcessImplicationsOfPCAttack() function called whenever the player attacks someone prevents entering combat mode only if we attacked friendly units or animals (and they didn't go hostile)... And maybe in some other cases I don't remember now. Of course at this point, entering turn-based has nothing to do with anyone being aware of player's presence, no checks are made for that or even whether the victim survived the attack. That's what I want to change - if the RT sneaking is on, turn-based will only start if the enemies have been alerted by the player's attack.

I've had some (but little) success be adding the NobodyAlerted() check to the end of HandleSoldierDeath() function, but that's an ugly workaround, not very reliable if I understand it correctly. Optimally, I should check if any enemies have been alerted by specific aspects of the attack - player's gun's noise, killing a soldier, bullet impacts from misses etc. Otherwise checking 1sec after the victim's death should work as well, as any nearby enemies ought to be alarmed by then.

My question is where and how should I check if anyone was alerted ? Or where should I add code that would break sneaking in real time upon detection ? Can I use the JA2 event system for that ?

I got to the point where silent attacks work however, as long as they were silent and no one was alerted - otherwise the enemies run to where the noise came from and usually find the player. That is to say that, surprisingly, it works as it should. Of course if the soldier who was attacked survives, the merc gets packed full of lead.


What's the purpose? it's always been such that if you kill someone silenty, you only need to end your turn and you're back in real time. :whoknows:

Report message to a moderator

Corporal
Re: Real Time Mode Mod[message #219130] Thu, 04 June 2009 22:05 Go to previous messageGo to next message
Watchman is currently offline Watchman

 
Messages:101
Registered:August 2008
Location: Philippines
Well, it sure helps cut the time to position yourself do the stealth kill, especially in broad daylight. Takes a good 5 turns for me to do the kill. (I prefer waiting 2 turns to check for any other enemy close by)

And makes it pretty exciting especially with 20 enemy soldiers prancing around.

Report message to a moderator

Sergeant
Re: Real Time Mode Mod[message #219138] Thu, 04 June 2009 22:28 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
I prefer it that way, it's more fun without entering turn based if there's no reason for it. Without the real-time mod enabled it doesn't seem so out of place.

Anyhow, if I'm misunderstanding the concept behind entering turn-based after every attack as a default then I'd be very grateful for an explanation before I go too far a misguided path. So far however, it simply looks like... maybe not sloppy coding, but simply a default.

In the ProcessImplicationsOfPCAttack() function, the game checks for things like whether the militia should turn hostile, the attacked NPC should change sides (ie. turn hostile), town's loyalty drop etc., also it checks whether the attack should _not_ trigger turn-based - in cases like attacking friendly units, animals or hitting Pablo for stealing your stuff. There simply are no checks for whether the target died (thus pretty much making the next turn pointless - it's not a confrontation of two sides or a combat situation) or if anyone could see the attack (although the function that calls ProcessImplicationsOfPCAttack() does some sight range checks after that).

With the introduction of the real-time sneaking feature, entering turn-based for no special reason was a little unjustified as a default - first, because it (pointlessly) interrupted realtime, second because it could enter turn-based when the merc could see another enemy (maybe want to sneak up on him as well). My logic was that if the other team was unaware of player's presence and actions, it could not take action anyway - so entering turn-based was not necessary and as such should be prevented, in the light of the player's preference for playing the stealthy part of the game in real time. That, and the fact I've made the 'silent death' an option - if the player prefers to enter turn-based after the attack then there's absolutely no compulsion to play the game otherwise.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219142] Thu, 04 June 2009 23:12 Go to previous messageGo to next message
Native_Elder is currently offline Native_Elder

 
Messages:56
Registered:April 2009
in plain language, we save the time for hitting the "d" button once?

Report message to a moderator

Corporal
Re: Real Time Mode Mod[message #219145] Thu, 04 June 2009 23:21 Go to previous messageGo to next message
Sandro is currently offline Sandro

 
Messages:420
Registered:November 2008
Location: Mars
Have you been thinking about disabling the ability to enter TB at will and simply enter TB when some real interaction between the two sides happen - like an attack, or when they both see each other..?
Then when happen, that the enemy turn and sees you, the check who will start first would be clasically counted as before. Otherwise, if you attack him without noticing and not killing him, you would have the first turn always. If I am not wrong, the enemy have sach an ability, when he sees you, fire at you and then the TB is entered with enemy side as first.
Actually the check can be based more on that if you move or not, so silent waiting behind the tree would give you better chance to gain first turn, when the enemy is moves and vice versa. It would prevent to spoil the entering TB when it is just most beneficial to you. Just an idea, what do you think?

Report message to a moderator

Master Sergeant

Re: Real Time Mode Mod[message #219146] Thu, 04 June 2009 23:23 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
Native_Elder
in plain language, we save the time for hitting the "d" button once?

Pretty much Very Happy

One exception is when we can see other enemies - then we also have to lose sight of them before we can get back to real time. No problem if alone, more of a hassle if you have mercs observing enemy movements via binoculars/scopes.

I'd also like to once again stress the coolness factor inherent to smoothly slaying an enemy with one blow and being on your way before the body hits the ground.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219154] Thu, 04 June 2009 23:50 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
Sandro
Have you been thinking about disabling the ability to enter TB at will and simply enter TB when some real interaction between the two sides happen - like an attack, or when they both see each other..?
Then when happen, that the enemy turn and sees you, the check who will start first would be clasically counted as before. Otherwise, if you attack him without noticing and not killing him, you would have the first turn always. If I am not wrong, the enemy have sach an ability, when he sees you, fire at you and then the TB is entered with enemy side as first.

That would actually be rather inconvenient to the player and unfair to the enemy.

If there would be no option to enter TB, then the player could not properly attack the enemy - aiming is pretty much broken in real time, and even though I've read this, I don't see myself adding aiming to real time in the near future. I've a bunch of ideas though, so I may get around to it eventually.

Also, if the player was allowed a bonus attack in real time (in addition to having a full turn afterward), that would be plain unfair to the enemy. Making a unbiased check (or rather forcing it) would hardly amend the situation since a soldier crippled by being hit would have far inferior chance of winning the turn. Unless he wasn't alone or wasn't really hurt, but a wise player would avoid such situations.

Now making enemies attack the player in real time and _then_ have a check for who should win the turn - it's a bit out of my league right now, since I still lack grasp of the event system/simply don't know how to properly make things happen one after another. I know how to make the enemy shoot in real time though (or I think I do) - replicating the code used when you shoot one of your mercs and he fires back should work (from what I understand). I've no idea however, how could I interfere with the events that would follow that.

Sandro

Actually the check can be based more on that if you move or not, so silent waiting behind the tree would give you better chance to gain first turn, when the enemy is moves and vice versa. It would prevent to spoil the entering TB when it is just most beneficial to you. Just an idea, what do you think?


Implementing the core principle might involve AI hacking that's within my reach but making it work in a reasonable way is, sadly, still beyond that. You've probably seen a bunch of games that suffered from bad implementation of stealth detection, where enemies would bump into you and not see you or otherwise do stupid things when the PC simply met some abstract conditions for remaining undetected, like standing in a dark spot on the floor or having the sneak skill > 90. The perspective of the fine-tuning nightmare that might ensue is enough to prevent me from trying for now.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219158] Fri, 05 June 2009 00:28 Go to previous messageGo to next message
Thor is currently offline Thor

 
Messages:423
Registered:February 2007
Location: Belgium
I have just been thrown out of a game while sneaking and shooting an enemy from behind. Plain out of it, so no savegame.. Used the SVN version. May be a coincidence.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219159] Fri, 05 June 2009 00:34 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
Thor
I have just been thrown out of a game while sneaking and shooting an enemy from behind. Plain out of it, so no savegame.. Used the SVN version. May be a coincidence.
Likely so.

Still, the game not being designed for this (or rather the things I do to make this work), I wouldn't be surprised if this happened more often.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219161] Fri, 05 June 2009 00:35 Go to previous messageGo to next message
Thor is currently offline Thor

 
Messages:423
Registered:February 2007
Location: Belgium
So what did I do wrong or how can I avoid this?
"likely so" --- Do you mean it is probably a coincidence and doesn't have anything to do with the real time mod?

[Updated on: Fri, 05 June 2009 00:43] by Moderator

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219165] Fri, 05 June 2009 00:48 Go to previous messageGo to next message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
Thor
So what did I do wrong or how can I avoid this?

Obviously you did nothing wrong, the game shouldn't just crash like that Razz
Also, I've no idea what might cause the game to crash, but I suppose sending a loooong burst of autofire into a large group of enemies in real-time might tax the game engine a bit. Then again it shouldn't crash the game either.

Thor

Do you mean it is "likely" a coincidence?
Yes, I've tested it quite a bit and (to my surprise) failed to make the game crash by shooting people in real-time. Although I've mostly stabbed them.

I think It happaned to me once, but considering the time I've spent testing and the things I've done, it was quite random as well.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219166] Fri, 05 June 2009 00:51 Go to previous messageGo to next message
Thor is currently offline Thor

 
Messages:423
Registered:February 2007
Location: Belgium
It was just one enemy... and not even a burst... Maybe because I moved closer and shot at the same time? No animation or something like that?

Thanks for your quick answer... I'll test on Wink

[Updated on: Fri, 05 June 2009 00:52] by Moderator

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219167] Fri, 05 June 2009 00:55 Go to previous messageGo to next message
Thor is currently offline Thor

 
Messages:423
Registered:February 2007
Location: Belgium
It's a really handy feature, also for the landing in insane... turn-based helps Wink

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219194] Fri, 05 June 2009 07:09 Go to previous messageGo to next message
usrbid is currently offline usrbid

 
Messages:1506
Registered:December 2008
Thor
thrown out of a game


It happens to me at least once a gaming session, but mostly when I burst, something seems to upset the game... Smile Since I play so much, I noticed it is more likely to happpen when I "push" the game by entering commands too fast.

For example it seems to happen more frequently when I look at the enemy inventory using Alt, the tooltip is still up or fading, and I shoot the enemy before the tooltip is completely gone.

But it happened to me once with the last enemy in I14 (Alma mine I think), came through the fence, cleaned out all the enemies slowly and painfully, last two running around like headless chicken in front of the mine building, one gets shot and flees the sector, the other gets a head shot with the SVD with the x10 scope, playing on Insane Iron Man, had 20+ enemies in the sector, CTD (crash to desktop), I sit there staring at the blue Windows background for a while... Had to do someting else for a bit before I wanted to try again.

Report message to a moderator

Sergeant Major

Re: Real Time Mode Mod[message #219945] Mon, 08 June 2009 15:51 Go to previous messageGo to next message
Thor is currently offline Thor

 
Messages:423
Registered:February 2007
Location: Belgium
Some issues...

Kingpin always starts shooting when the bell tolls. Very frustrating if you have put your guns away for a boxing match...

Furthermore there should be an option to have a forced turn as soon as you spot an enemy (as it used to be). An enemy now can get very close to your mercs (when he is not aware of them) and when he then spots them he will hit them easily, although your mercs did not get an interrupt... I guess that's not the intention... Definitely not when you are moving your other mercs.

Report message to a moderator

Master Sergeant
Re: Real Time Mode Mod[message #219951] Mon, 08 June 2009 16:04 Go to previous messageGo to previous message
The_Bob is currently offline The_Bob

 
Messages:415
Registered:May 2009
Location: Behind you.
You can toggle the real time sneak with ctrl-shift-x, which is what I do when not aiming for a stealthy approach. Also having to enter turn-based first is a sort of counterbalance for the pros of this mod.

I'll add the feature to enter turn-based upon next contact and to automatically enter turn-based when an off-screen merc spots an enemy.

I'll probably refine that later to check if the off-screen mercs are at the border of enemies' FOV (based on cover calculations) and then make them go into turn-based - no need to be alarmed if they can't spot you anyway.

Also I'll have to scrap the auto-selecting of the merc that saw an enemy, it tends to be more annoying then not.

I'm still not sure hot to properly implement the silent kill feature. Even in it's current form it's quite cool.

edit:
Thor
Kingpin always starts shooting when the bell tolls. Very frustrating if you have put your guns away for a boxing match...

how is that related to my mod ?

[Updated on: Mon, 08 June 2009 16:06] by Moderator

Report message to a moderator

Master Sergeant
Next Topic: What would I need to start coding?
Goto Forum:
  


Current Time: Fri Apr 19 08:08:34 GMT+3 2024

Total time taken to generate the page: 0.02575 seconds