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] Changing Weapon Strength - Cause>Damage - BrotherT
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
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Wed Aug 06, 2003 8:58 pm
   Subject: [Code] Changing Weapon Strength - Cause>Damage - BrotherT
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

The GunAttack routine looks to see which (if any) enemy is closest to you when you fired the weapon.... It will always attack the closest enemy in your field of view with the damage rate generated at random with no difference for weapon type.

This Mod takes a more realistic approach. It generates the damage to the actor, based on their "distance" (position), and increases the hurtpoints by a defined factor.

Ie: Given x distance and using a machinegun, a damage was generated for "y" guard of lets say 10 hitpoints... My routine then multiplies the 10 by 1.15 and the new damage is now 11 (integer variables drops the decimal point and doesn't round up).

I know it doesn't look like much difference, but the damage is variable based on proximity to gaurd you are attacking. Doing it the way others have suggested defeats the whole purpose of generating the distance to the emeny in the first place and eliminates the randomness of damage based on that distance.

Ie: The closer to the enemy the more accurate your shot, hence more damage.

My mod, keeps this balance. You can change any weapons characteristics very easily, and all other weapons can be added to the routine as well. I'm not saying what you did is wrong, just the solution that I have given is a better balance and realistic.

You can change the strength of any weapon by modifying the "Gun_Attack" routine in the WL_AGENT.C file....

Look for the call to DamageActor (closest, damage) at the end of the routine and modify it something like this:

::: CODE :::


switch (gamestate.weapon)
    {
     case wp_pistol:
          break;
     case wp_machinegun:
          damage = damage * 1.15;
          break;
     case wp_chaingun:
          damage = damage * 1.30;
     }
     
     DamageActor (closest, damage);  // Original code



You can add to it to include all of your firing weapons, and set the damage based on your own personal preferences. Also remember if you are using the same ammo type for all the weapons to adjust the amount used to compensate for this added strength... You want the extra firepower to be used wisely, and make the person think about which weapon they are using and why... Or maybe you don't...

Anyhow.. that is how and where it is done... so enjoy..

Greg
BrotherTank
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:40 pm
   Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - Brot
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

is that all the code ?

im not entirely competant when it comes to code but i couldnt see much differnt when i upper the values

_________________
I Like (Brackets)
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Tue Dec 28, 2004 7:37 am
   Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - Brot
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Sporb2000 wrote:
is that all the code ?

im not entirely competant when it comes to code but i couldnt see much differnt when i upper the values


Yes, that is all the code... You can change the values of 1.15 and 1.30 to whatever you would like. By doing it this way, you still retain the distance factor to the actor, whereas other tutorials don't.

Greg
BrotherTank
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: Fri Dec 31, 2004 7:38 pm
   Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - Brot
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

OK- This is a real pain in the arse so im gonna ask you to smooth sum stuff over for me
Below is the code in my gun attack routine (im assuing that its the correct area to work in)
i implemented ur code as shown and changed the values a bit .Then i got fed up of
friggin round with vlaues that didnt seem to do any thing so i thought i would do somthin so
rash if it worked it would shurely kill everyone (see WP_chaingun) but that didnt go either
so now im sittin on a flash gun that looks the part but still acts like a flick with a wet towel

::: CODE :::

void   GunAttack (objtype *ob)
{
   objtype *check,*closest,*oldclosest;
   int      damage;
   int      dx,dy,dist;
   long   viewdist;

   switch (gamestate.weapon)
   {
   case wp_pistol:
       damage = damage * 1.00;
      SD_PlaySound (ATKPISTOLSND);
      break;
   case wp_machinegun:
       damage = damage * 1.15;
      SD_PlaySound (ATKMACHINEGUNSND);
      break;
   case wp_chaingun:
      damage = damage * 10.50 + 100;
      SD_PlaySound (ATKGATLINGSND);
      break;
   case wp_mag:
       damage = damage * 1.30;
      SD_PlaySound (ATKMACHINEGUNSND);
      break;
   }
   madenoise = true;

//
// find potential targets
//
   viewdist = 0x7fffffffl;
   closest = NULL;

   while (1)
   {
      oldclosest = closest;

      for (check=ob->next ; check ; check=check->next)
         if ( (check->flags & FL_SHOOTABLE)
         && (check->flags & FL_VISABLE)
         && abs (check->viewx-centerx) < shootdelta
         )
         {
            if (check->transx < viewdist)
            {
               viewdist = check->transx;
               closest = check;
            }
         }

      if (closest == oldclosest)
         return;                  // no more targets, all missed

   //
   // trace a line from player to enemey
   //
      if (CheckLine(closest))
         break;

   }

//
// hit something
//
   dx = abs(closest->tilex - player->tilex);
   dy = abs(closest->tiley - player->tiley);
   dist = dx>dy ? dx:dy;

   if (dist<2)
      damage = US_RndT() / 4;
   else if (dist<4)
      damage = US_RndT() / 6;
   else
   {
      if ( (US_RndT() / 12) < dist)      // missed
         return;
      damage = US_RndT() / 6;
   }

   DamageActor (closest,damage);
}


Did i do sumthin wrong? or am i just over reacting - please help dude before i throw a fit and eat my laptop
Shocked

_________________
I Like (Brackets)
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Fri Dec 31, 2004 8:25 pm
   Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - Brot
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yep... You did something wrong... You didn't follow the tutorial. The tutorial is done the way it is because if you try and merge it up top (like you did) then it doesn't affect the actual damage done, which is calculated below the "switch (gamestate.weapon)" code...

Yes, you could merge the "switch" code, but it must be done just above the "DamageActor (closest,damage);" line.

Hence, to make it work, try moving the your code around to look like this:

::: CODE :::

void GunAttack (objtype *ob)
{
   objtype *check,*closest,*oldclosest;
   int damage;
   int dx,dy,dist;
   long viewdist;

   madenoise = true;

//
// find potential targets
//
   viewdist = 0x7fffffffl;
   closest = NULL;

   while (1)
   {
      oldclosest = closest;

      for (check=ob->next ; check ; check=check->next)
      if ( (check->flags & FL_SHOOTABLE) && (check->flags & FL_VISABLE) && abs (check->viewx-centerx) < shootdelta)
      {
         if (check->transx < viewdist)
         {
            viewdist = check->transx;
            closest = check;
         }
      }

      if (closest == oldclosest) return; // no more targets, all missed
//
// trace a line from player to enemey
//
      if (CheckLine(closest)) break;

   }

//
// hit something
//
   dx = abs(closest->tilex - player->tilex);
   dy = abs(closest->tiley - player->tiley);
   dist = dx>dy ? dx:dy;

   if (dist<2) damage = US_RndT() / 4;
   else if (dist<4) damage = US_RndT() / 6;
   else
   {
      if ( (US_RndT() / 12) < dist) return; // missed
      damage = US_RndT() / 6;
   }
   switch (gamestate.weapon)
   {
      case wp_pistol:
         damage = damage * 1.00;
         SD_PlaySound (ATKPISTOLSND);
         break;
      case wp_machinegun:
         damage = damage * 1.15;
         SD_PlaySound (ATKMACHINEGUNSND);
         break;
      case wp_chaingun:
         damage = damage * 10.50 + 100;
         SD_PlaySound (ATKGATLINGSND);
         break;
      case wp_mag:
         damage = damage * 1.30;
         SD_PlaySound (ATKMACHINEGUNSND);
         break;
   }
   DamageActor (closest,damage);
}


It all makes a difference.

Greg
BrotherTank

_________________

The probability of someone watching you is directly related to the Stupidity of your actions
&
The two most abundant things in the Universe are Hydrogen & Stupidity - H.Ellison

Which of those is more relevant to you??
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: Fri Dec 31, 2004 11:27 pm
   Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - Brot
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Nuts - i knew it would be somthing like that - erm thanks big T Shrug

PS - if you ever run out of code to fix that other people have buggered just drop me a line and i will break some for you ,im good at that Cheesy Grin

_________________
I Like (Brackets)
Raziel
DieHard SS
DieHard SS


Joined: 03 Dec 2005
Last Visit: 03 Dec 2009

Topics: 49
Posts: 485
Location: Israhell
israel.gif

PostPosted: Wed Aug 22, 2007 4:00 pm
   Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - BrotherT
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'm sorry that I need to resurect this 2 year old thread.. But I got some problems with that code Sad
Everytime when I put it in, I get no errors. But when I fire the weapons inside the game. I cant hear them... Neutral
Any ideas why does that happens? on maybe someone can help me with it?
Thanks in advance.

-Raziel

_________________
Raziel A.
ronwolf1705
Moderator
<B>Moderator</B>


Joined: 31 Jul 2006
Last Visit: 9:44 ago.

Topics: 69
Posts: 3673

blank.gif

PostPosted: Thu Aug 23, 2007 10:58 am
   Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - Brot
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

::: CODE :::

void GunAttack (objtype *ob)
{
   objtype *check,*closest,*oldclosest;
   int damage;
   int dx,dy,dist;
   long viewdist;

                switch (gamestate.weapon)
   {
      case wp_pistol:
         SD_PlaySound (ATKPISTOLSND);
         break;
      case wp_machinegun:
         SD_PlaySound (ATKMACHINEGUNSND);
         break;
      case wp_chaingun:
         SD_PlaySound (ATKGATLINGSND);
         break;
   }
   
//
// find potential targets
//
   viewdist = 0x7fffffffl;
   closest = NULL;

   while (1)
   {
      oldclosest = closest;

      for (check=ob->next ; check ; check=check->next)
      if ( (check->flags & FL_SHOOTABLE) && (check->flags & FL_VISABLE) && abs (check->viewx-centerx) < shootdelta)
      {
         if (check->transx < viewdist)
         {
            viewdist = check->transx;
            closest = check;
         }
      }

      if (closest == oldclosest) return; // no more targets, all missed
//
// trace a line from player to enemey
//
      if (CheckLine(closest)) break;

   }

//
// hit something
//
   dx = abs(closest->tilex - player->tilex);
   dy = abs(closest->tiley - player->tiley);
   dist = dx>dy ? dx:dy;

   if (dist<2) damage = US_RndT() / 4;
   else if (dist<4) damage = US_RndT() / 6;
   else
   {
      if ( (US_RndT() / 12) < dist) return; // missed
      damage = US_RndT() / 6;
   }
   switch (gamestate.weapon)
   {
      case wp_pistol:
         damage = damage * 1.00;
         SD_PlaySound (ATKPISTOLSND);
         break;
      case wp_machinegun:
         damage = damage * 1.15;
         SD_PlaySound (ATKMACHINEGUNSND);
         break;
      case wp_chaingun:
         damage = damage * 10.50 + 100;
         SD_PlaySound (ATKGATLINGSND);
         break;
   }
   DamageActor (closest,damage);
}


Does this help?
Raziel
DieHard SS
DieHard SS


Joined: 03 Dec 2005
Last Visit: 03 Dec 2009

Topics: 49
Posts: 485
Location: Israhell
israel.gif

PostPosted: Thu Aug 23, 2007 11:46 am
   Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - BrotherT
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

it doesnt matter anymore because I managed fixed it last night Smile

_________________
Raziel A.
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] Display Different Ammo Types on Statusbar-BrotherTank
Author: BrotherTank
1 2381 Fri Feb 11, 2005 9:18 pm
Zombie_Plan View latest post
No new posts [Code] Changing an Enemies Attack Strength - BrotherTank
Author: BrotherTank
0 1969 Tue Jan 27, 2004 10:29 am
BrotherTank View latest post
No new posts [Info] Giving a Guard a Rocket Launcher
Author: Guest
4 193 Fri Jan 23, 2004 1:58 pm
Guest View latest post
No new posts [Code] Changing Weapons -CheckWeaponChange- BrotherTank
Author: BrotherTank
2 2700 Sun Oct 26, 2003 1:21 am
Guest View latest post
No new posts [Help] Different Enemy Dying Frames/Views
Author: Guest
7 607 Tue Jul 29, 2003 3:00 pm
Codetech84 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