Major Fubar 0 Posted July 31, 2002 OK, I did do a search on this, but no luck (I hate posting questions like this and coming off like a dumbass ). How do I simulate a suicide bomber ingame. What I'm looking for is to equip a civilian with a satchel charge, who will then recognise one side (east or west) as an enemy, run up to a squad and detonate (not place the satchel on the ground, just blow it in his backpack). I am also looking for a car/truck bomber, which i assume would be done in a similar fasion... Any ideas? Share this post Link to post Share on other sites
Bosun 0 Posted July 31, 2002 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Major Fubar -----------------------------------------------------------------(I hate posting questions like this and coming off like a dumbass ). <span id='postcolor'> Well l hate posting answers and sounding like a dumbass Anyways this is how l would do it; Giving the suicideCiv a move waypoint into enemy, under condition; suicideCiv Distance <2 and under activation; Bomb = "Grenade" camCreate GetPos enemyname You could have him/her do some sort of animation if you wanted tinsel. Well hope this helps in some way... Share this post Link to post Share on other sites
johanvc 0 Posted October 12, 2002 Here's a nice little script to have a unit of choice chase a target unit and detonate itself with a big bang once it gets close enough. The chase uses a lead pursuit algorithm so the suicide bomber will effectively attempt to intercept a moving target if his speed allows it. The suicide bomber will also explode when his patience runs out (tmeout) or when killed. The blast is powerful enough to take out a T-80. Most straightforward use is simple - set up a trigger to activate "on detected", and call the script from there with as first argument the "suicide bomber" unit (works best with civilian men or vehicles), and as a second the target - i.e. the unit that activated the trigger ( list <triggername> select 0). Comments/improvements welcome...  Enjoy :-) Johan. ;-------------------------------------------------------------------------------------- ; ; Suicide Bomber script for Operation Flashpoint Resistance ; by Johan Van Camp ; ;-------------------------------------------------------------------------------------- ; call with [bomber,(list bombertrig select 0) exec "suicidebomber.sqs" _bomber = _this select 0 _target = _this select 1 ; delay between intercept point calculations _delay = 2 ; Set a timeout counter to avoid this script running eternally _c = 30 ; Assume the bomber can run at at least speed 23 (speed of man running) _vb = 23 ; Try to make sure our bomber runs at full speed to the target and doesnt get distracted _bomber setSpeedMode "FULL" _bomber setBehaviour "SAFE" #loop _c = _c - 1 ? (_c==0)||(!alive _bomber)  : goto "end" ~_delay ; Only chase if the bomber actually sees the target ? _bomber knowsabout _target <= 1 : goto "loop" ; Here comes some applied trigonometry... Rudimentary lead pursuit algorithm to get the ; bomber to the target by calculating an intercept point based on the targets current ; heading and velocity and the bombers potential velocity ; Grab some coordinates for easy manipulation _targpos = getpos _target _tx= _targpos select 0 _ty= _targpos select 1 _tz= _targpos select 2 _bomberpos = getpos _bomber _bx= _bomberpos select 0 _by= _bomberpos select 1 _bz= _bomberpos select 2 ; Convert OFP angles (0 degrees = Y-axis) into standard geometric angles (0 degrees = X-axis) ; for our further calculations to keep things nice and simple _ta= 90 - getdir _target ? _ta < 0 : _ta = _ta + 360 ; calculate targets speed and distances split in x and y components _vtx = speed _target * cos (_ta) _vty = speed _target * sin (_ta) _sx = _tx - _bx _sy = _ty - _by _s  = sqrt(_sx^2 + _sy^2) ; Check if bombers actual speed is exceeding our expectations and if so conservatively increase our assumed maximal speed _vba = speed _bomber ? _vba > _vb : _vb = (_vba + _Vb) / 2 ; Calculate the intercept angle _oa=acos (_sx/_s) ? _sy > 0 : _oa = -_oa _h = ((_sx*_vty)-(_sy*_vtx))/_vb _ia = (asin (_h/_s))-_oa ; Put angle in right quadrant and clean up presentation ? (((_sx*sin(_ia))-_h)/_sy) * (cos(_ia)) < 0 : _ia = 180 - _ia ? _ia < 0 : _ia = _ia + 360 ; Now we have the bombers velocity components for the intercept _vbx = _vb * cos(_ia) _vby = _vb * sin(_ia) ; And with this we can finally work out the actual intercept point _t = _sx / (_vbx - _vtx) _ix = _bx + (_vbx * _t) _iy = _by + (_vby * _t) ; Put the current waypoint at the calculated intercept point _bomber move [_ix,_iy,0] ; Check if were close enough to detonate - if not continue the chase ? _bomber distance _target > 10 : goto "loop" #end ; Time to say adios muchahos - nice visual feature if our bombers a man (not a vehicle) ; wait 2 seconds to let the animation play ; _bomber playMove "EffectStandSalute" ; ~2 ; And lets make a nice big explosion... create multiple bombs and detonate them ; This is enough of a blast to take out a T-80 or a full infantery squad _c=5 _boem = [] #bombs _boem = _boem + [("bomb" camCreate getpos _bomber)] _c=_c-1 ? _c > 0 : goto "bombs" "_x setdamage 1" foreach _boem ; end of script Share this post Link to post Share on other sites
Shorty87 0 Posted October 12, 2002 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Bosun @ July 31 2002,08:12)</td></tr><tr><td id="QUOTE"></span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Major Fubar -----------------------------------------------------------------(I hate posting questions like this and coming off like a dumbass  ). <span id='postcolor'> Well l hate posting answers and sounding like a dumbass Anyways this is how l would do it;  Giving the suicideCiv a move waypoint into enemy, under condition; suicideCiv Distance <2 and under activation; Bomb = "Grenade" camCreate GetPos enemyname You could have him/her do some sort of animation if you wanted tinsel. Well hope this helps in some way...<span id='postcolor'> you sound like a dumbass the script is wrong: he says: invalid number in expression no, this didn't helped me Share this post Link to post Share on other sites
Bart.Jan 0 Posted October 12, 2002 Bosun condition shoud be : suicideCiv Distance target<2 Johanvc it looks like good script. You have little mistake in calling : call with [bomber,(list bombertrig select 0)] exec "suicidebomber.sqs" These little mistakes may confuse unexperienced scripters. Share this post Link to post Share on other sites
Bart.Jan 0 Posted October 12, 2002 I made also suicide script  : It is drugged bomber who doesn't care about shooting and speed of his target  and with simple explosion. </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;Bart.Jan's suicide bomber script : ;calling : [target,suicide bomber] exec "sucideb.sqs" _target=_this select 0 _bomb=_this select 1 ;prevent accidental inital explosion _bomb reveal _target ;bomber is drugged so he don't care about shooting _bomb setbehaviour "careless" #loop ;bomber knows target's position so he is chasing it ?(_bomb knowsAbout _target >=1):_bomb move (getpos _target) ;bomber is near target so he is going to explode ?(_bomb distance _target <4):goto "boom" ~0.2 ;bomber reached last known position of target and he can't see it so he decided to explode ;or he can start searchin procedure or whatever you order to him :) ?(unitReady _bomb):goto "boom" goto "loop" #boom ;insert animation or taunt here ;and bomber explodes _explode = "shell125" camCreate (getPos _bomb) ;or use resistance (only?) big explosion : ;_explode = "Bomb" CreateVehicle getpos _bomb ;_explode SetDammage 1 exit<span id='postcolor'> There shoud be interesting sript for recognizing of nearest enemy units (targets) but it needs properly working nearestUnit command (will be in next patch  ) But it's possible even now to make script that locates visible enemies (targets) for bomber but you must use trigger for it. Share this post Link to post Share on other sites
johanvc 0 Posted October 13, 2002 4--></span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Bart.Jan @ Oct. 12 2002,224)</td></tr><tr><td id="QUOTE">Johanvc it looks like good script. You have little mistake in calling : call with [bomber,(list bombertrig select 0)] exec "suicidebomber.sqs" These little mistakes may confuse unexperienced scripters.<span id='postcolor'> Quite so BartJan, I stand corrected... thanks for ironing this out  Share this post Link to post Share on other sites
Rastavovich 0 Posted October 13, 2002 Well, you can also make a changed config.cpp where you define a weapon over a satchel charge but make it not possible to drop down, those weapon you give to a civilian model. (you may make it Resistance side, but then you have to make it nearly invisible for AI units). After that it should search its targets itself, without any script. Share this post Link to post Share on other sites
Bart.Jan 0 Posted October 13, 2002 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Rastavovich @ Oct. 13 2002,13: 00)</td></tr><tr><td id="QUOTE">Well, you can also make a changed config.cpp where you define a weapon over a satchel charge but make it not possible to drop down, those weapon you give to a civilian model. (you may make it Resistance side, but then you have to make it nearly invisible for AI units). After that it should search its targets itself, without any script.<span id='postcolor'> I think it will not work when somebody download his misson and do not modify his/her own config.cpp. Â Share this post Link to post Share on other sites
Rastavovich 0 Posted October 13, 2002 of course you have to provide that addon with the mission, but since it is only a config and no model or texture files, it may size about 1-2 kb. Share this post Link to post Share on other sites
Major Fubar 0 Posted October 13, 2002 Hey, thanks guys. I'd almost forgotten I'd asked this one Share this post Link to post Share on other sites