The Game Modding Community - Since 2001

Making usable vending machines

A Tutorial for Source Engine

Learn how to make usable vending machines that dispense cans and make sounds

Hey guys !!

I had the idea to make this tutorial when I was making my Deadlock map. Since there was no tutorial like that, I had to decompile one of the first map of HL2 to see how Valve made it...

And here I am, because I'm sure not everyone likes mess around with official maps... 
Also, it's not very difficult, but you should definitely know how to correctly use Hammer before reading this tutorial...

Anyway, for this vending machine, there will be sounds and a limited number of cans. Ready ?

START

1. Building the vending machine

Place a prop_static and change its properties : 
  • World Model : vendingmachinesoda01a_door.mdl
  • Collisions : Not Solid
Then, do the "walls" of the vending machine and make them func_detail

(I used the texture metal/metalhull003a)

Beware : you must not use the complete vending machine model because you won't be able to make cans drop out...

2. Making the collisions for both the player and the cans

For the player : just use the special texture playerclip and make brushes around the model. It will only be solid for the player, but not for the cans models.

For the cans : make the "skeleton" of the model with the nodraw texture, don't forget the hole !! 
You will also have to make a sort of box with a toboggan that go through the hole. 
Tie all these brushes as func_clip_vphysics. It will only be solid for the cans.

3. Spawning the cans and playing the sounds

What I made is a button that will always trigger two relays. But only one relay is enable at a time. Once you've reached the number of cans, the first relay become disable, and the second one is enable.

It's not very complex, but stay attentive to the whole entity system. This is how I made it, but I'm sure there is other ways to make it...  Perhaps better ways !!

========================

Place a prop_physics inside the vending machine, inside the "box", and change its properties :
  • Name : soda_can
  • World Model : popcan01a.mdl

========================

Place a math_counter, change its properties and it's outputs :
  • Name : soda_counter
  • Maximal Legal Value : 6 (the vending machine could spawn 6 cans)

========================

Place a point_template, and change its properties :
  • Name : soda_template
  • Template 1 : soda_can

========================

Place two logic_relay, and change their properties and their outputs :
  • Name : soda_dispense_relay
  • OnTrigger - soda_dispense_sound - PlaySound - 0.10
  • OnTrigger - soda_template - ForceSpawn - 0.50
  • Name : soda_empty_relay
  • Start Disabled : Yes
  • OnTrigger – soda_empty_sound – PlaySound – 0.10

========================

Place three ambient_generic in front of the vending machine and change their properties and their flags :
  • Name : soda_empty_sound
  • Sound Name : Trainyard.sodamachine_empty.wav
  • Max Audible Distance : 96
  • SourceEntityName : soda_button
  • Flags : "Start Silent" "Is NOT Looped"

  • Name : soda_dispense_sound
  • Sound Name : Trainyard.sodamachine_dispense.wav
  • Max Audible Distance : 96
  • SourceEntityName : soda_button
  • Flags : "Start Silent" "Is Not Looped"

And another one for the ambient sound that is always looping :
  • Sound Name : city_ventpump_loop1.wav
  • Max Audible Distance : 128

========================

Make a brush using the invisible texture in front of the vending machine's buttons, tie it to a func_button and change its properties , its outputs and its flags :
  • Delay Befor Reset : 2
  • OnPressed - soda_counter - Add - 1 - 0.10
  • OnPressed - soda_dispense_relay - Trigger - ~ - 0.50
  • OnPressed - soda_empty_relay - Trigger - ~ - 0.50
  • Flags : "Don't move" "Use Activates"

4. And it's done !! 

Don't forget that it's a "simple" vending machine. 

If you want, you can make the player choose different cans types, use sprites to show if there is still one kind of can or no, etc...

END

Notes :
  • The differents steps have screenshots. Don't forget to take a look at them
  • I hope that you have learn something and that it was not so hard to understand
  • Thanks for reading !!
Promotional Content

Posts

Embed

Share banner
Image URL:
HTML embed code:
BB embed code:
Markdown embed code:

Credits

Creator
Foofinoo avatar Cell 1 Flag
Affiliation
Cell 1
Foofinoo username pic Joined 4y ago
Offline
Cell 1 Flag Affiliation: Cell 1
11,104 points Ranked 413rd
28 medals 3 legendary 5 rare
  • Returned 5000 times Medal icon
  • 15+ Entries! GameBanana’s Christmas Giveaway 2016 Medal icon
  • 15+ Entries! GameBanana’s Christmas Giveaway 2017 Medal icon
  • 2nd Place - Marble Tracks Redux Contest Medal icon
  • Returned 1000 times Medal icon
  • Submitted 20 Maps Medal icon
Writer

Submitter

Foofinoo avatar
Foofinoo username pic Joined 4y ago
Lost in time...
Cell 1 Flag Affiliation: Cell 1
11,104 points Ranked 413rd
28 medals 3 legendary 5 rare
  • Returned 5000 times Medal icon
  • 15+ Entries! GameBanana’s Christmas Giveaway 2016 Medal icon
  • 15+ Entries! GameBanana’s Christmas Giveaway 2017 Medal icon
  • 2nd Place - Marble Tracks Redux Contest Medal icon
  • Returned 1000 times Medal icon
  • Submitted 20 Maps Medal icon

Foofinoo avatar
Foofinoo
Cell 1 Flag
Affiliation
Cell 1

Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!
  • Paypal Donate
Sign up to access this!

Category

Details

Difficulty Level
Intermediate Difficulty

Attributes

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • Share on Google+

Stats

  • 495 Views
  • 3 Posts
  • 6mo Submitted
  • 6mo Modified

Scores

  • Not yet rated
Sign up to access this!

Hey, you! Mascot

GameBanana is one of the oldest mod sites on the net. Sign up and maximize your browsing experience.

  • Subscribe: Get notified of new submissions like this.
  • Say Thanks: Show your appreciation - send modders points.
  • Post: Give modders your thoughts on their work.
  • Vote: Help your favorite modders win monthly awards.
  • Rate: Rate mods and help them stand out.
  • Flag: Alert moderators and warn members of problems with mods.
  • Watch: Get notified when mods are updated.

Sound fun? Sign up now!

Already a Bananite? Login

bcp.crwdcntrl.net tracking pixel