Jump to content
Sign in to follow this  
smacker909

eventhandler question

Recommended Posts

Hello -

I'm adding scoring/point system to my current mission and doing okay, but know have run into something.. The mission spawns some groups using code like

_insGrp=[getMarkerPos _mkr, EAST, (configFile >> "CfgGroups" >> "EAST" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Patrol")] ;

Now, if I wanted to give points for units in the group I can add eventhandler and use

{_x addEventHandler [...code to call script...]} forEach units _insGrp;

But if I wanted give more points for vehicles in the group... say 3 pts for men and 5 pts for vehicles.. what would be the best method to add separate eventhandler to the vehicles in the group?

Share this post


Link to post
Share on other sites

Have the points script check the type of object that called it?

Share this post


Link to post
Share on other sites

I'll try that Kylania, I wasn't sure if the 'units _insGrp' would also grab the vehicles for the group.. My example above was a poor choice because the actual group is a "motor" group of "technicals" which includes units and vehicles. I'm at work, so can't test currently. Will try when I get home :)

Share this post


Link to post
Share on other sites

Thanks, I really screwed up with my code example in the initial post. Im using the BIS_fuc_spawnGroup to spawn a Motor group of units and vehicles (Technicals) .. I think you are saying to check the - type - in the script that is called by the evenhandler.. so I assume if I added evenhandler "killed" to ...foreach units.. in the group.. then that would fire for the men and the vehicles? Sorry for the confusion.

Share this post


Link to post
Share on other sites

Depends on how the points work. Are you scoring points for each group killed or each soldier/vehicle?

Your example was fine, just missing some syntax, for each kill resulting in points. You'd create the group per your normal function. Then do the forEach for each unit in the group applying an MPKilled eventHandler to the unit. Then when they are killed have your script take the input from the eventhandler, the victim and killer and just use a simply switch to apply points. If it was a Man type unit give 'em 1 point if it was a vehicle give 'em 10 points or whatever. At least I hope it works with vehicles, I'll need to check when I get home. heh

For vehicle crew that'll probably not work, they'd be worth no points unless you went in and applied the EH to each crew member. Depends if that matters to you. :)

Share this post


Link to post
Share on other sites

Okay, so here is what I have;

_insPatrol = [_finalPos, EAST, (configFile >> "CfgGroups" >> "EAST" >> "BIS_TK_INS" >> "Motorized" >> "TK_INS_Technicals")] call BIS_fnc_spawnGroup;

{_x addEventHandler ["killed", {[_this select 0, _this select 1] execVM "insKilled.sqf"}]} forEach units _insPatrol;

When any of the soldiers are killed the script runs, but not when I destroy either vehicle in the group. Is there a way to add the EH to the vehicles in the group as well as the units?

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  

×