Announcement

Collapse
No announcement yet.

So you want to add items to the buy menu?

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

  • So you want to add items to the buy menu?

    I thought I'd share this with you (text in red should be changed to suit your needs):

    //================================================== ===========================
    // MyMutator.
    //================================================== ===========================
    class MyMutator expands Mutator;

    var bool Initialized;
    var() int MyItemCost; // Line can be omitted if you hardcode the cost

    function PostBeginPlay()
    {
    SetTimer(2.0, false);
    }

    function Timer()
    {
    local ThieveryShopGuards S; // You can replace red text with ThieveryShopThieves or ThieveryShopThievesThiefMatch
    local int J; // I doesn't work well with [ and ] in BBcode
    local bool bFoundSlot;

    if (Initialized) // I dunno why I do this
    return;
    Initialized = True;

    foreach AllActors(class'ThieveryShopGuards', S) // Red text must be same as above
    {
    bFoundSlot = false; // In the unlikely event that AllActors returns multiple shops
    for (J = 0; (J <= 14 && !bFoundSlot); J++) // goes thru slots and checks for availability
    {
    if (S.Items[J].Item == None) // if slot is available. Red text can be Items, Melee or Ranged
    {
    // Adds MyObject to the slot:
    bFoundSlot = true; // found a slot
    S.Items[J].Item = class'MyObject';
    S.Items[J].Cost = MyItemCost;
    S.Items[J].Quantity = 1;
    S.ItemsName[J] = "My Object";
    S.ItemsLimit[J] = 1; // Remove line if you're not using item or don't want a limit on it
    }
    }
    if (!bFoundSlot) log("[MyMutator] Error: No item slots available.");
    }
    if (S == None) log("[MyMutator] Error: No ThieveryShopGuards found.");
    }


    [edit] Forgot some red coloring [/edit]
    [edit=2] Made some improvements [/edit]
    ]V[]V[

  • #2
    I hate to be the first to tell you (thats a lie, I'm quite enjoying posting this) but that mutator is 100% unnecessary.

    Just place a corresponding ThieveryShop (Thieves or Guards) in your map & edit it's properties for whatever items you want available. If a ThieveryShop is already detected at the start of the map, then that one will be used as opposed to spawning a fresh one.

    Oh well, the thought was defintely appreciated :|

    Comment


    • #3
      Ah yes, I thought as much.
      But my main concern has not been how to make it, but how to make it a mutator. It would be a bit stupid if you had to download a new version of every map just to buy my bow upgrade in it, no?
      ]V[]V[

      Comment


      • #4
        that would REALLY suck.

        try editing thefile so that it makes a temp file of the thievery.ini file, including your loadout.

        Might not be a agood idea, saying that it might screw up the way the game thinks, with having 2 thievery.ini files.

        but hey, build on the thought.
        "Just off the border of your waking mind there lies another time, where darkness and light are one. As you tread the halls of sanity, you feel so glad to be unable to go beyond. I have a message from another time."

        Comment


        • #5
          Nono Rad, I've already fixed the problem, that's why I posted all that code at the beginning
          ]V[]V[

          Comment


          • #6
            Ah, well I've been attempting to code a mutator for a similar purpose (allow the ThieveryShop for any level to be intercepted and altered to add/remove certain items, without altering the map itself), as part of my larger plan (add support for third-party Inventory Items).

            Heres the thread: http://www.thieveryut.com/bb/viewtopic.php?t=1220

            Script-wise, my version is as good as complete but I can't work out how to store Structs in an ini file, & so I'm having trouble working out how to store my new TShop values. Also, there is no easy way to access Uwindows in Thievery and so the ini file has to be altered directly.

            If I get my version working I'll contact you, so you can nitpick it or add your own contribution (if you wish). Alternatively, you could just push ahead with your version and we'll see who can do better :twisted:

            Comment


            • #7
              Did some further tweaking with the script and the problems boil down to trying to store a Struct that consists of an array, in an ini file.

              I can't work out why, but the values just aren't being read (even if I use the exact text from defaultproperties, when I export the script to a .uc file).

              Comment


              • #8
                I don't undrstand...that should work.
                "Just off the border of your waking mind there lies another time, where darkness and light are one. As you tread the halls of sanity, you feel so glad to be unable to go beyond. I have a message from another time."

                Comment


                • #9
                  I've found another approach that works so I'm using that instead.

                  I'll post updates in the 'mutators' thread in the general forums.

                  Comment


                  • #10
                    there's a thread there?!?!?!?!!?

                    *opens new window and posts there*
                    "Just off the border of your waking mind there lies another time, where darkness and light are one. As you tread the halls of sanity, you feel so glad to be unable to go beyond. I have a message from another time."

                    Comment


                    • #11
                      Let the posts be as one!

                      Efficient and broadly compatible code for adding new bolts to a thievery shop:

                      [code:1:169176e3d2]
                      //================================================== =======
                      // ThAddBoltClass.
                      //================================================== =======
                      class ThAddBoltClass expands Mutator config(ThMutators);

                      var() class<ThieveryAmmo> AmmoClass; // The ammo type to add
                      var() config int Cost; // The cost of the ammo

                      var ThBoltAdder ThShopChanger;
                      var bool Initialised;

                      function PostBeginPlay() {
                      local ThieveryShopGuards Shop;

                      if(!Initialised) {
                      ThShopChanger = Spawn(class'ThBoltAdder');
                      if (ThShopChanger != None)
                      ThShopChanger.Master = Self;
                      foreach AllActors(class'ThieveryShopGuards', Shop) {
                      ThShopChanger.SpawnNotification(Shop);
                      }
                      Initialised = True;
                      }
                      }


                      //================================================== =======
                      // ThBoltAdder.
                      //================================================== =======
                      class ThBoltAdder expands SpawnNotify;

                      var ThAddBoltClass Master;
                      var ThieveryShopGuards Shop;

                      simulated event Actor SpawnNotification(Actor A) {
                      local bool ItemFound;
                      local int i;

                      if (Role == ROLE_Authority && A.IsA('ThieveryShopGuards')) {
                      Shop = ThieveryShopGuards(A);
                      for(i=0;i<ArrayCount(Shop.Ranged) && Shop.Ranged[i].Item != none; i++) {
                      if(Shop.Ranged[i].Item == Master.AmmoClass) ItemFound = true;
                      }
                      if (!ItemFound && i<ArrayCount(Shop.Ranged)) {
                      Shop.Ranged[i].Item = Master.AmmoClass;
                      Shop.Ranged[i].Cost = Master.Cost;
                      Shop.Ranged[i].Quantity = 1;
                      }
                      if (i==ArrayCount(Shop.Ranged)) {
                      log("Shop Full: Adding extra bolttype failed!");
                      }
                      }
                      return A;
                      }
                      [/code:1:169176e3d2]

                      Information on adding submenues to the UT preferences menu:

                      Add a line like this to a mutator's .int file:

                      Preferences=(Caption="SubMenu",Parent="ParentMenu( Advanced Options is the base menu)", Class=Package.Class.ClassAgain?,Immediate=True)

                      Where immediate is whether the .ini/.u package settings are updated immediately.
                      You can add simple submenues for holding other submenues with lines such as:

                      Preferences=(Caption"SubMenu",Parent="ParentMenu")
                      Immortius' Forge

                      Comment

                      Working...
                      X