AngusHeaf 0 Posted March 22, 2003 I wrote an absolute sealevel function that, in my opinion, is more accurate than those that have come before. I know the scripting works but I'm trying to compartmentalize the code by making the sea level height script into a function. To make a long story short, I'm at the end of my rope. I've looked at this function for hours and for some reason it refuses to work. I'm using OFP 1.90 and I've read all the coding references but still I get this bizarre bool array error when I try to output the height value to a hint (for debugging purposes). I'm calling the function from a script file that calls the function twice (to get the height of two objects) then calculate the difference in height between them. Check out my files and PLEASE see if there's something I just missed in the way of syntax! Many thanks to anyone who helps. Download SeaLevel Height Test Share this post Link to post Share on other sites
AngusHeaf 0 Posted March 22, 2003 Ok well, for those of you who don't want to download, unzip, and run the files I included I'll include the important stuff below... I realized a lot of you might have A.D.D. Â MISSION.SQM 3 objects on map. 1 soldier (man), 1 jeep (jeep), 1 trigger (sealeveltrig). Man has "[man,jeep] exec "logic_getheightdif.sqs"" as INIT. This starts the script going. INIT.SQS </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">sealeveltrig setPos [0,0,0]; GetHeight = preProcessFile "func_getheight.sqf"<span id='postcolor'> LOGIC_GETHEIGHTDIF.SQS </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">; ************************************************************************************* ; Initialize input variables _obj1 = _this select 0; _obj2 = _this select 1; sealeveltrig setPos [0,0,0]; ; ************************************************************************************* ; Find height of each of the two objects above sea level and then calc the difference _obj1h = [_obj1] call GetHeight _obj2h = [_obj2] call GetHeight _dif = _obj1h - _obj2h hint format ["Debug Info...\nObj1h: %1 \nObj2h: %2 \nDif: %3", _obj1h, _obj2h, _dif]<span id='postcolor'> FUNC_GETHEIGHT.SQF </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">// ************************************************************************************* // Initialize variables _obj = _this select 0; // ************************************************************************************* // Find the height of the object sealeveltrig setPos [0,0,0]; _3ddist = _obj distance ABS; _a = (getpos _obj select 0)^2; _b = (getpos _obj select 1)^2; _2ddist = sqrt (_a + _b); objh = sqrt ((_3ddist ^ 2) - (_2ddist ^ 2))<span id='postcolor'> Somewhere along the way the function is not passing any values back to the script Logic_GetHeightDif.sqs. Or perhaps the function isn't running at all, it's damn hard to tell. Share this post Link to post Share on other sites
Guest jacobaby Posted March 23, 2003 ABS in the function needs to be an object ni the mission, usually the seal level trigger I think. I too spent a LOT of time on sea level scripting, for my rotorwash script. In the end I managed to get an extremely accurate version that would return the exact height of sea level so precisely that it continually gave you the exact figure. I think I posted a video clip of it in action where you could see the rise and fall of the sea level affecting the type of wash produced. However, I found that different Islands act differently, and a script suitable for one wasnt accurate on another. So in the end I gave up and settled for a compromise. And do you know what? Nobody noticed. So bear in mind that you could WASTE a lot of time on this..... TJ Share this post Link to post Share on other sites
Guest jacobaby Posted March 23, 2003 Oh yeh, something else I just found out, that may be of interest. if you createvehicle a trigger (emptydetector) at position [0,0,0] it starts at sea level, but after setpos'ing it to [0,0,0] it goes to absolute zero sea bed. Share this post Link to post Share on other sites
AngusHeaf 0 Posted March 23, 2003 Crapola. Damn variable names. That'll teach me to change my variable names after coding things. ABS should be "sealeveltrig". However, fixing that error does not clear up the scalar bool array error. So that's not it. By the way, that error came when I was cutting my script out of the mission I'm working on so I could upload a map with just the height script. In working form (script form not function form) the script doesn't seem to set the trigger at sea-bed Z value like you suggest. At least I don't think it is considering if I stand right on the shore my sealevel height is 0. But even if it did, ultimately I'm only writing this script so that I can calculate the difference between two sealevel heights. So it's not a big deal. Any idea why it's still not working? Share this post Link to post Share on other sites
Guest jacobaby Posted March 23, 2003 A gamelogic or invisible H is created on the "top" of the sea, as opposed to a trigger which is created DEAD bottom of the sea. Try standing on a hill with a trigger at your position and call a distance command, you to the trigger. So for differences in sea level you just need to have the differences between the invisible H and the trigger updated on a continual basis. Try putting the maths into brackets, its all i can see. </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _dif = (_obj1- _obj2) <span id='postcolor'> TJ Share this post Link to post Share on other sites