How to make an aim command?

Discuss programming in the QuakeC language.
ThePlasticBling
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

How to make an aim command?

Post by ThePlasticBling »

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!
GiffE
Posts: 170
Joined: Sun Oct 08, 2006 3:39 pm
Location: USA, CT
Contact:

Post by GiffE »

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.
ThePlasticBling
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Post by ThePlasticBling »

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 :?
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

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)
ThePlasticBling
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Post by ThePlasticBling »

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
Arkage
Posts: 66
Joined: Thu Nov 19, 2009 4:17 pm

Post by Arkage »

Ctrl + f , then search for the function names.
ThePlasticBling
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Post by ThePlasticBling »

Arkage wrote:Ctrl + f , then search for the function names.
idk i just wont add iron sights
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

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)
ThePlasticBling
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Post by ThePlasticBling »

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

Post by frag.machine »

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)
ThePlasticBling
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Post by ThePlasticBling »

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
GiffE
Posts: 170
Joined: Sun Oct 08, 2006 3:39 pm
Location: USA, CT
Contact:

Post by GiffE »

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.
ThePlasticBling
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Post by ThePlasticBling »

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

Post by ThePlasticBling »

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?
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Post by ceriux »

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.
Post Reply