Announcement

Collapse
No announcement yet.

Multiple Firemodes revisited...

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

    Multiple Firemodes revisited...

    I'm trying to make a grenade launcher that can fire different types of grenades, and you can cycle through the grenade-types using the AltFire. I basically want it to work just like the grenade launcher in the Annihilation Aresenal mutator.

    I looked over the Chaos MultiAmmo tut on Wiki, but I kept getting all kinds of errors about the FireMode's being protected, or there was a type mismatch.

    Besides, I don't want an extra key to bind to, I just want to use the AltFire. I also just want the grenades to use the same ammo.

    I currently have all the weapon pickup stuff ready to go, and I have two firemodes that I'm ready to switch between, I'm just not sure how to do it. Apparently, there was a cool tutorial that got deleted here:

    http://www.ina-community.com/forums/...light=firemode

    #2
    Huh. I always find the answer a few minutes after posting.

    I found a bit of code from EvilDrWong on 3DBuzz that may set me straight. Here it is (altered for my guns):

    simulated function ClientStartFire( int mode )
    {
    if( mode == 1 )
    {
    if( !FireMode[0].bIsFiring )
    {
    Log( "Changing Fire Rate" );
    if(FireMode[Mode].IsA('GrenadeClusterFire'))
    {
    FireMode[mode].Weapon=None;
    FireMode[mode].Destroy();
    FireMode[mode]=None;
    FireMode[mode]=Spawn(class'GrenadeFlashFire', Owner);
    }
    else if(FireMode[Mode].IsA('GrenadeFlashFire'))
    {
    FireMode[mode].Weapon=None;
    FireMode[mode].Destroy();
    FireMode[mode]=None;
    FireMode[mode]=Spawn(class'GrenadeClusterFire', Owner);
    }
    }
    FireMode[mode].bIsFiring = True;
    }
    else
    {
    Super.ClientStartFire( mode );
    }
    }

    In theory its great, except that I keept getting a compile error saying "Error, Unrecognized member 'Destroy' in class 'WeaponFire'"

    Looks like there is a DestroyEffects function in WeaponFire, but no Destroy. Opinions?

    Comment


      #3
      I'm also having trouble with this line:

      FireMode[mode]=Spawn(class'GrenadeFlashFire', Owner);

      I get a compile error saying "Error, Call to 'Spawn': type mismatch in parameter 1."

      GrenadeFlashFire is extended from ProjectileFire, which in turn is extended from WeaponFire, so would have thought it wouldn't be a problem.

      Comment


        #4
        Would using States not be the textbook way of handling this? One state for every fire mode?

        Comment


          #5
          I'm relatively new to the UT coding thing and have only been chipping away at the bits of code to create new weapons (mostly extending exisitng ones), so I'm not sure what "states" are, although I would imagine in this case it would translate to something like "switch weaponfire state to clusterfire." Something like that?

          Comment


            #6
            Code can be divided into States. In your case, you could write a State for frag nades, another State for incendiary nades and another State for smoke bombs. Every State would contain whatever code is required for when that specific type of nade is fired. Then, when cycling nade types, all you need to do is tell the code which state to use from now on.

            I guess it doesn't really lead to a lot less code, but to me this seems a textbook example of what State code was designed for.

            For a far more detailed explanation than I can give, check States on the Wiki.

            Comment


              #7
              Why can't you people use the little button in the top-right corner labeled "search"?

              This has already been asked several times before.

              The code you found doesn't work because the weaponfire class is no longer an actor in UT2004.

              Comment


                #8
                Holy S**T, The States Thing Gives Me An IDEA!
                (~) !!
                {}

                Comment


                  #9
                  Actually, I did search and I found that article, but I didn't read far enough.

                  I think I understand that code, in that you can easily set the number of firemodes via the constant, and then declare the firemodes using the MultiFireModeClass in default properties. Much of the rest is voodoo to me, but it looks good.

                  The only thing I don't understand how to do is attach the actual switch to the AltFire. In his example, he uses his own class for the switch "FireModeClass(1)=class'SGOMPReload'

                  I know I'm an idiot, but what needs to be in this class in order to call the switch function, so that AltFire will switch the class?

                  Comment

                  Working...
                  X