Home » MODDING HQ 1.13 » v1.13 Coding Talk » Real Time Mode Mod
|
|
|
Re: Real Time Mode Mod[message #218675]
|
Mon, 01 June 2009 20:46
|
|
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 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 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 ), 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 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 #218692]
|
Tue, 02 June 2009 00:28
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
Re: Real Time Mode Mod[message #218810]
|
Tue, 02 June 2009 21:48
|
|
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
|
|
|
|
|
Re: Real Time Mode Mod[message #218828]
|
Wed, 03 June 2009 03:14
|
|
The_Bob |
|
Messages:415
Registered:May 2009 Location: Behind you. |
|
|
Maalstroomyou 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
|
|
|
|
|
|
Re: Real Time Mode Mod[message #219127]
|
Thu, 04 June 2009 21:51
|
|
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 #219138]
|
Thu, 04 June 2009 22:28
|
|
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
|
|
|
|
|
Re: Real Time Mode Mod[message #219145]
|
Thu, 04 June 2009 23:21
|
|
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
|
|
|
|
|
Re: Real Time Mode Mod[message #219154]
|
Thu, 04 June 2009 23:50
|
|
The_Bob |
|
Messages:415
Registered:May 2009 Location: Behind you. |
|
|
SandroHave 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
|
|
|
|
|
|
Re: Real Time Mode Mod[message #219161]
|
Fri, 05 June 2009 00:35
|
|
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 #219194]
|
Fri, 05 June 2009 07:09
|
|
usrbid |
|
Messages:1506
Registered:December 2008 |
|
|
Thorthrown 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... 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
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 19 23:01:42 GMT+3 2024
Total time taken to generate the page: 0.03644 seconds
|