Results 1 to 9 of 9
  1. #1
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Posts
    467

    Default Turn auto pickup into manual button pressed pickup

    I want to change the pickup system so I can pickup items by pressing a button.
    I tried changing pickupQuery function, but weapons won't pickup once pawn is inside weapon's collision box. I want to change it so it doesn't matter if you are already inside. I have this much.

    Code:
    function bool PickupQuery(Pawn Other, class<Inventory> ItemClass, Actor Pickup)
     {
     	local byte bAllowPickup;
         cont = Other.controller;
        if (BaseMutator != None && BaseMutator.OverridePickupQuery(Other, ItemClass, Pickup, bAllowPickup))
    	{
    		return bool(bAllowPickup);
    	}
    
        if(cont.isAimingAt(PickUp, 0))
        {
          `log("Should PickUp");
          if(Other.InvManager!=none)
          {
          Other.ClientMessage("This is a "$PickUp); `log("Will pick up");
    	  if(bTrue)
            {
              `log("Pick up: " $PickUp @" ?");
               return Other.InvManager.HandlePickupQuery(ItemClass, Pickup);
            }
    	else
    	return false;
          }
           else
           {
            return false;
           }
        }
        else
        {
         return false;
        }
    }
    Any ideas?
    Basic Parkour Obstacle Course: Link here Second Link Here

    My Youtube page: http://www.youtube.com/kinos141

  2. #2
    MSgt. Shooter Person
    Join Date
    Nov 2010
    Posts
    382

    Default

    override isvalidtouch or touch in your pickup and put your pickup codes in PerformedUseAction in player controller:
    Code:
    function bool CheckWeaponToPickup()
    {
        local KADroppedPickup V, Best;
    	local vector ViewDir, PawnLoc2D, VLoc2D;
    	local float NewDot, BestDot;
    
    	// Pick best nearby vehicle
    	PawnLoc2D = Pawn.Location;
    	PawnLoc2D.Z = 0;
    	ViewDir = vector(Pawn.Rotation);
    
    	ForEach Pawn.OverlappingActors(class'KADroppedPickup', V, 50)
    	{
    		// Prefer vehicles that Pawn is facing
    		VLoc2D = V.Location;
    		Vloc2D.Z = 0;
    		NewDot = Normal(VLoc2D-PawnLoc2D) Dot ViewDir;
    		if ( (Best == None) || (NewDot > BestDot) )
    		{
    			// check that vehicle is visible
    			//if ( FastTrace(V.Location,Pawn.Location) )
    			//{
    				Best = V;
    				BestDot = NewDot;
    			//}
    		}
    	}
    	if (Best != none && Best.ValidUse(Pawn))//write valid use function or change with validtouch
    	{
    	  Best.GiveTo(Pawn);
    	  return true;
    	}
    	return false;
    
    }
    ///////////
    simulated function bool PerformedUseAction()
    {
      if(Role >= Role_Authority && CheckWeaponToPickup())
      {
       return true;
      }
      return super.PerformedUseAction();
    }

  3. #3
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    you guys always make things so hard

    Code:
    auto state Pickup
    {
        function bool ValidTouch(Pawn Other) { return False; }
        function bool UsedBy(Pawn User) { GiveTo(User); return True; }
    }
    then implement the code in your player controller to use the item.
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  4. #4
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Posts
    467

    Default

    That didn't work. I'm still having trouble because my pawn and the weapon having their collision boxes touch, but not equiping the weapon until the player presses E (exec function use()).
    Any ideas?
    Last edited by Kinos; 03-10-2011 at 04:13 PM.
    Basic Parkour Obstacle Course: Link here Second Link Here

    My Youtube page: http://www.youtube.com/kinos141

  5. #5
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Posts
    467

    Default

    bumping because it hurts.
    I still don't have a solution to my issue. To reiterate( and explain clearer) I want to pickup items by pressing the use key. However, it seems that once I'm inside the collision box of the item and pressed the button, my pawn won't pickup.
    I did another method where I made an bool function. While true and if ran over the item(from outside the collision box), pawn could pickup weapon. It's not what I want, but at least it isolated my issue. Please advise. Thanks.
    Basic Parkour Obstacle Course: Link here Second Link Here

    My Youtube page: http://www.youtube.com/kinos141

  6. #6

    Default

    xxxPawn default properties change:
    Code:
        bCanPickupInventory=false
    xxxPlayerController variables:
    Code:
    var Actor CurrentPickup;
    xxxPlayerController functions:
    Code:
    /*
    ================================================
    ValidPickup()
    
    Checks whether or not a certain actor is actually something we can pickup or not.
    Rather bad way to go about it, but since PickupFactories, DroppedPickups etc
    don't share and common parent class, aside from Actor, I'm unsure what to check for yet...
    ================================================
    */
    function bool ValidPickup(Actor Pickup)
    {
        // all dropped pickups can be picked up, else they wouldn't exist
        if (DroppedPickup(Pickup) != None)
        {
            return true;
        }
        else if (PickupFactory(Pickup) != None)
        {
            // If a pickup factory is hidden, it can't be picked up
            return (PickupFactory(Pickup).bPickupHidden == false);
        }
        // If a pickup factory is hidden, it can't be picked up
        else if (UTCarriedObject(Pickup) != None)
        {
            if (UTCarriedObject(Pickup).bHome == true)
            {
                return true;
            }
    
            if (UTCarriedObject(Pickup).IsInState('Dropped'))
            {
                return true;
            }
        }
    
    
        // not a valid pickup
        return false;
    }
    
    
    /*
    ================================================
    FindPickup()
    
    Finds a pickup (dropped, factory, weapon cache etc) within a limited radius.
    Returns true if its valid.
    ================================================
    */
    function bool FindPickup()
    {
        local Actor Pickup, Best;
        local vector ViewDir, PawnLoc2D, PickupLoc2D;
        local float NewDot, BestDot;
    
        if (Pawn == None)
        {
            return false;
        }
    
        CurrentPickup = None;
    
        // are we standing on one?
        if ((Pawn.Base != None) && ValidPickup(Pawn.Base))
        {
            CurrentPickup = Pawn.Base;
            return true;
        }
    
        // Pick best nearby item
        PawnLoc2D = Pawn.Location;
        PawnLoc2D.Z = 0;
        ViewDir = vector(Pawn.Rotation);
    
        ForEach Pawn.OverlappingActors(class'Actor', Pickup, Pawn.VehicleCheckRadius)
        {
            if (ValidPickup(Pickup))
            {
                // Prefer items that Pawn is facing
                PickupLoc2D = Pickup.Location;
                PickupLoc2D.Z = 0;
                NewDot = Normal(PickupLoc2D-PawnLoc2D) Dot ViewDir;
                if ((Best == None) || (NewDot > BestDot))
                {
                    // check that item is visible
                    if ( FastTrace(Pickup.Location,Pawn.Location) )
                    {
                        Best = Pickup;
                        BestDot = NewDot;
                    }
                }
            }
        }
    
        // remember what we found please
        CurrentPickup = Best;
    
        // if Best is not NULL, we found something
        return (Best != None);
    }
    insert into xxxPlayerController::PerformedUseAction() :
    Code:
    ...
            return Vehicle(Pawn).DriverLeave(false);
        }
    
        // If we find a valid pickup, touch it.
        if (FindPickup())
        {
            bCanPickupInventory = true;
            CurrentPickup.Touch(Pawn, None, CurrentPickup.Location, Normal(CurrentPickup.Location-Pawn.Location));
            bCanPickupInventory = false;
             return true;
        }
    
        // try to find a vehicle to drive
        if (FindVehicleToDrive())
        {
    ...
    This is based on code I used in UT3, slightly updated.
    It was designed to work with default UT3 items/weapons.
    If you don't need to do that, then there are better ways to do this, as shown by Blade.
    Kris Redbeard
    GROUND BRANCH
    Mature Classic Tactical First Person Shooter
    Rule #11: Always cheat, always win. The only unfair fight is the one you lose.

  7. #7
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    got 3 working solutions here, one of them should do it for ya
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  8. #8
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Posts
    467

    Default [Solved]

    Just wanted to say waInfinite thanks + 1. That worked out for me.
    Basic Parkour Obstacle Course: Link here Second Link Here

    My Youtube page: http://www.youtube.com/kinos141

  9. #9
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Posts
    467

    Default

    How do I make it so I have to hold the E button instead of pressing it.
    Basic Parkour Obstacle Course: Link here Second Link Here

    My Youtube page: http://www.youtube.com/kinos141


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.