[solved] set max damage for a weapons

Discussions about Coding and Scripting
User avatar
Letylove49
Masterful
Posts: 506
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

[solved] set max damage for a weapons

Post by Letylove49 »

hi i need help for that:

i would like to set damage for each weapons for exemple : ( Shockrifle = max 1000 ) and Enforcer = max 100)

here an exemple of my weapons :

Code: Select all

/=============================================================================
// Enforcer
//=============================================================================
class MH2Enforcer extends  Enforcer config(Monsterhunt2GoldAKv5);



var config int hitdamage;
var config int AmmoAmount;
Var config int MaxAmmo;



defaultproperties
{
hitdamage=100
AmmoAmount=1990
MaxAmmo=1990
PickupMessage="You've got the MH2 Enforcer."
ItemName="MH2Enforcer" 
did i forgot someting ?
Last edited by Letylove49 on Fri Apr 25, 2025 10:45 am, edited 1 time in total.
Image
Image
Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 3318
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: set max damage for a weapons

Post by Barbie »

What do you mean by "max damage"? What happens when a player picks up an amp (UDamage)? Default UDamage sets damage multiplied by 3. Or do you mean "default damage"?
"If Origin not in center it be not in center." --Buggie
User avatar
Letylove49
Masterful
Posts: 506
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: set max damage for a weapons

Post by Letylove49 »

Barbie wrote: Tue Apr 15, 2025 9:23 pm What do you mean by "max damage"? What happens when a player picks up an amp (UDamage)? Default UDamage sets damage multiplied by 3. Or do you mean "default damage"?
i mean default damage
Image
Image
Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 3318
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: set max damage for a weapons

Post by Barbie »

There you have to distinguish between projectile and instant hit weapons: The UT_Eightball for example as a projectile weapon uses Class'BotPack.RocketMk2' as projectile which has a damage of 75. you can change such by
  • changing default damage value for all further projectiles of that class (Class'BotPack.RocketMk2'.Default.Damage = xyz)
  • using a custom projectile class and assign it to the weapons
  • changing the damage value for each projectile by SpawnNotify

Instant hit weapons may have damage value fixed in the code, like SniperRifle that has a damage of 100 for head shots and 45 else:

Code: Select all

function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z) {
…
	Other.TakeDamage(45,  Pawn(Owner), HitLocation, 30000.0*X, MyDamageType);
…
Here you must use a custom replacement (or try XC_Engine to modify this function only?) Also if "MyDamageType" is unique you can change damage in game controller or a Mutator's function TakeDamage().
Or instant hit weapons have a configurable damage like

Code: Select all

class ShockRifle extends TournamentWeapon;
…
var() int HitDamage;
…
function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z) {
…
	Other.TakeDamage(HitDamage, Pawn(Owner), HitLocation, 60000.0*X, MyDamageType);
}
"If Origin not in center it be not in center." --Buggie