X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fdefault%2Fscripting.qc;h=1531cde98db39e08cff0b494f89dc259d3566a17;hb=f873097f5ded4b7a43e424a97c2407f5b175ad88;hp=e8355575edae23ef274bd8ddeb089068a2dc664a;hpb=e2897355e6cd1ca18e9ab1547e188eab316ce79d;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/bot/default/scripting.qc b/qcsrc/server/bot/default/scripting.qc index e8355575e..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; @@ -991,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; } @@ -1054,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) @@ -1062,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 @@ -1078,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"); } } @@ -1106,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; @@ -1161,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) {