| Author |
Message |
BrotherTank
Forum Administrator

Joined: 01 Mar 2003
Last Visit: 07 Feb 2010
Topics: 142
Posts: 2071
Location: Ontario

|
Posted: Thu Aug 07, 2003 3:58 am
Subject: [Code] Changing Weapon Strength - Cause>Damage - BrotherT
[ IP : Logged ]
|

 
|
|
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


Joined: 28 Dec 2004
Last Visit: 26 May 2009
Topics: 19
Posts: 383
Location: New Zealand - Invercargill

|
Posted: Tue Dec 28, 2004 7:40 am
Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - Brot
[ IP : Logged ]
|

  
|
|
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

Joined: 01 Mar 2003
Last Visit: 07 Feb 2010
Topics: 142
Posts: 2071
Location: Ontario

|
|
 |
Sporb2000
DieHard SS


Joined: 28 Dec 2004
Last Visit: 26 May 2009
Topics: 19
Posts: 383
Location: New Zealand - Invercargill

|
|
 |
BrotherTank
Forum Administrator

Joined: 01 Mar 2003
Last Visit: 07 Feb 2010
Topics: 142
Posts: 2071
Location: Ontario

|
Posted: Sat Jan 01, 2005 4:25 am
Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - Brot
[ IP : Logged ]
|

  
|
|
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


Joined: 28 Dec 2004
Last Visit: 26 May 2009
Topics: 19
Posts: 383
Location: New Zealand - Invercargill

|
Posted: Sat Jan 01, 2005 7:27 am
Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - Brot
[ IP : Logged ]
|

  
|
|
Nuts - i knew it would be somthing like that - erm thanks big T
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  |
_________________ I Like (Brackets)
|
|
 |
Raziel
DieHard SS

Joined: 03 Dec 2005
Last Visit: 03 Dec 2009
Topics: 49
Posts: 485
Location: Israhell

|
Posted: Wed Aug 22, 2007 11:00 pm
Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - BrotherT
[ IP : Logged ]
|

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


Joined: 31 Jul 2006
Last Visit: 0:17 ago.
Topics: 21
Posts: 1537
Location: Dongen

|
|
 |
Raziel
DieHard SS

Joined: 03 Dec 2005
Last Visit: 03 Dec 2009
Topics: 49
Posts: 485
Location: Israhell

|
Posted: Thu Aug 23, 2007 6:46 pm
Subject: Re: [Code] Changing Weapon Strength - Cause>Damage - BrotherT
[ IP : Logged ]
|

 
|
|
it doesnt matter anymore because I managed fixed it last night  |
_________________ Raziel A.
|
|
 |
|
|