Page 1 of 1
Lua When Weapon Fired [Solved]
Posted: Tue Feb 09, 2010 10:54 pm
by KnightsFan
Is it possible to run a function in my script when a specific weapon is fired?
Re: Lua When Weapon Fired
Posted: Tue Feb 09, 2010 11:00 pm
by Master_Ben
Take a look at the geonosis stock campaign lua. The sniping objective speaks for itself, it can be done.

Re: Lua When Weapon Fired
Posted: Tue Feb 09, 2010 11:46 pm
by KnightsFan
I can't find anything. I want it to run when I fire the weapon, but the sniper objective stuff is run when an object dies.
Re: Lua When Weapon Fired
Posted: Wed Feb 10, 2010 11:59 am
by Fiodis
This is an unfortunate quirk of BF2. If it weren't in place, there would be so much more we could do. As it is, we are only able to (directly) detect a "dispenser" class weapon being fired. This is still very useful, as you can do quite a lot through this. We can also detect weapons being fired indirectly, as in the Geo script, but of course there are obvious problems and setbacks with this.
What exactly do you want to happen when you fire your weapon?
Re: Lua When Weapon Fired
Posted: Wed Feb 10, 2010 6:46 pm
by KnightsFan
Send the AI an objective, kind of like a command. So I suppose a dispenser weapon would be fine, since the weapon doesn't have to have any other effect.
Re: Lua When Weapon Fired
Posted: Wed Feb 10, 2010 6:52 pm
by Fiodis
Aye, dispense a turret, kill the turret via lua, and add the AI goal.
Re: Lua When Weapon Fired
Posted: Wed Feb 10, 2010 7:40 pm
by KnightsFan
Thanks! It is working perfect now.