seed 11 Posted December 25, 2015 Hello forum, As my understanding from scripting is minimal i would like to ask a help for a problem of mine. I would appreciate any kind of help or hint. (Sorry my bad English) For a MP - Mission that i am creating i decided to include a temperature influence on players. The parameters are defined on Description.ext. class Params { class Daytime { title = "Daytime"; texts[] = {"Morning","Day","Evening","Night"}; values[] = {6,12,18,0}; default = 12; function = "BIS_fnc_paramDaytime"; // (Optional) Function called when player joins, selected value is passed as an argument isGlobal = 1; // (Optional) 1 to execute script / function locally for every player who joins, 0 to do it only on server }; class ViewDistance { title = "View distance (in metres)"; values[] = {500,1000,2000,5000}; // When 'texts' are missing, values will be displayed directly instead default = 1000; //file = "setViewDistance.sqf"; // (Optional) Script called when player joins, selected value is passed as an argument }; //Start Temperature class Temperature { title = "Temperature"; values[] = {-15,-10,-5,0,5,10,15}; default = 0; }; //Defining amount of damage the player takes if its too hot of too cold. class DamageTemp { title = "Temperature Damage"; values[] = {10,5,3,1}; default = 3; }; //How many defrees/hour the temperature changes class ChangeTemp { title = "Temperature Change"; values[] = {5,4,3,2,1}; default = 3; }; }; The questions that i have is : 1. How can i make the Temperature depending from "Daytime" parameters. Would something like the Pseudocode below work ? : _var1 = Temperature; _var 2 = Daytime; switch true do { case "Morning": { _var2 = _var1 ; }; }; 2. How can i combine in a script the temperature change/ hour with "Daytime Class". Would something like the pseudocode below do ? _var1 = ChangeTemp; _var2 = Daytime; _var3 = StartTemp; switch true do { case "Minimum": { while (true) do { if (_var2) between (6 && 12) then { _var3 + _var1 sleep 3600; }; }; 3. How can i combine the damage a player takes if the temp goes above or below the threshold defined in "StartTemp". I hope i was clear enough as to what my problem is. Regards Seed Share this post Link to post Share on other sites
cybercoco 16 Posted December 31, 2015 1. How can i make the Temperature depending from "Daytime" parameters. Would something like the Pseudocode below work ? : _var1 = Temperature; _var 2 = Daytime; switch true do { case "Morning": { _var2 = _var1 ; // this is a simplified version right ?? }; }; I think this will only check once, when the mission starts. If you want it to be active during the scenario, it will have to be a trigger (which will work more like a "when"). Because this code will only run on mission start and not twice or more. I need to be verified on that though. And if you want the temperature to be dependant from the daytime var you will just need to create a math function. For exemple : _daytime = 0.5; // this will be known _temperature = 0; // this is now a defined variable // dependency of temperature _temperature = (10*(_daytime + 10) - 2); In this case, because daytime is 0.5, the temperature will be (0.5+10)*10-2 = 1.5*10-2 = 15-2 = 13° Share this post Link to post Share on other sites
Kingsley1997 39 Posted December 31, 2015 I actually recommend getting stuff like this worked out in something like Excel where you can quickly draw up formulas and get the math right. Once that's right, work out how you want it to be handled in-game... Every X seconds, once, on a particular event etc. and then you can start to implement it. While planning can be a pain, it's often worth it when implementing things like this so that you don't shoot yourself in the foot later on. Share this post Link to post Share on other sites
badpr1m3r 2 Posted October 12, 2017 Any luck with your script I'm working on a Thirsk winter survival mission and could use something like this. Share this post Link to post Share on other sites
das attorney 858 Posted October 13, 2017 49 minutes ago, badpr1m3r said: Any luck with your script I'm working on a Thirsk winter survival mission and could use something like this. He last visited these forums in Nov 2016 - maybe he'll be back, you might be better off pming him or writing it yourself. Share this post Link to post Share on other sites
badpr1m3r 2 Posted October 13, 2017 Ha, writing it myself. Good one. Share this post Link to post Share on other sites
das attorney 858 Posted October 13, 2017 38 minutes ago, badpr1m3r said: Ha, writing it myself. Good one. Okay, if you don't know enough to put together a script then fair enough. If you turn it into a joke, then that's up to you. Ha ha. It doesn't really advance what you could learn though. 4 Share this post Link to post Share on other sites
badpr1m3r 2 Posted October 13, 2017 Lol, yea I mean I would have to go all over the place to figure out how to put this together. Just asking for a headache. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted October 13, 2017 2 hours ago, badpr1m3r said: Lol, yea I mean I would have to go all over the place to figure out how to put this together. Just asking for a headache. You mean like most of us? Cheers 3 Share this post Link to post Share on other sites
badpr1m3r 2 Posted October 13, 2017 Ah yes, the scripting rights of passage. The old I had it hard so you should too lol. Very well dudes take care. You gotta be fond of something to give yourself gray hairs doing it. For me I'm forced in order to accomplish what I'm in need of. Not very interesting. I'm the designer. I just put all the cool stuff together. 1 Share this post Link to post Share on other sites
Sgt. Dennenboom 98 Posted October 13, 2017 Once you get the hang of the language and its quirks, it won't give you gray hairs anymore. There's not many things more relaxing for me than scripting something to work exactly as you envisioned :D Ofcourse it's not everybody's cup of tea Share this post Link to post Share on other sites
badpr1m3r 2 Posted October 13, 2017 Gotcha, think this project is just a little too advanced for a beginner to take on. Share this post Link to post Share on other sites
pierremgi 4850 Posted October 14, 2017 1 hour ago, badpr1m3r said: Gotcha, think this project is just a little too advanced for a beginner to take on. 0 = [] spawn { while {true} do { _temp = dayTime * whatYouWant ; _damage = - (otherVar * _temp); }; }; with temp something like: _temp = -10 + 20/12 * ( dayTime min (24 - dayTime)); // (Celsius) Here what you want means, it's up to you defining a temp law = f (time of the day). Usually, you can find some tips on internet. there can be a 3hr delay between the sun position and the effect on temperature on ground (3 AM could be the lowest temp, 3 PM the highest) but that depends on so much other factors! You can work around dayTime command (0 to 24), but also fog (0 to 1) or fogParams , rain (0 to 1) , overcast (0 to 1), and even simulCloudDensity (0 to 1 ?) 1 Share this post Link to post Share on other sites
Von Quest 1163 Posted October 14, 2017 Start with the Map Location. And decide what the COLDEST Base Temp is at the COLDEST Time of Day. You need to set your defaults for all Maps you want to include. Then just count up, adding the numbers for each Month, and Time of day. So the coldest would be (guessing, ballpark) January, and at Midnight just to keep things simple. Then the formula would be 0 for January, and 0 for Midnight. Add your starting Map Default Temp Coldest, then count up adding the variables starting at January, and Midnight. You will need to set your defaults for all Months, and modifiers for any Time of Day levels. For example: Altis = 30° (coldest, January, Midnight, Mediterranean Climate) January = 0; February = 10; March = 15; etc. So, the coldest temp in the example, in March would be 45° at Midnight. Do the same for Time of Day. 24hr format, so Midnight is 0, 6am is 6, 1pm is then 13 and so on. 0000hrs = 0; 0100hrs = 1; 0200hrs = 2; etc. This is all pseudocode, concept of course. So at the start of the game: _getMapLocation; _getDateTime; if (_mapAltis) then {_useAltisStuff}; if (_tooCold) then { _health = getPlayerDamage; setPlayerDamage (_health - 0.1); }; sleep (600 + random 1800); Don't use that, proof of concept only. On my phone right now. The trick is to start at ZERO and count up as the temp gets warmer. Set your defaults, then run a long loop with a series of if/then checks. Start small. Build in small code blocks. Check each step. Expand from there. You can code in long sections per file, or break it down in segregated files if it helps. You might want to have a separate execVM file for each Map you want to include. Hope this helps. if ( _mapAltis ) then { execVM "example_file.sqf"; }; Ninja'd LOL. pierremgi beat me to it. 1 Share this post Link to post Share on other sites
badpr1m3r 2 Posted October 14, 2017 Awesome thanks for explaining the concept and code guys I will be attempting to set something up with it. Share this post Link to post Share on other sites