Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[0.1.3] [client/server] BotCreator
#1
Description:

This is still WIP, so expect bugs

Please report any problems you find, here: Issue Tracker
Wiki (WIP): Wiki Home
Current version: 2.6.3

Adds synchronized bots with AI.

[Image: ugpFzRJ.png]

I am aware that there are already multiple threads with similar projects, but I do believe that this is not just another attempt to synchronize bots. What I am trying to achieve is a simple to use, complete package to a simple bot/AI system anybody can use with minimal effort.

Among the current features of the bots are:
  • Synchronization
  • Warning, chasing and attacking players or other bots
  • Faction system
  • Pathfinding using waypoints
  • Immversive respawn
  • Schedules to be executed at set times of day (ingame time) (send your bot to sleep at 20:00h, wake up at 8:30h for example)
Among the planned features are:
  • Optional module to add hostile bots to the world by default
  • Or better: look into writing a basic Daedalus parser to convert singleplayer NPCs partially to synchronized bots. Possible? (no promises)
  • Parrying (wip-system was taken out for now)
  • Dialogue system (look GUI system)


Installation:

  1. Install my utility scripts: download
  2. Extract G2O_Module_BotCreator.7z
  3. Move resulting folder in the root folder of your server
  4. Add the following to your config.xml:
Code:
<!-- Module BotCreator -->
<import src="G2O_Module_BotCreator/scripts.xml" />




Usage:

Spawning:
Code:
local bot = BotHuman(name, x, y, z, angle, world)
local bot = BotMonster(name, x, y, z, angle, world)
local bot = BotOrcWarrior(name, x, y, z, angle, world)
local bot = BotOrcElite(name, x, y, z, angle, world)
local bot = BotOrcShaman(name, x, y, z, angle, world)
local bot = BotSkeleton(name, x, y, z, angle, world) //clients crash when skeleton dies - don't think that can be fixed by me



Basics:
Code:
bot.setWorld(world)
bot.setInstance(instance)
bot.setPosition(x, y, z)
bot.setAngle(angle)
bot.playAni(ani)
bot.stopAni()
bot.setWeaponMode(mode)
bot.setMaxHealth(maxHealth)
bot.setHealth(health)
bot.setStrength(strength)
bot.setDexterity(dexterity)
bot.setOneH(oneH)
bot.setTwoH(twoH)
bot.setBow(bow)
bot.setCBow(cBow)
bot.equipArmor(armor)
bot.equipMeleeWeapon(meleeWeapon)
bot.equipRangedWeapon(rangedWeapon)
bot.equipShield(shield)
bot.equipHelmet(helmet)
bot.setVisuals(bodyModel, bodyTexture, headModel, headTexture)
bot.setFatness(fatness)



AI:
Code:
bot.getFactionComp().addToFaction(factionname)
bot.getScheduleComp().returnToSchedule(time)

bot.getScheduleComp().addGoto(hour, min, x, y, z) // at given time, goto coordinates using waypoints
bot.getScheduleComp().addSetAngle(hour, min, angle) // at given time, immediately set angle
bot.getScheduleComp().addTurn(hour, min, angle) // at given time, smoothly turn to angle
bot.getScheduleComp().addPlayAni(hour, min, ani, aniLength = 1000) // at given time, play animation once
bot.getScheduleComp().addPlayRandomAni(hour, min, ani, aniLength = 1000) // at given time, play random animation of an animation sequence once
bot.getScheduleComp().addRepeatAni(hour, min, ani, aniLength = 1000, repeatCount = 0) // at given time, repeat animation for repeatCount times (0 = infinitely)
bot.getScheduleComp().addRepeatRandomAni(hour, min, ani, aniLength = 1000, repeatCount = 0) // at given time, repeat random animation of animation sequence
bot.getScheduleComp().addSleep(hour, min, wp, angle) // at given time, go to wp, turn to angle and start sleeping

Examples:

Code:
local novice = BotHuman("novice", 47034, 4990, 19750, 99);

//if registered for the same time of day, the schedule that was added first, will be executed first and vice versa
novice.getScheduleComp().addGoto(15, 0, 47019, 5090, 21527); //at 15:0h, go to 47019|5090|21527
novice.getScheduleComp().addTurn(15, 0, 330); //at 15:0h, turn to angle 330
novice.getScheduleComp().addPlayAni(15, 0,"T_STAND_2_PRAY"); //at 15:0h, play animation "T_STAND_2_PRAY"

Code:
local novice = BotHuman("novice", 47034, 4990, 19750, 99);

novice.getScheduleComp().addSleep(20, 0, "NW_MONASTERY_NOVICE01_06", 238);




Animation:

Bots have an AnimTypeComponent, which holds registered animations for this type of bot. Similar bots share the same AnimTypeComponent.

existing animation types (eg. bot.setAnimTypeComp(ANIMTYPE_HUMAN) -> bot uses human animations):
  • ANIMTYPE_HUMAN
  • ANIMTYPE_MONSTER
  • ANIMTYPE_ORC
  • ANIMTYPE_SKELETON
Animations are stored in the form of animation sequences. They can either be played at random, at a certain index or in succession. Animation sequences can be played through these methods:

Code:
bot.playNextAni(identifier)
bot.playPrevAni(identifier)
bot.playRandomAni(identifier)
bot.playAniAt(identifier, at)

examples:

Code:
bot.playNextAni("attack1h") // plays attackanimations in succession
bot.playPrevAni("attack1h") // plays attackanimations in succession - reversed
bot.playRandomAni("attack1h") // plays attackanimations at random
bot.playAniAt("attack1h", 0) // plays first-registered attackanimation

Some registered animation sequences for humans are:

  • "die"
  • "run"
  • "walk"
  • "warn"
  • "jumpBack"
  • "strafe"
  • "sleep"
  • "wakeup"
  • "draw"
  • "sheath"
  • "attack1h"
  • "attack2h"
  • "attackFist"


Combat:

Bots have a CombatTypeComponent, which holds attributes that define combat behaviour. Similar bots share the same CombatTypeComponent.

existing combat types (eg. bot.setCombatTypeComp(COMBATTYPE_HUM_1H) -> bot behaves like human with onehanded weapon):
  • COMBATTYPE_HUM_FIST
  • COMBATTYPE_HUM_1H
  • COMBATTYPE_HUM_2H
  • COMBATTYPE_MONSTER
  • COMBATTYPE_ORC_2H
  • COMBATTYPE_SKELETON_2H


Events:
  • onBotDead(botId, killerId)
  • onBotRespawn(botId)
  • onBotInView(botId)
  • onBotOutOfView(botId)
  • onBotHit(botId, enemyId)
  • onBotTakeDamage(botId, killerId)
  • onPlayerHitBot(playerId, botId, dmg)


Commands:
  • /botidle <botid>: bot cancels what he is currently doing
  • /botschedule <botid>: bot returns to his current schedule
  • /botgoto <botid>: sends bot to current position of player
  • /botturn <botid>: makes bot turn to current angle of player
  • /botstopani <botid>: makes bot stop current animation
  • /botrun <botid> <0-1>: toggles bot walking/running mode
  • /destroybot: <botid>: destroys bot on server and all clients
  • /pos: shows coordinates of player in the chat
  • /angle: shows angle of player in degrees in the chat
  • /tpbot <fromId> <toId>: teleports player to bot or bot to player


By default, a bunch of bots are spawned in the newworld monastery. They have schedules implemented (work by day, sleep by night) and are capable of fighting enemies.

If you want to test combat go to server/placement/NewWorld.nut and remove comments to spawn a bunch of enemy factions in the newworld monastery.



Download

Repository
Reply
#2
Good! Maybe I'll try to do coop mode with that script on my free time.

(I thought about to do that script long time ago, but I'm to lazy, so thx Big Grin)
Discord: I'm not a spy...#9943.
GG: 60474243.

[Image: OsmithREV.gif]
[Image: 76561198181768479.png]
Reply
#3
Awesome Big Grin
Small update that fixes respawn. Requires redownloading my Utility Scripts, too.
Reply
#4
Update with a bunch of fixes. Respawn should work as intended now, the code is cleaner and targeting is a bit more reliable (still causes issues sometimes but I don't have time to work on this at the moment).

Note that some methods have changed:

ScheduleAction(hour, min, identifier, function, repeat) -> AddSchedule(hour, min, function, repeat)

Damage dealt by bots is now calculated on a client
Reply
#5
So, I went to the monastery to check the bots and their AI. They don't deal any damage to me at all. I don't think wolves dealt any as well. Also, one of the scripts spams "1" in my server console, I'm not sure which one, but It has to be something connected to the bots, as I turned them off to check if that was something wrong on my side. Am I doing something wrong? Big Grin

Edit: Whoops, my fault. Bots deal damage to me, I just had 10k health so I didn't actually see the health bar going lower. Sadly, I still can't fix console spam :/ Any advices?
Reply
#6
search function that make that spam. Look for print. if u use notepad ++ just serach>look in file> print Smile
Reply
#7
(22.01.2018, 18:51)Quarchodron Wrote: search function that make that spam. Look for print. if u use notepad ++ just serach>look in file> print Smile

Well, I've tried that. I have no clue what's causing this.

Edit: Okay I got it. There was a "print(packet.ID)" in server/packets.nut file. No idea why it's there but this is what was causing the spam. I should spend more time on finding the problem myself other then spamming on the forum. Sorry ^^
Reply
#8
I see 1 error, while player is staying afk, wolf will stay afk too instead of attacking/jumping back from player in fight.

Anyway good job, very useful script for whole users Smile
[Image: pjDBIfE.gif]
Reply
#9
The combat generally still needs an overhaul. I'm on it
Reply
#10
Update 2.0 - requires new version of Util scripts

This is almost a rewrite of most aspects of the AI. It should use less memory, work more reliably and the code is a lot cleaner. Combat got an overhaul too in the process and should work a lot better now.

Note that a lot of things have changed. Adding schedules for example is a lot more streamlined now, requires rewriting any existing schedules though. Look at instructions in OP or server/placement/NewWorld.nut to find out more.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Server] ORM Quarchodron 3 3,444 08.07.2020, 10:19
Last Post: Quarchodron
  [0.1.3] [server] ItemGroundSpawner HammelGammel 1 4,041 05.02.2020, 18:40
Last Post: demor140202
  [Client] Version check Quarchodron 2 4,011 25.08.2019, 14:06
Last Post: Quarchodron
  [Client] GUI Creator Quarchodron 6 7,517 12.08.2019, 23:05
Last Post: Arkhan
  [New G2O][Client-Side] bindKey Patrix 6 8,970 14.11.2018, 02:32
Last Post: Patrix
  [0.1.4.*] [client/server] Simple anty-cheat Profesores 8 10,248 20.03.2018, 19:16
Last Post: Patrix
  [0.1.3] [client/server] Utility Scripts HammelGammel 1 5,253 27.01.2018, 14:03
Last Post: HammelGammel
  [G2O v.0.1.2][Server-Side] NPC Manager Quarchodron 16 17,490 21.01.2018, 19:59
Last Post: Quarchodron
  [New G2O][Client-Side] Key Combination Patrix 1 3,784 23.12.2017, 13:16
Last Post: Patrix
  [CLIENT]Draw(Line/Color) Tommy 0 3,118 19.12.2017, 04:23
Last Post: Tommy

Forum Jump:


Users browsing this thread: 3 Guest(s)