Announcement

Collapse
No announcement yet.

weapon mutator help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    weapon mutator help

    i've brought this problem to beyond unreal forums, but i havn't gotten a solid answer that solved my problem.

    I'm trying to convert this mutator tutorial: Minigun HE, and basicaly change the assault rifle primary fire to the same thing. In other words, I'm trying to apply this tutorial to the assault rifle.

    i can select the mutator, but it has absolutely no effect.

    here's my code:

    Code:
    class ARHE extends AssaultRifle;
    
    //=============================================================================
    defaultproperties
    {
        FireModeClass(0)=class'ARHEFire'
        PickupClass=class'ARHEPickup'
        ItemName="HE Assault Rifle"
    }
    Code:
    class ARHEFire extends AssaultFire;
    
    var() class<Actor> ExplosionClass;
    var() class<Projector> ExplosionDecalClass;
    
    //=============================================================================
    function BlowUp(vector HitLocation)
    {
        Instigator.HurtRadius(15, 45, DamageType, 250, HitLocation );
        Instigator.MakeNoise(1.0);
    }
    
    //=============================================================================
    simulated function Explode(vector HitLocation, vector HitNormal)
    {
        Instigator.PlaySound(sound'WeaponSounds.BExplosion3',,2.5*TransientSoundVolume);
    
        if ( Instigator.EffectIsRelevant(HitLocation,false) )
        {
            Instigator.Spawn(ExplosionClass,,,HitLocation + HitNormal*16,rotator(HitNormal));
            Instigator.Spawn(ExplosionDecalClass,,,HitLocation, rotator(HitNormal));
        }
    
        BlowUp(HitLocation);
    }
    
    //=============================================================================
    simulated function SpawnBeamEffect(Vector Start, Rotator Dir, Vector HitLocation, Vector HitNormal, int ReflectNum)
    {
        Super.SpawnBeamEffect( Start, Dir, HitLocation, HitNormal, ReflectNum);
        Explode( HitLocation, HitNormal );
    }
    
    //=============================================================================
    defaultproperties
    {
        ExplosionClass=class'NewExplosionB'
        ExplosionDecalClass=class'RocketMark'
    }
    Code:
    class ARHEPickup extends AssaultRiflePickup;
    
    //=============================================================================
    defaultproperties
    {
        InventoryType=class'ARHE'
        PickupMessage="You got the HE Assault Rifle."
    }
    Code:
    class MutARHE extends Mutator
        config(user);
    
    //=============================================================================
    function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
    {
        local int i;
        local WeaponLocker L;
    
        bSuperRelevant = 0;
    
        if ( xWeaponBase(Other) != None )
        {
            if ( string( xWeaponBase(Other).WeaponType ) ~= "XWeapons.AssaultRifle" )
            {
                xWeaponBase(Other).WeaponType = class'ARHE';
                return false;
            }
        }
        else if ( WeaponPickup(Other) != None )
        {
            if ( string(Other.Class) ~= "XWeapons.AssaultRiflePickup" )
            {
                ReplaceWith( Other, "ARHEPickup" );
                return false;
            }
        }
        else if ( WeaponLocker(Other) != None )
        {
            L = WeaponLocker(Other);
    
            for (i = 0; i < L.Weapons.Length; i++)
            {
                if ( string( L.Weapons[i].WeaponClass ) ~= "XWeapons.AssaultRifle" )
                    L.Weapons[i].WeaponClass = class'ARHE';
            }
        }
    
        return true;
    }
    
    //=============================================================================
    defaultproperties
    {
         GroupName="ARHE"
         FriendlyName="ARHE"
         Description="Change Assault Rifle rounds to High Explosive rounds."
    }

    I'd appreciate any help.

    #2
    Yea this kind of thing is hard. Good luck with this and I hope some one helps you. We need more people like you who are willing to learn coding good luck.:up:

    Comment


      #3
      hey thanks for the encouragement man, it means alot.

      here's the thread in beyondunreal forums. here

      Comment


        #4
        You forgot the RequiredEquipment of the Pawn class, it's giving them an Assault Rifle. Either change the Pawn(Other).RequiredEquipment array or change Weapon(Other).

        Comment


          #5
          The wiki also has a mutator tutorial (a Hello World mutator, I think it's at the start of the scripting tutorials) that explains how to set up a mutator and see it work. It works by writing a line to the log, I believe. If you let your mutator write a line to the log, you can check if it is not being used at all or "just" not producing visible results.

          Comment


            #6
            I used that example for my weapon (used to be a shock rifle) aswell, all worked like 100%
            I think you need to make up your .ucl file, use one from another weapon mutator and change the classes,names into yours

            Comment


              #7
              The problem is as AM said: Your mutator replaces all the weapons in weaponlocker, weaponbases, and weapon pickups with your weapon, but is NOT coded to replace the assaultrifle you START with. I don't remember how it is exactly set up, but I'm sure you can find somethink on the Wiki, or DL a weapon that replaces theAR and check out it's Mutator code.

              Comment


                #8
                hey, thanks for the replies. I'll try out your suggestions and return with the results.

                Comment


                  #9
                  a segment of code from the mutator subclass file.

                  Code:
                  
                   if ( xPawn(Other) != None )
                      {
                          if ( xPawn(Other).RequiredEquipment[1] == "XWeapons.AssaultRifle" )
                          {
                              xPawn(Other).RequiredEquipment[1] = "ARHE";
                              return false;
                          }
                      }
                      else if ( xWeaponBase(Other) != None )
                      {
                          if ( string( xWeaponBase(Other).WeaponType ) ~= "XWeapons.AssaultRifle" )
                          {
                              xWeaponBase(Other).WeaponType = class'ARHE';
                              return false;
                          }
                      }
                      else if ( WeaponPickup(Other) != None )
                      {
                          if ( string(Other.Class) ~= "XWeapons.AssaultRiflePickup" )
                          {
                              ReplaceWith( Other, "ARHEPickup" );
                              return false;
                          }
                      }
                      else if ( WeaponLocker(Other) != None )
                      {
                          L = WeaponLocker(Other);
                  
                          for (i = 0; i < L.Weapons.Length; i++)
                          {
                              if ( string( L.Weapons[i].WeaponClass ) ~= "XWeapons.AssaultRifle" )
                                  L.Weapons[i].WeaponClass = class'ARHE';
                          }
                      }
                  i gather that that's not the correct way to change the AR at spawn? what is?thnx

                  Comment


                    #10
                    i finaly put a simple log entry into each replacement function. xWeaponBase, xWeaponPickup, and WeaponLocker, things. and they were not in the log file, so it's not running the those parts of the mutator. what's up?

                    Comment


                      #11
                      GetInventoryClassOverride is the function you should be looking at. Something like:

                      Code:
                      function string GetInventoryClassOverride(string InventoryClassName)
                      {
                      	local int x;
                      
                      	for (x = 0; x < 16; x++)
                      		if (InventoryClassName ~= string(oldWeaponClasses[x]))
                      			return string(newWeaponClasses[x]);
                      
                      	return Super.GetInventoryClassOverride(InventoryClassName);
                      }
                      Note that I'm being lazy and merely pasting the code from the MutONSWeapons mutator because I don't feel like typing it up from scratch. That should give you an idea of how it should work though.

                      Comment


                        #12
                        this line
                        Code:
                        function string GetInventoryClassOverride(string InventoryClassName)
                        brings this compile error.

                        Error, 'Function' is not allowed here

                        Comment


                          #13
                          Then you probably did not place it between the var() bits and the defaultproperties, or you placed it inside another function. The latter can be done inadvertently by forgetting a single }. Comment out chunks of your code and recompile. Rinse and repeat until it compiles. If it suddenly compiles, the cause is probably in what you commented out last.

                          Comment


                            #14
                            i think i finaly found the answer, or part of it at least, here

                            Code:
                                Other.GiveWeapon("XWeapons.BioRifle");
                                Other.GiveWeapon("XWeapons.FlakCannon");
                                Other.GiveWeapon("XWeapons.LinkGun");
                                Other.GiveWeapon("XWeapons.Minigun");
                                Other.GiveWeapon("XWeapons.RocketLauncher");
                                Other.GiveWeapon("XWeapons.ShockRifle");
                                Other.GiveWeapon("XWeapons.SniperRifle");
                            will that not work just as well?

                            Comment


                              #15
                              Other.GiveWeapon does exactly what it says: gives the player a weapon from spawn without the need to pick it up from a weaponbase. Which means you'd still have the default *** rifle, and also the ammo for the weapon wouldn't be replaced.

                              Comment

                              Working...
                              X