Home » MODDING HQ 1.13 » v1.13 Coding Talk » Help with tweaking the sneaking
Help with tweaking the sneaking[message #323065] Mon, 22 July 2013 16:57 Go to next message
merc05 is currently offline merc05

 
Messages:90
Registered:January 2013
Hi guys. I would appreciate some advice on this. What I had in mind was changing some mechanisms regarding real time sneaking. First I wanted to make the game treat enemies collapsed from lack of breath as harmless, the same as it treats guys that are in dying state or have been handcuffed. Second thing is I wanted to change the way sleeping dart works, since now killing an enemy with a silenced pistol will not break stealth but shooting him with a sleep dart and leaving sleeping will. Changes I made are:

opplist.cpp void ManSeesMan

if (!pSoldier->bActive || !pSoldier->bInSector || (pSoldier->stats.bLife < OKLIFE) )
	return;

to
if (!pSoldier->bActive || !pSoldier->bInSector || (pSoldier->stats.bLife < OKLIFE) || (pSoldier->bBreath < OKBREATH) )
	return;


opplist.cpp void NoticeUnseenAttacker

if ( pAttacker->usAttackingWeapon == DART_GUN )
	{
		// rarely noticed
		if ( SkillCheck( pDefender, NOTICE_DART_CHECK, 0 ) < 0)
		{
			return;
		}
	}

// do we need to do checks for life/breath here?

to
//if ( pAttacker->usAttackingWeapon == DART_GUN )
if ( AmmoTypes[pAttacker->inv[pAttacker->ubAttackingHand][0]->data.gun.ubGunAmmoType].dart )
	{
		// rarely noticed
		if ( SkillCheck( pDefender, NOTICE_DART_CHECK, 0 ) < 0)
		{
			return;
		}
	}

// do we need to do checks for life/breath here?
if ( pDefender->stats.bLife < OKLIFE || pDefender->bBreath < OKBREATH )
	return;


Overhead.cpp BOOLEAN SoldierHasSeenEnemiesLastFewTurns

if ( pSoldier->bActive && pSoldier->bInSector && ( pSoldier->bTeam == gbPlayerNum || ( pSoldier->stats.bLife >= OKLIFE ) ) )

to
if ( pSoldier->bActive && pSoldier->bInSector && ( pSoldier->bTeam == gbPlayerNum || ( pSoldier->stats.bLife >= OKLIFE && ( !gGameSettings.fOptions[TOPTION_ALLOW_REAL_TIME_SNEAK] || pSoldier->bBreath >= OKBREATH ) ) ) )


Overhead.cpp BOOLEAN NobodyAlerted

if ( ( pSoldier->bTeam != gbPlayerNum ) && ( ! pSoldier->aiData.bNeutral ) && (pSoldier->stats.bLife >= OKLIFE) && (pSoldier->aiData.bAlertStatus >= STATUS_RED) )

to
if ( ( pSoldier->bTeam != gbPlayerNum ) && ( ! pSoldier->aiData.bNeutral ) && (pSoldier->stats.bLife >= OKLIFE) && (pSoldier->bBreath >= OKBREATH) && (pSoldier->aiData.bAlertStatus >= STATUS_RED) )


Overhead.cpp BOOLEAN CheckForEndOfCombatMode

if ( pTeamSoldier && pTeamSoldier->stats.bLife >= OKLIFE && !pTeamSoldier->aiData.bNeutral )

to
if ( pTeamSoldier && pTeamSoldier->stats.bLife >= OKLIFE && ( !gGameSettings.fOptions[TOPTION_ALLOW_REAL_TIME_SNEAK] || pTeamSoldier->bBreath >= OKBREATH ) && !pTeamSoldier->aiData.bNeutral )




That basically achieved what I wanted to do. Now I can quit combat after collapsing a foe or use a sleeping dart without triggering an alarm. There is a slight problem though. After I k.o. an opponent and he wakes up he attacks naturally, but after a couple of rounds the game will quit combat mode and go into real-time even when he is not k.o.'ed again. It will start combat a second later. I guess it's the k.o.'ed guys breath gauge getting low and the game starts to recognize him as

Report message to a moderator

Corporal 1st Class
Re: Help with tweaking the sneaking[message #323088] Tue, 23 July 2013 00:06 Go to previous messageGo to next message
silversurfer

 
Messages:2791
Registered:May 2009
I'm not sure I understand. You want to ignore enemy soldiers that are knocked out but could shoot you in the back during the next round? Opponents that are dying or handcuffed cannot shoot you anymore.
What do you want to accomplish? Making the darts last until battle is over is probably not what you want?

Report message to a moderator

Lieutenant
Re: Help with tweaking the sneaking[message #323123] Tue, 23 July 2013 17:51 Go to previous messageGo to next message
merc05 is currently offline merc05

 
Messages:90
Registered:January 2013
Sorry for getting this somewhat incomprehensive. Currently (I mean in a trunk .exe file) the real time sneaking feature is implemented in the way that we have a check NobodyAlerted which tracks if any enemy soldier has went into a red or higher alert state. If it's false and real time sneaking is on then the player can see the enemy and the game will not go into turn based mode, unless the enemy sees us. Also the game doesn't go into turn based mode if an enemy is present but he is either in dying state or handcuffed. So I can roam the map with my merc and kill people silently provided I can take them out in one round.

Now what I want is to be less lethal in taking them out. If you played i.e. Metal Gear Solid aside from killing enemies one could knock them out with martial arts or use a sleeping dart and leave them that way and continue onward. In the way current 1.13 works I can knock an enemy out but I have to either kill him or handcuff him, otherwise the game won't end the turn based mode. That's one thing.
Second thing is the dart pistol we have in JA2. It can instantly put an enemy to sleep (his breath counter goes to 0) but as one can notice putting an enemy down with a sleeping dart still requires killing/handcuffing him in the same round or the NobodyAlerted check will go off and the player is considered discovered ergo real time sneaking can no longer be used.

The changes I want to make are:
- the enemy who is hit with a dart and goes to sleep won't go into higher alert state
- when RT sneaking is on unconscious enemies (lying on the floor due to lack of breath) don't count (the same way as dying and handcuffed ones don't), so if 2 turns pass with no combat and only unconscious enemies are lying around the turn based mode will end as the game considers player doesn't want to finish them off

As you can see I did this by adding the ->bBreath 0 and <10. The game will stop treating him as a threat so, if my merc doesn't attack in 2 consecutive turns and the enemies BP is still in range >0 <10, turn based mode will end. I was thinking of a better condition to treat an enemy as not posing a threat. There is a parameter called bCollapsed but using such a condition messed with tha AI for some reason in a way I described in the firs post (when waking up the enemy would attack me in the first turn of combat, but remain idle afterward). Stuff described in this paragraph is my main problem right now.

The issue I described is not such a big deal and if there is nothing to be done about it I can live with that. If you're asking why I wanted to do those changes - well, I wanted to add some Metal Gear flavor. I've already added a lot stuff from those games including some sci-fi stuff, hence I wanted the soldiers to act more like those morons that you had to sneak past in MG Razz . The most noticeable thing in the gameplay is the ability to take out a soldier from afar with a dart sniper rifle without triggering an alarm, until I get close enough to tie him. Why go all the way for this? Hmm, since Flugente's prisoner system it's justifiable Smile.

Report message to a moderator

Corporal 1st Class
Re: Help with tweaking the sneaking[message #323134] Tue, 23 July 2013 21:47 Go to previous messageGo to next message
silversurfer

 
Messages:2791
Registered:May 2009
Ok, that makes it clearer for me. I don't know Metal Gear but that sneaking approach can also be found in other games, Deus Ex 1-3 for example. There are some differences between them however. In 1+2 an opponent that is unconscious stays so forever (unless you decide to kill him). In part 3 unconscious opponents could be woken up by comrades passing by. That's why I was asking what exactly you want to accomplish.

So should the opponent:
1. stay unconscious forever (until you decide what to do with him)?
2. recover over time and go on red alert once he wakes up? This will alert all other enemies as well.

Number 1 would probably be safer for the player. Number 2 is complicated. There is an option BP_RT_BREATH_RECOVER_MODIFIER in APBPConstants.ini. I externalized it a few weeks ago to make it possible for the player to adjust breath regeneration in RT mode. This affects enemies as well. So it directly influences your unconscious opponent. He will recover quickly and shoot you.

Report message to a moderator

Lieutenant
Re: Help with tweaking the sneaking[message #323143] Wed, 24 July 2013 00:59 Go to previous messageGo to next message
merc05 is currently offline merc05

 
Messages:90
Registered:January 2013
Quote:
recover over time and go on red alert once he wakes up? This will alert all other enemies as well


Exactly. With the changes above enemies behave just like that. The problem is the condition which is
1. The enemy was knocked out. His BP went to 0, and now it's rising. When it reaches 10 he will wake up. <- that situation is desired and the enemy should be treated as harmless

2. The enemy has awaken and has taken action against the nearby merc. He has 10 BP but since he starts acting he uses them up - they drop <10 (i.e. Cool. Now he is not yet unconcious (>0) but is in an
What I need is for the game only to consider the first situation and not the second one. I don't have much clue how to make it differentiate between the two. As you can see the changes I did to the code were mainly adding an
I don't have a problem with the enemies waking up too early. It's realistic I guess. It is logical that they should be handcuffed sooner or later. Since unconscious enemies won't trigger an alert now until after they wake up that's enough time I need to do something with them.

Report message to a moderator

Corporal 1st Class
Re: Help with tweaking the sneaking[message #323149] Wed, 24 July 2013 02:26 Go to previous messageGo to next message
silversurfer

 
Messages:2791
Registered:May 2009
I saw another property called "bBreathCollapsed". Have you tried that?

Report message to a moderator

Lieutenant
Re: Help with tweaking the sneaking[message #323249] Fri, 26 July 2013 01:24 Go to previous messageGo to next message
merc05 is currently offline merc05

 
Messages:90
Registered:January 2013
I've tried with bBreathCollapsed but that worked like bCollapsed. I've also tried with added height ANIM_PRONE check and it prevented from quitting the turn based mode but again the soldiers got idle after the 1st round. I don't get it... Sad should've worked.

Report message to a moderator

Corporal 1st Class
Re: Help with tweaking the sneaking[message #323250] Fri, 26 July 2013 01:35 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
I'm not entirely sure I understand you... wouldn't your changes mean that you can knock an enemy out, game does not go to turnbased... he recovers breath... enters turnbased, gets the turn, gets up and kills you at close range?

Report message to a moderator

Captain

Re: Help with tweaking the sneaking[message #323269] Fri, 26 July 2013 15:56 Go to previous messageGo to next message
merc05 is currently offline merc05

 
Messages:90
Registered:January 2013
I managed to get that issue of mine on video. I think it will clear things a bit. The behavior of ending the turn based mode after the enemy falls asleep without triggering red alert is correct and is what I want. But I don't want what is happening to an enemy soldier after he wakes up. Since he is low on breath points, after shooting his gun they drop <10 Bps (OKBREATH) and the turn based mode ends even though he is conscious - I need something that will discriminate between enemies that are knocked out and recovering breath (<10 Bps) and those that are conscious but low on Bps (also <10 Bps).

http://youtu.be/7Xh2nYgqMXw

Report message to a moderator

Corporal 1st Class
Re: Help with tweaking the sneaking[message #323271] Fri, 26 July 2013 18:03 Go to previous messageGo to next message
silversurfer

 
Messages:2791
Registered:May 2009
Maybe that "bCollapsed" and "bBreathCollapsed" need fixing?

What is the stance when the opponent is lying on the floor? Prone?

Report message to a moderator

Lieutenant
Re: Help with tweaking the sneaking[message #323325] Sat, 27 July 2013 17:22 Go to previous message
merc05 is currently offline merc05

 
Messages:90
Registered:January 2013
I think it's prone since adding a height check prevented the game from exiting to turn based mode, but this (along with other things I've tried like bCollapsed and bBreathCollapsed condition) caused a knocked out soldier to get dumb after recovering. I don't understand what can prevent the AI to attack during consecutive rounds. Maybe it still considers an

Report message to a moderator

Corporal 1st Class
Previous Topic: I'm putting an end to save-file compatibility breaks, if noone minds...
Next Topic: Jagged Alliance 2 3D
Goto Forum:
  


Current Time: Sat Nov 30 11:05:05 GMT+2 2024

Total time taken to generate the page: 0.01461 seconds