Forum

How to make an aim command?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

How to make an aim command?

Postby ThePlasticBling » Tue Jun 08, 2010 9:00 pm

hello can somebody please make a quick aim command for me. all i want it to do is switch to a different model (iron sights) when an impulse is typed and then make it so there will be a different aim model for each weapon. thanx!
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby GiffE » Tue Jun 08, 2010 11:54 pm

Switch model? :shock: Why do that?... Just have an ironsight animation for the model, then have the impulse toggle the animation. Or if your in DP you could just re-origin the model on your screen.
GiffE
 
Posts: 170
Joined: Sun Oct 08, 2006 3:39 pm
Location: USA, CT

Postby ThePlasticBling » Wed Jun 09, 2010 11:01 pm

GiffE wrote:Switch model? :shock: Why do that?... Just have an ironsight animation for the model, then have the impulse toggle the animation. Or if your in DP you could just re-origin the model on your screen.


well the thing is that im a n00b and i dont know how to do that :?
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby frag.machine » Thu Jun 10, 2010 1:02 pm

Well, unfortunately there's no "quick and easy" (at least not in the sense of something you can accomplish in 15 minutes) way to do so in Quake. The best way would be as GiffE said: add at least one frame to the desired weapon with the iron sight mode, and you can try something like that in weapons.qc:

*** WARNING: untested, I may have forgot something important! ***

Code: Select all

.float iron_sight;
float IMPULSE_IRON_SIGHT = 123; // just an example

void() ImpulseCommands =
{
   if (self.impulse == IMPULSE_IRON_SIGHT)
   {
      self.iron_sight = 1 - (self.iron_sight & 1); // this will toggle the iron sight
   }
   (...)


And, for the specific weapon (let's say, the shotgun), you do like that:

Code: Select all
float V_SHOT_IRON_SIGHT_FRAME = 321; // again, for example

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

                if (self.iron_sight == 1)
                {
          self.weaponframe = V_SHOT_IRON_SIGHT_FRAME;
                }
                else
                {
          self.weaponframe = 0;
                }

      self.items = self.items | IT_SHELLS;
   }
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

Postby ThePlasticBling » Thu Jun 10, 2010 7:09 pm

frag.machine wrote:Well, unfortunately there's no "quick and easy" (at least not in the sense of something you can accomplish in 15 minutes) way to do so in Quake. The best way would be as GiffE said: add at least one frame to the desired weapon with the iron sight mode, and you can try something like that in weapons.qc:

*** WARNING: untested, I may have forgot something important! ***

Code: Select all

.float iron_sight;
float IMPULSE_IRON_SIGHT = 123; // just an example

void() ImpulseCommands =
{
   if (self.impulse == IMPULSE_IRON_SIGHT)
   {
      self.iron_sight = 1 - (self.iron_sight & 1); // this will toggle the iron sight
   }
   (...)


And, for the specific weapon (let's say, the shotgun), you do like that:

Code: Select all
float V_SHOT_IRON_SIGHT_FRAME = 321; // again, for example

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

                if (self.iron_sight == 1)
                {
          self.weaponframe = V_SHOT_IRON_SIGHT_FRAME;
                }
                else
                {
          self.weaponframe = 0;
                }

      self.items = self.items | IT_SHELLS;
   }


well i don't know where to put any of that stuff in weapons.qc :?

i guess you can call me a major n00b
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby Arkage » Thu Jun 10, 2010 7:34 pm

Ctrl + f , then search for the function names.
User avatar
Arkage
 
Posts: 66
Joined: Thu Nov 19, 2009 4:17 pm

Postby ThePlasticBling » Thu Jun 10, 2010 8:02 pm

Arkage wrote:Ctrl + f , then search for the function names.


idk i just wont add iron sights
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby frag.machine » Thu Jun 10, 2010 8:38 pm

ThePlasticBling wrote:well i don't know where to put any of that stuff in weapons.qc :?

i guess you can call me a major n00b


I guess you need first learn the basics before anything.

My suggestion is:

0) Don't give up.

1) Grab the original QuakeC code and learn how to edit and compile it. Pro tip: you don't need Visual Studio 2008 to do that :D : Notepad++, UltraEdit or even the Windows notepad plus frikqcc is enough;

2) After that, learn how to run your just compiled progs.dat;

3) Learn a bit about QuakeC. Google for it and you'll find lots of places where you can find commented code examples for new weapons, monsters and game modes. I personally advice to check the AI Cafe tutorials, they are an excellent source;

4) After that, try changing small things to get used to the language: a really easy start point are the kill messages in the ClientObituary() function. After that, try something a bit more hard, like adding a MOTD. Don't hesitate in looking other mod's source to learn, but avoid the blind copy & paste. Do an honest effort to understand what's going on;

5) Don't be afraid of asking about things you may consider "stupid" or "lame" - there's no stupid or lame question when someone truly wants to learn. Besides, we all had to ask about those things (or even worse) to someone one day.

6) Again, Don't give up.
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

Postby ThePlasticBling » Thu Jun 10, 2010 10:34 pm

frag.machine wrote:
ThePlasticBling wrote:well i don't know where to put any of that stuff in weapons.qc :?

i guess you can call me a major n00b


I guess you need first learn the basics before anything.

My suggestion is:

0) Don't give up.

1) Grab the original QuakeC code and learn how to edit and compile it. Pro tip: you don't need Visual Studio 2008 to do that :D : Notepad++, UltraEdit or even the Windows notepad plus frikqcc is enough;

2) After that, learn how to run your just compiled progs.dat;

3) Learn a bit about QuakeC. Google for it and you'll find lots of places where you can find commented code examples for new weapons, monsters and game modes. I personally advice to check the AI Cafe tutorials, they are an excellent source;

4) After that, try changing small things to get used to the language: a really easy start point are the kill messages in the ClientObituary() function. After that, try something a bit more hard, like adding a MOTD. Don't hesitate in looking other mod's source to learn, but avoid the blind copy & paste. Do an honest effort to understand what's going on;

5) Don't be afraid of asking about things you may consider "stupid" or "lame" - there's no stupid or lame question when someone truly wants to learn. Besides, we all had to ask about those things (or even worse) to someone one day.

6) Again, Don't give up.


lol thanx for the inspiration :D

i know how to do most of that. im not good at the coding. all i want to do is make an impulse so if the impulse is typed, than the model will change (but the weapon stats will stay the same.) the reason i dont want to do an extra frame is because i have reloading in my game, and i am afraid it will mess reloading up (as in showing an iron sight animation in the middle of reloading)
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby frag.machine » Fri Jun 11, 2010 12:10 am

ThePlasticBling wrote:lol thanx for the inspiration :D

LOL yeah I went a bit too didactic, but is hard to know what someone already knows from 1 or 2 posts.
ThePlasticBling wrote:i know how to do most of that. im not good at the coding. all i want to do is make an impulse so if the impulse is typed, than the model will change (but the weapon stats will stay the same.) the reason i dont want to do an extra frame is because i have reloading in my game, and i am afraid it will mess reloading up (as in showing an iron sight animation in the middle of reloading)


Well, do a backup, apply the changes and make some experiments. It's very likely it will indeed mess the reload, but that's something quite easy to fix: just force the .iron_sight field to 0 during the reload animation.
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

Postby ThePlasticBling » Fri Jun 11, 2010 12:52 am

frag.machine wrote:
ThePlasticBling wrote:lol thanx for the inspiration :D

LOL yeah I went a bit too didactic, but is hard to know what someone already knows from 1 or 2 posts.
ThePlasticBling wrote:i know how to do most of that. im not good at the coding. all i want to do is make an impulse so if the impulse is typed, than the model will change (but the weapon stats will stay the same.) the reason i dont want to do an extra frame is because i have reloading in my game, and i am afraid it will mess reloading up (as in showing an iron sight animation in the middle of reloading)


Well, do a backup, apply the changes and make some experiments. It's very likely it will indeed mess the reload, but that's something quite easy to fix: just force the .iron_sight field to 0 during the reload animation.


lol :lol:

i don't know how to do that either.

hahahah lol sorry im losing my mind
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby GiffE » Fri Jun 11, 2010 2:46 am

ThePlasticBling wrote:i know how to do most of that. im not good at the coding. all i want to do is make an impulse so if the impulse is typed, than the model will change (but the weapon stats will stay the same.) the reason i dont want to do an extra frame is because i have reloading in my game, and i am afraid it will mess reloading up (as in showing an iron sight animation in the middle of reloading)
ThePlasticBling wrote:lol :lol:
i don't know how to do that either.
hahahah lol sorry im losing my mind


Then you need to do some learning. Do something simpler to learn, as you clearly have zero understanding and are looking for copy paste solutions.

I hate to break it to you but you can't make a game with copy and paste.
GiffE
 
Posts: 170
Joined: Sun Oct 08, 2006 3:39 pm
Location: USA, CT

Postby ThePlasticBling » Fri Jun 11, 2010 3:57 pm

GiffE wrote:
ThePlasticBling wrote:i know how to do most of that. im not good at the coding. all i want to do is make an impulse so if the impulse is typed, than the model will change (but the weapon stats will stay the same.) the reason i dont want to do an extra frame is because i have reloading in my game, and i am afraid it will mess reloading up (as in showing an iron sight animation in the middle of reloading)
ThePlasticBling wrote:lol :lol:
i don't know how to do that either.
hahahah lol sorry im losing my mind


Then you need to do some learning. Do something simpler to learn, as you clearly have zero understanding and are looking for copy paste solutions.

I hate to break it to you but you can't make a game with copy and paste.


lol ur right. i have been trying stuff that isn't copy and paste, but it never compiles :(

btw: what part of CT are you from? (im from portland :D )
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby ThePlasticBling » Fri Jun 11, 2010 4:44 pm

ok. so now i got an aiming impulse working :D

but the only problem is that when i shoot while the aiming model is showing, it turns back to the regular model thats not aiming. any ideas?
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby ceriux » Fri Jun 11, 2010 5:15 pm

hey man try doing some menu tutorials iv developed my own form of menu's that was derived from the menu tutorials here. honestly i found that the menu tutorials are a good basic way to learn things like what .floats are and what not. ( and if you dont understand the difference between .float and float is "float" is for everything is global ".float" is for things like the player or his weapon, it really depends on the entitie its applied to. just keep trying . start with simpler mods and just reading through the .qc source till you start to realize what its actually saying. once you get used to .qc its almost like your reading a book and then writing a sentance. =) believe me i was in a similar state your in atm but i was just persistant try getting on irc i found its a little bit easier to learn if you can get someone there to explain things to you in real time. rather than spaced posts. good luck i hope you get better. maybe we can help each other out once i get out of school here in a month or so. =) once again GOOD LUCK and keep trying.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest