Jump to content

pedeathtrian

Member
  • Content Count

    284
  • Joined

  • Last visited

  • Medals

Posts posted by pedeathtrian


  1. Yeah, I was trying to say it from the beginning:

    As far as I can understand, AnimationSources is for establishing direct user interaction with object, so not needed in your case.

    ...
    Now you only have to periodically call animate with required phase argument. Start with onEachFrame just to check if it works.

    From my understanding, unless you have builtin animation source, model will not (and probably can not) update itself on its own behalf. You need to perform external command to be pefrormed for that (i.e. animate).

    Check this: https://community.bistudio.com/wiki/onEachFrameIt can impact performance, so I don't recommend it as final solution, but should work for first test. After you check everything works, you will need some othe system (e.g. script) that runs animate command for your weathervane. The problem is, I don't see clear now, how to do it properly. I mean, I know how to organize some sort of script in mission which would call some other script periodically. But that seems wrong way for me. There should be some way to make object behaviour entirely object-hosted, so you could place it anywhere and it will work instantly.

    Btw, I'm still not sure whether you need AnimationSourrces definitions or not. Can you check everything without them and report here then?

    • Like 1

  2. It works well - except for the CTD for clients without the file... So far #include is one of the few things that work with filepatching disabled.

    Again, because the check (isServer) is localted in the same file and performed after file was preprocessed (and game possibly crashed).

    What I was suggesting (well, ok, I only implied, my bad) was to take away the check from the file with #include. Something like this:

     

    PublicScript = compileFinal "[] call (_this select 0);  systemchat format ['%1',_this select 0];";
    
    if (isServer) then
    {
    	call compile preprocessFileLineNumbers "VCOMAI\Functions\VCOM_dangerous_file_loader.sqf";
    };
    

    Where "VCOMAI\Functions\VCOM_dangerous_file_loader.sqf" has all include-dependent contents and not preprocessed before check / if check fails (this check could be loadFile, as I stated in previous post, without `compile' or `call' calls, just to check that content of file are not empty):

    #include "\userconfig\VCOM_AI\AISettingsV2.hpp";
    if !(isNil "VCOMAI_Func") then 
    {
    	[] call VCOMAI_Func;
    }
    else
    {
    	VCOMAI_Func = compile preprocessFileLineNumbers "VCOMAI\Functions\VCOMAI_DefaultSettings.sqf";
    	[] call VCOMAI_Func;
    };
    [VCOMAI_Func] remoteExec ["PublicScript",0,true];
    
    • Like 2

  3. _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.


  4. 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).
    • Like 1

  5. 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
    };
    

  6. 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.

×