Jump to content


  • Content Count

  • Joined

  • Last visited

  • Medals

Everything posted by pedeathtrian

  1. pedeathtrian

    Filepatching and userconfig file

    _contents = compile preprocessFileLineNumbers "\userconfig\VCOM_AI\AISettingsV2.hpp"; if !(_contents isEqualTo {}) then { #include "\userconfig\VCOM_AI\AISettingsV2.hpp"; }; Your code contains #include directive, so you run preprocessor on it before it is executed. Before you have any chance to do any preprocessFileLineNumbers, compile or isEqualTo calls. This is why it's called preprocessor. And it will fail before you can check whether it will fail or not. preprocessFileLineNumbers should actually work (and even loadFile is enough), but you should check whether it fails before the very first attempt to preprocess file containing #include directive on file being checked.
  2. six_ten, I assume you have inherited class Weathervane from (cfgModels >> NameOfP3d >> Animations), (see https://community.bistudio.com/wiki/Model_Config#config.cpp_model.cfg_relationship ). As far as I can understand, AnimationSources is for establishing direct user interaction with object, so not needed in your case. The source string seem to be the controller of your animation, in your case "windDir". So I guess you control your animation with call myWeatherVane animate ["windDir", phase]; from anywhere from your scrips (animate: aG, eG), where myWeatherVane is your weathervane object (vehicle) and phase is in [-pi, pi] according to your minValue=-3.141590; and maxValue=3.141590; I guess (again) that compass angle 0 for your axis will be wind's direction also 0 and phase value grows counterclockwise, as radians naturally do. Then convert windDir to phase using private ["_wd"]; _wd = windDir; phase = rad ( if (_wd < 180) then {-_wd} else {360-_wd} ); To be not confused in the future, I recommend rename "windDir" to smth like "WeatherVaneCtrl" or so. Now you only have to periodically call animate with required phase argument. Start with onEachFrame just to check if it works. Hope that helps. pS. If it does not work, try creating AnimationSource in config.cpp with class name windDir (or replaced).
  3. pedeathtrian

    Arrays, and subtracting issues

    Why not filter by city names? If for some reasons (I don't see yet) it is not possible, you can still use distance2D command, then compare to some threshold. Some other considerations about the code: 1. Try to eliminate as much nested cycles as possible. 2. Get rid of hardcoded values in code (unless not in defaults list). Pass as function arguments, store in mission-specific locations: parameters, global variables, etc. If in some time in the future you will want to port your mission to another world you will have to do less work. Even if mission remains unported it will be much more readable. Well, that's all words, here's the code. Spawn_fnc_getCities = { params [ // params since 1.48 ["_exclNames", [], [[]]], // can be both config names and cities' display names ["_exclPoses", [], [[]]], // probably will not be needed because of names are much easier to list ["_inclTypes", ["NameVillage","NameCity","NameCityCapital","NameLocal"], [[]]], // default params values (reluctantly) hardcoded here. could be reference to global variable or smth. ["_inclNames", [], [[]]], // can be both config names and cities' display names, even with types not specified in _inclTypes; positions included if names found ["_inclPoses", [], [[]]], // unconditionally include these positions ["_tol", 10, [3.14159]] ]; _tol = abs _tol; // in case negative specified // some more args validity checks could be performed here... private ["_locations", "_cities"]; _cities = []; // after this line _locations will be filtered by type and excluded names _locations = (format ['(getText(_x >> "type") in %1) && !(getText(_x >> "name") in %2) && !(configName(_x) in %2)', _inclTypes, _exclNames]) configClasses (configfile >> "CfgWorlds" >> worldName >> "Names"); // now filter by excluded positions { private ["_cityPos", "_good"]; _cityPos = getArray(_x >> "position"); _good = true; scopeName "locs"; { if ((_x distance2D _cityPos) < abs(_tol)) then { // distance2D since 1.50 _good = false; breakTo "locs"; }; } forEach _exclPoses; if (_good) then { _cities pushBack _cityPos; }; } forEach _locations; // adding custom positions by names { _cities pushBack getArray(_x >> "position"); } forEach ((format ['(getText(_x >> "name") in %1) || (configName(_x) in %1)', _inclNames]) configClasses (configfile >> "CfgWorlds" >> worldName >> "Names")); // adding custom positions by positions // select with code since 1.55 dev 155,133771. alternatively could be implemented as simple loop or _inclPoses added with + operator w/o validity check _cities = _cities + (_inclPoses select {((typeName _x) == "ARRAY") && ((count _x) == 2) && ((typeName (_x select 0)) == "SCALAR") && ((typeName (_x select 1)) == "SCALAR")}); _cities };
  4. pedeathtrian

    Editor : How to place units on the top floor of a building?

    No need to do a lot of previewing. Place a playable unit on desired position at approximate height. Write to its init: this addAction ["Show current height ATL", {systemChat format ["Current height ATL: %1", (getPosATL (_this select 0)) select 2]}]; You will have action "Show current height ATL" which when activated will write your current height above the terrain level (ATL). You can use this value later for (almost) precise positioning.