Announcement

Collapse
No announcement yet.

Getting Players current weapon?

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

    Getting Players current weapon?

    Context: I made a grappling gun, projectile based, that allows for "offhand" use, meaning you can maintain the grapple and use a different gun. This results in a problem. To get 3rd person beams to show up, in the attachment code, I have to use SetFlashLocation() in my weapon. Problem is, that sets the flashlocation, which is what weapons like the shock rifle and link gun use. So when you switch away from your grapple, you get nasty shock beams being drawn, etc.

    I can think of a few different ways to try to solve this, but the easiest to me seems to be to figure out what weapon is currently equipped, and just do a check for the problematic weapons and clearflashlocation(). I thought this would be straightforward, but I'm not seeing a way to do this in the weapon code.

    You can pull up a "list" in the code, but it's literally a # (like I have 4 weapons). You can check for previous weapon, but that's no good because I'd need to call that from the problematic weapon (e.g. shock rifle), not my weapon.

    Any ideas? I'll release it today or tomorrow regardless, most of the show stopping bugs are all squished, you just can't see a beam in 3rd person until I solve this.

    #2
    From the Pawn Class
    Code:
    /** Weapon currently held by Pawn */
    var()	Weapon Weapon;
    Hope this helps

    Comment


      #3
      Eh I figured it out, sigh, I feel like I should delete these, but I'll leave it up for some other poor soul who maybe does a search.

      Solution:
      Code:
      if (UTWeap_ShockRifle(Instigator.Weapon) != none)
      Implemented within the updatebeamemitter for my purposes it looks like:
      Code:
      
      simulated function UpdateBeamEmitter(vector FlashLocation, vector HitNormal, actor HitActor)
      {
      	if (UTWeap_ShockRifle(Instigator.Weapon) != none)
      	{
      		ClearFlashLocation();
      		SetBeamEmitterHidden( UTPawn(Instigator).IsFirstPerson() );
      	}
      	else if (UTWeap_ShockRifle(Instigator.Weapon) == none)
      	{
      		if (BeamEmitter[CurrentFireMode] != none && bHooked == true)
      		{
      			SetFlashLocation(GrappleHook.Location);
      			SetBeamEmitterHidden( !UTPawn(Instigator).IsFirstPerson() );
      			BeamEmitter[CurrentFireMode].SetVectorParameter(EndPointParamName,FlashLocation);
      		}
      	}
      }

      Comment

      Working...
      X