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
#2278 
(Random() * 450) - 150;

where Random() returns a random number from 0-1 - i assume QC has that? 
A Better Answer 
so yeah the general case for getting a random number between min and max is:

(random() * (max - min)) + min

where random() would be a builtin function returning a random number in the range 0-1 
Thank You 
How do i put a negative number in there? Like say i want a range from -250 to 250 
 
It's no different, "min" is -250, "max" is 250, so that would be

(random() * 500) - 250 
Thanks 
First time i did it with negatives i must've entered something wrong, now it's working thank you 
Any Way To Set Model Flags Through QC? 
Hexen 2 has some extra model flags for trails that I can't set unless I merge models with QME, but I still can't get exactly what I want 
@bloodshot 
random:
random(-250, 400) will give you a random number between -250 and 400.
this will work with any HexenC compiler, as well as fteqcc even when not targetting hexen2.

model flags:
fte and dp both have some .float modelflags; field.
unfortunately the networking only supports the first 8 bits, and isn't supported by any (non-fte) hexen2 engines, so it won't get you anyhwere.
you may need to resort to a hex editor. you want the 32bit int at offset 0x4c.
although I'd like to think that later versions of qme allowed setting arbitrary flags... 
Good Point About QME 
I've been using 30 because I couldn't find the download again for 31, but I think I might be able to grab it from my laptop and check 
 
i seem to have 3.1 ill look for a zip or i can make one i guess. I know i have it somewhere 
 
 
It's been about 5 months since the last time this was asked, that's a pretty good run I guess. Maybe six next time? :p 
Can You Make Anonymous Functions In Qc? 
 
Fteqcc 
void() foo =
{
entity e = spawn();
e.think = (void()){
dprint("I THOUGHT!\n");
remove(self);
};
e.nextthink = time + 1;
};

such functions may still have undefined behaviour when it comes to saved games, especially when the progs itself is changed. so while you should probably still avoid it, the above works in most cases.
note that there's no enclosures - so you can't access the locals of the parent (static locals should work though). 
+1 Sticky This Thread 
 
 
Make the thread sticky on its 10 year anniversary. 
Blood Splat Question 
Ok, I was in the wrong thread last time...

Do you know how to make a blood splat on the walls in quake that will align with the wall? I've seen it done before, but I cannot cite my sources, unfortunately. I'd be happy to pay someone to make a .qc file for this.

Thanks. 
Blood Splat Question 
Ok, I was in the wrong thread last time...

Do you know how to make a blood splat on the walls in quake that will align with the wall? I've seen it done before, but I cannot cite my sources, unfortunately. I'd be happy to pay someone to make a .qc file for this.

Thanks. 
Untested Suggestion 
Try adding the following to SplatTouch above the line which changes self.velocity:

//fire a trace in the direction of movement to
//try and hit what we collided with
traceline(self.origin, self.origin + self.velocity, 0, world);

//if we hit a surface with the trace
//face the angle of the surface normal
if(trace_fraction < 1)
����self.angles = vectoangles(trace_plane_normal);

It's ever so slightly hacky, because we need to try and reconstruct the collision. So we have a bit of logic to guard against failure, and we don't change the angle if it fails.

This code will fix the angle relative to the facing of the wall, but you may need to add a constant angle if it's consistently turned 90 degrees from true. 
Preach 
Preach, you brilliant bastard!

Can I compensate you for your help?

Thank you so much! 
Nah, Cheers 
I'd risk getting a bit mercantile if I accepted that! 
Bit Subtraction 
okay, I'm not a novice to QuakeC but, i have a question.

float FOO 64
float foo2 128
float foo3 256

so

is it incorrect to use:
value = value - FOO

vs

value = value - (value & FOO)

logically the first just subtracts 64.
I'm looking at OLD code and finding stuff like this.

I have always done it
value = value - (value & FOO);
to just turn off a value. 
 
is it incorrect to use:
value = value - FOO


I imagine you'll find instances of this in the old code only in places where they knew 100% that the bit was set, so just needed to subtract it.

Even so, it's still always better to use
value = value - (value & FOO)

because it shows the coder intent. 
 
if you know that its already set then just subtracting it is fine... 
How Do I Get... 
After killing something,it drops a weapon,out of which some can be picked-up.Just like AD but with vanilla QC code.How do I get this?

I tried adding rubicon2's code for g_axe and g_shotgun in my mod but it didn't work.So now I am starting with a clean source in a few days,how do I make this code from scratch?

Is there a shortcut way to add frames for a monster in qc? I heard it was there in some tutorial online but I can't find it. 
 
Maybe start from checking out DropBackpack in items.qc 
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.