Lua When Weapon Fired [Solved]

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
KnightsFan
Second Lance Corporal
Second Lance Corporal
Posts: 108
Joined: Fri Mar 06, 2009 9:34 pm

Lua When Weapon Fired [Solved]

Post by KnightsFan »

Is it possible to run a function in my script when a specific weapon is fired?
Master_Ben
Lieutenant General
Lieutenant General
Posts: 675
Joined: Wed Nov 12, 2008 9:50 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Watching your PC over your shoulder. No, the other sholder....

Re: Lua When Weapon Fired

Post by Master_Ben »

Take a look at the geonosis stock campaign lua. The sniping objective speaks for itself, it can be done. :wink:
User avatar
KnightsFan
Second Lance Corporal
Second Lance Corporal
Posts: 108
Joined: Fri Mar 06, 2009 9:34 pm

Re: Lua When Weapon Fired

Post 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.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Lua When Weapon Fired

Post 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?
User avatar
KnightsFan
Second Lance Corporal
Second Lance Corporal
Posts: 108
Joined: Fri Mar 06, 2009 9:34 pm

Re: Lua When Weapon Fired

Post 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.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Lua When Weapon Fired

Post by Fiodis »

Aye, dispense a turret, kill the turret via lua, and add the AI goal.
User avatar
KnightsFan
Second Lance Corporal
Second Lance Corporal
Posts: 108
Joined: Fri Mar 06, 2009 9:34 pm

Re: Lua When Weapon Fired

Post by KnightsFan »

Thanks! It is working perfect now.
Post Reply