Home   Help Search Login Register  

Author Topic: Nighttime/Daytime streetlamp  (Read 2425 times)

0 Members and 1 Guest are viewing this topic.

Offline Goullou

  • Members
  • *
Nighttime/Daytime streetlamp
« on: 10 Mar 2007, 09:11:00 »
For those who doesn't know:

I read a lot of discussion about the streetlamp where there were many lines of script. Everybody was calling the object streetlamp... Something like in this script :
? lightison (nearestobject [player,"streetlamp"])=="ON":(nearestobject [player,"streetlamp"])switchlight "off"

That doesn't work !!!

You want to know why ??

Because the lampost are different on Everon or Malden or Nogova etc ...
All the streetlamp objects built in the cities of Everon are "streetlampwood". In malden they are "streetlampmetal" for Nogova there's a lot of lampost which must have different object names ...

So the line script above will work on Everon like this :

? lightison (nearestobject [player,"streetlampwood"])=="ON":(nearestobject [player,"streetlampwood"])switchlight "off"

If you request the status of the light, by default it's alway "AUTO", the day, the night, always.
AUTO means ON because if you set the lamp to ON, it won't be lighting during the day. ON means ON at night and OFF by daylight. AUTO means the same thing. OFF means OFF everytime. The game knows when the night fall and then turn a state (somewhere???) which start all the lights even the cars/boats/planes lights (i.e. the light availability). This nighttime event is not tied to an hour of the day. It's depending of the month of the year. 'Cause the game assume different daylight time depending the month. Winter daylights are shortest, you know that and the game too!

If someone know a way to get the moment when the game starts the lights to synchronize actions... Please tell me!    :clap:

The streetlamps cannot help because always set to AUTO. May be a way to check the 'turn light on' action menu appearing on the vehicles...     ::)

Otherwise don't try to turn on the orginal streetlamp of the mission editor by using the command 'switchlight' ... What you'll see is a very strong light fixed at the middle of the mast and sometime it makes OFP to quit. It's crazy when you "switchlight" on a fridge or a chair ...:D

The only streetlamps working for your missions are those brought by the different EditorUpgrade1.x.x.pbo under "Streetlamp white/blue/yellow" etc... Where the command to turn on/off is 'this inflame true/false' like a fire.

If i'm stupid, tell me as well...
Si vis pacem, para bellum.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Nighttime/Daytime streetlamp
« Reply #1 on: 10 Mar 2007, 14:19:59 »
Well, I won't say you are stupid, just mistaken:

All the streetlights are "StreetLamp", they all inherit from class "StreetLamp".

For example:

class StreetLamp {};
class StreetLampWood: StreetLamp {};
class StreetLampMetal: StreetLamp{};

In short ALL Streetlamp inherit from class StreetLamp, even the ones on Nogova.


As for the "AUTO", "ON" and "OFF" parameters:

"AUTO" means Automatic.......if it is night time the lights come on, when day comes they go off.
"OFF" mean the lamp is switched off, you can do this anytime....even at night.
"ON" means the lamp is switched on, you can do this anytime....even in daytime.


Editor placed streetlamps will not work properly if you try to switch them on, as you already said.

The reason is because switching the lights on was only ever intended to work for .wrp placed streelamps (Ones already placed on the island in the .wrp file).

There never was any original streetlamps available in the mission editor.

Placing streetlamps via the editor is something that was introduced by the community via editorupdate addons, it was never an option with a clean install of the game.

Finally, you can turn any .wrp placed streetlamp on or off with switchLight at ANY time of day, you just need to use the object ID of the particular light.


This works fine, just change the number for the ID number of the lamp you want to turn off or on.

(object 68932) switchLight "off"
(object 68932) switchLight "on"



Planck
I know a little about a lot, and a lot about a little.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Nighttime/Daytime streetlamp
« Reply #2 on: 10 Mar 2007, 15:40:58 »
to answer the question, there is a way to detect the time of day at which lights are switched on by the ofp engine, but only in multiplayer. it requires a script to make use of the missionstart command and knowledge of times of the rising and setting of the sun throughout the year.

unfortunately the missionstart command only works in multiplayer.  :confused:

EDIT - have a read through this thread.
« Last Edit: 10 Mar 2007, 16:22:03 by bedges »

Offline schuler

  • Contributing Member
  • **
Re: Nighttime/Daytime streetlamp
« Reply #3 on: 12 Mar 2007, 01:26:20 »
Code: [Select]
{(object _x) switchlight "OFF"} forEach [1251,2003,28419,28420,28424,28664,32938,37326,66997,66998,67026,90863]  this might save some time, this is for Malden "switchlight" works, sp, just might help you alittle looking up objects #
Semper Fi

Offline Goullou

  • Members
  • *
Re: Nighttime/Daytime streetlamp
« Reply #4 on: 12 Mar 2007, 01:58:36 »
Thx Plank and all for your answer but i knew how to switch the streetlamp by object XXXX switchlight "on" "off" auto" but if you want to use with 'nearestobject' you need to know the real name of the streetlamp and my line of script works. I had to find this a long time. This part of my topic was not a question but information for those who keep on searching on this ...  :D

The point where i can be help is the way to know the time when the game decide to turn all the lights on and makes the action menu "turn light on" appearing on my jeep !!!

Otherwize if someone know a way to pick the system time from Windows by using a MOD or a miraculous .PBO or kind external device .... would be great ...
Si vis pacem, para bellum.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Nighttime/Daytime streetlamp
« Reply #5 on: 12 Mar 2007, 03:52:34 »
No.

? lightison (nearestobject [player,"streetlamp"])=="ON":(nearestobject [player,"streetlamp"])switchlight "off"

nearestObject is perfectly capable of detecting all the BI "StreetLamp" classes just by using "StreetLamp".

You do not need to specify the exact classname of the lamp.

The reason the above line does not work is because the lights are never "ON".

They are always  "AUTO", the check for the light to be "ON" will always fail.

Also the nearestObject command will fail if there is no "StreetLamp" within 50 metres of the player, so that is 2 ways for it to fail, the most important is because all "StreetLamp" objects in .wrp files are set to "AUTO" by default.


Why do you need an action menu item to turn on jeep lights, can't you just press "L"?

EDIT:  Apologies to Goullou, I did more checking and it appears nearestObject does have problems and needs the EXACT classname in order to find a "StreetLamp".
It will not find "StreetLamp" even though "StreetLampWood" and "StreetLampMetal" inherit from "Streetlamp".

But the rest stands, presuming the check was ok it would still fail because the lamps are never "ON" and of course must be within 50m.


Planck
« Last Edit: 12 Mar 2007, 14:02:14 by Planck »
I know a little about a lot, and a lot about a little.

Offline Goullou

  • Members
  • *
Re: Nighttime/Daytime streetlamp
« Reply #6 on: 12 Mar 2007, 15:46:47 »

The point where i can be help is the way to know the time when the game decide to turn all the lights on and makes the action menu "turn light on" appearing on my jeep !!!

Otherwize if someone know a way to pick the system time from Windows by using a MOD or a miraculous .PBO or kind external device .... would be great ...


You didn't understand my question. You wanted to reply too fast.¦nbsp; :laugh:
I repeat the question differently. At the sunset, at a moment different for each day depending the month of the year there's a "light starter" universal command which makes all the lights to really produce some light. In the mean time this event generate the appearance of an action menu "Turn light on" for all placed vehicles (having lights of course) of the current mission. I don't need a script to do that. The game do that itself... I just want to intercept this event. The way to intercept the moment where the action menu appears on vehicules is just a suggestion to help somebody to help ... :D If i had the answer i wouldn't be asking it over here ...
Si vis pacem, para bellum.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Nighttime/Daytime streetlamp
« Reply #7 on: 12 Mar 2007, 16:16:22 »
Quote
You didn't understand my question. You wanted to reply too fast.

You are incorrect this time.

I understood your question perfectly.......I was merely correcting what I thought was incorrect info and as it turned out I was partly mistaken with that anyway.

If I had an answer to your original query I would have given you one, as I did not have an answer I didn't address the question.

I hope your understanding is clearer now.   :laugh:


Planck


I know a little about a lot, and a lot about a little.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Nighttime/Daytime streetlamp
« Reply #8 on: 13 Mar 2007, 11:22:56 »
I've found out that civilians are quite blind by night, even with lights on. So here is my idea.

1 - Place two civilians (medium skill) on the map, name them watcher1 and watcher2 respectively.
2 - Look for a flat area far away from the action and place 4 makers there in the following way: mk_watcher1_close and mk_watcher2_close separated 25m, mk_watcher1_far and mk_watcher2_far separated 1000m.
3 - run the following script:

Code: [Select]
;canweseeus.sqs
;Can we see us?
#check
watcher1 setPos (getMarkerPos "mk_watcher1_close")
watcher2 setPos (getMarkerPos "mk_watcher2_close")
watcher1 doWatch [getMarkerPos "mk_watcher2_close" select 0,getMarkerPos "mk_watcher2_close" select 1, 1.5]
watcher2 doWatch [getMarkerPos "mk_watcher1_close" select 0,getMarkerPos "mk_watcher1_close" select 1, 1.5]
~15
_k1 = watcher1 knowsAbout watcher2
_k2 = watcher2 knowsAbout watcher1
_lights = false
?_k1 < 4 || _k2 < 4:_lights = true
hint format["Knowledge level W1: %1, W2: %2\n\nLights: %3", _k1, _k2, _lights]
watcher1 setPos (getMarkerPos "mk_watcher1_far")
watcher2 setPos (getMarkerPos "mk_watcher2_far")
~15
goto "check"

While lights are off (day time), the knowledged of each one about the other is 4 when each one is placed close to the other. As soon as lights are switched on, the knowledge lowers below 4. This may be a way to find out if lights are on/off.


Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: Nighttime/Daytime streetlamp
« Reply #9 on: 13 Mar 2007, 15:16:37 »
Very clever idea.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

karantan

  • Guest
Re: Nighttime/Daytime streetlamp
« Reply #10 on: 13 Mar 2007, 16:00:10 »
I've found out that civilians are quite blind by night, even with lights on.

Yea, they should to close all pubs and bars after eleven  :yes: ...

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Nighttime/Daytime streetlamp
« Reply #11 on: 13 Mar 2007, 16:37:24 »
I think it was Ondrej (Suma) that said once that AI ignores streetlights or any   light sources completely.


I had a look at this.

I searched for the action menu text 'Light on' and found it ONLY in the stringtable....of course.

The corresponding string reference name was STR_ACTION_LIGHTON.

Searching all the rest of the game files failed to find this reference ....except.........the game .exe file.

In other words the whole process is handled by the game engine and will therefore be very hard, and possibly not worth the effort, to try and interfere with.


Planck
I know a little about a lot, and a lot about a little.

Offline Goullou

  • Members
  • *
Re: Nighttime/Daytime streetlamp
« Reply #12 on: 13 Mar 2007, 23:13:22 »
Very good idea Mandoble.

I'm gonna test that ...  :good:

Anyway all other idea still welcome ...

Goullou


Heeuuu, i'm civilian and fortunately not blind at night even when i'm drunk ... :scratch:
Si vis pacem, para bellum.