Jump to content
Sign in to follow this  
dmarkwick

Need to move on now

Recommended Posts

OK, I need some help with the next phase of my DMSmokeEffects addon, specifically I need to know how to make it a "magic" addon, so the smoke effects work just by having the addon.

The config part of the addon is just fine, I see that in any mission by default. But the smoke effects (which is really the core of the addon) needs to have a trigger in the mission before it works.

Essentially it's a huge trigger that adds an eventhandler to every unit on the map. How can I get this activity through an addon? Is a trigger even the best way to do this?

Share this post


Link to post
Share on other sites
Guest

i think you dont need nothing

u need trigger because your smoke is outside addons

when you put your smoke effects into an addon, (vehicle for example) it creates an event when destructed so you can launch your scripts, ... from there

say if i'm wrong

Share this post


Link to post
Share on other sites

Have you tried overwriting (e.g.) buildings' event handlers (e.g. the init-event handler) directly in your config yet? I.e.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//...

class SomeBISBuilding{

  //...

  class EventHandlers

  {

     init =""; // Exec or call custom script here

  };

//...

};

Just a guess, cannot verify anything at the moment.

Share this post


Link to post
Share on other sites

this should work as long as you have a correct cfgPatches. you

need to add the ArmA addon classes to requiredAddons which you

overwrite with your EH(s).

Share this post


Link to post
Share on other sites
Quote[/b] ]Essentially it's a huge trigger that adds an event handler to every unit on the map. How can I get this activity through an addon? Is a trigger even the best way to do this?

If when you say "every unit" you mean all Men and Vehicles then a triggers not a bad solution, but not for buildings. At least with a trigger you can use any addon in your mission without having to create a new config for it. Also you don't have to go and add to the init field, for every unit on the map.

But with dynamically created units or respawning units in MP, your going to have to constantly monitor the trigger. If you forget about the code to create the trigger for now, you will have something like this, running every x seconds of your mission:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_OldInfantry=[];

_OldVehicles=[];

_LastCount=-1;

WaitUntil

       {

       _CurrList=+(List _MainTrigger);

       _CurrCount=Count _CurrList;

       If (_CurrCount!=_LastCount) Then

               {

               _LastCount=_CurrCount;

               _CurrInfantry=[];

                       {

                       _CurrInfantry=_CurrInfantry+[Crew _x];

                       } ForEach _CurrList;

               _NewInfantry=_CurrInfantry-_OldInfantry;

               _OldInfantry=+_CurrInfantry;

                       {

                       .....Add your Infantry event handlers here

                       } ForEach _NewInfantry;

               Sleep 0.5;

               _CurrVehicles=+Vehicles;

               

               _NewVehicles=_CurrVehicles-_OldVehicles;

               _OldVehicles=+_CurrVehicles;

                       {

                       .....Add your Vehicle event handlers here

                       } ForEach _NewVehicles;

               };

       Sleep 0.5;                

       (False)

       };

Obviously if you have loads of units in your mission, it could cause some lag. But Arma's scripting is pretty fast and you could always adjust the number and duration of the sleep commands.

Share this post


Link to post
Share on other sites
Quote[/b] ]Essentially it's a huge trigger that adds an event handler to every unit on the map. How can I get this activity through an addon? Is a trigger even the best way to do this?

If when you say "every unit" you mean all Men and Vehicles then a triggers not a bad solution, but not for buildings. At least with a trigger you can use any addon in your mission without having to create a new config for it. Also you don't have to go and add to the init field, for every unit on the map.

But with dynamically created units or respawning units in MP, your going to have to constantly monitor the trigger. If you forget about the code to create the trigger for now, you will have something like this, running every x seconds of your mission:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_OldInfantry=[];

_OldVehicles=[];

_LastCount=-1;

WaitUntil

{

_CurrList=+(List _MainTrigger);

_CurrCount=Count _CurrList;

If (_CurrCount!=_LastCount) Then

{

_LastCount=_CurrCount;

_CurrInfantry=[];

{

_CurrInfantry=_CurrInfantry+[Crew _x];

} ForEach _CurrList;

_NewInfantry=_CurrInfantry-_OldInfantry;

_OldInfantry=+_CurrInfantry;

{

.....Add your Infantry event handlers here

} ForEach _NewInfantry;

Sleep 0.5;

_CurrVehicles=+Vehicles;

_NewVehicles=_CurrVehicles-_OldVehicles;

_OldVehicles=+_CurrVehicles;

{

.....Add your Vehicle event handlers here

} ForEach _NewVehicles;

};

Sleep 0.5;

(False)

};

Obviously if you have loads of units in your mission, it could cause some lag. But Arma's scripting is pretty fast and you could always adjust the number and duration of the sleep commands.

I could get the trigger to activate every couple of seconds or so, I doubt there's much lag induced by it.

What I don't know is whether adding an event handler twice to any unit has any detrimental effect, will they just keep piling up and eventually run all the added eventhandlers once killed? (The evenhandler is on the "killed" event.) or will the eventhandlers just be seen as one?

Will setting the trigger to "repeat" make a difference to dynamic unit missions you reckon?

*edit* BTW, building effects etc are handled through configs, I'm just discussing the extra effects here, ones that are not called automatically.

Share this post


Link to post
Share on other sites

well loading an additional addon is a lot more convenient than editing every mission to get the effects?!

of course you could offer both solutions as well.

Share this post


Link to post
Share on other sites
well loading an additional addon is a lot more convenient than editing every mission to get the effects?!

of course you could offer both solutions as well.

This is what I'm trying to achieve now smile_o.gif a "magic" addon that "just works".

Share this post


Link to post
Share on other sites
Quote[/b] ]This is what I'm trying to achieve now smile_o.gif a "magic" addon that "just works".

to achieve that you must say how your scripts work smile_o.gif.

i am sorry but i havent used them ,so let me specualte if i may?

your scripts mask the original effects of the engine ?

if so then you must find where these scripts are activated in the engine.

this will either be very simple for you if have covered from the core

i.e you have covered major events like building destruction or wheeledkilled etc.

then you simply make your pbo. you copy the original class of destruction but where the original effects link to an internal script , you change this to your \your.pbo\yourscript.

this way your pbo because it is loaded after the ADDONS pbo will update all classes and your effects will be vanilla effects and not arma.

fort a really basic exaple of this take a peek at any addon that over rides the default classes ,such as the replacement troops or raedors sandbags

if i have completely misunderstood your request pls ingore wink_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]This is what I'm trying to achieve now smile_o.gif a "magic" addon that "just works".

to achieve that you must say how your scripts work smile_o.gif.

i am sorry but i havent used them ,so let me specualte if i may?

your scripts mask the original effects of the engine ?

if so then you must find where these scripts are activated in the engine.

this will either be very simple for you if have covered from the core

i.e you have covered major events like building destruction or wheeledkilled etc.

then you simply make your pbo. you copy the original class of destruction but where the original effects link to an internal script , you change this to your \your.pbo\yourscript.

this way your pbo because it is loaded after the ADDONS pbo will update all classes and your effects will be vanilla effects and not arma.

fort a really basic exaple of this take a peek at any addon that over rides the default classes ,such as the replacement troops or raedors sandbags

if i have completely misunderstood your request pls ingore wink_o.gif

Duly ignored wink_o.gif

The effects are basically two different types, replacements and additions. The replacements are already OK, they work via configs.

The additions are the problem, and are currently activated by a trigger that must be in the mission. This is what I want to remove.

Share this post


Link to post
Share on other sites

ah as usual my tanents are best served up in artillery.

have you tried the logic route ?

this way people only have to add your logic to there missions.

see nim weather or any mapfact type addon .

you prolly have but to succeed is to eliminate or something .lol

Share this post


Link to post
Share on other sites
Quote[/b] ]What I don't know is whether adding an event handler twice to any unit has any detrimental effect, will they just keep piling up and eventually run all the added eventhandlers once killed? (The evenhandler is on the "killed" event.) or will the eventhandlers just be seen as one?

Will setting the trigger to "repeat" make a difference to dynamic unit missions you reckon?

If your talking about calling the same bit of code multiple times from multiple event handlers then its not really recommended. It has the potential of bringing the mission to a grinding halt.

But there is no need. If you don't already have an object you can place on the map in your current config. Just create a game logic that creates a repeating trigger when the mission starts using the logics init event.

Also from that logics init event, call something like the script I posted above. It's designed to only add eventhandlers to current\new objects once, during the mission. So it will cater for respawns and units created while the missions running. It's a reasonable efficient way of doing it, could be made a little better if you added getin and getout events to help keep track of who is in a vehicle.

Share this post


Link to post
Share on other sites

sorry i didn't get whats wrong with EH's in the config like weedomatic suggested.

here is like it works in WGL5 in OFP. i guess it still works pretty much the same.

note that i made the class inheritance ArmA style already

http://pastebin.ca/653561 (for better code viewing)

inside the the addon wglevents.pbo the wglinit.sqs:

// i removed all non interesting stuff. basically its own to this line here:

// [] exec "\WGLEvents\destroyedFX\destroyedDetect.sqs"

// however you mind find the rest interesting as well hopefully smile_o.gif

PS: it is very likely to make this better / more optimized though

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(WGLinit): goto "initDone"

WGLinit = true

WGLinitds= false

WGLMPgame={playersNumber _x>0}count[east,west,resistance,civilian]>0

?!WGLMPgame:[]exec"wglinitsp.sqs"

WGLdedy=false

_nstring = "scalar bool array string 0xfcffffef"

[] exec "\WGLEvents\destroyedFX\destroyedDetect.sqs"

[] exec "\WGLEvents\weaponFX\weaponFXinit.sqs"

[] exec "\WGLEvents\vehicleFX\weaponFXinit.sqs"

?(format["%1",WGLDisableDestructionFX] == _nstring): WGLDisableDestructionFX = !(["Prefs","exploFX"]call WGLfGetProperty)

WGLrotorwashPlayerFX = false

WGLheliEngines=[]

WGLheliDMG=[]

#initDone

_unit = _this select 0

?("Helicopter"countType[_unit]>0):[_unit] call loadfile"\wglevents\heliFX\heliInit.sqf"

?("Plane"countType[_unit]>0): [_unit] call loadfile"\wglevents\heliFX\heliInit.sqf"

; Have units inside vehicles from the start be included in the WGL unit arrays and

; spectator script "DeathCamArray" (both of which men_init.sqf takes care of)

?{_x countType[_unit]>0}count["Air","LandVehicle","Ship"]>0:{[_x]call loadFile"\wgl_zm\men\men_init.sqf"}forEach(crew _unit)

~1

?(player!=player)&&WGLMPgame:WGLdedy=true;if!(WGLinitds)then{WGLinitds=true;[]exec"wglinitds.sqs"}

?("Man" countType [_unit] > 0): _unit addWeapon "WGLObjCarry";_unit addWeapon "WGL_Put";_unit addWeapon "WGL_Throw"

?!(local player)||(WGLplayerside==WGLplayerside): exit

WGLplayerside=side player

#end

exit

Share this post


Link to post
Share on other sites
Quote[/b] ]sorry i didn't get whats wrong with EH's in the config like weedomatic suggested.

I think DMarkwick wants his scripts to run with all addons, rather than a specific addon?

This way he can automaticaly support the default Arma units as well as those made by other mods. Without having to keep creating new configs and pbos every time someone releases new units.

Share this post


Link to post
Share on other sites

yea sure. thats the reason you add them to the bases class like car, tank, men etc (check code in pastebin)

ps: of course once you've got addons overwriting the init EH, it most probably doesn't work any longer for these.

thats why i suggested to do both solutions.

Share this post


Link to post
Share on other sites

I see, sorry. I only read this line fully (and weedomatic's original post):

Quote[/b] ]sorry i didn't get whats wrong with EH's in the config like weedomatic suggested.

Weedomatic suggested something different to the WGL method, so I did not think to read on. With the new method of inheriting in Arma, a third party addon might only declare:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Class SoldierWB;

e.t.c In thier config.

But if it does still work then that is a better solution.

Share this post


Link to post
Share on other sites

No worries mate. smile_o.gif I scribbled my stuff as well. icon_rolleyes.gif

The stuff i posted doesn't work that way in ArmA or at least

it can be made better. It was only meant to show the principle.

That is "add eventhandlers to the base classes to be found in the

main config" (ArmA\dta\bin).

This should work as the access values allows these classes to get

overwritten / config values added.

Only the cfgPatches must be declared correctly to make this work.

I would suggest to use the bases classes, one might go for the

actual unit classes as well, but i can't see a benefit here.

Share this post


Link to post
Share on other sites

I should know better than to skim through posts.

Anyway, you peaked my curiosity, so I had to give it a try smile_o.gif I think this was what you were suggesting?

MyBaseClass.pbo:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class CfgPatches

       {

       class MyBaseClass

               {

               units[] = {};

               weapons[] = {};

               requiredVersion = 0.1;

               requiredAddons[] = {CACharacters};

               };

       };

class cfgVehicles

       {

       class Land;

       class Man : Land

               {

               class eventhandlers

                       {

                       fired="Hint ""Bang Bang""";

                       };

               };

       };

AWestSoldier.pbo:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class CfgPatches

       {

       class AWestSoldier

               {

               units[] = {"AWestSoldier"};

               weapons[] = {};

               requiredVersion = 0.1;

               requiredAddons[] = {};

               };

       };

class cfgVehicles

       {

       class SoldierWB;

       class AWestSoldier : SoldierWB

               {

               Scope=2;

               DisplayName="My New Soldier";

               };

       };

For the AWestSoldier.pbo config I did'nt bother adding the requiredAddons section. As I think this would be closer to what DMarkWick originaly wanted. If you imagine AWestSoldier.pbo could be an addon that was created and released before his own addon.

It all seemed to work ok. But there was one issue, the Hint now shows up for any unit placed on the map simply because the addon was present in the addons folder. So it would effect every mission, regardless of whether the mission designer\server admin wanted that or not.

But if you change the config for MyBaseClass.pbo to add a logic as an effect switch:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class CfgPatches

       {

       class MyBaseClass

               {

               units[] = {"DMWSwitchEffects"};

               weapons[] = {};

               requiredVersion = 0.1;

               requiredAddons[] = {CACharacters};

               };

       };

class cfgVehicles

       {

       class Logic;

       class DMWSwitchEffects : Logic

               {

               DisplayName="Enable DMW Effects";

               class eventhandlers

                       {

                       init="DMWEFFECTS=True";

                       };

               };

       class Land;

       class Man : Land

               {

               class eventhandlers

                       {

                       fired="If DMWEFFECTS Then {Hint ""Bang Bang""}";

                       };

               };

       };

Ok, so your adding an extra event handler to every infantry guy in every mission played, while the addon is installed. Even if they do not want to use the effects scripts for that particular mission. In most cases it probably won't have any adverse effect. So all in all I think it works out as a better solution to a giant trigger  thumbs-up.gif

Share this post


Link to post
Share on other sites

Thanks for all the info & suggestions guys, I do appreciate it smile_o.gif

The trigger as it stands does add an eventhandler to everything on the battlefield (map objects not included) and there's no ill effects or performance impact so I'm happy to follow that up with adding it in config. The EH should be applied to every moving object really, so I suppose that would be the AllVehicles base class? I think that includes soldiers so that would be fine.

The soldiers currently aren't handled in the DMSmokeEffects (Although for testing I do make soldiers pop out an angel whenever one dies) I did have ideas of having dead soldiers' bodies smoldering slightly from shrapnel if killed by shel/grenade/explosion etc. But that's a future project smile_o.gif

Share this post


Link to post
Share on other sites

exactly UNN - great job presenting an accurate example smile_o.gif

thumbs-up.gif

Share this post


Link to post
Share on other sites

I cannot get an evenhandler into the config.

The code from the trigger that I use now is:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x addEventHandler ["killed", {[_this select 0, _this select 1] execVM "DMSmokeEffects\Scripts\DMSmokeEffects.sqf"}]} foreach thislist;

And I need to apply it to AllVehicles. I tried using code samples from the above examples provided by UNN, with variations, but not one single attempt worked.

Share this post


Link to post
Share on other sites

in the config it has to look like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

class Man: Land

{

class EventHandlers

{

killed = "_this exec "\WGLEvents\onPlayerDeathBlack.sqs"";

};

};

(this is ofp code, so the script call could be different)

Share this post


Link to post
Share on other sites

Minor syntactic and semantic correction:

class Man: Land

{

class EventHandlers

{

killed = "_this execVM ""\WGLEvents\onPlayerDeathBlack.sqs""";

};

};

Share this post


Link to post
Share on other sites

cheers weedomatic smile_o.gif

Share this post


Link to post
Share on other sites

Well the code I have now, and which doesn't work, looks like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

class CfgPatches

{

class DMSmokeEffects

{

units[] = {};

weapons[] = {};

requiredVersion = 0.1;

requiredAddons[] = {"CAData"};

};

};

class CfgVehicles

{

class All

{

class AllVehicles

{

class eventhandlers

{

killed = "[_this select 0, _this select 1] execVM ""DMSmokeEffects\Scripts\DMSmokeEffects.sqf""";

};

};

};

};

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  

×