[Solved]MH2 : Exclued weapons from Regen

Discussions about Coding and Scripting
Letylove49
Adept
Posts: 395
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

[Solved]MH2 : Exclued weapons from Regen

Post by Letylove49 »

Hello. i need help please : i would like to exclued some weapons from regen fonction on MH2Gold but that doesn't work and i don't know why :

Code: Select all

  if (bUseRegenAmmo)
{
  for (Inv = P.Inventory; Inv != None; Inv = Inv.Inventory)


	{

      if( (Inv.IsA('MH2Eightball')) ||  (Inv.IsA('MH2Enforcer')) || (Inv.IsA('MH2biorifle')) || (Inv.IsA('MH2FlakCannon')) || (Inv.IsA('MH2minigun2')) || 
      (Inv.IsA('MH2ShockRifle'))|| (Inv.IsA('MH2SniperRifle')) || (Inv.IsA('MH2ripper')) || (Inv.IsA('MH2SuperShockRifle')) || (Inv.IsA('MH2PulseGun' )) || (Inv.IsA('MH2Rifle'))
      ||(Inv.IsA('MH2SFC')))
        Ammo(Inv).AmmoAmount += Ammo(Inv).MaxAmmo;

        if( (Inv.class==class'MH2WarheadLauncher') || (Inv.class==class'WarheadLauncher') || (Inv.class==class'ukbadboy') )  // this weapons must no regen 
                     {
                        if (Ammo(Inv).AmmoAmount ==0 )
                           Ammo(Inv).AmmoAmount = Ammo(Inv).MaxAmmo * 0 ;
 }


     if ((Ammo(Inv) != None) && (P.bFire == 0) && (P.bAltFire == 0))
    {
      if (Ammo(Inv).AmmoAmount < Ammo(Inv).MaxAmmo )
      {
        Ammo(Inv).AmmoAmount = Ammo(Inv).MaxAmmo;
      }



}
  }
  
  }
  
Last edited by Letylove49 on Thu Nov 06, 2025 3:36 pm, edited 1 time in total.
Image

Letylove49 aka Alicia
User avatar
Titled
Novice
Posts: 6
Joined: Thu Aug 07, 2025 4:42 pm
Location: Netherlands

Re: MH2 : Exclued weapons from Regen

Post by Titled »

Not sure what you actually want to do but I did notice a few weird things in the code.

1. You are using an include filter, not an exclude filter. If you want to change this, add an exclamation mark to your if statement.

Code: Select all

if( ! (Inv.IsA('MH2Eightball')) ||  (Inv.IsA('MH2Enforcer')) || ...
2. The following code seems to be a no-op. (It sets the ammo, if it is 0 to 0)

Code: Select all

if (Ammo(Inv).AmmoAmount ==0 )
    Ammo(Inv).AmmoAmount = Ammo(Inv).MaxAmmo * 0 ;
3. The following code sets ammo to the max if it was lower. Personally I think it would make more sense to set it, if it is higher.

Code: Select all

if (Ammo(Inv).AmmoAmount < Ammo(Inv).MaxAmmo )
{
    Ammo(Inv).AmmoAmount = Ammo(Inv).MaxAmmo;
}
If you want to change it, swap < with >. Another option would be to replace it with:

Code: Select all

Ammo(Inv).AmmoAmount = min(Ammo(Inv).AmmoAmount, Ammo(Inv).MaxAmmo);
User avatar
GEARvision
Average
Posts: 66
Joined: Wed Nov 02, 2022 10:48 am
Personal rank: Rookie Archivist

Re: MH2 : Exclued weapons from Regen

Post by GEARvision »

Interesting, this same thought was crossing my mind yesterday
So I could give the player the InstaGib Rifle as a reward the same type of reward like the Damage Amplifier

It would last a minute, but it may drain sooner because it has ammo (which never fills up)
My all time games & software are UT +mods & Smuggler's Run 2 by Rockstar; on the other side FFmpeg (CLI multimedia editor) & Zstandard (add-on for 7zip)
Aka RICOTTA_19216 / Loading SKAARJNET...
Letylove49
Adept
Posts: 395
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2 : Exclued weapons from Regen

Post by Letylove49 »

Titled wrote: Tue Sep 30, 2025 12:46 pm Not sure what you actually want to do but I did notice a few weird things in the code.

1. You are using an include filter, not an exclude filter. If you want to change this, add an exclamation mark to your if statement.

Code: Select all

if( ! (Inv.IsA('MH2Eightball')) ||  (Inv.IsA('MH2Enforcer')) || ...
ok i have test that :
if (bUseRegenAmmo)
{
for (Inv = P.Inventory; Inv != None; Inv = Inv.Inventory)


{




if( (Inv.IsA('MH2Eightball')) || (Inv.IsA('MH2Enforcer')) || (Inv.IsA('MH2biorifle')) || (Inv.IsA('MH2FlakCannon')) || (Inv.IsA('MH2minigun2')) ||
(Inv.IsA('MH2ShockRifle'))|| (Inv.IsA('MH2SniperRifle')) || (Inv.IsA('MH2ripper')) || (Inv.IsA('MH2SuperShockRifle')) || (Inv.IsA('MH2PulseGun' )) || (Inv.IsA('MH2Rifle'))
||(Inv.IsA('MH2SFC')))
Ammo(Inv).AmmoAmount += Ammo(Inv).MaxAmmo;

if( (Inv.class!=class'MH2WarheadLauncher') || (Inv.class!=class'WarheadLauncher') || (Inv.class!=class'MH2UKBadBoy')|| (Inv.class!=class'UltimaProtos')|| (Inv.class!=class'NuclearLauncher')|| (Inv.class!=class'MJD.dokuoLauncher')|| (Inv.class!=class'MJD.WarHeadLauncher3') )

if ((Ammo(Inv) != None) && (P.bFire == 0) && (P.bAltFire == 0))
{
if (Ammo(Inv).AmmoAmount < Ammo(Inv).MaxAmmo )
{
Ammo(Inv).AmmoAmount = Ammo(Inv).MaxAmmo;
}



}
thanks.
that work for . class'MH2WarheadLauncher and class'WarheadLauncher. no infinte ammo like i want.

that doesn't work for : Inv.class!=class'MH2UKBadBoy')|| (Inv.class!=class'UltimaProtos')|| (Inv.class!=class'NuclearLauncher')|| (Inv.class!=class'MJD.dokuoLauncher')|| (Inv.class!=class'MJD.WarHeadLauncher3') )

Note that these weapons are only available in certain maps. I don’t know if it matters.

how i can fix that
Image

Letylove49 aka Alicia
Letylove49
Adept
Posts: 395
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: AK admin
Location: suisse

Re: MH2 : Exclued weapons from Regen

Post by Letylove49 »

i have fund the solution for that.
Image

Letylove49 aka Alicia