Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Download Outerra Tech Demo. Unofficial Outerra Discord server, MicroProse Discord server for OWS.

Author Topic: - SCRIPT - Multiple turret handling for ships or vehicle-stationary weaponry  (Read 14184 times)

PytonPago

  • Hero Member
  • *****
  • Posts: 2284
  • It´s way too complex, dont let me try to explain !

I made a little combination-script for the basic turning of turrets and a counter-defined selection of the needed one - feel to check out and try on your projects. ( Was meant just to help out for the Bismark project, but actually, i could use it for stationary weapons on my BTR-80 too, when the interior gets done. ) Hope, that the change of the FPS view can be changed at the same time once it can be fixed to some mesh rotation to add the feeling of "wielding" it.

First three turrets have separate characteristics (max-min angles and speeds) and the last two the same - if, for ships, is the need to use the same for multiple of the same gun-types. But all do keep their own situational rotation values as they should.

If any questions rise, just write ...

Here to get :

https://docs.google.com/file/d/0B3ZscF0ox2AGM3RyQ0djUVZLeWM/edit

P.S.: you can see, i gave the selector button (and thus the counter button) as the AUX2 - you need to define it yourselves in the control options menu. (i just use the selector on an other project on that button, cause of a shortage of buttons and just copy/pasted them - sorry if its any inconvenient)
« Last Edit: April 08, 2014, 02:43:46 pm by PytonPago »
Logged
We are still undeveloped as long as we don´t realize, that all our science is still descriptive, and than beyond that description lies a whole new world we just haven´t even started to fully understand.

M7

  • Hero Member
  • *****
  • Posts: 736
  • newbie

Dont know if i got everythings right, but i have 4 turrets and i can get only one to rotate...
Logged

PytonPago

  • Hero Member
  • *****
  • Posts: 2284
  • It´s way too complex, dont let me try to explain !

Dont know if i got everythings right, but i have 4 turrets and i can get only one to rotate...

I added to the counter an dialog window message - you should see Turret01 till Turret04 and over again popping up, when you change the count (and the turret selection whyte it). If its not changing, the counter might be broken somewhere (doe i checked my file again and it works) or just look, if in options the vehicle control of "aux button 2" is set to something, that isnt used twice in the controls (if there are two same buttons, it will ignore the second).

 Another thing, if you modifying it for your own projects, might be aether the turret names -check the mesh definition scripts somewhere at the beginning, if they are right -- or its the variables of the turrets (there is a lot of stuff to be checked on names being right if you modified the script for your own - but you find that if you look trough the classic turret script, where what variable should be).
« Last Edit: April 09, 2014, 01:22:39 am by PytonPago »
Logged
We are still undeveloped as long as we don´t realize, that all our science is still descriptive, and than beyond that description lies a whole new world we just haven´t even started to fully understand.

M7

  • Hero Member
  • *****
  • Posts: 736
  • newbie

Ak ok i had the same key assigned to light and aux button2 :-[. So it works now! Very nice  script . Thanks Pyton!
Logged

PytonPago

  • Hero Member
  • *****
  • Posts: 2284
  • It´s way too complex, dont let me try to explain !

Ah ok i had the same key assigned to light and aux button2 :-[. So it works now! Very nice  script . Thanks Pyton!

 Heh ... thought so.  :D  Cant wait it to be slapped on the Bismark and other future MultiTurret projects ...



P.S.: Cameni - any plans to have a similar turret script option for airplanes ? Or does JSBSim have something for that kind of utility-control ?
Logged
We are still undeveloped as long as we don´t realize, that all our science is still descriptive, and than beyond that description lies a whole new world we just haven´t even started to fully understand.

M7

  • Hero Member
  • *****
  • Posts: 736
  • newbie

Now i have another idea for turrets/aa/mg and i dont know if its even possible to script but here it goes.

The idea would be to make sort of global aim command for all turrets. It would fonction like a single "virtual" turret from a 360 degree dial . Lets say the front of the ship is 0 (or 360) degree and the back is 180 degree. You could dial 250 degree and all guns that can, would turn to 250 degree, all at their respective rotation speed. Same with elevation.

So it would be like steering a single (invisible) turret. When you stop the rotation you would get a message showing the aiming point in degree. Then  all turrets/AA/MG than can, will start to rotate to that specific direction.

Do you imagine all mgs and guns moving like its targeting in a single object. Then if you can add the same bullet flare (dont know the real word for it) of the mercerary weapon that could be fired from  the ship MGs and AA , it could make for nice firework show ;D

In the mean time i will definatly try your script for the Bismark.
Logged

zzz

  • Sr. Member
  • ****
  • Posts: 266
  • newbie

This will come in handy.  :)
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com

P.S.: Cameni - any plans to have a similar turret script option for airplanes ? Or does JSBSim have something for that kind of utility-control ?
You can do the same with aircraft .. well, you can't do the exact same thing now, the axis integrator isn't included in aircraft scripts, but it's actually just a piece of JS code now:
Code: [Select]
function axis_integrator(maxspeed,maxaccel,clamp_min,clamp_max){
  this.mac = maxaccel ? maxaccel : 1.0;
  this.msp = maxspeed;
  this.speed = 0;
  this.value = 0;
  this.targ = 0;
  this.cmin = clamp_min!=undefined ? clamp_min : Number.NEGATIVE_INFINITY;
  this.cmax = clamp_max!=undefined ? clamp_max : Number.POSITIVE_INFINITY;
}

axis_integrator.prototype.set = function(v){this.targ = v}
axis_integrator.prototype.set_max_speed = function(v){this.msp = v}
axis_integrator.prototype.changed = function(dt){
  var ob = this.speed;
  var dm = this.mac*dt;
  if(this.targ > ob+dm)
    this.speed += dm;
  else if(this.targ < ob-dm)
    this.speed -= dm;
  else
    this.speed = this.targ;
  var ov = this.value;
  this.value += this.speed*this.msp*dt;
  if(this.value < this.cmin) this.value = this.cmin;
  if(this.value > this.cmax) this.value = this.cmax;
  return ov != this.value;
}

A bigger problem is that aircraft script is currently missing the extra input actions. For vehicles it was actually a temporary solution before a fully configurable input system is done, that will be common for aircraft and vehicles.
Logged

PytonPago

  • Hero Member
  • *****
  • Posts: 2284
  • It´s way too complex, dont let me try to explain !

A bigger problem is that aircraft script is currently missing the extra input actions. For vehicles it was actually a temporary solution before a fully configurable input system is done, that will be common for aircraft and vehicles.

Nice, bombers whyte stationary-es could be done then. Looking forward for how the inputs be made.
Logged
We are still undeveloped as long as we don´t realize, that all our science is still descriptive, and than beyond that description lies a whole new world we just haven´t even started to fully understand.

PytonPago

  • Hero Member
  • *****
  • Posts: 2284
  • It´s way too complex, dont let me try to explain !

Now i have another idea for turrets/aa/mg and i dont know if its even possible to script but here it goes.

The idea would be to make sort of global aim command for all turrets. It would fonction like a single "virtual" turret from a 360 degree dial . Lets say the front of the ship is 0 (or 360) degree and the back is 180 degree. You could dial 250 degree and all guns that can, would turn to 250 degree, all at their respective rotation speed. Same with elevation.

So it would be like steering a single (invisible) turret. When you stop the rotation you would get a message showing the aiming point in degree. Then  all turrets/AA/MG than can, will start to rotate to that specific direction.

Do you imagine all mgs and guns moving like its targeting in a single object. Then if you can add the same bullet flare (dont know the real word for it) of the mercerary weapon that could be fired from  the ship MGs and AA , it could make for nice firework show ;D

In the mean time i will definatly try your script for the Bismark.

 ... it actually is possible. You leave one turret as it is and other turrets would have corrections (aether as constant addition of functions dependent on the first turrets turx and tury values) added to the others rotations. Would take some time, to calibrate the rotations properly, but i dont see it being as such a problem there. Problem will be shooting - you have to limit that option of the guns to the ones that actually can face that targeting direction. (you know, not all have 360 deg. combat ability, especially on a ship) That may prove itself to be a little more complicated thing. Something like calculating a doubled turning variable for each gun, just that second one would have 360 deg rotation and if for a certain turret it doesnt fit whyte the actual rotation (cause it hit the max/min degrees), it would not fire ... hmm now when i think about it, i might have a idea how to do that (but probably need to limit turnx/y values to max 360 degrees by returning its value to 1 once it hits 360 and vice versa - or is it already, just like the wheel rotation angle for animations ? Will have to check that one ... ). Doe, it will make the script a little stretched-lined, making it little chaotic at first view. I guess, i could try that when i get some spare time again, but probably would need the ship final-imported to OT, so i could do the corrections to the turrets right.

Also, in that way of using the script for targeting, you still could have the option to select main guns, left/right lower caliber guns and AA guns trough the counter. So you dont waste much unnecessary ammo. :D - yes, a lots of individual canon ammo-counters involved (actually not much complicated, you can see those at my BTR and BM-21 scripts), but certainly would add some reality to that.
« Last Edit: April 09, 2014, 03:07:32 pm by PytonPago »
Logged
We are still undeveloped as long as we don´t realize, that all our science is still descriptive, and than beyond that description lies a whole new world we just haven´t even started to fully understand.