How to loot only 1 monster at a time?

Discussion in 'Programming' started by Jihl, Jan 10, 2019.

  1. Jihl

    Jihl Member

    Joined:
    Nov 26, 2018
    Posts:
    42
    Hey there!

    I am trying to make a loot system for my game, I'd like to just open the loot of the sprite that's in front of the picture.

    Explicative image:
    [​IMG]

    As you can see here, there are several corpses stacked, if I click on one of those, all of the ones that are touching the mouse will be opened too. How can I make this to just focus one of the objects?

    Thank you everyone :D

    PD: Those are dead slimes of my project
     
  2. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    728
    Use instance_place and it will return one id only. Use that and collision_rectangle() to detect where the mouse has clicked, to process the pickup.
     
  3. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    512
    Pro tip: Try formatting better, those are two separate links and they aren't displaying, I have to right click on them and open them in a new tab just to look at them. Moreover I don't feel they're very helpful since I don't know what I'm looking at, and there's no UI or anything that fits with your question so it's doubly confusing.

    Honestly, it's either something you just have to deal with, or you need to have a system where the monster that's layered the closest to the screen gets priority, but I'm not sure how to do that. Or how well that would work. You could also just make the die in a way that makes them forcibly move away from eachother so that looting them both at once is impossible, though that may not be good for your particular art direction. (Again, unless that would be fine to deal with.)

    EDIT: Oh looks like The Sly got in a good response while I was typing. Yeah work with what he suggested, that should be the answer right there.
     
  4. Jihl

    Jihl Member

    Joined:
    Nov 26, 2018
    Posts:
    42
    "As you can see here, there are several corpses stacked, if I click on one of those, all of the ones that are touching the mouse will be opened too." I don't see where the explanation is not clear here.

    Also I don't know what you are reffering to by saying "those are two separate links and they arent displaying"

    - "I have to right click on them and open them in a new tab just to look at them."
    That's strange, the post looks perfectly fine for me.

    And also I am pretty sure that there are several ways of dealing with this, this is clearly not a thing that I have to just pass it by, it can be solved.
     
  5. Jihl

    Jihl Member

    Joined:
    Nov 26, 2018
    Posts:
    42
    Thank you for your reply!

    I will try it to see if it works as I need it O:
     
  6. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    728
    Here's a simple way to do it, in case you have trouble.

    Code:
    if (mouse_check_button_pressed(mb_left)){
        var obj = instance_position( mouse_x, mouse_y, o_object);
        if (obj != noone){
            with (obj) {
                //place code here to run inside the object.
            }
        }  
    }
    
     
    Last edited: Jan 11, 2019
  7. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    512
    Weird, it works fine now. Before it was two broken images displayed as errors with a [/IMG] next to both of them, and they both lead to different websites showing the same one. It's working fine now though, maybe it was just a glitch.
     
  8. Jihl

    Jihl Member

    Joined:
    Nov 26, 2018
    Posts:
    42
    It wasnt a glitch, I edited the post just after I posted it because I didn't know how the image system worked, it was unedited
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice