OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: bedges on 23 May 2005, 22:10:26
-
m'kay, i'm working on a range of 'ultimate cheats' - call me Mister Cheatypants if you must 8) - and i've hit a wee snag.
i'm using the nearestobject command to catch anything resembling a 'BulletSingleE' nearby and setpos'ing it into the air. now the loop this is in is pretty fast - 0.002 to be precise - and yet still, the bullets find their way into the player.
i realise this may be simply down to limitations, but am i going about it the right way?
#loop
_j = nearestobject [player,"bulletsinglee"]
_j setpos [0,0,0]
_k = nearestobject [player,"bulletburste"]
_k setpos [0,0,0]
~0.002
goto "loop"
ideas?
EDIT - it seems that distance has something to do with it - the closer the enemy is, the more likely the player is to be hit. but a generous distance away, and not one hit ;)
-
I believe - although I'm not sure - that you cannot reliably catch bullets in mid air. They can move faster than even the fastest loop. The only way to do it is with a fired ED because then the "catch" is timed with the bullet launch.
-
mmmwell, that's always an option in my own missions, but this is for a script pack which is easily dropped into any mission, thus identifying all enemies and giving them each an EH is impractical.
cheers anyways - incidentally, even with a 12-loon squad firing at the player simultaneously, they only become dangerous at less than 30 feet. otherwise no bullet bites ;)
-
... after which Neo presumably uses a setpos loop to fly across the island? :D
-
actually, that doesn't work - he begins to tumble, as if the very matrix was disintegrating around him :P
-
I've just finished giving up on this method for doing exactly the same thing. Basically what I found was:
a.) You don't know the type of ammo you're after, necessitating a nearestobject _position call instead of a more specific nearestobject ["type",position] call. This picks up everything from bullets to decals (craters, footprints, ecp blood et cetera) to men and vehicles. This means that the player is less protected when he's next to a whole bunch of his comrades, since if the position of the nearestobject call happens to be close to a soldier, it generally picks him up instead of the bullet flying past him on it's way to your head.
b.) You need a lot of them! More so because they are non-specific nearestobject calls. At least 60 calls, say 10 per concentric circle going outwards from the player, are needed before anything resembling good protection is endowed. And with this number, looping as slowly as T=0.1s causes quite heavy lag. At least it did for me, and my computer is fairly modern :/. I know for a fact that 0.002s is highly impractical with this number
c.) You need even more of them! Because fast bullets can travel several hundred meters per second, your outer radius of nearestobject calls must depend on the frequency of calling. For example: you call with 0.01 seconds' period. A bulletSingle can travel, say, at 200 metres per second, or 2 metres per 0.01 seconds. That means you need an outer radius of at least 2 metres to catch most of the bullets at this period. BUT, LAWs, AA's and hellfires travel at 350 m/s whilst rockets travel at a blistering 1000 m/s! that would mean multiplying by 5 times, as you can see.
d.) The number of calls depends on the volume of a sphere, which depends on the cube of the radius. The further out from the player you go, the more calls you need per circle as the circles get bigger. BUT if you want to protect from air attacks, you need not just circles but spheres, for total protection. This means a lot of calls indeed
For these reasons I gave up. I'm now pursuing the idea of surrounding the player with invisible objects, e.g. invisible barrels, which will absorb the impact of bullets etc. These follow the player around with a fast setpos loop. This approach is still in the 'idea' stage however, I haven't had a chance to do any testing yet and don't forsee I will have in the near future. Perhaps this is what you're after?
-
hmmmm.... well as i've mentioned, the only problem i've encountered is being too close to the loon doing the firing, where the frequency/speed of bullets is too fast for the EH to handle. further out it catches everything.
i agree that perhaps a lot of them are required, but it can be minimized. this is the script i have as it stands (unfinished) -
;there is no spoon
?side player==east:goto "protect_east"
?side player==west:goto "protect_west"
#protect_west
#loop
nearestobject [player,"bulletsinglee"] setpos [0,0,0]
nearestobject [player,"bulletburste"] setpos [0,0,0]
nearestobject [player,"bulletsingleg"] setpos [0,0,0]
nearestobject [player,"bulletburstg"] setpos [0,0,0]
nearestobject [player,"bullet7_6e"] setpos [0,0,0]
nearestobject [player,"bizon"] setpos [0,0,0]
nearestobject [player,"skorpion"] setpos [0,0,0]
~0.01
goto "loop"
#protect_east
#loop
nearestobject [player,"bulletsinglew"] setpos [0,0,0]
nearestobject [player,"bulletburstw"] setpos [0,0,0]
nearestobject [player,"bullet7_6w"] setpos [0,0,0]
nearestobject [player,"g36a"] setpos [0,0,0]
nearestobject [player,"steyr"] setpos [0,0,0]
~0.01
goto "loop"
just need to add the remaining e/w ordnance, and resistance weapons and i'm set.
the likelihood of an enemy loon using a rocket launcher against the player is remote, unless said player has a tank around him/her, in which case my patented Rebound Armour is activated, which camcreates a small but perfectly formed laserguidedbomb at the culprit's position...
at the end of the day it's not a cureall, as that would sort of take the fun out of playing the game, running around invincible, but it certainly improves the player's chances of staying alive longer ;)
EDIT - also negates the use of the enemy's weapons, as you let loose a clip of rounds from an ak47 and all the bullets end up at [0,0,0] - not helpful ::)
-
what if you used a simple piece of code such as
{_x addEventHandler {"fired",[this exec "myscript.sqs"]} forEach list triggerAto provide the fired event handlers to each unit, therefore removing any need of adding an EH to each unit?
-
i could, but i wanted this to be a script suite which could be dropped into any mission folder, without the need for creating triggers in the editor. having said that, the player's event handler cheats still need to be initialised in the init.sqs file, so needing an extra map-sized trigger is just as much work...
i shall think on it, cheers for the input :)
-
Oh, i see- you have names in your nearestobject calls. Forget what I said about needing loads of them, if you're adding ammo names manually then you should be fine. More so if you're not worried about air attacks, laws etc.
-
I once had something I can't quite remember. I'll post it later maybe... Anyway what this done is it allowed the bullet to hit the player, but the player doesn't die. Sadly tank bullets and rapid machine gun firing (not automatic weapons) can kill the player. Anyway I'll post it later It's quite useful!