From fe74e8ae8060dff6257647cc595aca85556d09d2 Mon Sep 17 00:00:00 2001 From: jhh8 Date: Sat, 20 Dec 2025 16:03:54 +0200 Subject: [PATCH 1/2] return weapon handle in GiveWeapon script function for convenience if you want to edit the given weapon, so you dont have to do GetInventoryTable bs --- src/game/server/swarm/asw_marine.cpp | 6 ++++-- src/game/server/swarm/asw_marine.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/game/server/swarm/asw_marine.cpp b/src/game/server/swarm/asw_marine.cpp index 06cf7a88c..625f9e84b 100644 --- a/src/game/server/swarm/asw_marine.cpp +++ b/src/game/server/swarm/asw_marine.cpp @@ -3476,13 +3476,13 @@ void CASW_Marine::ScriptGiveAmmo( int iCount, int iAmmoIndex ) GiveAmmo( iCount, iAmmoIndex, false ); } -void CASW_Marine::ScriptGiveWeapon( const char *pszName, int slot ) +HSCRIPT CASW_Marine::ScriptGiveWeapon( const char *pszName, int slot ) { CASW_Weapon* pWeapon = dynamic_cast(Weapon_Create(pszName)); if ( !pWeapon ) { Msg( "NULL Ent in GiveWeapon!\n" ); - return; + return NULL; } int weaponIndex = GetWeaponPositionForPickup( pWeapon->GetClassname(), pWeapon->m_bIsTemporaryPickup ); @@ -3505,6 +3505,8 @@ void CASW_Marine::ScriptGiveWeapon( const char *pszName, int slot ) int iClips = GetAmmoDef()->MaxCarry( pWeapon->GetPrimaryAmmoType(), this ); GiveAmmo( iClips, pWeapon->GetPrimaryAmmoType(), true ); } + + return ToHScript( pWeapon ); } bool CASW_Marine::ScriptDropWeapon( int iWeaponIndex ) diff --git a/src/game/server/swarm/asw_marine.h b/src/game/server/swarm/asw_marine.h index faecfc692..7170f955b 100644 --- a/src/game/server/swarm/asw_marine.h +++ b/src/game/server/swarm/asw_marine.h @@ -549,7 +549,7 @@ class CASW_Marine : public CASW_VPhysics_NPC, public IASWPlayerAnimStateHelpers, int m_nIndexActWeapBeforeTempPickup; void ScriptGiveAmmo( int iCount, int iAmmoIndex ); - void ScriptGiveWeapon( const char *pszName, int slot ); + HSCRIPT ScriptGiveWeapon( const char *pszName, int slot ); bool ScriptDropWeapon( int iWeaponIndex ); bool ScriptRemoveWeapon( int iWeaponIndex ); bool ScriptSwitchWeapon( int iWeaponIndex ); From 233c15e83627a1f98d1598df604f6c27de45f53c Mon Sep 17 00:00:00 2001 From: jhh8 Date: Sat, 20 Dec 2025 17:15:07 +0200 Subject: [PATCH 2/2] update desc --- src/game/server/swarm/asw_marine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/server/swarm/asw_marine.cpp b/src/game/server/swarm/asw_marine.cpp index 625f9e84b..f2e08f443 100644 --- a/src/game/server/swarm/asw_marine.cpp +++ b/src/game/server/swarm/asw_marine.cpp @@ -391,7 +391,7 @@ BEGIN_ENT_SCRIPTDESC( CASW_Marine, CASW_Inhabitable_NPC, "Marine" ) DEFINE_SCRIPTFUNC_NAMED( ScriptBecomeInfested, "BecomeInfested", "Infests the marine." ) DEFINE_SCRIPTFUNC_NAMED( ScriptCureInfestation, "CureInfestation", "Cures an infestation." ) DEFINE_SCRIPTFUNC_NAMED( ScriptGiveAmmo, "GiveAmmo", "Gives the marine ammo for the specified ammo index." ) - DEFINE_SCRIPTFUNC_NAMED( ScriptGiveWeapon, "GiveWeapon", "Gives the marine a weapon." ) + DEFINE_SCRIPTFUNC_NAMED( ScriptGiveWeapon, "GiveWeapon", "Gives the marine a weapon. Returns the weapon's handle." ) DEFINE_SCRIPTFUNC_NAMED( ScriptDropWeapon, "DropWeapon", "Makes the marine drop a weapon." ) DEFINE_SCRIPTFUNC_NAMED( ScriptRemoveWeapon, "RemoveWeapon", "Removes a weapon from the marine." ) DEFINE_SCRIPTFUNC_NAMED( ScriptSwitchWeapon, "SwitchWeapon", "Make the marine switch to a weapon" )