Re: Using a math_counter and logic entites and to count "keys"
Posted by DrFrag on
Sat Jun 11th 2005 at 3:54pm
62 posts
16 snarkmarks
Registered:
Jan 12th 2005
Location: Australia
Something I forgot to mention. Since I want the player to have a maximum of 5 keys, I'll be adding a check to see if they already have 5 keys (before the key entity is destroyed on pickup). This is pretty easy, but it means I can't use the above process and stick the math_counter at the end.
Re: Using a math_counter and logic entites and to count "keys"
Posted by zombie_computer on
Sat Jun 11th 2005 at 6:56pm
28 posts
3 snarkmarks
Registered:
Feb 15th 2005
Location: Netherlands
seems awfully complicated what you want to do, and i probalby can help
you, but not with the current info (can't really make out what it is
exactly you want: when is the trigger and brush going to be deleted?
What exactly do you want with the locks?)
but know you can check the value of the counter by just doing an "add
0" input, causing the entity to refire its output. youi can change this
output for these checks and quickly set it to the default one as you
see need
Re: Using a math_counter and logic entites and to count "keys"
Posted by DrFrag on
Sun Jun 12th 2005 at 2:42pm
62 posts
16 snarkmarks
Registered:
Jan 12th 2005
Location: Australia
Thanks Zombie. Ideally I'd like a way to check the value of a counter without firing its outputs, but maybe I'm looking at the flow of events the wrong way.
I think I've come up with a solution. It uses a few logic_compare entities and it's pretty messy. The math_counter entity ends up having something like 90 outputs. Hopefully it'll work, I'll post again later with the results.
Are there any tutorials on the general use of logic entities? The examples I've found are too specific, and information on them presented more as a reference. I'm having trouble getting my head around it all.
Re: Using a math_counter and logic entites and to count "keys"
Posted by DrFrag on
Mon Jun 13th 2005 at 10:26am
Posted
2005-06-13 10:26am
62 posts
16 snarkmarks
Registered:
Jan 12th 2005
Location: Australia
Thanks for the diagram. It took me a little while to figure out, but I think I understand it now.
Unfortunately my programming skills are pretty basic so I already used a different method. I'll try to explain it.
The map is based on an old game called Total Eclipse. You run around in a pyramid picking up keys and opening doors. You can hold a maximum of 5 keys at any one time. In the game there are 7 keys and 11 doors.
The way I've put it into hammer is this. Each key is made up of three brush entities and a point entity (a logic_compare that acts as a "key zone" flag). The first brush is a thin func_wall with a picture of the key - that's what you see. The second brush is a trigger_multiple which lies just in front of it - this is the "key pickup" area. Around this is a large trigger_multiple brush that acts as sort of a "key zone". As soon as you enter this, the point entity logic_compare is set to value 1 compare 1. As soon as you leave it switches back to value 0 compare 1. This way, the game knows which key you're about to pick up (by reading the state of the logic_compare flag).
(At this point, control is moved to a bunch of global entities no matter what key you've tried to pick up.)
Once you're in the key zone and try to pick up the key, it runs a compare on a logic_compare entity called Maxkeys. This is to make sure you're not trying to pick up more than 5 keys. It keeps a copy of the main math_counter used to count your keys, and a constant Compare of 5. If the Value has gone up to 5, the compare run on it will trip a game_text entity saying you have too many keys - the program flow will end there.
But if you have less than five keys, it adds one to the main math_counter (which also triggers it). The math_counter passes its own value to a logic_case entity where most of the work happens.
The logic_case entity is filled with Case01=0, Case02=1, Case03=2, etc. For its outputs, it triggers a display text entity for each possible value (eg "You now have 1 key"). It also passes its own value to Maxkeys (and Minkeys) for the next time you try to pick up a key but have too many.
It also does a compare for every case against every "key zone" flag, so every possible key and lock in the game is checked to see if the player is standing in that area. That makes 108 additional outputs - notice at this point how much my programming skills suck!
But of all 108 logic_compare entities that are called, only one of them is going to have Value 1 Compare 1 - the "key zone" that was entered earlier on. So control is passed back to the single point entity that sits next to the key. It then plays a pickup sound and destroys two brush entites (the func_wall that looks like a key, and the trigger to pick it up). This stops the player picking up that key twice.
The locks go through the same process, but subtract one from math_counter and check their value against Minkeys instead of Maxkeys (if you have no keys it says you can't open it).
For those who skipped the above, start reading again here
Long story short, I got it working using logic_compare entities as flags. It was probably the hardest part of making this map so I decided to get it out of the way first. The map will be available for download when I'm done. In the meantime, the original 1988 version of Total Eclipse is available from The Underdogs.