Go Back   Steam Users' Forums > Steam Tool Discussions > Source Level Design

Reply
 
Thread Tools Display Modes
Old 02-19-2012, 01:09 PM   #1
forums101
 
 
 
Join Date: Feb 2012
Reputation: 0
Posts: 153
How do you create a point system?

Hi, I am trying to create a point system based off of the number of npcs that you kill. I was wondering if this was possible with a math_counter (when you kill an enemy npc the counter increases by a certain amount).

And if this is possible, I want these "points" to be spendable.
EX: You use a func_button (or trigger etc.) to spawn a weapon that costs a certain amount of points, thus when the button is triggered it subtracts the number from the counter (then obviously if you don't have enough points the button will not produce the desired weapon when pressed).

I am sure there are many ways to go about doing this. Any method that would work I would be glad to hear.
forums101 is offline  
Reply With Quote
Old 02-21-2012, 08:28 AM   #2
forums101
 
 
 
Join Date: Feb 2012
Reputation: 0
Posts: 153
I'd also like to mention that I would prefer for there not to be any modding involved.
forums101 is offline   Reply With Quote
Old 02-21-2012, 02:39 PM   #3
¥en
 
Join Date: Apr 2009
Reputation: 6
Posts: 72
Quick question, which game would this be for? Assuming it's for a singleplayer game I'll have a go at creating something to do the job this evening and upload an example for you (assuming I'm successful)
¥en is offline   Reply With Quote
Old 02-21-2012, 02:55 PM   #4
zombie@computer
 
Join Date: Aug 2008
Reputation: 426
Posts: 908
Quote:
Originally Posted by forums101 View Post
Hi, I am trying to create a point system based off of the number of npcs that you kill. I was wondering if this was possible with a math_counter (when you kill an enemy npc the counter increases by a certain amount).

And if this is possible, I want these "points" to be spendable.
EX: You use a func_button (or trigger etc.) to spawn a weapon that costs a certain amount of points, thus when the button is triggered it subtracts the number from the counter (then obviously if you don't have enough points the button will not produce the desired weapon when pressed).

I am sure there are many ways to go about doing this. Any method that would work I would be glad to hear.
yes, you can have a math_counter to keep score, and have any npc onkill add X to the counter. Displaying it is more difficult (you could use the portal2 method as described here :http://www.interlopers.net/tutorials/25686)
You can use logic_compare to create a wicked system of various prices using the math_counters' outvalue and the logic_compare's setvalue or setvaluecompare (so you can make it disable a certain trigger to buy a gun when the math_counter is below 100 and enable that trigger when it is above) etc.
zombie@computer is offline   Reply With Quote
Old 02-21-2012, 03:17 PM   #5
forums101
 
 
 
Join Date: Feb 2012
Reputation: 0
Posts: 153
@ Yen: this is intended for half life 2.
@ Zombie@Computer: thanks ill try that out.
forums101 is offline   Reply With Quote
Old 02-22-2012, 09:02 AM   #6
¥en
 
Join Date: Apr 2009
Reputation: 6
Posts: 72
Ok had some success with creating this system! You start with just a crowbar with every zombie you kill being worth one point. Your point tally is shown on a 7 segment display in front of you and the zombies will continue to spawn until you kill all 30 of them (for the first round). Once they are all dead the 3 buttons can be used to buy weapons of various prices with the 7 segment display updating after you purchase a weapon. You can then hit the restart wave button (the one on the back wall) to start a new wave (each new wave adds 10 more zombies to the total). Obviously this is just a test of a principle and isn't at all optimised for good gameplay, it's also ugly as hell.

Here's a download link for the vmf anyway

Here's a boring overly long-winded explanation of how it actually works (this WILL be tl;dr):

Total Kills Tracking:
The zombies are spawned by 3 separate npc_template_makers which spawn 1 NPC at a time. This allows them to fire off an OnAllLiveChildrenDead output to add 1 to the points total (obviously you could allow more alive children for a harder game and just add more than 1 to the total each time). The overall points total itself is controlled by a simple math_counter with no boundaries.

7 Segment Display:
The display itself is controlled by a math_counter for the units with a max value of 10, every time a spawner fires the OnAllLiveChildrenDead output, 1 is added to the math_counter. This counter then adds one to the tens counter every time it hits it's max value and also resets itself to 0. The actual changes in the 7 segment display are all handled by a logic_case; every time the math_counter updates it fires its value to the logic_case which then determines which brushes to enable/disable based on the value (this was very tedious to set-up and could probably be improved).

Wave End Tracker:
This is just a simple math_counter with a max value of 3, each time one of the 3 NPC spawners is exhausted it adds one to this counter and when the counter hits a max value it displays text to the player and unlocks the shop buttons and the round reset button.

Round Reset Button:
This is also very simple, it adds 10 to each of the spawners and then re-enables them (they have to be re-enabled to start spawning again after being exhausted). It then adds a further 10 to their total so that each round becomes progressively harder.

Weapon "Shops":
The weapon spawning itself just uses point_templates and an env_entity_maker to spawn the weapons, a logic_compare checks the your points total is > the weapon's price and if it is the weapon is spawned. The hard part comes with updating the 7 segment display and this is arguably where this particular system kind of falls down in terms of simplicity of adding new weapons etc. Basically if the weapon's price is < 10 then its price gets passed to another logic_compare, this checks the price against how many "units" you have on the counter. If the units are > the price then it simply updates the units math_counter. However, if it's <= to the price then we have to do a couple more steps, first we add 10 - weapon price to the units and then we take 1 from our tens counter to do the subtraction.

For example, we have a pointsTotal of 23 and want to buy a weapon with a price of 7, a simple bit of subtraction tells us the answer should be 16 but when your tens and units are split into 2 separate values you need to add an extra calculation so: 10 - 7 = 3 therefore 23 + 3 = 26 therefore 26 - 10 = 16.

Apologies if that explanation was actually more confusing than helpful or didn't even make grammatical sense... Anyway, hope this helps!
¥en is offline   Reply With Quote
Old 02-23-2012, 10:10 PM   #7
forums101
 
 
 
Join Date: Feb 2012
Reputation: 0
Posts: 153
Thanks. This helped a lot. The npc spawning, point system and weapon purchasing all works flawlessly and smoothly. But like you mentioned the point counter does seem a little "tedious". I was hoping to display the number of points wherever a player went throughout the map (on the HUD for example), nevertheless it's a good start. And thanks for the help. I will try to work out this point display issue and keep you posted (if I actually find a better solution).

Nice work and once again, thanks.

PS: And no the explanation was not confusing and was most definitely helpful. I really appreciate the detail. Every bit helps.
forums101 is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Level Design


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 02:35 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2014, All Rights Reserved.