Spoor 23 Posted June 20, 2018 Working on a TvT Campaign and would like to have a script that changes a flag when a faction captured an area (trigger) been looking around but can't find anything suitable - help appriciated - thanks Share this post Link to post Share on other sites
pierremgi 4690 Posted June 21, 2018 Hello, What you could do: _ place a none,none, non repeatable trigger (just for its area, and its position btw) then in cond: true and on act field: 0 = thisTrigger spawn { _trig = _this; _flag = objNull; _flagType = ""; _eastFlag = "Flag_CSAT_F"; _westFlag = "Flag_US_F"; _neutral = "Flag_White_F"; while {true} do { if ((West countSide (allUnits select {_x inArea _this}) == East countSide (allUnits select {_x inArea _this})) && _flagType != _neutral) then { _flagType = _neutral; deleteVehicle _flag; _flag = createVehicle [_neutral, getpos _trig, [], 0, "Can_collide"]; }; if ((West countSide (allUnits select {_x inArea _this}) > East countSide (allUnits select {_x inArea _this})) && _flagType != _westFlag) then { _flagType = _westFlag; deleteVehicle _flag; _flag = createVehicle [_westFlag, getpos _trig, [], 0, "Can_collide"]; }; sleep 1; if ((west countSide (allUnits select {_x inArea _this}) < East countSide (allUnits select {_x inArea _this})) && _flagType != _eastFlag) then { _flagType = _eastFlag; deleteVehicle _flag; _flag = createVehicle [_eastFlag, getpos _trig, [], 0, "Can_collide"]; }; sleep 1; }; }; You catch the principle. 1 1 Share this post Link to post Share on other sites
Mr H. 399 Posted June 22, 2018 or flags have hidden selection textures so you could change them instead of creating a new flag every time, useful if you want to use customized textures 2 1 Share this post Link to post Share on other sites
HazJ 1288 Posted June 23, 2018 ^^ Simple as: https://community.bistudio.com/wiki/setFlagTexture Unless I misunderstood. https://community.bistudio.com/wiki/Flag_Textures 1 1 Share this post Link to post Share on other sites
7erra 628 Posted June 24, 2018 (edited) How about an actually capturable flagpole? /* Author: 7erra Description: Makes a flag pole capturable Parameter(s): 0: OBJECT - Flag (optional) 1: CODE - Code executed after the cap Returns: NUMBER - Action ID of the Hold Action Example: [this] call TAG_fncName; [this,{hint "Capped";}] call TAG_fncName; */ #define FLAG_PATH(TEXTURE) (format ["\a3\data_f\flags\%1.paa",TEXTURE]) #define NATO_FLAG FLAG_PATH("flag_nato_co") #define CSAT_FLAG FLAG_PATH("flag_csat_co") #define AAF_FLAG FLAG_PATH("flag_aaf_co") #define EMPTY_FLAG FLAG_PATH("flag_white_co") #define HOLDACTION_PARAMS ["_flag", "_caller", "_actionId", "_arguments"] #define FLAG_ARRAY [NATO_FLAG,CSAT_FLAG,AAF_FLAG,EMPTY_FLAG] #define SIDE_ARRAY [west,east,independent,civilian] #define OWN_FLAG(ARG_SIDE) (FLAG_ARRAY select (SIDE_ARRAY find ARG_SIDE)) params ["_flag",["_afterCommand",{}]]; _flag setflagAnimationPhase 1; _flag setFlagTexture EMPTY_FLAG; _flag setVariable ["TER_flagSide",civilian]; _icon = "\a3\ui_f\data\igui\cfg\holdactions\holdaction_takeoff2_ca.paa"; _duration = 10; _addID = [_flag, "Capture Flag", _icon, _icon, "_target getVariable [""TER_flagSide"",civilian] != side _this",//condition show "true", {//code start }, {// code progress -> set flag height params (HOLDACTION_PARAMS+["_progress", "_maxProgress"]); _relProgress = _progress/_maxProgress; if (_relProgress < 0.5) then { _flag setFlagAnimationPhase (1-(2*_relProgress)); } else { if (_relProgress == 0.5) then {_flag setFlagTexture OWN_FLAG(side _caller)}; _flag setFlagAnimationPhase ((2*_relProgress)-1); }; }, {// codeCompleted params HOLDACTION_PARAMS; _flag setVariable ["TER_flagSide",side _caller]; [] call (_arguments select 0); }, {//codeInterrupted //revert params HOLDACTION_PARAMS; _flag setFlagAnimationPhase 1; _side = _flag getVariable ["TER_flagSide",civilian]; _flag setFlagTexture OWN_FLAG(_side); }, [_afterCommand], _duration, 1.5, false] call BIS_fnc_holdActionAdd; _addID ---EDIT--- Function for the init line further down below Edited June 26, 2018 by 7erra better function 1 2 Share this post Link to post Share on other sites
Larrow 2753 Posted June 24, 2018 On 6/20/2018 at 2:34 PM, Spoor said: that changes a flag when a faction captured an area (trigger) I presume you do actually mean just a trigger and have your own setup? As if your using a sector then you can synchronise a flagpole ( anything that inherits from Flag_F ) and the sector will automatically update the flag for you. Thought I would point that out just in case. 1 Share this post Link to post Share on other sites
Spoor 23 Posted June 24, 2018 Gents, Thanks all will test in the mission later - let y know. @Larrow sync with sector controll module I know but would like to have flag changing without the module just with a tricker - thanks. I like @7erra idea aswell - and @pierremgi scripts works always :-) - again thanks guys Best Spoor 1 Share this post Link to post Share on other sites
Spoor 23 Posted June 26, 2018 @pierremgi - works however when leave the trigger area the flag turns white again. The flag should stay at the faction who captured the area - please to hear. @7erra - noob here :-( but trying hard) - do you have a sample mission for me to see how things has been put together can't get it work. Thanks Gents Best 1 Share this post Link to post Share on other sites
7erra 628 Posted June 26, 2018 2 hours ago, Spoor said: noob here :-( but trying hard) - do you have a sample mission for me to see how things has been put together can't get it work. That's okay I started off with mashing commands together with auto complete and hoping they'd work :D. I have rewritten the code so you can copy and paste it into the init line of an editor-placed flag: _flag = this; _afterCommand = {}; _fncOwnFlag = { params ["_winSide"]; _flagPath = "\a3\data_f\flags\%1.paa"; _fileFlag = switch _winSide do { case west: {"flag_nato_co"}; case east: {"flag_csat_co"}; case independent: {"flag_aaf_co"}; default {"flag_white_co"} }; format [_flagPath,_fileFlag]; }; _actionParams = ["_flag", "_caller", "_actionId", "_arguments"]; _flag setflagAnimationPhase 1; _flag setFlagTexture (civilian call _fncOwnFlag); _flag setVariable ["TER_flagSide",civilian]; _icon = "\a3\ui_f\data\igui\cfg\holdactions\holdaction_takeoff2_ca.paa"; _duration = 10; _addID = [_flag, "Capture Flag", _icon, _icon, "_target getVariable [""TER_flagSide"",civilian] != side _this", "true", { }, { params ["_flag", "_caller", "_actionId", "_arguments","_progress","_maxProgress"]; _arguments params ["_actionParams","_fncOwnFlag","_afterCommand"]; _relProgress = _progress/_maxProgress; if (_relProgress < 0.5) then { _flag setFlagAnimationPhase (1-(2*_relProgress)); } else { if (_relProgress == 0.5) then {_flag setFlagTexture (side _caller call _fncOwnFlag)}; _flag setFlagAnimationPhase ((2*_relProgress)-1); }; }, { params ["_flag", "_caller", "_actionId", "_arguments"]; _arguments params ["_actionParams","_fncOwnFlag","_afterCommand"]; _flag setVariable ["TER_flagSide",side _caller]; [] call _afterCommand; }, { params ["_flag", "_caller", "_actionId", "_arguments"]; _arguments params ["_actionParams","_fncOwnFlag","_afterCommand"]; _flag setFlagAnimationPhase 1; _side = _flag getVariable ["TER_flagSide",civilian]; _flag setFlagTexture (_side call _fncOwnFlag); }, [_actionParams,_fncOwnFlag,_afterCommand], _duration, 1.5, false] call BIS_fnc_holdActionAdd; _addID Here is a demo mission: Demo mission on Google Drive: demoMission_capFlag.vr 3 Share this post Link to post Share on other sites
pierremgi 4690 Posted June 26, 2018 4 hours ago, Spoor said: @pierremgi - works however when leave the trigger area the flag turns white again. The flag should stay at the faction who captured the area - please to hear. @7erra - noob here :-( but trying hard) - do you have a sample mission for me to see how things has been put together can't get it work. Thanks Gents Best It was intended but you just have to remove the first condition (when east == west). Share this post Link to post Share on other sites
Spoor 23 Posted June 26, 2018 5 hours ago, pierremgi said: It was intended but you just have to remove the first condition (when east == west). @pierremgi thanks Share this post Link to post Share on other sites
Spoor 23 Posted July 16, 2018 @Larrow @pierremgi @7erra - thanks Gents all work just fine and inlcuded the Campaign 1 Share this post Link to post Share on other sites