Jump to content
Sign in to follow this  
El Giggi

Using a flare as a go-signal.

Recommended Posts

Hey,

I want to use a flare as a signal to AI-Troops to start an attack. So, the player shoots a flare and the AI attacks. I searched the forum and I think it works with an eventhandler, but I have no Idea how to use this command. In the threads I found people asked how to detect, if the player generally shoots. They didn't dealed with the question how to detect, if the player uses a specific weapon.

Can someone please help me with this?

Share this post


Link to post
Share on other sites

You can check if a unit fired a certain Flare with:

this addEventHandler ["Fired",{if ((_this select 4 == "F_40mm_Red")) then {attackGo=true;}}];

In above example, the variable "attackGo" is set to true when the unit fired a red Flare.

Share this post


Link to post
Share on other sites

hey, thanks for the answer.

But I encountered another problem: Is it possible that the eventhandler only work with BIS Units? I ask because it worked perfectly with BIS Ammo and Weapons, than I tried it with Invasion1944 flares and it didn't. First i thought they might have changed the classname of their ammo but then I tested it with addmagazine and the ammo appeared in my inventory. So the classname is correct.

Share this post


Link to post
Share on other sites

Then you need to find the classname of the Invasion'44 flares and replace the BIS classname... "F_40mm_Red"

Share this post


Link to post
Share on other sites
Then you need to find the classname of the Invasion'44 flares and replace the BIS classname... "F_40mm_Red"

Ok, I expressed myself unclearly. I did this. Thats why I checked the classname via the addmagazine command.

Share this post


Link to post
Share on other sites

"F_40mm_Red" is an ammo classname, not magazine. If you're using a magazine classname, use _this select 5.

Share this post


Link to post
Share on other sites
"F_40mm_Red" is an ammo classname, not magazine. If you're using a magazine classname, use _this select 5.

No, this didn't work either :unhappy:

//edit: Ok, I think the problem is simply the name of the ammo-class. It works, if I use the other riflegrenades. Only the flare is still a problem. So it seems, that I don't have the correct ammo classname for the flare. Invasion1944 never released their ammoclass names so its up to trial-and-error.

Thanks for the help guys.

Edited by El Giggi

Share this post


Link to post
Share on other sites

Use hint str (getText (configFile / "CfgMagazines" / "Magazinename" / "ammo")) to speed up your discovery.

Share this post


Link to post
Share on other sites
Use hint str (getText (configFile / "CfgMagazines" / "Magazinename" / "ammo")) to speed up your discovery.

Hey, I already found it out by myself. But this is goint to be helpful in the future. Thanks again.

Share this post


Link to post
Share on other sites

Can you tell us how did you do that please because I tried a lots but I had always failed ?

Share this post


Link to post
Share on other sites
Can you tell us how did you do that please because I tried a lots but I had always failed ?

You read the whole thread?

Share this post


Link to post
Share on other sites

Yes I read the whole thread. I've spent 4 hours yesterday to make tests that's why I asked some help !

Share this post


Link to post
Share on other sites
Yes I read the whole thread. I've spent 4 hours yesterday to make tests that's why I asked some help !

I think, I didn't understand your question. For what do you need help? You can find all infos I needed in this thread already.

Share this post


Link to post
Share on other sites

mmm - in relation to ??Using a flare as a go-signal.??

Post 2

http://forums.bistudio.com/showthread.php?132544-Using-a-flare-as-a-go-signal&p=2121198&viewfull=1#post2121198

W0lle adds that code to init line of a soldier/officer WITH flares, specificaly a red one - if its fired a global variable is true.

Have a trigger on map, its activation line

attackGo=true;

Could launch into scripts.sqf or whatever you need from trigger. Or it can then be linked/ syncronised to groups or any other attacking forces.

Hard part was detecting a single shot

Share this post


Link to post
Share on other sites

This is the first thing I did, and it didn't work.

(I put the code in init unit, me of course, then a trigger called attackGo and in it's activation attackGo=true. This trigger is linked to a first waypoint of a group. But when I launched the flare nothing happened. After this I spent a lot of time on the wiki (poor wiki very poor wiki not very usefull when you don't know scriting).

I am just asking a little infos (not the entire solution) to make that code work.

Thanks.

Edited by panda123

Share this post


Link to post
Share on other sites
This is the first thing I did, and it didn't work.

(I put the code in init unit, me of course, then a trigger called attackGo and in it's activation attackGo=true. This trigger is linked to a first waypoint of a group. But when I launched the flare nothing happened. After this I spent a lot of time on the wiki (poor wiki very poor wiki not very usefull when you don't know scriting).

I am just asking a little infos (not the entire solution) to make that code work.

Thanks.

Mabye It helps, when I descripe what I did exactly:

1. I put this in the Init of the my Unit: this addEventHandler ["Fired",{if ((_this select 4 == "F_40mm_Red")) then {attackGo=true;}}]; (Obvisouly I changed F_40mm_Red to the ammo classname of the flare I needed)

Note: This should be the first entry in the init-line of an unit. I realised that it doesn't work if some other commands like addweapon or so stands first.

2. I created an AI-Group. I set up a couple of Waypoints for this group. In the condition-field of the first waypoint I entered "attackGo" (without the ""). So the Group will move up to the first Waypoint and will wait there unitl attackGo is "true".

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  

×