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
@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 
 
Like khreathor says,
when the mod drops a backpack, it spawns an entity, (with a timer to remove it).
To drop a gun seperate from the pack, like the gun in hand with *some* ammo, you need to spawn a new entity, with a PRECACHED model. and give that entity a .ammo amount, and create a touch function for that gun-entity.
I had done this once long ago. I will dig up some code and try to point you to your goal.
It only helps you to become a better coder with hints and not code cut/paste. But I can give you a detail list of what you need to get this working. 
Ijazz2 
Not exactly what you want but you may find some of the coding useful to get what you are after:-

http://www.insideqc.com/qctut/qctut-60.shtml

http://www.insideqc.com/qctut/lesson-10.shtml 
Lightningdamage 
does anyone know why IDsoftware made the trace for the lg start at the feet not +16?
```
org = self.origin + '0 0 16';

traceline (org, org + v_forward*600, TRUE, self);

WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
WriteEntity (MSG_BROADCAST, self);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
WriteCoord (MSG_BROADCAST, trace_endpos_x);
WriteCoord (MSG_BROADCAST, trace_endpos_y);
WriteCoord (MSG_BROADCAST, trace_endpos_z);

LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
``` 
Lightning Position 
First thing to note is that the player's self.origin is at crotch level, not feet level. However, you are correct that the visual beam projects from a height of 16 units above the damage beam.

The sad truth is that the lightning bolt code is kinda buggy, and that's not even the worst bug. If you look through LightningDamage you'll notice it performs 3 traces in a row. The intent seems to be making the beam wider and allowing it to hit multiple enemies in the path. In fact, the vector calculations for the 2nd and 3rd are completely wrong, and the beams just fire into parts of the level that can't be seen by the player.

The buggy extra beams do fire in a way that is predictable based on the player's origin and facing angle. The following video shows a speedrun which exploits this! At about 50 seconds in, the player rides a lift down, faces in a very specific direction, and starts shooting the Thunderbolt. The specific location and direction of the shot causes a second beam to hit the Shalrath at the end of the level, which kills it before the doors open. This lets you grab the rune early, speeding up the run...

https://www.youtube.com/watch?v=D_P35WtpAwY 
 
origin is at crotch level

So that's realistic then. 
Lightning Buggy 
Sounds like a fast 4 wheeler.

Anyhow, is there a fixed version of the code somewhere? 
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.