X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fdefault%2Fscripting.qc;h=1531cde98db39e08cff0b494f89dc259d3566a17;hb=f873097f5ded4b7a43e424a97c2407f5b175ad88;hp=fa273410ea6882bd012daff70dffe93c67c17743;hpb=b43e106e511a88d84591860849f01b8da208e022;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/bot/default/scripting.qc b/qcsrc/server/bot/default/scripting.qc index fa273410e..1531cde98 100644 --- a/qcsrc/server/bot/default/scripting.qc +++ b/qcsrc/server/bot/default/scripting.qc @@ -4,6 +4,7 @@ #include #include +#include #include "bot.qh" @@ -310,6 +311,11 @@ float bot_decodecommand(string cmdstring) bot_cmd.bot_cmd_parm_string = strzone(parm); break; case BOT_CMD_PARAMETER_VECTOR: + if(substring(parm, 0, 1) != "\'") + { + LOG_INFOF("ERROR: expected vector type \'x y z\', got %s\n", parm); + return 0; + } bot_cmd.bot_cmd_parm_vector = stov(parm); break; default: @@ -376,7 +382,7 @@ void bot_cmdhelp(string scmd) LOG_INFO("Look to the right or left N degrees. For turning to the left use positive numbers."); break; case BOT_CMD_MOVETO: - LOG_INFO("Walk to an specific coordinate on the map. Usage: moveto \"x y z\""); + LOG_INFO("Walk to an specific coordinate on the map. Usage: moveto \'x y z\'"); break; case BOT_CMD_MOVETOTARGET: LOG_INFO("Walk to the specific target on the map"); @@ -485,6 +491,7 @@ float bot_cmd_impulse(entity this) float bot_cmd_continue(entity this) { + bot_relinkplayerlist(); this.bot_exec_status &= ~BOT_EXEC_STATUS_PAUSED; return CMD_STATUS_FINISHED; } @@ -568,9 +575,22 @@ float bot_cmd_select_weapon(entity this) if(id < WEP_FIRST || id > WEP_LAST) return CMD_STATUS_ERROR; - if(client_hasweapon(this, Weapons_from(id), true, false)) - PS(this).m_switchweapon = Weapons_from(id); - else + bool success = false; + + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(this.(weaponentity).m_weapon == WEP_Null && slot != 0) + continue; + + if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false)) + { + success = true; + this.(weaponentity).m_switchweapon = Weapons_from(id); + } + } + + if(!success) return CMD_STATUS_ERROR; return CMD_STATUS_FINISHED; @@ -587,16 +607,12 @@ const int CMD_CONDITION_false_BLOCK = 8; float bot_cmd_eval(entity this, string expr) { // Search for numbers - if(strstrofs("0123456789", substring(expr, 0, 1), 0) >= 0) - { + if(IS_DIGIT(substring(expr, 0, 1))) return stof(expr); - } // Search for cvars if(substring(expr, 0, 5)=="cvar.") - { return cvar(substring(expr, 5, strlen(expr))); - } // Search for fields switch(expr) @@ -995,6 +1011,7 @@ float bot_cmd_pause(entity this) this.movement = '0 0 0'; this.bot_cmd_keys = BOT_CMD_KEY_NONE; + bot_clear(this); this.bot_exec_status |= BOT_EXEC_STATUS_PAUSED; return CMD_STATUS_FINISHED; } @@ -1058,7 +1075,7 @@ float bot_cmd_debug_assert_canfire(entity this) if(f) { this.colormod = '0 8 8'; - LOG_INFO("Bot ", this.netname, " using ", this.weaponname, " wants to fire, inhibited by weaponentity state\n"); + LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by weaponentity state\n"); } } else if(ATTACK_FINISHED(this, slot) > time) @@ -1066,15 +1083,15 @@ float bot_cmd_debug_assert_canfire(entity this) if(f) { this.colormod = '8 0 8'; - LOG_INFO("Bot ", this.netname, " using ", this.weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left)\n"); + LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left)\n"); } } - else if(this.tuba_note) + else if(this.(weaponentity).tuba_note) { if(f) { this.colormod = '8 0 0'; - LOG_INFO("Bot ", this.netname, " using ", this.weaponname, " wants to fire, bot still has an active tuba note\n"); + LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, bot still has an active tuba note\n"); } } else @@ -1082,7 +1099,7 @@ float bot_cmd_debug_assert_canfire(entity this) if(!f) { this.colormod = '8 8 0'; - LOG_INFO("Bot ", this.netname, " using ", this.weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left\n"); + LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left\n"); } } @@ -1110,7 +1127,6 @@ void bot_setcurrentcommand(entity this) if(!this.bot_cmd_current) { this.bot_cmd_current = new_pure(bot_cmd); - this.bot_cmd_current.is_bot_cmd = true; } bot_cmd = this.bot_cmd_current; @@ -1165,16 +1181,17 @@ float bot_execute_commands_once(entity this) // Find command bot_setcurrentcommand(this); - // if we have no bot command, better return - // old logic kept pressing previously pressed keys, but that has problems - // (namely, it means you cannot make a bot "normal" ever again) - // to keep a bot walking for a while, use the "wait" bot command - if(bot_cmd == NULL) - return false; - // Ignore all commands except continue when the bot is paused - if(this.bot_exec_status & BOT_EXEC_STATUS_PAUSED) - if(bot_cmd.bot_cmd_type!=BOT_CMD_CONTINUE) + if(!(self.bot_exec_status & BOT_EXEC_STATUS_PAUSED)) + { + // if we have no bot command, better return + // old logic kept pressing previously pressed keys, but that has problems + // (namely, it means you cannot make a bot "normal" ever again) + // to keep a bot walking for a while, use the "wait" bot command + if(bot_cmd == world) + return 0; + } + else if(bot_cmd.bot_cmd_type != BOT_CMD_CONTINUE) { if(bot_cmd.bot_cmd_type!=BOT_CMD_NULL) {