DieHard Wolfers Forum Index
 
Hosted by: MCS & Areyep.com - Designed by: CC & BT Original Yahoo Forum - Die Hard Archives

Areyep Homepage ProfileProfile FAQFAQ SearchSearch Log out [ Xarkon ]Log out [ Xarkon ]
DieHard Wolfenstein Bunker MemberlistMemberlist UsergroupsUsergroups ProfileTop 10 Charts PM - No new messagesPM - No new messages
MemberlistDieHard Chat Room ProfileStatistics Ranks Watched TopicsWatched Topics

[Code] Gun Bobbing or Aminated Weapons - Dugtrio17
:|: Options :|:
Forum Index » Code Tutorials » [Code] Gun Bobbing or Aminated Weapons - Dugtrio17 » Page 1 of 1
View posts since last visit :|: Watch this topic for replies :|: View previous topic :|: View next topic
Display posts from previous:   
Jump to:  
Post new topic  Reply to topic  printer-friendly view   All times are GMT + 9.5 Hours  
  
 Author  Message
Dugtrio17
Code Master
Code Master

Joined: 12 Mar 2003
Last visit: Online Now
Posts: 137
Location: USA
 Post Posted: Thu Apr 24, 2003 5:31 am [1]    Page Top  Next Post Page Bottom   Reply with quote
     Post subject: [Code] Gun Bobbing or Aminated Weapons - Dugtrio17

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
_________________
It liiiivveess!! http://www.dugtrio17.com/


Last edited by Dugtrio17 on Tue May 27, 2003 8:02 am; edited 2 times in total
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Dugtrio17
Code Master
Code Master

Joined: 12 Mar 2003
Last visit: Online Now
Posts: 137
Location: USA
 Post Posted: Fri Apr 25, 2003 5:57 am [2]    Page Top Prev Post  Page Bottom   Reply with quote
     Post subject:

Quoting: Zach Attack
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
_________________
It liiiivveess!! http://www.dugtrio17.com/
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Post new topic   Reply to topic   printer-friendly view     
All times are GMT + 9.5 Hours  
Display posts from previous:   
Jump to:  
View posts since last visit :|: Watch this topic for replies :|: View previous topic :|: View next topic
Forum Index » Code Tutorials » [Code] Gun Bobbing or Aminated Weapons - Dugtrio17 » Page 1 of 1
You cannot post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You cannot delete your posts in this forum
You can vote in polls in this forum

Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group

DieHard Wolfenstein Bunker Template © 2004 ® CC & BrotherTank - Best Viewed 800 x 600 Resolution