• 0
Sign in to follow this  
Followers 0
curtcooll

Vehicle damage

Question

Posted (edited)

Ok so ive had a lot of help of a friend putting my server together but issue I'm having is the script being used sets damage of a spawn vehicle but I'm trying to get it so it spawns in really damaged missing wheels and like next to no fuel or maybe a fuel leak how would I do this, I'm trying to make it so it has a 90 percent chance to be really damaged and then say a 10 percent chance to be no damage at all.

 

Spoiler
class VehicleSpawn
 {
  /**
  * Grid Size for vehicle spawning,
  * smaller the number more vehicles,
  * you get the point
  */
  vehiclesGridSize = 1500;
 
  /**
  * Vehicle ammount per grid
  * kinda self explanitory
  */
  vehiclesGridAmount = 6;
 
  /**
  * Creates global markers for vehicle spawn tweeking,
  * after you are satisfied with vehicle ammount and spread set this to 0.
  */
  vehiclesDebugMarkers = 1;
 
  /**
  * The server will apply random damage up to this value when spawning a vehicle.
  */
  damageChance = 100; // 20% chance for a vehicle HITPOINT to be damaged
  maximumDamage = 1;

 

Edited by curtcooll

Share this post


Link to post
Share on other sites

7 answers to this question

  • 1

Posted (edited)

What you're looking to do can't be done in the config. It's only going to set a chance on whether or not to apply damage. Set the max damage to 0.9 for starters. 1 will just cause it to explode as soon as it's spawned and cannot be repaired. 

This isn't tested, so make any necessary backups 1st, then in exile_server.pbo > code replace ExileServer_object_vehicle_createNonPersistentVehicle.sqf

with this:

/**
 * ExileServer_object_vehicle_createNonPersistentVehicle
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_className","_position","_direction","_usePositionATL","_chance","_vehicleObject"];
_className = _this select 0;
_position = _this select 1;
_direction = _this select 2;
_usePositionATL = _this select 3;

_chance = floor random 10;  //random number to determine whether or not to set damage

_vehicleObject = [_className, _position, _direction, _usePositionATL] call ExileServer_object_vehicle_carefulCreateVehicle;
_vehicleObject setVariable ["ExileIsPersistent", false];

if (_chance < 8) then { _vehicleObject setHit ["motor", 1];}; // added for random damage chance.

_vehicleObject setFuel (random 1);
_vehicleObject addEventHandler ["GetIn", {_this call ExileServer_object_vehicle_event_onGetIn}];
_vehicleObject addMPEventHandler ["MPKilled", { if !(isServer) exitWith {}; _this call ExileServer_object_vehicle_event_onMPKilled;}];
_vehicleObject call ExileServer_system_simulationMonitor_addVehicle;
_vehicleObject

In theory, this should disable the engine on 80% of all spawned vehicles.

Edited by oSoDirty
1 person likes this

Share this post


Link to post
Share on other sites
  • 0

Nice post ill have to test this as well. 

16 minutes ago, oSoDirty said:

What you're looking to do can't be done in the config. It's only going to set a chance on whether or not to apply damage. Set the max damage to 0.9 for starters. 1 will just cause it to explode as soon as it's spawned and cannot be repaired. 

This isn't tested, so make any necessary backups 1st, then in exile_server.pbo > code replace ExileServer_object_vehicle_createNonPersistentVehicle.sqf

with this:


/**
 * ExileServer_object_vehicle_createNonPersistentVehicle
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_className","_position","_direction","_usePositionATL","_chance","_vehicleObject"];
_className = _this select 0;
_position = _this select 1;
_direction = _this select 2;
_usePositionATL = _this select 3;

_chance = floor random 10;  //random number to determine whether or not to set damage

_vehicleObject = [_className, _position, _direction, _usePositionATL] call ExileServer_object_vehicle_carefulCreateVehicle;
_vehicleObject setVariable ["ExileIsPersistent", false];

if (_chance < 8) then { _vehicleObject setHit ["motor", 1];}; // added for random damage chance.

_vehicleObject setFuel (random 1);
_vehicleObject addEventHandler ["GetIn", {_this call ExileServer_object_vehicle_event_onGetIn}];
_vehicleObject addMPEventHandler ["MPKilled", { if !(isServer) exitWith {}; _this call ExileServer_object_vehicle_event_onMPKilled;}];
_vehicleObject call ExileServer_system_simulationMonitor_addVehicle;
_vehicleObject

In theory, this should disable the engine on 80% of all spawned vehicles.

Nice post ill have to test this as well.

 

-PDX

Share this post


Link to post
Share on other sites
Advertisement
  • 0

cheers man, I set it to 1 and some vehicles didn't start some had fuel leaking some had low fuel, is there anyway to make 80 percent of vehicles have some wheels missing? I'm gonna be using another script someone made to allow for real repair using parts to repairs wheels etc.

Share this post


Link to post
Share on other sites
  • 0
6 hours ago, curtcooll said:

cheers man, I set it to 1 and some vehicles didn't start some had fuel leaking some had low fuel, is there anyway to make 80 percent of vehicles have some wheels missing? I'm gonna be using another script someone made to allow for real repair using parts to repairs wheels etc.

setHit ["motor", 1]

"motor" will need to be changed to the wheel, not sure what it needs to be changed to, each wheel has it's own class and alot of it is in Czech according to the wiki, so you'll have to search/ask around. But it can be done.

Share this post


Link to post
Share on other sites
  • 0

For all wheeled vehicles it should be: 

Spoiler

setHit ["wheel_1_1_steering", 1]; //front left
setHit ["wheel_1_2_steering", 1]; //front right
setHit ["wheel_2_1_steering", 1]; //back left
setHit ["wheel_2_2_steering", 1]; //back right    

Let me know how that works for you :-) 

1 person likes this

Share this post


Link to post
Share on other sites
  • 0

Posted (edited)

On 23.6.2016 at 9:26 AM, ka0s said:

For all wheeled vehicles it should be: 

  Reveal hidden contents

setHit ["wheel_1_1_steering", 1]; //front left
setHit ["wheel_1_2_steering", 1]; //front right
setHit ["wheel_2_1_steering", 1]; //back left
setHit ["wheel_2_2_steering", 1]; //back right    

Let me know how that works for you :-) 

As some people doesnt reply :P, thx a lot for coding help :) 

i want to let you know that this worked for me:

Just the description of which wheel it represents is wrong ;) and i´m not sure if its working for any car. I think there might be some cars with other wheel "names/variables"  then wheel_x_x_steering. 

Spoiler

_chance = floor random 11;  //random number to determine whether or not to set damage

_vehicleObject = [_className, _position, _direction, _usePositionATL] call ExileServer_object_vehicle_carefulCreateVehicle;
_vehicleObject setVariable ["ExileIsPersistent", false];

if (_chance == 0) then { _vehicleObject setHit ["wheel_1_1_steering", 1];}; // added for random damage chance.
if (_chance == 1) then { _vehicleObject setHit ["wheel_1_1_steering", 1];};
if (_chance == 2) then { _vehicleObject setHit ["wheel_1_2_steering", 1];};
if (_chance == 3) then { _vehicleObject setHit ["wheel_1_2_steering", 1];};
if (_chance == 4) then { _vehicleObject setHit ["wheel_2_1_steering", 1];};
if (_chance == 5) then { _vehicleObject setHit ["wheel_2_1_steering", 1];};
if (_chance == 6) then { _vehicleObject setHit ["wheel_2_2_steering", 1];};
if (_chance == 7) then { _vehicleObject setHit ["wheel_2_2_steering", 1];};
if (_chance == 8) then 

                        _vehicleObject setHit ["wheel_1_1_steering", 1];
                        _vehicleObject setHit ["wheel_2_2_steering", 1];
};
if (_chance == 9) then 

                        _vehicleObject setHit ["wheel_2_1_steering", 1];
                        _vehicleObject setHit ["wheel_2_2_steering", 1];
};
if (_chance == 10) then 

                        _vehicleObject setHit ["wheel_2_1_steering", 1];
                        _vehicleObject setHit ["wheel_2_2_steering", 1];
                        _vehicleObject setHit ["wheel_1_2_steering", 1];
};

Maybe thats not proper coded, im coderNOOB. I think there are better ways to randomize which wheel is damaged but it works :)

Edited by LukeSkywaIker

Share this post


Link to post
Share on other sites
  • 0
On 11/08/2016 at 1:13 PM, LukeSkywaIker said:

As some people doesnt reply :P, thx a lot for coding help :) 

i want to let you know that this worked for me:

Just the description of which wheel it represents is wrong ;) and i´m not sure if its working for any car. I think there might be some cars with other wheel "names/variables"  then wheel_x_x_steering. 

  Hide contents

_chance = floor random 11;  //random number to determine whether or not to set damage

_vehicleObject = [_className, _position, _direction, _usePositionATL] call ExileServer_object_vehicle_carefulCreateVehicle;
_vehicleObject setVariable ["ExileIsPersistent", false];

if (_chance == 0) then { _vehicleObject setHit ["wheel_1_1_steering", 1];}; // added for random damage chance.
if (_chance == 1) then { _vehicleObject setHit ["wheel_1_1_steering", 1];};
if (_chance == 2) then { _vehicleObject setHit ["wheel_1_2_steering", 1];};
if (_chance == 3) then { _vehicleObject setHit ["wheel_1_2_steering", 1];};
if (_chance == 4) then { _vehicleObject setHit ["wheel_2_1_steering", 1];};
if (_chance == 5) then { _vehicleObject setHit ["wheel_2_1_steering", 1];};
if (_chance == 6) then { _vehicleObject setHit ["wheel_2_2_steering", 1];};
if (_chance == 7) then { _vehicleObject setHit ["wheel_2_2_steering", 1];};
if (_chance == 8) then 

                        _vehicleObject setHit ["wheel_1_1_steering", 1];
                        _vehicleObject setHit ["wheel_2_2_steering", 1];
};
if (_chance == 9) then 

                        _vehicleObject setHit ["wheel_2_1_steering", 1];
                        _vehicleObject setHit ["wheel_2_2_steering", 1];
};
if (_chance == 10) then 

                        _vehicleObject setHit ["wheel_2_1_steering", 1];
                        _vehicleObject setHit ["wheel_2_2_steering", 1];
                        _vehicleObject setHit ["wheel_1_2_steering", 1];
};

Maybe thats not proper coded, im coderNOOB. I think there are better ways to randomize which wheel is damaged but it works :)

As I see it, all modders should follow the classnames used by BI, because then your code will always work just fine. But I'm glad it worked out for you :-) 

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.