Announcement

Collapse
No announcement yet.

Weapon Bar

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

    Weapon Bar

    I am trying to make a custom HUD, and I want to get rid of the weapon bar. The simple way was to have an empty DrawWeaponBar function in my custom HUD. But the weapons my mod is using recharge their ammo, whether or not the player is currently using them. Now, when I have the weaponbar in my HUD, everything works fine. But if I put the empty function in, my weapons start acting funny. They don't start recharging until the player chooses them, and then they quickly zip up to the actual value. This might be a cool effect except for te fact that if you fire while its still rising, it will stop where ever it was and take the ammo for the shot away, instead of taking away from the value it should have been. I find it wierd that the weaponbar is having this effect, but maybe there is some code in there that effects this that I didn't notice. Any ideas, help, or hints at where to start to debug? Thanks

    #2
    I'm at work bro but I am almost positive that there is a simple Boolean variable that prevents it from drawing the weapon bar.

    Look in the Deathmatch HUD class file, I think it's first appearance is there.

    Comment


      #3
      Can you post some code?

      Comment


        #4
        Thanks for the replies guys.

        PlayerPawn, I have not found any bool that does that.

        kungfu, I figured I'd ask before posting a ton of different code, what code do you want exactly? the weapon recharging code, HUD code, maybe somehting else?

        cause like i said, with the weaponbar there, the recharge code works, but I don't see what could be effected by it not being there, so I'm not sure what exactly to look at or show you.

        Again, thanks for the help.

        Comment


          #5
          Well, just for kicks I copied the code for the weaponbar into my HUD, and just commented out the draw function calls. The weapons work perfectly. But this is a crappy solution. I understand their may be some update issues involved, but I still don't see how it can actually effect the amount of ammo.

          Comment


            #6
            Commenting out would work. I'd perfer to override the draw function and exlude the Weapon Bar.

            Sorry about the boolean deal, that was bShowMissingWeaponInfo. Pretty neat trick. Doesn't draw that part of the weapon bar unless you have a weapon for that number. This is an idea you could approach somehow...

            Comment


              #7
              Nice web site btw Asteryus

              I'd be interested in seeing just the parts that involve the drawing of the weapons bar and the default properties. As for commenting the stuff out, I've found that's normally the best way to start. Empty out the functions, then start modifying them as you need to .

              Comment


                #8
                Thanks guys.

                PlayerPawn, I haven't gotten around to it but I'll look at that bool in more detail and see how that works.

                kungfu, thanks, though i can only take credit for a majority of the code and some visual touchups, as it was a 3 person collaboration.

                as for the code here is the weapon bar function:
                Code:
                simulated function DrawWeaponBar( Canvas C )
                {
                    local int i, Count, Pos;
                    local float IconOffset;
                    local float HudScaleOffset, HudMinScale;
                
                    local Weapon Weapons[WEAPON_BAR_SIZE];
                    local byte ExtraWeapon[WEAPON_BAR_SIZE];
                    local Inventory Inv;
                    local Weapon W, PendingWeapon;
                
                    HudMinScale=0.5;
                    // CurHudScale = HudScale;
                    //no weaponbar for vehicles
                    if (Vehicle(PawnOwner) != None)
                	return;
                
                    if (PawnOwner.PendingWeapon != None)
                        PendingWeapon = PawnOwner.PendingWeapon;
                    else
                        PendingWeapon = PawnOwner.Weapon;
                
                    // fill:
                    for( Inv=PawnOwner.Inventory; Inv!=None; Inv=Inv.Inventory )
                    {
                        W = Weapon( Inv );
                        Count++;
                        if ( Count > 100 )
                	break;
                
                        if( (W == None) || (W.IconMaterial == None) )
                            continue;
                
                        if ( W.InventoryGroup == 0 )
                	Pos = 8;
                        else if ( W.InventoryGroup < 10 )
                	Pos = W.InventoryGroup-1;
                        else
                	continue;
                
                        if ( Weapons[Pos] != None )
                	ExtraWeapon[Pos] = 1;
                        else
                	Weapons[Pos] = W;
                    }
                
                        if ( PendingWeapon != None )
                        {
                	if ( PendingWeapon.InventoryGroup == 0 )
                		Weapons[8] = PendingWeapon;
                	else if ( PendingWeapon.InventoryGroup < 10 )
                		Weapons[PendingWeapon.InventoryGroup-1] = PendingWeapon;
                         }
                
                    // Draw:        ************************************
                    for( i=0; i<WEAPON_BAR_SIZE; i++ )
                    {
                        W = Weapons[i];
                
                        // Keep weaponbar organized when scaled
                        HudScaleOffset= 1-(HudScale-HudMinScale)/HudMinScale;
                        BarBorder[i].PosX =  default.BarBorder[i].PosX+( BarBorderScaledPosition[i] - default.BarBorder[i].PosX) *HudScaleOffset;
                        BarWeaponIcon[i].PosX = BarBorder[i].PosX;
                
                        IconOffset = (default.BarBorder[i].TextureCoords.X2 - default.BarBorder[i].TextureCoords.X1) *0.5 ;
                        BarWeaponIcon[i].OffsetX =  IconOffset;
                
                        BarBorder[i].Tints[0] = HudColorRed;
                        BarBorder[i].Tints[1] = HudColorBlue;
                        BarBorder[i].OffsetY = 0;
                        BarWeaponIcon[i].OffsetY = default.BarWeaponIcon[i].OffsetY;
                
                        if( W == none )
                        {
                	BarWeaponStates[i].HasWeapon = false;
                	if ( bShowMissingWeaponInfo )
                	{
                		if ( BarWeaponIcon[i].Tints[TeamIndex] != HudColorBlack )
                		{
                			BarWeaponIcon[i].WidgetTexture = default.BarWeaponIcon[i].WidgetTexture;
                			BarWeaponIcon[i].TextureCoords = default.BarWeaponIcon[i].TextureCoords;
                			BarWeaponIcon[i].TextureScale = default.BarWeaponIcon[i].TextureScale;
                			BarWeaponIcon[i].Tints[TeamIndex] = HudColorBlack;
                			BarWeaponIconAnim[i] = 0;
                		}
                		//DrawSpriteWidget( C, BarBorder[i] );
                		//DrawSpriteWidget( C, BarWeaponIcon[i] ); // FIXME- have combined version
                	}
                       }
                       else
                       {
                	if( !BarWeaponStates[i].HasWeapon )
                	{
                		// just picked this weapon up!
                		BarWeaponStates[i].PickupTimer = Level.TimeSeconds;
                		BarWeaponStates[i].HasWeapon = true;
                	}
                
                	BarBorderAmmoIndicator[i].PosX = BarBorder[i].PosX;
                	BarBorderAmmoIndicator[i].OffsetY = 0;
                	BarWeaponIcon[i].WidgetTexture = W.IconMaterial;
                	BarWeaponIcon[i].TextureCoords = W.IconCoords;
                
                	BarBorderAmmoIndicator[i].Scale = W.AmmoStatus();
                	BarWeaponIcon[i].Tints[TeamIndex] = HudColorNormal;
                
                	if( BarWeaponIconAnim[i] == 0 )
                                {
                	                  if ( BarWeaponStates[i].PickupTimer > Level.TimeSeconds - 0.6 )
                	                 {
                			if ( BarWeaponStates[i].PickupTimer > Level.TimeSeconds - 0.3 )
                	                                {
                				BarWeaponIcon[i].TextureScale = default.BarWeaponIcon[i].TextureScale *
                					(1 + 1.3 * (Level.TimeSeconds - BarWeaponStates[i].PickupTimer));
                				BarWeaponIcon[i].OffsetX =  IconOffset - IconOffset *
                					( Level.TimeSeconds - BarWeaponStates[i].PickupTimer );
                			}
                			else
                			{
                				BarWeaponIcon[i].TextureScale = default.BarWeaponIcon[i].TextureScale *
                					(1 + 1.3 * (BarWeaponStates[i].PickupTimer + 0.6 - Level.TimeSeconds));
                				BarWeaponIcon[i].OffsetX = IconOffset - IconOffset *
                					(BarWeaponStates[i].PickupTimer + 0.6 - Level.TimeSeconds);
                                                 	}
                                }
                                else
                                {
                                    BarWeaponIconAnim[i] = 1;
                                    BarWeaponIcon[i].TextureScale = default.BarWeaponIcon[i].TextureScale;
                	}
                         }
                
                         if (W == PendingWeapon)
                         {
                	// Change color to highlight and possibly changeTexture or animate it
                	BarBorder[i].Tints[TeamIndex] = HudColorHighLight;
                	BarBorder[i].OffsetY = -10;
                	BarBorderAmmoIndicator[i].OffsetY = -10;
                	BarWeaponIcon[i].OffsetY += -10;
                         }
                         if ( ExtraWeapon[i] == 1 )
                         {
                	if ( W == PendingWeapon )
                	{
                                    BarBorder[i].Tints[0] = HudColorRed;
                                    BarBorder[i].Tints[1] = HudColorBlue;
                	    BarBorder[i].OffsetY = 0;
                	    BarBorder[i].TextureCoords.Y1 = 80;
                	    //DrawSpriteWidget( C, BarBorder[i] );
                	    BarBorder[i].TextureCoords.Y1 = 39;
                	    BarBorder[i].OffsetY = -10;
                	    BarBorder[i].Tints[TeamIndex] = HudColorHighLight;
                	}
                	else
                	{
                	    BarBorder[i].OffsetY = -52;
                	    BarBorder[i].TextureCoords.Y2 = 48;
                	    //DrawSpriteWidget( C, BarBorder[i] );
                	    BarBorder[i].TextureCoords.Y2 = 93;
                	    BarBorder[i].OffsetY = 0;
                	}
                         }
                         //DrawSpriteWidget( C, BarBorder[i] );
                         //DrawSpriteWidget( C, BarBorderAmmoIndicator[i] );
                         //DrawSpriteWidget( C, BarWeaponIcon[i] );
                      }
                   }
                }
                and as far as the default properties goes, I have nothing new in my class, and the only really important things to know are that WEAPON_BAR_SIZE = 9 and is a constant, and bShowMissingWeaponInfo = True.

                I tried to take out everything after //Draw:, I have it marked with a bunch of **'s. But that didn't change anything. So this code has the whole function, with the Draw function calls being commented out.

                Again, if you need anything else, let me know. And thanks for taking the time to try and help me.

                BTW, I tried to format the code as best as I could, hopefully it comes out decently.

                Comment


                  #9
                  Well, it looks to me that commenting those lines out should be an okay way to handle it if your code is working fine. I've found that emptying an dcommenting out like that is the best way to handle working with the engine. It might feel like a sloppy way to do it, but to me it's not. Just make sure you remove all the equasions you're not going to be using or at least comment them out in order to avoid confision!

                  As for the boolean variable, sometimes those work, but I think the emptying out of code is a more direct way to do it...and it helps you to undersatand more of what's going on...

                  Comment

                  Working...
                  X