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
Euler Angles 
How to calculate roll from a vector? I tried and atan2(-y, x) was best so far but roll can still jump from 162 to 77 when moving in loop-de-loop. 
 
I don't think you can really get that. A single vector representing a forward direction doesn't have an inherent roll to it. 
#3094 
A number of engines have a two-arg version of vectoangles, the second being the 'upwards' vector that pairs with the regular 'forward' vector arg. It doesn't need to be fully perpendicular - its sole use is for computing the proper resulting roll angle.

You can then use makevectors twice, do some matrix maths to combine them (hurrah for order mattering), and then vectoangles2 to get back to eular angles.

vectoangles' buggy pitch values are still an issue though (along with mdl pitch too). just flip the sign as appropriate depending on bsp/spr/view/makevectors vs mdl/vectoangles. 
QuArK Built In QuakeC Editor 
I've decided to use QuArK to start getting into quake modding (and I know it's not the best pick) but I like it as a full IDE. I was going to only use it for models and maps but by chance I found it supports QuakeC files with syntax highlighting, now the problem is that I don't really get it what exactly a QuakeC patch is that QuArK can make. I don't need to recompile id1 to get the progs? I'd really like to see a few examples. Another problem is that the text editor breaks spacing and cursor position after I put a bracket when syntax highlighting is on: https://x0.at/JDv2.png
Any way to fix that without disabling the highlighting? 
 
And now I just figured that whenever I try to "compile the QuakeC patch" within QuArK all I get is a memory access violation error...
https://x0.at/rufa.png 
 
You might consider using Visual Studio (freeish) and not using the QuakeC syntax and use real C syntax which fteqcc supports naming all your source files monsters.c or defs.h

Then you can autocomplete and go to definition and search/find like a true final boss.

It is known way to be productive in QuakeC, and a number of successful projects have a .vcproj file or similar in their QuakeC source dir.

And then just make .bat file shortcut on the desktop to fteqcc in your qc folder to compile your source. 
 
THanks for the reply, I am aware of other ways to work with QuakeC. Im just very curious about how it works in QuArK after seeing this video: https://www.youtube.com/watch?v=XB_em-5m7Z4
I have a little experience (really little) coding in QuakeC but I always thought you need to do changes to the existing sources and then compile them into a dat file although in the video just one QC file was used somehow 
 
I have a little experience (really little) coding in QuakeC but I always thought you need to do changes to the existing sources and then compile them into a dat file although in the video just one QC file was used somehow

What you thought was correct. Quark is not doing anything magical here - it's simply that the video has given you the wrong impression. The mod has been compiled earlier, using all the QC files off-camera. The video starts with the mod already compiled, and just happens to have one of the source files open on screen. 
 
Thank you for clarifying! May I also ask how to configure visual studio to work with QC? I only have experience with compiling the sources using FTEQCC directly 
 
You just have an empty project, drag files into the project and use it as a text editor.

I do the same thing you do to compile. I use the fteqcc directly (although I always use the fteqccgui for errors).

Visual Studio cannot compile QuakeC. The point is the code editor only. 
 
Also is there code highlighting in fteqccgui? According to some screenshots there is such functionality, but I have no idea where it's adjusted. And I noticed by rightclicking on something it can show the definition of that but it never works saying "there is no name currently selected", I tried to rightclick on a selected text and that didn't work too 
#3102 
you can configure msvc to invoke external programs somehow. the ui for that has probably been changed completely since I last used msvc though.
when invoking fteqcc in this way be sure to use the '-fmsvcstyle' argument in order to have fteqcc spit out the error/warning output that msvc requires for being able to double-click errors/etc to jump to the lines indicated. otherwise it'll probably just ignore your attempts.


syntax highlighting is provided by the third-party scintilla component. if that wasn't enabled at compile time(read: because you compiled it yourself) then you get no syntax colouring - and a much worse editor experience too. all gui builds on TTH include it. 
 
Has anybody created a (open source) mod of info_intermission that allows the mapper to point to a text file and make it print the contents on level change? Or one that achieves a similar effect to Quake's end of episode texts but without having to hardcode the text? 
@Tex_Fish 
You could make use of the trigger_boss_gate.

This are the logic endings of an episode and switch with one of the four end runes to the text file, as they are used to complete the cycle.

Only thing you also have to do is change the progs.dat with a texteditor and use the same amount of text and replace it with your own. 
@text_fish - Custom Intermission 
Untested code! This should be easy to patch into most mods:

1. Open client.qc, and look for the definition of info_intermission. Replace it with the following:


/*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
This is the camera point for the intermission.
Use mangle instead of angle, so you can set pitch or roll as well as yaw. 'pitch roll yaw'
*/
string custom_intermission;
void() info_intermission =
{
if(self.message) {
custom_intermission = self.message;
}
};

2. Scroll further down client.qc looking for the comment below. Insert the code in bold

//
// run some text if at the end of an episode
//
if (custom_intermission)
{
WriteByte (MSG_ALL, SVC_CDTRACK);
WriteByte (MSG_ALL, 2);
WriteByte (MSG_ALL, 3);

WriteByte (MSG_ALL, SVC_FINALE);
WriteString (MSG_ALL, custom_intermission;
return;
}
else
if (world.model == "maps/e1m7.bsp")...

Now you can add a "message" key on the info_intermission entity, and it will come up as the end text for the level. Note that if you have multiple info_intermission entities and give them [i]different[/i] messages, one message will overwrite all the others, and will display regardless of which viewpoint gets selected. 
Spot The Error! 
Missed out a closing brace there.

WriteString (MSG_ALL, custom_intermission);

This is the kind of deliberate error Raymond Chen would put into a solution to make sure the recipient has their brain engaged. I'm not as cunning as he is though, it's just an honest mistake on my part... 
Preach 
Here's how ILike80sRock did this for progs_dump: Allows for multiple pages. Would be interested in your feedback... just cuz.

https://github.com/progs-dump-dev/progs_dump/blob/main/qc/intermission.qc 
Code Review 
Hi dumptruck! It all looks good to me. It's aiming slightly higher by allowing for multiple pages of intermission text in a sequence. That explains why the code is a bit more complex than mine, and why the design requires a separate entity type to hold the pages.

That said, I'm proud of my solution as far as it goes. It wanted to be concise enough to fit into a func_ post, so I didn't add any bonus features. And I tried to create it as a "patch" that could be integrated into nearly any mod, so I aimed to make the edits:
- at as few points as possible
- at points easy to find regardless of how much the mod changes client.qc
- as small as they could be 
Wow 
Thanks Preach that looks awesome, I'll try it out as soon as I can.

Respect. 
Thanks! 
Your insights are greatly appreciated. 
Orge Doesn't Drop A Backpack With A New Ammo Type - Using Copper 
Hi there, I got a small problem. I've been working on my own gameplay mod that adds onto the gameplay changes Copper adds, one of them being that the Grenade Launcher and Rocket Launcher uses their own ammo types (Grenades and Rockets).

I have the ammo working perfectly but I wanted the Orges to only drop the new Grenade ammo and *not* Rockets. So when I went to change the ammo they drop and tested it out, they don't drop a backpack at all. I tested other ammo types and got similar results... it only seems like they only like dropping backpacks if they ammo is set to Rockets. Any help I could get with this? 
Grenade Advice 
Hi wuunds.

I'd take a look at the DropBackpack function - one of Quake surprisingly consistent details is that the same function is used for both monsters and players dropping all their ammo. The very first check in that function is whether the total ammo of monster/player is zero or not. You will need to modify this to include the count of grenades.

This should make the ogre drop the backpack. However, you will probably also need to make related changes throughout the backpack code. Make sure that the number of grenades is copied into the backpack when it spawns. Also make sure that when a backpack is collected it makes the second transfer from the backpack to the player.

As a general tip, try doing a global search for ammo_rockets in the codebase, and see what you find. You may discover there are more spots where you need to add a case looking at ammo_grenades to avoid a bug. 
Base QC Code That Makes Sense To Use 
Hi!
I am starting a new adventure in coding, the MOD will be primarly MP but with SP too.
Question is, instead of starting from scratch all the times with 1.06, and then getting crazy to add CTF or bots to it, is there some solid QC code which already contains the basics for Multiplayer, so I can mod that one directly?
I am sure there are already codes to run servers with CTF + ROcket Arena + Bots + whathave you.
Can anybody point me in the right direction? 
How Do I Make An Entity Rotate Around Its Own Axis? 
Hello,
I'm having trouble trying to make entities rotate around their own axes instead of the world's in QC, for example if they're pointing straight forward using only angles_y to rotate it works just fine, but what about when they're tilted (angles_x or angles_z != 0), how can it be done? I tried using v_up, sin, cos and crossproduct to no avail. If it's actually possible, how do I do it?
Any help will be appreciated. 
Func_rotate 
There is a mod called "extras_r4" from Hipnotic, that uses rotating models with usefull info.

Here is a link from Khreator.
https://github.com/khreathor/extras_r5/blob/master/progs.src

Also I put a link on quaketastic with some info.
There is also a rotatetut.zip.

https://www.quaketastic.com/files/rotate.html

Hope it's of any help. 
First | Previous | Next | Last
You must be logged in to post in this thread.
Website copyright © 2002-2024 John Fitzgibbons. All posts are copyright their respective authors.