Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Be aware of this when using a mod expanding the range of time deceleration to slower than 1/4  (Read 179 times)

0 Members and 1 Guest are viewing this topic.

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6066

I use Mike's (Storebror's) game time acceleration/deceleration mod, which allows to reduce the rate of time deyond the stock 1/4 rate, including 1/8, 1/16 and 1/32.

Well, recently I was testing out effects and while firing the Tiny Tim rockets at a time reduction of less than 1/4 I got a divide by zero error. In Controls.update() I've added an additional time check for 1/8 speed. If I wanted to use time rates slower than this I would add appropriate checks, as for 1/16 and 1/32. I've decided that slower than 1/8 is kind of useless because in track playback objects stop moving. And in the [Mod] section in conf.ini I have set the time divider value to 8, so that I cannot reduce the time rate to slower than 1/8 during play (or track playback).

from Controls.update():
Code: [Select]
long l1 = weaponReleaseDelay;
if((double)Time.speed() == 0.5D)  //1/2 speed
l1 *= 2L;
else
if((double)Time.speed() == 0.25D)  //1/4 speed; in stock game this is the slowest
l1 *= 4L;

else  //NEW! for extended time slowing (best to limit max time divider in conf.ini [Mods] section to 8!)
if((double)Time.speed() == 0.125D)  //1/8 speed
l1 *= 8L;

else
l1 /= (long)Time.speed();  //can generate a divide by zero error when time multiplier is less than 0.25!!
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

Draken

  • member
  • Offline Offline
  • Posts: 1138

Interesting.
This is important for movie makers who wants to make slow motion segments .

Where to find the Controls.update() file , please ?
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6066

Controls class is a Java file, and within it is a method called update(). The shorthand for specifying this is Controls.update(), as would be written in Java for any external class or method calling that method.

One could say that any topics getting into Java code should be posted in the Super School. But as I'm supplying code in a topic of general interest, and furthermore am not asking for help with coding, I feel that a topic like this warrants placement here. ;)

A mod would need to be released which incorporates my change in the compiled class/classfile(s). This would likely be game version dependent to at least some degree. My B.A.T. 4.0 class is potentially not the same in certain respects as for B.A.T 4.2.3. If a modder is set up to compile Java for the latest game version, my code snippet can be easily incorporated.
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

Frankiek

  • SAS Team
  • member
  • Offline Offline
  • Posts: 3054

Posting in the lounge means only that in little time this post will be buried by many others with less chances for anyone to see it and making search more difficult
Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23979
  • Taking a timeout
    • STFU

Looks odd indeed.

Code: [Select]
l1 /= (long)Time.speed();...should rather be...
Code: [Select]
l1 = (long)((double)l1 / Time.speed());
]cheers[
Mike
Logged
Don't split your mentality without thinking twice.
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 24 queries.