DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[Code] Gun Bobbing or Aminated Weapons - Dugtrio17
Page 1 of 1
DieHard Wolfers Forum Index -> Code Tutorials View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

Topics: 49
Posts: 903
Location: Seattle
usa.gif

PostPosted: Wed Apr 23, 2003 1:01 pm
   Subject: [Code] Gun Bobbing or Aminated Weapons - Dugtrio17
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

If you did the tutorial before May 26, 2003, look for the bold print with the edit.

Gun bobbing: a dream of many. And now you can do it! I present you an adjustable tutorial on how to implement gun bobbing in your TC. Quite simple really, and if you want any change at all, just adjust a few numbers! Once again, it has been tested from start to finish and works beautifully. If you have any problems, gimme a yell at Dugtrio17@aol.com. And Martin and JLB, lemme know if you want it in Kreml or Battlestein Smile

OK, open Wl_def.h and search for health. Below int keys, type this:

::: CODE :::
int      bobber;
int      bobdir;
int      bobber2;
int      bobdir2;


Bobber is the up and down bobbing, bobber2 is the left to right bobbing, and bobdir and bobdir2 are the direction controllers. Save that and close.

Open up Wl_draw.c and search for DrawPlayerWeapon. Modify this:

::: CODE :::
 if (gamestate.weapon != -1)
 {
   shapenum = weaponscale[gamestate.weapon]+gamestate.weaponframe;
   SimpleScaleShape(viewwidth/2,shapenum,viewheight+1);
 }

 if (demorecord || demoplayback)
   SimpleScaleShape(viewwidth/2,SPR_DEMO,viewheight+1);


To this:

::: CODE :::
 if (gamestate.weapon != -1)
 {
   shapenum = weaponscale[gamestate.weapon]+gamestate.weaponframe;
   SimpleScaleShape(viewwidth/2-10+gamestate.bobber2,shapenum,viewheight+1+gamestate.bobber);
 }

 if (demorecord || demoplayback)
   SimpleScaleShape(viewwidth/2,SPR_DEMO,viewheight+1);}


You see the adding of the bobber and bobber2 values. Since these values will change when you walk (this will be applied next), the gun will bob. Also take a look at how that 10 is subtracted. Make sure that 10 is equal to half of whatever you have as the 20 below, or it'll look a little lopsided.
Now save and close that. Open up Wl_agent.c and search for void Thrust. Below unsigned offset, add this:

::: CODE :::
  if (gamestate.bobdir != 2)
  {gamestate.bobber++;}
  if (gamestate.bobdir == 2)
  {gamestate.bobber--;}
  if (gamestate.bobber == 10)
  {gamestate.bobdir = 2;}
  if (gamestate.bobber == 0)
  {gamestate.bobdir = 1;}
  if (gamestate.bobdir2 != 2)
  {gamestate.bobber2++;}
  if (gamestate.bobdir2 == 2)
  {gamestate.bobber2--;}
  if (gamestate.bobber2 == 20)
  {gamestate.bobdir2 = 2;}
  if (gamestate.bobber2 == 0)
  {gamestate.bobdir2 = 1;}


EDIT! The tutorial now works on all systems! See post below. If you did this before May 26, 2003, take out that DrawPlayerWeapon (); that used to be there. You'll see where it's put next.
Take a close look at that. When you walk at first, the values will go up, but once they reach a certain number, the bobdir/bobdir2 values change, and the gun will bob the other way. Also take a look at that 20 and that 10. Keep that 20 twice the value of that 10, or your bobbing may look sloped.

Last thing: To make sure you see the gun bobbing, look for the UpdateFace function in Wl_agent.c (around 296 in the original code). ABOVE [if (SD_SoundPlaying() == GETGATLINGSND)], put this:

::: CODE :::
  DrawPlayerWeapon();


And there you go! You have a bobbing gun now. Play around with those numbers up there if you want (the 20 and the 10); modify them to suit your needs, though I find those values work great. You could also modify this tutorial to make certain guns/weapons bob more or less (or not at all) with a few if statements.

Enjoy, and I hope to see some people happy about this (especially Zach; when I told him about the extremely light gun bobbing in Pikachu14's BorgPanic demo, he got all excited and started typing in all caps Laughing )

-DAD

_________________


Last edited by Dugtrio17 on Mon May 26, 2003 3:32 pm; edited 2 times in total
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

Topics: 49
Posts: 903
Location: Seattle
usa.gif

PostPosted: Thu Apr 24, 2003 1:27 pm
   Subject: Re: [Code] Gun Bobbing or Aminated Weapons - Dugtrio17
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Zach Attack wrote:
You know what we would be an excellent follow-up to this tutorial? A tutorial on how to make it possible to have an in-game switch to turn this off or on! Smile


That's not that hard. All you have to do is add a new variable as the on/off switch for the bobbing (an int bobberswitch, or something like that. or you could add a boolean to make a true/false switch, but I'd prefer the variable).

Open the file wl_def.h, and search for the 'gamestate' type, and add the following line within the structure:

::: CODE :::
int bobberswitch;


Then modify the start of the thrust function (from the post above) to look like this:

::: CODE :::
if (gamestate.bobberswitch != 1) // see below about that !=
{
  if (gamestate.bobdir != 2)
  {gamestate.bobber++;}
  if (gamestate.bobdir == 2)
  {gamestate.bobber--;}
  if (gamestate.bobber == 10)
  {gamestate.bobdir = 2;}
  if (gamestate.bobber == 0)
  {gamestate.bobdir = 1;}
  if (gamestate.bobdir2 != 2)
  {gamestate.bobber2++;}
  if (gamestate.bobdir2 == 2)
  {gamestate.bobber2--;}
  if (gamestate.bobber2 == 20)
  {gamestate.bobdir2 = 2;}
  if (gamestate.bobber2 == 0)
  {gamestate.bobdir2 = 1;}

  DrawPlayerWeapon ();
}


Of course that != should only be a != if you want the gun bobbing to be on automatically from the start. otherwise, it should be == 1.

Then somewhere appropriate in Wl_agent.c (though I always keep my "press a key to do this" functions with the MLI cheat) [EDIT: Never mind, go ahead and stick it in Wl_play.c], add something like this:

::: CODE :::

//
// Gun Bobbing Toggle
//

  if (Keyboard[sc_B])
  {if (gamestate.bobberswitch == 1)
   {CenterWindow (18,3);
     US_PrintCentered ("Gun bobbing ON");
     VW_UpdateScreen();
     gamestate.bobberswitch = 0;
     return;}
    if (gamestate.bobberswitch != 1)
   {CenterWindow (18,3);
     US_PrintCentered ("Gun bobbing OFF");
     VW_UpdateScreen();
     gamestate.bobberswitch = 1;
     gamestate.bobber = 0;
     gamestate.bobber2 = 10; // see below about that 10
     gamestate.bobdir = 0;
     gamestate.bobdir2 = 0;
     DrawPlayerWeapon ();
     return;}
  }


[EDIT AGAIN: Revised to set bobbing directions to 0 as well. In fact, I made it set the variables to zero wrong, too! Cut me some slack, I did this on the fly Cheesy Grin ]
That 10 should be whatever the 10 is in the edited ( Embarassed ) line below. this way, without gun bobbing on, the gun is drawn as if the gun bobbing never happened.

OK, I think I got that right. Someone let me know if I screwed that up, because I don't have the source with me at this moment.

-DAD

_________________
Sporb2000
DieHard SS
DieHard SS


Joined: 27 Dec 2004
Last Visit: 26 May 2009

Topics: 19
Posts: 383
Location: New Zealand - Invercargill
newzealand.gif

PostPosted: Mon Dec 27, 2004 11:10 pm
   Subject: Re: [Code] Gun Bobbing or Aminated Weapons - Dugtrio17
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yea well ok - how do you make the gun return to it origin when you stop movin IE it swings out and swings back to where it started when you stop

_________________
I Like (Brackets)
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Mon Sep 11, 2006 12:10 pm
   Subject: Re: [Code] Gun Bobbing or Aminated Weapons - Dugtrio17
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hey,
Nice tut - found it and it is really cool.
But, the bobbing speed goes too fast when you use two buttons at one time (ie, strafing and walking thus moving diagonaly).
How can I change this? I think the strafe speed adds itself to the movespeed - maybe that is the solution.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

Topics: 49
Posts: 903
Location: Seattle
usa.gif

PostPosted: Wed Sep 13, 2006 9:20 pm
   Subject: Re: [Code] Gun Bobbing or Aminated Weapons - Dugtrio17
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Whoa, I just happened to see your reply when I was looking at this thread again. It didn't even tell me there were any replies in this forum, so it's a good thing I checked.

Anyway, it goes faster because the player is going faster. The strafing and back/forward motions are seperate, so it is possible to do them both at once. You could get the Thrust () function to detect if it's thrusting from strafing and just not do any bobbing if it is.

_________________
Redeemer
Can I Play Daddy
Can I Play Daddy


Joined: 13 Apr 2008
Last Visit: 01 Sep 2008

Topics: 5
Posts: 48
Location: Under your bed.
usa.gif

PostPosted: Tue May 06, 2008 10:53 am
   Subject: Re: [Code] Gun Bobbing or Aminated Weapons - Dugtrio17
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

This is a great tutorial Dugtrio. Thanks for the help!

_________________
Check out my new Wolf3D mod Silencer and tell me what you think!

You can rate and review the Silencer Demo here.
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Tutorials View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts [Code] Blood Splatz Tutorial - Blood Splatters
Author: Dugtrio17
45 14703 Tue Mar 11, 2008 12:02 am
AlumiuN View latest post
No new posts [Code] Display Different Ammo Types on Statusbar-BrotherTank
Author: BrotherTank
1 2962 Fri Feb 11, 2005 9:18 pm
Zombie_Plan View latest post
No new posts [Code] Adding a Frames per Second Counter - Darkone
Author: BrotherTank
0 2153 Sat Mar 13, 2004 2:07 pm
BrotherTank View latest post
No new posts [Code] Changing an Enemies Attack Strength - BrotherTank
Author: BrotherTank
0 2469 Tue Jan 27, 2004 10:29 am
BrotherTank View latest post
No new posts [Code] Changing Weapons -CheckWeaponChange- BrotherTank
Author: BrotherTank
2 3314 Sun Oct 26, 2003 1:21 am
Guest View latest post
 
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


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group