Home   Help Search Login Register  

Author Topic: creating lights, animating computers and speed radars  (Read 2370 times)

0 Members and 1 Guest are viewing this topic.

Offline Delta Hawk

  • Members
  • *
  • I'm a llama!
I'm sure this is the right place to post my questions and i hope someone will answer them.  I'm currently making a specific kind of car that has a computer in it, a speed radar and lights and i got a few questions.  I would try to figure all this out by myself, but i really don't have the time to do it sadley.

How would i create an additional "cone" light that you can turn on and off and maybe move around, but not related to the vehicle's own headlights?  I know u have to create some kind of object and attach it to the vehicle, but can anyone make this dummy proof for me?  I guess you could call it a spot light, like the spot lights on police cars that you can turn on and off.  :confused:

This vehicle also has a computer that i want to animate.  Simple enough, add an action - setobjecttexture blah blah blah, but i'd like to make it where you can toggle multiple windows with different screens with two or three actions, which the actual screens textures will be in the mission files of the editors and some from the addon itself.  It can't be animated since this computer is already animated to be seen by the driver and passanger.  KIND OF like the computers that you might see in a police car.

And then for some reason i want to put in a speed radar.  Simple enough, get speed of vehicle, if speed = some number, setobjecttexture 000.  But i want to make it where it shoots a cone in front of the car and only reads the speeds of the cars to the front, which will then setobjecttexture specfic digits on the speed radar display.   An option of selecting a rear speed radar to read speeds of cars from behind would also be useful. Speed radars also display the speed of the vehicle that it is equiped to.  something common i guess, in ah...maybe...i dunno...police cars. *Cough   :D

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: creating lights, animating computers and speed radars
« Reply #1 on: 28 Aug 2008, 01:06:32 »
For the cone-light you need to create a weapon that the driver/someone_else can pan (check out the static spotlight on the blufor side).

However, this does not 'fire' but turns on with the 'lights on' action.

For the speed radar, you need a bit of scripting.  What you need to do is:

1) Somehow capture the unit of which you want get the speed
2) use iskindof "LandVehicle" to sort out what you don't need
3) use the speed command to get their speed
4) get your textures of each individually
 (that way you can set up 30 textures, [10 for each digit, as opposed to 1000 for various numbers]
Code: [Select]
_hundreds_place= floor (_speed/100);
_tens_place= floor((_speed mod 100)/10);
_ones_place= (_speed mod 10)

set texture _hundreds_place;
set texture _tens_place;
set texture _ones_place;
this gives you the digits individually which you can set.

if you want to round the ones place (which you probably do) replace that ones line with
Code: [Select]
_ones_place= floor((_speed mod 10)+.5);

Hope that helps!

Luke
Pesky Human!!
Wort Wort Wort.

Offline Delta Hawk

  • Members
  • *
  • I'm a llama!
Re: creating lights, animating computers and speed radars
« Reply #2 on: 28 Aug 2008, 04:10:28 »
does it matter if the horn is being used for the car?  I'm gonna look at the spot light

with the digits, each digit is it's own number, so i can use setobjecttexture Gdigit0.pac - 9.  There's three digits on the speed radar for other cars, first one is either a 1 or two, second one ranges from 0 - 9 and the third is either 0 or 5, just to make things simple.  i.e. [1 4 5] 

besides that, u blew my mind and now i got to walk around my room and scrape my brains off the walls

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: creating lights, animating computers and speed radars
« Reply #3 on: 28 Aug 2008, 05:41:22 »
Well, there goes my suicide hotline career   ;)

I'll walk you through it.

Edit: Take it slow, because it is LONG!!

For the cone-light you need to create a weapon that the driver/someone_else can pan (check out the static spotlight on the blufor side).
Create a turret or mount that aims the light

However, this does not 'fire' but turns on with the 'lights on' action.
Self-explanitory.

For the speed radar, you need a bit of scripting.  What you need to do is:
1) Somehow capture the unit of which you want get the speed
ask a moderator or an admin, as I am not one who can do the above easily.
2) use iskindof "LandVehicle" to sort out what you don't need
if you type '? _radar-ed_vehicle iskindof "landvehicle" ' then this will yield a true for only land vehicles.
A helicopter, ship, building, man, etc. will return a false, which you can script to exit using the line:
Code: [Select]
? not (_vehicle_being_radared iskindof "landvehicle":exitin an .sqs file

3) use the speed command to get their speed
Again, self-explanitory.
4) get your textures of each individually
 (that way you can set up 30 textures, [10 for each digit, as opposed to 1000 for various numbers]
this means you have to set single texture for each of the three digits,
rather than 1 texture for all three.
That way you don't have to do a texture like '214 kph','215 kph','216 kph',
which would be too much work.
Code: [Select]
_hundreds_place= floor (_speed/100);
this sets the value of the hundreds place.
how it works: It takes the value (we will use 142) and divides it by 100.
we now have 1.42, but we're not done.
the command 'floor()' rounds down, so floor(1.42) = 1
we now have our hundreds digit of 1!!! (YAY!!  :))
Code: [Select]
_tens_place= floor((_speed mod 100)/10);
this does something similar.  the mod command uses modular division.
what that is, is dividing something then using the remainder.
so 142 mod 100 would be 1 remainder: 42, because 100 goes into 142 once, and leaves 42 left over.
(I know this is simple. I am NOT talking down to you.
I just don't want you to have your brains splattered on the walls after all that effort of repacking them.)
Because this is modular division, it tosses out the one and keeps the 42.
We then do the same thing with the tens, divide 42 by 10 to get 4.2 and then round down to get 4.
Now we have a tens digit of four. (once again: YAY!!  :))
Code: [Select]
_ones_place= (_speed mod 10)
Now, we do something similar.
this mods by ten so we get 14 remainder: 2.  Toss out the 14, and keep the two.
now this won't work as its not rounded, so you may end up with 2.14718945169358046,
if it is not exactly 142 kph.

Code: [Select]
set texture _hundreds_place;
set texture _tens_place;
set texture _ones_place;

this gives you the digits individually which you can set.

The line below fixes the problem.
if you want to round the ones place (which you probably do) replace that ones line with
Code: [Select]
_ones_place= floor((_speed mod 10)+.5);
how this works:
two examples:
1) the speed is 137.67 kph, this mods by ten giving you 13 with remainder: 7.67
then adds .5 to 7.67 to get 8.17.
Then it rounds 8.17 down to 8 to give you a ones value of eight.

2) the speed is 165.48 kph, this mods by ten giving you 16 remainder: 5.48
then it adds .5 to 5.48 to give you 5.98.
It then rounds DOWN (not up, that's why its called a floor value) giving you a ones digit of five.

Both cases were rounded to the nearest whole number, with a bit of math magic, giving you the ones digit.

Hope that helps!

Hopes this helps, even more!!!

Luke

P.S.
Delta Hawk, The way this was written was to make it very easy and understandable,
and not meant to be demeaning to your intelligence.
« Last Edit: 28 Aug 2008, 05:46:22 by Luke »
Pesky Human!!
Wort Wort Wort.

Offline Delta Hawk

  • Members
  • *
  • I'm a llama!
Re: creating lights, animating computers and speed radars
« Reply #4 on: 28 Aug 2008, 17:16:58 »
no offense taken, i prefer ppl to talk to me about scripting like i was a mental retard.  All my talent went into modeling and textureing, not scripting...in fact, if you want to take a stab at the actual addon making the scripts for it, be my guess...u can beta test it too.  I'm taking it ur experianced in scripting and interested in helping me.  U might as well get a sneek peek and apply new scripts to a addon that will probably be in everyone's addon folder when it's released.  :)

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: creating lights, animating computers and speed radars
« Reply #5 on: 29 Aug 2008, 00:47:22 »
While thoroughly honored, I am not as experienced as you say.

I am more a casual scriptor, but I have a little (little) experience. (See my two scripts, currently in testing, here and here.)
I consider myself more of a problem solver, who knows bits and pieces of lots of different things,
and as such tries to help people with what they need. :)

I am horrible with the configs, modeling and texturing, but I would be more than happy to help you with the scripting.

Two notes:

I am currently enrolled as a twelfth-grader at my local school.  My work would be sporadic at best. :(

My scripting is prone to errors, which mean that they may have to be tested, debugged a couple times. :(

However I am honoured that you would allow me to do this and am excited to see what you have.
If you have any problems with something, or want me to script something,
let me know and I will try as much as the situation allows.  :D

I'd be more than happy to be on your project team!  :good:

Do get back to me!

Luke

PS I didn't say in earlier posts but, I dont believe the horn affects the lights.

Also double-checking to make sure that you did indeed understand everything I explained?
Pesky Human!!
Wort Wort Wort.