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
Particles Are Harder Than They Look 
Continuing on my super enforcer, I'd like for the projectile to spawn particles as it's flying in the game, and make particles scatter on impact.

So for the first part of this I went to the QuakeC manual and found said line to spawn particles: "void particle(vector origin, vector dir, float color,float count)". I tried "void particle(org, 0, 245, 7);" but FTEQCC doesn't like that I wrote "org", and putting "0" instead make the same results.
The idea is to spawn chunks of particles at a given time btw. 
Org 
is probably undefined, so 0 has the same effect. 
So What Should I Replace It With Then? 
 
A Vector! 
particle (self.origin, '0 0 0', 228, 5);

Where do you need them? right where the thing is, so, self.origin.

Do you want them to move in xyz? Probably not because the bullet is moving, so '0 0 0' movement.

What colour? Maybe orange... 228

How many? Really it depends on how frequently it will produce them... 5 maybe. 
Note 
If you do want to give them movement, the vector of the projectile will not be taken into account unless you do some vectormancy. 
Thanks Ijed 
Now I need for the projectile to generate said particles, like the Vore's explosive balls. I looked into its file, but there's no mention of any particle line here, same thing for the rocket in weapons.qc. 
(please Ignore The Title Icon) 
 
 
The particles coming from the voreballs and rockets are features of their models, not the code. Your better bet is to look at the AD source code. 
Burst Of Particles 
To get the explosion of particles when the projectile lands, you need to use the following rather unintelligible code:

WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
WriteByte (MSG_BROADCAST, 35);
WriteByte (MSG_BROADCAST, 8);

The most interesting value to play around with here is the one currently set to 35. This controls the colour of the particles. The 35th colour in the palette is a pale blue, so that's the colour of the explosion, 144 makes it bright purple instead.

The following value sets the range of colours that the particles cycle through. At the moment, the value 8 means that we cycle through eight colours in the palette. In the example, the next 7 colours after the starting point are all slightly different shades of blue, so the effect is a slightly dappled effect. If you changed this value to 255 then you would get (almost) all the colours in the palette.

QC Quiz: What goes wrong if you set this value to 256? 
 
It wraps to zero and you don't get any particles? Or they're all black ... or something ... 
256 Refers To The Transparent Color, E.g There Won't Be Any Particles 
 
The Solution 
It wraps to zero

Yes! As the function suggests, the value is packed into a byte, and so a value of 256 will be transmitted as zero instead. Based on the patch notes for darkplaces, I'd guess this will usually make the engine crash with a divide by zero error. 
TE_EXPLOSION And DP 
TE_EXPLOSION2 doesn't exist (a trap!), so I changed to TE_EXPLOSION. Compiled it, run it, and when the projectile hits, this happens: http://image.noelshack.com/fichiers/2015/53/1451421144-infantry20151229213012-00.jpg

Is this an isolated incident to DP or did I made a mistake on just copy pasting your code? 
 
#define TE_EXPLOSION2 12
it was created for rogue, so tends to not be pre-defined in vanilla id1 code, but it does work in all NQ engines (but not vanilla qw) if used properly. 
It's Nice But 
It's like when I tried to make a custom explosion sound for a rocket soldier: the original explosion sound seem to always play whenever TE_EXPLOSION or any variant is called. There's also no burst of light and the particle spread, while blue like I wanted, doesn't look as good as the original one. 
Ah Yes, The Sound Trick 
Yeah, it's annoying that the engine does that - there is a silly workaround though. Replace the sound/weapons/r_exp3.wav file with a silent sound like sound/misc/null.wav. Then you need to add the sound back onto the the grenade and rocket explosion by making a copy of the original sound and playing it manually. 
Thanks Again Preach, Another Thing 
You said some time ago your website holds a way to make a monster spawner, much like how Quoth did. I did look for it in the Code section but I haven't found such a thing. Maybe the title is different, or it's not in the Code section? 
Quake Mp1 Laser Gun Laser Position Help 
I'm trying to change the position of the lasers from mp1 to match the new quake 1.5 models. I've managed to correctly change the position of everything else. But looking at the code, I'm having some trouble figuring out where/how to actually change it.

I assume it is here:
=================
HIP_FireLaser
=================
*/
void(float stat) HIP_FireLaser =
{
local vector org;
local vector dir;
local vector out;
local float ofs;
local float aofs;

if (!self.button0)
{
player_run ();
return;
}
if (self.ammo_cells < 1)
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
SuperDamageSound();
self.effects = self.effects | EF_MUZZLEFLASH;
makevectors (self.v_angle);

ofs = 6;
out = v_forward;
out_z = 0;
out = normalize(out);
org = self.origin + ((12-ofs) * v_up) + (12*out); // this is the value I have to change for the starting position?
// org = self.origin + (1*v_forward);
dir = aim (self, 1000);
aofs = ofs * 0.707;
if (stat == 0)
{
self.currentammo = self.ammo_cells = self.ammo_cells - 1;
org = org + (aofs*v_right);
org = org - (aofs*v_up);
HIP_LaunchLaser(org, dir, 0);
org = org - (2*aofs*v_right);
HIP_LaunchLaser(org, dir, 0);
}
else if (stat == 1)
{
self.currentammo = self.ammo_cells = self.ammo_cells - 1;
org = org + (ofs*v_up);
if (random()<0.1)
{
HIP_LaunchLaser(org, dir, 1);
newmis.dmg = 25;
}
else
HIP_LaunchLaser(org, dir, 0);
}
self.punchangle_x = -1;
}; 
Looks Like It 
 
HIP_FireLaser () 
Yes, its where you commented. I went a little further and made a .vector vwep_pos , that merely points to that org vector in each of the weapon firing functions...so now its easy to know where a missile originated from with respect to the player.Its a little but weird because the Quake guy dont really hold the weapon up to his eye level like other games do, but alot of the tracelines in Quake start at eye position, and there is a difference depending on what knd of calc you wanna do.

Also, I have tried to make the starting point of the missile or the beam for the LG look just as good from the first person view , as from the outside of the model when firing. Its tough, and I dont think there is really a way to make it look exactly right...bleh. 
 
@Daya
Little known hack for explosion particles without sound:
particle(pos, '0 0 0', 0, 255);
(direction and colour will be ignored, count must be exactly 255, pos is the middle, obviously) 
Blood Redscreen 
Is there a way to disable or control the frequency of the red screen flash when the player takes damage? Apparently the QC is not doing a bf stuffcmd, so I guess this is done engineside? It sould be neat to setup the intensity based on the amount of damage taken...right now using Darkplaces, I cant find a setting for this and the effect seems the same no matter what the damage taken is. 
 
Dunno but sounds like the sort of thing that would trigger Smabler so go for it. 
 
Dmg_take controls red tint, dmg_save armour tint. Dmg_inflictor I think controls how the screen tilts. 
Quake 1 .bsp Lightmaps 
Does anyone have some documentation they could link me on how lightmaps are stored inside the .bsp?

I'm trying to create a Quake 1 map renderer in Unity and lightmaps are sort of my final frontier.

I've found some conflicting documentation, most of which is vague. From what I gather the lightmaps themselves are simple arrays of values 0-255. I assume it's just a big lump of bytes, and the faces point into it to the start of their lightmap, but I do not know how to determine the size of any given face's lightmap. bspfile.h defines it as [numstyles*surfsize], but I'm not sure where to find or how to calculate a faces surfsize for this purpose.

Can anyone toss me a pointer? 
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.