Forum

Weapon Reload

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Weapon Reload

Postby Ghost_Fang » Thu Nov 12, 2009 4:41 am

I've for been looking for a while, and im sorry if i missed it.
I am not a QC coder, but our dev team doesnt have a coder at the moment so all i am doing is following tutorials and copying and pasting provided codes until we get a coder for our mod.
I can't find reload anywhere.
Could someone point me in the direction of a tutorial that would show me how to add reload to vanilla quake. And/or to add the reload frames to the weapon models.

Thank you.
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Postby r00k » Thu Nov 12, 2009 5:15 am

What MOD are you supporting?

I'm asking for engine support as well. This narrows down the QC side of help. If its a PSP mod then it would need basic QuakeC features. And your query is easily do able in basic quakec.

Check out player.qc for animations. Normal FPS is 10fps for Quake.
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby Ghost_Fang » Thu Nov 12, 2009 5:20 am

well, its for jailbroken iphones. I dont know if you have heard quake4iphone? Well it was the original shareware quake ported to iphone. And thats the source I'm using, original quake.
I don't know anything about QC syntax or anything like that. I would need the actual code and be told where to put it and thats all im asking. And if possible how to add the reloading animations as well. If its all in one code thats even better.
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Postby lth » Fri Nov 13, 2009 2:04 pm

Adding the QC for reloading to the original QC code is a relatively simply task. Here's how I'd add reloading to the shotgun, off the top of my head:

Open up defs.qc and add a line at the bottom:
Code: Select all
.float ammo_shotgun;


In weapons.qc:
- In W_SetCurrentAmmo for the shotgun, change
Code: Select all
self.currentammo = self.ammo_shells

to:
Code: Select all
self.currentammo = self.ammo_shotgun;


- Add a new impulse to ImpulseCommands:
Code: Select all
if (self.impulse==23) // or whatever number
  {
  if (self.weapon == IT_SHOTGUN)
    {
    if (self.ammo_shells < 8)
      {
      self.currentammo = self.ammo_shotgun = self.ammo_shells;
      self.ammo_shells = 0;
      }
    else
      {
      self.currentammo = self.ammo_shotgun = 8;
      self.ammo_shells = self.ammo_shells - 8;
      }
    }
  }


You'd need to muck about in client.qc too to handle level transitions properly, but I can't really remember how to do that offhand.

Building the actual reload animations would be an immense pain in the arse and I doubt anyone is going to volunteer to do them for you. Good luck with that...
User avatar
lth
 
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

Postby Ghost_Fang » Sun Nov 15, 2009 9:50 pm

it sort of worked, it just didnt start loaded, but i could just do a simple autoexec for that.
As for the animation, couldnt i just add the frames to the model,
(reload1 reload2 reload3 etc)
Then add them in the weapons.qc
then set it so that not only impulse 23 reloads, it plays the reload animation. Wouldnt that work?
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Postby lth » Sun Nov 15, 2009 10:03 pm

it sort of worked, it just didnt start loaded, but i could just do a simple autoexec for that.


You probably want to set it up so that when you start a new game, it starts loaded, but if you go to the next level it either maintains its loaded state, or becomes fully loaded, taking any required ammo out of your shells supply. That would mean fiddling with *ChangeParms in client.qc, ideally.

As for the animation, couldnt i just add the frames to the model,
(reload1 reload2 reload3 etc)
Then add them in the weapons.qc
then set it so that not only impulse 23 reloads, it plays the reload animation. Wouldnt that work?


Indeed, that's exactly what you'd need to do. You probably want to set:
Code: Select all
self.attack_finished = time + 0.5;

in your new reload function too. That's also where you'd start off the animation (and play a sound if you want), and by setting an attack_finished time you prevent the player from shooting or changing weapon while the reload animation is in progress.
User avatar
lth
 
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

Postby Ghost_Fang » Sun Nov 15, 2009 11:30 pm

Im not that experienced coder at all, how would i go about making the reload thingy with animation and sound based on the current code you gave me. level transitions arent an issue atm.
Could you just give me code and tell me where to put it and that be it?
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

O a

Postby UrbanKid » Wed Nov 18, 2009 9:40 am

o a reload code....i could use some help for csportable i want to add more frames for all my custom animated weapons in the game
this could help thanks.
UrbanKid
 
Posts: 55
Joined: Fri Aug 22, 2008 8:34 am

Postby lth » Wed Nov 18, 2009 10:11 am

Ghost_Fang:

If you actually want to mod Quake, you're going to have to learn how to mod Quake! No-one else is going to do it all for you :)

If you're not bothered about level transitions at the moment, then go to PutClientInServer in client.qc and add:

Code: Select all
self.ammo_shotgun = 8;


Somewhere before W_SetCurrentAmmo. PutClientInServer is the function that is called whenever a player starts a level, so anything you want all players to have when they start should go in here. Notice that PutClientInServer also does stuff like set the player's health and max_health, their model, and spawns a teleflash if necessary.

For the reload animations, first you'll need to get qMe or other model editor and actually make the animation frames showing the weapon doing what you want. After you've done that, I can show you how to add the reloading animations to the game.
User avatar
lth
 
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

yes i have a model

Postby UrbanKid » Wed Nov 18, 2009 11:59 am

i converted glock pistol from cs and i wanted to add full firing animations and reload animations


oh yeah i always check the forums every 5minutes or less

http://www.sendspace.com/file/y5mmkm
UrbanKid
 
Posts: 55
Joined: Fri Aug 22, 2008 8:34 am


thanks

Postby UrbanKid » Thu Nov 19, 2009 1:51 am

...edited.....

i have encountered this problem
compiling csportable/cspplayer.qc
in function player_reloadk39 (line 939),
csportable/cspplayer.qc:939: error: Unknown frame macro $stand41
in function player_reloadk40 (line 940),
csportable/cspplayer.qc:940: error: Unknown frame macro $stand42
in function player_reloadk41 (line 941),
csportable/cspplayer.qc:941: error: Unknown frame macro $stand43
in function player_reloadk42 (line 942),
csportable/cspplayer.qc:942: error: Unknown frame macro $stand44
in function player_reloadk43 (line 943),
csportable/cspplayer.qc:943: error: Unknown frame macro $stand45
in function player_reloadk44 (line 944),
csportable/cspplayer.qc:944: error: Unknown frame macro $stand46
in function player_reloadk45 (line 945),
csportable/cspplayer.qc:945: error: Unknown frame macro $stand47
in function player_reloadk46 (line 946),
csportable/cspplayer.qc:946: error: Unknown frame macro $stand48
in function player_reloadk47 (line 947),
csportable/cspplayer.qc:947: error: Unknown frame macro $stand49
in function player_reloadk48 (line 948),
csportable/cspplayer.qc:948: error: Unknown frame macro $stand50
in function player_reloadk49 (line 949),
csportable/cspplayer.qc:949: error: Unknown frame macro $stand51

************ ERROR ************
Errors have occured


UrbanKid
 
Posts: 55
Joined: Fri Aug 22, 2008 8:34 am

Postby redrum » Mon Nov 23, 2009 11:03 pm

I'm no expert, but I'm guessing you didn't precache.
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Dr. Shadowborg » Tue Nov 24, 2009 12:09 am

Actually it looks more like he didn't define his frame macros in the cspplayer.qc file.

Look at player.qc in stock quakec to see how your supposed to define frame macros. Also keep in mind that frame macros define starting from frame 0. Any additional frame macros defined will advance from that. Also, frame macros will ONLY apply within the scope of the file you've defined them in. Try to use them in another file, and it won't work. (You CAN however redefine them inside that file and then it will work.)
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

o

Postby UrbanKid » Tue Nov 24, 2009 7:14 am

ok....thanks!
UrbanKid
 
Posts: 55
Joined: Fri Aug 22, 2008 8:34 am

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest