Lua When Weapon Fired [Solved]
Moderator: Moderators
- KnightsFan
- Second Lance Corporal

- Posts: 108
- Joined: Fri Mar 06, 2009 9:34 pm
Lua When Weapon Fired [Solved]
Is it possible to run a function in my script when a specific weapon is fired?
-
Master_Ben
- Lieutenant General

- Posts: 675
- Joined: Wed Nov 12, 2008 9:50 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Watching your PC over your shoulder. No, the other sholder....
Re: Lua When Weapon Fired
Take a look at the geonosis stock campaign lua. The sniping objective speaks for itself, it can be done. 
- KnightsFan
- Second Lance Corporal

- Posts: 108
- Joined: Fri Mar 06, 2009 9:34 pm
Re: Lua When Weapon Fired
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.
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: Lua When Weapon Fired
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?
What exactly do you want to happen when you fire your weapon?
- KnightsFan
- Second Lance Corporal

- Posts: 108
- Joined: Fri Mar 06, 2009 9:34 pm
Re: Lua When Weapon Fired
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.
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: Lua When Weapon Fired
Aye, dispense a turret, kill the turret via lua, and add the AI goal.
- KnightsFan
- Second Lance Corporal

- Posts: 108
- Joined: Fri Mar 06, 2009 9:34 pm
Re: Lua When Weapon Fired
Thanks! It is working perfect now.
