Jump to content

changing game settings with script


DonQ

Recommended Posts

So I can't seem to figure out how to change a game setting with a script. It seems like a really simple thing, and probaby is, but I can't find anything about it anywhere. I saw on the scripts posted here that you can 'GetGameSetting' with script, but 'SetGameSetting' isn't working for me.

 

The only ways I know to alter game settings are through the geck, or with the console, but you can't use console commands in script for some reason. Any advice would be really appreciated.

 

 

(alternatively, maybe someone knows a way to help me bypass the setting entirely - the setting I'm trying to change is 'iSoundLevelNormal' ; I'd like it to change when certain weapons are equipped, because I'm trying to broaden the range of noise levels guns make beyond 'silent', 'normal', and 'loud', but if there's some other way to alter a weapons noise level that would be nice to know)

Link to comment
Share on other sites

Ahh, well I guess I meant to say that the script I kept trying is giving me a 'this is a console command only' error when trying to compile it. Excuse my semantics, I'm pretty code naive. I tend to just beat my head against the monitor until it sinks in just enough to accomplish my usually pretty simple goals.

 

So anyway. My head was getting sore, so I appreciate the help...

 

I was trying 'SetGameSetting' as well as 'SetGS', both of which give me the error, but that's how I saw it described in the readme for FOSE, and at that link you posted. I haven't tried 'SetNumericGameSetting' however. Maybe I'll give that a whirl.

 

As for the script, its going to be very basic, like :

.........................................

scn (nameofgun)script

 

begin onEquip

 

SetNumericGameSetting iSoundLevelNormal to ## ; this ## is to vary depending on the gun

 

end

 

begin onUnequip

 

SetNumericGameSetting iSoundLevelNormal to 50 ; the default value

 

end

......................................

 

Not sure if thats correct code, but its the general idea. I didn't get very far, so I moved on.

 

In the meantime I devised a crude work-around to make missles and grenades have varying degrees of damage depending on your proximity to the explosion. I just got it working, so I'm feeling really proud of myself, even if my head is frickin killing me.

Link to comment
Share on other sites

Well that was the problem it seems - I got it to compile once I used 'SetNumericGameSetting' instead of SetGameSetting or SetGS. So thanks for that tip! I don't think I ever would've figured that one out. I also dropped the 'to' s from the code above, btw.

 

I need to test it in game, but since it's compiling okay I don't see why it wouldn't work... right?

 

Oh who the heck am I kidding, even my most basic scripts require at least two hours of shouting at my screen. Wish me luck!

 

EDIT: It works! HAHAHAHAHAA!!! On the first try and everything. I guess maybe the several hours of blind frustration I spent before asking for help carried over to now, in a 'time already served' cosmic-code-karma-kind of way.

 

Anyway, thanks again for the help.

Link to comment
Share on other sites

Well that was the problem it seems - I got it to compile once I used 'SetNumericGameSetting' instead of SetGameSetting or SetGS. So thanks for that tip! I don't think I ever would've figured that one out. I also dropped the 'to' s from the code above, btw.

 

I need to test it in game, but since it's compiling okay I don't see why it wouldn't work... right?

 

Oh who the heck am I kidding, even my most basic scripts require at least two hours of shouting at my screen. Wish me luck!

 

EDIT: It works! HAHAHAHAHAA!!! On the first try and everything. I guess maybe the several hours of blind frustration I spent before asking for help carried over to now, in a 'time already served' cosmic-code-karma-kind of way.

 

Anyway, thanks again for the help.

 

Just so you know if you are planning on releasing the mod: If you change the soundlevels, the volume/area for the sounds is changed for everything using the soundlevel you change. Especially the "normal" soundlevel is used a lot, so you might want to think of another way to accomplish what you want.

 

I do use changed soundlevels in my own mod, but that was because I thought the values for silent and normal were not giving the results I wanted from them overall.

Link to comment
Share on other sites

Yeah I was sort of wondering exactly how else those sound levels are used in game. So to minimize the changes I made, I spread them out over the three levels, ie; when equiping a gun with a desired range b/w 1-25, I made the change to SoundLevelSilent, from 26-75 SoundLevelNormal, and the louder guns with ranges b/w 76-120 use an altered SoundLevelLoud. That way any given sound level isn't altered by more than 25 points.

 

I haven't really noticed any effects other than the desired ones. But then I haven't been looking very hard. I'll keep an eye out for weird behavior now. Thanks for the heads up.

 

I've got several custom esms my mod depends on so it's not really fit for being released, but if anyone were interested, feel free to release it as your own. I have a few pointers though.

 

1.) The code above has a few flaws - anytime an NPC equips or unequips a weapon with that script attached, the sound levels will alter accordingly. So slap on a 'Player' after each begin on(Un)Equip line.

 

2.) If you go from using a gun with a script attached to directly equiping a gun without one, it won't reset the default sound levels b/c it doesn't count it as an unequip, but rather as an equip of the new gun. Further, if you go from a gun with an altered 'A' sound level to one with a new 'B' level, the default 'A' setting won't be reset. A work-around is to add lines setting the sound levels you're not changing to each script, reestablishing their default value. Example:

 

scn aaSound20 (I made one script for every 5 points of sound from 5-120 instead of unique scripts for each gun)

 

begin onEquip Player

 

SetNumericGameSetting iSoundLevelSilent 20 (altered value, in the 'silent' range from 1-25)

SetNumericGameSetting iSoundLevelNormal 50 (default value)

SetNumericGameSetting iSoundLevelLoud 100 (default value)

 

end

 

You only need to reset the value you changed with the Unequip line though, since if you actually do an 'unequip', then the original idea works. Any weapon that doesn't alter sound levels should have a script reseting all three default values onEquip (10, 50, 100, or whatever your defaults are).

 

3.) The only other issue I'm having is that whenever you reload a game, the defaults reload as well, and any script on a gun already equipped won't fire until it's equiped again, or unequiped. I suppose adding a 'begin onLoad' block followed by the same three sound levels would do it. Kind of a pain though... not sure its worth it since I'm not releasing it. I'm just unequiping and requiping my guns when I load.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...