3 moderate QuakeC questions
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
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?
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?
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
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...
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...
Neurotic Conversions - New location: Update your bookmarks!
-

CocoT - Posts: 695
- Joined: Tue Dec 14, 2004 5:39 pm
- Location: Belly-Gum
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...
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...
-

Lardarse - Posts: 266
- Joined: Sat Nov 05, 2005 1:58 pm
- Location: Bristol, UK
Thanks
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.
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.
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Now I realize my answer to question 2 was totally beside the point 
Neurotic Conversions - New location: Update your bookmarks!
-

CocoT - Posts: 695
- Joined: Tue Dec 14, 2004 5:39 pm
- Location: Belly-Gum
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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest