Inside3D!
     

Adjusting the turning speed if you have a certain weapon.

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Team Xlink



Joined: 25 Jun 2009
Posts: 320

PostPosted: Fri Dec 18, 2009 7:51 pm    Post subject: Adjusting the turning speed if you have a certain weapon. Reply with quote

Hello.


I was wondering how I would adjust the turningspeed if I had another weapon?

Thank you.
_________________
Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!
Back to top
View user's profile Send private message
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Fri Dec 18, 2009 7:54 pm    Post subject: Reply with quote

well im not sure about the turning speed, but i know it should start with

IF (self.weapon == IT_WEAPONNAME)

{

blah blah blah

};

ill look through the source and see if i can fill in the blah blah blah.

well looking through defs.qc iv found these things not sure if im even in the right direction.


Code:
vector(entity e, float speed) aim = #44;      // returns the shooting vector



Code:
void() ChangeYaw = #49;                  // turn towards self.ideal_yaw
                                 // at self.yaw_speed


Code:
vector(vector v) vectoangles         = #51;

//
// direct client message generation
//

_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Downsider



Joined: 16 Sep 2008
Posts: 478

PostPosted: Sat Dec 19, 2009 1:00 am    Post subject: Reply with quote

Should be done clientside via the engine or CSQC.
Back to top
View user's profile Send private message
Wazat



Joined: 15 Oct 2004
Posts: 732
Location: Middle 'o the desert, USA

PostPosted: Sat Dec 19, 2009 5:35 am    Post subject: Reply with quote

You'll need to modify the player's mouse speed, which may drive players absolutely batty (I know I'd be gnawing off my arm like a trapped coyote). I recommend against it.

There is another option, however. If you made your mod 3rd person using a QC-based chase cam, you could have the player turn gradually toward the direction the player's camera is facing. Thus you would affect the rate at which the player could turn toward enemies while wielding the gun.

When the player looks left or right, that swings the camera in an arc around the player as rapidly as the player wants (controlled by his mouse speed), but his actual body takes time to turn toward that direction. Light weapons like handguns would let him turn fast, while heavy weapons like a chaingun would turn slowly (especially while firing).

The way to do such a QC camera is to turn the real player entity into the camera, and then spawn another entity that acts as the physical player.

I don't think this type of QC-controlled swing-around camera works very well in lag though. If it doesn't behave well, that's another way to drive players batty. Sad So then we are back to doing things engine-side and/or with CSQC, or simply changing the player's mouse speed.

Sorry if that's not helpful. :/
_________________
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
Back to top
View user's profile Send private message MSN Messenger
Downsider



Joined: 16 Sep 2008
Posts: 478

PostPosted: Sat Dec 19, 2009 6:47 am    Post subject: Reply with quote

I'm assuming he means to limit it as if you drag the mouse greater than 5 pixel distance this frame, just clamp it to 5, as opposed to dropping the sensitivity. The former would have to be done engineside or CSQC for sure, otherwise, as you said, it'd be choppy and awkward.
Back to top
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 910

PostPosted: Sat Dec 19, 2009 4:51 pm    Post subject: Reply with quote

Wazat wrote:
You'll need to modify the player's mouse speed, which may drive players absolutely batty (I know I'd be gnawing off my arm like a trapped coyote). I recommend against it.

I'll second this. Unless there is a real in-game reason for it you're just going down a bad bad bad path. Something like turning speed is what I would view as being the property of the player, not of the mod. The person playing your game should be treated with respect rather than having their settings gleefully trampled over.

Anyway, there's an m_yaw cvar that may be another option. But remember - treat the player with respect and put the value back the way it was when you're done with it.
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Wazat



Joined: 15 Oct 2004
Posts: 732
Location: Middle 'o the desert, USA

PostPosted: Sat Dec 19, 2009 10:47 pm    Post subject: Reply with quote

The mouse needs to be responsive as a general rule of computers. However, there's another path you can take.

Instead of restricting the player's turn speed, you can instead have accuracy be affected by the player's average turn rate over the past 0.5 seconds. I think I've seen this done often in games. Walking can also affect accuracy. Thus the player can turn and move around as much as he wants, and he needs to strategically limit movement when he needs to make a more accurate shot.

That might be a nice alternative to limiting the player's turn speed, and it's *much* easier to implement well.
_________________
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
Back to top
View user's profile Send private message MSN Messenger
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Mon Dec 21, 2009 9:36 am    Post subject: Reply with quote

Theoretically there are situations when "limited turn speed" is correct. That is, manned turrets and tank guns and the like. Which I doubt is what Team Xlink has in mind.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
Wazat



Joined: 15 Oct 2004
Posts: 732
Location: Middle 'o the desert, USA

PostPosted: Tue Dec 22, 2009 3:06 am    Post subject: Reply with quote

Sajt wrote:
Theoretically there are situations when "limited turn speed" is correct. That is, manned turrets and tank guns and the like. Which I doubt is what Team Xlink has in mind.


Though many games will pop to 3rd person view for these, so that the player can look around as fast as he wants and the turret/tank gun turns toward his crosshair at its own speed. Smile

Edit: One time I have seen first-person turn speed be controlled by the game, instead of player settings, is in console games where the player doesn't have a mouse. Sometimes that can work.
_________________
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
Back to top
View user's profile Send private message MSN Messenger
Team Xlink



Joined: 25 Jun 2009
Posts: 320

PostPosted: Wed Dec 23, 2009 6:42 pm    Post subject: Reply with quote

Sajt wrote:
Theoretically there are situations when "limited turn speed" is correct. That is, manned turrets and tank guns and the like. Which I doubt is what Team Xlink has in mind.


That is exactly what I wanted to do.

I already have it switching to third person but you still turn on a dime like you do normally.

If I adjusted the settings for the turning speed someone could just make them faster through the console which would ruin it.

So any ideas on how to do this?
_________________
Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!
Back to top
View user's profile Send private message
avirox



Joined: 16 Aug 2006
Posts: 109

PostPosted: Wed Dec 23, 2009 9:42 pm    Post subject: Reply with quote

I'm assuming this is for a psp mod? If so..


if (self.weapon == IT_WEPNAME)
stuffcmd(self, "cl_yawspeed ###\n");

just remember to change the yaw back when you switch.
Back to top
View user's profile Send private message
Team Xlink



Joined: 25 Jun 2009
Posts: 320

PostPosted: Thu Dec 24, 2009 1:33 am    Post subject: Reply with quote

avirox wrote:
I'm assuming this is for a psp mod? If so..


if (self.weapon == IT_WEPNAME)
stuffcmd(self, "cl_yawspeed ###\n");

just remember to change the yaw back when you switch.
I have thought of that but I would like to avoid doing it through certain settings, but I have been doing it this way as a placeholder.
_________________
Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!
Back to top
View user's profile Send private message
Wazat



Joined: 15 Oct 2004
Posts: 732
Location: Middle 'o the desert, USA

PostPosted: Thu Dec 24, 2009 3:11 am    Post subject: Reply with quote

Team Xlink wrote:
Sajt wrote:
Theoretically there are situations when "limited turn speed" is correct. That is, manned turrets and tank guns and the like. Which I doubt is what Team Xlink has in mind.


That is exactly what I wanted to do.

I already have it switching to third person but you still turn on a dime like you do normally.

If I adjusted the settings for the turning speed someone could just make them faster through the console which would ruin it.

So any ideas on how to do this?


I recommend a dummy player attached to the turret (or just show the turret). The reason we do a dummy player is so that the real player can turn at whatever speed he likes. This swivels the camera around so the player can look where he wants, and the turret (and dummy player) follows at its own turn rate. If the player changes his turn speed, that affects the camera but won't let him cheat to speed up the turret. Think of the Goliath tank in UT2003: the player can look around all he wants, and the tank's turret slowly turns toward his aim.


Here's how to do it, IMO:

1) When the player takes control of the turret, make the player invisible. You can do your third person view either through the engine (i.e. the stock quake or glquake 3rd person stuffcmd, forget what it is) or through QC code. The engine solution should be handled client-side, which will be more lag friendly. If you turn the player into the camera for a QC chasecam that centers on the turret, that's fine; if you have the camera behind the player and make the player invisible, that's good too. The end goal of all this is to have a 3rd person camera, and the player cannot see himself (he will see a dummy instead -- see below).

Then hide the player's weapon model. You might even make an IT_TURRET item that the player can change weapons to, which will make it easy for W_SetCurrentAmmo etc to fall into line.
You might want to set the player's movetype to movetype_none, unless you want him to be able to walk away from the turret as his means of disengaging from it.

2) Put a dummy player model where the player would be. It and the turret will turn together. If you don't want to see the player at all (i.e. just see the turret model, with the player presumed to be inside), then the dummy is unnecessary. The turret could even change model to a version with a player mesh included and animating with the turret.
Otherwise, make the dummy player animate his stand frames (or hold turret frames if you make them), and set the turret's .enemy (or some other entity pointer) to it so it can move the dummy around as it turns, and delete it when needed.

3) During the turret's think function (every frame, for example), change the turret's yaw and pitch toward the player's by its turn rate * frametime. Don't use frametime in QW, however: it's a trap!

4) When the player presses the attack button, intercept it in w_attack. If he is using a turret, pass the command along to the turret instead of firing the player's weapon.

5) When the turret attacks, it uses makevectors on its own angle instead of the player's so it fires in the direction in which it points. If you're using the turret's .angles in makevectors, you'll need to invert its pitch:
vector ang;
ang = self.angles;
ang.x = -ang.x;
makevectors(ang).

This is due to an odd bug with a player's v_angle.x and angles.x being reversed from each other.

6) When the player disengages from the turret (by impulse or moving away, whatever you set up), have the turret kill the dummy. Then set the player's model back to normal, reset his movetype if necessary, kill the 3rd person camera, etc.

7) Celebrate. Most important of all. Smile

I hope that's helpful in getting you started. Other people may (read: probably) have better ideas and actual working code to share.
_________________
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group