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)

Privateer GG talking heads

Postby Herr_Koos » Wed Dec 12, 2012 4:21 am

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.
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Share On:

Share on Facebook Facebook Share on Twitter Twitter Share on Digg Digg

Re: Privateer GG talking heads

Postby klauss » Wed Dec 12, 2012 5:48 am

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
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Postby Herr_Koos » Wed Dec 12, 2012 7:34 am

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
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby Herr_Koos » Wed Dec 12, 2012 8:15 am

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
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby Herr_Koos » Fri Dec 14, 2012 11:31 am

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.
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby loki1950 » Fri Dec 14, 2012 3:56 pm

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 18/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 DELL E6400 4GB ram/100 GB HD Mint 17.3 6
User avatar
loki1950
The Shepherd
 
Posts: 5706
Topics: 51
Joined: Fri May 13, 2005 1:37 pm
Location: Ottawa

Re: Privateer GG talking heads

Postby Herr_Koos » Sat Dec 15, 2012 9:25 am

Thanks Loki, will keep digging. Where are these XML files located and referenced?
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby klauss » Sat Dec 15, 2012 8:17 pm

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
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Postby Herr_Koos » Sun Dec 16, 2012 4:59 am

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?
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby klauss » Sun Dec 16, 2012 11:27 am

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
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Postby Herr_Koos » Sun Dec 16, 2012 2:32 pm

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

Re: Privateer GG talking heads

Postby Herr_Koos » Sun Dec 16, 2012 2:39 pm

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?
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby klauss » Sun Dec 16, 2012 2:45 pm

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
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Postby Herr_Koos » Sun Dec 16, 2012 3:32 pm

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

Re: Privateer GG talking heads

Postby Herr_Koos » Sun Dec 16, 2012 3:43 pm

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?
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby klauss » Sun Dec 16, 2012 3:57 pm

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
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Postby Herr_Koos » Tue Dec 18, 2012 4:53 am

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.
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby klauss » Tue Dec 18, 2012 5:48 am

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
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Postby Herr_Koos » Tue Dec 18, 2012 5:50 am

Opened it in a Python interpreter.
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby klauss » Tue Dec 18, 2012 10:31 am

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
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Postby Herr_Koos » Tue Dec 18, 2012 2:49 pm

But surely you have ways to view the current value of a variable or otherwise do error checking?
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby klauss » Tue Dec 18, 2012 3:39 pm

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
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Postby Herr_Koos » Wed Dec 19, 2012 12:15 am

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...
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am

Re: Privateer GG talking heads

Postby klauss » Wed Dec 19, 2012 12:52 am

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
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Privateer GG talking heads

Postby Herr_Koos » Wed Dec 19, 2012 1:15 am

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 1:22 am, edited 1 time in total.
Herr_Koos
Trader
Trader
 
Posts: 31
Topics: 1
Joined: Wed Dec 12, 2012 3:43 am


Next

Return to Privateer Universe

Who is online

Users browsing this forum: No registered users and 2 guests