OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started 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?
-
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.
-
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....
-
problem is that nearestObject getPos player will return always the player.
You may try something like:
#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.
-
Thanks guys!
All posts were very helpful! :)
I think I'm learning! Yay! 8)