legion7698 0 Posted November 8, 2009 Hey All, I'm trying to make and addon that comes in the form of a small mortar (51mm) and a packpack. What I'm currently trying to achieve at the moment is evertime a person has the backpack they recieve an action to place the mortar, and evertime there in the mortar they have the action to pack it back into the backpack. I can achieve this perfectly in the mission editor by adding the script calls into the units, that are using the addons, INIT line but for ease of use I want to have it attached to the config. If anyone can help I would be very thankfull. Regards, LEGION7698. P.S. I have tried searching but could not find anything that works. Share this post Link to post Share on other sites
ProfTournesol 956 Posted November 8, 2009 Hi, you can do the same through the config thanks to the init eventhandler :add this inside the config of your soldier : class my_soldier:soldierWB {blablabla class EventHandlers { init = "(_this select 0) exec "\mypbo\scripts\myscript.sqs""; }; }; Share this post Link to post Share on other sites
legion7698 0 Posted November 8, 2009 Hey ProfTournesol, It unfortunatly creates an error upon trying to start up OFP with those lines, I think this could be as the lines are for a soldier config where as this a secondary weapon config. Also, from my little amount of understanding, dosn't putting that type of EH make it run straight away? The effect I'm after should be activated by the action menu. I do apoligise, my understanding of configs is null and void and thank you for the help so far. Regards, LEGION7698. Share this post Link to post Share on other sites
ProfTournesol 956 Posted November 8, 2009 Well, you may post your action script / command line you put in the init here. Share this post Link to post Share on other sites
legion7698 0 Posted November 9, 2009 (edited) Ok So here is my script so far for the backpack a1 removeweapon "RC_BP"Mortar="RC_51mm" createVehicle position Player ID2=Mortar addaction ["Pack Mortar","Backpack.sqs"] a1 removeaction ID1 and here is the script i want attached to the mortar deletevehicle Mortara1 addweapon "RC_BP" ID1=a1 addaction ["Place Mortar","Mortar.sqs"] Now this works if i put it into the units INIT field, but what i want is to add this to the config for the backpack and mortar, so i then dont have to put these scripts into every mission. (obviously when i attach these to the configs I'll be changing it slightly). Here is also the two configs i need the scripts attached to. #define TEast 0#define TWest 1 #define TGuerrila 2 #define TCivilian 3 #define TSideUnknown 4 #define TEnemy 5 #define TFriendly 6 #define TLogic 7 #define true 1 #define false 0 // type scope #define private 0 #define protected 1 #define public 2 #define WeaponNoSlot0 // dummy weapons #define WeaponSlotPrimary1 // primary weapons #define WeaponSlotSecondary16 // secondary weapons #define WeaponSlotHandGun2 // HandGun #define WeaponSlotHandGunItem32 // HandGun magazines #define WeaponSlotItem256 // items #define WeaponSlotBinocular4096 // binocular #define WeaponHardMounted65536 class CfgPatches { class RC_BP { units[]={""}; weapons[]={"RC_BP"}; requiredVersion=1.750000; }; }; class CfgModels { class default {}; class Weapon: default {}; class RC_BP: Weapon {}; }; class CfgWeapons { class Default {}; class LAWLauncher: Default {}; class RPGLauncher: Default {}; class CarlGustavLauncher : LAWLauncher {}; class AT4Launcher : CarlGustavLauncher {}; class RC_BP: LAWLauncher { model="\backpack\RC_BP"; distanceZoomMin=100; distanceZoomMax=100; displayName="backpack"; picture=""; initSpeed=120; magazines[]={}; sound[]={}; reloadMagazineSound[]={}; }; class RC_BPMag: RC_BP { } // some basic defines #define TEast 0 #define TWest 1 #define TGuerrila 2 #define TCivilian 3 #define TSideUnknown 4 #define TEnemy 5 #define TFriendly 6 #define TLogic 7 #define true 1 #define false 0 // type scope #define private 0 #define protected 1 #define public 2 #define WeaponNoSlot 0// dummy weapons #define WeaponSlotPrimary 1// primary weapons #define WeaponSlotSecondary 16// secondary weapons #define WeaponSlotItem 256// items #define WeaponSlotBinocular 4096// binocular #define WeaponHardMounted 65536 #define CanSeeRadar 1 #define CanSeeRye 2 #define CanSeeOptics 4 #define CanSeeEar 8 #define CanSeeCompass 16 #define CanSeeRadarC CanSeeRadar+CanSeeCompass #define CanSeeAll 31 class CfgPatches { class RC_51mm { units[] = {RC_51mm}; requiredVersion = 1.01; }; }; class CfgAmmo { class Default{}; class Grenade: Default{}; class MortarShell: Grenade{}; class RC_51mmAmmo: MortarShell { minRangeProbab=0.900000; midRange=150; midRangeProbab=0.950000; maxRange=600; maxRangeProbab=0.400000; }; }; class WeaponFireGun {}; class WeaponCloudsGun {}; class WeaponFireMGun: WeaponFireGun {}; class WeaponCloudsMGun: WeaponCloudsGun {}; class CfgWeapons { class Default{}; class GrenadeLauncher: Default{}; class Mortar: GrenadeLauncher{}; class RC_51mm: Mortar{ ammo=RC_51mmAmmo; count=40; initSpeed=100; reloadTime=3; magazineReloadTime=0.010000; optics = true; opticsZoomMin=0.04; opticsZoomMax=0.12; distanceZoomMin=400; distanceZoomMax=80; }; }; class RC_51mmClouds : WeaponCloudsMGun{ access=3; cloudletGrowUp=0.050000; cloudletFadeIn=0; cloudletFadeOut=0.100000; cloudletDuration=0.050000; cloudletAlpha=0.300000; cloudletAccY=0; cloudletMinYSpeed=-100; cloudletMaxYSpeed=100; interval=0.020000; size=0.000000; sourceSize=0.020000; }; class CfgVehicles { class All{}; class AllVehicles:All{}; class Land: AllVehicles{}; class LandVehicle: Land{}; class Tank: LandVehicle{}; class APC: Tank{}; class M113:APC{}; class M2StaticMG: M113{}; class RC_51mm: M2StaticMG { displayName="51mm Mortar"; picture="im113"; model="\51mm mortar\RC_51mm"; cost=15000; weapons[]={"RC_51mm"}; magazines[]={"RC_51mm"}; side=1; crew="SoldierWB"; sensitivity=3; hasCommander=0; commanderOpticsModel="optika_dalekohled"; threat[]={1,0.100000,0.100000}; armor=60; armorStructural=20.000000; icon="kulomet.paa"; commanderAction="ManActRC_51mmCommander"; commanderInAction="ManActRC_51mmCommander"; gunnerAction="ManActRC_51mmGunner"; gunnerInAction="ManActRC_51mmGunner"; class GunFire: WeaponCloudsMGun{}; class GunClouds: RC_51mmClouds {}; class MGunFire: WeaponFireMGun {}; class MGunClouds: WeaponCloudsMGun {}; class Turret { gunAxis = "osahlavne"; turretAxis = "osaveze"; soundServo[]={Vehicles\gun_elevate2,db-30,1.0}; gunBeg = "usti hlavne"; gunEnd = "konec hlavne"; body = "OtocVez"; gun = "OtocHlaven"; minElev=-30; maxElev=+90; minTurn=-360; maxTurn=+360; }; class ComTurret { turretAxis="OsaVelitele"; gunAxis="OsaHlavneVelitele"; soundServo[]={"Vehicles\gun_elevate2",0.000316,1.200000}; gunBeg="usti hlavne"; gunEnd="konec hlavne"; minElev=-4; maxElev=20; minTurn=-360; maxTurn=360; body="OtocVelitele"; gun="OtocHlavenVelitele"; }; }; }; class CfgNonAIVehicles { class ProxyWeapon{}; class ProxytRC_51mm: ProxyWeapon{}; }; class CfgVehicleActions { RC_51mmGunner="CombatToMedic"; RC_51mmCommander="CombatToBinoc"; } Regards, LEGION7698. Edited November 9, 2009 by LEGION7698 Share this post Link to post Share on other sites
ProfTournesol 956 Posted November 9, 2009 Ok, so i will modify slightly the scripts and the config. To add the script in the init of the mortar, we can do it this way : // some basic defines #define TEast 0 #define TWest 1 #define TGuerrila 2 #define TCivilian 3 #define TSideUnknown 4 #define TEnemy 5 #define TFriendly 6 #define TLogic 7 #define true 1 #define false 0 // type scope #define private 0 #define protected 1 #define public 2 #define WeaponNoSlot 0// dummy weapons #define WeaponSlotPrimary 1// primary weapons #define WeaponSlotSecondary 16// secondary weapons #define WeaponSlotItem 256// items #define WeaponSlotBinocular 4096// binocular #define WeaponHardMounted 65536 #define CanSeeRadar 1 #define CanSeeRye 2 #define CanSeeOptics 4 #define CanSeeEar 8 #define CanSeeCompass 16 #define CanSeeRadarC CanSeeRadar+CanSeeCompass #define CanSeeAll 31 class CfgPatches { class RC_51mm { units[] = {RC_51mm}; requiredVersion = 1.01; }; }; class CfgAmmo { class Default{}; class Grenade: Default{}; class MortarShell: Grenade{}; class RC_51mmAmmo: MortarShell { minRangeProbab=0.900000; midRange=150; midRangeProbab=0.950000; maxRange=600; maxRangeProbab=0.400000; }; }; class WeaponFireGun {}; class WeaponCloudsGun {}; class WeaponFireMGun: WeaponFireGun {}; class WeaponCloudsMGun: WeaponCloudsGun {}; class CfgWeapons { class Default{}; class GrenadeLauncher: Default{}; class Mortar: GrenadeLauncher{}; class RC_51mm: Mortar{ ammo=RC_51mmAmmo; count=40; initSpeed=100; reloadTime=3; magazineReloadTime=0.010000; optics = true; opticsZoomMin=0.04; opticsZoomMax=0.12; distanceZoomMin=400; distanceZoomMax=80; }; }; class RC_51mmClouds : WeaponCloudsMGun{ access=3; cloudletGrowUp=0.050000; cloudletFadeIn=0; cloudletFadeOut=0.100000; cloudletDuration=0.050000; cloudletAlpha=0.300000; cloudletAccY=0; cloudletMinYSpeed=-100; cloudletMaxYSpeed=100; interval=0.020000; size=0.000000; sourceSize=0.020000; }; class CfgVehicles { class All{}; class AllVehicles:All{}; class Land: AllVehicles{}; class LandVehicle: Land{}; class Tank: LandVehicle{}; class APC: Tank{}; class M113:APC{}; class M2StaticMG: M113{}; class RC_51mm: M2StaticMG { displayName="51mm Mortar"; picture="im113"; model="\51mm mortar\RC_51mm"; cost=15000; weapons[]={"RC_51mm"}; magazines[]={"RC_51mm"}; side=1; crew="SoldierWB"; sensitivity=3; hasCommander=0; commanderOpticsModel="optika_dalekohled"; threat[]={1,0.100000,0.100000}; armor=60; armorStructural=20.000000; icon="kulomet.paa"; commanderAction="ManActRC_51mmCommander"; commanderInAction="ManActRC_51mmCommander"; gunnerAction="ManActRC_51mmGunner"; gunnerInAction="ManActRC_51mmGunner"; class GunFire: WeaponCloudsMGun{}; class GunClouds: RC_51mmClouds {}; class MGunFire: WeaponFireMGun {}; class MGunClouds: WeaponCloudsMGun {}; class Turret { gunAxis = "osahlavne"; turretAxis = "osaveze"; soundServo[]={Vehicles\gun_elevate2,db-30,1.0}; gunBeg = "usti hlavne"; gunEnd = "konec hlavne"; body = "OtocVez"; gun = "OtocHlaven"; minElev=-30; maxElev=+90; minTurn=-360; maxTurn=+360; }; class ComTurret { turretAxis="OsaVelitele"; gunAxis="OsaHlavneVelitele"; soundServo[]={"Vehicles\gun_elevate2",0.000316,1.200000}; gunBeg="usti hlavne"; gunEnd="konec hlavne"; minElev=-4; maxElev=20; minTurn=-360; maxTurn=360; body="OtocVelitele"; gun="OtocHlavenVelitele"; }; [b]class eventhandlers { init=" [_this Select 0] exec {\51mm mortar\MortaInit.sqs}"; }; [/b] }; }; class CfgNonAIVehicles { class ProxyWeapon{}; class ProxytRC_51mm: ProxyWeapon{}; }; class CfgVehicleActions { RC_51mmGunner="CombatToMedic"; RC_51mmCommander="CombatToBinoc"; } Now the "MortarInit.sqs", that you put into the "51mm mortar.pbo" file : _mortar = _this select 0 ;let's wait for a gunner being into the mortar crew : #begin @!(isnull gunner _mortar) ;clean eventual residual action gunner _mortar removeaction MortarPack ~1 MortarPack= gunner _mortar addaction ["Pack Mortar","\51mm mortar\Backpack.sqs"] @(isnull gunner _mortar) goto "begin" exit Then the "BackPack.sqs" : _gunner = _this select 0 _gunner removeaction MortarPack deletevehicle nearestObject [_gunner, "RC_51mm"] ;if it doesnt work try (uncomment) the following line instead : ;deletevehicle vehicle _gunner ~0.01 _gunner addweapon "RC_BP" MortarDeploy= _gunner addaction ["Place Mortar","\51mm mortar\Mortar.sqs"] exit Then the "Mortar.sqs" : _gunner = _this select 0 _gunner removeweapon "RC_BP" _gunner removeaction MortarDeploy Mortar="RC_51mm" createVehicle getpos _gunner exit The gunner will only get the "Pack Mortar" command once inside the mortar. Then, you cannot add an action to the backpack weapon cause it isn't a vehicle class. But you can create a soldier with the backpack, with an such an eventhandler in the config : [b]class eventhandlers { init=" [_this Select 0] exec {\backpack\backpack2.sqs}"; }; [/b] With the following "backpack2.sqs" script in the "backpack.pbo" file : _gunner = _this select 0 MortarDeploy= _gunner addaction ["Place Mortar","\51mm mortar\Mortar.sqs"] exit Pay attention to the path of the scripts in the addaction command (put the scripts in the good pbo files). Hope it'll work cause i can't test and i'm quite brain dead tonight :ill: Share this post Link to post Share on other sites
legion7698 0 Posted November 9, 2009 Hey ProfTournesol, Cheers for the help, it now works perfectly. I can now work on improving the backpack and mortar models to a more exeptable level. Regards, LEGION7698 Share this post Link to post Share on other sites