Warning: include(/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php): failed to open stream: No such file or directory in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Warning: include(): Failed opening '/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Notice: Undefined index: OFPEC in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152
    Home   Help Login Register  

Author Topic: Replacing Vehicles with Wrecks  (Read 1163 times)

0 Members and 1 Guest are viewing this topic.

Offline D-scythe

  • Members
  • *
Replacing Vehicles with Wrecks
« on: 13 Mar 2007, 22:26:29 »
Yeah, I'm new to OFP and its scripts, and was wondering if there was a tutorial or some kind of template from which I can tinker with. I want to replace destroyed units, like a jeep or truck, with a destroyed wreak - not a huge fan of the crumpled look.

I tried the search function, but it's not really getting me anywhere. Any help would be appreciated.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Replacing Vehicles with Wrecks
« Reply #1 on: 13 Mar 2007, 23:08:19 »
First you need the vehicle wreak types. You may place one of them in the map and put this into its init field:
Code: [Select]
hint format["Type: %1", typeOf this]Copy these types into a doc.

Then, for your replacement functionality you need a script running. Lets say you have 3 M113 you want to check. Run the following script from the init.sqs or from the init field of each unit:
Code: [Select]
[this, "typeofthewreak", 0.9, 30]exec"replaceforwreak.sqs"
And the replaceforwreak.sqs script
Code: [Select]
;replaceofwreak.sqs script
;arguments:
;unit to check
;typeofwreak to use
;maxdamage allowed before change
;delay in seconds before change and after taking max allowed damage

_unit = _this select 0
_typeofwreak = _this select 1
_maxdamage = _this select 2
_delay = _this select 3

@damage _unit >= _maxdamage
~_delay
_pos = getPos _unit
_dir = getDir _unit
deleteVehicle _unit
_wreak = _typeofwreak createVehicle _pos
_wreak setDir _dir
exit