OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: ShrubberyJSC on 13 Jul 2006, 10:27:36

Title: Touch of death
Post by: ShrubberyJSC on 13 Jul 2006, 10:27:36
Ok, here's my "touch of death"

myloc = getpos player; deadguy = nearestobject myloc; deadguy setdammage 1;

This, quite hilariously, kills me.   ;D

It does exactly what I told it to do, but if I want to kill the person closest to me, (without killing me) how would I do this?  ???

BTW, nobody should lose sleep over this, it's just a way for me to learn this stuff.  ;)

Yay! I found a way to do this, even with crappy 1.30 version!   (OFPR) coming in the mail........... :-\

I take apart the array, using select, then using variables, put together a new array. I wish I could use SET, but I will be

able to use it once I get OFPR.

So now it kills a poor idiot that happens to be standing east of me.

But the question still stands, can I have it not target me with nearestobject?

because it seems silly to have the nearest object to me be me... I understand, but can it not include me in the search?
Title: Re: Touch of death
Post by: Mr.Peanut on 13 Jul 2006, 17:36:19
Only way to get this to work is to set the exact type of object you are looking for, and that type is not you. Execute the nearestObj command once for each specific object type i.e. OfficerG, SoldierGB etc.
Title: Re: Touch of death
Post by: bedges on 13 Jul 2006, 18:53:20
Code: [Select]
myloc = getpos player
deadguy = nearestobject myloc
?not  (deadguy == player) : deadguy setdammage 1

will have to be a looping script, but it won't kill you any longer. vehicles exploding nearby might though....
Title: Re: Touch of death
Post by: Mandoble on 13 Jul 2006, 20:18:47
problem is that nearestObject getPos player will return always the player.

You may try something like:
Code: [Select]
#check
_dir = getDir player
_pos = [(getPos player select 0)+3*sin(_dir),(getPos player select 1)+3*cos(_dir), 2]
_obj = nearestObject _pos
?(alive _obj) &&(driver _obj == _obj)&&(_obj!=player):_obj setDamage 1
~0.5
goto "check"

That will return the alive nearest object (not vehicles) of a point 3 meters ahead of the player.
Title: Re: Touch of death
Post by: ShrubberyJSC on 14 Jul 2006, 02:15:50
Thanks guys!

All posts were very helpful!  :)

I think I'm learning!  Yay! 8)