1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Gun equiping does not work properly

Discussion in 'Programming' started by JohnSebek, Nov 10, 2019.

  1. JohnSebek

    JohnSebek Member

    Joined:
    Apr 2, 2018
    Posts:
    26
    So, I have created an inventory system, and it also switches guns. To make it more resource-friendly, I used the parent object for all guns so the inventory system just switches it up. But now, all the guns shoot the same as the first weapon player has in hand, and keep the same values such as fire rate, ammo capacity, etc.
    This is the item that switches the weapon
    Code:
    Create Event:
    call the inherited event of the parent object
    execute code:
    
    ///initial variables
    item_count_maximum=1
    inventory_explorer_in_range_required=0
    item_name="Broomhandle"
    item_description="German Classic"
    item_target=obj_player
    
    Other Event: User Defined 0:
    call the inherited event of the parent object
    execute code:
    
    ///condition
    
    if ds_grid_height(obj_inventory_tracker.my_inventory_grid)<obj_inventory_tracker.maximum_inventory_cursor_row
    and ds_grid_width(obj_inventory_tracker.my_inventory_grid)<_inventory_tracker.maximum_inventory_cursor_column
       {
       condition_accepted=1
       }
    else
       {
       condition_accepted=0
       }
    
    Other Event: User Defined 1:
    call the inherited event of the parent object
    execute code:
    
    ///action
    with (obj_inventory_tracker.my_target)
     {
    with (o_gunpar)
       {
       instance_change(o_broomhandle)
       }
    }
    
     
  2. TailBit

    TailBit Member

    Joined:
    Oct 16, 2019
    Posts:
    62
    You are changing every parent into o_broomhandle .. instead of just the gun player is holding.

    But these parts seems rather disconnected .. not sure if this is enough clues for us to work with.

    Code:
    if ds_grid_height(obj_inventory_tracker.my_inventory_grid)<obj_inventory_tracker.maximum_inventory_cursor_row
    and ds_grid_width(obj_inventory_tracker.my_inventory_grid)<_inventory_tracker.maximum_inventory_cursor_column
       {
       condition_accepted=1
       }
    else
       {
       condition_accepted=0
       }
    About that line..
    Code:
    // that would be something like this:
    if (a>5){
       b=true;
    }else{
        b=false;
    }
    
    // or you could write:
    b = a>5;
    ..as the argument itself would be true or false
     
  3. JohnSebek

    JohnSebek Member

    Joined:
    Apr 2, 2018
    Posts:
    26
    Well the gunpar is not created its just used so I can only write gunpar to change it and not all the guns individually. Also, the weapon object and weapon item are two separate objects.I can post other codes if that would help.
     

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