Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » Give_Weapon?
Re: Give_Weapon? [message #482870 is a reply to message #482869] Tue, 30 July 2013 03:04 Go to previous messageGo to previous message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma:
General (4 Stars)
WeaponBagClass functions:

	WeaponClass * 	Add_Weapon( const WeaponDefinitionClass * def, int rounds = 0, bool give_weapon = true );
	WeaponClass * 	Add_Weapon( int id, int rounds = 0, bool give_weapon = true );
	WeaponClass * 	Add_Weapon( const char *weapon_name, int rounds = 0, bool give_weapon = true );


You can get a WeaponBagClass pointer for an GameObject like:

SCRIPTS_API const wchar_t *Get_Current_Wide_Translated_Weapon(GameObject *obj)
{
	if (!obj)
	{
		return 0;
	}
	PhysicalGameObj *o = obj->As_PhysicalGameObj();
	if (!o)
	{
		return 0;
	}
	ArmedGameObj *o2 = o->As_ArmedGameObj();
	if (!o2)
	{
		return 0;
	}
	WeaponBagClass *w = o2->Get_Weapon_Bag();


SoldierGameObj::Give_All_Weapons(void) loops through weapon definitions and grants everyone of them to a soldier withWeaponBagClass::Add_Weapon(char const*,int,bool). It loops through all definitions with DefinitionMgrClass::Get_First(ulong,DefinitionMgrClass::ID_TYPE) and call DefinitionMgrClass::Get_Next(DefinitionClass *,ulong,DefinitionMgrClass::ID_TYPE). It sets the amount of ammo for the granted weapon to -1 and passes 'true' to the 'give_weapon' bool arg. Those two DefinitionMgrClass functions return a DefinitionClass object (NOT pointer), and DefinitionClass::Get_Name() is probably called to get the weapon name to pass to Add_Weapon().



Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
 
Read Message
Read Message
Read Message
Previous Topic: Level Edit scripts.dll
Next Topic: Projectile size fix
Goto Forum:
  


Current Time: Sun Dec 22 17:13:39 MST 2024

Total time taken to generate the page: 0.01239 seconds