Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » Give_Weapon?
Give_Weapon? [message #482869] Tue, 30 July 2013 00:47 Go to next message
Xpert is currently offline  Xpert
Messages: 1588
Registered: December 2005
Location: New York City
Karma: 0
General (1 Star)
Is there a script or some kind of function that you can use to give a character a weapon? I'm not looking for Give_PowerUp either before someone mentions it.

http://i32.photobucket.com/albums/d42/XpertMaverick/xpertyankee.jpg

Creator of NetGuard, an IRC network regulator.
Developer of the CloudyServ 0.982-X project.
Developer of the CloudyServ Ren-X bot.

Part time streamer - https://twitch.tv/gg_wonder
Re: Give_Weapon? [message #482870 is a reply to message #482869] Tue, 30 July 2013 03:04 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4299
Registered: April 2011
Karma: 0
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
Re: Give_Weapon? [message #482871 is a reply to message #482869] Tue, 30 July 2013 03:09 Go to previous message
Xpert is currently offline  Xpert
Messages: 1588
Registered: December 2005
Location: New York City
Karma: 0
General (1 Star)
Cool, thanks! Thumbs Up

http://i32.photobucket.com/albums/d42/XpertMaverick/xpertyankee.jpg

Creator of NetGuard, an IRC network regulator.
Developer of the CloudyServ 0.982-X project.
Developer of the CloudyServ Ren-X bot.

Part time streamer - https://twitch.tv/gg_wonder
Previous Topic: Level Edit scripts.dll
Next Topic: Projectile size fix
Goto Forum:
  


Current Time: Fri May 17 23:39:21 MST 2024

Total time taken to generate the page: 0.00548 seconds