[Weapon]: PlayerCmd_initialWeaponRaise (#803)
This commit is contained in:
@ -19,7 +19,7 @@ namespace Components
|
||||
// Probably a macro 'originally' but this is fine
|
||||
static Game::gentity_s* Scr_GetPlayerEntity(Game::scr_entref_t entref)
|
||||
{
|
||||
if (entref.classnum != 0)
|
||||
if (entref.classnum)
|
||||
{
|
||||
Game::Scr_ObjectError("not an entity");
|
||||
return nullptr;
|
||||
|
@ -548,6 +548,35 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
void Weapon::PlayerCmd_initialWeaponRaise(Game::scr_entref_t entref)
|
||||
{
|
||||
auto* ent = Script::Scr_GetPlayerEntity(entref);
|
||||
const auto* weapon = Game::Scr_GetString(0);
|
||||
const auto index = Game::G_GetWeaponIndexForName(weapon);
|
||||
|
||||
auto* ps = &ent->client->ps;
|
||||
if (!Game::BG_IsWeaponValid(ps, index))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
assert(ps);
|
||||
|
||||
if (!index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto* equippedWeapon = Game::BG_GetEquippedWeaponState(ps, index);
|
||||
if (!equippedWeapon)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
equippedWeapon->usedBefore = false;
|
||||
Game::Player_SwitchToWeapon(ent);
|
||||
}
|
||||
|
||||
void Weapon::AddScriptMethods()
|
||||
{
|
||||
Script::AddMethod("DisableWeaponPickup", [](Game::scr_entref_t entref)
|
||||
@ -563,6 +592,8 @@ namespace Components
|
||||
|
||||
ent->client->ps.weapCommon.weapFlags &= ~Game::PWF_DISABLE_WEAPON_PICKUP;
|
||||
});
|
||||
|
||||
Script::AddMethod("InitialWeaponRaise", PlayerCmd_initialWeaponRaise);
|
||||
}
|
||||
|
||||
Weapon::Weapon()
|
||||
|
@ -34,6 +34,9 @@ namespace Components
|
||||
static void JavelinResetHook_Stub();
|
||||
|
||||
static void WeaponEntCanBeGrabbed_Stub();
|
||||
|
||||
static void PlayerCmd_initialWeaponRaise(Game::scr_entref_t entref);
|
||||
|
||||
static void AddScriptMethods();
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user