Raised This Month: $32 Target: $400
 8% 

[L4D] Restricted Zones


Post New Thread Reply   
 
Thread Tools Display Modes
SkyVash
New Member
Join Date: Jan 2009
Old 01-11-2009 , 23:59   Re: [L4D] Restricted Zones
Reply With Quote #11

I'm one of Davids friends, he doesn't understand English well

What this does is it keeps the Survivor team from camping in the closet near the elevator, and under the ramp in No Mercy.

What happens when a survivor goes in one of these spots is they get moved by the server and get a message saying "This zone is restricted. You have been moved by the server!" It then moves them back a foot or 2. Infected can still spawn and run in these places without restriction.


Shango - It doesnt seem to cause any more lag then what you normally would get in a server.

Ydiss - I think this only works for Versus mode as the maps are acutally differnet then the Co-op ones, i can however ask David if he could do it for Co-op too tho.
SkyVash is offline
Durzel
Member
Join Date: Aug 2008
Old 01-12-2009 , 10:44   Re: [L4D] Restricted Zones
Reply With Quote #12

I don't think the survivor locations need to be checked every 1/2 second to be honest, if they are teleported far enough away from the restricted area it will take them longer than 1/2 a second to return there (if they were so inclined).

Having a repeatable timer that runs every 1/2 second which executes code which performs a loop & various other non-threadsafe checks is asking for trouble - though I'm a bit of a noob to SourceMod myself - I don't know whether it spawns additional timer threads irrespective of the state of the last one, etc.

Also as far as I can make out the 1/2 second repeatable timer starts running as soon as you load the plugin (irrespective of which map - if any - is loaded) and carries on running regardless of the map or state of the server?

Last edited by Durzel; 01-12-2009 at 10:46.
Durzel is offline
ChillyWI
Senior Member
Join Date: Aug 2008
Old 01-12-2009 , 12:20   Re: [L4D] Restricted Zones
Reply With Quote #13

From looking at the code each location has one restricted point and one destination if the player needs to be teleported from the restricted spot. It runs a distance calculation, looping through all of the points and teleports a player if they're within 50 units. This is definitely the best way to do it, but there's room for optimizations as well.

Here's the best idea I came up with for optimization:
Adjust the timer based on proximity to those locations. This would be a little complex, but would be a great optimization. Let's say all players are currently at least 5000 units from any restricted location. Make your timer sleep for at least 30 seconds. If a player is within 5000 units but not within 1000, make it sleep for 10 seconds. Once a player is within 1000 units, THEN run the function every 500ms. You'd have to calculate acceptable values for these, but the performance gains would be incredible. I'm not sure how timers work in SourcePwn, but I'm sure you could just add a case/switch statement with the distance/timer and have it set a variable for "restarttimer". When the function is run, you'd just check if the current time has reached "restarttimer" and if not just exit the function. Hope this makes sense, since it'd really reduce the load of the plugin.

edit:
Looking closer, you would just have CheckClientCoordinates return an int which would be number of ms until next check. Then LocationCheckThread would calculate the actual time and check the timer value each iteration, immediately exiting if it's not time to run the code yet.

Last edited by ChillyWI; 01-12-2009 at 12:26.
ChillyWI is offline
djromero
Senior Member
Join Date: Dec 2008
Location: Maracaibo, Venezuela
Old 01-12-2009 , 12:21   Re: [L4D] Restricted Zones
Reply With Quote #14

Well, the problem wasn't my english (**** Vash ) but the fact that i was falling asleep when i wrote this ..... (and also when i published it ) ... so please forgive me if i didn't provide much details about it.

Shango: 1/2 seconds won't put much strain on the server, since other mods and the game itself make checks more often than this. I also tried to store as much as i could in variables so it doesn't have to read a file or call an api function so often.

Ydiss: As Keamos said it only checks for spots on 2 VS maps: l4d_vs_hospital04_interior and l4d_vs_hospital05_rooftop. Remember that COOP maps are different from VS ones.

Durzel: Remember that Source Pawn is single-threaded (http://wiki.alliedmods.net/Introduct...uage_Paradigms). But don't worry about it, there's nothing in this mod that would cause any kind of problems. About the 0.5 secs checks, well, i wanted to cause the players the impresion of being pushed back as soon as they tried to get into those spots. About the fact that i'm not checking server-states and stuff ... well, as yourself i'm a bit of a noob to Source Mods, but i'm a very skillfull programmer.

Others: Yes, i will improve this one by adding a command to store coordinates in-game.

I already created a MetaMod pluging for this that allowed you to store coordinates in-game for those restricted spots. Now i'm porting it to SourceMod, because it's a lot easier.
djromero is offline
djromero
Senior Member
Join Date: Dec 2008
Location: Maracaibo, Venezuela
Old 01-12-2009 , 12:23   Re: [L4D] Restricted Zones
Reply With Quote #15

Quote:
Originally Posted by ChillyWI View Post
From looking at the code each location has one restricted point and one destination if the player needs to be teleported from the restricted spot. It runs a distance calculation, looping through all of the points and teleports a player if they're within 50 units. This is definitely the best way to do it, but there's room for optimizations as well.

Here's the best idea I came up with for optimization:
Adjust the timer based on proximity to those locations. This would be a little complex, but would be a great optimization. Let's say all players are currently at least 5000 units from any restricted location. Make your timer sleep for at least 30 seconds. If a player is within 5000 units but not within 1000, make it sleep for 10 seconds. Once a player is within 1000 units, THEN run the function every 500ms. You'd have to calculate acceptable values for these, but the performance gains would be incredible. I'm not sure how timers work in SourcePwn, but I'm sure you could just add a case/switch statement with the distance/timer and have it set a variable for "restarttimer". When the function is run, you'd just check if the current time has reaced "restarttimer" and if not just exit the function. Hope this makes sense, since it'd really reduce the load of the plugin.
Thanks a lot. I really like your idea and i'll put it in practice. I'll release it as soon as i add the command to store coordinates in-game.
djromero is offline
Ydiss
Member
Join Date: Jan 2009
Old 01-12-2009 , 13:35   Re: [L4D] Restricted Zones
Reply With Quote #16

Quote:
Originally Posted by djromero View Post
Well, the problem wasn't my english (**** Vash ) but the fact that i was falling asleep when i wrote this ..... (and also when i published it ) ... so please forgive me if i didn't provide much details about it.

Shango: 1/2 seconds won't put much strain on the server, since other mods and the game itself make checks more often than this. I also tried to store as much as i could in variables so it doesn't have to read a file or call an api function so often.

Ydiss: As Keamos said it only checks for spots on 2 VS maps: l4d_vs_hospital04_interior and l4d_vs_hospital05_rooftop. Remember that COOP maps are different from VS ones.

Durzel: Remember that Source Pawn is single-threaded (http://wiki.alliedmods.net/Introduct...uage_Paradigms). But don't worry about it, there's nothing in this mod that would cause any kind of problems. About the 0.5 secs checks, well, i wanted to cause the players the impresion of being pushed back as soon as they tried to get into those spots. About the fact that i'm not checking server-states and stuff ... well, as yourself i'm a bit of a noob to Source Mods, but i'm a very skillfull programmer.

Others: Yes, i will improve this one by adding a command to store coordinates in-game.

I already created a MetaMod pluging for this that allowed you to store coordinates in-game for those restricted spots. Now i'm porting it to SourceMod, because it's a lot easier.
Thank you

For the record I don't care about Coop. I only play Versus. I also don't think this is as much of an issue in Coop as it is in Versus, so the way it is right now is fine, then.

I'd definitely like a cfg set up to allow me to add or remove locations, though.

Great work.
Ydiss is offline
Durzel
Member
Join Date: Aug 2008
Old 01-12-2009 , 14:22   Re: [L4D] Restricted Zones
Reply With Quote #17

By the way, a few hopefully helpful points:
  1. The timer will run even if a map isn't loaded (i.e. it starts as soon as plugin loads)
  2. The timer will run even on maps where it doesn't need to do anything.
  3. Because of 2) and the way you initialise the coordinates and don't clear them on map end or anything like that the following will happen:
    1. The 1st time the server runs through the No Mercy campaign everything works as designed,
    2. When campaign has finished and server returns to idle the No Mercy finale coordinates are still preserved in memory,
    3. Because you check the coordinates on every map this means that the 2nd time the campaign runs the No Mercy finale restricted spots will be applied even if the map is No Mercy 1-3, or all of Blood Harvest.
    4. Only when it gets to No Mercy 4 does the server return to normal behaviour.
Hope the above makes sense!

Out of curiosity how did you work out the X, Y, Z bounds of the restricted zones in the first place?
Durzel is offline
djromero
Senior Member
Join Date: Dec 2008
Location: Maracaibo, Venezuela
Old 01-12-2009 , 15:15   Re: [L4D] Restricted Zones
Reply With Quote #18

Quote:
Originally Posted by Durzel View Post
By the way, a few hopefully helpful points:
  1. The timer will run even if a map isn't loaded (i.e. it starts as soon as plugin loads)
  2. The timer will run even on maps where it doesn't need to do anything.
  3. Because of 2) and the way you initialise the coordinates and don't clear them on map end or anything like that the following will happen:
    1. The 1st time the server runs through the No Mercy campaign everything works as designed,
    2. When campaign has finished and server returns to idle the No Mercy finale coordinates are still preserved in memory,
    3. Because you check the coordinates on every map this means that the 2nd time the campaign runs the No Mercy finale restricted spots will be applied even if the map is No Mercy 1-3, or all of Blood Harvest.
    4. Only when it gets to No Mercy 4 does the server return to normal behaviour.
Hope the above makes sense!

Out of curiosity how did you work out the X, Y, Z bounds of the restricted zones in the first place?
Thx for your feed back.

I already noted all that and it has been fixed, but i haven't released the new version because i'm still finishing up the console commands to add and delete zones. Also i implemented ChillyWI's suggestion.About the coordinates of the specific spots, i first ran the plugin with a debug message that printed the current coordinates all the time . I use a constant radious of 50 for all spots, but in the next version (the one i'm about to release) you can set the radious for each spot.
__________________
David Romero



Last edited by djromero; 01-12-2009 at 15:19.
djromero is offline
ChillyWI
Senior Member
Join Date: Aug 2008
Old 01-12-2009 , 15:22   Re: [L4D] Restricted Zones
Reply With Quote #19

Quote:
Originally Posted by Durzel View Post
Out of curiosity how did you work out the X, Y, Z bounds of the restricted zones in the first place?
They're single points that he's storing, so I would guess he's just walking into one and getting the coordinates. Makes perfect sense, and should make saving new locations really simple.

edit: Dang it... he edited his post first. At least I was right. ;)
ChillyWI is offline
Durzel
Member
Join Date: Aug 2008
Old 01-12-2009 , 16:05   Re: [L4D] Restricted Zones
Reply With Quote #20

Cool

It's a great idea by the way, I'm keen to see it in action and to see peoples reactions when they find they can't closet camp lol
Durzel is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 23:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode