OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: TonyRanger on 11 Jul 2004, 12:58:45

Title: how to detect shell
Post by: TonyRanger on 11 Jul 2004, 12:58:45
we can detect RPG,LAW,missile,grenade etc. by nearestobject[_unitname,_ammotype]
RPG's ammotype is "RPG"
by why I can't detect shell by
nearestobject[_unitname,"shell120"]
is shell120's ammotypename is not "shell120"?
but it's "addeventhandler["fired",{_this exec"check.sqs"}]" tell me this

;check.sqs
_ammotpye=_this select 4
#mian
titletext[format["ammotype is:%1",_ammotpye],"plain"]
exit

I fire a m1a1 and the titletext is"ammotype is:shell120"

 

Title: Re:how to detect shell
Post by: ponq on 11 Jul 2004, 16:13:45
have a look at a script called Bullet Cam at the editors depot.

The cam catches a shell125 there without probs.
Title: Re:how to detect shell
Post by: h- on 13 Jul 2004, 23:19:43
You can put that nearest object check into the fired eventhandler...
That ensures you that the shell is detected because it shoots out from the barrel a 'bit' faster than an RPG or LAW etc...

On low-end systems the shell might escape the nearestObject range before the nearestObject gets called if it's not called from the eventhandler...

As such:
unit addEventHandler ["fired",{[nearestObject [_this select 0, _this select 4]] exec "script.sqs"}]

And in the script you have the shell passed with:
_shell = _this select 0...