WiseGateLockMath: Gate lock Whack counter

From Valve Developer Community
Jump to: navigation, search


This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.

Introduction

Counting Whacks? Yep. For any of you not familiar with that term it’s the action taken when someone gives you a good hit with something, you just receive a good Whack.

This project is an adaptation of WiseGateLock.

An AKG forum member requested a tutorial on making it harder for the Player to break the lock. As you probably know most of the tutorials are the results of requests.

In this project I’m using a math_counter to count how many times the lock received damage, or Whacks. I could have simply created a method to control the Health but I believe this method is best.

Creation

Everything is the same as the previous tutorial except the lock was changed from prop_physics to prop_physics_override (models\props_wasteland\prison_padlock001a.mdl)

Why the need for prop_physics_override? With prop_physics_override, and prop_dynamic_override, we have additional properties. Each of the override prop types has their own qualities, for this project prop_physics_override is perfect.

Changing the lock to prop_physics_override is simple. Select it and press Alt+ Enter or double-click on it. Once the properties dialog is open change the Class to prop_physics_override.

Now in the properties dialog make sure the Health is set to 0. In the flags put a checkmark in Don’t take physics damage.


Now add a math_counter to the project. (Don’t be afraid of these entities. They have the word "Math" in their name but they are really simple to use.)

Once the math_counter entity has been added change the properties:

  • Name: HitCounter
  • Initial Value: 0
  • Minimum legal value: 0
  • Maximum legal value: 5

We’ll create two outputs from the math_counter.

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnHitMax locklatch Kill 0.00 Yes
Io11.png OnHitMax lockgate Break 0.00 Yes

The Outputs from the Lock need to be changed from the previous project.

  • Name: lockgate
  • World Model: models/props_wasteland/prison_padlock001a.mdl
  • Health: 0
  • Flags: Don’t take physics damage
  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnHealthChanged HitCounter Add 1 0.00 No
Io11.png OnBreak sparkgate SparkOnce 0.10 Yes
Io11.png OnBreak socketgate Kill 1 0.20 Yes
Io11.png OnBreak gate01 Unlock 0.30 Yes

Notice with the many Outputs only one of them isn’t Checked for Only Once. We need the Output to the math_counter to be fired 5 times. One the fifth Output the math_counter will break the lock. When the Lock breaks it will fire off a series of Outputs.

In this project I’ve also added a Player Clip in one corner of the fence. This was to illustrate how you can keep the Player in the area you want them.

See also