[diff] demotimers

Developer discussion of experimental fixes, changes, and improvements.

Moderators: Nexuiz Moderators, Moderators

[diff] demotimers

Postby lda17h » Tue Sep 22, 2009 9:51 pm

This diff adds demotimers to the client qc code. These can be used to setup timers that e.g. reliably start capturing at a certain time in the demo. Note that these timers are stable against slomo. Thus they can be used to e.g. slomo 100 to a certain position in a demo then start capturing for a certain time, etc...

Use with e.g.

cl_cmd demotimer 20 "slowmo 100"
cl_cmd demotimer 59 "slowmo 1"
cl_cmd demotimer 60 "cl_capturevideo 1"
cl_cmd demotimer 120 "cl_capturevideo 0"
cl_cmd demotimer 121 "disconnect"


I leave it as exercise to the reader to create useful aliases, etc..

Note that only demos recorded with the patched csprogs will allow this..

Have fun..

EDIT: errors..
EDIT: Thanks MrBougo for guiding me through hacking this up :) And also for the original idea of course :D

EDIT: Updated diff to provide a hook called hook_demostart. This hook is executed right after playback of the demo started. With this you could do the following:

alias hook_demostart cl_cmd "demotimer 1 disconnect"

and then run a demo.. It will run until exactly 1 second into the gametime. Note that the start of the demo is not nessecarily at gametime 0.. No timing problems using defer anymore..

So to create a way to record e.g. the game from 0:10 to 0:20, you could do something like the following:

alias hook_demostart "cl_cmd demotimer 10 \"slowmo 1; cl_capturevideo 1\"; cl_cmd demotimer 20 \"cl_capturevideo 0; disconnect; slowmo 1\"; slowmo 100"


Code: Select all
Index: data/qcsrc/client/Main.qc
===================================================================
--- data/qcsrc/client/Main.qc   (revision 7768)
+++ data/qcsrc/client/Main.qc   (working copy)
@@ -447,6 +447,12 @@
   debug_shotorg.view_ofs = '25 8 -8';
}

+void thinkdemotimer() {
+   localcmd("\n", self.message, ";");
+   strunzone(self.message);
+   remove(self);
+}
+
void GameCommand(string msg)
{
   float argc;
@@ -459,6 +465,7 @@
      print("  radar\n");
      print("  sbar_columns_set ...\n");
      print("  sbar_columns_help\n");
+      print("  demotimer secs cmd | demotimer clear | demotimer list \n");
      GameCommand_Generic("help");
      return;
   }
@@ -474,6 +481,39 @@
   else if(cmd == "settemp") {
      cvar_clientsettemp(argv(1), argv(2));
   }
+   else if(cmd == "demotimer") {
+      if not(isdemo()) {
+         print("Error! demotimer can be only used during demo playback");
+         return;
+      }
+      if (argv(1) == "clear") {
+         local entity e;
+         e = world;
+         for( ; e=find(e, classname,"demotimer") ; ) {
+            strunzone(e.message);
+            remove(e);
+         }
+         return;
+      }
+      if (argv(1) == "list") {
+         local entity e;
+         e = world;
+         for( ; e=find(e, classname,"demotimer") ; ) {
+            print(ftos(e.nextthink), " ", e.message, "\n");
+         }
+         return;
+      }
+      if (stof(argv(1)) < time) {
+         print("Error! time is in the past");
+         return;
+      }
+      local entity e;
+      e = spawn();
+      e.classname = "demotimer";
+      e.nextthink = stof(argv(1));
+      e.message = strzone(argv(2));
+      e.think = thinkdemotimer;
+   }
   else if(cmd == "radar") {
      ons_showmap = !ons_showmap;
   }
@@ -868,6 +908,8 @@
   {
      localcmd("\n_cl_hook_gamestart ", GametypeNameFromType(gametype), ";");
      calledhooks |= HOOK_START;
+   } else { // isdemo() == true
+      localcmd("\nhook_demostart");
   }
}
// CSQC_Parse_StuffCmd : Provides the stuffcmd string in the first parameter that the server provided.  To execute standard behavior, simply execute localcmd with the string.
Last edited by lda17h on Wed Sep 23, 2009 11:38 am, edited 2 times in total.
lda17h
Alien
 
Posts: 221
Joined: Tue Jun 16, 2009 1:04 pm
Location: Germany

Postby paperclips » Wed Sep 23, 2009 7:42 am

*plops up*
wait, wat!? someone said fastforward and record demos in the same sentence!?
WOW1 :shock: :shock: cant wait to try this out! Thanks a lot for starting to fiddle this into reality! :D
[Want to develop? Look HERE]. Image Image Gif sauce.
paperclips
Alien trapper
 
Posts: 346
Joined: Mon Jan 12, 2009 10:27 am
Location: internets

Postby lda17h » Wed Sep 23, 2009 8:19 am

paperclips wrote:*plops up*
wait, wat!? someone said fastforward and record demos in the same sentence!?
WOW1 :shock: :shock: cant wait to try this out! Thanks a lot for starting to fiddle this into reality! :D


:) No problem. This scratches an itch i had myself for a long time... Anyways, i want to repeat the caveat here once more:

This will only work with demos recorded where the csprogs used in the game has this code.. This means that for online games the _server_ needs to have this code. I guess it will become really useful only if it goes into the next nexuiz release.. Then when people play with updated servers they can afterwards use this to maybe make navigation in demos a little easier :)

BTW: about this latter point: The time in the timedemo command is in seconds. And it's _absolute_ game time. So the example in my first post above would wait until time 20 secs into the demo (from the beginning), then it would slowmo 100 until time 59. Then it'll start recording at time 60 up until time 120 and at time 121 it would disconnect..


EDIT: removed comments about way to atomically schedule a cmd after demo start. see top post for info..
lda17h
Alien
 
Posts: 221
Joined: Tue Jun 16, 2009 1:04 pm
Location: Germany

Postby FruitieX » Thu Sep 24, 2009 2:39 pm

O_O Nice!
This could perhaps also be developed to a democamera scripting system, so that you'd first record what kind of actions you want the democamera to make, then automatically render part of the demo together with the prerecorded camera movement into a file. This'd be awesome for people who make frag movies, especially if they have a low-end system and want to record with full settings. Heck, you could probably "chain" the recording of demos so that you first script the demo camera for all demos you want to record from, then execute a script which renders all scenes into ogv for later editing in a video editor. A procedure like this would also make it lots easier for the artist to sync the scenes and camera angles/events etc. to the music that he'll play in his movie.
FruitieX
Keyboard killer
 
Posts: 588
Joined: Mon Nov 13, 2006 4:47 pm
Location: Finland

Re: [diff] demotimers

Postby lda17h » Sat Sep 26, 2009 10:08 pm

lda17h wrote:This diff adds demotimers to the client qc code. These can be used to setup timers that e.g. reliably start capturing at a certain time in the demo. Note that these timers are stable against slomo. Thus they can be used to e.g. slomo 100 to a certain position in a demo then start capturing for a certain time, etc...

Use with e.g.

cl_cmd demotimer 20 "slowmo 100"
cl_cmd demotimer 59 "slowmo 1"
cl_cmd demotimer 60 "cl_capturevideo 1"
cl_cmd demotimer 120 "cl_capturevideo 0"
cl_cmd demotimer 121 "disconnect"


Ok, here's two more diffs.

The first one changes the menu system to use the startdemos command to start a demo. This allows the user to use the "demos" command to restart the playback of the currently playing demo.

The second one bumps a max string length in the engine, so the first patch actually works :)

EDIT: This is a rather stupid approach. Here's a much simpler solution. We just define the alias restartdemo in the demo menu code:

Code: Select all
Index: data/qcsrc/menu/nexuiz/demolist.c
===================================================================
--- data/qcsrc/menu/nexuiz/demolist.c   (revision 7894)
+++ data/qcsrc/menu/nexuiz/demolist.c   (working copy)
@@ -125,7 +125,8 @@
{
     string s;
     s = me.demoName(me,me.selectedItem);
-    localcmd("playdemo demos/", s, ".dem\nwait\ntogglemenu\n");   
+    localcmd("\nalias restartdemo "playdemo demos/", s, ".dem"\n");
+    localcmd("\nplaydemo demos/", s, ".dem\nwait\ntogglemenu\n");   
}

void StartDemo_Click(entity btn, entity me)


With this it should be possible to navigate to a certain position in a demo, even if it is gone by already..
lda17h
Alien
 
Posts: 221
Joined: Tue Jun 16, 2009 1:04 pm
Location: Germany

Re: [diff] demotimers

Postby lda17h » Sun Sep 27, 2009 3:31 pm

lda17h wrote:This diff adds demotimers to the client qc code. These can be used to setup timers that e.g. reliably start capturing at a certain time in the demo. Note that these timers are stable against slomo. Thus they can be used to e.g. slomo 100 to a certain position in a demo then start capturing for a certain time, etc...


Ok and here's finally a .cfg to make use of this [use keypad left to rewind and keypad right to fast forward].. depending on your machine you might have to play with the slowmo commands in the cfg. if you machine is slow, don't use such a fast slowmo. try 100, or 50. this should increase the precision at the cost of rewind speed..

EDIT: fixed first line of .cfg
EDIT: turn off sound during seek, too

Code: Select all
alias demotimers_cleardemostuff "cl_cmd demotimer clear; alias demostart_hook "";"

alias demotimers_determinegametime "prvm_globalget client time demotimers_gametime;"

alias demotimers_substract "menu_cmd rpn /demotimers_gametime $demotimers_gametime $demotimers_seektime - def"
alias demotimers_add "menu_cmd rpn /demotimers_gametime $demotimers_gametime $demotimers_seektime + def"

alias demotimers_setupclientcommands "cl_cmd demotimer $demotimers_gametime "r_render 1; slowmo 1; nosound 0""

alias demotimers_setupreverseseek "alias hook_demostart demotimers_setupclientcommands; r_render 0; nosound 1; slowmo 200"

alias demotimers_setupforwardseek "cl_cmd demotimer $demotimers_gametime "r_render 1; slowmo 1; nosound 0"; r_render 0; nosound 1; slowmo 200"

alias demotimers_rewind10 "demotimers_cleardemostuff; demotimers_determinegametime; set demotimers_seektime 10; demotimers_substract; demotimers_setupreverseseek; restartdemo"

alias demotimers_forward10 "demotimers_cleardemostuff; demotimers_determinegametime; set demotimers_seektime 10; demotimers_add; demotimers_setupforwardseek"

bind kp_leftarrow demotimers_rewind10
bind kp_rightarrow demotimers_forward10

Last edited by lda17h on Sun Sep 27, 2009 5:40 pm, edited 4 times in total.
lda17h
Alien
 
Posts: 221
Joined: Tue Jun 16, 2009 1:04 pm
Location: Germany

Postby paperclips » Sun Sep 27, 2009 3:49 pm

that is really awesome good Sir!
one small question though, how do I apply this on latest svn? :)
(find out how to get latest svn here for: "linux" or windows.)

- oh rite you told me on irc -

cd ~/Games/Nexuiz/trunk
wget http://tapas.affenbande.org/demotimers-diff
patch --dry-run -p0 < demotimers-diff
patch -p0 < demotimers-diff
cd data; make; cd -

now take the config part above and paste it into a demotest.cfg file in ~/.nexuiz/data
open up the console in nexuiz and do a

exec demotest.cfg

now record a demo and after a few minutes of playing replay the demo through the menu.
you should now be able to fastforward and rewind.
--


it would be really awesome if it was possible to somehow utilize the recording function by something like this in the console:

recdemo 2009-11-26_12-24_fragcity.dem 420 600

and then like by some sort of black voodoo magic you ended up with a 3min demo :)
Last edited by paperclips on Mon Sep 28, 2009 8:11 am, edited 2 times in total.
[Want to develop? Look HERE]. Image Image Gif sauce.
paperclips
Alien trapper
 
Posts: 346
Joined: Mon Jan 12, 2009 10:27 am
Location: internets

Postby lda17h » Sun Sep 27, 2009 9:21 pm

paperclips wrote:cd ~/Games/Nexuiz/trunk
wget http://tapas.affenbande.org/demotimers-diff
patch --dry-run -p0 < demotimers-diff


Don't forget to run make in the data/ dir to rebuild the quakeC src..
lda17h
Alien
 
Posts: 221
Joined: Tue Jun 16, 2009 1:04 pm
Location: Germany

Postby parasti » Sun Sep 27, 2009 11:07 pm

"--dry-run" typically means "pretend to do stuff, but don't actually do anything"...
parasti
Alien
 
Posts: 110
Joined: Sun May 11, 2008 11:32 pm
Location: On the walls and the ceiling

Postby C.Brutail » Mon Sep 28, 2009 12:14 am

A very much needed patch! Very nice job man!
"One should strive to achieve; not sit in bitter regret."
WE ARE NEXUIZ.
Image
Image
C.Brutail
Laidback mapper
 
Posts: 2357
Joined: Tue Feb 28, 2006 7:26 pm
Location: Ironforge

Next

Return to Nexuiz - Development

Who is online

Users browsing this forum: No registered users and 1 guest