Weapon Views from scratch QC
Moderator: InsideQC Admins
25 posts
• Page 1 of 2 • 1, 2
Weapon Views from scratch QC
OK, so I have re-coded almost my whole mod onto Enders scratch QC tutorial. The only problem I have now is that I can't see any weapons. I know this obviously is because I haven't told it to spawn any weapons. But I'm not sure where to... I know that before QC was told to load the start weapons in client.qc, I tried to implement that code into my client.qc but it didn't work. No luck with impulse 9 in the console either... :/ 
You guys should also know that I do have weapons.qc in the directory. It just doesn't have any of the original Quake guns anymore plus I got rid of some un-needed functions.
You guys should also know that I do have weapons.qc in the directory. It just doesn't have any of the original Quake guns anymore plus I got rid of some un-needed functions.
-

ScatterBox - Posts: 50
- Joined: Sun Oct 13, 2013 7:53 pm
Re: Weapon Views from scratch QC
are you setting self.weaponmodel anywhere?
- Code: Select all
void() W_SetCurrentAmmo =
{
player_run (); // get out of any weapon firing states
self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
if (self.weapon == IT_AXE)
{
self.currentammo = 0;
self.weaponmodel = "progs/v_axe.mdl";
self.weaponframe = 0;
}
else if (self.weapon == IT_SHOTGUN)
{
self.currentammo = self.ammo_shells;
self.weaponmodel = "progs/v_shot.mdl";
self.weaponframe = 0;
self.items = self.items | IT_SHELLS;
}
else if (self.weapon == IT_SUPER_SHOTGUN)
{
self.currentammo = self.ammo_shells;
self.weaponmodel = "progs/v_shot2.mdl";
self.weaponframe = 0;
self.items = self.items | IT_SHELLS;
}
else if (self.weapon == IT_NAILGUN)
{
self.currentammo = self.ammo_nails;
self.weaponmodel = "progs/v_nail.mdl";
self.weaponframe = 0;
self.items = self.items | IT_NAILS;
}
else if (self.weapon == IT_SUPER_NAILGUN)
{
self.currentammo = self.ammo_nails;
self.weaponmodel = "progs/v_nail2.mdl";
self.weaponframe = 0;
self.items = self.items | IT_NAILS;
}
else if (self.weapon == IT_GRENADE_LAUNCHER)
{
self.currentammo = self.ammo_rockets;
self.weaponmodel = "progs/v_rock.mdl";
self.weaponframe = 0;
self.items = self.items | IT_ROCKETS;
}
else if (self.weapon == IT_ROCKET_LAUNCHER)
{
self.currentammo = self.ammo_rockets;
self.weaponmodel = "progs/v_rock2.mdl";
self.weaponframe = 0;
self.items = self.items | IT_ROCKETS;
}
else if (self.weapon == IT_LIGHTNING)
{
self.currentammo = self.ammo_cells;
self.weaponmodel = "progs/v_light.mdl";
self.weaponframe = 0;
self.items = self.items | IT_CELLS;
}
else
{
self.currentammo = 0;
self.weaponmodel = "";
self.weaponframe = 0;
}
};
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
Re: Weapon Views from scratch QC
at first, when working with Enders Scratch QC, do NOT JUST copy/paste stuff, code it from scratch (thats why its called scratch qc..)
second, you should maybe post your qc files, we cant look into your harddisk.
second, you should maybe post your qc files, we cant look into your harddisk.
-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: Weapon Views from scratch QC
put this code in your weapons.qc
put UpdateWeapon(); in PutClientInServer(in client.qc)
put this code in weapons.qc
and you need W_WeaponFrame(); in PlayerPostThink(in client.qc)
I think,thats all
- Code: Select all
void() UpdateWeapon = //like as W_SetCurrentAmmo in original Quake
{
if(self.weapon == MY_WEAPON)
{
self.weaponmodel = "progs/mymodel.mdl";
self.currentammo = self.ammo_blah;
}
}
put UpdateWeapon(); in PutClientInServer(in client.qc)
put this code in weapons.qc
- Code: Select all
void() W_WeaponFrame =
{
if (time < self.attack_finished)
return;
// check for attack
if (self.button0)
W_Attack (); //your attack code
};
and you need W_WeaponFrame(); in PlayerPostThink(in client.qc)
I think,thats all
Sorry for my english 
- Max_Salivan
- Posts: 93
- Joined: Thu Dec 15, 2011 1:00 pm
Re: Weapon Views from scratch QC
lol i hope you didnt think i was telling him to copy paste... i was showing him how to look for what hes missing... if thats what anyone was thinking anyways...
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
Re: Weapon Views from scratch QC
Hmm.. none of the code here seems to work.. (and yes I have checked my progs.src
) Impulse 9 didn't seem to work either, and I start with 0 ammo which is strange. :/ 
And I'm not just copying and pasting the code.
I'm using it as a reference and reading it, and learning from it.
And I'm not just copying and pasting the code.
-

ScatterBox - Posts: 50
- Joined: Sun Oct 13, 2013 7:53 pm
Re: Weapon Views from scratch QC
Assuming you're setting self.weaponmodel properly, and also assuming you don't have code somewhere that instantly sets it to null, I would be looking at whether or not your weapon models are positioned correctly. (i.e. internal to the model file) (try using your weapon models in stock quake, i.e. replacing v_shot.mdl with your own model, etc.)
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
Re: Weapon Views from scratch QC
Dr. Shadowborg wrote:Assuming you're setting self.weaponmodel properly, and also assuming you don't have code somewhere that instantly sets it to null, I would be looking at whether or not your weapon models are positioned correctly. (i.e. internal to the model file) (try using your weapon models in stock quake, i.e. replacing v_shot.mdl with your own model, etc.)
Well, I am almost certain that I have set self.weaponmodel correctly, also I am completely sure the positioning is correct since I was using this weapon in game before I coded the QuakeC from scratch.. But.. the this- "and also assuming you don't have code somewhere that instantly sets it to null" got me thinking... is there places in QuakeC that would do this? I've never heard of it! I'm thinking that this is most likely the problem. How would I know if this is the case?
-

ScatterBox - Posts: 50
- Joined: Sun Oct 13, 2013 7:53 pm
Re: Weapon Views from scratch QC
- Code: Select all
if (self.weaponmodel == string_null)
{
bprint ("YAY NO WEAPON MODEL!!!!!!11ONE");
}
Somewhere in your code should do the trick
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Re: Weapon Views from scratch QC
frag.machine wrote:
- Code: Select all
if (self.weaponmodel == string_null)
{
bprint ("YAY NO WEAPON MODEL!!!!!!11ONE");
}
Somewhere in your code should do the trick
Well, I placed this in my code and ran the came and no message popped up.. (YAY NO WEAPON MODEL...). So I was thinking that since impulse 9 isn't working either it's quite strange.. In fact, none of the code in weapons.qc seems to be running. Hmmm. Yes, it is in the progs.src (and it is above any .qc file it's called in) and the compiler does give me some warning on a few things in weapons.qc pertaining to unused function, so I know that the code is operable... Hmm. I'm stuck.
-

ScatterBox - Posts: 50
- Joined: Sun Oct 13, 2013 7:53 pm
Re: Weapon Views from scratch QC
you should check your impulse commands
in W_WeaponFrame
if (self.impulse) ImpulseCommands ();
and put W_WeaponFrame (); in PlayerPostThink
void() PlayerPostThink =
{
W_WeaponFrame ();
};
remember that
in W_WeaponFrame
if (self.impulse) ImpulseCommands ();
and put W_WeaponFrame (); in PlayerPostThink
void() PlayerPostThink =
{
W_WeaponFrame ();
};
remember that
worldspawn - Called when the world.. umm.. spawns!
main - Have no idea when this is called...
StartFrame - Called at the start of each frame
ClientConnect - Called when a client connected to the server
ClientDisconnect - Called when a client disconnects from the server
ClientKill - Called when a client issues the 'kill' command
PutClientInServer - Called to spawn the clients player entity
PlayerPreThink - Called every frame, before physics(pressing the handle and sets the player parameters - acceleration, crouching, jumping, movement in the water,etc)
PlayerPostThink - Called every frame, AFTER physics(causes the command handling of weapons,i think)
SetNewParms - Called on level change
SetChangeParms - Called on level change
Sorry for my english 
- Max_Salivan
- Posts: 93
- Joined: Thu Dec 15, 2011 1:00 pm
Re: Weapon Views from scratch QC
ScatterBox wrote:frag.machine wrote:
- Code: Select all
if (self.weaponmodel == string_null)
{
bprint ("YAY NO WEAPON MODEL!!!!!!11ONE");
}
Somewhere in your code should do the trick
Well, I placed this in my code and ran the came and no message popped up.. (YAY NO WEAPON MODEL...). So I was thinking that since impulse 9 isn't working either it's quite strange.. In fact, none of the code in weapons.qc seems to be running. Hmmm. Yes, it is in the progs.src (and it is above any .qc file it's called in) and the compiler does give me some warning on a few things in weapons.qc pertaining to unused function, so I know that the code is operable... Hmm. I'm stuck.
Well, "the compiler does give me some warning on a few things in weapons.qc pertaining to unused function" is a important information, since it means some code in weapons.qc is not being called at all.
And code not called is code not executed, hence you don't have any visible weapon.
Try to place some
- Code: Select all
bprint ("passed here");
in places where the code must be executed to set the weapon correctly, and try to pinpoint what's not being called.
I know, debugging QuakeC code this way is a PITA.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Re: Weapon Views from scratch QC
frag.machine wrote:ScatterBox wrote:frag.machine wrote:
- Code: Select all
if (self.weaponmodel == string_null)
{
bprint ("YAY NO WEAPON MODEL!!!!!!11ONE");
}
Somewhere in your code should do the trick
Well, I placed this in my code and ran the came and no message popped up.. (YAY NO WEAPON MODEL...). So I was thinking that since impulse 9 isn't working either it's quite strange.. In fact, none of the code in weapons.qc seems to be running. Hmmm. Yes, it is in the progs.src (and it is above any .qc file it's called in) and the compiler does give me some warning on a few things in weapons.qc pertaining to unused function, so I know that the code is operable... Hmm. I'm stuck.
Well, "the compiler does give me some warning on a few things in weapons.qc pertaining to unused function" is a important information, since it means some code in weapons.qc is not being called at all.
And code not called is code not executed, hence you don't have any visible weapon.
Try to place some
- Code: Select all
bprint ("passed here");
in places where the code must be executed to set the weapon correctly, and try to pinpoint what's not being called.
I know, debugging QuakeC code this way is a PITA.
Darn.. it's come down to this.. Oh well, I figured I'd have to debug my QuakeC like this at some point.. I guess this is that point. :/ Hopefully I get some good results on where the code isn't being executed though.
EDIT: I tested it and I get a bunch of "passed here" flashing on the top of my screen over and over again meaning that the code it indeed running as it should... hmm.
SECOND EDIT: I'm going to run the bprint separately for each function and test them all separately. This will take longer, but will help me find the problem after an hour or so hopefully..
-

ScatterBox - Posts: 50
- Joined: Sun Oct 13, 2013 7:53 pm
Re: Weapon Views from scratch QC
Here are the places that bprint printed nothing (meaning code wasn't executed)
These were the places that seemed to be putting the most effort into actually drawing the weapon on the screen. Seeing how they aren't executed.. well... you get the point. for the "UpdateWeapon" (like W_SetCurrentAmmo) I called it in "client.qc (PutClientInServer and PlayerPostThink)", in weapon_touch function, and in W_CheckNoAmmo, W_ChangeWeapon, and CheatCommand. So it should be running somewhere there.. right? this seems to be most likely my problem.
- Code: Select all
void() UpdateWeapon = //like as W_SetCurrentAmmo in original Quake
{
self.items = self.items - (self.items & (IT_BULLETS) );
if(self.weapon == IT_BLUN)
{
self.weaponmodel = "progs/v_blunderbuss.mdl";
self.currentammo = self.ammo_shells;
self.weaponframe = 0;
self.items = self.items | IT_BULLETS;
bprint ("passed here");
}
}
- Code: Select all
/*
Weapon Spawning..
*/
void() weapon_blunderbuss =
{
precache_model ("progs/v_blunderbuss.mdl");
setmodel (self, "progs/v_blunderbuss.mdl");
self.weapon = IT_BLUN;
self.netname = "Blunderbuss";
self.touch = weapon_touch;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
These were the places that seemed to be putting the most effort into actually drawing the weapon on the screen. Seeing how they aren't executed.. well... you get the point. for the "UpdateWeapon" (like W_SetCurrentAmmo) I called it in "client.qc (PutClientInServer and PlayerPostThink)", in weapon_touch function, and in W_CheckNoAmmo, W_ChangeWeapon, and CheatCommand. So it should be running somewhere there.. right? this seems to be most likely my problem.
-

ScatterBox - Posts: 50
- Joined: Sun Oct 13, 2013 7:53 pm
Re: Weapon Views from scratch QC
The first one will only work if you're setting self.weapon = IT_BLUN; (this should be handled by your weapon selection code, and thus trigger a bprint when you press whatever key you've assigned your blunderbuss selection to.)
The second one is a map entity and won't generally print anything, even on map load.
The second one is a map entity and won't generally print anything, even on map load.
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
25 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest