Home   Help Search Login Register  

Author Topic: Do something with all objects in an area (e.g.: switch off lights)  (Read 487 times)

0 Members and 1 Guest are viewing this topic.

csde-PiLLe

  • Guest
Hey guys,

as some of you might have guessed, I am doing a night attack mission involving paratroopers. See this thread for further information.

The "Target" I am talking about in the other thread is a power plant on trinity, so naturally I want to switch the streetlights off in a rather large area after the plant has been hit. As for the SP Version (I might do MP later), the player will supervise the attack on the plant, then lead a group into a nearby base to steal a vehicle. As the player's group has NV and the russian guards dont, it will make things a lot easier when the light is out (hehe... at least for a short while...), so I need to switch off the streetlights in a trigger's area. The trigger simply checks for the plant's damage and runs a script if the plant is destroyed. That is the easy part.

Now, I started looking up the streetlights using the object ids and then adding them to the script:

object 12345 switchlight["OFF"];
and so on.

After 2 hours and 30 lights, I swore to god there had to be an easier way than running around the island and looking up object ids in the editor...

Maybe someone can help me?

Cheers
PiLLe

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Maybe you could make a game logic and run a script that moves the game logic in a zig-zag pattern across the area you are searching for street lights.  As the game logic is "setPos" in each new spot (say every 50 meters or so) do a "nearestobject" command to find the nearest street light, and turn it off.  If you make the game logic start at the location of the power plant and spiral out ward that would also make for a realistic looking power outage (as in a real power grid the transformers have enough stored energy so that the lights would not go off instantly in the whole area).  The "blackout" would spread outward.  You could adjust a delay in the script that moves the game logic to change the speed of the "spreading blackout" to suit your preference.

Tom Norman

  • Guest
The only thing I can think of for this mate is to use the 'NearestObject' command.  The fomat is NearestObject [Grid/Object, "Type"].  Using this system you can specify a point on the ground and pass this position to a script that finds the nearest street lights (nearestObject [(X,Y,Z), "StreetLamp"]) and turns them off, before then moving the initial grid up by a metre and searching again.  You can make the script repeat this process as many times as you like until it's done it a certain number of times, then you can have it move across by one by metre and then down by the same number (and then across and up, across and down, etc.).  Get what I'm saying?  It wouldn't take much scripting, because you could alter the grid as a local variable based on the initial one and just move it about like that a set number of times.  Via this means you could choose an area you want to shut down (a 100m square for example).  I'm sure you can do this script yourself, but if you can't be arsed, it'll be something to keep me busy for a while.   ;)

Tom Norman

  • Guest
Ooops, sorry, pal.  I must have been busy writing my message when you already posted the answer.   :-X

csde-PiLLe

  • Guest
Tried it. Did not work out as I wanted it to... First, some lights will not switch to "OFF" and second, it looks odd. Some of the LightSources on Trinity even are other objects than Streetlights, so I will have to add them to my script one by one.

The good thing about the "manual" shutdown is: Lower CPU Usage. When spiralling the gamelogic out, things got pretty choppy. First, it was more "squareling" out than "spiralling" and second, it had to be a small radius in order to ensure that only one lightsource would be inside.

Now I am deactivating town by town with a nice top-down-flyby of the towns affected :) I even had one lamp "flickering" for 0.3 seconds and that looked pretty good ;)

Now its time for the russian counter-offensive... hrhr...

Thanks a lot
PiLLe

Daedalus692002

  • Guest
I downloaded a mission about 6 months ago called "The Assignment" that contained a trigger + script for turning off the lights in a terrorist camp. The authors name was Jahve and the url is:

http://ofp.gamezone.cz/index.php?sekce=missions

Hope this helps out.

Daedalus

Ps, needs the Mapfact barrecks addon.