I thought I would start this thread to give people ideas how to go about hacking QuakeC code to do things and see why Quake can still be so much fun to play. Long after you beat the game you eventually want to change something, maybe just make it harder. Well there used to be lots of tutorials on QuakeC but they aren't many around on the internet anymore. So this thread will be kind of an interactive tutorial where I can show you some little things you can do and how you can go about making quake do whatever you want.
Now you need to know how to program to do QuakeC. But I'm going to just jump right in and show you to do stuff and get immediate feedback from the game, and you will learn all this code. Trust me it is not hard at all, it just takes some desire to want to learn it.
Ok so I thought what would be a good little snippet to get started with? Well did you ever notice in Quake, when you get hit by a grenade, or you shoot a monster with a rocket, it doesn't go flying? Doesn't it seem strange that explosions don't send monsters flying through the world? Well you are in luck because it is pretty easy to do this.
Now first you have to get the quakec code and the compiler. I am pretty sure you can find this stuff on this site. But if you can't, go to ftp://ftp.idsoftware.com. Go into the source directory. Somewhere in there should be something like qccsource. If you have trouble finding it then I will upload the code somewhere for you. Now you need the quakec compiler. Well you are in luck there, because one is available on this site. It's called qccx and it's in the downloads. This is much better than the original compiler anyways, as it will catch more errors that you might make. It even caught some errors that were made in the original source code.
Ok so now hopefully you are set up and ready to roll. Now you need one more thing. Some way to edit the files. Well, you can use notepad which comes with windows. I like QCide myself, but notepad will work fine. Now find where you extracted the quakec files and look for a file called combat.qc. That is all the quakec code that is used for combat.
In combat.qc you will scroll down and find a function called T_Damage that looks like this
Scroll down until you see this:
now select that last line and paste this over it
Now compile the code with qccx and if it all goes correctly, there will be a progs.dat file. That is the compiled QuakeC code. If something went wrong, qccx will tell you a line number with an error. Hopefully if you did this right though, you won't have any errors. Now you need to put this progs.dat file somewhere where quake will find it. The best thing is to create your own mod folder in the Quake directory and put in there. Then you start the game with quake +game directory where the directory is the name you used. You can stick it in the ID1 folder, but keep in mind that some pak files have their own progs.dat, and yours might not get loaded if it finds another one first.
So now what does it do? Well you see T_Damage is called whenever something is hurt. When you get hit by a lightning bolt, T_Damage is called to inflict damage on you. You see the self.velocity? Well that is just some variable that tells quake how fast you are moving. Self is an entity which has information about the monsters and things in game. Self is a special entity in the engine, but don't worry about it right now. Whenever you see self, just know that it is the special entity that quake is currently interest in. Just understand this, we are calculating the effect of the damage and adding momentum to the object. That is a force, pushing you back in the direction of whatever hit you. Don't worry if this is confusing right now, it will begin to make sense and you will see it is really very easy to make Quake do almost anything you want to in the game with QuakeC. That is why QuakeC is so much fun, it is very easy to do so much in it. But there is alot you can't do, but you will learn that later.
Ok the next thing is self.avelocity. This is applied velocity, like self.velocity, but this is a force being applied to the entity. Quake is pretty old, and it's physics are pretty rudimentary. You just have a velocity, the speed you are moving at, and the avelocity, which is a force to act on the entity. That's all you need to know to make stuff move in Quake.
The last bit says, if the self.flags has the flag FL_ONGROUND on it, then let's unset this. This makes it so the entity is not on the ground, so it will go flying away.
Well I hope people can find this useful, and if you have problems feel free to ask me, I have plenty of free time right now unfortunatley, or fortunately for you, if you want to learn I will try to help but I don't know everything and I programmed in quakec for years in the past. But there is always more to learn, new engines people hack with new stuff in it, and so much stuff to do so you will never grow bored.
Now you need to know how to program to do QuakeC. But I'm going to just jump right in and show you to do stuff and get immediate feedback from the game, and you will learn all this code. Trust me it is not hard at all, it just takes some desire to want to learn it.
Ok so I thought what would be a good little snippet to get started with? Well did you ever notice in Quake, when you get hit by a grenade, or you shoot a monster with a rocket, it doesn't go flying? Doesn't it seem strange that explosions don't send monsters flying through the world? Well you are in luck because it is pretty easy to do this.
Now first you have to get the quakec code and the compiler. I am pretty sure you can find this stuff on this site. But if you can't, go to ftp://ftp.idsoftware.com. Go into the source directory. Somewhere in there should be something like qccsource. If you have trouble finding it then I will upload the code somewhere for you. Now you need the quakec compiler. Well you are in luck there, because one is available on this site. It's called qccx and it's in the downloads. This is much better than the original compiler anyways, as it will catch more errors that you might make. It even caught some errors that were made in the original source code.
Ok so now hopefully you are set up and ready to roll. Now you need one more thing. Some way to edit the files. Well, you can use notepad which comes with windows. I like QCide myself, but notepad will work fine. Now find where you extracted the quakec files and look for a file called combat.qc. That is all the quakec code that is used for combat.
In combat.qc you will scroll down and find a function called T_Damage that looks like this
Code:
void(entity targ, entity inflictor, entity attacker, float damage) T_Damage=
Code:
// figure momentum add if ( (inflictor != world) && (targ.movetype == MOVETYPE_WALK) ) { dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5; dir = normalize(dir); targ.velocity = targ.velocity + dir*damage*8; }
Code:
self = targ; if ( (inflictor != world) && (targ.movetype == MOVETYPE_WALK) ) { dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5; dir = normalize(dir); self.velocity = self.velocity + dir*damage*20; self.avelocity = dir*damage*50; // lift the monster off the ground so it flies if (self.flags & FL_ONGROUND) self.flags = self.flags - FL_ONGROUND; }
So now what does it do? Well you see T_Damage is called whenever something is hurt. When you get hit by a lightning bolt, T_Damage is called to inflict damage on you. You see the self.velocity? Well that is just some variable that tells quake how fast you are moving. Self is an entity which has information about the monsters and things in game. Self is a special entity in the engine, but don't worry about it right now. Whenever you see self, just know that it is the special entity that quake is currently interest in. Just understand this, we are calculating the effect of the damage and adding momentum to the object. That is a force, pushing you back in the direction of whatever hit you. Don't worry if this is confusing right now, it will begin to make sense and you will see it is really very easy to make Quake do almost anything you want to in the game with QuakeC. That is why QuakeC is so much fun, it is very easy to do so much in it. But there is alot you can't do, but you will learn that later.
Ok the next thing is self.avelocity. This is applied velocity, like self.velocity, but this is a force being applied to the entity. Quake is pretty old, and it's physics are pretty rudimentary. You just have a velocity, the speed you are moving at, and the avelocity, which is a force to act on the entity. That's all you need to know to make stuff move in Quake.
The last bit says, if the self.flags has the flag FL_ONGROUND on it, then let's unset this. This makes it so the entity is not on the ground, so it will go flying away.
Well I hope people can find this useful, and if you have problems feel free to ask me, I have plenty of free time right now unfortunatley, or fortunately for you, if you want to learn I will try to help but I don't know everything and I programmed in quakec for years in the past. But there is always more to learn, new engines people hack with new stuff in it, and so much stuff to do so you will never grow bored.
Comment