removing wheels logic, carryable wheels

This commit is contained in:
commy2 2015-03-29 03:35:55 +02:00
parent a92bdfdb58
commit f231b2b14c
9 changed files with 143 additions and 3 deletions

View File

@ -33,6 +33,11 @@ class Extended_Init_EventHandlers {
init = QUOTE(_this call DFUNC(initObject));
};
};
class ACE_RepairItem_Base {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
};
class Extended_Killed_EventHandlers {

View File

@ -83,4 +83,18 @@ class CfgVehicles {
GVAR(canCarry) = 0;
GVAR(canDrag) = 0;
};
class ACE_RepairItem_Base: ThingX {};
class ACE_Track: ACE_RepairItem_Base {
GVAR(canCarry) = 1;
GVAR(carryPosition[]) = {0,1,1};
GVAR(carryDirection) = 0;
};
class ACE_Wheel: ACE_RepairItem_Base {
GVAR(canCarry) = 1;
GVAR(carryPosition[]) = {0,1,1};
GVAR(carryDirection) = 0;
};
};

View File

@ -558,4 +558,16 @@ class CfgVehicles {
class ACE_SelfActions {};
};
class ACE_RepairItem_Base: thingX {
class ACE_Actions {
class ACE_MainActions {
displayName = "$STR_ACE_Interaction_MainAction";
selection = "";
distance = 2;
condition = "true";
};
};
class ACE_SelfActions {};
};
};

View File

@ -39,8 +39,9 @@ class CfgVehicles {
MACRO_REPAIRVEHICLE
};
class ThingX;
class ACE_RepairItem_Base: ThingX {
class thingX;
class ACE_RepairItem_Base: thingX {
XEH_ENABLED;
icon = "iconObject_circle";
mapSize = 0.7;
accuracy = 0.2;

View File

@ -2,3 +2,6 @@
["setVehicleDamage", {_this call FUNC(setDamage)}] call EFUNC(common,addEventHandler);
["setVehicleHitPointDamage", {_this call FUNC(setHitPointDamage)}] call EFUNC(common,addEventHandler);
// wheels
["setWheelHitPointDamage", {(_this select 0) setHitPointDamage [_this select 1, _this select 2]}] call EFUNC(common,addEventHandler);

View File

@ -6,6 +6,7 @@ PREP(addRepairActions);
PREP(canRemoveWheel);
PREP(canRepair);
PREP(canReplaceWheel);
PREP(doRemoveWheel);
PREP(doRepair);
PREP(getWheelHitPointsWithSelections);
PREP(normalizeHitPoints);
@ -14,5 +15,6 @@ PREP(repairVehicle);
PREP(replaceWheel);
PREP(setDamage);
PREP(setHitPointDamage);
PREP(spawnObject);
ADDON = true;

View File

@ -0,0 +1,44 @@
/*
* Author: commy2
*
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* Stuff from progress bar.
*
* Return Value:
* NONE
*/
#include "script_component.hpp"
private ["_unit", "_vehicle", "_hitPoint"];
_unit = _this select 0 select 0;
_vehicle = _this select 0 select 1;
_hitPoint = _this select 0 select 2;
// get current hitpoint damage
private "_hitPointDamage";
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
// can't remove destroyed or already removed wheel
if (_hitPointDamage >= 1) exitWith {};
// don't die by spawning / moving the wheel
["fixCollision", _unit] call EFUNC(common,localEvent);
// spawn wheel
private "_wheel";
_wheel = ["ACE_Wheel", getPosASL _unit] call FUNC(spawnObject);
_wheel setdamage _damage;
// raise event to set the new hitpoint damage
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent);
// display text message if enabled
if (GVAR(DisplayTextOnRepair)) then {
private "_text";
_text = "WHEEL REMOVED";
[_text] call EFUNC(common,displayTextStructured);
};

View File

@ -1 +1,39 @@
(_this select 1) setHitPointDamage [_this select 2, 1]; systemChat str _this;
/*
* Author: commy2
*
* Start a remove wheel action and open progress bar.
*
* Arguments:
* 0: Unit that does the repairing (Object)
* 1: vehicle to repair (Object)
* 2: Selected hitpoint (String)
*
* Return Value:
* NONE
*/
#include "script_component.hpp"
private ["_unit", "_vehicle", "_hitPoint"];
_unit = _this select 0;
_vehicle = _this select 1;
_hitPoint = _this select 2;
// exit if not a valid hitpoint
if !(_hitPoint in ([_vehicle] call EFUNC(common,getHitPoints))) exitWith {};
// calculate time to fully repair the hitpoint
private "_time";
_time = 10;
// get string of the hitpoint
private "_text";
_text = "REMOVE WHEEL";
// open the loading bar
[_time, [_unit, _vehicle, _hitPoint], DFUNC(doRemoveWheel), {hint "abort"}, _text, {true}, []] call EFUNC(common,progressBar);
// do animation
[_unit] call EFUNC(common,goKneeling);
// @todo play sound

View File

@ -0,0 +1,21 @@
// by commy2
#include "script_component.hpp"
private ["_item", "_position", "_damage"];
_item = _this select 0;
_position = _this select 1;
_damage = _this select 2;
if (isNil "_damage") then {_damage = 0};
// randomized end position
_position = _position vectorAdd [1 - random 2, 1 - random 2, 0];
_item = createVehicle [_item, _position, [], 0, "NONE"];
_item setPosASL _position;
["fixCollision", _item] call EFUNC(common,localEvent);
["fixPosition", _item] call EFUNC(common,localEvent);
_item setDamage _damage;