• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Gun equiping does not work properly

J

JohnSebek

Guest
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)
   }
}
 

TailBit

Member
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
 
J

JohnSebek

Guest
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
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.
 
Top