View previous topic :: View next topic |
Author |
Message |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Thu Aug 21, 2008 4:30 am Post subject: 3 moderate QuakeC questions |
|
|
1. How can you set some background music in QuakeC? (Not the cd track or a DarkPlaces .ogg).
2. How can you read information set in the worldspawn in a map? I want to be able to set a flag or variable in a map to specify the availability of a couple of custom QuakeC features?
3. Finally, the starship mod had a low gravity area that was rather hacky in the sense that it set sv_gravity. Is there a good way to have custom gravity per player? |
|
Back to top |
|
 |
CocoT

Joined: 14 Dec 2004 Posts: 599 Location: Belly-Gum
|
Posted: Thu Aug 21, 2008 5:22 am Post subject: |
|
|
Okay, I'm a pretty goofy coder and my ways are often not the most direct ones and/or the ones more experienced coders would recommend, but here is still my two cents...
1 - You coul have a .wav file (it'll have to be shortish and not of the highest quality, otherwise it's going to be too big to precache, though) be played either in replacement of a environment sound or (the way I usually do it), just create a new, invisible entity which will play it throughout the level (something like "sound (self, CHAN_VOICE, "misc/yoursound.wav", 1, ATTN_NONE);" - I think) in loops of a time you'll preset (through nextthink). That way your music could also be heard in engines others than DP. This is how I did it in Quakability Bot Arena (and its first public, infamous "dance tracks" version )
2 -Here, too, there might be less roundabout way to do it, but what I usually do is create a "dummy" entity in the level to which I assign various values in the map editor, then, in QuakeC, I add something like "if (self.tempyourvalue == 1) yourvalue = 1" if I want to make these values global. Again, this is maybe a ridiculous way to do it, but it works
3 - Can't help you there... _________________ http://www.planetcocot.net/ |
|
Back to top |
|
 |
Lardarse

Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK
|
Posted: Thu Aug 21, 2008 8:44 am Post subject: |
|
|
3: .gravity
Originally added to the engine in 1.07 (for the hipnotic missionpack), it allows an entity to feel gravity at a modified level. setting it to 2 will mean twice the gravity (1600), between 0 and 1 will make it be low gravity (0.125 for a mini Ziggurat Vertigo), below 0 may make it float upwards (untested). 0 acts as being 1, so it's impossible to make something not affected by gravity at all, but this allows you ignore it completely if you don't need to set it for some (or all) entities. Just add .float gravity; at the bottom of defs.qc
All custom engines support this, as they are all derived from the original engine source release (which I beleive was 1.10)
2: create a field for it
Say you want to check for a keypair... something like "price_of_beer" "200". What you need to do is add the declaration .float price_of_beer; in the usual place, and then in worldspawn() have something like if(self.price_of_beer > 250) bprint("Prices here are exhorbitant.\n");
A minor caveat is that if the keypair isn't defined, it will be set to 0, so you will need to find another way to let the QC know that it's happy hour... |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Thu Aug 21, 2008 9:28 am Post subject: |
|
|
Thanks
Lardarse wrote: | 3: .gravity
Originally added to the engine in 1.07 (for the hipnotic missionpack), it allows an entity to feel gravity at a modified level. setting it to 2 will mean twice the gravity (1600), between 0 and 1 will make it be low gravity (0.125 for a mini Ziggurat Vertigo), below 0 may make it float upwards (untested). 0 acts as being 1, so it's impossible to make something not affected by gravity at all, but this allows you ignore it completely if you don't need to set it for some (or all) entities. Just add .float gravity; at the bottom of defs.qc |
Do you happen to know if there is a low gravity area in mission pack 1 somewhere? I've played that one through a couple of times but I don't recall a low gravity area, but it's been a while. |
|
Back to top |
|
 |
negke
Joined: 16 Apr 2008 Posts: 56
|
Posted: Thu Aug 21, 2008 12:44 pm Post subject: |
|
|
Afaik it's only used in the start map and in that one base map where you fly through that dimensional portal (with the lightning beams and all). |
|
Back to top |
|
 |
CocoT

Joined: 14 Dec 2004 Posts: 599 Location: Belly-Gum
|
Posted: Thu Aug 21, 2008 2:13 pm Post subject: |
|
|
Now I realize my answer to question 2 was totally beside the point  _________________ http://www.planetcocot.net/ |
|
Back to top |
|
 |
frag.machine

Joined: 25 Nov 2006 Posts: 728
|
Posted: Fri Aug 22, 2008 2:36 am Post subject: |
|
|
You can play sounds in loop just having a cue mark in the .wav file. Play it through an entity sound channel and any stock Quake engine will recognize it and assume the cue mark as the point to restart the sound. It also can be stopped as a regular sound. SoundForge can add such cue marks in the .wav file, but surely people can point you to another tools (maybe some freeware or GPL'd program) to do that, since it's a fairy common feature in commercial sound editors. _________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/ |
|
Back to top |
|
 |
|