Sentry Limit Mod

twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
edited September 2011 in Modding
<div class="IPBDescription">Sentry, Sentry, Sentry and Spam is not on the menu</div><!--coloro:#FF0000--><span style="color:#FF0000"><!--/coloro-->(for Build 185)<!--colorc--></span><!--/colorc-->

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: <a href="http://www.mediafire.com/?xc2a57y74y151zl" target="_blank">Download Sentry Limit mod v2</a>

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: <a href="http://www.mediafire.com/?8e8yz0y91iy24ky" target="_blank">Sentry Limit mod v1</a> (replaces default NS2Utility.lua)

Notes: Server admin can tweak the two variables near the top of the file
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->kSentryBuildRadius = 21
kMaxSentryInArea = 3<!--QuoteEnd--></div><!--QuoteEEnd-->

Thanks to <b>FocusedWolf</b>, for improvements to the mod! Hopefully it will continue to work beyond build 185.

Comments

  • HackepeterHackepeter Join Date: 2003-06-08 Member: 17107Members, 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.
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1872285:date=Aug 31 2011, 05:59 AM:name=Hackepeter)--><div class='quotetop'>QUOTE (Hackepeter @ Aug 31 2011, 05:59 AM) <a href="index.php?act=findpost&pid=1872285"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->
    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: 17107Members, Constellation
    <!--quoteo(post=1872296:date=Aug 31 2011, 05:23 PM:name=twiliteblue)--><div class='quotetop'>QUOTE (twiliteblue @ Aug 31 2011, 05:23 PM) <a href="index.php?act=findpost&pid=1872296"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->

    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: 13116Members, 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: 42471NS1 Playtester, Forum Moderators, Constellation
    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.
  • HackepeterHackepeter Join Date: 2003-06-08 Member: 17107Members, Constellation
    <!--quoteo(post=1872420:date=Sep 1 2011, 04:54 AM:name=twiliteblue)--><div class='quotetop'>QUOTE (twiliteblue @ Sep 1 2011, 04:54 AM) <a href="index.php?act=findpost&pid=1872420"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->

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

    <!--quoteo(post=1872426:date=Sep 1 2011, 05:05 AM:name=aeroripper)--><div class='quotetop'>QUOTE (aeroripper @ Sep 1 2011, 05:05 AM) <a href="index.php?act=findpost&pid=1872426"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->

    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: 16247Members, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Developer
    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: 13116Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1872449:date=Sep 1 2011, 12:06 AM:name=Hackepeter)--><div class='quotetop'>QUOTE (Hackepeter @ Sep 1 2011, 12:06 AM) <a href="index.php?act=findpost&pid=1872449"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->
    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: 24595Members, 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: 34258Members
    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): <a href="http://pastebin.com/gUH8YzkL" target="_blank">http://pastebin.com/gUH8YzkL</a>

    This version has comments explaining the various changes: <a href="http://pastebin.com/L7P8BSFU" target="_blank">http://pastebin.com/L7P8BSFU</a>

    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?
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, 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: <a href="http://pastebin.com/ynQE6vkj" target="_blank">http://pastebin.com/ynQE6vkj</a>
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Members
    edited September 2011
    <!--quoteo(post=1872634:date=Sep 1 2011, 10:01 PM:name=twiliteblue)--><div class='quotetop'>QUOTE (twiliteblue @ Sep 1 2011, 10:01 PM) <a href="index.php?act=findpost&pid=1872634"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I've edited your code slightly. Here's my version: <a href="http://pastebin.com/ynQE6vkj" target="_blank">http://pastebin.com/ynQE6vkj</a><!--QuoteEnd--></div><!--QuoteEEnd-->

    Ya the XZ check makes sense, but i see GetTeamNumber() is back. It's easy to remove again by implementing the missing "GetEntitiesWithinXZRange" function: <a href="http://pastebin.com/ruLiA5Ws" target="_blank">http://pastebin.com/ruLiA5Ws</a> (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.
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1872653:date=Sep 1 2011, 09:14 PM:name=FocusedWolf)--><div class='quotetop'>QUOTE (FocusedWolf @ Sep 1 2011, 09:14 PM) <a href="index.php?act=findpost&pid=1872653"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Ya the XZ check makes sense, but i see GetTeamNumber() is back. It's easy to remove again by implementing the missing "GetEntitiesWithinXZRange" function: <a href="http://pastebin.com/ruLiA5Ws" target="_blank">http://pastebin.com/ruLiA5Ws</a> (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)<!--QuoteEnd--></div><!--QuoteEEnd-->

    Was GetTeamNumber() misbehaving? :P I don't seem to have any trouble running that code I posted.
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Members
    edited September 2011
    <!--quoteo(post=1872676:date=Sep 2 2011, 03:55 AM:name=twiliteblue)--><div class='quotetop'>QUOTE (twiliteblue @ Sep 2 2011, 03:55 AM) <a href="index.php?act=findpost&pid=1872676"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Was GetTeamNumber() misbehaving? :P I don't seem to have any trouble running that code I posted.<!--QuoteEnd--></div><!--QuoteEEnd-->

    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.
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
    edited September 2011
    <!--quoteo(post=1872727:date=Sep 2 2011, 08:56 AM:name=FocusedWolf)--><div class='quotetop'>QUOTE (FocusedWolf @ Sep 2 2011, 08:56 AM) <a href="index.php?act=findpost&pid=1872727"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->
    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
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Members
    edited September 2011
    <!--quoteo(post=1872830:date=Sep 2 2011, 09:55 PM:name=twiliteblue)--><div class='quotetop'>QUOTE (twiliteblue @ Sep 2 2011, 09:55 PM) <a href="index.php?act=findpost&pid=1872830"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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<!--QuoteEnd--></div><!--QuoteEEnd-->

    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: <a href="http://pastebin.com/ruLiA5Ws" target="_blank">http://pastebin.com/ruLiA5Ws</a> 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: <a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=112425" target="_blank">http://www.unknownworlds.com/ns2/forums/in...howtopic=112425</a> 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.
  • dePARAdePARA Join Date: 2011-04-29 Member: 96321Members, Squad Five Blue
    The download-link didnt work :(
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
    edited September 2011
    <!--quoteo(post=1872847:date=Sep 2 2011, 10:52 PM:name=dePARA)--><div class='quotetop'>QUOTE (dePARA @ Sep 2 2011, 10:52 PM) <a href="index.php?act=findpost&pid=1872847"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->The download-link didnt work :(<!--QuoteEnd--></div><!--QuoteEEnd-->
    Oops looks like the link changed when I updated it. I'll put it back up shortly!
    (Update: New version is up! Thanks FocusedWolf!)
  • dePARAdePARA Join Date: 2011-04-29 Member: 96321Members, 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.
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1872856:date=Sep 3 2011, 12:42 AM:name=dePARA)--><div class='quotetop'>QUOTE (dePARA @ Sep 3 2011, 12:42 AM) <a href="index.php?act=findpost&pid=1872856"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->
    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: 96321Members, Squad Five Blue
    But if i run it as a mod, overmind wont work. And this is essential for a server.
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Members
    edited September 2011
    <!--quoteo(post=1872863:date=Sep 3 2011, 04:39 AM:name=dePARA)--><div class='quotetop'>QUOTE (dePARA @ Sep 3 2011, 04:39 AM) <a href="index.php?act=findpost&pid=1872863"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->But if i run it as a mod, overmind wont work. And this is essential for a server.<!--QuoteEnd--></div><!--QuoteEEnd-->

    I didn't test this, but i'm guessing it will work. Try copying the lua file to the NS2GmOvrmind\Lua folder.
  • playerplayer Join Date: 2010-09-12 Member: 73982Members
    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: 16247Members, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Developer
    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)

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

    <!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo--><a href="http://www.mediafire.com/?lxp06ti7l3j5me3" target="_blank">Structure Limit Mod</a><!--sizec--></span><!--/sizec--> (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
  • woodywoody SoCal Woody56 Join Date: 2004-02-14 Member: 26541Members
    Second version: Download Sentry Limit mod v2

    this work with latest build ?
  • MiniH0wieMiniH0wie Join Date: 2007-11-25 Member: 63013Members
    <!--quoteo(post=2065144:date=Jan 22 2013, 05:18 PM:name=woody)--><div class='quotetop'>QUOTE (woody @ Jan 22 2013, 05:18 PM) <a href="index.php?act=findpost&pid=2065144"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Second version: Download Sentry Limit mod v2

    this work with latest build ?<!--QuoteEnd--></div><!--QuoteEEnd-->


    Not really needed anymore since the latest build only allows 3 sentries per room.
  • woodywoody SoCal Woody56 Join Date: 2004-02-14 Member: 26541Members
    Yea thats what I want to change, the number and range but can't seem to find it
Sign In or Register to comment.