Wrote (using code from
this thread as a base), that allows you to :
- Shut down power to whole island (All non-editor placed street lamps)
- Restore power to whole island
- Blow up a substation and take all near-by streetlamps out
Code for substation :
;[this,100] exec "substation.sqs"
; User defined varibles
_center = _this select 0
_range = _this select 1
;INIT
_maxid = 200000
_i = 0
_lightArray = []
; Start - Wait for desroyed station
#wait
~1
?(alive _center):goto "wait"
; Middle - Get all street lights
#loop
;one line \/
if ((typeof (object _i) in ["StreetLampPanel","StreetLampMetal","StreetLampWood","StreetLampPanelAmpl","StreetLampYellow","StreetLampCut"]) AND (object _i distance _center > _range)) then {object _i switchlight "OFF"}
;one line /\
_i = _i + 1
if (_i <= _maxid) then {goto "loop"}
;End
exit
Basicly, when the _center (substation) is dead, go from 0 to 200000, checking if current object number (I.e object 1234) is a streetlamp (typeof object _i in array of streetlamp types)
If it's < _range, shut it down
It's not very fast, but it gives it a nice effect of not shutting every light down instantly, it wouldn't happen that fast in reality
Power Station Down :
_maxid = 200000
_i = 0
#loop
;one line \/
if (typeof (object _i) in ["StreetLampPanel","StreetLampMetal","StreetLampWood","StreetLampPanelAmpl","StreetLampYellow","StreetLampCut"]) then {(object _i) switchlight "OFF"}
;one line /\
_i = _i + 1
;if this is startup script, uncomment the following line :
~random(0.1)
if (_i <= _maxid) then {goto "loop"}
exit
The startup script is identcal, apart from the switchlight bit is on, instead of off, and the line that's mentioned in script is uncommented (Makes the lights have a bigger delay when starting up, random between 0 and 0.1 makes lights take abour 10 seconds to come back up)
If this is usefull, I will further develop it, current ideas :
- Multi-thread the script, make the main script launch another, one handling, say, 1 to 5000, another handling 5001 to 10,000 etc. This will speed up the script a lot
- Make lights within x of desroyed substations not come back up, ever (add them to "disabled array"
- Substation objects - I don't recall ever seeing them. The power station exists in AGS Industry Pack, and I use the BIS "modern" computer to run the scripts from (Add action). Only thing missing is the substation to blow up
There may be better way of doing this (Killing all lights on map), but nearestobject doesn't work over 50meters, and isn't very easy making it find secondnearestobject
I've attached an script that uses the BIS modern computer as the substation and powerplant controler. You can shut down power to poor Nogava, or take out nearby lamps by desroying it (Shoot it a few times)
Anyway, this thread is kinda long for a simple script like this, but it can have many uses, from civillian RPG missions (Power Station owner killing power to island cause they refused to pay electicity bill?
), to covert assault missions (Take out the substation, and assault the enemy base under the cover of your artifical darkness)
Any comments or sugestions.. erm.. guess what I want you to do
If you guessed reply here, your correct
- Ben
[Edit : Added in thread link]