Page 1 of 1

Detect shots

Posted: Wed Mar 04, 2009 9:32 pm
by bobfinkl
Alright well I'm making a sniper mission and long story short I need to be able to detect if a player shoots a weapon in the campaign, e.g. if the player shoots this weapon during this objective they lose.

Any help appreciated, if it's not possible then that's fine I'll find a workaround.

Re: Detect shots

Posted: Wed Mar 04, 2009 9:54 pm
by Master_Ben
Had a look through Lua functions in the FAQ and didn't find anything. Looks like a no go.

Re: Detect shots

Posted: Wed Mar 04, 2009 10:20 pm
by Fiodis
You can only detect dispensers firing. However, you may be able to save your campaign yet - take a look at the Geonosis campaign, specifically the objective in which you must kill some droids with a sniper rifle. They use some sort of GetLastWeaponHitClass or something similar, if the player in your campaign is inside a room, you could edit the room's ODF to be destructable with a very very high health, then use something like

Code: Select all

OnObjectDamage (
function (object, damager)
           if GetLastHitWeaponClass (object) == "whatever weapon you want" and GetEntityClass (object) == "name of room's ODF" then
           "insert code to make them lose here"
           end, 
           end
    )

Re: Detect shots

Posted: Thu Mar 05, 2009 6:27 pm
by bobfinkl
Alright well I've found an acceptable workaround, thanks anyway. Admins this topic can be locked now.