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
 
Surely, lacking a modulo operator, something like this must work:

if (number & 0x1) {
// odd
}
else {
// even
 
"positive number line" 
 
float(float a, float n) modf = {
return a - (n * floor(a/n));
};

modulo with floating point types is fun.


but yeah, if its just odd vs even, just use value&1. 
Weapon Animation Going Faster Than 10 Fps 
For some who've been on the modelling help thread, I've been working on a machinegun weapon. I've been able to complete them and are ready to be implemented in the game.
Thing is, the viewmodel has been designed to run at 0.05 sec for each frame, more than the minimum 0.1 sec. But I've seen there's a way to go past this, as seen here: https://youtu.be/E5zyhlZ1xVI?t=2m22s .
I know Q2 got around that as well with the Chaingun's second spin, and from what I've seen in the sourcecode, the same fire pattern is applied a second time but with a 0.05 delay. Thing is, I have no idea how to accomplish it, can anyone help me on that?
Also, the weapon is supposed to fire at every two frames, the inbetween are for cosmetic purposes (meaning it'll fire as fast as the NG/SNG), and I intend to apply the same fire programming seen from the Nailgun/SNG (where the fire trigger is tied to the animation) 
Variables For Storing Persistent Info Between Maps 
I know we once had a long discussion about the most efficient and safe way to store information between maps (say if one was to try to make a hub-style continuity across maps) - anyone remember this, and got link to the posts? 
Kinn 
Not sure about that but I'm pretty sure Socks mod new mod has a better way to do this now. 
 
Daya - view weapon anim is driven by the player model's animation state, which is crappy. there's not-insignificant reengineering to be done to decouple them.

Kinn - parm1-parm16. 
Kinn, 
Got Most Things Working For The Infantry Gun 
Now there's a last thing, and it's about def.qc, where it stores the weapon slots. Taking http://www.insideqc.com/qctut/qctut-7.shtml as face value, I put "17" as a value for my weapon. Now thing is, it opens the grenade launcher icon, while I want it to be on the 4th (NG) one. I tried "5", but it also adds me the Nailgun when I pick up my weapon on the testmap. Tried other values like 3 and 7 but I always have other weapons added on pickup. How can I deal with this? 
Copy Paste 
If you want it to be on the nailgun slot, copy the value that the nailgun has there. You basically have to replace the nailgun by stealing its slot, copying the values etc. If you want the nailgun as an alternative then you need to do a lot more complicated stuff, for starters just replace everything to do with the nailgun with your new code. 
Cf. Scourge Of Armagon, With Proxymine Launcher 
I looked at said sourcecode (both weapons.qc and hipdef.qc) and the weapon switching code is the exact same (see http://pastebin.com/7bUga8cy ). Even with that I still can't choose the gun by pressing 4. What the hell! 
Parms Abuse 
Cheers chaps, that post by Preach was the stuff I was looking for 
Data 
your code says 'if i have the nailgun, switch to the infantry gun, otherwise switch to the nailgun' which makes no sense. 
Source Of Confusion 
There are lots of places to get confused in the weapons code. The first is the difference between .items and .weapons.

You'll have spotted the way that the IT_ codes are taken from the sequence of doubling numbers:
1,2,4,8....
That's to make each of them have a single 1 digit in binary:
0001,0010,0100,1000...
This lets you add a set of them together into one number, and get the bit flags back afterwards:
1101 = 1000+0100+0001 - the point is that you can work out what "single digit numbers" to put on the right, just by looking at the number on the left. It wouldn't work with just any set of numbers (the trick is called bitflags if you want to google it).

So that's how .items work, it can store all the items the player has picked up in a single number, just because of how the bitflags add up. On the other hand, the .weapon field only needs to be able to store one weapon at a time, so there's no reason it couldn't use 1,2,3,4,5 as the codes for the weapons. It basically uses the same codes as .items out of expedience.

Well...ok, that last bit is not strictly true, but it's a very useful way to think about the QC code in isolation. Enter the second confusing thing about the .items and .weapon system: as well as being the way that the QC handles the player inventory, these fields have "side effects" which affect the HUD. So the binary digits which are 1 for the .items value turn on weapon slots. When .weapon is the equal to the value of one of the item slots, that weapon is lit up on the HUD.

So the side effects stuff is a bit hard to keep track of, but it gets worse. The third confusing thing is that the expansion packs wanted to alter the HUD, but originally it all works automatically as "side effects". So if you run engines in -hipnotic or -rogue mode, the HUD changes behaviour! Different numbers of weapons/powerups appear, an extra field called .items2 controls some behaviour...it's a real hacky mess.

So I return to my original suggestion. Initially, just make a weapon that replaces the nailgun. This will be challenging enough to get to grips with, and once you've done that, you'll be in a much better shape to understand the changes in the hipnotic code and how to bring the nailgun back. 
Found A Way To Keep Both 
By pretty much writing 4 possibilites, depending on what the player holds. "No weapons" shows up when pressing 4 with either the nailgun or the infantry gun hold, but for now I don't care.
Now, the absolute final thing: how do I make the hitscan attack draw a small trailpuff like Q2 Weapon Factory's Mega Chaingun? I've been told to make some sort of loop to make it happen, but that only made things more confusing for me. Any help on that one? 
Parms Follow-up Post 
In my parms blog post a short way above, I linked to a bug that can cause you to lose runes when you load a save file and then decide to restart the level instead. I've devised a way to work around this bug in QC, and posted it tonight:

https://tomeofpreach.wordpress.com/2015/09/30/fixing-runes-and-restart-with-qc/

There's not much insight to it besides fixing the bug, but you should go and copy-paste the code anyway... 
High Level Smoke Puff Trail 
use this shotgun tempentity code to create the puff:
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);

look at code for temp entity stuff, the last 3 lines are the x y z coords and org_? is the vector variable.

create a loop that iterates along the vector generated by the traceline that is detecting damage for hits and such at regular intervals and spawn the temp entity from the above code (make a vector variable called 'org' as referenced in the code).

to iterate, get the vector and normalize() it then multiply that unit vector by increasing amounts until you are past the end point. 
 
That's the thing though, I know mostly nothing about programming, and your reply just make me ask more questions, like "How do I write such a loop and where do I implement it?" and "Wouldn't this effect be too big considering I want to control the particles amount and spread?" and "Wouldn't using gunshot impact effect look bad in Darkplaces, considering it replaces the puff with an actual bullet impact GFX?" 
 
http://www.tutorialspoint.com/cprogramming/c_while_loop.htm

float len = vlen(endpos - startpos);
while(len > 0)
{
//do whatever effects here
len = len - 16; //do it spaced out by 16 units
 
Another "been a while since I did this shizzle" question:

What QC compiler are the kool kids using now, is it FTEQCC? If so, where is the homepage/link to latest version pls? (google throws up a host of dead/shady links) 
 
I just use whatever tools are on ericw's page ...

http://ericwa.github.io/tyrutils-ericw/ 
Warrenm 
Ah yes, for map compiling absolutely - but what I was wondering is what QC compiler is the current hotness. 
Kinn 
Mfx 
Noice, that's just the ticket 
 
Oh lord, sorry. :) Reading, hard, blugh... 
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.