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
Gremlin 
I was trying to add a gremlin to the standard qcc and of course I got a lot of errors.
When I finally had cleaned them up I started the game and reached:

progs.dat system vars have been modified.
progsdefs.h is out of date.


It might sound familiar, but is there a solution? 
Defs.qc 
Check the changes you made to defs.qc, you can't add new fields to that file until all of the system fields have been created. 
Typically 
It means you've added new stuff too high up - put your changes at the bottom of defs. 
Confirmed 
I added four strings to the defs.qc as they were the errors I recived after compiling.

float visible_distance;
.float gorging;
.float stoleweapon;
.entity lastvictim;


How can I make addittions to the defs.qc , or should I delete all functions in grem.qc that work with doe.qc 
Fixable 
Like ijed said, just move those lines right to the bottom of defs.qc, and you should be fine. 
Yes! 
that worked.
You earned your pronounciationmark back Ij!ed.

Alhough I don't see it steal my gun, it works fine. 
Hit That One 
Alot of times. When you're learning blind a molehill is everest. 
 
Gremlin 
Well I trried including a Gremlin in my map without the whole SOA pak. And as I expected was the hipgrem.qc not enough. I had to make a change to the ai.qc and defs.qc as well.
When I was done and could compile without errors the gremlin came in game.

But for some reason the weapon steal trick doesn't seem to go. I did all I thought I need to do changing the needed hipsdef into the normal def.qc but something slipped away. 
Substitute 
it was neg!ke with his pronouncion mark. 
Well 
i guess its a dubious question asking where the gremlin has left my weapon. 
Bit Masks 
i want to be sure i understand these:

Operations:

self.flags = self.flags - (self.flags & FL_ONGROUND);
this will subtract FL_ONGROUND but ONLY if FL_ONGROUND is present in self.flags.

whereas:
self.flags = self.flags - FL_SWIM;
would just blindly subtract the flag and risk breaking self.flags if FL_SWIM wasn't there when you subtracted.

likewise:

self.flags = self.flags | FL_ONGROUND;
would add FL_ONGROUND but only if FL_ONGROUND wasn't present in self.flags.

whereas:
self.flags = self.flags + FL_SWIM;
would add the flag as well, but would break if FL_SWIM was already present in self.flags.


Conditionals:

if (self.flags & FL_ONGROUND)
is the only way to check if FL_ONGROUND is present in self.flags. 
Correct 
But the safe versions are strongly preferred, because they don't break anything.

Note that you can work with multiple bits if you need to. The code for picking up armor removes all 3 armor flags before adding the correct one.

The only operation I'm not sure how to do is to toggle a flag (if off, set it; if on, clear it). 
Toggle 
The following code will toggle flags:

self.flags = (self.flags | FL_ONGROUND) - (self.flags & FL_ONGROUND);

The right hand side features two halves. In the case that FL_ONGROUND is already set, the first half does nothing, and the second half is equal to FL_ONGROUND, so the flag gets removed.

In the case that FL_ONGROUND is not set, the first half turns it on, and the second half is equal to zero, so has no effect.

There's a nice kind of symmetry going on with this formula. It combines the adding and subtracting flags, but in such a way that only one actually does anything in each case. The whole right hand side is evaluated before the result is assigned to the left hand side, you there is no risk that self.flags changes mid way through.

It's worth knowing that this can be extended to multiple flags:

float IT_TOP3WEAPONS = IT_GRENADE_LAUNCHER | IT_ROCKET_LAUNCHER | IT_LIGHTNING;
self.items = (self.items | IT_TOP3WEAPONS) - (self.items & IT_TOP3WEAPONS);

This code will toggle the most powerful weapons in the player's inventory correctly, regardless of which ones they may possess. In practice, it would be worth following up that line with a call to W_BestWeapon(), in case the player was using one of the weapons you just toggled. 
Thanks 
didn't know about the toggle one. 
That Sound Bug 
You know, the one where you pick up 2 items more-or-less simultaneously, and hear only 1 sound. I was thinking of fixing it engine-side, but then I realized this: often, 1 sound overriding another is the desired behavior.

I know of the null.wav being used to kill a playing sound, but I suspect there are other situations. Can you guys give me some examples? 
Upon Further Consideration... 
It probably makes more sense to look at it from the opposite side, ie. when don't you want one sound to override another?

So, picking up multiple, different items; using a key which causes a door to open; what else? 
There's Also The Classic 
"Quad Cancel" sound bug, where you land just after picking up the quad, and the "oof" overrides the quad pickup sound. 
 
Picking up the MH at DM4 with no sound (picking up the rockets to achieve that) is a deathmatch tactic.

I am all for it anyways. 
CHAN_VOICE 
It makes sense that anything a monster/player says overrides what they were previously saying - for example a pain sound interrupting some other noise.

If people wanted multiple pickups to sound, the fix is easy to perform in QC. Just remove the channel specification from the sound command - if set to 0, the sound plays from any available channel. 
Revised Ruleset 
The DM angle is something I hadn't thought about, so I probably should just apply the fix to sp/coop. I agree that changing the QC is the "proper" way to do it, but an engine workaround has the advantage of not requiring any effort from the user(*).

How about only applying the fix to CHAN_ITEM and the powerups on CHAN_VOICE? Or is there a case where you'd want one of these sfx to be stopped before completion? (I'll probably include a check for null.wav, which would kill all sounds on the channel)


*assuming I do eventually release this, and anyone actually uses it 
Say No 
to cheap hacks. :( 
No Cheap Hacks?! 
Quake as we know it wouldn't exist without them - interpolation, fullbrights, external textures, skyboxes, fog, extended limits, modified protocols, plus a good chunk of the id & hipnotic code.

It's a good philosophy to keep in mind, but it's never a black-and-white issue. The reality is that all code makes assumptions about the environment in which it's run. And making changes to an existing codebase is never as clean as it would be were the features part of the original design. Sometimes you have to bend the rules to get the result you want. And in the end, if it works, people are willing to overlook the messiness of the implementation.

So I take it personally when someone dismisses my attempt to fix a known bug as a "cheap hack". If you've got any particular concerns or informed criticism, I'd like to hear them. Otherwise, don't bother.

And to those who provided useful input, thank you :) 
 
except it is a cheap hack. it will cause an inconsistency in how channels work for a specific few cases which can cause confusion and annoyance later down the line for some poor bastard modder who isn't aware of one guy's attempt to 'fix' behaviour that was working as intended. a sound is expected to override the previous sound playing on a channel.

if it bothers you, fix it in qc (channels 5, 6 and 7 on the player are rarely, if never(?) used-- they could easily be used for a second item channel) because it's a qc bug. you can even play the pickup sounds on the items themselves, although the left/right won't be balanced because the sound isn't emanating from the player, but that solution is probably the most easiest to implement. 
Thank You 
That made a far better case for your point than your previous post ;)

I guess my frustration wasn't really due to you calling it a cheap hack (because I'm not disputing that); it was more the feeling that you were dismissing it outright. The truth is I respect you for all you've contributed to the Quake community, so it's people like you I need to hear from to help me see things from a mapper/modder view. So thanks for the followup.

For me, the annoying thing with a bug like this is, here we are, 13 years later, and the QC hasn't been fixed (afaik; maybe you guys did in Quoth, but that would still leave a few hundred mods that are potentially affected, plus the thousands of maps that people don't run under Quoth).

One part of your post I didn't quite get was the "play the pickup sounds on the items themselves". Were you talking about reworking the QC to call sound() in an item-specific touch function rather than the generic one? Or were you talking about the engine making use of the .noise field? 
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.