dhewm3 icon indicating copy to clipboard operation
dhewm3 copied to clipboard

g_armorProtection resets on level change

Open thekovic opened this issue 3 years ago • 6 comments

I don't like the vanilla armor mechanics so I decided to play with g_armorProtection set to 0.6. However, there is one small annoyance - every time the level changes I have to re-input the command. This behaviour is in contrast with other commands like com_allowConsole or com_showFPS which are persistent.

I tried adding my custom value of 0.6 to DoomConfig.cfg as seta g_armorProtection 0.6 and also to autoexec.cfg as g_armorProtection 0.6 but to no avail.

thekovic avatar Feb 26 '22 18:02 thekovic

g_armorProtection is obviously reset on map load (g_... might reflect that?)

paulwratt avatar Feb 27 '22 00:02 paulwratt

You'd have to call the cvar each frame or game tic, or at least more often, the way I understand it. One way to do it is in the player script. In player::Torso_Idle, within "eachframe" you can add something like:

if ( sys.getcvar( "si_gameType" ) != "multiplayer" ) { sys.setcvar( "g_armorProtection", "0.6" ); } It might be a hacky way to do it, but it works!

Lippeth avatar May 27 '22 01:05 Lippeth

You'd have to call the cvar each frame or game tic, or at least more often, the way I understand it. One way to do it is in the player script. In player::Torso_Idle, within "eachframe" you can add something like:

if ( sys.getcvar( "si_gameType" ) != "multiplayer" ) { sys.setcvar( "g_armorProtection", "0.6" ); } It might be a hacky way to do it, but it works!

Apologies for bumping this, but this too doesn't seem to work. I have similar code in player::Torso_Idle. Within "eachframe" I added this:

if ( sys.getcvar( "si_gameType" ) == "singleplayer" ) { sys.setcvar( "g_armorProtection", "0.5" ); }

and yet still it seems to reset on exiting and entering certain levels of the game (I noticed this on the later maps of the game).

AtifArshad1995 avatar Aug 31 '22 17:08 AtifArshad1995

Another way could be to create an idle state and reference it in the player base and init state:

At the end of "object player : player_base" add: void Idle();

At the end of "player::init" add: thread Idle();

Then create a new state between "player::Idle" and "player::EnterCinematic"

void player::Idle() {

	while ( 1 ) {
		if ( sys.getcvar( "si_gameType" ) == "singleplayer" ) {
			sys.setcvar( "g_armorProtection", "0.5" );
		}
		waitFrame();
	}
}

Lippeth avatar Aug 31 '22 17:08 Lippeth

Another way could be to create an idle state and reference it in the player base and init state:

Thanks man. This method works great. No longer is armor protection getting reset after entering a new map.

I tested by using an autosave of Delta Lab sector 4 (the short 2 Hell knight map). After ending the map and reaching Hell, my armor protection would reset back to 0.2 with the older method. But with this new method you posted, the armor protection remained at 0.5.

AtifArshad1995 avatar Aug 31 '22 19:08 AtifArshad1995

Another way could be to create an idle state and reference it in the player base and init state:

At the end of "object player : player_base" add: void Idle();

At the end of "player::init" add: thread Idle();

Then create a new state between "player::Idle" and "player::EnterCinematic"

void player::Idle() {

	while ( 1 ) {
		if ( sys.getcvar( "si_gameType" ) == "singleplayer" ) {
			sys.setcvar( "g_armorProtection", "0.5" );
		}
		waitFrame();
	}
}

Hello, I tried this but all that happens is I get sent back to the main menu upon trying to enter a new game or load a level, and the music cuts out. I know nothing about scripting whatsoever, what am I doing wrong?

SquireTybalt avatar Oct 05 '23 21:10 SquireTybalt