Discussion: Conditional statements in BF1942

Ask questions, discuss ideas, get answers

Re: Discussion: Conditional statements in BF1942

Postby russ » Wed Nov 21, 2018 10:41 pm

Modding templates while the round is running is a bit tricky, but doable.
russ
 
Posts: 55
Joined: Sun Oct 29, 2017 8:12 am

Re: Discussion: Conditional statements in BF1942

Postby Classical Modder » Wed Nov 21, 2018 11:43 pm

russ wrote:Modding templates while the round is running is a bit tricky, but doable.


Is there any command from the game engine that returns the amount of time in seconds remaining in a round? It would make it easier to create time dependent events instead of having an admin change the time limit manually.
{SoH} Clan Leader // http://sohclan.forumotion.com/
See my Strasbourg map project here.
GSC: diamondback67
Steam: diamondback67
Classical Modder
 
Posts: 437
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada

Re: Discussion: Conditional statements in BF1942

Postby russ » Thu Nov 22, 2018 12:52 am

Doesn't appear to be any direct way to return the elapsed or remaining time in a round. You might be able to use a timer to keep track though:

http://www.battlefieldsingleplayer.info ... leProfiler
russ
 
Posts: 55
Joined: Sun Oct 29, 2017 8:12 am

Re: Discussion: Conditional statements in BF1942

Postby Classical Modder » Thu Nov 22, 2018 11:26 pm

I tried using some of the commands in that category but nothing seems to be happening. Maybe these commands only work with the debugger.

ConsoleProfiler.startTimer takes a string as an argument. Is that to name the timer?

I tried messing around with the Profiler commands, but nothing happens as well. Some code:

Code: Select all
Var v_start
var v_end
var v_inter

Const c_on = 0
Const c_off = 1
Const c_start = 0
Const c_end = 200

profiler.enable c_off
profiler.enableTimer c_start -> v_start
profiler.disableTimer c_end -> v_end

Utils.mathExprI v_end - v_start -> v_inter

if v_inter < 200
debug.debugOutputMessage "Timer on" 1

elseif v_inter > 200
debug.debugOutputMessage "Timer off" 1

endIf
{SoH} Clan Leader // http://sohclan.forumotion.com/
See my Strasbourg map project here.
GSC: diamondback67
Steam: diamondback67
Classical Modder
 
Posts: 437
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada

Re: Discussion: Conditional statements in BF1942

Postby Classical Modder » Sun Dec 02, 2018 6:52 am

Classical Modder wrote:I fixed the problem. I can confirm that the following code works correctly:

Code: Select all
Var v_time

Const c_time1 = 3600
Const c_time2 = 1800
Const c_time3 = 900
Const c_time4 = 450

admin.timelimit -> v_time

if v_time < c_time4
admin.serverMessage "Test 4"

elseif v_time < c_time3
admin.serverMessage "Test 3"

elseif v_time < c_time2
admin.serverMessage "Test 2"

elseif v_time < c_time1
admin.serverMessage "Test 1"

endIf


This will output the correct message, which will be seen by everyone in the server I think (needs to be tested on an Internet server).

Even better still, an admin that has in-game rights can change the time limit with an alias like !timeXX, where XX is the amount of minutes (this is how they do it on SiMPLE). In a sense, this means that events can happen in-game depending on the time that is set by the admin.

For example, an admin could set the time to under 7.5 minutes and disable all weapons except zooks and knives, for a short zook and knives round. Of course, this still has to be tested. Working on it atm.


So this only works on a local server, on an Internet server the console will output an Unknown command or method error when the script is run. Any idea why that might be?
{SoH} Clan Leader // http://sohclan.forumotion.com/
See my Strasbourg map project here.
GSC: diamondback67
Steam: diamondback67
Classical Modder
 
Posts: 437
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada

Re: Discussion: Conditional statements in BF1942

Postby russ » Tue Dec 04, 2018 7:53 am

I did some more searching. You can start and stop timers, but the output is not consumable by scripts. There doesn't appear to be any way to get elapsed or remaining round time from within the console. It can only be obtained via the server info query port.
russ
 
Posts: 55
Joined: Sun Oct 29, 2017 8:12 am

Re: Discussion: Conditional statements in BF1942

Postby Classical Modder » Wed Dec 05, 2018 12:25 am

russ wrote:I did some more searching. You can start and stop timers, but the output is not consumable by scripts. There doesn't appear to be any way to get elapsed or remaining round time from within the console. It can only be obtained via the server info query port.


Well that’s disappointing. Thanks for the information though. Out of curiosity, how would one start a timer and end it? Do you have an example of a script?
{SoH} Clan Leader // http://sohclan.forumotion.com/
See my Strasbourg map project here.
GSC: diamondback67
Steam: diamondback67
Classical Modder
 
Posts: 437
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada

Re: Discussion: Conditional statements in BF1942

Postby russ » Wed Dec 05, 2018 3:19 am

Code: Select all
> ConsoleProfiler.enable 1
> ConsoleProfiler.report 
No profiling data available
> ConsoleProfiler.startGlobalTimer
> ConsoleProfiler.report
No profiling data available
> ConsoleProfiler.stopGlobalTimer
> ConsoleProfiler.report
Frames:           1
Seconds:          10.8271
------------------
Average fps:      0.0923611
Min     fps:      0.0923611
Max     fps:      0.0923611
------------------
Average ms/frame: 10827.1
Min     ms/frame: 10827.1
Max     ms/frame: 10827.1
------------------
Process                    0: userTime/f =  0.00ms [100000000376832.00,  0.00]
 , kernelTime/f =  0.00ms  [999999986991104.00,  0.00]
Threads:
0   Global timer                         10827.0690 ms/f,  100.0000%
0   Global timer                                     0.00% (sum)


Note that this appears to be tied into the renderer, so on dedicated the frames value isn't valid nor are any of the values derived from it.
russ
 
Posts: 55
Joined: Sun Oct 29, 2017 8:12 am

Re: Discussion: Conditional statements in BF1942

Postby Classical Modder » Wed Dec 05, 2018 9:39 pm

russ wrote:
Code: Select all
> ConsoleProfiler.enable 1
> ConsoleProfiler.report 
No profiling data available
> ConsoleProfiler.startGlobalTimer
> ConsoleProfiler.report
No profiling data available
> ConsoleProfiler.stopGlobalTimer
> ConsoleProfiler.report
Frames:           1
Seconds:          10.8271
------------------
Average fps:      0.0923611
Min     fps:      0.0923611
Max     fps:      0.0923611
------------------
Average ms/frame: 10827.1
Min     ms/frame: 10827.1
Max     ms/frame: 10827.1
------------------
Process                    0: userTime/f =  0.00ms [100000000376832.00,  0.00]
 , kernelTime/f =  0.00ms  [999999986991104.00,  0.00]
Threads:
0   Global timer                         10827.0690 ms/f,  100.0000%
0   Global timer                                     0.00% (sum)


Note that this appears to be tied into the renderer, so on dedicated the frames value isn't valid nor are any of the values derived from it.


I think these commands could have an interesting use. If one would like to know, for example, how long it takes them to move their tank from their main base to one of the flags on a map in Conquest mode, these commands could be used. This is especially useful in clanwars, where every second counts.

I still want to try to use this command to make a script out of it that could possibly make events happen based on the time elapsed in the Global Timer.

This is the code I previously used to try to make time-based events happen in game. It doesn't work, either because the code is faulty (most likely), or the commands involved do not return anything or are unused by the game engine.

Code: Select all
Var v_start
var v_end
var v_inter

Const c_on = 0
Const c_off = 1
Const c_start = 0
Const c_end = 200

profiler.enable c_off
profiler.enableTimer c_start -> v_start
profiler.disableTimer c_end -> v_end

Utils.mathExprI v_end - v_start -> v_inter

if v_inter < 200
debug.debugOutputMessage "Timer on" 1

elseif v_inter > 200
debug.debugOutputMessage "Timer off" 1

endIf



I then modify the above code to something like this:

Code: Select all
Var v_start
var v_end
var v_inter

ConsoleProfiler.enable 1
ConsoleProfiler.report
ConsoleProfiler.startGlobalTimer -> v_start
ConsoleProfiler.stopGlobalTimer -> v_end

Utils.mathExprI v_end - v_start -> v_inter

if v_inter < 200
debug.debugOutputMessage "Timer on" 1

elseif v_inter > 200
debug.debugOutputMessage "Timer off" 1

endIf



EDIT: Nvm, the ConsoleProfiler commands only work with the Debugger so it's useless to try to implement it somewhere else.
{SoH} Clan Leader // http://sohclan.forumotion.com/
See my Strasbourg map project here.
GSC: diamondback67
Steam: diamondback67
Classical Modder
 
Posts: 437
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada

Re: Discussion: Conditional statements in BF1942

Postby russ » Thu Dec 06, 2018 7:44 am

It returns a huge long stanza of text you'd need to parse to get the one line where it has a time. It just isn't doable.
russ
 
Posts: 55
Joined: Sun Oct 29, 2017 8:12 am

PreviousNext

Return to 1942 Modding Discussion

Who is online

Users browsing this forum: No registered users and 28 guests