Home   Help Search Login Register  

Author Topic: Replacing Vehicles with Wrecks  (Read 962 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