X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fdefault%2Fbot.qc;h=3b9dd7c60ccd8a5b878bb9a01a5e3e2b4a91442c;hb=5444bd39fcdcc064f706f3dea516dbc29e3b06a0;hp=bdde55b9aa94683b7ffb0901229203fb1ff59116;hpb=ac9fba402abf745436adf0ecaa8f90347708ff53;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index bdde55b9a..3b9dd7c60 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -45,6 +46,7 @@ entity bot_spawn() entity bot = spawnclient(); if (bot) { + setItemGroupCount(); currentbots = currentbots + 1; bot_setnameandstuff(bot); ClientConnect(bot); @@ -62,7 +64,8 @@ void bot_think(entity this) if(autocvar_bot_god) this.flags |= FL_GODMODE; - this.bot_nextthink = this.bot_nextthink + autocvar_bot_ai_thinkinterval * pow(0.5, this.bot_aiskill); + this.bot_nextthink = max(time, this.bot_nextthink) + max(0.01, autocvar_bot_ai_thinkinterval * (0.5 ** this.bot_aiskill) * min(14 / (skill + 14), 1)); + //if (this.bot_painintensity > 0) // this.bot_painintensity = this.bot_painintensity - (skill + 1) * 40 * frametime; @@ -71,6 +74,7 @@ void bot_think(entity this) if (!IS_PLAYER(this) || (autocvar_g_campaign && !campaign_bots_may_start)) { + this.movement = '0 0 0'; this.bot_nextthink = time + 0.5; return; } @@ -117,6 +121,7 @@ void bot_think(entity this) // if dead, just wait until we can respawn if (IS_DEAD(this)) { + this.movement = '0 0 0'; if (this.deadflag == DEAD_DEAD) { PHYS_INPUT_BUTTON_JUMP(this) = true; // press jump to respawn @@ -203,7 +208,13 @@ void bot_setnameandstuff(entity this) prio = 6; - #define READSKILL(f,w,r) if(argv(prio) != "") this.f = stof(argv(prio)) * (w); else this.f = (!autocvar_g_campaign) * (2 * random() - 1) * (r) * (w); ++prio + #define READSKILL(f, w, r) MACRO_BEGIN { \ + if(argv(prio) != "") \ + this.f = stof(argv(prio)) * w; \ + else \ + this.f = (!autocvar_g_campaign) * (2 * random() - 1) * r * w; \ + prio++; \ + } MACRO_END //print(bot_name, ": ping=", argv(9), "\n"); READSKILL(havocbot_keyboardskill, 0.5, 0.5); // keyboard skill @@ -337,9 +348,8 @@ void bot_custom_weapon_priority_setup() void bot_endgame() { - entity e; - //dprint("bot_endgame\n"); - e = bot_list; + bot_relinkplayerlist(); + entity e = bot_list; while (e) { setcolor(e, e.bot_preferredcolors); @@ -364,14 +374,13 @@ void bot_relinkplayerlist() if(prevbot) prevbot.nextbot = it; else - { bot_list = it; - bot_list.nextbot = NULL; - } prevbot = it; ++currentbots; } }); + if(prevbot) + prevbot.nextbot = NULL; LOG_TRACE("relink: ", ftos(currentbots), " bots seen."); bot_strategytoken = bot_list; bot_strategytoken_taken = true; @@ -396,7 +405,7 @@ void bot_clientdisconnect(entity this) this.playerskin_freeme = string_null; if(this.bot_cmd_current) delete(this.bot_cmd_current); - if(bot_waypoint_queue_owner==this) + if(bot_waypoint_queue_owner == this) bot_waypoint_queue_owner = NULL; } @@ -524,18 +533,18 @@ void autoskill(float factor) bestbot = max(bestbot, it.totalfrags - it.totalfrags_lastcheck); )); - LOG_TRACE("autoskill: best player got ", ftos(bestplayer), ", "); - LOG_TRACE("best bot got ", ftos(bestbot), "; "); + LOG_DEBUG("autoskill: best player got ", ftos(bestplayer), ", "); + LOG_DEBUG("best bot got ", ftos(bestbot), "; "); if(bestbot < 0 || bestplayer < 0) { - LOG_TRACE("not doing anything"); + LOG_DEBUG("not doing anything"); // don't return, let it reset all counters below } else if(bestbot <= bestplayer * factor - 2) { if(autocvar_skill < 17) { - LOG_TRACE("2 frags difference, increasing skill"); + LOG_DEBUG("2 frags difference, increasing skill"); cvar_set("skill", ftos(autocvar_skill + 1)); bprint("^2SKILL UP!^7 Now at level ", ftos(autocvar_skill), "\n"); } @@ -544,14 +553,14 @@ void autoskill(float factor) { if(autocvar_skill > 0) { - LOG_TRACE("2 frags difference, decreasing skill"); + LOG_DEBUG("2 frags difference, decreasing skill"); cvar_set("skill", ftos(autocvar_skill - 1)); bprint("^1SKILL DOWN!^7 Now at level ", ftos(autocvar_skill), "\n"); } } else { - LOG_TRACE("not doing anything"); + LOG_DEBUG("not doing anything"); return; // don't reset counters, wait for them to accumulate } @@ -562,9 +571,8 @@ void autoskill(float factor) void bot_calculate_stepheightvec() { stepheightvec = autocvar_sv_stepheight * '0 0 1'; - jumpstepheightvec = stepheightvec + - ((autocvar_sv_jumpvelocity * autocvar_sv_jumpvelocity) / (2 * autocvar_sv_gravity)) * '0 0 0.85'; - // 0.75 factor is for safety to make the jumps easy + jumpheight_vec = (autocvar_sv_jumpvelocity ** 2) / (2 * autocvar_sv_gravity) * '0 0 1'; + jumpstepheightvec = stepheightvec + jumpheight_vec * 0.85; // reduce it a bit to make the jumps easy } float bot_fixcount() @@ -629,14 +637,60 @@ float bot_fixcount() return true; } +void bot_remove_from_bot_list(entity this) +{ + entity e = bot_list; + entity prev_bot = NULL; + while (e) + { + if(e == this) + { + if(!prev_bot) + bot_list = this.nextbot; + else + prev_bot.nextbot = this.nextbot; + if(bot_strategytoken == this) + { + bot_strategytoken = this.nextbot; + bot_strategytoken_taken = true; + } + this.nextbot = NULL; + break; + } + prev_bot = e; + e = e.nextbot; + } +} + +void bot_clear(entity this) +{ + bot_remove_from_bot_list(this); + if(bot_waypoint_queue_owner == this) + bot_waypoint_queue_owner = NULL; + this.aistatus &= ~AI_STATUS_STUCK; // otherwise bot_waypoint_queue_owner will be set again to this by navigation_unstuck +} + void bot_serverframe() { - if (intermission_running) + if (game_stopped) return; if (time < 2) return; + if(autocvar_skill != skill) + { + float wpcost_update = false; + if(skill >= autocvar_bot_ai_bunnyhop_skilloffset && autocvar_skill < autocvar_bot_ai_bunnyhop_skilloffset) + wpcost_update = true; + if(skill < autocvar_bot_ai_bunnyhop_skilloffset && autocvar_skill >= autocvar_bot_ai_bunnyhop_skilloffset) + wpcost_update = true; + + skill = autocvar_skill; + if (wpcost_update) + waypoint_updatecost_foralllinks(); + } + bot_calculate_stepheightvec(); bot_navigation_movemode = ((autocvar_bot_navigation_ignoreplayers) ? MOVE_NOMONSTERS : MOVE_NORMAL); @@ -686,7 +740,7 @@ void bot_serverframe() botframe_spawnedwaypoints = true; waypoint_loadall(); if(!waypoint_load_links()) - waypoint_schedulerelinkall(); + waypoint_schedulerelinkall(); // link all the autogenerated waypoints (teleporters) } if (bot_list)