Jump to content

[Fix] Salvage Vehicle Tires and Damaged Parts


SchwEde

Recommended Posts

============= [Fix] Salvage Vehicle Tires and Damaged Parts ==============

 

What it does....
 
Fixing the Salvage Vehicle Script.
Some Admins know the issue that it is possible to remove 8 Tires from any Cars/ATVs or it is not possible to remove fully repaired Tires.
This thing should fix this Problem.
 
!!WARNING!!
An Epoch Dev said this about the Damage part:

To prevent issues with certain vehicles that do not take tire damage, thus allowing you to take an unlimited amount.

Source:
 
I did not tested this, but you know now about this issue. Maybe someone can tell us which vehicles has invincible so it is possible to disable salvaging tires from this vehicles.
END OF THE WARNING
 
What you need:
 
custom fn_selfaction.sqf
fixed salvage_vehicles.sqf
 
How to Install:
 
fn_selfaction:
 
find this part:
_menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
 
and change the path to the salvage_vehicles.sqf:

_menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "path_to\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "","];

 
fixed salvage_vehicles.sqf
//Hitpoint and Damage fix by SchwEde aka shinySonic
private ["_part","_cancel","_color","_percent","_string","_handle","_damage","_cmpt","_vehicle","_hitpoints"];
 
_vehicle = _this select 3;
 
{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
// dayz_myCursorTarget = _vehicle;
 
if (((typeof _vehicle) isKindOf  "Car") and !((typeof _vehicle) isKindOf  "Truck")) then {
    _hitpoints = ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitLFWheel","HitLBWheel","HitRFWheel","HitRBWheel","HitFuel","HitRGlass","HitLGlass","HitEngine"]
    };
 
if ((typeof _vehicle) isKindOf  "Truck") then {
_hitpoints = ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitGlass7","HitGlass8","HitLFWheel","HitLBWheel","HitRFWheel","HitRBWheel","HitLMWheel","HitRMWheel","HitFuel","HitRGlass","HitLGlass","HitEngine"]
};
 
// _allFixed = true;
//_hitpoints = _vehicle call vehicle_getHitpoints; // old Hitpoints
 
// diag_log format["DEBUG SALVAGE: %1", _hitpoints];
{        
    _damage = [_vehicle,_x] call object_getHit;
    _part = "PartGeneric";
 
    //change "HitPart" to " - Part" rather than complicated string replace
    _cmpt = toArray (_x);
    _cmpt set [0,20];
    _cmpt set [1,toArray ("-") select 0];
    _cmpt set [2,20];
    _cmpt = toString _cmpt;
 
    if(["Engine",_x,false] call fnc_inString) then {
        _part = "PartEngine";
    };
    
    if(["HRotor",_x,false] call fnc_inString) then {
        _part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL
    };
 
    if(["Fuel",_x,false] call fnc_inString) then {
        _part = "PartFueltank";
    };
 
    if(["Wheel",_x,false] call fnc_inString) then {
        _part = "PartWheel";
    };
    
    if(["Glass",_x,false] call fnc_inString) then {
        _part = "PartGlass";
    };
 
    // allow removal of any lightly damaged parts
    if (_damage <= 0.95 and _damage >= 0) then {
    
        // Do not allow removal of engine || fueltanks
        if( _part == "PartGlass" || _part == "PartWheel" ) then {
 
            _color = "color='#ffff00'"; //yellow
            if (_damage >= 0.5) then {_color = "color='#ff8800'";}; //orange
            if (_damage >= 0.75) then {_color = "color='#ff0000'";}; //red
 
            _percent = round(_damage*100);
            _string = format["<t %2>Remove%1 (%3 %4)</t>",_cmpt,_color,_percent,"%"]; //Remove - Part
            _handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\salvage.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
            s_player_repairActions set [count s_player_repairActions,_handle];
        
        };
    };
 
} count _hitpoints;
 
if(count _hitpoints > 0 ) then {
 
    _cancel = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_CANCEL", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false, "",""];
    s_player_repairActions set [count s_player_repairActions,_cancel];
    s_player_repair_crtl = 1;
};
 
If you like to change the max salvage damage just change this line:
 

if (_damage <= 0.95 [<<max damage] and _damage >= 0 [<< min damage]) then {

 
Credits:
I dont take Credits for the Salvage Script, just for the Fixes
Guy(s) who made this Script
Link to comment
Share on other sites

Installed and working. Thanks for fixing this. It really is something that should've been addressed a long time ago. Perhaps the devs should stop working on Epoch for Arma II and allow the community to continue to tweak, instead of breaking fixes and mods with each patch...

 

Thanks again...beans.

Link to comment
Share on other sites

This will break salvage for everything that's not a car. I prevented this by adding the following around line 8.

_hitpoints = _vehicle call vehicle_getHitpoints; 

if (((typeof _vehicle) isKindOf  "Bike") or ((typeof _vehicle) isKindOf  "Motorcycle")) then {
_hitpoints = ["HitLFWheel","HitLBWheel"]
};

if (((typeof _vehicle) isKindOf  "ATV_US_EP1") or ((typeof _vehicle) isKindOf  "ATV_CZ_EP1")) then {
_hitpoints = ["HitLFWheel","HitLBWheel","HitRFWheel","HitRBWheel"]
};
Link to comment
Share on other sites

  • 5 months later...

have you tried it on other vehicles?

 

I don't have a list of vehicles that have the extra wheels so checking other vehicles doesn't really matter, plus there's no sure fire way to ensure that the extra wheels are "damaged", resulting in them being able to be removed. I just happened to notice the extra wheels on the vehicle after applying the changes. Maybe add some debugging lines in the code to see what is (or isn't) happening?

Link to comment
Share on other sites

I have it as it is up there and don't have 6 wheels on any car.

And as far as I can nobody else who installed this has the same issue.

Anything in the RPT or client RPT?

 

Next time I find a vehicle with the extra wheels I'll screenshot it for you. I'll also double check the code to be sure everything is correct.

Link to comment
Share on other sites

i dont need a screenshot ^^ i believe you

Only thing that would help is your RPT and client RPT ;)

 

Are you not using any kind of admin tool to just spawn you a vehicle or teleport to one on the map?

 

I've looked for errors in the RPT logs and there is none related to this. These were not vehicles spawned by me. The truck with the extra wheels was a mission vehicle. I went the the mission, went to take a tire off and found the extras on it.

Link to comment
Share on other sites

  • 2 months later...

Hi SchwEde,  fantastic scripting - and not just this one!  One thing to note, I assume you mean salvage_vehicle.sqf, not salvage_vehicles.sqf.

 

Anyway, I've also put in the "Remove Origins Logo" script (), since I'm running with Origins 1.7.9.5 as one of my mods, which has been working great.  

When I put your wheel fix in, I get no salvage selection at all - on any vehicle type.  There are no messages in any log files - just no scroll selection for salvage.  To simplify the testing, I didn't change fn_selfactions.sqf, I did a total replacement of salvage_vehicle.sqf in the .PBO with a straight copy and past into the file.

 

Any ideas? 

 

nevermind.... I changed the path to repair_vehicle.sqf instead of salvage_vehicle.sqf...whatta dope!

 

But I did find the same thing as BDTZ.  Some cars now show up correctly as having four tires, others six or eight.  I didn't do an exhaustive search but just bouncing between vehicles, it seems the Origins vehicles have the extra tires.  Since BDTZ didn't post the .rpt files, I can if it'll help.  Both client and server .rpt have numerous lines like:

 

class HitPoints::HitLF2Wheel not found in ori_vil_lada_2105_rust
class HitPoints::HitRF2Wheel not found in ori_vil_lada_2105_rust
class HitPoints::HitLMWheel not found in ori_vil_lada_2105_rust
class HitPoints::HitRMWheel not found in ori_vil_lada_2105_rust

 

 

Got that fixed, too!   Works great!

 

Bob

Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...