Sentry Limit Mod

twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Posts: 1,728Members, NS2 Playtester, Squad Five Blue
edited September 2011 in Modding
Sentry, Sentry, Sentry and Spam is not on the menu
(for Build 185)

I've created a mod for limiting Sentries.
The initial setting limits 3 Sentries in an area with radius of 21. (The range of Sentry is 20.)


To use this mod, first place the downloaded zip into your "natural selection 2" folder.
Then start your ns2.exe with the option "-game mod_sentrylimit" (or whatever you renamed the zip file.)


Second version: Download Sentry Limit mod v2

Installation:
1. Extract zip into your "natural selection 2\ns2\lua" directory.
2. Edit your natural selection 2\ns2\lua\Shared.lua and add the following line:
Script.Load("lua/SentryLimitMod.lua").



Old working version: Sentry Limit mod v1 (replaces default NS2Utility.lua)

Notes: Server admin can tweak the two variables near the top of the file
QUOTE
kSentryBuildRadius = 21
kMaxSentryInArea = 3


Thanks to FocusedWolf, for improvements to the mod! Hopefully it will continue to work beyond build 185.
Post edited by Unknown User on

Comments

  • HackepeterHackepeter Join Date: 2003-06-08 Member: 17107Posts: 181Members, Constellation
    edited August 2011
    Works nice, good job! Seams like the server is sending error messages at every tick if the build is blocked, but that's not your fault.

    I hope server admins will use your script! In my opinion it's much better to avoid sentry spam on the server side than kicking player after doing it.
    Post edited by Unknown User on
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Posts: 1,728Members, NS2 Playtester, Squad Five Blue
    QUOTE (Hackepeter @ Aug 31 2011, 05:59 AM) »
    Works nice, good job! Seams like the server is sending error messages at every tick if the build is blocked, but that's not your fault.

    I hope server admins will use your script! In my opinion it's much better to avoid sentry spam on the server side than kicking player after doing it.

    I know, the function is called every tick, which isn't very efficient (not my code!). IMO it should only send an error when the client sends the command to place the entity (by LClicking). But I don't have the time to optimize it. I also tried to check its server load with the profiler, but it doesn't appear to be significant.
  • HackepeterHackepeter Join Date: 2003-06-08 Member: 17107Posts: 181Members, Constellation
    QUOTE (twiliteblue @ Aug 31 2011, 05:23 PM) »
    I know, the function is called every tick, which isn't very efficient (not my code!). IMO it should only send an error when the client sends the command to place the entity (by LClicking). But I don't have the time to optimize it. I also tried to check its server load with the profiler, but it doesn't appear to be significant.


    Yeah don't worry about that it's working good. I just saw that HBZ already installed it to their server and it didn't explode, so all fine there ^^
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Posts: 1,728Members, NS2 Playtester, Squad Five Blue
    Gorges don't seem to obey these rules. Hydras and Mini-cysts spam can be a problem. I won't have the time to find a fix that this week, unfortunately.
  • aeroripperaeroripper Join Date: 2005-02-25 Member: 42471Posts: 1,994NS1 Playtester, Forum Moderators, Constellation mod
    edited August 2011
    You should go further. Have a hard limit of 4 sentries per robotics factory. Turrets should only augment base defense with your own marines, not be "the" base defense. This will also make it so commanders place them more wisely instead of spamming them everywhere as a strategy. Focus less on building turrets, and more on getting upgrades for your team.
    Post edited by Unknown User on
  • HackepeterHackepeter Join Date: 2003-06-08 Member: 17107Posts: 181Members, Constellation
    QUOTE (twiliteblue @ Sep 1 2011, 04:54 AM) »
    Gorges don't seem to obey these rules. Hydras and Mini-cysts spam can be a problem. I won't have the time to find a fix that this week, unfortunately.


    Thanks to the grenade launcher alien spam isn't a real problem. A few nades kill every hydra garden.

    QUOTE (aeroripper @ Sep 1 2011, 05:05 AM) »
    You should go further. Have a hard limit of 4 sentries per robotics factory. Turrets should only augment base defense with your own marines, not be "the" base defense. This will also make it so commanders place them more wisely instead of spamming them everywhere as a strategy. Focus less on building turrets, and more on getting upgrades for your team.


    No. Turret spam usually appears at the end game if the marines already have all upgrades. Besides the "turret factory" concept itself I don't think it's a good idea do make such an intervention in the current game play because I think it would disturb a realistic beta testing progress to much. Such changes should be better put in alternatives like Schimmels PT-mod.
  • SewlekSewlek The programmer previously known as Schimmel Join Date: 2003-05-13 Member: 16247Posts: 2,303Members, NS2 Developer, NS2 Playtester
    I think I will add that robo factory stuff. But I'm not sure about an "artificial" limit. At first I will simply make the robo factory - sentry relation be the same as it was in NS1. And since the robo factory takes a lot of place away, we already are limiting sentry spam (just have to adjust the radius of the robo factory)
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Posts: 1,728Members, NS2 Playtester, Squad Five Blue
    QUOTE (Hackepeter @ Sep 1 2011, 12:06 AM) »
    Thanks to the grenade launcher alien spam isn't a real problem. A few nades kill every hydra garden.

    No. Turret spam usually appears at the end game if the marines already have all upgrades. Besides the "turret factory" concept itself I don't think it's a good idea do make such an intervention in the current game play because I think it would disturb a realistic beta testing progress to much. Such changes should be better put in alternatives like Schimmels PT-mod.

    What I meant was that Hydras spam can be abused to create unnecessary load on the server, as you can literally spam a hundred Hydras in each room, due to the lack of entity count checking mechanism.
  • vizioNzvizioNz InversionNS2.com Join Date: 2003-12-21 Member: 24595Posts: 661Members, Constellation, NS2 Playtester
    Any chance you can also post this in the MODs section over at AnagramNS2.com? We are going to try and implement it on our AnagramNS2.com | Chicago servers if it's stable.
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Posts: 1,260Members
    edited September 2011
    Nice mod twiliteblue.

    I will say this though. People should be warned not to set kSentryBuildRadius to large or else it will prevent sentry building in adjacent rooms.

    Also, i reduced your mods code if your're interested (it's certainly less likely to break now between versions): http://pastebin.com/gUH8YzkL

    This version has comments explaining the various changes: http://pastebin.com/L7P8BSFU

    Btw, is it really necessary to show the error message. I mean i guess it is because it's not the vanilla behavior and people will wonder why they can't build fields of turrents. But maybe they'll figure it out when the turrent doesn't drop?
    Post edited by Unknown User on
    The enemy cannot eat an IP, if you disable its head!
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Posts: 1,728Members, NS2 Playtester, Squad Five Blue
    edited September 2011
    Thanks so much for that, FocusedWolf! It's a lot neater than my original hack.

    I think the error message is essential for giving user feedback. It's a quicker way of giving info, than having to ask another player, or forum admin.

    I've edited your code slightly. Here's my version: http://pastebin.com/ynQE6vkj
    Post edited by Unknown User on
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Posts: 1,260Members
    edited September 2011
    QUOTE (twiliteblue @ Sep 1 2011, 10:01 PM) »
    I've edited your code slightly. Here's my version: http://pastebin.com/ynQE6vkj


    Ya the XZ check makes sense, but i see GetTeamNumber() is back. It's easy to remove again by implementing the missing "GetEntitiesWithinXZRange" function: http://pastebin.com/ruLiA5Ws (i'm only light testing this but i'm not seeing any issues with skipping the team check... like it's not showing up when dropping 5+ whips... that's about the extent of my testing :P)

    Ya the thing with the error message that i found annoying was how long that tooltip lingers. At first it seemed to be showing incorrectly despite the fact that a ghost sentry (indicating a valid placement) was visible, but if you wait like 5+ seconds the message will disappear, so it really is testing where the cursor is. Just seemed weird at first.

    EDIT: Lol just noticed their's a sort of buzzing sound when trying to drop a turrent close to 4 sentries... it's the sound of a million tooltips getting shown.
    Post edited by Unknown User on
    The enemy cannot eat an IP, if you disable its head!
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Posts: 1,728Members, NS2 Playtester, Squad Five Blue
    QUOTE (FocusedWolf @ Sep 1 2011, 09:14 PM) »
    Ya the XZ check makes sense, but i see GetTeamNumber() is back. It's easy to remove again by implementing the missing "GetEntitiesWithinXZRange" function: http://pastebin.com/ruLiA5Ws (i'm only light testing this but i'm not seeing any issues with skipping the team check... like it's not showing up when dropping 5+ whips... that's about the extent of my testing :P)


    Was GetTeamNumber() misbehaving? :P I don't seem to have any trouble running that code I posted.
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Posts: 1,260Members
    edited September 2011
    QUOTE (twiliteblue @ Sep 2 2011, 03:55 AM) »
    Was GetTeamNumber() misbehaving? :P I don't seem to have any trouble running that code I posted.


    No their's nothing functionally wrong with your code. It's just going to be slightly (unnoticeably) less efficient with the team check. That's assuming the team check is unnecessary.
    Post edited by Unknown User on
    The enemy cannot eat an IP, if you disable its head!
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Posts: 1,728Members, NS2 Playtester, Squad Five Blue
    edited September 2011
    QUOTE (FocusedWolf @ Sep 2 2011, 08:56 AM) »
    No their's nothing functionally wrong with your code. It's just going to be slightly (unnoticeably) less efficient with the team check. That's assuming the team check is unnecessary.

    You understand LUA a lot better than me. Looks like your solution is more efficient for our need (until both teams can build Sentries). :D
    Post edited by Unknown User on
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Posts: 1,260Members
    edited September 2011
    QUOTE (twiliteblue @ Sep 2 2011, 09:55 PM) »
    You understand LUA a lot better than me. Looks like your solution is more efficient for our need (until both teams can build Sentries). :D


    Aka i made more mistakes, and here's another xD: The sillyness i did with base_CheckBuildEntityRequirements wasn't necessary (wrapping with if statement). Updated code: http://pastebin.com/ruLiA5Ws In the past i needed to do something like that but i don't think it's needed for this situation.

    For example, story time: http://www.unknownworlds.com/ns2/forums/in...howtopic=112425 I learned a lot of the techniques for overloading stuff from the Player_Client.lua of that mod. But in the process of saving changes to files i found that mods approach to not handle code reloads right.

    Then through some trial and error i figured out a way that worked through reloads (this is for overloading member functions of a class only):

    if not GUIMarineHUD.base_Initialize then
    GUIMarineHUD.base_Initialize = GUIMarineHUD.Initialize
    end

    function GUIMarineHUD:Initialize()

    GUIMarineHUD.base_Initialize(self)

    ... added code goes here
    end

    But i'm thinking for your mod it's not necessary because everything is global functions.
    Post edited by Unknown User on
    The enemy cannot eat an IP, if you disable its head!
  • dePARAdePARA Join Date: 2011-04-29 Member: 96321Posts: 723Members, Squad Five Blue
    The download-link didnt work :(
    image
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Posts: 1,728Members, NS2 Playtester, Squad Five Blue
    edited September 2011
    QUOTE (dePARA @ Sep 2 2011, 10:52 PM) »
    The download-link didnt work :(

    Oops looks like the link changed when I updated it. I'll put it back up shortly!
    (Update: New version is up! Thanks FocusedWolf!)
    Post edited by Unknown User on
  • dePARAdePARA Join Date: 2011-04-29 Member: 96321Posts: 723Members, Squad Five Blue
    Thx for new version.

    But how can i integrate it. I mean, if i replace the original-one with this version, i think im going to break the game.
    image
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Posts: 1,728Members, NS2 Playtester, Squad Five Blue
    QUOTE (dePARA @ Sep 3 2011, 12:42 AM) »
    Thx for new version.

    But how can i integrate it. I mean, if i replace the original-one with this version, i think im going to break the game.

    Oops I forgot to mention that. :P

    You have to run it as a mod, so it can load the original NS2Utility.lua.
  • dePARAdePARA Join Date: 2011-04-29 Member: 96321Posts: 723Members, Squad Five Blue
    But if i run it as a mod, overmind wont work. And this is essential for a server.
    image
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Posts: 1,260Members
    edited September 2011
    QUOTE (dePARA @ Sep 3 2011, 04:39 AM) »
    But if i run it as a mod, overmind wont work. And this is essential for a server.


    I didn't test this, but i'm guessing it will work. Try copying the lua file to the NS2GmOvrmind\Lua folder.
    Post edited by Unknown User on
    The enemy cannot eat an IP, if you disable its head!
  • playerplayer Join Date: 2010-09-12 Member: 73982Posts: 1,677Members
    It won't load the Lua-file just because it is in the Lua-directory, it actually has to be part of the script-hierarchy.

    A bit of a guess, but if you download the latest version, rename "SentryLimitMod.lua" to "NS2Utility.lua", and then place it in the NS2GmOvrmind/Lua-directory, it should properly override the default NS2Utility.lua (but still load it manually in the first line).
  • SewlekSewlek The programmer previously known as Schimmel Join Date: 2003-05-13 Member: 16247Posts: 2,303Members, NS2 Developer, NS2 Playtester
    edited November 2011
    i thought it's not worth an own thread, and since i also added the sentry limit mod this here is the best place to post it:
    Structure Limit Mod for build 188:

    - hydras are now affected by the global entity limit (same as commanders have)
    - seperate hydra per area limitation
    - mini cyst per area limitation
    - sentry limitation

    i already tried to optimize those numbers. if you want to keep your servers stable, you might only edit the sentry limitations and keep the cyst and hydra. Those two are responsible to some higher degree for bad server performance.

    simply extract the files and overwrite the lua folder with the one in the zip, you can edit the limitations by:

    for hydra open lua/Weapon/alien/HydraAbility.lua and change the variable on top of the file.
    same for lua/Weapon/alien/CystAbility.lua
    and sentry limitations are defined in lua/NS2Utility.lua on top of the file

    i also included my hotfixes for build 188 (power node repair rate, GL / healspray bug, script errors fixes)

    update: I merged it with the hotfix release. it's serving the same purpose (improving server performance)

    Structure Limit Mod (188_fixes_b)

    edit: before i get feedback that the cyst limitation is not working: it only applies to the mini cysts, and is therefor also only checking for mini cysts in a specific area! the commander can still place normal cysts as before, which i don't see as a problem because they tend to use their energy more wisely and i don't want to prevent the "cyst rush" tactic :D
    Post edited by Unknown User on
  • woodywoody 192.210.148.243:27016 [KcK] SoCal..Kustom Maps Join Date: 2004-02-14 Member: 26541Posts: 259Members
    Second version: Download Sentry Limit mod v2

    this work with latest build ?
    192.210.148.243:27016 SoCal..ComBat....[KcK]
  • MiniH0wieMiniH0wie Join Date: 2007-11-25 Member: 63013Posts: 526Members
    QUOTE (woody @ Jan 22 2013, 05:18 PM) »
    Second version: Download Sentry Limit mod v2

    this work with latest build ?



    Not really needed anymore since the latest build only allows 3 sentries per room.
    Skulks to the left of the me, Fades to the right, here I am, Stuck in the middle with noobs.

    image


  • woodywoody 192.210.148.243:27016 [KcK] SoCal..Kustom Maps Join Date: 2004-02-14 Member: 26541Posts: 259Members
    Yea thats what I want to change, the number and range but can't seem to find it
    192.210.148.243:27016 SoCal..ComBat....[KcK]
Sign In or Register to comment.