Merge pull request #11498 from VOREStation/upstream-merge-8240

[MIRROR] Vending machine throwing tweaks
This commit is contained in:
Aronai Sieyes
2021-08-26 14:01:32 -04:00
committed by Chompstation Bot
parent 145f8172f4
commit 362a58386e
3 changed files with 16 additions and 7 deletions

View File

@@ -954,6 +954,7 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
#define CELLS 8 //Amount of cells per row/column in grid
#define CELLSIZE (world.icon_size/CELLS) //Size of a cell in pixels
/*
Automatic alignment of items to an invisible grid, defined by CELLS and CELLSIZE.
Since the grid will be shifted to own a cell that is perfectly centered on the turf, we end up with two 'cell halves'
@@ -989,4 +990,8 @@ Note: This proc can be overwritten to allow for different types of auto-alignmen
W.pixel_y = (CELLSIZE * (0.5 + cell_y)) - W.center_of_mass["y"]
#undef CELLS
#undef CELLSIZE
#undef CELLSIZE
// this gets called when the item gets chucked by the vending machine
/obj/item/proc/vendor_action(var/obj/machinery/vending/V)
return

View File

@@ -112,3 +112,6 @@
walk(src, null, null)
..()
return
/obj/item/weapon/grenade/vendor_action(var/obj/machinery/vending/V)
activate(V)

View File

@@ -65,6 +65,7 @@
emagged = 0 //Ignores if somebody doesn't have card access to that machine.
var/seconds_electrified = 0 //Shock customers like an airlock.
var/shoot_inventory = 0 //Fire items at customers! We're broken!
var/shoot_inventory_chance = 1
var/scan_id = 1
var/obj/item/weapon/coin/coin
@@ -677,7 +678,7 @@ GLOBAL_LIST_EMPTY(vending_products)
speak(slogan)
last_slogan = world.time
if(shoot_inventory && prob(2))
if(shoot_inventory && prob(shoot_inventory_chance))
throw_item()
return
@@ -717,20 +718,20 @@ GLOBAL_LIST_EMPTY(vending_products)
//Somebody cut an important wire and now we're following a new definition of "pitch."
/obj/machinery/vending/proc/throw_item()
var/obj/throw_item = null
var/obj/item/throw_item = null
var/mob/living/target = locate() in view(7,src)
if(!target)
return 0
for(var/datum/stored_item/vending_product/R in product_records)
for(var/datum/stored_item/vending_product/R in shuffle(product_records))
throw_item = R.get_product(loc)
if(!throw_item)
continue
break
if(!throw_item)
return 0
spawn(0)
throw_item.throw_at(target, 16, 3, src)
return FALSE
throw_item.vendor_action(src)
INVOKE_ASYNC(throw_item, /atom/movable.proc/throw_at, target, rand(3, 10), rand(1, 3), src)
visible_message("<span class='warning'>\The [src] launches \a [throw_item] at \the [target]!</span>")
return 1