NS2 bot

jeffcojeffco Join Date: 2011-02-14 Member: 81785Members
edited January 2012 in Modding
<div class="IPBDescription">jeffco's shot</div>Hello there,... yepp... some of us like to see a basic <a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=115742" target="_blank">bot for NS2</a> that can be used by new players to learn how to command and how to play the game. Unfortunately i do not have enough spare time to develop such a bot entirely on my own, but i am very interested in this and i already created something which is close to being useful. This is what i got so far:

<!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo-->Implemented features<!--sizec--></span><!--/sizec--> (Version 0.4)
<ul><li> automatic bot count adjusting (bots will be removed when normal players join)</li><li> Marine: obeying commander orders</li><li> Marine: building unbuilt structures</li><li> Marine: building of an infantry portal (using the command station)</li><li> Marine: auto attacking</li><li> Marine: power node / player repairing</li><li> Marine: alert triggering (med pack, ammo, orders)</li><li> Skulk: walking to random tech points and resource nozzles</li><li> Skulk: auto attacking</li></ul>
<!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo-->Ideas:<!--sizec--></span><!--/sizec-->
<ul><li> Marine commander?</li><li> Marine: Using the armory to heal, restock, buy weapons</li><li> Marine: Using sprint</li><li> Marine: Picking up med and ammo packs</li><li> Alien commander?</li><li> Alien: Using lerks, gorges, fades</li><li> Alien: Returning to the hive to recover health</li><li> Skulk: Using upgrades</li><li> Skulk: Using leap</li></ul>
<!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo-->Known issues<!--sizec--></span><!--/sizec--> (Version 0.4)
<ul><li> Skulks may get stuck somewhere on the map</li><li> Marines may attack targets without LOS</li></ul>
<!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo-->Source code / Download:<!--sizec--></span><!--/sizec-->

>>> <a href="http://host07.ath.cx/download/NS2/Bot_Jeffco_0.4.zip" target="_blank">Latest Release</a> <<<

or <a href="https://github.com/jeffco/NS2Bot" target="_blank">Development Version</a> (on github)
(I would love to receive some patches!)

<!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo-->Version history:<!--sizec--></span><!--/sizec-->
<ul><li> 0.0 (B189) - initial release with basic marine functionality</li><li> 0.1 (B189) - basic alien support and auto attacking</li><li> 0.2 (B189) - bugfixes, improvements</li><li> 0.3 (B189) - bugfixes, infantry portal building, bot count adjusting</li><li> 0.4 (B189) - power node and player repairing, alert triggering</li></ul>
<!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo-->Installation:<!--sizec--></span><!--/sizec-->

All you have to do is copying Bot.lua and Bot_Jeffco.lua from the zip file (or git repo) into your ns2/lua directory somewhere in your natural selection 2 folder (e.g. C:\Program Files\Steam\steamapps\common\natural selection 2\ns2\lua). There is already a file named Bot.lua that must be overwritten (you may want to create a backup first).

<!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo-->How to use it:<!--sizec--></span><!--/sizec-->

On a local server you have to enable the development mode ("dev 1") or cheats ("cheats 1") first. Then you can use "setbots <count>", "addbot [<count>]" or "removebot [<count>]" to set or change the maximum amount of bots allowed on your server.
On a dedicated server... ... dunno

Comments

  • ZeikkoZeikko Join Date: 2007-12-16 Member: 63179Members, Squad Five Blue, NS2 Map Tester
    Hi Jeffco

    First of all thanks for the great work you have done so far with the basic bot features and releasing them publicly. I have tested each version you have released and spent some time extending the features you have written. Last night I spent quite many hours writing my own bot from scratch because i started getting weird problems with my previous codebase. I ended up copying a lot of stuff from your bot and even though i learned quite a bit yesterday i was also thinking that it would be much more effective to do collaboration on this instead of each of us working on our own code.

    I don't have too much time to spend on this either but i find it a very interesting project because it offers totally different kind of programming challenged than what I tackle daily at work as a web application developer. I am not a huge fan of the gameplay of single player games nor playing FPS against bots, but in NS they make sense especially for aspiring commanders.

    So far i have been focusing on the marine bots and their attack features like stopping whatever the bot is doing and focusing on attacking, more realistic aiming, reflexes and senses. I guess I had quite a bit of luck and got somethign right because they feel pretty good now apart from the occasional slow reaction time. I'm currently uploading a Youtube video as a demonstration.

    So...
    How can I help?
    How are we going to steer and administer this project?
    Can I just start committing stuff?
  • BJHBnade_spammerBJHBnade_spammer Join Date: 2005-02-25 Member: 42431Members
    do you have it hosted on git hub?
  • jeffcojeffco Join Date: 2011-02-14 Member: 81785Members
    First of all, thanks for your interest. I think the easiest way to work corporately would be using the git branch, merge, cherrypick features. Therefore our work should be based on the same code "framework" so that everybody could add and develop features on his own that can then be merged into a master branch whenever these features are ready to be merged. Hence, at first we should focus on finding our codebasis.

    Right now the git repository is hosted on repo.or.cz. I can give access rights there. All i need is your repo.or.cz username. But if reasonable we could transfer to another hoster (github? googlecode?)
  • vizioNzvizioNz InversionNS2.com Join Date: 2003-12-21 Member: 24595Members, Constellation, NS2 Playtester
    Great work Jeff! I'm sure this will be a nice little holiday present for UWE when they get back from the holidays. Keep up the great work bud!
  • ZeikkoZeikko Join Date: 2007-12-16 Member: 63179Members, Squad Five Blue, NS2 Map Tester
    Ups. I accidentally kinda posted to the wrong bot thread but it is relevant to there too. Anyways you can see the video and find the code i was working on yesterday from <a href="http://www.unknownworlds.com/ns2/forums/index.php?s=&showtopic=115742&view=findpost&p=1892144" target="_blank">here</a>
  • ZycaRZycaR Join Date: 2002-11-12 Member: 8263Members
    2 jeffco:
    did you try to write your own target filter?

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function PowerPointFilter()
        return function(target)
            if target:isa("PowerPoint") then
                if not target:GetIsSocketed() or target:GetIsDestroyed() then
                    return false
                end
            end
            return true
        end
    end

    ...


    function BotJeffco:GetStaticAttackTarget()

        local player = self:GetPlayer()

        if not player.staticTargetSelector then
            if player:isa("Marine") then
                player.staticTargetSelector = TargetSelector():Init(
                    player,
                    BotJeffco.kRange,
                    true,
                    { kMarineStaticTargets },
                    { CloakTargetFilter(), CamouflageTargetFilter() })
            end
            if player:isa("Alien") then
                player.staticTargetSelector = TargetSelector():Init(
                    player,
                    BotJeffco.kRange,
                    true,
                    { kAlienStaticTargets },
                    { PowerPointFilter() })
            end
        end
        
        if player.staticTargetSelector then
            player.staticTargetSelector:AttackerMoved()
            return player.staticTargetSelector:AcquireTarget()
        end
    end<!--c2--></div><!--ec2-->

    I hope it will help to filter un-socketed or already destroyed power nodes.
  • fmponefmpone Join Date: 2011-07-05 Member: 108086Members, Squad Five Blue
    Great to see you step up to the plate Jeff. I'm sure your work can be a great foundation for folks to build on.
  • jeffcojeffco Join Date: 2011-02-14 Member: 81785Members
    <!--quoteo(post=1892149:date=Dec 30 2011, 07:04 PM:name=ZycaR)--><div class='quotetop'>QUOTE (ZycaR @ Dec 30 2011, 07:04 PM) <a href="index.php?act=findpost&pid=1892149"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->2 jeffco:
    did you try to write your own target filter?<!--QuoteEnd--></div><!--QuoteEEnd-->
    The TargetCache wasn't causing the issue. It was caused by the "order system" which suggested attacking the destroyed power node. I added a few lines to ignore such orders.
  • BJHBnade_spammerBJHBnade_spammer Join Date: 2005-02-25 Member: 42431Members
    i was asking about git hub because im familiar with it and they have there website where it is easy to dload the repository i dont know what your host has as ive never used it or been to the website to look. if it wouldent be too much trouble if you could make a copy on git hub would be nice.
    also if you do let us know what the link to it is.

    Thanks
  • jeffcojeffco Join Date: 2011-02-14 Member: 81785Members
    <!--quoteo(post=1892850:date=Jan 6 2012, 03:28 PM:name=BJHBnade_spammer)--><div class='quotetop'>QUOTE (BJHBnade_spammer @ Jan 6 2012, 03:28 PM) <a href="index.php?act=findpost&pid=1892850"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->i was asking about git hub because im familiar with it and they have there website where it is easy to dload the repository i dont know what your host has as ive never used it or been to the website to look. if it wouldent be too much trouble if you could make a copy on git hub would be nice.
    also if you do let us know what the link to it is.

    Thanks<!--QuoteEnd--></div><!--QuoteEEnd-->
    <a href="https://github.com/jeffco/NS2Bot" target="_blank">https://github.com/jeffco/NS2Bot</a>
  • BJHBnade_spammerBJHBnade_spammer Join Date: 2005-02-25 Member: 42431Members
    ok thanks. and lol at some of the bot names.

    i guess the next question would be adding bots with out using cheats.
    im sure you would have to implement some sortive login for it so people cannot abuse the adding of bots.
    maby it can be something similar with overmind where it looks for the steam ids.
  • coinecoine Join Date: 2006-11-16 Member: 58631Members, Reinforced - Supporter, Reinforced - Shadow
    Hi and thank you for working on this botprojekt :)

    Got a problem when adding bots, they wont join the game, all staying in rr. Ive tried to force to join side with "addbot 2 1" or "addbot 2 2" but it doesnt work for me. Got this error in console: Script error: lua/bot_jeffco.lua:408:attempt to perform arithmetic on field 'basePitch'(a nil value)lua/bot_jeffco.lua:408(tail call):-1

    Any idea whats going wrong?
  • FragmagnetFragmagnet Join Date: 2010-07-26 Member: 72873Members
    Would it be possible for the bots to turn on their flashlight if they are in a dark place?
    I'd assume so.
  • WombatLOLWombatLOL Join Date: 2011-11-30 Member: 136042Members, Reinforced - Shadow
    <!--quoteo(post=1902724:date=Feb 13 2012, 04:16 PM:name=Fragmagnet)--><div class='quotetop'>QUOTE (Fragmagnet @ Feb 13 2012, 04:16 PM) <a href="index.php?act=findpost&pid=1902724"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Would it be possible for the bots to turn on their flashlight if they are in a dark place?
    I'd assume so.<!--QuoteEnd--></div><!--QuoteEEnd-->

    That would be cool actually.
  • FloodinatorFloodinator [HBZ] Member Join Date: 2005-02-22 Member: 42087Members, Reinforced - Shadow
    Hey still working on the bot?

    To the flashlight, an idea could be to give the Bot also the Structure flag in combination of the PowerPointFilter, so that when the bot is in a unpowered room (structure flag) and the powernode is destroyed (PowerPointFilter) he would turn the flashlight on. But the Bot should be invul against structural DMG (ARC,Bilebomb, etc).
  • 1dominator11dominator1 Join Date: 2010-11-19 Member: 75011Members
    Are you bychance a corporation?
  • KaptainKoolAidzKaptainKoolAidz Join Date: 2012-03-18 Member: 148946Members
    I'm assuming the bots are outdated and no longer work, and my question is; is this project dead? And if it is how would I go about updating this mod for the latest version?
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    The code is on GitHub. The link is in one of the earlier posts. To make your own updates to the mod, just fork the code on GitHub and start making your own version.
  • KaptainKoolAidzKaptainKoolAidz Join Date: 2012-03-18 Member: 148946Members
    My stupid browser just refreshed and I lost my reply, so I'll sum up what I said.

    Basically I've been messing with it and got a bunch of errors to go away. But I have very basic experience with coding, little with lua, and none in NS2. I think what I'm having trouble figuring out is the API I think its called? Idk. Theres bots defaultly in NS2 now, but they lack all pathfinding ability. A question I have is there some basic pathfinding in NS2 already? I'd imagine so since the drifters use it, I think; I havent alien comm'd. So how would I hook into that or w/e and utilize that? and is that how jeffco was doing it, or did he have some other trick?

    Sorry for all the Q's, I desire to contribute to the community but I just need a push in the right direction.
  • private_jokerprivate_joker Join Date: 2012-11-11 Member: 169534Members
    I couldn't get the bot to work. I used the commands but no bots were added to the game. Does this mod not work anymore?

    -Joker
  • MaxunitMaxunit Join Date: 2005-02-01 Member: 39414Members, Reinforced - Shadow
    This bot is highly outdated.

    Here's a more-or-less working one, which is in development: <a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=115742&st=100&start=100" target="_blank">http://www.unknownworlds.com/ns2/forums/in...0&start=100</a>
Sign In or Register to comment.