NS2 bot
<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
<!--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
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?
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?)
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.
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.
also if you do let us know what the link to it is.
Thanks
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>
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.
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?
I'd assume so.
I'd assume so.<!--QuoteEnd--></div><!--QuoteEEnd-->
That would be cool actually.
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).
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.
-Joker
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>