Math Counter 2

Tutorial collection, comprehensive listings on main site.

Math Counter 2

Postby Tutorial on Mon Sep 05, 2005 5:56 pm

category
General Half-Life 2/Entities

description
Use it to control a door.

keywords
math, counter, 2, math_counter.

To easily understand this tutorial you must know how to create a func_door and a func_button.

OK in this tutorial im going to teach you how to create the affect of a barricade type door with a math counter and some simple output commands. (This is like having a garage door and a remote).

It is basically going to replace setting up path_tracks and all the hassle of lining them up and fixing your door to east or west or whatever you have to do to make your func_traintrack door to look right when you compile your map.

Ok first step let make our door. my func_door just happens to be a metal barricade in front of a window to act as a metal reinforcement.

Image

Now I want to have it so my metal door will go up and uncover my window so I can see outside. But when you work with doors in this fashion they tend to go back down after a few seconds. (This can be prevented in many ways but i'm going to teach you how to do it with a math counter).

Ok when I made my door I made my origin twice as long as my door

Image

That way when it goes up it uncovers just my window and doesn't keep going. Ok now that I have it set to move up i=I go to my flags and I make sure that "Toggle" is the only one checked.

Dont forget do have a name for your door, mine is "glass office barricade door"

- ok your done with your door now.

Now set up your button and math_counter

Image

First setup your math_counter, I named mine "glass office baricade door-counter" (i know really long name) don't change initial value or minimum legal value because it will mess up with the counting process, but
make sure you set MaXimum Leagal Value to 2. Ok now go to your outputs tab make it like this

add- OnHitMax * glass office baricade door * close ---------------
add- OnHitMax * glass office baricade door - Counter * SetValue * 0 ---------------

- ok your done with your math counter now

Now set up your button. I didn't name mine anyting for the simple purpose im not goign to target it with any other entity so i just left that blank.(**side note come back to this**)you can do cool stuff with targeting the button tho, for instanceif you had a breakable object on your door, like a garage system, You could say on heath change disabledoor button and shoot sparks from door with some env_sparks. There are tuns of things you could do with this. - back to the tutorial) ok now go to the outputs tab
make sure you make these.
add- OnPressed * glass office baricade door - counter * add * 1 ------------
add- OnPressed * glass office baricade door * Open -------------------------

Now go to your flags and make sure "Don't move" and "Use Activates" are the only things checked

Ok and your done!!

Image

Image

^^^^----- the breakdown -----^^^^

Ok what i did in this tutorial is have it so the math counters max is set to 2. When the math counter reaches 2 (Maxhit) it will close the door. To do this i set the button to add 1 to the counter every time its pressed, it also opens the door when you press the button but it cannot open twice. So the 2nd time you press the button the open command is canceled out by the counter. on the first press the door opens and it adds 1 , this is the halfway point for the counter. On the second press it adds up too 2 giving the go ahead on the counter to close the door because it has reached its max number. We also have the counter set so when it reaches its max number it will reset itself allowing the process to start over.

And thats how its done

- Generalvivi , if you have any questions or wanna show me an example that you made stop by
http://www.iwannamap.com
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Postby zombie@computer on Wed Sep 07, 2005 4:22 pm

okay, I may be misinterpreting but:

1)no need for the origin, doors always just open to the height (or whatever axis you make them move) they are. adjustable per "lip" property

2) the toggle flag? + delay before reset=-1? does the same thing, with less ents.

or is this tutorial just for showing how a math_counter works? if so, i suggest to add some line saying: dont use this for real doors, cuz its really hard
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Postby Generalvivi on Sun Sep 11, 2005 7:08 pm

it was to show off math counters. plus you can set it so if the door was shot that it could delet the math counter giving it the affect that the door was broken or somthing, because it will never go back down. you can toy with lots of stuff , just use your imagination.
Generalvivi
Irrational Games
 
Joined: Fri Feb 18, 2005 1:41 am
Location: Boston

Postby wisemx on Sun Sep 18, 2005 8:09 pm

...I'm with Zombie, the origin brush is going to confuse Source mappers.

The door illustrated here can be created with a func_movelinear in a few seconds.

Teach mappers how to use math counters but please something less confusing, perhaps how many times an NPC got shot, etc. :wink:
User avatar
wisemx
Regular
Regular
 
Joined: Wed Aug 10, 2005 10:40 pm
Location: Tennessee U.S.A.

Postby Generalvivi on Mon Sep 19, 2005 1:27 am

yeah i feel ashamed. :oops:
Generalvivi
Irrational Games
 
Joined: Fri Feb 18, 2005 1:41 am
Location: Boston

Postby Hades_9966 on Mon Sep 19, 2005 4:05 am

Im trying to make it so when the player pulls 4 leavers the math_counter triggers off some stuff like opens doors and plays sounds but it doesnt work.
You just pull the leavers and it does nothing.What could i be doing wrong. {This is in CSS btw}
Hades_9966
User avatar
Hades_9966
Dumpling
Dumpling
 
Joined: Thu May 26, 2005 7:21 am

Postby Shifty31 on Mon Sep 19, 2005 4:17 am

Do the leavers have to be pulled in a order ?

+ Sh|fty
171157165040075040154145145164054
040053040123150174146164171
Image
User avatar
Shifty31
Been Here A While
Been Here A While
 
Joined: Sun May 01, 2005 1:53 pm

Postby Hades_9966 on Mon Sep 19, 2005 4:29 am

I haven't made it so it has to be pulled in order and i don't think it has to.
Hades_9966
User avatar
Hades_9966
Dumpling
Dumpling
 
Joined: Thu May 26, 2005 7:21 am

Postby Hades_9966 on Mon Sep 19, 2005 4:47 am

I figgured it out and it's working now
Hades_9966
User avatar
Hades_9966
Dumpling
Dumpling
 
Joined: Thu May 26, 2005 7:21 am

Postby Generalvivi on Wed Sep 21, 2005 5:59 am

did you use teh math counters?
Generalvivi
Irrational Games
 
Joined: Fri Feb 18, 2005 1:41 am
Location: Boston

Postby Hades_9966 on Wed Sep 21, 2005 6:52 am

I used the math counter. I only had some numbers in the wrong place so I moved them and now it's working.
Hades_9966
User avatar
Hades_9966
Dumpling
Dumpling
 
Joined: Thu May 26, 2005 7:21 am

Postby Grantax on Tue Mar 14, 2006 6:58 pm

Why not just use the toggle method when pushing the button?
Grantax
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Tue Mar 14, 2006 1:33 pm
Location: Norway

Postby Generalvivi on Tue Mar 14, 2006 7:15 pm

this was only ment to show you what types of things you can do . Your supposed to take this knowledge and use it in other places also :P
Generalvivi
Irrational Games
 
Joined: Fri Feb 18, 2005 1:41 am
Location: Boston

Return to Tutorials

Who is online

Users browsing this forum: No registered users

cron