Privateer GG talking heads

Forum for discussing various mods for the VS-engine based upon Privateer. (Please play nice now, and extinguish all flaming materials.
Sincerely, The Management)
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Privateer GG talking heads

Post by Herr_Koos »

Hi all,

Been lurking for a while; I mostly post on the Privateer GG forums since it's the only Vega Strike based game I currently play. This community seems much more active though, so here I am! :D

I decided to start messing around with the talking heads implementation. First step was to try and replace the static images with an animation as done for various other things like base backgrounds (walking people, flying spaceships, etc). This turned out to be easier than expected. I also have a fairly easy and repeatable way of turning videos into screen captures and then into animated PNG sequences. It will take time, but can be done, no problem.

The next challenge is getting the logic right so that a particular animation only plays when the correct character is speaking. At the moment, the animation just keeps playing and is oblivious to the timing/duration of the conversation. It also doesn't switch from the fixer or bartender to the player character and back.

What I really need is some insight into how talking heads were supposed to be implemented in the first place. Does the logic perhaps already exist to switch between heads based on who is speaking? I can see some references to talking heads in the code, as taken here from bar_lib.py:

if bartenderhead:
import campaign_lib
if campaign_lib.doTalkingHeads():
script+="import Base\nimport campaign_lib\ncampaign_lib.AddConversationStoppingSprite('Bartender','bases/heads/"+bartenderhead+".spr',(.582,-.2716),(3.104,2.4832),'Return_To_Bar').__call__(Base.GetCurRoom(),None)\n"
Base.Python (room0, 'talk', 0.5875, -0.373333, 0.285, 0.626667,'Talk to the Bartender',script+"import bartender\nbartender.Speak (bartender.GetBartenderText("+repr(bartext)+"))\n",0)


Quite frankly though, I have no solid idea where to start looking or what to look for. Any insight would be greatly appreciated. In the meantime, I will keep working on creating the assets themselves.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Post by klauss »

Herr_Koos wrote: I decided to start messing around with the talking heads implementation. First step was to try and replace the static images with an animation as done for various other things like base backgrounds (walking people, flying spaceships, etc). This turned out to be easier than expected. I also have a fairly easy and repeatable way of turning videos into screen captures and then into animated PNG sequences. It will take time, but can be done, no problem.
You know, we do have support for video files. You do need a build with such support enabled though (not sure it's commonplace in SVN), and it hasn't been tested on the talking heads, but it'd be a matter of testing it anyway.
Herr_Koos wrote:The next challenge is getting the logic right so that a particular animation only plays when the correct character is speaking. At the moment, the animation just keeps playing and is oblivious to the timing/duration of the conversation. It also doesn't switch from the fixer or bartender to the player character and back.
An easy way to fix that is with a timed trigger - ie, you can switch the animation with a static file as soon as some amount of time elapses. Of course it'd be easier with videos.
Herr_Koos wrote:What I really need is some insight into how talking heads were supposed to be implemented in the first place. Does the logic perhaps already exist to switch between heads based on who is speaking? I can see some references to talking heads in the code, as taken here from bar_lib.py
Actually, I'd have to read bar_lib to figure it out. I've never dived much into that code.

But suffice it to say, that the engine itself has very few "base interface primitives". It's probably all done in python, based on timings.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

klauss wrote: You know, we do have support for video files. You do need a build with such support enabled though (not sure it's commonplace in SVN), and it hasn't been tested on the talking heads, but it'd be a matter of testing it anyway.
I'm not really keen to play with SVN right now; I'd prefer to work on what I have. Creating the animations from the videos is quite straightforward, and switching to the video's later will be easy enough.
Herr_Koos wrote:The next challenge is getting the logic right so that a particular animation only plays when the correct character is speaking. At the moment, the animation just keeps playing and is oblivious to the timing/duration of the conversation. It also doesn't switch from the fixer or bartender to the player character and back.
klauss wrote: An easy way to fix that is with a timed trigger - ie, you can switch the animation with a static file as soon as some amount of time elapses. Of course it'd be easier with videos.
Can you give me an example of the syntax, or point me to a reference? I'm willing to give it a shot. I also take it that you would add this line to the environment .py file, thus for bar_lib.py, add a line that plays mining_spr (the animation) for x seconds, then switch to the static PNG.
What I would prefer to do is, for example, play the animation until the currently playing sound file has completed. If there is some flag set after this (I could even add one), one could use this as the trigger for the static animation.
Herr_Koos wrote:What I really need is some insight into how talking heads were supposed to be implemented in the first place. Does the logic perhaps already exist to switch between heads based on who is speaking? I can see some references to talking heads in the code, as taken here from bar_lib.py
klauss wrote:Actually, I'd have to read bar_lib to figure it out. I've never dived much into that code.
But suffice it to say, that the engine itself has very few "base interface primitives". It's probably all done in python, based on timings.
Cool, Let me know if you find anything insightful.
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

A good start would be to find where the current sprite files for the heads are referenced in the code. It may seem like an obvious thing but I'm struggling to find it.
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

OK, think I have the soundfile reference figured out. Question: Can I add and reference variables in .py files without recompiling anything? Thus far, any attempt to set flags or create new variables in a base environment .py file results in that environment no longer being selectable from the main concourse.
loki1950
The Shepherd
Posts: 5841
Joined: Fri May 13, 2005 8:37 pm
Location: Ottawa
Contact:

Re: Privateer GG talking heads

Post by loki1950 »

You should be able to make changes to the Python without re-compiling as Python is an interpreted language not a complied one.BTW some of the sound file controls are done with associated XML files.

Enjoy the Choice :)
my box::HP Envy i5-6400 @2Q70GHzx4 8 Gb ram/1 Tb(Win10 64)/3 Tb Mint 19.2/GTX745 4Gb acer S243HL K222HQL
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo ideapad 320-15ARB Win 10/Mint 19.2
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

Thanks Loki, will keep digging. Where are these XML files located and referenced?
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Post by klauss »

Herr_Koos wrote:
klauss wrote: An easy way to fix that is with a timed trigger - ie, you can switch the animation with a static file as soon as some amount of time elapses. Of course it'd be easier with videos.
Can you give me an example of the syntax, or point me to a reference?
Sorry for the delay, I've been held up by RL. You have an example usage in GUI.py, in the class GUIVideoStream - Base.RunScript can be used to add a python callback with a timeout. The class there uses 0.0 as a timeout to make it run immediately, but you can set any timeout you want.

The pythoncallback function just creates a parameterized script, so it can plug the proper identifiers. You might not need to, and a plain string with the script might be enough.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

klauss wrote: Sorry for the delay, I've been held up by RL. You have an example usage in GUI.py, in the class GUIVideoStream - Base.RunScript can be used to add a python callback with a timeout. The class there uses 0.0 as a timeout to make it run immediately, but you can set any timeout you want.

The pythoncallback function just creates a parameterized script, so it can plug the proper identifiers. You might not need to, and a plain string with the script might be enough.
No worries. I'm on leave as of last Friday, so I finally have some time to play around. :D Still trying to figure out how the scripts tie together. I've been using the mining base bartender as my guinea pig, and inside bar_lib.py I've found where the spr file is referenced and also where the sound files for the speech are referenced. I'll try the timed trigger first and see how that goes.

Will any of Python's default functions or libraries be available? If, for example, I want to add "import time" so that I can use "time.sleep", will that work or will it break something?
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Post by klauss »

Herr_Koos wrote:Will any of Python's default functions or libraries be available? If, for example, I want to add "import time" so that I can use "time.sleep", will that work or will it break something?
There are many built-in modules available in VS (check modules/builtin). There are many missing too. You shouldn't assume they're there in any case, check the builtin folder first.

Though linux systems will have them all available (since we use the distro's python), windows will only find whatever's on modules/builtin.

In any case, you don't want to time.sleep. That would freeze the engine until the timeout happens. Bad thing.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

That helps a lot, thanks. I just used time.sleep as an example, don't worry. :-)
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

klauss wrote: You have an example usage in GUI.py, in the class GUIVideoStream - Base.RunScript can be used to add a python callback with a timeout. The class there uses 0.0 as a timeout to make it run immediately, but you can set any timeout you want.
GUIVideoStream does not exist in my GUI.py file... I'm working with 1.03 stable remember, so maybe it was added after that. Can you maybe post the example for me?
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Post by klauss »

I could, but why not just check VS SVN?

All you need is see how Base.RunScript works, which should work just fine in 1.03.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

Awesome, did not know I could view the code online... Will have to bookmark that link!
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

OK, so looking at this line:

Base.RunScript(self.room.getIndex(),self.index+"PLAY",pythoncallback(self.id, "play"),0.0)

Base.RunScript expects four inputs, but I'm only interested in the timeout (0.0), right? What can I pass in the other parameter fields?
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Post by klauss »

Herr_Koos wrote:OK, so looking at this line:

Base.RunScript(self.room.getIndex(),self.index+"PLAY",pythoncallback(self.id, "play"),0.0)

Base.RunScript expects four inputs, but I'm only interested in the timeout (0.0), right? What can I pass in the other parameter fields?
RunScript takes:
  • Room number
  • Script identifier
  • Python script to run
  • Time delay
The first two are standard for Base interface elements. A script is an element too, one that is invisible and just triggers the script when the timeout occurs.

The python script you pass is run on an empty context, so it gets a bit tricky to do useful stuff in there. You don't have access to variables, not even globals. You can only import modules and invoke their functions.

I was working a way back on XGUI.py, which was an XML-backed UI description parser that would be able to run "pythonscript"-like scripts, essentially adding useful context to that callback. I don't think you need that much context though, because all you need is to change the sprite of an image element, and you can do that by importing Base and invoking it with proper arguments.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

Any way to see what the contents if a script file currently are? I installed Python, opened bar_lib.py, added a "print" line to display the contents of the script file used in the module, launched the game and then ran the module. It returns an error: ImportError: No module named Base, which obviously comes from "import Base" in the first line of the file.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Post by klauss »

Herr_Koos wrote:Any way to see what the contents if a script file currently are? I installed Python, opened bar_lib.py, added a "print" line to display the contents of the script file used in the module, launched the game and then ran the module. It returns an error: ImportError: No module named Base, which obviously comes from "import Base" in the first line of the file.
How did you "run" the module?
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

Opened it in a Python interpreter.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Post by klauss »

Ya... that doesn't work.

Base, VS and a few other modules, are interfaces to engine internals. They don't exist outside of the engine's embedded python interpreter.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

But surely you have ways to view the current value of a variable or otherwise do error checking?
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Post by klauss »

Print, and debug.info/warn/error/fatal/debug (in debug.py)
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

I've tried print with no success thus far. Where does the output of a print command actually display when you use it? Will it be output to a file? Does it create a command line pop-up or open the Python shell window?

EDIT: There is also the question of whether to use the print statement or the print function...
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Post by klauss »

In linux, it all goes to the console. In windows, plain print goes to stdout.txt, while "print >>sys.stderr" goes to stderr.txt.

AFAIK, all the debug functions go to stderr.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Herr_Koos
Trader
Trader
Posts: 31
Joined: Wed Dec 12, 2012 10:43 am

Re: Privateer GG talking heads

Post by Herr_Koos »

How often is stdout.txt recreated or refreshed? Can I just say "print variable" at any point in the code to have it print the variable to that file?

EDIT: OK, yes, it works. That will help a lot, thanks.
Last edited by Herr_Koos on Wed Dec 19, 2012 8:22 am, edited 1 time in total.
Post Reply