Skip to content

Commit

Permalink
Fix bots with switchtoweapon and setspawnweapon built-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
ineed bots committed Nov 29, 2023
1 parent 4f07800 commit 3d11e8f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/asmsource/_g_weapon.asm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
extern G_FireRocket
extern G_AntiLagRewindClientPos
extern G_AntiLag_RestoreClientPos
extern Bot_SetBotWeapon

;Exports of g_weapon:
global _ZZ11Melee_TraceP9gentity_sP11weaponParmsifffP7trace_tPfE12traceOffsets
Expand Down Expand Up @@ -1090,6 +1091,11 @@ G_SelectWeaponIndex:
mov eax, [ebp+0x8]
mov [esp], eax
call SV_GameSendServerCommand
mov eax, [ebp+0xc]
push eax
mov eax, [ebp+0x8]
push eax
call Bot_SetBotWeapon
leave
ret

Expand Down
9 changes: 9 additions & 0 deletions src/sv_bots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,13 @@ qboolean shouldSpamUseButton(gentity_t *bot)
return is_alive == qfalse && ai->useSpamDelay == 0 ? qtrue : qfalse;
}

void Bot_SetBotWeapon(int clientNum, unsigned int weaponIdx)
{
::byte weapInt;

weapInt = static_cast<::byte>(weaponIdx);

g_botai[clientNum].weapon = weapInt;
}

}
1 change: 1 addition & 0 deletions src/sv_bots.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern "C"

void Scr_AddBotsMovement();
qboolean shouldSpamUseButton(gentity_t *bot);
void Bot_SetBotWeapon(int, unsigned int);


#ifdef __cplusplus
Expand Down

0 comments on commit 3d11e8f

Please sign in to comment.