Remember in the Hazard Course there was that drinks machine that gave you small amounts of health when you pressed the buttons, and you could also smash it? With the aid of this tutorial, now you can make your own! Or not, in which case you can just download an example .MAP here.
First of all, you'll need to make yourself something that looks like a vending machine of some kind. Make it a drinks machine though, as it's quite difficult to make it dispense chocolate instead.
Now turn your vending machine into 3 separate solids- you'll need a layer at the front, which you should then clip horizontally just behind the buttons, as shown in this top-down view:
Then, carve up the main part of the front section and a rectangular hole in the back body so you get something looking like that on the left. Finally, carve up the front layer which has the buttons on it so that each button is a separate solid. It takes a bit of skill to get a good looking one, so persevere!
Now comes the entity part. First of all, tie each of the separate button brushes to a func_button entity, all of them targeting an env_beverage entity called soda_spawner (the exact name doesn't matter, as long as it's targeted by the func_buttons.) The capacity field of the env_beverage says how many cans the machine can hold- each one only gives 1 health, so you may as well whack it up to something like 50. The env_beverage entity should be placed in the small tray compartment at the bottom where you'd expect to pick up your drink from after, er, "purchasing" it.
Now for the effects when it's broken. Over the top of the smashed up part of the vending machine, create a new solid that appears to cover up the gaping hole (so it looks like a normal, healthy vending machine again). Make this into a func_breakable entity, that targets broken_soda_spawner.
Create an env_shooter and trigger_relay entity, both called broken_soda_spawner. Edit the trigger_relay entity-
killtarget soda_spawner
trigger state off
So when the vending machine is shot, this trigger_relay will stop the env_shooter from making any more drinks. Edit the env_shooter-
number of gibs 20 (or something similar)
gib velocity 200
course variance 0.15
gib life 4
model name models/can.mdl
material sound metal
Note that the env_shooter should also be placed in the small compartment where drinks are dispensed from, with the directional arrow pointing outwards from the machine. So when the func_breakable is broken by you shooting it, it removes the env_beverage entity from the game (i.e. no more drinks) and gets an env_shooter to fire out a bunch of cans as if it's broken.
First of all, you'll need to make yourself something that looks like a vending machine of some kind. Make it a drinks machine though, as it's quite difficult to make it dispense chocolate instead.
Now turn your vending machine into 3 separate solids- you'll need a layer at the front, which you should then clip horizontally just behind the buttons, as shown in this top-down view:

Then, carve up the main part of the front section and a rectangular hole in the back body so you get something looking like that on the left. Finally, carve up the front layer which has the buttons on it so that each button is a separate solid. It takes a bit of skill to get a good looking one, so persevere!

Now comes the entity part. First of all, tie each of the separate button brushes to a func_button entity, all of them targeting an env_beverage entity called soda_spawner (the exact name doesn't matter, as long as it's targeted by the func_buttons.) The capacity field of the env_beverage says how many cans the machine can hold- each one only gives 1 health, so you may as well whack it up to something like 50. The env_beverage entity should be placed in the small tray compartment at the bottom where you'd expect to pick up your drink from after, er, "purchasing" it.
Now for the effects when it's broken. Over the top of the smashed up part of the vending machine, create a new solid that appears to cover up the gaping hole (so it looks like a normal, healthy vending machine again). Make this into a func_breakable entity, that targets broken_soda_spawner.
Create an env_shooter and trigger_relay entity, both called broken_soda_spawner. Edit the trigger_relay entity-
killtarget soda_spawner
trigger state off
So when the vending machine is shot, this trigger_relay will stop the env_shooter from making any more drinks. Edit the env_shooter-
number of gibs 20 (or something similar)
gib velocity 200
course variance 0.15
gib life 4
model name models/can.mdl
material sound metal
Note that the env_shooter should also be placed in the small compartment where drinks are dispensed from, with the directional arrow pointing outwards from the machine. So when the func_breakable is broken by you shooting it, it removes the env_beverage entity from the game (i.e. no more drinks) and gets an env_shooter to fire out a bunch of cans as if it's broken.