toggle laser vs ir laser

This commit is contained in:
commy2 2015-04-14 00:32:09 +02:00
parent b72366f0f6
commit 3da3543381
7 changed files with 116 additions and 8 deletions

View File

@ -2,7 +2,7 @@ class CfgVehicles {
class NATO_Box_Base; class NATO_Box_Base;
class Box_NATO_Support_F: NATO_Box_Base { class Box_NATO_Support_F: NATO_Box_Base {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_acc_pointer_red,4); MACRO_ADDITEM(ACE_acc_pointer_green,4);
}; };
}; };
@ -23,13 +23,12 @@ class CfgVehicles {
class FIA_Box_Base_F; class FIA_Box_Base_F;
class Box_FIA_Support_F: FIA_Box_Base_F { class Box_FIA_Support_F: FIA_Box_Base_F {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_acc_pointer_red,4); MACRO_ADDITEM(ACE_acc_pointer_green,4);
}; };
}; };
class ACE_Box_Misc: Box_NATO_Support_F { class ACE_Box_Misc: Box_NATO_Support_F {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_acc_pointer_red,4);
MACRO_ADDITEM(ACE_acc_pointer_green,4); MACRO_ADDITEM(ACE_acc_pointer_green,4);
}; };
}; };

View File

@ -1,17 +1,28 @@
class SlotInfo; class SlotInfo;
class PointerSlot: SlotInfo { class PointerSlot: SlotInfo {
compatibleItems[] += {"ACE_acc_pointer_red","ACE_acc_pointer_green"}; compatibleItems[] += {"ACE_acc_pointer_red","ACE_acc_pointer_green_IR","ACE_acc_pointer_green"};
}; };
class CfgWeapons { class CfgWeapons {
class ItemCore; class ItemCore;
class InventoryFlashLightItem_Base_F; class InventoryFlashLightItem_Base_F;
class acc_pointer_IR: ItemCore {
ACE_nextModeClass = "ACE_acc_pointer_red";
ACE_modeDescription = "$STR_ACE_Laserpointer_IRLaser";
displayName = "$STR_ACE_Laserpointer_red";
descriptionUse = "$STR_ACE_Laserpointer_useLaser";
};
class ACE_acc_pointer_red: ItemCore { class ACE_acc_pointer_red: ItemCore {
ACE_nextModeClass = "acc_pointer_IR";
ACE_modeDescription = "$STR_ACE_Laserpointer_Laser";
author = "$STR_ACE_Common_ACETeam"; author = "$STR_ACE_Common_ACETeam";
_generalMacro = "ACE_acc_pointer_red"; _generalMacro = "ACE_acc_pointer_red";
scope = 2; scope = 1;
displayName = "$STR_ACE_Laserpointer_red"; displayName = "$STR_ACE_Laserpointer_red";
descriptionUse = "$STR_ACE_Laserpointer_useLaser"; descriptionUse = "$STR_ACE_Laserpointer_useLaser";
picture = "\A3\weapons_F\Data\UI\gear_accv_pointer_CA.paa"; picture = "\A3\weapons_F\Data\UI\gear_accv_pointer_CA.paa";
@ -54,9 +65,23 @@ class CfgWeapons {
inertia = 0.1; inertia = 0.1;
}; };
class ACE_acc_pointer_green: ACE_acc_pointer_red { class ACE_acc_pointer_green_IR: acc_pointer_IR {
ACE_nextModeClass = "ACE_acc_pointer_green";
ACE_modeDescription = "$STR_ACE_Laserpointer_IRLaser";
author = "$STR_ACE_Common_ACETeam"; author = "$STR_ACE_Common_ACETeam";
_generalMacro = "ACE_acc_pointer_green"; _generalMacro = "ACE_acc_pointer_green";
scope = 1;
displayName = "$STR_ACE_Laserpointer_green";
};
class ACE_acc_pointer_green: ACE_acc_pointer_red {
ACE_nextModeClass = "ACE_acc_pointer_green_IR";
ACE_modeDescription = "$STR_ACE_Laserpointer_Laser";
author = "$STR_ACE_Common_ACETeam";
_generalMacro = "ACE_acc_pointer_green";
scope = 2;
displayName = "$STR_ACE_Laserpointer_green"; displayName = "$STR_ACE_Laserpointer_green";
}; };
}; };

View File

@ -11,7 +11,7 @@ GVAR(nearUnits) = [];
// @todo. Maybe move to common? // @todo. Maybe move to common?
[{ [{
private "_nearUnits"; private "_nearUnits";
_nearUnits = nearestObjects [positionCameraToWorld [0,0,0], ["CAManBase"], 50]; _nearUnits = nearestObjects [positionCameraToWorld [0,0,0], ["CAManBase"], 50]; // when moving this, search also for units inside vehicles. currently breaks the laser in FFV
if (count _nearUnits > 10) then { if (count _nearUnits > 10) then {
_nearUnits resize 10; _nearUnits resize 10;
@ -24,3 +24,16 @@ GVAR(nearUnits) = [];
addMissionEventHandler ["Draw3D", { addMissionEventHandler ["Draw3D", {
call FUNC(onDraw); call FUNC(onDraw);
}]; }];
// init keybinds
["ACE3", QGVAR(switchLaserLightMode), localize "STR_ACE_Laserpointer_switchLaserLight",
{
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if !([ACE_player] call EFUNC(common,canUseWeapon)) exitWith {false};
[ACE_player, currentWeapon ACE_player] call FUNC(switchLaserLightMode);
true
},
{false}, [38, [false, true, false]], false] call CBA_fnc_addKeybind;

View File

@ -4,5 +4,6 @@ ADDON = false;
PREP(drawLaserpoint); PREP(drawLaserpoint);
PREP(onDraw); PREP(onDraw);
PREP(switchLaserLightMode);
ADDON = true; ADDON = true;

View File

@ -3,7 +3,7 @@
class CfgPatches { class CfgPatches {
class ADDON { class ADDON {
units[] = {}; units[] = {};
weapons[] = {"ACE_acc_pointer_red","ACE_acc_pointer_green"}; weapons[] = {"ACE_acc_pointer_red","ACE_acc_pointer_green","ACE_acc_pointer_green_IR"};
requiredVersion = REQUIRED_VERSION; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"}; requiredAddons[] = {"ace_common"};
author[] = {"commy2"}; author[] = {"commy2"};

View File

@ -0,0 +1,58 @@
// by commy2
#include "script_component.hpp"
private ["_unit", "_weapon"];
_unit = _this select 0;
_weapon = _this select 1;
// 1 = primary, 2 = secondary, 3 = handgun
private "_currentWeaponType";
_currentWeaponType = 0;
private "_pointer";
_pointer = switch (_weapon) do {
case (primaryWeapon _unit): {
_currentWeaponType = 1;
primaryWeaponItems _unit select 1
};
case (secondaryWeapon _unit): {
_currentWeaponType = 2;
secondaryWeaponItems _unit select 1
};
case (handgunWeapon _unit): {
_currentWeaponType = 3;
handgunItems _unit select 1
};
default {""};
};
if (_pointer == "") exitWith {};
private "_nextPointer";
_nextPointer = getText (configFile >> "CfgWeapons" >> _pointer >> "ACE_nextModeClass");
if (_nextPointer == "") exitWith {};
private ["_description", "_picture"];
_description = getText (configFile >> "CfgWeapons" >> _nextPointer >> "ACE_modeDescription");
_picture = getText (configFile >> "CfgWeapons" >> _nextPointer >> "picture");
switch (_currentWeaponType) do {
case 1: {
_unit removePrimaryWeaponItem _pointer;
_unit addPrimaryWeaponItem _nextPointer;
};
case 2: {
_unit removeSecondaryWeaponItem _pointer;
_unit addSecondaryWeaponItem _nextPointer;
};
case 3: {
_unit removeHandgunItem _pointer;
_unit addHandgunItem _nextPointer;
};
};
[_description, _picture] call EFUNC(common,displayTextPicture);
playSound "ACE_Sound_Click";

View File

@ -36,5 +36,17 @@
<Russian>&lt;t color='#9cf953'&gt;Использовать: &lt;/t&gt;вкл/выкл лазер</Russian> <Russian>&lt;t color='#9cf953'&gt;Использовать: &lt;/t&gt;вкл/выкл лазер</Russian>
<Spanish>&lt;t color='#9cf953'&gt;Usar: &lt;/t&gt;encender/apagar láser</Spanish> <Spanish>&lt;t color='#9cf953'&gt;Usar: &lt;/t&gt;encender/apagar láser</Spanish>
</Key> </Key>
<Key ID="STR_ACE_Laserpointer_Laser">
<English>Laser</English>
<German>Laser</German>
</Key>
<Key ID="STR_ACE_Laserpointer_IRLaser">
<English>IR Laser</English>
<German>IR-Laser</German>
</Key>
<Key ID="STR_ACE_Laserpointer_switchLaserLight">
<English>Switch Laser / IR Laser</English>
<German>Umschalten Laser / IR-Laser</German>
</Key>
</Package> </Package>
</Project> </Project>