News | Forum | People | FAQ | Links | Search | Register | Log in
Coding Help
This is a counterpart to the "Mapping Help" thread. If you need help with QuakeC coding, or questions about how to do some engine modification, this is the place for you! We've got a few coders here on the forum and hopefully someone knows the answer.
First | Previous | Next | Last
Hope this is the right place to ask.

GLHexen 2 has an annoying long standing issue when upscaling the HUD with -conwidth, some HUD elements are tiled and the seams become visible, like so:

Any idea how can this be fixed? I mostly want to submit a patch for the Hammer of Thyrion source port, I've contacted the author and he's definitely interested in fixing this, but he's no idea what's causing this. We've tried changing GL_CLAMP to GL_CLAMP_TO_EDGE, and it helps with some images, but the others still have those thin lines. I've noticed that FTE seems to have this fixed, how was this done? 
clamp-to-edge is good, but it doesn't affect anything when you're atlasing the texture. In such cases, the atlas should just have the border pixels doubled such that it gets the same value instead of averaging in the texel from the neighbouring image.
beware of mipmaps - eg the smallest mipmap is a 1*1 image that averages the ENTIRE texture instead of just the interesting part. you can use a few mip layers by aligning and capping the mip levels (on desktop gl anyway). or just prescale and avoid mips entirely (with 1 pixel borders).
alternatively you can pinch texture coords inwards by half a texel instead of padding with borders, but beware that the half-texel depends upon the mip level that will be used, so that's still messy.
(sidenote: gles supports npot textures only with clamp-to-edge and no mipmapping)

the other thing to do, especially for the hud images themselves, is to use premultiplied alpha (aka: rgb*=a [or equivalent] before uploading, then draw with blendfunc one,one_minus_src_alpha, you'll need glColor4f(rgb*a,a) for variable transparency). This avoids all discolouration on the edges between opaque/transparent texels, how this works should be well documented elsewhere but basically premultiplied alpha is awesome - USE IT!

also, if you're in contact with the author, can you get him to respond to my bsp2 patch (ideally by merging part of it)?
he doesn't really need to bump all the limits that my patch bumped, so long as the clipnodes are no longer so horribly limited... 
Ambient Sounds From A Point 
If I was to make a mod to create ambient sound entities that could play custom sounds from a point, how would I go about this?

Also what's the best program to use for this kind of thing?

Can custom ambient sounds be done with Quoth? if so, how? 
@ HexenMapper 
Here's a link to a version of the Quoth .fgd(JACK/Worldcraft editing game file) that lists custom ambient sounds.

So it's a simple as placing an entity and then setting the keys for your custom sound, location of course being the most important one.

As far as adding your own custom sounds to a mod, simply look at a mod that has the QC source available(Not Quoth). Though Preach my have a tutorial covering this on his site. Arcane Dimensions is a good current example, so if you play that you already have the QC files to examine.

Download and use FTEQCC GUI, then you can search for "custom sound" to see how it is implemented.

thanks damage_inc, I'll have a look into this 
If the goal is simply to have custom sounds play on a map, why not just make the map for Quoth or AD. Load the fgd into your editor and you are set, the custom sound entities are documented in the readme files for these mods. This will save you from having to create a new progs just for this one thing. Also it will allow you to use all of the other entities from Quoth or AD. 
You could also use the qc or progs from "extras4" - it has some nice features and custom sounds as well.

In mid 2002 nostalgia and boredom drove me to write some interesting QuakeC hacks. The result is this "Extras" mod, which aims to provide extra stuff for Quake mappers. It features honest to goodness func_water, and func_ladder entities, as well as an insanely customizable emitter/effector based particle system, and advanced trains and switches. So if you ever wanted to dynamically flood a level, or attach water volumes and/or switches to trains, this is the mod for you! Example maps and some snazzy new animated sprites and sound effects are also included. 
For The Curious 
1. Download qc source.
2. Add the following to misc.qc:

void ambient_generic () = {
if (self.noise1 == "") { remove (self); return; } // check that we have a sound
precache_sound (self.noise1); // load sound in memory
ambientsound (self.origin, self.noise1, 0.5, ATTN_STATIC); // start ambient loop with volume 0.5

3. Compile using fteqccgui.exe
4. Place the resulting progs.dat in your mod directory (e.g. C:/QUAKE/mymod/progs.dat)
5. Run your map with -game mymod in the commandline. 
Thanks for the info - I think I can attempt to put something like this together! 
I followed your example and have a progs.dat, but how do I add a sound entity into a map? which entity and keys should I use

And where should I place any new sounds inside my mod directory? 
Adding The Entity 
1. Add any point entity.
2. Rename it to ambient_generic
3. Add key|value of noise1|"folder/sound.wav" without the quotes and of course going to the directory under C:/QUAKE/mymod/sounds/folder/sound.wav or wherever your sound is. Don't include the "sounds" folder.
4. Compile and you will have your ambient. 
In world.qc, the different lightstyles are defined using 'a' thru 'z' for brightness in a string. I have questions about limits and compiler:

1. What is the character limit for the string?

2. Is there a limit on different lightstyles?

3. Does the compiler create a different saved lightmap for each letter a,b,c, etc?

4. Are lightstyles hardcoded into the compiler?

5. Does anyone know of a mod that makes their own lightsyles, e.g. Spastic Lightning or a Flash and Fade, etc.? 
1. Max string length is MAX_STYLESTRING = 64 which looks like it includes a null terminator, so 63 characters
3. No, the compiler bakes (and writes to the bsp) lighting at 100% brightness, which is level "m", I think. Whatever level QC requests is generated by scaling the 100% brightness lightmap to the requested brightness.

Each face can have up to 4 different lightmaps baked for it (bsp format limit), and each lightmap is linked to a lightstyle number.

more detail: the engine looks up the current brightness levels (a-z) of the (up to) 4 lightmaps that were baked for that face. Each of the baked lightmaps is scaled to the right brightness, they're added together, and the result is used as the lightmap for that frame.

4. No. There's not much hardcoded in the light compiler except it knows if a light has "targetname" set, it allocates one of the 64 style numbers for that targetname. It knows if a light has "style" set to use that as the style number for when that light hits faces.

5. Hmm.. I'm not sure. "The Middle Evil" had a lightning effect. ne_ruins might do some tricks with lightstyles, I forget?

The system could be pushed further with a bit of QC, e.g. switchable lights could be extended so they can be animated while on. Could have fade in/out transitions. 
1: 63 chars (more depending on engine). chars outside the a-z range still have meaning but may result in numerical overflows (at least in surface caches), so avoid capitals etc.
there is an extension that allows styles of the form of "=0.5" to set a specific value with greater precision (1 is about equivalent to m - quake has overbrights), which allows for smoother style changes.
fte has an additional extension that allows you to pass an extra arg for rgb values.
the style strings are dynamic state, the qc is free to change them whenever it wants. however its the engine's choice which char it uses from the string at any particular time so if you want fancy qc-based animations its best to stick to a single char per lightstyle string (or the = thing, if your target engine supports it).

2: the bsp format (including bsp2) is limited to 255 different light styles (0-254, 255=no more). Many engines still limit to 0-63 however (higher requires saved game changes).

3: the map compiler is unaware of the style strings themselves. triggered lights will automatically be assigned a (shared-by-matching-targetname) style index.

4: styles 32+ will typically be used for triggered lights. lower indexes can freely be (re)defined by the QC mod, but existing mods will expect the same style strings that they were made for, so beware of that if you try changing the existing styles.

5: my recommendation would be to create some new trigger_lightstyle entity or something that allows you to (re)define the styles from the map itself, because awesomesauce. Bonus points if it can be triggered to enable/disable/recolour/etc all lights with the same style. Note that this should probably not be baked into the individual lights. 
Dynamic Strings 
If you want to be able to programmatically change the lighting strings you can use the basic idea from the following tutorials (a long and involved series of posts)

The crucial change you need to make is to use

float SVC_LIGHTSTYLE = 12;

as the header byte instead of SVC_CENTERPRINT when you send the characters. This may be overkill but it's nice to know there's a way to do it if you need. If you just want a way to translate a float into a light level it's a fairly compact way to do it without some kind of 26 line long if statement.

This trick will be employed in an upcoming project I'm working on... 
a mod that makes their own lightsyles

I remember JPL's "FortDriant" used a recompiled light index for making a long stairway of repulsing light on a long range of 32.

Don't know if its included in the map. 
Thanks Guys! 
Rubicon 2 has custom light styles 
i've done this
void () execute_changelevel =
local entity tmp;
local float bcount;

intermission_running = 1;
intermission_exittime = (time + 5);
lightstyle(0, "f");// R00k: -added- dim light on intermission

oddly I assume the world uses lightstyle 0 looking in the misc.qc for the lights i cant find any reference for the actual numerical value, yet in world.qc, lightstyle (0,"m"); etc.. 
wait ya, .style entity field is a lightstyle thus the world entity inits with = 0; 
Zero Style 
It's basically that, except it's the style field on the light entities which matters, not the style of the world entity. When you don't set a style, the field defaults to 0 - even in the light compiler. 
okay so basically all default lights use lighstyle 0 which is why altering
that to a lower value makes it look like nighttime? i set
that for intermissions and on any map it dims the screen
so the scoreboard shows up better ;) pr_lightstyle calls the svc_ to broadcast to all connected clients. 
Cell Shading On Makaqu 
so I wanted to implement cell shading in my game, and I'm using the makaqu engine because it has cell shading support but more importantly it can be compiled for the dreamcast (I'm making a game for it). When I asked the developer how to implement the cell shading he told me to edit defs.qc and add the line:

float EF_CELSHADING = 16384;

and add this to the model script:
self.effects = self.effects | EF_CELSHADING;

problem is, when I compile it using fteqccgui and place it in my mod pak it still doesn't have cell shaded graphics. I want to add the effect to the player model and the dog, so how would I do this? 
Request For Details 
and add this to the model script:
self.effects = self.effects | EF_CELSHADING;

Can you give us a bit more of the context surrounding this line of code, like which function you've added it to? It wants to be in the function which is setting the model of the entity you want cell-shading on. 
Cutscene Code For Commercial Game? 
I’m looking for QuakeC code for creating cutscenes for a commercial project. I plan to ask whoever originally wrote the code for permission to use it for this, and it’s for a Dreamcast and PC game using the makaqu engine. If anyone can point me in the direction of code for this, I’d like to homogenenise it with my current code (I’m using a little bit of modified code since I can really only read C and C++) to play the beginning of a level. Is there anyone who can suggest some good code for this that’s relatively easy to use? 
Another Question 
Also, I’m putting commands in the world.c code for specific levels, but for some reason it’s not using them. I’m using cvar_set and localcmd. I need these for the game to work. 

Are you putting those localcmd's inside worldspawn or startframe? If you use main() it might not work. 
Thx! One More Question! 
Thanks for your answer! Another question, when I start a demo when the level starts, then the demo exits the level, the game crashes. However, it doesn’t crash the menu screen if I put in startdemo instead of startdemos it goes into the next level which I want this one to do. Is it because I have different cvars coded into both levels? I’m currently at work so I can’t test it yet, but just getting a second opinion. 
Last Part 
I’m using localcmd to start the demo in the start level, which the demo is supposed to spawn the player in e1m1 after the demo plays. 
Demo Hacks 
the typical way to chain demos to maps is to insert an svc_stufftext into the end of the demo to get the client to issue a 'map' console command at the end.
you can't use the changelevel command etc, so all weapons etc will be forgotten. you can work around that with cvars (again eg nehahra) but this makes a mess when it comes to saved games (and potentially restarting the map). 
So Type It In The Console? 
So just straight up type in svc_stufftext map e1m1 into the console when I want the demo to end? Or do I have to code a timer? 
Player Walk Animation Not Playing Right For Custom Character? 
so I have this coder and he and I can't figure out what is wrong with the code. In Darkplaces, the walking animation works fine, but when I switch to makaqu, it also combines with the attack animation! We don't know whats going on! Any help would be appreciated! 
We will need to see your code. Are you using frame macros? Skeletal or vertex animation? Any QC extensions? 
My Code 
Nevermind! Just Had Too Many Animations! 
Just found out that it had too many animation frames! We fixed it! Taking down drive file for security reasons 
Explobox-induced Undead Leaping Fiend Bug 
Hi guys!

In my upcoming map I have a problem with fiends when they (quite often) kill themselves by leaping at exploboxes. They do give the death sound and add to the kill total, but they kind of end up only half-dead:

-If not gibbed by the explobox, they will remain upright and solid and periodically turn to face the player and leap at them. The attack won't damage the player, though.

-If gibbed, the same behaviour occurs except with just the fiend's decapitated head! Delightful! @~@

Does anybody know if someone's already fixed the bug? 
Explobox-induced Undead Leaping Fiend Bug 
Multiple exploboxes? 
possible workaround:
make a second entity to surround the explobox, using the 'clip' texture so that the fiend can't hit the explobox itself, and thus can't zombify itself.
add a trigger_once entity inside the explobox and give it a health value, and have it killtarget your clip entity, so that the artificial blocker doesn't continue blocking after the box explodes (unfortunately the explobox doesn't do target/killtarget stuff, hence the separate trigger).

any qc mod that fixes the chained-explobox-not-chaining bug should have also fixed the zombie-fiend bug thanks to adding a small delay before the explobox itself fires. 

I heard about this earlier. Can you give more details where and why this happens? 
the explobox's th_die function calls T_RadiusDamage which calls findradius, which calls another explobox's th_die which calls findradius again, which clobbers the first findradius's chain causing it to not see the ents that it should have. You can see this on e3m1 I think it was.
The solution is to add a small delay between the th_die and the T_RadiusDamage.
This additionally fixes a stack overflow crash, as well as this fiend bug, and imho looks a little nicer when a group explodes over time, instead of all at once.

Unfortunately there's not really anything an engine can do to fix this (short of ugly hacks that rewrite the qc at load time). Increasing max stack depth delays the crash but still doesn't allow you to have 10000 exploboxes in a domino-run sort of layout...
I guess you'll have to do that with spawns instead... 
This bug is fixed in URQP. I'd suggest looking at its source, especially misc.qc and combat.qc. 
No More Zombie Fiends 
Thanks a lot for your help, Spike and c0burn!

Since my map already has custom code in it (to enable some custom decorative models), I solved the problem the qc way: I simply copied the explobox-related code from the URQP misc.qc, so now my barrels explode in a cool domino style (but still almost instantaneously for it to feel vanilla enough)! B)

The only problem is that the fiends no longer deliciously gib to pieces when they kill themselves by leaping into a bunch of barrels. :'( I did lazily check if URQP had a more "vanilla" solution, fixing the zombie fiend issue while still retaining the instantaneous explosion chaining, but I couldn't be bothered enough. Did you have something in mind, c0burn, when you referred to combat.qc? o: Oh well, better having less gib-inducing barrel clusters than having some solid "ghost" fiends (or their heads) leaping about.

I also gave Spike's "clip shield" workaround a try, but my memory served me well as I recalled that the clip texture can only be used on world brushes and func_details, it seems. Not even info_notnull or InitTrigger trickery fooled qbsp to compile the brush. :/ I even tried giving the func_detail brush a targetname and tried to killtarget it with a trigger, but nothing worked.

Anyway, the delayed barrel chain explosion fix is a good enough workaround for me. Thanks again! :) 
Best Darkplaces Controller Analog Config? 
So, I'm trying to fine tune the analog stick movements so they aren't so twitchy. However, everytime I try to edit the config, it just doesn't do anything. I think I'm using the wrong commands. Darkplaces joystick config commands are so confusing so I don't know which one to use! Basically, I need it so that the character always moves slowly when the left analog stick on the 360 controller moves around. I'm using chase_active for my game, so if they need to see the player and it can't be too fast. If someone could give me the base settings and new better settings that I can tweak to fit the game, please do! 
iiuc, you can build clip brushes into non-world entities, but you do have to include a non-clip brush somewhere in the same entity.
But yeah, better to fix it via qc, if you have that option. 
Try using the fixed T_RadiusDamage from URQP (you can skip the dtype stuff though). 
Hmm just had a though they're probably not gibbing because the demon gib check is for less than -80 health. You could try increasing it. 
Garbled Centerprint Text 
Hi. I'm trying to get back into quakec so I can finally finish my mod I started ages ago. Anyways, trying to brush up and some things by starting simple. I added a reverseweaponcycle to Malice ( I found a source on github). I seem to be getting some garbled text when shooting buttons which activate secrets. For instance, in level 2, there is a button which is supposed to display "there are more to go) after you shoot it. But now it displays some sort of garbled text which includes some of the brown text. Any idea where I would look to see about fixing this? As in which source file? Thanks. 
The Malice src. is decompiled. So don't expect everything to work. 

I get that, but I don't know which of the files to look in to try and fix it. :( Been looking through other info to try and figure it out, but no luck yet.

I can't seem to register on insideqc and since quakeone changed, it won't let me enter text to post over there. :( This is the only other place I know to ask. 
Legend, Open Up Your Mind! 
The source is alright. The only thing your Quake engine cannot do is to print russian letters.

You might have noticed that EVERY print is like that. Not just the secret button text.

The fix is really easy. Just copy the english phrases into your Malice source. Overwriting the russian text and you are done. Use the ones from vanilla 1.06. It works like a charm.

Or you can switch from english to russian in your engine if it supports it :P

To give you a start: For your specific secret button issue replace the russian words in the function: void() counter_use into english. The function starts in line 170 inside triggers.qc in the Malice source.

The rest we can discuss at if you prefer. 
Wow. Thanks. I didn't notice the rest of the text because I kept testing off of a save file. I'll start poking around. Thanks again.

Unfortunately, I can't use quakeone anymore. I think it may be because my computer is too old and therefore my chrome version is outdated. I'm on xp. I can't enter any text in quakeone for some reason in order to make posts or replies. 
Any idea what this one is supposed to mean? "предмет выпал с уровня на". Using google translate, it comes out as "the subject fell from the level on". But I have no idea what that should really say or what the context is. It's in line 157 of triggers2.qc. Void() The_plant. 
Something To Do With Map Testing? 
I'm no expert, but as I understand, Quake has some tools for map testing. For example, if you place one of your entities like health/ammo boxes etc. too close to the floor when creating the map, there's a chance the entity falls of the level when you run it and get a message in your console for every entity that had fallen off the level. Maybe the line of code is referring to that? 
Malice Source Tweaks 
Thanks for the tips. Spent a few hours getting most pertinent messages translated back into English correctly. The last one I posted still escapes me. As well as one I find that translates into "Splitter" But no idea what it actually does.

Other than the translations, I have managed to add reverse weapon cycling and reverse item cycling. Is there anywhere I can post it when I'm finished so that an English source is available for all?

Also, any ideas on a fix for the probe not moving when selected? Is there a quakec fix for this or only an engine side fix within quakespasm?

Legend Is Everywhere 
Hello again my friend,

I noticed that you posted about your Malice issues in the Quakespasm thread as well. I would like to stay here in the coding help section to better keep topics together. Also because it is not an Quakespasm-only bug.

First of all I am glad that the russian-english tip brought you further in your project.

You brought up some other related questions which I would like to try to answer.

- Chrome is outdated:
You would be suprised who else is still using XP. Why not try and install firefox if chrome doesnt work. You can install and use multiple browsers.

- "the subject fell from the level on":
Like Esrael already wrote, this is a developer message. Please look at the vanilla function inside items.qc: void() PlaceItem
It is exactly the same. You can even use the original english text from there. Which is: "Item fell out of level at "

- minigun texture misalignment:
Please find a fix for it here:

- spy probe not flying in Quakespasm:
Never use setmodel() without setsize()
That is the main culprit here.
So, what you want to do is, open probe.qc and add after: setmodel(self, "progs/probe.mdl");
this line: setsize(self, VEC_HULL_MIN, VEC_HULL_MAX);
That will fix the basic issue and the probe works again.
But there is another issue with the code: Malice spawns it in relation to the players view and angle. That needs another fix to make the probe also work when it is spawned while the player is looking upwards:
Change this line: self.origin = self.origin + v_forward * 40;
To this: self.origin = self.origin + v_forward * 40 + v_up * 10;
That should do the trick for most angles and situations. The ceiling is normally always 10 units higher than the player. So that is no problem.

Best of luck with your version of Malice. 
Cool. Thanks again for the probe and message help. I was hoping the probe could be fixed with qc. :)

As for the browser, I do have firefox installed as well. Unfortunately it doesn't wanna work either as far as quakeone goes. :(

I came across that minigun skin you pointed out and it does indeed fix the issue. Though, I suspected it could have been an engine thing since messing about with graphic settings does temporarily fix it without the need of the new skin. Though I'm happy to just go with the skin for simplicity sake.

I posted in Quakespasm thread cause I believed the probe to be an engine issue.

Thanks again. 
Thanks I got the probe working now with your code. One odd thing is that it won't start moving until the player looks up first. As in, you can't activate the probe and immediately start moving forward. Is this how it originally was supposed to work? 
That Dang Probe! 
Something is eluding me here. I can make it it function, but only after the player looks straight up. I've even tried using code from spawning rockets to try and make it begin further out. I'm missing something. Any other ideas? 
No problems here, Legend.
I push the use button and right after that the fire button and it starts flying without even moving the mouse. It doesnt matter if I look straight, a little down or upwards.
Sorry, you must have done some wrong copy/paste.
I used the exact same lines I gave you.

Just in case, be sure to not use a previously saved game with your new progs.dat as the gamecode has been changed. Always start a new game/map and test.

Even in that tiny place at the start of map d2 it works as it should. I am using QS 0.93.
Try harder Legend :) 
Malice Probe Code 
Thanks. I'm using the same version of QS. Could you possibly look at my code and let me know where I went wrong?


self.probe_sound = time + random() * SVC_SETVIEWPORT;

Gotta love decompilers. :)
All those assignments to unrelated constants from defs.qc makes it really hard to read. Consider changing them because that'll be way more appealing for anyone willing to help. 
C´mon Legend ... :) 
I wrote:
So, what you want to do is, open probe.qc and add after: setmodel(self, "progs/probe.mdl");
this line: setsize(self, VEC_HULL_MIN, VEC_HULL_MAX);

Unfortunately you added the new line at the wrong place. You must read more carefully.

You added the line after:
setmodel(probe, "progs/probe.mdl");
That is NOT:
setmodel(self, "progs/probe.mdl");
You set the model to the wrong entity.
probe is not self and self is not probe. ;)

You should not change model or size to different entities in one code block. That awakes evil things and the shamblers will hunt you for that :P

I am sure you can fix it by yourself now. Just reread post #2448.

Also, you still have the russian text inside your code...

Best wishes my friend.
And many greetings to osjclatchford. 
Ugghh. Of course it was just a simple silly oversight by me.

I cannot find any more russian in the probe.qc. I'm sure I may still be missing some in the rest of the files. Though. Which is my blind ass missing in the probe.qc though?

And btw, who is you is? Seven? Dutch? And how do you know I've been talking with osjclatchford? Are you psychic? A sorcerer? :O

Anyways, thanks again for all your help and explanations. 
2 posts not shown on this page because they were spam
First | Previous | Next | Last
Post A Reply:
Website copyright © 2002-2017 John Fitzgibbons. All posts are copyright their respective authors.