Jump to content
Sign in to follow this  
Divinitize

Custom Grenade config

Recommended Posts

I'm in the process of making a custom grenade but i am struggling to find a config template online anywhere, the following is what i currently have and its been copied from an Arma 2 config that somone else made, im very much aware that this is a bad config, my coding skills are very poor and any help would be greatly appreciated

class CfgPatches {
class crg_toxin  {
	units[] = {""};
	requiredAddons[] = {};

};
};

class CfgAmmo {
class Default;	// External class reference

class crg_toxin  : Default {

	scope = 1;
	hit = 0.001;
	indirectHit = 0.001;
	indirectHitRange = 0.01;
};
class MissileCore;	// External class reference
class BombCore;	// External class reference
class LaserBombCore;	// External class reference
class RocketCore;	// External class reference
class BulletCore;	// External class reference
class ShellCore;	// External class reference
class GrenadeCore;	// External class reference
class TimeBombCore;	// External class reference
class PipeBombCore;	// External class reference
class MineCore;	// External class reference
class SmokeShellCore;	// External class reference
class BulletBase;	// External class reference
class GrenadeBase;	// External class reference
class ShellBase;	// External class reference
class RocketBase;	// External class reference
class MissileBase;	// External class reference

class Grenade : Default {
	hit = 20;
	indirectHit = 12;
	indirectHitRange = 4;
};

class GrenadeHand : Grenade {
	typicalspeed = 0;
	model = "\crg_toxin\crg_toxin.p3d";
	visibleFire = 0.5;
	audibleFire = 0.05;
	visibleFireTime = 1;
	fuseDistance = 5;
};

class crg_toxin  : GrenadeHand  {
	model = "\crg_toxin\crg_toxin.p3d";
	soundHit[] = {"Ca\sounds\Weapons\explosions\grenade_new1", 15.8489, 1, 1000};
               soundFly[] = {"\ca\Weapons\Data\Sound\noise", 0.0001, 1};
	soundEngine[] = {"", 0.0001, 4};
	explosionTime = 15;
	deflecting = 0;
	indirectHit = 0.2;
	indirectHitRange = 0.5;
};
};

class CfgMagazines {
class Default;	// External class reference
class CA_Magazine;	// External class reference
class HandGrenadeMuzzle;	// External class reference

       class CA_LauncherMagazine : CA_Magazine {
	type = 512;
};

class HandGrenade : CA_Magazine {
	model = "\crg_toxin\crg_toxin.p3d";
};

class crg_toxin :  HandGrenade {
	displayName = crg_toxin;
	picture = "\BreachCharge_strip\data\AGP-DB14.paa" ;
	model = "\crg_toxin\crg_toxin.p3d";
	displayNameShort = AGPDB14;
	ammo = crg_toxin;
};
};

class CfgWeapons {
class Default;	// External class reference
class Binocular;	// External class reference
class PistolCore;	// External class reference
class RifleCore;	// External class reference
class MGunCore;	// External class reference
class LauncherCore;	// External class reference
class GrenadeCore;	// External class reference
class Launcher;	// External class reference
class CannonCore;	// External class reference
class RocketPods;	// External class reference


};
class Pistol;	// External class reference


	class ThrowMuzzle;	// External class reference







	class HandGrenadeMuzzle;	// External class reference















	class crg_toxin : HandGrenadeMuzzle  {







		displayName = crg_toxin;







		soundHit[] = {"Ca\sounds\Weapons\explosions\grenade_new1", 15.8489, 1, 1000};







		soundFly[] = {"\ca\Weapons\Data\Sound\noise", 0.0001, 1};







		soundEngine[] = {"", 0.0001, 4};







		magazines[] = {crg_toxin};







	};







       muzzles[] = {"HandGrenade_Stone", "HandGrenadeMuzzle", "SmokeShellMuzzle", "IRStrobe",};








};

All im looking for is the ability to get my custom grenade in game currently called "crg_toxin" and throwable.

Share this post


Link to post
Share on other sites

Hi, unfortunately I can't help you, but I want to make a new grenade too (flashbang) and I am a bit lost with config files.

The first thing I want to learn is precisely what you want : "ability to get my custom grenade in game and throwable". I hope a config guru will help us!

Just one remark: it seems your last "};" is useless.

Share this post


Link to post
Share on other sites

Grenades come as ammo and a weapon, just like any other weapon system in game. It's a bit gash that you can't easily (without changing a lot of base classes) add a new grenade to the existing throw weapon, but such is life. At any rate, do yourself a favour and use inheritance from the existing classes ingame, so you don't have to fanny around with too many variables :)

Untested and off the top of my head:

class CfgPatches
{
class crg_toxin  
{
	units[] = {};
	weapons {crg_toxin_throw}
	requiredAddons[] = {};	
};
};

class CfgAmmo 
{
class Default;	// External class reference
class Grenade : Default {};
class GrenadeHand : Grenade {};
class crg_toxin_ammo  : GrenadeHand 
{
	scope = 1;
	hit = 0.001;
	indirectHit = 0.001;
	indirectHitRange = 0.01;
	model = "\crg_toxin\crg_toxin.p3d";
	visibleFire = 0.5;
	audibleFire = 0.05;
	visibleFireTime = 1;
	fuseDistance = 5;
};
};

class cfgMagazines
{
class Default;	// External class reference
class CA_Magazine : Default {};
class HandGrenade : CA_Magazine {};
class crg_toxin :  HandGrenade
{
	displayName = "The Name Of Your Grenade Goes Here";
	picture = "\BreachCharge_strip\data\AGP-DB14.paa" ;
	displayNameShort = "A shortened name for your grenade goes here";
	ammo = "crg_toxin_ammo";
};
};

class CfgWeapons 
{
class Default;
class GrenadeLauncher : Default {};
class Throw : GrenadeLauncher {};
class Crg_Toxin_Throw : Throw 
{
	displayname = "Throw";
	muzzles[] = {"Crg_Toxin_Muzzle"};
	class Crg_Toxin_Muzzle : GrenadeLauncher
	{
		aidispersioncoefx = 6;
		aidispersioncoefy = 6;
		autoreload = 1;
		cursor = "EmptyCursor";
		cursoraim = "throw";
		enableattack = 0;
		keepininventory = 1;
		magazinereloadtime = 0;
		maxrange = 60;
		maxrangeprobab = 0.03;
		midrange = 45;
		midrangeprobab = 0.9;
		minrange = 10;
		minrangeprobab = 0.2;
		modeloptics = "";
		reloadsound[] = {"", 0.000316228, 1};
		reloadtime = 0;
		showempty = 0;
		sound[] = {"", 0.000316228, 1};
		magazines[] = {"crg_toxin"};
	};
};
};

You'll need to add the weapon 'Crg_Toxin_Throw' to the solider, as well as the magazine 'Crg_Toxin'. Remember to alter the parts where you need to add a name for your grenade. Your throw weapon will only throw your grenade as it stands. To make it throw anything you can change this line:

muzzles[] = {"Crg_Toxin_Muzzle"};

to:

{"Crg_Toxin_Muzzle", "HandGrenade_Stone", "HandGrenadeMuzzle", "MiniGrenadeMuzzle", "SmokeShellMuzzle", "SmokeShellYellowMuzzle", "SmokeShellGreenMuzzle", "SmokeShellRedMuzzle", "SmokeShellPurpleMuzzle", "SmokeShellOrangeMuzzle", "SmokeShellBlueMuzzle", "ChemlightGreenMuzzle", "ChemlightRedMuzzle", "ChemlightYellowMuzzle", "ChemlightBlueMuzzle"};

Share this post


Link to post
Share on other sites

Thanks Loyalguard. Is there a way to copy paste something from the config viewer? I can't find a way to copy a whole class file.

Looking at the cfgAmmo, cfgWeapons and cfgMagazines for the grenade in the config viewer, I see some subfiles (sub classes?). For instance for cfgWeapons : Grenadelauncher, I see too subfolders "Gunclouds" and "Gunfire".

Using this topic: forums.bistudio.com/showthread.php?40759-Hand-Grenade-Standard-Config I extracted the following:

class CfgPatches
{
class SUPER_FLASH
{
units [] = {};
Weapons [] = {SUPER_FLASH};
requiredVersion = 0.54;
requiredAddons = {""};
};
};

class cfgAmmo
{
class Default;
class GrenadeHand;

class SUPER_FLASH: GrenadeHand 
{
model = "\sleepingbag\Weapons\flash.p3d";
deflecting = 90;
explosionTime = 5;
hit = 0.002;
indirectHit = 0.0002;
indirectHitRange = 7;
cost = 40;
simulationStep = 0.05
whistleDist = 7;};
};


class cfgWeapons {
class Default;
class GrenadeLauncher;

class: ThrowMuzzle : GrenadeLauncher;
class HandGrenadeMuzzle : ThrowMuzzle {
magazines[] = {"SUPER_FLASH"};
};
};



class CfgMagazines {
class Default;
class CA_Magazine;
class HandGrenade;
class SUPER_FLASH : HandGrenade
{
displayName = "flashbang";
picture = "sleepingbag\data\flash.tga";
ammo = "SUPER_FLASH";
descriptionShort = "Stun hand grenades or flashbangs are used as diversionary or distraction devices during building and room clearing operations";
sound[] = {"", 0.000316228, 1};
reloadSound[] = {"", 0.000316228, 1};
};
}; 

Something is puzzling me: is the class structure different from arma 2? Where are those Gunfire and Gunclouds subcategories? Are they just another name for the throwmuzzle and handgrenademuzzle sub classes?

I can't find a link to a good tutorial on config files. Do someone has any good one in mind?

Unrelated question: I have already a 3d model for my grenade, but a friend of mine is struggling adding the textures. Can I use the p3d without textures to learn how to make the config and try in game till he finishes? (meaning being able to make an addon with a "white", untextured grenade).

edit: I didn't see the previous post. You can probably disregard my code!

Edited by super-truite

Share this post


Link to post
Share on other sites

Configs are learning by doing really. The most common mistake is that people seem to want to define EVERYTHING at once, which is a horrendous ball ache and a waste of time. Inheritance is very important. If we know that weapon A (our addon) is identical to weapon B (already ingame) in every way except that we want to change one thing (let's say, the model path), then why then go and redefine the other 300 parametres?

class Default;

All clases start here

class WeaponB : Default {};

Weapon B inherits from Default. We want to keep its values so we open and close the brackets {}; without anything inbetween

class WeaponA : Weapon B
{
model = "\pboname\modelname.p3d";
};

Our weapon is identical to weapon B, but we do wish to change one parametre. So, we open the brackets, change what we want (in this case a model path) and close the brackets again. Every other value we didn't alter will remain the same as in Weapon B, which we have inherited from

In my grenade example, we know this is a grenade, it is to be thrown, and do what grenades do that are already ingame, therefore it stands to reason we can inherit 90% of the code for the grenade, rather than rewriting it ourselves:

class Default;	// External class reference
class Grenade : Default {};
class GrenadeHand : Grenade {};
class crg_toxin_ammo  : GrenadeHand 

Essentially what that says is that the crg_toxin_ammo is based off GrenadeHand, which is based off Grenade, which is based off Default (as is everything in ArmA). We then go in an only alter those things we need to, so we open the brackets and add the code in that i relevant to this ammo, which was the model path, and a few parametres about how the ammo reacts. Any values that are not stated will simply be inherited from the baseclass, which is the existing hand grenade in game (crg_toxin_ammo is based off grenadehand)

You will very rarely have to go in and alter subclasses such as gunclouds and the like. Only alter what is UNIQUE to your weapon. If you inherit correctly, then everything will be fine. Always start off by finding a weapon, ammo, magazine, vehicle that is most similar to your addon, then use that to inherit from and change only those things you need to

You can happily use untextured models, the game doesn't care either way :)

Edited by Messiah

Share this post


Link to post
Share on other sites

Yeah! thanks messiah! I understood that I needed to inherit from classes already defined, but it is way more clear with your detailed explanation (specially for the syntax explanations, since I am quite rusty with c++).

For the gunclouds and so on, just to be sure: when you put "class GrenadeLauncher : Default {};" you inherit also the properties of the subclasses gunclouds and gunfire automatically and that's why there is never any references to those classes in your code, right?

When I am done I'll put my config here (It will work for you divinitize).

Share this post


Link to post
Share on other sites

Yes, everything, including subclasses, will be inherited - essentially anything you would define between {}; if you were writing the code from scratch, will be taken across. When you open those brackets and define something new, you're only replacing the values you define, anything you don't define, will remain as per the inheritance.

Share this post


Link to post
Share on other sites

OK, I am making progress since the game doesn't crash :) . Here is my config:

class CfgPatches
{
class SUPER_FLASH  
{
	units[] = {};
	weapons[] = {"SUPER_FLASH_throw"};
	requiredAddons[] = {};	
};
};

class CfgAmmo 
{
class Default;	// External class reference
class Grenade : Default {};
class GrenadeHand : Grenade {};
class SUPER_FLASH_ammo  : GrenadeHand 
{
	scope = 1;
	hit = 0.001;
	indirectHit = 0.001;
	indirectHitRange = 0.01;
	model = "\SUPER_FLASH\flash.p3d";
	visibleFire = 0.5;
	audibleFire = 0.05;
	visibleFireTime = 1;
	fuseDistance = 5;
};
};

class cfgMagazines
{
class Default;	// External class reference
class CA_Magazine : Default {};
class HandGrenade : CA_Magazine {};
class crg_toxin :  HandGrenade
{
	displayName = "flashbang";
	picture = "" ;
	displayNameShort = "flash";
	ammo = "SUPER_FLASH_ammo";
};
};

class CfgWeapons 
{
class Default;
class GrenadeLauncher : Default {};
class Throw : GrenadeLauncher {};
class SUPER_FLASH_Throw : Throw 
{
	displayname = "Throw";
	muzzles[] = {"SUPER_FLASH_Muzzle"};
	class SUPER_FLASH_Muzzle : GrenadeLauncher
	{
		aidispersioncoefx = 6;
		aidispersioncoefy = 6;
		autoreload = 1;
		cursor = "EmptyCursor";
		cursoraim = "throw";
		enableattack = 0;
		keepininventory = 1;
		magazinereloadtime = 0;
		maxrange = 60;
		maxrangeprobab = 0.03;
		midrange = 45;
		midrangeprobab = 0.9;
		minrange = 10;
		minrangeprobab = 0.2;
		modeloptics = "";
		reloadsound[] = {"", 0.000316228, 1};
		reloadtime = 0;
		showempty = 0;
		sound[] = {"", 0.000316228, 1};
		magazines[] = {"SUPER_FLASH"};
	};
};
};

I can't use my grenade though... The classname is not recognized when I use this addmagazinecargo[ "SUPER_FLASH_ammo",20] in a crate init...:(.

(I get an error message in the mission editor "CfgMagazines.SUPER_FLASH_ammo" not recognized or something like this ).

I guess the syntax is correct (since the game launched), but I still did something wrong.

By the way Messiah, I think there is a typo at the second line of your code. It should be: "weapons [] = {"crg_toxin_throw"};".

Share this post


Link to post
Share on other sites
magazines[] = {"SUPER_FLASH"};

think your mag is called CRG_toxin isnt it ? so your trying to add the "bullet" not the mag i think

also did you give you unit a new weapon called SUPER_FLASH_Throw instead of Throw too ?

Share this post


Link to post
Share on other sites

Sorry for the confusion, it's because we are two having the same issue so CRG_toxin = SUPER_FLASH in my case... I should have kept the same name as the op.

Hmm indeed I forgot to give my unit a new weapon. I don't know yet how to do that. I will try. Thanks for the quick answers.

Share this post


Link to post
Share on other sites

You're adding the ammo, when you should be adding the magazine.

In ArmA you have Ammo, which is used by a Magazine, which is used by a Weapon. The throw 'muzzle' uses the magazine, not the ammo.

And yes, I forgot the "" - simple mistake :)

Share this post


Link to post
Share on other sites

in fact it's what I tried first, but it doesn't work with "SUPER_FLASH" which is my magazine name. That's why I tried with the ammo after and then I mixed up everything in my post :)

edit: OK it was just a copy/paste mistake. One of my class names was still "CRG_toxin". I just need to figure out how to add it to the players weapons now.

edit 2: Hmm I have no idea how to actually throw my grenade in game...I don't find anything else linked to handgrenade in BIS config.bin.

So so far I have this:

class CfgPatches
{
class SUP_flash  
{
	units[] = {};
	weapons[] = {"SUP_flash_throw"};
	requiredAddons[] = {};	
};
};

class CfgAmmo 
{
class Default;	// External class reference
class Grenade : Default {};
class GrenadeHand : Grenade {};
class SUP_flash_ammo  : GrenadeHand 
{
	scope = 1;
	hit = 0.001;
	indirectHit = 0.001;
	indirectHitRange = 0.01;
	model = "\SUP_flash\flash.p3d";
	visibleFire = 0.5;
	audibleFire = 0.05;
	visibleFireTime = 1;
	fuseDistance = 5;
};
};

class cfgMagazines
{
class Default;	// External class reference
class CA_Magazine : Default {};
class HandGrenade : CA_Magazine {};
class SUP_flash :  HandGrenade
{
    model = "\SUP_flash\flash.p3d";
	displayName = "flashbang";
	picture = "" ;
	displayNameShort = "flash";
	ammo = "SUP_flash_ammo";
};
};


class CfgWeapons 
{
class Default;
class GrenadeLauncher : Default {};
class Throw : GrenadeLauncher 
{
displayName = "flashbang";
 muzzles[] = {"SUP_flash_Muzzle"};
	class SUP_flash_Muzzle: GrenadeLauncher 
	{	
	}; 
	class HandGrenadeMuzzle: ThrowMuzzle
	{
		magazines[] = {"SUP_flash"};
	};
};	
};

In game I can put the grenade in my inventory and put it on the ground, but I can't throw it.

I guess it is not an issue for testing, but still, maybe I should mention it: could it be a problem that the 3D model draft from my friend is "slightly" bigger than a usual grenade :) :

littleflash.jpg

Edited by super-truite

Share this post


Link to post
Share on other sites

You're altering things I wrote, and trying to hash the existing throwing weapon ;)

class CfgWeapons 
{
class Default;
class GrenadeLauncher : Default {};
class Throw : GrenadeLauncher 
{
displayName = "flashbang";
 muzzles[] = {"SUP_flash_Muzzle"};
	class SUP_flash_Muzzle: GrenadeLauncher 
	{	
	}; 
	class HandGrenadeMuzzle: ThrowMuzzle
	{
		magazines[] = {"SUP_flash"};
	};
};	
};

This isn't what I posted. Try again:

class CfgWeapons 
{
class Default;
class GrenadeLauncher : Default {};
class Throw : GrenadeLauncher {};
class SUP_Flash_Throw : Throw 
{
	displayname = "Throw";
	muzzles[] = {"SUP_Flash_Muzzle"};
	class SUP_FLash_Muzzle : GrenadeLauncher
	{
		aidispersioncoefx = 6;
		aidispersioncoefy = 6;
		autoreload = 1;
		cursor = "EmptyCursor";
		cursoraim = "throw";
		enableattack = 0;
		keepininventory = 1;
		magazinereloadtime = 0;
		maxrange = 60;
		maxrangeprobab = 0.03;
		midrange = 45;
		midrangeprobab = 0.9;
		minrange = 10;
		minrangeprobab = 0.2;
		modeloptics = "";
		reloadsound[] = {"", 0.000316228, 1};
		reloadtime = 0;
		showempty = 0;
		sound[] = {"", 0.000316228, 1};
		magazines[] = {"SUP_Flash"};
	};
};
};

Weapon is 'SUP_Flash_Throw' and the magazine is 'SUP_Flash'

Share this post


Link to post
Share on other sites

Thanks Messiah. I tried with your code and it still doesn't work. I understand what's wrong with mine. But shouldn't it work like this:

class CfgWeapons 
{
class Default;
class GrenadeLauncher : Default {};
class Throw : GrenadeLauncher {};
class SUP_Flash_Throw : Throw 
{
	displayname = "Throw";
	muzzles[] = {"SUP_Flash_Muzzle"};
	class  ThrowMuzzle: GrenadeLauncher {};
	class SUP_FLash_Muzzle: ThrowMuzzle
	{
		magazines[] = {"SUP_Flash"};
	};
};
};

(since in the bis class, Handgrenademuzzle inherit from Throwmuzzle which I don't want to modify for the time being).

Since my weapon config and my magazine config are recognized by the game (at least I don't receive any error message), I suspect that I am doing something silly outside the config.cpp.

So what I do is the following: I have my .p3d and config inside the same directory (named SUP_flash). I pbo it and put it in a @SUP_flash\addons directory in my arma3 folder.

In the editor, I put a soldier with the init:

this addmagazine ["SUP_flash",20]; 
this addweapon "SUP_Flash_Throw"; 

Is there something wrong with this?

Share this post


Link to post
Share on other sites

Throw is not a normal weapon like a gun IIRC you cant add it via a commandline you will need to put it in a unit classfrom memory ,you can remove it but cant add it back

at least you have done the hard work :).

Share this post


Link to post
Share on other sites

Hmm, I'm not sure I follow. I tried before to add it in the class CfgVehicles and in the subclass of a soldier. Is that what you say?

Share this post


Link to post
Share on other sites

no i mean make your unit as well something like : untested

class cfgvehicles
{
class B_Soldier_base_F;
class my_throwing_soldier: B_Soldier_base_F
{
	_generalMacro = "my_throwing_soldier";
	scope = 2;
	displayName = "Flash Grenadier";
	weapons[] = {"arifle_MX_GL_ACO_point_F","hgun_P07_F","SUP_Flash_Throw","Put","Binocular"};
	respawnWeapons[] = {"arifle_MX_GL_ACO_point_F","hgun_P07_F","SUP_Flash_Throw","Put","Binocular"};
	magazines[] = {"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","16Rnd_9x21_Mag","16Rnd_9x21_Mag","SUP_flash","SUP_flash","SUP_flash"};
	respawnMagazines[] = {"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","16Rnd_9x21_Mag","16Rnd_9x21_Mag","SUP_flash","SUP_flash","SUP_flash","SUP_flash"};
	cost = 60000;
	threat[] = {1,0.3,0.1};
	linkedItems[] = {"V_PlateCarrierGL_rgr","H_HelmetB_paint","NVGoggles","ItemMap","ItemCompass","ItemWatch","ItemRadio"};
	respawnLinkedItems[] = {"V_PlateCarrierGL_rgr","H_HelmetB_paint","NVGoggles","ItemMap","ItemCompass","ItemWatch","ItemRadio"};
};
}:

DOnt forget to add to requiredaddon in cfg patches A3_characters_F so it will load after BIS ones etc

I removed old throw and grenades that are relating to old throw muzzles because you havent added them to the new throw so it cant use obviously .

Share this post


Link to post
Share on other sites

Ok thanks, yeah it's what I tried to say but with my noob vocabulary :). I'll try again. I must have messed up with the soldier classname.

edit: :yay: :yay: :yay: :yay: it's working!

You guys did all the work though...But I guess I know how it works now, so I hope I won't bother you that much with this kind of stuff!

I have still to figure out how to launch my flashbang scripts from the config. But this is another story and it will fit better in an other post and I'll try to figure it out on my own first, so don't help me!

For the OP: here is the full config you need (replace all the SUP_flash and so on by your own names):

class CfgPatches
{
class SUP_flash  
{
	units[] = {};
	weapons[] = {"SUP_flash_throw"};
	requiredAddons[] = { A3_characters_F};	
};
};

class CfgAmmo 
{
class Default;	// External class reference
class Grenade : Default {};
class GrenadeHand : Grenade {};
class SUP_flash_ammo  : GrenadeHand 
{
	scope = 1;
	hit = 0.001;
	indirectHit = 0.001;
	indirectHitRange = 0.01;
	model = "\SUP_flash\flash.p3d";
	visibleFire = 0.5;
	audibleFire = 0.05;
	visibleFireTime = 1;
	fuseDistance = 5;
};
};

class cfgMagazines
{
class Default;	// External class reference
class CA_Magazine : Default {};
class HandGrenade : CA_Magazine {};
class SUP_flash :  HandGrenade
{
    model = "\SUP_flash\flash.p3d";
	displayName = "flashbang";
	picture = "\SUP_flash\flash.paa";
	displayNameShort = "flash";
	ammo = "SUP_flash_ammo";
};
};


class CfgWeapons 
{
class Default;
class GrenadeLauncher : Default {};
class Throw : GrenadeLauncher {};
class SUP_Flash_Throw : Throw 
{
	displayname = "Throw";
	muzzles[] = {"SUP_Flash_Muzzle"};
	class  ThrowMuzzle: GrenadeLauncher
	{
		aidispersioncoefx = 6;
		aidispersioncoefy = 6;
		autoreload = 1;
		cursor = "EmptyCursor";
		cursoraim = "throw";
		enableattack = 0;
		keepininventory = 1;
		magazinereloadtime = 0;
		maxrange = 60;
		maxrangeprobab = 0.03;
		midrange = 45;
		midrangeprobab = 0.9;
		minrange = 10;
		minrangeprobab = 0.2;
		modeloptics = "";
		reloadsound[] = {"", 0.000316228, 1};
		reloadtime = 0;
		showempty = 0;
		sound[] = {"", 0.000316228, 1};

	};

	class SUP_FLash_Muzzle: ThrowMuzzle
	{
		magazines[] = {"SUP_Flash"};
	};
};
};


class cfgvehicles
{
class B_Soldier_base_F;
class my_throwing_soldier: B_Soldier_base_F
{
	_generalMacro = "my_throwing_soldier";
	scope = 2;
	displayName = "Flash Grenadier";
	weapons[] = {"arifle_MX_GL_ACO_point_F","hgun_P07_F","SUP_Flash_Throw","Put","Binocular"};
	respawnWeapons[] = {"arifle_MX_GL_ACO_point_F","hgun_P07_F","SUP_Flash_Throw","Put","Binocular"};
	magazines[] = {"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","16Rnd_9x21_Mag","16Rnd_9x21_Mag","SUP_flash","SUP_flash","SUP_flash"};
	respawnMagazines[] = {"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","16Rnd_9x21_Mag","16Rnd_9x21_Mag","SUP_flash","SUP_flash","SUP_flash","SUP_flash"};
	cost = 60000;
	threat[] = {1,0.3,0.1};
	linkedItems[] = {"V_PlateCarrierGL_rgr","H_HelmetB_paint","NVGoggles","ItemMap","ItemCompass","ItemWatch","ItemRadio"};
	respawnLinkedItems[] = {"V_PlateCarrierGL_rgr","H_HelmetB_paint","NVGoggles","ItemMap","ItemCompass","ItemWatch","ItemRadio"};
};
};

Edited by super-truite

Share this post


Link to post
Share on other sites

well done i am glad i could be part of the help along with others :).

i did actually make one yesterday so was waiting to see how you went along ;) .

a clue/hint for your script thing : >

BIS_Effects_EH_Fired=compile preprocessFileLineNumbers "\A3\data_f\ParticleEffects\SCRIPTS\fired.sqf";
_this call (call compile GetText (configFile >> "CfgAmmo" >> _amm >> "muzzleEffect"));

Share this post


Link to post
Share on other sites

Ah, I had an annoying feeling/recollection all this time that there was a some weird thing about thrown weapons, but I couldn't remember why.

Glad it worked in the end, I'm still rather rusty with these configs ;)

Share this post


Link to post
Share on other sites

I modified a bit the config so that every soldiers can use the flashbang:





class CfgPatches
{
class SUP_flash  
{
	units[] = {};
	weapons[] = {"SUP_flash_throw"};
	requiredAddons[] = { "A3_characters_F", "A3_Data_F"};	
};
};


class CfgCloudlets
{
class Default;
class SUP_flashExp: Default
{
	circleVelocity[] = {0,0,0};
	moveVelocity[] = {0,0,0};
	size[] = {"4 + 4 * intensity","6 + 4 * intensity"};
	color[] = {
		{ 0.45,1,0.83,0 },
		{ 0.45,1,0.25,0.03 },
		{ 0.45,1,0.25,0.03 },
		{ 0.45,1,0.25,0.03 },
		{ 0.45,1,0.83,0 }};
	animationSpeed[] = {1000};
	positionVar[] = {"3 * intensity","1.2 * intensity","3 * intensity"};
	MoveVelocityVar[] = {1.75,1.75,1.75};
	colorVar[] = {0,0,0,0.02};
	interval = "0.007 * interval + 0.007";
	circleRadius = "intensity";
	particleShape = "\A3\data_f\ParticleEffects\Universal\Universal";
	particleFSNtieth = 16;
	particleFSIndex = 13;
	particleFSFrameCount = 2;
	particleFSLoop = 0;
	angleVar = 1;
	animationName = "";
	particleType = "Billboard";
	timerPeriod = 1.5;
	lifeTime = "25 + 20 * intensity";
	rotationVelocity = 0;
	weight = 4;
	volume = 1;
	rubbing = 0;
	randomDirectionPeriod = 0.01;
	randomDirectionIntensity = 0.08;
	onTimerScript = ""; //put script here
	beforeDestroyScript = "";
	lifeTimeVar = 0.2;
	rotationVelocityVar = 1;
	sizeVar = 2;
	randomDirectionPeriodVar = 2;
	randomDirectionIntensityVar = 0.1;
};
class SUP_flashExp2: Default
{
	circleVelocity[] = {0,0,0};
	moveVelocity[] = {0,0,0};
	size[] = {"4 + 4 * intensity","6 + 4 * intensity"};
	color[] = {
		{ 0.45,1,0.83,0 },
		{ 0.45,1,0.25,0.03 },
		{ 0.45,1,0.25,0.03 },
		{ 0.45,1,0.25,0.03 },
		{ 0.45,1,0.83,0 }};
	animationSpeed[] = {1000};
	positionVar[] = {"3 * intensity","1.2 * intensity","3 * intensity"};
	MoveVelocityVar[] = {1.75,1.75,1.75};
	colorVar[] = {0,0,0,0.02};
	interval = 1;
	circleRadius = "intensity";
	particleShape = "\A3\data_f\ParticleEffects\Universal\Universal";
	particleFSNtieth = 16;
	particleFSIndex = 13;
	particleFSFrameCount = 2;
	particleFSLoop = 0;
	angleVar = 1;
	animationName = "";
	particleType = "Billboard";
	timerPeriod = 0.01;
	lifeTime = 1;
	rotationVelocity = 0;
	weight = 4;
	volume = 1;
	rubbing = 0;
	randomDirectionPeriod = 0.01;
	randomDirectionIntensity = 0.08;
	onTimerScript = "\SUP_flash\scripts\flashbang.sqf"; //put script here
	beforeDestroyScript = "";
	lifeTimeVar = 0.1;
	rotationVelocityVar = 1;
	sizeVar = 2;
	randomDirectionPeriodVar = 2;
	randomDirectionIntensityVar = 0.1;
};
class SUP_flashSmoke: Default
{
	circleVelocity[] = {0,0,0};
	moveVelocity[] = {0,1,0};
	size[] = {"1.013 * intensity + 3","1.0125 * intensity + 5","1.013 * intensity + 7","2.013 * intensity + 10"};
	color[] = {
		{ 0.9,1,0.83,0.2 },
		{ 0.9,1,0.83,0.6 },
		{ 0.9,1,0.83,0.2 },
		{ 0.9,1,0.83,0 }};
	animationSpeed[] = {0.2};
	positionVar[] = {1.2,0.6,1.2};
	MoveVelocityVar[] = {3,1.5,3};
	colorVar[] = {0,0,0,0.1};
	interval = "0.014 * interval + 0.014";
	circleRadius = 0;
	particleShape = "\A3\data_f\ParticleEffects\Universal\Universal";
	particleFSNtieth = 16;
	particleFSIndex = 12;
	particleFSFrameCount = 8;
	particleFSLoop = 0;
	angleVar = 1;
	animationName = "";
	particleType = "Billboard";
	timerPeriod = 1;
	lifeTime = "5 * intensity";
	rotationVelocity = 0;
	weight = 0.053;
	volume = 0.04;
	rubbing = 0.15;
	randomDirectionPeriod = 0.2;
	randomDirectionIntensity = 0.2;
	onTimerScript = "";
	beforeDestroyScript = "";
	lifeTimeVar = 2;
	rotationVelocityVar = 5;
	sizeVar = 0.4;
	randomDirectionPeriodVar = 0.5;
	randomDirectionIntensityVar = 0.02;
};
};
class CfgLights
{
class SUP_flashLight
{
	color[] = {10,10,9.37};
	ambient[] = {0.35,0.35,0.35};
	brightness = 1;
	diffuse[] = {0,0,0};
	position[] = {0,0,0};
};
};







class SUP_flashExplosion
{
class Light1
{
	position[] = {0,0,0};
	simulation = "light";
	type = "SUP_flashLight";
	intensity = 1;
	interval = 1;
	lifeTime = 1;
};
class GrenadeExp1
{
	position[] = {0,0,0};
	simulation = "particles";
	type = "SUP_flashExp";
	intensity = 0.5;
	interval = 1;
	lifeTime = 1;
};
class GrenadeExp2
{
	position[] = {0,0,0};
	simulation = "particles";
	type = "SUP_flashExp2";
	intensity = 0.5;
	interval = 0.01;
	lifeTime = 0.015;
};
class GrenadeSmoke1
{
	position[] = {0,0,0};
	simulation = "particles";
	type = "SUP_flashExp"; //SUP_flashSmoke
	intensity = 0.5;
	interval = 1;
	lifeTime = 1;
};
};
class CfgAmmo 
{
class Default;	// External class reference
class Grenade : Default 
{
	explosionTime = 2;
};
class GrenadeHand : Grenade {};
class SUP_flash_ammo  : GrenadeHand 
{
	scope = 1;
	hit = 0.001;
	indirectHit = 0.001;
	indirectHitRange = 0.01;
	model = "\SUP_flash\flash.p3d"; //  mettre ça plus tard  \SUP_flash\flash.p3d
	//\A3\Weapons_f\ammo\smokegrenade_white
	visibleFire = 0.5;
	audibleFire = 0.05;
	visibleFireTime = 1;
	fuseDistance = 5;
	ExplosionEffects = "SUP_flashExplosion";
	explosionSoundEffect = "DefaultExplosion";
};
};

class cfgMagazines
{
class Default;	// External class reference
class CA_Magazine : Default {};
class HandGrenade : CA_Magazine {};
class SUP_flash :  HandGrenade
{
    model = "\SUP_flash\flash.p3d";   //  mettre ça plus tard  \SUP_flash\flash.p3d
	displayName = "flashbang";
	picture = "\SUP_flash\flash.paa";
	displayNameShort = "flash";
	ammo = "SUP_flash_ammo";
};
};


class CfgWeapons 
{
class Default;
class GrenadeLauncher : Default {};
class Throw : GrenadeLauncher {

muzzles[] = {"HandGrenade_Stone","HandGrenadeMuzzle","MiniGrenadeMuzzle","SmokeShellMuzzle","SmokeShellYellowMuzzle","SmokeShellGreenMuzzle","SmokeShellRedMuzzle","SmokeShellPurpleMuzzle","SmokeShellOrangeMuzzle","SmokeShellBlueMuzzle","ChemlightGreenMuzzle","ChemlightRedMuzzle","ChemlightYellowMuzzle","ChemlightBlueMuzzle","SUP_FLash_Muzzle"};


	class  ThrowMuzzle: GrenadeLauncher
	{
		aidispersioncoefx = 6;
		aidispersioncoefy = 6;
		autoreload = 1;
		cursor = "EmptyCursor";
		cursoraim = "throw";
		enableattack = 0;
		keepininventory = 1;
		magazinereloadtime = 0;
		maxrange = 60;
		maxrangeprobab = 0.03;
		midrange = 45;
		midrangeprobab = 0.9;
		minrange = 10;
		minrangeprobab = 0.2;
		modeloptics = "";
		reloadsound[] = {"", 0.000316228, 1};
		reloadtime = 0;
		showempty = 0;
		sound[] = {"", 0.000316228, 1};

	};

	class SUP_FLash_Muzzle: ThrowMuzzle
	{
		magazines[] = {"SUP_Flash"};
	};
};
};



compared to what I was doing before with your help, I overwrite the class Throw to include my new weapon. I feel like I am doing something heretic, yet it works.

Am I a bad boy or is it OK to do that :) ?

My flashbang is almost done (It needs some polish but it is more or less functional against humans and AI). Thanks again for the help.

Share this post


Link to post
Share on other sites

It's ok to overwrite for a total conversion like dayz or project reality because it won't interfere with other addons , if yours is to be public it could mess with others inheritance if someone combines your mod and another or yours could be overwritten again , all depends on what your making it for

You can be selfish and say I made it for my clan and I think your lucky I shared

Or you can try and make it in the least intrusive way

In the end it's your desicion , you could even make both and release one .

It's all very subjective really :)

There's nothing stopping you creating a group of units and adding biz muzzles to your muzzle and calling them something fitting too don't forget , after all I'm sure it's not every soldier in every scenario would use these flash ?

Edited by Thromp

Share this post


Link to post
Share on other sites

Ok, thanks, I didn't think of this subtlety I'll release the least intrusive one then. But it's really restrictive for the user, because for instance if someone wants to use the flashbang with a special force mod, he won't be able to do it unless he create a new soldier class which would inherit from the special force soldier class and then add the flashbang to its weapons (something I wouldn't have been able to do yesterday :) and that most of the people don't know how to do). There must be some way to make this without overwriting the "Throw" class. Cannot I in some sense take muzzles[] in the Throw class and add to it my new weapon whatever the list is (meaning that if some mod has already overwritten the class, I won't remove the new weapons, but just add to it mine). A sort of sqf analogy would be muzzles_array = muzzles_array+[my new muzzle array] while at the moment I am doing a brutal muzzles_array = mynewmuzzles_array.

Share this post


Link to post
Share on other sites

You have a few options really , the most stable would be to script it fully and use fired event handler and doing the swap out method where the old grenade I'd deleted and yours replaces , Use CBA and you negate the problem of overwriting event handlers.

Or you could overwrite the stone grenade which isn't use

I personally would opt for the special unit and let others learn from your code so they can make there own if they wish :) ,

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×