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
 
Went looking for an equivalent in the quakeC manual, it said "float" was it.

Or maybe I misred it and it's something else? 
 
there's no booleans or integers in quakec, float is what you get.

also, spirit is right, "if (gatlingsound = TRUE)" sets gatlingsound to true and then returns true 100% of the time.

why are you doing this?

float() gatlingsound =
{
TRUE;
};


are you trying to define a variable named gatlingsound? because this is a function declaration.

just trigger the sound on every 8th frame of the animation, you don't need to faff with this at all. 
 
2) float as Boolean?!

In QC everything is a float - like javascript!

Spirit is correct that your test should use a double equals sign like:

if (gatlingsound == TRUE)

If your compiler doesn't warn you about this then you should get a newer version of FTEQCC.

Also, I think your definition of gatlingsound is a bit confused. What you have defined is not a variable to store a value. It's a function. It isn't even quite a function which returns "TRUE", because you've missed off the return command.

What you want to do is:

.float gatlingsound;

This adds a new variable to the player called gatlingsound. You have to access it as "self.gatlingsound = FALSE" and "if(self.gatlingsound == TRUE)".

That should get you compiled. You may find it doesn't delay the sound very much, but you'll be at the right point to look at the example of invisible_sound for how to do longer delays. 
Lunaran 
I can't play the sound as you said, because the firing animation is played 1 frame every 0.05 second, meaning it would only play half the firing sound every time the animation loops.

And I just can't get the thing to work, even with "==" (it says "==" is not a name). Tried to replace TRUE and FALSE with 1 and 0 while changing "float" with "void", but the same errors always came in: "local functions may not be initialized" (is also said when I still use TRUE and FALSE while using == on everything but the declaration line) for the declaration line, and the rest is "unknown value "galtingsound"". 
Preach 
Your thing got compiled. Thanks! 
@Lunaran 
float() gatlingsound =
{
return (TRUE); // add return
};

if (gatlingsound == TRUE) // single = is an assignment , double is a comparison
sound (self, CHAN_WEAPON, "weapons/mingn2.wav", 1, ATTN_NORM);
else
sound (self, CHAN_WEAPON, "weapons/normal_gun_sound", 1, ATTN_NORM);

Also realize CHAN_WEAPON is not the same as CHAN_AUTO , so if there is another sound playing on CHAN_WEAPON, it will be overrided as well as another sound on the channel being able to override yours in code executing past the function you are putting it in. 
Gatlingsound () 
Sorry, the () is required otherwise it might cause that compile error:

if (gatlingsound ())

// pretty sure this will proceed only if true, but I have seen cases where negative intergers cause a true in some engines , IE: -1, -2 etc. 
Lmao 

float() gatlingsound =
{
return (TRUE); // add return
};


Can we just agree this is dumb as hell and not do it like this?

Just use a constant. 
Soundbuffer () 
Also, I have made soundbuffers in my mod but using just the basic sound command "play" stuffed to the console. I suppose it could be done with regular sound calls, best to define a special sound channel for it though, IE : CHAN_BUFFSOUND = blah

Where blah is the sound channel number. Darkplaces suppoert up to 128 sound channels total, not sure if other engines expand the sound channel range.

Basicly:

.string buf1,buf2,buf3,buf4;
.float sounbuffer

So you play the first sound, then call a new function that lists all the possible sound strings that the playing sound can be, and returns a float value equal to the total time it takes to play the sound in seconds, for each given sound. Then -

self.soundbuffer = time + SUB_SNDLEN (current sound);

In PlayerPRethink () , you add

if (self.soundbuffer < time && (self.buf1 != "" || self.buf2 != "" || self.buf3 != "" || self.buf4 != ""))
SUB_ChkSndBuffer ();

From there you just make the new function that checks all 4 buffers if a string is present. If so, clear that buffer with a null (""), and send that old string over to the function to play a buffered sound. that function also needs to scope through all the buffers in order in the even lost of sounds are stored. 
Most Engines Have 7 Xhannels 
1 to 7 are explicit and 0 is whatever is free.

Of course, you can just spawn new entities and have unlimited channels. 
 
actually, that's a common falacy.
channel 0 is not 'whatever is free', its a 'don't terminate anything'.

of course if you do play lots of sounds at once then things can get VERY LOUD, which is why stuff tends to use an explicit channel, especially if the later half of the sound is a little echoy such that it sounds stupid when you have multiple instances playing with 0.1 sec intervals.

there may still be a global limit on the total number of sounds that can be playing at once, but thanks to static sounds this is typically quite a high limit (read: thousands). 
It's Okay Guys 
Preach's way was compatible with what I wanted to do, and it goes as expected and flawlessly.
But still, thanks for your attention. 
 
i have also noticed if you try to play the same sound twice in the same frame, the engine will ignore it (or play at half volume?).
the only way around that i've seen is to create two separate .wav files that are identical and play the "different" sounds at the same time. 
 
if you start two sounds at once on the same entity (on different channels) all you will have done is to double the volume.
with different ents, you will have spacialisation differences so there is still a purpose, but it will still be extra loud.

FTE does randomize the start time of the second sample slightly (this is something q2 also does). This tends to make it a little more echoy without making it quite so obnoxiously loud - more sounds means that it'll *probably* be louder, but this isn't guarenteed as the time difference will negate this effect by a not insignificant amount so volume 1.2 or so instead of 2.0.
This is the sort of thing you want if you have 20 identical monsters all seeing you in the same frame.
It can also potentially help in deathmatch too. 
Z-aware Grenade Shooters? 
I'm continuing on doing monster reskins, and I want to make an Enforcer that's similar to the Defender, but I want it to shoot grenades while being Z-Aware, unlike the Ogres, and maybe make it explode on contact (they'll have to be weakened if I want to do that).
I remembered Inside3D/InsideQC had a tutorial for that, but for some reason I can't find it.
Can anybody help me on that case? 
 
 
I remembered Inside3D/InsideQC had a tutorial for that, but for some reason I can't find it.

Try this one,it's not hijacked:

http://www.insideqc.com/qctut/ 
Thanks Lunaran, Also 
I did a Grunt shooting accelerating rockets, I tried to make in a custom explosion sound, but it plays the vanilla one instead and the explosion sprite doesn't come up.
code: http://pastebin.com/0aBFGkFP

Another thing, still on that Defender-like: how to make him trigger an attack where the player is in a set distance? Looking at the Ogre code doesn't seem to answer me.

and MadFox, this is exactly where I went, but I couldn't find it. 
Another Thing 
What's the way of reducing the amount of stun taken by a hit for a monster? Is it related to armor values? 
.th_pain Or Pleasure 
You need to look at the function in ".th_pain". Two good examples are knight_pain and sham_pain.

Typically there are three decisions to make in a pain function. The first is whether the monster had a pain animation recently or not. Usually this is a bit of code like:

if (self.pain_finished > time)
���return;

self.pain_finished stores the first moment the monster is allowed to go into pain again, and this code skips a pain animation entirely if it's too soon. This is a very important bit of code because it stops pain animations overlapping - without it you'd have monsters entirely stunlocked by a stream of nails.

The second choice is to decide if the damage is high enough to trigger pain. Typically only very large monsters do this, like the shambler:

if (random()*400 > damage)
���return;

This means we skip the pain animation randomly, in proportion to the damage inflicted. For example, a shambler will only go into pain from a 200hp hit 50% of the time. A full double-shotgun blast does ~50hp, so that's only a 1-in-8 chance of a pain animation. 400+ hp in one blow will always cause shambler to go into pain, but even a quad rocket to a shambler isn't powerful enough for that.

The last choice is selecting which pain animation to use, here's the code for the knight:

r = random();

if (r < 0.85)
{
���knight_pain1 ();
���self.pain_finished = time + 1;
}
else
{
���knight_painb1 ();
���self.pain_finished = time + 1;
}

The line knight_pain1(); start this pain animation immediately, and it will run to the end before the monster starts attacking again. The main difference between these two animations is that knight_painb is much longer. A way to make the pain animations less severe is to pick the short animations more often, so the monster resumes fighting earlier.

You'll also notice that it's this part of the code which sets the pain_finished time, in this case saying the knight won't go into pain for 1 second. The enf_pain is an elaboration on these ideas, as there are 4 pain animations to choose from, and the last one has a longer pain_finished time than the other. So another way to make your monster resistant to pain is to increase these times, but be careful! Setting these too high made the Quoth monsters irritating to fight, as they were too relentless. 
Ogres Lob Grenades Into Cover 
...is what I believe the original post on inside3d was. Me and Prime collaborated on this into Gnouc's clean src a while ago into a creepcam2 project. IT seemed to work pretty good from what I remember, and I thnk we put in a skill comparison to activate it as well. YOu can copy the code from the Ogres function here: [ https://github.com/teknoskillz/Creepcam2/blob/master/monsters/ogre.qc
Right Handed LG Pos 
Trying to _perfect_ as best as possible the starting pos of the LG beam using a right handed vwep model sort of like the one in dpmod has. The tricky part is finding a compromize between the 1st person view, and the external viewposition. I believe there is no perfect fit, but this is the code I am experimenting with in W_FireLightning ()

local vector angl;
// angl = self.v_angle;
angl = self.angles;


normalize (v_forward);
org = ((self.origin + (v_right * 7)) + ((v_up * (10 + ((angl_x * -1) / 3)))) + (v_forward * (12 + (((0 - angl_x) / 1.05)))));


I believe the problem may be v_angle versus angles, as the first person view will always be using the v_angle perspective, and using .angles definately manages the external view better so far in my experiments.

Just curious if anyone ou tthere knows a better way? Im using Darkplaces as the engine and it has a waist level lightning option in the menu but on or off does not seem to show much difference in this case. 
 
that's going to change based on engine, right? fitz engines use a different weapon offset than other engines, and it's positioned differently when you look up or down. 
CSQC 
Hey, anyone knows any resource for learning CSQC? Mostly HUD related CSQC. Every link i find seems to be dead.
Also i wanted to know if FTE supports CSQC for Hexen ;P 
 
There is some CSQC info at this location http://forums.insideqc.com/viewforum.php?f=16&sid=1 
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.