1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

[UT1] Access to Inventory

Discussion in 'Programming' started by Raven, Apr 14, 2004.

  1. Raven

    Raven Member

    Joined:
    Jan 17, 2004
    Messages:
    147
    Likes Received:
    0
    I want to modify Keymover code from chimeric, to destroy a key, and I don't know how to delete something from inventory.

    Code:
    // Modified by Raven
    
    class KeyMover expands Mover;
    
    // This will be the class of the item we will open for, be it
    // a weapon, or a keycard or whatever.  Just set this to the
    // class in the properties of the mover in the level...
    var() class keyclass;
    var() bool DestroyKey; // if true destry key
    
    state() BumpOpenTimed
    {
      // Bump is called when an actor "bumps" us, and the mover code
      // uses this to check and see if it should do its thing, if its
      // a bump-based mover.  We'll just insert some code here to
      // check to see if the bumper is a Pawn (player/bot), and then
      // if they have our desired key.  If so then we call the normal
      // Bump() function in the Parent class, otherwise go ahead and
      // abort now.
      function Bump(actor Other)
      {
        local Inventory key;
        local Inventory Inv;
    
        // BroadcastMessage("Bumped by "$Other.Name);
    
        // First check to make sure this is a Pawn, cause they are
        // only things that have inventories (i think:), and then
        // make sure we have a keyclass to check for.
        if (Other.IsA('Pawn') && keyclass != NONE)
        {
           // BroadcastMessage("Other.Class: "$Other.Class$", keyclass: "$keyclass);
    
           // Now we just use FindInventoryType() to see if they have
           // a copy of our desired key in their inventory...
           key = Pawn(Other).FindInventoryType(keyclass);
    
           // ...if so call the old Bump() function and let the mover
           // do its thing.
           if (key != NONE)
           {
             // Broadcastmessage("Found key");
             Super.Bump(Other);
             if(DestroyKey){
              for( Inv=Inventory; Inv!=None; Inv=Inv.Inventory )
    		if (Pickup(Inv)!= KeyClass)
    		{
                     KeyClass=none; // don't work, why?
                    }
             }
           }
           // ...otherwise just do nothing.
           // else BroadcastMessage("Couldn't find key");
        }
      }
    }
    
     
  2. Mr.Mitchell

    Mr.Mitchell New Member

    Joined:
    Sep 5, 2001
    Messages:
    140
    Likes Received:
    0
    Use DeleteInventory from the Pawn class to delete something from the users inventory.
     
  3. Raven

    Raven Member

    Joined:
    Jan 17, 2004
    Messages:
    147
    Likes Received:
    0
    Works gr8, thx.
     

Share This Page