How do I fix my loot system ?

0 favourites
  • 6 posts
From the Asset Store
Perfect, complete, easy to use to use, out-of-the-box inventory system
  • Hi guys

    Here is a loot system i'm trying to make for my game.

    There's a couple of issues I cannot fix :

    Microsecond of latency when generating loot...

    cannot get items to come back to original position when trying to equip them on wrong slot...

    items are swapping even if the swap results in some items being on a slot they are not supposed to be...

    maybe more, who knows !

    No joke, i've been working on this single file for about 10 hours straight, but this can bee explained by my close to 0 experience with the software.

    Here is the CAPX file.

    https://www.dropbox.com/s/flfplgsn7xwiayl/Loot%20Tests.capx?dl=0

    Hopefully some of you guys can help me ! Thank you very much !

  • Well swapping will occur every time because you have no checks for if it would be swapped onto a wrong item space. The other issue is the same, there are no checks against is a sword trying to be put onto a helmet space. The latency, no idea seems fine to me.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • (problems corrected, somehow figured out thinking about it during the day, and you confirmed it, thank you ! Before, I was using a "else" condition for every sub event, but it did not work. Now everything is fine !)

    For "latency" I was referencing to the very small window of time on which you see frame 0 of any loot spawned, you know, like every time it spawns, you see it being a green shield for like 1 frame, and then it transforms into the actual loot. Anyway around this ? It didn't happen before, it might be because there are too many events ?

    Speaking of events, do you think there would be anyway to reduce the number of events ?

    In my actual game, there is gonna be much more than 3 equipment slots, like maybe 8-10. This is gonna create a sh**ton of events, and I don't think I can use families to generalize events, since Every single equipment slot is unique.

    (EDIT : If I swap the logic between rarity and loot type, the frames representing loot will be "grouped" by type and not by rarity, allowing to make checks when dragging just by saying "if loot frame is between X and Y, equip it" coupled with "if loot frame if inferior to X, don't equip" and "if loot frame is over Y, don't equip". Should save dozens of events !)

    Thank you for your reply, kind sir.

  • Bump.

    Unfortunately I am running into two more problems :

    • One that I cant find the exact event to correct (although its not REALLY bad, unless problem 2 is not resolved),
    • One that could really be a bug, but again as a non experimented user, I just might be doing something wrong.

    Problem 1 : When swapping items, if the item dragged is equipped, both item still swap, even if they end up on the wrong equipment slot. I had the problem of the swap before between inventory and equipment slot, and resolved it for the opposite situation, when you try to swap an inventory item for an equipped item. This does not work anymore if the item would go in the wrong inventory slot.

    I might require a particular check for this situation, but I am having trouble to find the right one, since this unique situation has so much elements.

    Problem 2 : The attributes given to loot are dependent of the frame playing. This frame is set-up when the loot object is created. Rarity and type, which are attributed randomly determines which frame the sprite will be showing, thus showing item type (picture) and item rarity (background). Attributes are simply variables. When any loot is equipped, it copies its attributes onto the variable of the equipment slot sprite.

    In debug mode, I noticed that somehow, on loot created, after 1 frame, the correct attribute (atk, blk or def) was given, and after another 11 frames, the attribute corresponding to the next frame was also given. I do not understand why.

    Example : Common sword is created : its attributes are Atk 1 Blk 0 Def 0. its animation frame is frame 1. After 11 steps in debug mode, it will be also given the attributes of frame 2, which is 1 def, making the sword having both 1 atk and 1 def.

    In the event sheet, I tried to change the "compare frame" events, and changing them to not only "give X atk, blk or def" to "give X atk AND set blk to 0, set def to 0". The debug mode then shows my stats twitching every more or less 10 frames, quickly jumping from their correct value to 0, and back to their correct value a frame later.

    I hope it makes sense, if not, just test it yourself !

    If problem 1 was resolved, though, this change in stats would not be a problem, since the equipment slot only copies one single attribute of the loot.

    So if anyone can resolve problem 1, then no need to bother for tthis strange bug, although I really would like to know if its a bug or not.

    CAPX : https://www.dropbox.com/s/flfplgsn7xwia ... .capx?dl=0

  • In general I think it's better to use an array for an inventory. I've had this issue before, I started off by using a physical style inventory where you compare animations and if slot is full by instance variables and the events begin to snowball. It is much easier to use an array and relate it to co-ords in an inventory. That way you can check what value is in the array 1,0 2,0 3,0 etc and match with the item you want. It also cuts down on events. If you want to use your current method I'll have a read of your essay in a bit

  • I actually fixed my problem 1 : I simply swapped one single event from "pick bottom instance" to "pick top instance" (the only one in the whole event sheet, coupled with "if loot is overlapping with loot"

    However, now, item do not swap anymore between inventory slots (not a big deal), and also do not swap anymore same type loot from inventory into equipped slot, which makes the whole thing look noobish. Kind of a bigger deal, to me who is very strict with things.

    I somehow thought an array would be much more simple.

    However, I have NO idea how it works, even after reading basic tutorials on it.

    That's why I used a physical system.

    I'd be down for a lesson, if you care sparing some time. Or a link to a tutorial which exactly teaches that ?

    BTW : final updated version of the system : https://www.dropbox.com/s/2mq2vlmev7wn7 ... .capx?dl=0

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)