damotr 49 Posted February 16, 2018 Hello again :D I don't know if anyone have done this before. I used models from MAPFACT, Chernobyl and KLA Powerlines. Powerline consists of three elements: - Source (e.g. Electric House) - Objects that may be controlled by source - Power cables In every electricity pylon model cabels are defined as "lines" and may be rotated around "axis" that is 100m below base of pylon. If one of the pylons is down - following will rotate its cabels so they are no longer visable (no floating things in the air... yay :D ) Also - if pylon in last in row - it's cables will stay hidden Script was created for using with modified islands, run by GameLogic element. Code of "Powerlines.sqs": In the movie I'm near the SECOND_LINE - that is just Electric House and lamp Explosion broke the FIRST_LINE _Hoes=["ElectricHo","Energy"] _Lamps=["StreetLamp","StreetLampWood","StreetLampMetal","StreetLampMetal2","StreetLampMetalSeda","StreetLampMetalStara1"] ;powerline: source(HO), line(b), objects(a) ; ; a a ; \ / ; HO-b-b-b-b-b-b-c(next HO) ; / \ ; a a ; ;LINE=[source id, [object ids] , [line-object ids], last element id, name of higher powerline, name of this line] ; ;simpliefied version ; ; ; ; d-b-b-b-b-b-b-c(next d) ; ; ; ;LINE=[source id, [] , [line-object ids], last element id, name of higher powerline, name of this line] ; ;all used lines definitions FIRST_LINE=[577,[],[576,667,719,775,814,861,970,1054,1132,1289],1383,"none","FIRST_LINE"] SECOND_LINE=[1383,[1516],[],1383,"FIRST_LINE","SECOND_LINE"] THIRD_LINE=[575,[],[718,774,860,969,1131],1288,"none","THIRD_LINE"] FOURTH_LINE=[578,[],[776,971],1290,"none","FOURTH_LINE"] ;creating matrix of active powerlines - active means that last element of the line has power SLX_ActiveLines=[] ; listing _listOfLines=[FIRST_LINE,SECOND_LINE,THIRD_LINE,FOURTH_LINE] _listOfLineNames=[] "_listOfLineNames=_listOfLineNames+[_x select 5]" foreach _listOfLines _num_lines=(count _listOfLines)-1 _num_line=-1 ; Hiding useless cables "if ((typeOf (object (_x select 3))) in _Hoes) then {} else {(object (_x select 3)) animate [{Fall},1]}" foreach _listOfLines #loop ~0.1 ;selection of powerline _num_line=_num_line+1 if(_num_line>_num_lines) then {_num_line=0} else {} _curr_line=_listOfLines select _num_line ;unpacking the matrix _curr_line_start=object (_curr_line select 0) _curr_line_objects=_curr_line select 1 _curr_line_line=_curr_line select 2 _curr_line_end=object (_curr_line select 3) _curr_line_dependency=_curr_line select 4 _curr_line_name=_curr_line select 5 ;OBJECT-RELATED OPERATIONS ;checking dependency if (_curr_line_dependency=="none") then {goto"over_dependency"} else {} if (_curr_line_dependency in SLX_ActiveLines) then {goto "over_dependency"} else {} goto "switchOFFobjects" #over_dependency ;checking if first element is broken if (ALIVE _curr_line_start) then {} else {goto "switchOFFobjects"} ;checking if first object is HO if ((typeOf _curr_line_start) in _Hoes) then {} else {goto "switchONobjects"} ;checking if HO is switched on if ((_curr_line_start animationPhase "Switch")>0.5) then {goto "switchOFFobjects"} else {goto "switchONobjects"} ;end of object-related operations #first_end ; LINE-RELATED OPERATIONS - SINGLE HO if (_curr_line_start==_curr_line_end) then {} else {goto "OverHUB"} if (_curr_line_dependency=="none") then {goto "loop"} else {} if (_curr_line_dependency in SLX_ActiveLines) then {goto "AddToActive"} else {} goto "RemoveFromActive" #OverHUB ; LINE-RELATED OPERATIONS - LINE ;checking if there is discontinuity _damMatrix=[] _allMatrix=[(_curr_line select 0)]+_curr_line_line+[(_curr_line select 3)] "if (ALIVE (object _x)) then {} else {_damMatrix=_damMatrix+[_x]}" foreach _allMatrix ;if no discontinuity - line works fine if ((count _damMatrix)==0) then {goto "AddToActive"} else {} ;hiding useless cables "if ((_allMatrix find _x)>0) then {if (ALIVE (object (_allMatrix select ((_allMatrix find _x)-1)))) then {(object (_allMatrix select ((_allMatrix find _x)-1))) animate [{Fall},1]} else {(object (_allMatrix select ((_allMatrix find _x)-1))) animate [{Fall},0.45]}} else {}" foreach _damMatrix goto "RemoveFromActive" #switchOFFobjects ; switching off all objects "(object _x) switchLight {OFF}" foreach _curr_line_objects goto "first_end" #switchONobjects ; switching on all objects "if (ALIVE (object _x)) then{(object _x) switchLight {ON}} else {}" foreach _curr_line_objects goto "first_end" #RemoveFromActive ; removing line from active list if (_curr_line_name in SLX_ActiveLines) then {SLX_ActiveLines=SLX_ActiveLines-[_curr_line_name]} else {} goto "loop" #AddToActive ; adding line from active list if (_curr_line_name in SLX_ActiveLines) then {} else {SLX_ActiveLines=SLX_ActiveLines+[_curr_line_name]} goto "loop" 5 Share this post Link to post Share on other sites
krzychuzokecia 719 Posted February 16, 2018 I remember Mapfact barracks addon containing a power switch, and they had a scripted solution to use it to turn off streetlights in an area, but nothing of this level of complexity! There was a power system simulation made by Loyalguard for Armas 1 & 2, but that's it. Congrats! Share this post Link to post Share on other sites
damotr 49 Posted February 16, 2018 Well... I just want to make OFP/CWA great again ;P 1 Share this post Link to post Share on other sites