Forum

Weapon Views from scratch QC

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Weapon Views from scratch QC

Postby ScatterBox » Fri Nov 08, 2013 2:53 am

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.
User avatar
ScatterBox
 
Posts: 50
Joined: Sun Oct 13, 2013 7:53 pm

Re: Weapon Views from scratch QC

Postby ceriux » Fri Nov 08, 2013 5:48 am

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;
   }
};
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Weapon Views from scratch QC

Postby drm_wayne » Fri Nov 08, 2013 11:29 am

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.
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Weapon Views from scratch QC

Postby Max_Salivan » Fri Nov 08, 2013 11:47 am

put this code in your weapons.qc
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

Postby ceriux » Fri Nov 08, 2013 5:38 pm

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...
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Weapon Views from scratch QC

Postby ScatterBox » Fri Nov 08, 2013 10:00 pm

Hmm.. none of the code here seems to work.. (and yes I have checked my progs.src :P ) 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.
User avatar
ScatterBox
 
Posts: 50
Joined: Sun Oct 13, 2013 7:53 pm

Re: Weapon Views from scratch QC

Postby Dr. Shadowborg » Sat Nov 09, 2013 12:14 am

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.)
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Re: Weapon Views from scratch QC

Postby ScatterBox » Sat Nov 09, 2013 1:40 am

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?
User avatar
ScatterBox
 
Posts: 50
Joined: Sun Oct 13, 2013 7:53 pm

Re: Weapon Views from scratch QC

Postby frag.machine » Sat Nov 09, 2013 1:47 am

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)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: Weapon Views from scratch QC

Postby ScatterBox » Sat Nov 09, 2013 5:27 am

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. :?
User avatar
ScatterBox
 
Posts: 50
Joined: Sun Oct 13, 2013 7:53 pm

Re: Weapon Views from scratch QC

Postby Max_Salivan » Sat Nov 09, 2013 12:42 pm

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
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

Postby frag.machine » Sat Nov 09, 2013 7:32 pm

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. :x
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: Weapon Views from scratch QC

Postby ScatterBox » Sat Nov 09, 2013 8:44 pm

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. :x


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.. :)
User avatar
ScatterBox
 
Posts: 50
Joined: Sun Oct 13, 2013 7:53 pm

Re: Weapon Views from scratch QC

Postby ScatterBox » Sat Nov 09, 2013 9:15 pm

Here are the places that bprint printed nothing (meaning code wasn't executed)

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. :?
User avatar
ScatterBox
 
Posts: 50
Joined: Sun Oct 13, 2013 7:53 pm

Re: Weapon Views from scratch QC

Postby Dr. Shadowborg » Sat Nov 09, 2013 11:24 pm

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.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest