Jump to content

sarogahtyp

Member
  • Content Count

    2494
  • Joined

  • Last visited

  • Medals

Everything posted by sarogahtyp

  1. Original array gets modified: yeah this is true the original nodes array gets modified and will contain the solution. this is thought for spawning the script because if you spawn it then there is no return value. true value if no solution is possible: this is true as well and it is the way the script works. true means no solution possible. false means input data is not valid I tried to descibe all of that in the header of my scripts but maybe that desciption was a little short.
  2. yes you found a bug but compared with the "squared distances bug" it was a minor issue. But I fixed this as well, thank you for your findings. huh, my code is confusing me all the time I try to read it. I just try to not give up^^ Yeah I tried it that way but I did'nt read the description carefully enough. Now I think doing the nesseccary checks would consume more runtime than just calculating till the end node is reached. That's too much credit for me. I'm just an old fool trying to sort out the gibberish in my head and write it into code. That's too much credit for me. I'm just an old fool trying to sort out the gibberish in my head and write it into code. what are you working on? depending on the problem the A* algorithm could be much faster than dijkstra. In my latest tests using the version where the bugs are fixed I had A* always finding the same solution as dijkstra. In most cases A* is much faster. There are some cases when using multiple floors/layers where A* is much slower but although is finding the same solution as dijkstra...
  3. okay, this was a hard 'n heavy bug hunt^^ I crawled the code multiple hours back and forth and forth and back and I did not find any big issue with it. The bottom line is that there is no issue with the algorithm itself in the code. The issue was the distance calculation for the connections. I used distanceSqr to be a "smart guy" and write a fast code. But fast is b*llshit if it is just wrong. Why is it wrong there to use squared distances for the connections? the picture shows it: The problem is the Theorem of Pythagoras. (Which is very funny if you ever read my name backwards) if you want to go from A to B and use squared distances then the distance between A and B is the same as the sum of the distances between A and C and between C and B. That means using squared distances will often end up in selecting the longer way.
  4. Some little words bout the solution mentioned above: This solution is not very flexebile. No, its the opposite. You always have to rebuild the whole mission file if you wan't to delete or add a steam ID from/to the whitelist. Thats a thing you have to live with if u wanna have an easy solution. A flexible solution where you are able to edit those list at any time and the server handles that list nearly instant can be archieved with database integration only. To do this you need a database mod, a database and the knowledge bout accessing the database via sqf. But all of this is far beyond the things I can tell you about in this forum.
  5. sarogahtyp

    HandleDamage Event Handler Explained

    the difference is that u just can say a double deadly damage is okay but five times is not. this means that you can die by one damage event but it will not happen as often as before: ( _previousDamage + ( _newDamage min 2 ) * 0.7 ) with ur solution it is not possible to die with one damage event if u had no damage before. but I would not say that one solution is better than the other. It simply depends on what you need and prefer.
  6. trust me, u dont like to send ur script to all clients because it would run createVehicle there and you would have 4 created vehicles for every connected client. on a 10 player session you would create 40 vehicles this way. the easiest way is to execute the script on the client which started the addAction and use remoteExec as described in wiki example 2 for every hint message of your script.
  7. It should be located in fn_shortPathDijkstra.sqf but where exactly ... I ve no clue. Im not even sure if I tested it correctly and if the bug is really one. Therefore you should firstly test if those bug is there using the test mission. As far as I remember I did a strict implementation of the algorithm shown on wikipedia. therefore I always wondered why it is not finding the shortest path always.
  8. sarogahtyp

    Call or Spawn

    the only thing what runs unscheduled in ur examples is the content of the isNil command. everything else runs scheduled.
  9. sarogahtyp

    HandleDamage Event Handler Explained

    you could also use this to cap those deadly damage to 1 (or whatever u like) and reduce by 30% afterwards: ( _previousDamage + ( _newDamage min 1 ) * 0.7 )
  10. sarogahtyp

    Call or Spawn

    The most important biki page for understanding the different environments is this one: https://community.bistudio.com/wiki/Scheduler It was linked already by @dreadedentity but I would like to explicitly recommend reading this page for a better understanding.
  11. I did not test anything, just wrote some stuff out of my mind... initServer.sqf myGlobalWhitelist = [ "5673401289675890234", "4702358907894532849", "4352089734208957689" ]; //grab all players on connect to check if whitelisted addMissionEventHandler ["PlayerConnected", { params ["", "_uid", "_name"]; if !( _uid in myGlobalWhitelist) then { //kick not whitelisted player serverCommand format ["#kick %1", _name]; //log to .rpt file diag_log format ["kicked player: %1 for using not whitelisted UID: %2", _name, _uid]; }; }];
  12. if you want to get rid of the duplicates then you can use: _types = []; { _types pushBackUnique (typeOf _x); } forEach allUnits; copyToClipboard str _types; or _types = allUnits apply {typeOf _x}; copyToClipboard str (_types arrayIntersect _types); I guess there are speed differences between both solutions but I dont like to test it^^
  13. it seems this is intended behavior. the reason is the players rating value. if it is too low then you can't hack anymore. killing your sides vehicles lowers the rating value. you can test it in debug console. with player addRating -20000 now u r unable to hack. after using this: player addRating 20000 you r able to hack again ...
  14. this can't work that way for many reasons. Ill give u a solution but I guess for understanding it you have to get much more experience in scripting. The solution is to do it without any trigger but with 2 files. 1. File is for defining a function in armas function library. those function is defined to get executed automatically prior executiion of the init fields of objects. The file hase to be named description.ext and has to be located in missions root folder. The root folder is where your missions mission.sqm is located as well. here is the content of that file: description.ext class CfgFunctions { class vissarion { class viss_functions { class randomVars { preinit = 1; }; }; }; }; 2. file is the script itself which we defined in description.ext. it has to be located in a subfolder of missions root:<ROOT>\functions\viss_functions\fn_randomVars.sqf this file will set the variables Alpha and Bravo first and after that it will change it to the opposite values if the randomization requires it: fn_randomVars.sqf Alpha = false; Bravo = true; if ( random 3 > 1) then { Alpha = true; Bravo = false; }; Now you are able to use Alpha and Bravo in your init fields. This solution is not that easy as you thought but its no rocket science as well 🙂 Its a very clean solution and it is tested and works.
  15. sarogahtyp

    Unit Spawning Loop

    nul = [] spawn { for "_i" from 1 to 5 do { jet1 = createVehicle ["O_Plane_CAS_02_dynamicLoadout_F", getMarkerPos "JetSpawn", [], 0, "FLY"]; createVehicleCrew jet1; jet1 FlyInHeight 500; wp1 = group driver jet1 addWaypoint [getMarkerPos "JetPatrol",0]; null = [group driver jet1, (getMarkerPos "JetPatrol"),8000] call BIS_fnc_taskPatrol; sleep 15; }; }; https://community.bistudio.com/wiki/for
  16. sarogahtyp

    Unit Spawning Loop

    which loop? what purpose?
  17. Hey guys, with ur help in this Topic I managed to write a script which can predict a targets Position in the moment when ur current magazines ammo is reaching it. I ll post an example Mission within the next days. And here it is: /* Author: Sarogahtyp File: pre_tar_pos.sqf Description: Calculates the postion of a moving target at the time the bullet of shooters current magazine is arriving at target. Works with most self propelled weapons, too. Works with vehicles. Tested without MODs only - vanilla style. Version 0.0 Pre-Alpha Known issues: Not working with RPG but will be fixed soon. Parameter(s): 0: target - the object the shooter wants to shoot at - default is the nearest target to shooters crosshair 1: shooter - the one who wants to shoot at target - default is the player Returns: position - position of the target when the current bullet will reach it */ params [["_target", cursorTarget], ["_shooter", player], ["_speed_coef_muzzle", 1], ["_flight_dist", 0], "_weapon", "_magazine", "_init_speed_gun", "_init_speed_mag", "_ammo_class", "_air_friction", "_items", "_init_time", "_max_speed", "_thrust", "_thrust_time", "_rel_speed", ["_air_fric_fact", -0.002], ["_burned_out", false], ["_prop_started", false], ["_burn_time", 0], ["_last_dist", 0], ["_last_time", 0], ["_time_diff", 0], "_distance", "_dist_step", "_last_speed", "_last_accel", "_new_dist", "_term", "_new_time", "_new_speed", "_new_accel"]; _shooter = vehicle _shooter; _weapon = currentWeapon _shooter; _magazine = currentMagazine _shooter; _init_speed_gun = getNumber(configfile >> "CfgWeapons" >> _weapon >> "initSpeed"); _init_speed_mag = getNumber(configfile >> "CfgMagazines" >> _magazine >> "initSpeed"); _ammo_class = getText(configFile >> "CfgMagazines" >> _magazine >> "ammo"); _air_friction = getNumber(configFile >> "CfgAmmo" >> _ammo_class >> "airFriction"); _items = _shooter weaponAccessories _weapon; _init_time = getNumber(configFile >> "CfgAmmo" >> _ammo_class >> "initTime"); _max_speed = getNumber(configFile >> "CfgAmmo" >> _ammo_class >> "maxSpeed"); _thrust = getNumber(configFile >> "CfgAmmo" >> _ammo_class >> "thrust"); _thrust_time = getNumber(configFile >> "CfgAmmo" >> _ammo_class >> "thrustTime");; _rel_speed = ((velocity _target) vectorDiff (velocity _shooter)); if((_init_speed_gun) < 0) then { _init_speed_gun = -1 * init_speed_gun * _init_speed_mag; }; if((_init_speed_gun) == 0) then { _init_speed_gun = _init_speed_mag; }; { if((_x find "muzzle") > -1) then { _temp_coef = getNumber(configfile >> "CfgWeapons" >> _x >> "ItemInfo" >> "MagazineCoef" >> "initSpeed"); _speed_coef_muzzle = if (_temp_coef !=0) then {_temp_coef}else{1}; }; } forEach _items; _init_speed_gun = _init_speed_gun * _speed_coef_muzzle; if((vectorMagnitude _rel_speed) > 0) exitWith { _distance = _target distance _shooter; if(_air_friction > 0) then {_air_friction = _air_friction * _air_fric_fact;}; _dist_step = _distance / (10 * diag_fps); _last_speed = _init_speed_gun; _last_accel = _air_friction * _init_speed_gun ^ 2; while {_last_dist < _distance} do { _new_dist = _last_dist + _dist_step; //calculate time from last position to actual position (_time_diff) if (_last_accel < 0) then // standard case - bullet is decelerated by airflow { _term = _last_speed / _last_accel; _time_diff = -1 * sqrt (_term ^ 2 + 2 * _dist_step / _last_accel) - _term; } else { if(_last_accel == 0) then //maybe no value for air friction stored in config then we have just t=s/v { _time_diff = _dist_step / _last_speed; } else // positive acceleration should happen if a propulsion is burning only { _term = _last_speed / _last_accel; _time_diff = sqrt (_term ^ 2 + 2 * _dist_step / _last_accel) - _term; }; }; _new_time = _time_diff + _last_time; _new_speed = _last_speed + _last_accel * _time_diff; if(_new_speed <= 0) exitWith {0}; _new_accel = _air_friction * _new_speed ^ 2; //calc air frictions influence to acceleration //check if bullet is a rocket and if propulsion should accelerate if((_max_speed > 30) and (!_burned_out) and (_last_time > _init_time)) then { if(!_prop_started) then { _prop_started = true; _burn_time = diag_tickTime + _thrust_time; } else { if(diag_tickTime > _burn_time) then { _burned_out = true; }; }; _new_accel = _new_accel + _thrust; }; _last_dist = _new_dist; _last_time = _new_time; _last_speed = _new_speed; _last_accel = _new_accel; }; ((_target modelToWorld [0,0,1.2]) vectorAdd (_rel_speed vectorMultiply _last_time)) }; (_target modelToWorld [0,0,1.2]) Now I d like to optimize that script some more. My first question: Is the way I use params a good one? I just put every local variable in it to ensure it is private. The Problem I see is that someone could pass more than the 2 thought Parameters to the script. That would destroy the calculations. How can I avoid this? Beside that question tell me ur thoughts about the script please and also if u think ist worth a release if its more optimized. EDIT: this script is thought to be executed once each frame EDIT: moving this to first post ...
  18. Here is the mission I used to test it. But don't ask me how all of this works. It was a long time ago: https://www.dropbox.com/s/nuduogbp6csebfw/IR_laser_ranging.Altis.zip
  19. sarogahtyp

    Preventing reduced damage

    Players difficulty settings are forced by server in multiplayer.
  20. https://forums.bohemia.net/forums/topic/183993-scripting-introduction-for-new-scripters/
  21. I doubt that simply placing the module will take the AI over automatically. I guess you have to ensure that the mission spawns the AI on the HC. But Im not entirely sure bout it ... but nearly sure.
  22. Calling a heavy script in an unscheduled environment - like the onActivation fields are - leads to a nearly system halt as long as the script is executed. U should try to use spawn instead of call to give the system the time to execute other things as well.
  23. You just can't be a beginner and know the whole thing at the same time. Its (like) learning a language. To have the vocabularies and the grammar rules is not enough. You just need to practice it and you have to do it step by step. Mostly very small steps in the beginning... First thing most people learn is to say: "Hello (world)" in that language.
  24. @Soapbox0331 depends on your purpose and how you are trying to achieve it ...
  25. Are you on dev branch? The option is tagged as since 2.06 and the current official version is 2.04 afaik
×