mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
parent
17f8830fbf
commit
6713ee155c
@ -28,6 +28,7 @@
|
||||
* **[Campaign Design]** Ability to define preset groups for specific TGOs, given the preset group is accessible for the faction and the task matches.
|
||||
* **[Campaign Management]** Additional options for automated budget management.
|
||||
* **[Campaign Management]** New options to allow more control of randomized flight sizes (applicable for BARCAP/CAS/OCA/ANTI-SHIP).
|
||||
* **[Plugins]** Updated Splash Damage script to v2.0 by RotorOps.
|
||||
|
||||
## Fixes
|
||||
* **[UI]** Removed deprecated options
|
||||
|
||||
@ -5,7 +5,7 @@ import logging
|
||||
import textwrap
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, TYPE_CHECKING
|
||||
from typing import List, Optional, TYPE_CHECKING, Any
|
||||
|
||||
from game.settings import Settings
|
||||
|
||||
@ -32,9 +32,9 @@ class LuaPluginWorkOrder:
|
||||
|
||||
|
||||
class PluginSettings:
|
||||
def __init__(self, identifier: str, enabled_by_default: bool) -> None:
|
||||
def __init__(self, identifier: str, value: Any) -> None:
|
||||
self.identifier = identifier
|
||||
self.enabled_by_default = enabled_by_default
|
||||
self.value = value
|
||||
self.settings = Settings()
|
||||
self.initialize_settings()
|
||||
|
||||
@ -46,20 +46,26 @@ class PluginSettings:
|
||||
# Plugin options are saved in the game's Settings, but it's possible for
|
||||
# plugins to change across loads. If new plugins are added or new
|
||||
# options added to those plugins, initialize the new settings.
|
||||
self.settings.initialize_plugin_option(self.identifier, self.enabled_by_default)
|
||||
self.settings.initialize_plugin_option(self.identifier, self.value)
|
||||
|
||||
@property
|
||||
def enabled(self) -> bool:
|
||||
def get_value(self) -> Any:
|
||||
return self.settings.plugin_option(self.identifier)
|
||||
|
||||
def set_enabled(self, enabled: bool) -> None:
|
||||
self.settings.set_plugin_option(self.identifier, enabled)
|
||||
def set_value(self, value: Any) -> None:
|
||||
self.settings.set_plugin_option(self.identifier, value)
|
||||
|
||||
|
||||
class LuaPluginOption(PluginSettings):
|
||||
def __init__(self, identifier: str, name: str, enabled_by_default: bool) -> None:
|
||||
super().__init__(identifier, enabled_by_default)
|
||||
def __init__(
|
||||
self, identifier: str, name: str, min: Any, max: Any, value: Any
|
||||
) -> None:
|
||||
super().__init__(identifier, value)
|
||||
self.name = name
|
||||
if type(value) == int or type(value) == float:
|
||||
self.min, self.max = min, max
|
||||
else:
|
||||
self.min, self.max = None, None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@ -83,7 +89,9 @@ class LuaPluginDefinition:
|
||||
LuaPluginOption(
|
||||
identifier=f"{name}.{option_id}",
|
||||
name=option.get("nameInUI", name),
|
||||
enabled_by_default=option.get("defaultValue"),
|
||||
min=option.get("minimumValue", 0),
|
||||
max=option.get("maximumValue", 10000),
|
||||
value=option.get("defaultValue"),
|
||||
)
|
||||
)
|
||||
|
||||
@ -123,6 +131,7 @@ class LuaPlugin(PluginSettings):
|
||||
def __init__(self, definition: LuaPluginDefinition) -> None:
|
||||
self.definition = definition
|
||||
super().__init__(self.definition.identifier, self.definition.enabled_by_default)
|
||||
self.enabled = self.definition.enabled_by_default
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
@ -146,6 +155,10 @@ class LuaPlugin(PluginSettings):
|
||||
|
||||
return cls(definition)
|
||||
|
||||
def set_enabled(self, enabled: bool) -> None:
|
||||
self.set_value(enabled)
|
||||
self.enabled = enabled
|
||||
|
||||
def set_settings(self, settings: Settings) -> None:
|
||||
super().set_settings(settings)
|
||||
for option in self.definition.options:
|
||||
@ -160,9 +173,9 @@ class LuaPlugin(PluginSettings):
|
||||
if self.options:
|
||||
option_decls = []
|
||||
for option in self.options:
|
||||
enabled = str(option.enabled).lower()
|
||||
value = str(option.value).lower()
|
||||
name = option.identifier
|
||||
option_decls.append(f" dcsRetribution.plugins.{name} = {enabled}")
|
||||
option_decls.append(f" dcsRetribution.plugins.{name} = {value}")
|
||||
|
||||
joined_options = "\n".join(option_decls)
|
||||
|
||||
|
||||
@ -660,17 +660,17 @@ class Settings:
|
||||
def plugin_settings_key(identifier: str) -> str:
|
||||
return f"plugins.{identifier}"
|
||||
|
||||
def initialize_plugin_option(self, identifier: str, default_value: bool) -> None:
|
||||
def initialize_plugin_option(self, identifier: str, default_value: Any) -> None:
|
||||
try:
|
||||
self.plugin_option(identifier)
|
||||
except KeyError:
|
||||
self.set_plugin_option(identifier, default_value)
|
||||
|
||||
def plugin_option(self, identifier: str) -> bool:
|
||||
def plugin_option(self, identifier: str) -> Any:
|
||||
return self.plugins[self.plugin_settings_key(identifier)]
|
||||
|
||||
def set_plugin_option(self, identifier: str, enabled: bool) -> None:
|
||||
self.plugins[self.plugin_settings_key(identifier)] = enabled
|
||||
def set_plugin_option(self, identifier: str, value: Any) -> None:
|
||||
self.plugins[self.plugin_settings_key(identifier)] = value
|
||||
|
||||
def __setstate__(self, state: dict[str, Any]) -> None:
|
||||
# __setstate__ is called with the dict of the object being unpickled. We
|
||||
|
||||
@ -18,7 +18,7 @@ from PySide2.QtWidgets import (
|
||||
QSpinBox,
|
||||
QStackedLayout,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
QWidget, QSizePolicy,
|
||||
)
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
@ -232,11 +232,9 @@ class AutoSettingsPageLayout(QVBoxLayout):
|
||||
self.setAlignment(Qt.AlignTop)
|
||||
|
||||
for section in Settings.sections(page):
|
||||
gbox = AutoSettingsGroup(page, section, settings, write_full_settings)
|
||||
scroll = QScrollArea()
|
||||
scroll.setWidget(gbox)
|
||||
scroll.setWidgetResizable(True)
|
||||
self.addWidget(scroll)
|
||||
self.addWidget(
|
||||
AutoSettingsGroup(page, section, settings, write_full_settings)
|
||||
)
|
||||
|
||||
|
||||
class AutoSettingsPage(QWidget):
|
||||
@ -265,7 +263,7 @@ class QSettingsWindow(QDialog):
|
||||
self.setModal(True)
|
||||
self.setWindowTitle("Settings")
|
||||
self.setWindowIcon(CONST.ICONS["Settings"])
|
||||
self.setMinimumSize(600, 250)
|
||||
self.setMinimumSize(840, 480)
|
||||
|
||||
self.initUi()
|
||||
|
||||
@ -290,7 +288,10 @@ class QSettingsWindow(QDialog):
|
||||
page_item.setEditable(False)
|
||||
page_item.setSelectable(True)
|
||||
self.categoryModel.appendRow(page_item)
|
||||
self.right_layout.addWidget(page)
|
||||
scroll = QScrollArea()
|
||||
scroll.setWidget(page)
|
||||
scroll.setWidgetResizable(True)
|
||||
self.right_layout.addWidget(scroll)
|
||||
|
||||
self.initCheatLayout()
|
||||
cheat = QStandardItem("Cheat Menu")
|
||||
@ -314,7 +315,10 @@ class QSettingsWindow(QDialog):
|
||||
pluginsOptions.setEditable(False)
|
||||
pluginsOptions.setSelectable(True)
|
||||
self.categoryModel.appendRow(pluginsOptions)
|
||||
self.right_layout.addWidget(self.pluginsOptionsPage)
|
||||
scroll = QScrollArea()
|
||||
scroll.setWidget(self.pluginsOptionsPage)
|
||||
scroll.setWidgetResizable(True)
|
||||
self.right_layout.addWidget(scroll)
|
||||
|
||||
self.categoryList.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
self.categoryList.setModel(self.categoryModel)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from PySide2.QtCore import Qt
|
||||
from PySide2.QtCore import Qt, QLocale
|
||||
from PySide2.QtWidgets import (
|
||||
QCheckBox,
|
||||
QGridLayout,
|
||||
@ -6,6 +6,8 @@ from PySide2.QtWidgets import (
|
||||
QLabel,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
QDoubleSpinBox,
|
||||
QSpinBox,
|
||||
)
|
||||
|
||||
from game.plugins import LuaPlugin, LuaPluginManager
|
||||
@ -53,10 +55,24 @@ class PluginOptionsBox(QGroupBox):
|
||||
for row, option in enumerate(plugin.options):
|
||||
layout.addWidget(QLabel(option.name), row, 0)
|
||||
|
||||
checkbox = QCheckBox()
|
||||
checkbox.setChecked(option.enabled)
|
||||
checkbox.toggled.connect(option.set_enabled)
|
||||
layout.addWidget(checkbox, row, 1)
|
||||
val = option.value
|
||||
if type(val) == bool:
|
||||
checkbox = QCheckBox()
|
||||
checkbox.setChecked(val)
|
||||
checkbox.toggled.connect(option.set_value)
|
||||
layout.addWidget(checkbox, row, 1)
|
||||
elif type(val) == float or type(val) == int:
|
||||
if type(val) == float:
|
||||
spinbox = QDoubleSpinBox()
|
||||
spinbox.setSingleStep(0.01)
|
||||
spinbox.setLocale(QLocale.English)
|
||||
else:
|
||||
spinbox = QSpinBox()
|
||||
spinbox.setMinimum(option.min)
|
||||
spinbox.setMaximum(option.max)
|
||||
spinbox.setValue(val)
|
||||
spinbox.valueChanged.connect(option.set_value)
|
||||
layout.addWidget(spinbox, row, 1)
|
||||
|
||||
|
||||
class PluginOptionsPage(QWidget):
|
||||
|
||||
@ -4,6 +4,6 @@
|
||||
"skynetiads",
|
||||
"ewrs",
|
||||
"herculescargo",
|
||||
"splashdamage",
|
||||
"splashdamage2",
|
||||
"lotatc"
|
||||
]
|
||||
|
||||
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -1,209 +0,0 @@
|
||||
|
||||
|
||||
--[[
|
||||
2 October 2020
|
||||
FrozenDroid:
|
||||
- Added error handling to all event handler and scheduled functions. Lua script errors can no longer bring the server down.
|
||||
- Added some extra checks to which weapons to handle, make sure they actually have a warhead (how come S-8KOM's don't have a warhead field...?)
|
||||
28 October 2020
|
||||
FrozenDroid:
|
||||
- Uncommented error logging, actually made it an error log which shows a message box on error.
|
||||
- Fixed the too restrictive weapon filter (took out the HE warhead requirement)
|
||||
--]]
|
||||
|
||||
explTable = {
|
||||
["FAB_100"] = 45,
|
||||
["FAB_250"] = 100,
|
||||
["FAB_250M54TU"]= 100,
|
||||
["FAB_500"] = 213,
|
||||
["FAB_1500"] = 675,
|
||||
["BetAB_500"] = 98,
|
||||
["BetAB_500ShP"]= 107,
|
||||
["KH-66_Grom"] = 108,
|
||||
["M_117"] = 201,
|
||||
["Mk_81"] = 60,
|
||||
["Mk_82"] = 118,
|
||||
["AN_M64"] = 121,
|
||||
["Mk_83"] = 274,
|
||||
["Mk_84"] = 582,
|
||||
["MK_82AIR"] = 118,
|
||||
["MK_82SNAKEYE"]= 118,
|
||||
["GBU_10"] = 582,
|
||||
["GBU_12"] = 118,
|
||||
["GBU_16"] = 274,
|
||||
["KAB_1500Kr"] = 675,
|
||||
["KAB_500Kr"] = 213,
|
||||
["KAB_500"] = 213,
|
||||
["GBU_31"] = 582,
|
||||
["GBU_31_V_3B"] = 582,
|
||||
["GBU_31_V_2B"] = 582,
|
||||
["GBU_31_V_4B"] = 582,
|
||||
["GBU_32_V_2B"] = 202,
|
||||
["GBU_38"] = 118,
|
||||
["AGM_62"] = 400,
|
||||
["GBU_24"] = 582,
|
||||
["X_23"] = 111,
|
||||
["X_23L"] = 111,
|
||||
["X_28"] = 160,
|
||||
["X_25ML"] = 89,
|
||||
["X_25MP"] = 89,
|
||||
["X_25MR"] = 140,
|
||||
["X_58"] = 140,
|
||||
["X_29L"] = 320,
|
||||
["X_29T"] = 320,
|
||||
["X_29TE"] = 320,
|
||||
["AGM_84E"] = 488,
|
||||
["AGM_88C"] = 89,
|
||||
["AGM_122"] = 15,
|
||||
["AGM_123"] = 274,
|
||||
["AGM_130"] = 582,
|
||||
["AGM_119"] = 176,
|
||||
["AGM_154C"] = 305,
|
||||
["S-24A"] = 24,
|
||||
--["S-24B"] = 123,
|
||||
["S-25OF"] = 194,
|
||||
["S-25OFM"] = 150,
|
||||
["S-25O"] = 150,
|
||||
["S_25L"] = 190,
|
||||
["S-5M"] = 1,
|
||||
["C_8"] = 4,
|
||||
["C_8OFP2"] = 3,
|
||||
["C_13"] = 21,
|
||||
["C_24"] = 123,
|
||||
["C_25"] = 151,
|
||||
["HYDRA_70M15"] = 2,
|
||||
["Zuni_127"] = 5,
|
||||
["ARAKM70BHE"] = 4,
|
||||
["BR_500"] = 118,
|
||||
["Rb 05A"] = 217,
|
||||
["HEBOMB"] = 40,
|
||||
["HEBOMBD"] = 40,
|
||||
["MK-81SE"] = 60,
|
||||
["AN-M57"] = 56,
|
||||
["AN-M64"] = 180,
|
||||
["AN-M65"] = 295,
|
||||
["AN-M66A2"] = 536,
|
||||
}
|
||||
|
||||
local weaponDamageEnable = 1
|
||||
WpnHandler = {}
|
||||
tracked_weapons = {}
|
||||
refreshRate = 0.1
|
||||
|
||||
local function getDistance(point1, point2)
|
||||
local x1 = point1.x
|
||||
local y1 = point1.y
|
||||
local z1 = point1.z
|
||||
local x2 = point2.x
|
||||
local y2 = point2.y
|
||||
local z2 = point2.z
|
||||
local dX = math.abs(x1-x2)
|
||||
local dZ = math.abs(z1-z2)
|
||||
local distance = math.sqrt(dX*dX + dZ*dZ)
|
||||
return distance
|
||||
end
|
||||
|
||||
local function getDistance3D(point1, point2)
|
||||
local x1 = point1.x
|
||||
local y1 = point1.y
|
||||
local z1 = point1.z
|
||||
local x2 = point2.x
|
||||
local y2 = point2.y
|
||||
local z2 = point2.z
|
||||
local dX = math.abs(x1-x2)
|
||||
local dY = math.abs(y1-y2)
|
||||
local dZ = math.abs(z1-z2)
|
||||
local distance = math.sqrt(dX*dX + dZ*dZ + dY*dY)
|
||||
return distance
|
||||
end
|
||||
|
||||
local function vec3Mag(speedVec)
|
||||
|
||||
mag = speedVec.x*speedVec.x + speedVec.y*speedVec.y+speedVec.z*speedVec.z
|
||||
mag = math.sqrt(mag)
|
||||
--trigger.action.outText("X = " .. speedVec.x ..", y = " .. speedVec.y .. ", z = "..speedVec.z, 10)
|
||||
--trigger.action.outText("Speed = " .. mag, 1)
|
||||
return mag
|
||||
|
||||
end
|
||||
|
||||
local function lookahead(speedVec)
|
||||
|
||||
speed = vec3Mag(speedVec)
|
||||
dist = speed * refreshRate * 1.5
|
||||
return dist
|
||||
|
||||
end
|
||||
|
||||
local function track_wpns()
|
||||
-- env.info("Weapon Track Start")
|
||||
for wpn_id_, wpnData in pairs(tracked_weapons) do
|
||||
if wpnData.wpn:isExist() then -- just update speed, position and direction.
|
||||
wpnData.pos = wpnData.wpn:getPosition().p
|
||||
wpnData.dir = wpnData.wpn:getPosition().x
|
||||
wpnData.speed = wpnData.wpn:getVelocity()
|
||||
--wpnData.lastIP = land.getIP(wpnData.pos, wpnData.dir, 50)
|
||||
else -- wpn no longer exists, must be dead.
|
||||
-- trigger.action.outText("Weapon impacted, mass of weapon warhead is " .. wpnData.exMass, 2)
|
||||
local ip = land.getIP(wpnData.pos, wpnData.dir, lookahead(wpnData.speed)) -- terrain intersection point with weapon's nose. Only search out 20 meters though.
|
||||
local impactPoint
|
||||
if not ip then -- use last calculated IP
|
||||
impactPoint = wpnData.pos
|
||||
-- trigger.action.outText("Impact Point:\nPos X: " .. impactPoint.x .. "\nPos Z: " .. impactPoint.z, 2)
|
||||
else -- use intersection point
|
||||
impactPoint = ip
|
||||
-- trigger.action.outText("Impact Point:\nPos X: " .. impactPoint.x .. "\nPos Z: " .. impactPoint.z, 2)
|
||||
end
|
||||
--env.info("Weapon is gone") -- Got to here --
|
||||
--trigger.action.outText("Weapon Type was: ".. wpnData.name, 20)
|
||||
if explTable[wpnData.name] then
|
||||
--env.info("triggered explosion size: "..explTable[wpnData.name])
|
||||
trigger.action.explosion(impactPoint, explTable[wpnData.name])
|
||||
--trigger.action.smoke(impactPoint, 0)
|
||||
end
|
||||
tracked_weapons[wpn_id_] = nil -- remove from tracked weapons first.
|
||||
end
|
||||
end
|
||||
-- env.info("Weapon Track End")
|
||||
end
|
||||
|
||||
function onWpnEvent(event)
|
||||
if event.id == world.event.S_EVENT_SHOT then
|
||||
if event.weapon then
|
||||
local ordnance = event.weapon
|
||||
local weapon_desc = ordnance:getDesc()
|
||||
if (weapon_desc.category ~= 0) and event.initiator then
|
||||
if (weapon_desc.category == 1) then
|
||||
if (weapon_desc.MissileCategory ~= 1 and weapon_desc.MissileCategory ~= 2) then
|
||||
tracked_weapons[event.weapon.id_] = { wpn = ordnance, init = event.initiator:getName(), pos = ordnance:getPoint(), dir = ordnance:getPosition().x, name = ordnance:getTypeName(), speed = ordnance:getVelocity() }
|
||||
end
|
||||
else
|
||||
tracked_weapons[event.weapon.id_] = { wpn = ordnance, init = event.initiator:getName(), pos = ordnance:getPoint(), dir = ordnance:getPosition().x, name = ordnance:getTypeName(), speed = ordnance:getVelocity() }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function protectedCall(...)
|
||||
local status, retval = pcall(...)
|
||||
if not status then
|
||||
env.warning("Splash damage script error... gracefully caught! " .. retval, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function WpnHandler:onEvent(event)
|
||||
protectedCall(onWpnEvent, event)
|
||||
end
|
||||
|
||||
if (weaponDamageEnable == 1) then
|
||||
timer.scheduleFunction(function()
|
||||
protectedCall(track_wpns)
|
||||
return timer.getTime() + refreshRate
|
||||
end,
|
||||
{},
|
||||
timer.getTime() + refreshRate
|
||||
)
|
||||
world.addEventHandler(WpnHandler)
|
||||
end
|
||||
@ -1,12 +0,0 @@
|
||||
{
|
||||
"nameInUI": "Splash Damage",
|
||||
"defaultValue": false,
|
||||
"specificOptions": [],
|
||||
"scriptsWorkOrders": [
|
||||
{
|
||||
"file": "Weapons_Damage_Updated.lua",
|
||||
"mnemonic": "Splash Damage"
|
||||
}
|
||||
],
|
||||
"configurationWorkOrders": []
|
||||
}
|
||||
472
resources/plugins/splashdamage2/Splash_Damage_2_0.lua
Normal file
472
resources/plugins/splashdamage2/Splash_Damage_2_0.lua
Normal file
@ -0,0 +1,472 @@
|
||||
|
||||
--assert(loadfile("C:\\Users\\spenc\\OneDrive\\Documents\\Eclipe_LDT\\dcs splash damage\\src\\mist.lua"))()
|
||||
--[[
|
||||
2 October 2020
|
||||
FrozenDroid:
|
||||
- Added error handling to all event handler and scheduled functions. Lua script errors can no longer bring the server down.
|
||||
- Added some extra checks to which weapons to handle, make sure they actually have a warhead (how come S-8KOM's don't have a warhead field...?)
|
||||
|
||||
28 October 2020
|
||||
FrozenDroid:
|
||||
- Uncommented error logging, actually made it an error log which shows a message box on error.
|
||||
- Fixed the too restrictive weapon filter (took out the HE warhead requirement)
|
||||
|
||||
21 December 2021
|
||||
spencershepard (GRIMM):
|
||||
SPLASH DAMAGE 2.0:
|
||||
-Added blast wave effect to add timed and scaled secondary explosions on top of game objects
|
||||
-object geometry within blast wave changes damage intensity
|
||||
-damage boost for structures since they are hard to kill, even if very close to large explosions
|
||||
-increased some rocket values in explTable
|
||||
-missing weapons from explTable will display message to user and log to DCS.log so that we can add what's missing
|
||||
-damage model for ground units that will disable their weapons and ability to move with partial damage before they are killed
|
||||
-added options table to allow easy adjustments before release
|
||||
-general refactoring and restructure
|
||||
|
||||
31 December 2021
|
||||
spencershepard (GRIMM):
|
||||
-added many new weapons
|
||||
-added filter for weapons.shells events
|
||||
-fixed mission weapon message option
|
||||
-changed default for damage_model option
|
||||
|
||||
16 April 2022
|
||||
spencershepard (GRIMM):
|
||||
added new/missing weapons to explTable
|
||||
added new option rocket_multiplier
|
||||
--]]
|
||||
|
||||
----[[ ##### SCRIPT CONFIGURATION ##### ]]----
|
||||
|
||||
splash_damage_options = {
|
||||
["static_damage_boost"] = 2000, --apply extra damage to Unit.Category.STRUCTUREs with wave explosions
|
||||
["wave_explosions"] = true, --secondary explosions on top of game objects, radiating outward from the impact point and scaled based on size of object and distance from weapon impact point
|
||||
["larger_explosions"] = true, --secondary explosions on top of weapon impact points, dictated by the values in the explTable
|
||||
["damage_model"] = false, --allow blast wave to affect ground unit movement and weapons
|
||||
["blast_search_radius"] = 100, --this is the max size of any blast wave radius, since we will only find objects within this zone
|
||||
["cascade_damage_threshold"] = 0.1, --if the calculated blast damage doesn't exeed this value, there will be no secondary explosion damage on the unit. If this value is too small, the appearance of explosions far outside of an expected radius looks incorrect.
|
||||
["game_messages"] = true, --enable some messages on screen
|
||||
["blast_stun"] = false, --not implemented
|
||||
["unit_disabled_health"] = 30, --if health is below this value after our explosions, disable its movement
|
||||
["unit_cant_fire_health"] = 50, --if health is below this value after our explosions, set ROE to HOLD to simulate damage weapon systems
|
||||
["infantry_cant_fire_health"] = 90, --if health is below this value after our explosions, set ROE to HOLD to simulate severe injury
|
||||
["debug"] = false, --enable debugging messages
|
||||
["weapon_missing_message"] = false, --false disables messages alerting you to weapons missing from the explTable
|
||||
["rocket_multiplier"] = 1.3, --multiplied by the explTable value for rockets
|
||||
["explTable_multiplier"] = 1.0, --overall multiplier for explTable
|
||||
}
|
||||
|
||||
local script_enable = 1
|
||||
refreshRate = 0.1
|
||||
|
||||
----[[ ##### End of SCRIPT CONFIGURATION ##### ]]----
|
||||
|
||||
explTable = {
|
||||
["FAB_100"] = 45,
|
||||
["FAB_250"] = 100,
|
||||
["FAB_250M54TU"]= 100,
|
||||
["FAB_500"] = 213,
|
||||
["FAB_1500"] = 675,
|
||||
["BetAB_500"] = 98,
|
||||
["BetAB_500ShP"]= 107,
|
||||
["KH-66_Grom"] = 108,
|
||||
["M_117"] = 201,
|
||||
["Mk_81"] = 60,
|
||||
["Mk_82"] = 118,
|
||||
["AN_M64"] = 121,
|
||||
["Mk_83"] = 274,
|
||||
["Mk_84"] = 582,
|
||||
["MK_82AIR"] = 118,
|
||||
["MK_82SNAKEYE"]= 118,
|
||||
["GBU_10"] = 582,
|
||||
["GBU_12"] = 118,
|
||||
["GBU_16"] = 274,
|
||||
["KAB_1500Kr"] = 675,
|
||||
["KAB_500Kr"] = 213,
|
||||
["KAB_500"] = 213,
|
||||
["GBU_31"] = 582,
|
||||
["GBU_31_V_3B"] = 582,
|
||||
["GBU_31_V_2B"] = 582,
|
||||
["GBU_31_V_4B"] = 582,
|
||||
["GBU_32_V_2B"] = 202,
|
||||
["GBU_38"] = 118,
|
||||
["AGM_62"] = 400,
|
||||
["GBU_24"] = 582,
|
||||
["X_23"] = 111,
|
||||
["X_23L"] = 111,
|
||||
["X_28"] = 160,
|
||||
["X_25ML"] = 89,
|
||||
["X_25MP"] = 89,
|
||||
["X_25MR"] = 140,
|
||||
["X_58"] = 140,
|
||||
["X_29L"] = 320,
|
||||
["X_29T"] = 320,
|
||||
["X_29TE"] = 320,
|
||||
["AGM_84E"] = 488,
|
||||
["AGM_88C"] = 89,
|
||||
["AGM_122"] = 15,
|
||||
["AGM_123"] = 274,
|
||||
["AGM_130"] = 582,
|
||||
["AGM_119"] = 176,
|
||||
["AGM_154C"] = 305,
|
||||
["S-24A"] = 24,
|
||||
--["S-24B"] = 123,
|
||||
["S-25OF"] = 194,
|
||||
["S-25OFM"] = 150,
|
||||
["S-25O"] = 150,
|
||||
["S_25L"] = 190,
|
||||
["S-5M"] = 1,
|
||||
["C_8"] = 4,
|
||||
["C_8OFP2"] = 3,
|
||||
["C_13"] = 21,
|
||||
["C_24"] = 123,
|
||||
["C_25"] = 151,
|
||||
["HYDRA_70M15"] = 3,
|
||||
["Zuni_127"] = 5,
|
||||
["ARAKM70BHE"] = 4,
|
||||
["BR_500"] = 118,
|
||||
["Rb 05A"] = 217,
|
||||
["HEBOMB"] = 40,
|
||||
["HEBOMBD"] = 40,
|
||||
["MK-81SE"] = 60,
|
||||
["AN-M57"] = 56,
|
||||
["AN-M64"] = 180,
|
||||
["AN-M65"] = 295,
|
||||
["AN-M66A2"] = 536,
|
||||
["HYDRA_70_M151"] = 4,
|
||||
["HYDRA_70_MK5"] = 4,
|
||||
["Vikhr_M"] = 11,
|
||||
["British_GP_250LB_Bomb_Mk1"] = 100, --("250 lb GP Mk.I")
|
||||
["British_GP_250LB_Bomb_Mk4"] = 100, --("250 lb GP Mk.IV")
|
||||
["British_GP_250LB_Bomb_Mk5"] = 100, --("250 lb GP Mk.V")
|
||||
["British_GP_500LB_Bomb_Mk1"] = 213, --("500 lb GP Mk.I")
|
||||
["British_GP_500LB_Bomb_Mk4"] = 213, --("500 lb GP Mk.IV")
|
||||
["British_GP_500LB_Bomb_Mk4_Short"] = 213, --("500 lb GP Short tail")
|
||||
["British_GP_500LB_Bomb_Mk5"] = 213, --("500 lb GP Mk.V")
|
||||
["British_MC_250LB_Bomb_Mk1"] = 100, --("250 lb MC Mk.I")
|
||||
["British_MC_250LB_Bomb_Mk2"] = 100, --("250 lb MC Mk.II")
|
||||
["British_MC_500LB_Bomb_Mk1_Short"] = 213, --("500 lb MC Short tail")
|
||||
["British_MC_500LB_Bomb_Mk2"] = 213, --("500 lb MC Mk.II")
|
||||
["British_SAP_250LB_Bomb_Mk5"] = 100, --("250 lb S.A.P.")
|
||||
["British_SAP_500LB_Bomb_Mk5"] = 213, --("500 lb S.A.P.")
|
||||
["British_AP_25LBNo1_3INCHNo1"] = 4, --("RP-3 25lb AP Mk.I")
|
||||
["British_HE_60LBSAPNo2_3INCHNo1"] = 4, --("RP-3 60lb SAP No2 Mk.I")
|
||||
["British_HE_60LBFNo1_3INCHNo1"] = 4, --("RP-3 60lb F No1 Mk.I")
|
||||
["WGr21"] = 4, --("Werfer-Granate 21 - 21 cm UnGd air-to-air rocket")
|
||||
["3xM8_ROCKETS_IN_TUBES"] = 4, --("4.5 inch M8 UnGd Rocket")
|
||||
["AN_M30A1"] = 45, --("AN-M30A1 - 100lb GP Bomb LD")
|
||||
["AN_M57"] = 100, --("AN-M57 - 250lb GP Bomb LD")
|
||||
["AN_M65"] = 400, --("AN-M65 - 1000lb GP Bomb LD")
|
||||
["AN_M66"] = 800, --("AN-M66 - 2000lb GP Bomb LD")
|
||||
["SC_50"] = 20, --("SC 50 - 50kg GP Bomb LD")
|
||||
["ER_4_SC50"] = 20, --("4 x SC 50 - 50kg GP Bomb LD")
|
||||
["SC_250_T1_L2"] = 100, --("SC 250 Type 1 L2 - 250kg GP Bomb LD")
|
||||
["SC_501_SC250"] = 100, --("SC 250 Type 3 J - 250kg GP Bomb LD")
|
||||
["Schloss500XIIC1_SC_250_T3_J"] = 100, --("SC 250 Type 3 J - 250kg GP Bomb LD")
|
||||
["SC_501_SC500"] = 213, --("SC 500 J - 500kg GP Bomb LD")
|
||||
["SC_500_L2"] = 213, --("SC 500 L2 - 500kg GP Bomb LD")
|
||||
["SD_250_Stg"] = 100, --("SD 250 Stg - 250kg GP Bomb LD")
|
||||
["SD_500_A"] = 213, --("SD 500 A - 500kg GP Bomb LD")
|
||||
["AB_250_2_SD_2"] = 100, --("AB 250-2 - 144 x SD-2, 250kg CBU with HE submunitions")
|
||||
["AB_250_2_SD_10A"] = 100, --("AB 250-2 - 17 x SD-10A, 250kg CBU with 10kg Frag/HE submunitions")
|
||||
["AB_500_1_SD_10A"] = 213, --("AB 500-1 - 34 x SD-10A, 500kg CBU with 10kg Frag/HE submunitions")
|
||||
["AGM_114K"] = 10,
|
||||
["HYDRA_70_M229"] = 8,
|
||||
["AGM_65D"] = 130,
|
||||
["AGM_65E"] = 300,
|
||||
["AGM_65F"] = 300,
|
||||
["HOT3"] = 15,
|
||||
["AGR_20A"] = 8,
|
||||
["GBU_54_V_1B"] = 118,
|
||||
|
||||
}
|
||||
|
||||
|
||||
----[[ ##### HELPER/UTILITY FUNCTIONS ##### ]]----
|
||||
|
||||
local function tableHasKey(table,key)
|
||||
return table[key] ~= nil
|
||||
end
|
||||
|
||||
local function debugMsg(str)
|
||||
if splash_damage_options.debug == true then
|
||||
trigger.action.outText(str , 5)
|
||||
end
|
||||
end
|
||||
|
||||
local function gameMsg(str)
|
||||
if splash_damage_options.game_messages == true then
|
||||
trigger.action.outText(str , 5)
|
||||
end
|
||||
end
|
||||
|
||||
local function getDistance(point1, point2)
|
||||
local x1 = point1.x
|
||||
local y1 = point1.y
|
||||
local z1 = point1.z
|
||||
local x2 = point2.x
|
||||
local y2 = point2.y
|
||||
local z2 = point2.z
|
||||
local dX = math.abs(x1-x2)
|
||||
local dZ = math.abs(z1-z2)
|
||||
local distance = math.sqrt(dX*dX + dZ*dZ)
|
||||
return distance
|
||||
end
|
||||
|
||||
local function getDistance3D(point1, point2)
|
||||
local x1 = point1.x
|
||||
local y1 = point1.y
|
||||
local z1 = point1.z
|
||||
local x2 = point2.x
|
||||
local y2 = point2.y
|
||||
local z2 = point2.z
|
||||
local dX = math.abs(x1-x2)
|
||||
local dY = math.abs(y1-y2)
|
||||
local dZ = math.abs(z1-z2)
|
||||
local distance = math.sqrt(dX*dX + dZ*dZ + dY*dY)
|
||||
return distance
|
||||
end
|
||||
|
||||
local function vec3Mag(speedVec)
|
||||
local mag = speedVec.x*speedVec.x + speedVec.y*speedVec.y+speedVec.z*speedVec.z
|
||||
mag = math.sqrt(mag)
|
||||
--trigger.action.outText("X = " .. speedVec.x ..", y = " .. speedVec.y .. ", z = "..speedVec.z, 10)
|
||||
--trigger.action.outText("Speed = " .. mag, 1)
|
||||
return mag
|
||||
end
|
||||
|
||||
local function lookahead(speedVec)
|
||||
local speed = vec3Mag(speedVec)
|
||||
local dist = speed * refreshRate * 1.5
|
||||
return dist
|
||||
end
|
||||
|
||||
----[[ ##### End of HELPER/UTILITY FUNCTIONS ##### ]]----
|
||||
|
||||
|
||||
WpnHandler = {}
|
||||
tracked_weapons = {}
|
||||
|
||||
function track_wpns()
|
||||
-- env.info("Weapon Track Start")
|
||||
for wpn_id_, wpnData in pairs(tracked_weapons) do
|
||||
if wpnData.wpn:isExist() then -- just update speed, position and direction.
|
||||
wpnData.pos = wpnData.wpn:getPosition().p
|
||||
wpnData.dir = wpnData.wpn:getPosition().x
|
||||
wpnData.speed = wpnData.wpn:getVelocity()
|
||||
--wpnData.lastIP = land.getIP(wpnData.pos, wpnData.dir, 50)
|
||||
else -- wpn no longer exists, must be dead.
|
||||
-- trigger.action.outText("Weapon impacted, mass of weapon warhead is " .. wpnData.exMass, 2)
|
||||
local ip = land.getIP(wpnData.pos, wpnData.dir, lookahead(wpnData.speed)) -- terrain intersection point with weapon's nose. Only search out 20 meters though.
|
||||
local impactPoint
|
||||
if not ip then -- use last calculated IP
|
||||
impactPoint = wpnData.pos
|
||||
-- trigger.action.outText("Impact Point:\nPos X: " .. impactPoint.x .. "\nPos Z: " .. impactPoint.z, 2)
|
||||
else -- use intersection point
|
||||
impactPoint = ip
|
||||
-- trigger.action.outText("Impact Point:\nPos X: " .. impactPoint.x .. "\nPos Z: " .. impactPoint.z, 2)
|
||||
end
|
||||
--env.info("Weapon is gone") -- Got to here --
|
||||
--trigger.action.outText("Weapon Type was: ".. wpnData.name, 20)
|
||||
if splash_damage_options.larger_explosions == true then
|
||||
--env.info("triggered explosion size: "..getWeaponExplosive(wpnData.name))
|
||||
trigger.action.explosion(impactPoint, getWeaponExplosive(wpnData.name))
|
||||
--trigger.action.smoke(impactPoint, 0)
|
||||
end
|
||||
local explosive = getWeaponExplosive(wpnData.name)
|
||||
if splash_damage_options.rocket_multiplier > 0 and wpnData.cat == Weapon.Category.ROCKET then
|
||||
explosive = explosive * splash_damage_options.rocket_multiplier
|
||||
end
|
||||
blastWave(impactPoint, splash_damage_options.blast_search_radius, wpnData.ordnance, explosive)
|
||||
tracked_weapons[wpn_id_] = nil -- remove from tracked weapons first.
|
||||
end
|
||||
end
|
||||
-- env.info("Weapon Track End")
|
||||
end
|
||||
|
||||
function onWpnEvent(event)
|
||||
if event.id == world.event.S_EVENT_SHOT then
|
||||
if event.weapon then
|
||||
local ordnance = event.weapon
|
||||
local weapon_desc = ordnance:getDesc()
|
||||
if string.find(ordnance:getTypeName(), "weapons.shells") then
|
||||
debugMsg("event shot, but not tracking: "..ordnance:getTypeName())
|
||||
return --we wont track these types of weapons, so exit here
|
||||
end
|
||||
|
||||
if explTable[ordnance:getTypeName()] then
|
||||
--trigger.action.outText(ordnance:getTypeName().." found.", 10)
|
||||
else
|
||||
env.info(ordnance:getTypeName().." missing from Splash Damage script")
|
||||
if splash_damage_options.weapon_missing_message == true then
|
||||
trigger.action.outText(ordnance:getTypeName().." missing from Splash Damage script", 10)
|
||||
debugMsg("desc: "..mist.utils.tableShow(weapon_desc))
|
||||
end
|
||||
end
|
||||
if (weapon_desc.category ~= 0) and event.initiator then
|
||||
if (weapon_desc.category == 1) then
|
||||
if (weapon_desc.MissileCategory ~= 1 and weapon_desc.MissileCategory ~= 2) then
|
||||
tracked_weapons[event.weapon.id_] = { wpn = ordnance, init = event.initiator:getName(), pos = ordnance:getPoint(), dir = ordnance:getPosition().x, name = ordnance:getTypeName(), speed = ordnance:getVelocity(), cat = ordnance:getCategory() }
|
||||
end
|
||||
else
|
||||
tracked_weapons[event.weapon.id_] = { wpn = ordnance, init = event.initiator:getName(), pos = ordnance:getPoint(), dir = ordnance:getPosition().x, name = ordnance:getTypeName(), speed = ordnance:getVelocity(), cat = ordnance:getCategory() }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function protectedCall(...)
|
||||
local status, retval = pcall(...)
|
||||
if not status then
|
||||
env.warning("Splash damage script error... gracefully caught! " .. retval, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function WpnHandler:onEvent(event)
|
||||
protectedCall(onWpnEvent, event)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function explodeObject(table)
|
||||
local point = table[1]
|
||||
local distance = table[2]
|
||||
local power = table[3]
|
||||
trigger.action.explosion(point, power)
|
||||
end
|
||||
|
||||
function getWeaponExplosive(name)
|
||||
if explTable[name] then
|
||||
return explTable[name] * splash_damage_options.explTable_multiplier
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
--controller is only at group level for ground units. we should itterate over the group and only apply effects if health thresholds are met by all units in the group
|
||||
function modelUnitDamage(units)
|
||||
--debugMsg("units table: "..mist.utils.tableShow(units))
|
||||
for i, unit in ipairs(units)
|
||||
do
|
||||
--debugMsg("unit table: "..mist.utils.tableShow(unit))
|
||||
if unit:isExist() then --if units are not already dead
|
||||
local health = (unit:getLife() / unit:getDesc().life) * 100
|
||||
--debugMsg(unit:getTypeName().." health %"..health)
|
||||
if unit:hasAttribute("Infantry") == true and health > 0 then --if infantry
|
||||
if health <= splash_damage_options.infantry_cant_fire_health then
|
||||
---disable unit's ability to fire---
|
||||
unit:getController():setOption(AI.Option.Ground.id.ROE , AI.Option.Ground.val.ROE.WEAPON_HOLD)
|
||||
end
|
||||
end
|
||||
if unit:getDesc().category == Unit.Category.GROUND_UNIT == true and unit:hasAttribute("Infantry") == false and health > 0 then --if ground unit but not infantry
|
||||
if health <= splash_damage_options.unit_cant_fire_health then
|
||||
---disable unit's ability to fire---
|
||||
unit:getController():setOption(AI.Option.Ground.id.ROE , AI.Option.Ground.val.ROE.WEAPON_HOLD)
|
||||
gameMsg(unit:getTypeName().." weapons disabled")
|
||||
end
|
||||
if health <= splash_damage_options.unit_disabled_health and health > 0 then
|
||||
---disable unit's ability to move---
|
||||
unit:getController():setTask({id = 'Hold', params = { }} )
|
||||
unit:getController():setOnOff(false)
|
||||
gameMsg(unit:getTypeName().." disabled")
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
--debugMsg("unit no longer exists")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function blastWave(_point, _radius, weapon, power)
|
||||
local foundUnits = {}
|
||||
local volS = {
|
||||
id = world.VolumeType.SPHERE,
|
||||
params = {
|
||||
point = _point,
|
||||
radius = _radius
|
||||
}
|
||||
}
|
||||
|
||||
local ifFound = function(foundObject, val)
|
||||
if foundObject:getDesc().category == Unit.Category.GROUND_UNIT and foundObject:getCategory() == Object.Category.UNIT then
|
||||
foundUnits[#foundUnits + 1] = foundObject
|
||||
end
|
||||
if foundObject:getDesc().category == Unit.Category.GROUND_UNIT then --if ground unit
|
||||
if splash_damage_options.blast_stun == true then
|
||||
--suppressUnit(foundObject, 2, weapon)
|
||||
end
|
||||
end
|
||||
if splash_damage_options.wave_explosions == true then
|
||||
local obj = foundObject
|
||||
local obj_location = obj:getPoint()
|
||||
local distance = getDistance(_point, obj_location)
|
||||
local timing = distance/500
|
||||
if obj:isExist() then
|
||||
|
||||
if tableHasKey(obj:getDesc(), "box") then
|
||||
local length = (obj:getDesc().box.max.x + math.abs(obj:getDesc().box.min.x))
|
||||
local height = (obj:getDesc().box.max.y + math.abs(obj:getDesc().box.min.y))
|
||||
local depth = (obj:getDesc().box.max.z + math.abs(obj:getDesc().box.min.z))
|
||||
local _length = length
|
||||
local _depth = depth
|
||||
if depth > length then
|
||||
_length = depth
|
||||
_depth = length
|
||||
end
|
||||
local surface_distance = distance - _depth/2
|
||||
local scaled_power_factor = 0.006 * power + 1 --this could be reduced into the calc on the next line
|
||||
local intensity = (power * scaled_power_factor) / (4 * 3.14 * surface_distance * surface_distance )
|
||||
local surface_area = _length * height --Ideally we should roughly calculate the surface area facing the blast point, but we'll just find the largest side of the object for now
|
||||
local damage_for_surface = intensity * surface_area
|
||||
--debugMsg(obj:getTypeName().." sa:"..surface_area.." distance:"..surface_distance.." dfs:"..damage_for_surface)
|
||||
if damage_for_surface > splash_damage_options.cascade_damage_threshold then
|
||||
local explosion_size = damage_for_surface
|
||||
if obj:getDesc().category == Unit.Category.STRUCTURE then
|
||||
explosion_size = intensity * splash_damage_options.static_damage_boost --apply an extra damage boost for static objects. should we factor in surface_area?
|
||||
--debugMsg("static obj :"..obj:getTypeName())
|
||||
end
|
||||
if explosion_size > power then explosion_size = power end --secondary explosions should not be larger than the explosion that created it
|
||||
local id = timer.scheduleFunction(explodeObject, {obj_location, distance, explosion_size}, timer.getTime() + timing) --create the explosion on the object location
|
||||
end
|
||||
|
||||
|
||||
else --debugMsg(obj:getTypeName().." object does not have box property")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
world.searchObjects(Object.Category.UNIT, volS, ifFound)
|
||||
world.searchObjects(Object.Category.STATIC, volS, ifFound)
|
||||
world.searchObjects(Object.Category.SCENERY, volS, ifFound)
|
||||
world.searchObjects(Object.Category.CARGO, volS, ifFound)
|
||||
--world.searchObjects(Object.Category.BASE, volS, ifFound)
|
||||
|
||||
if splash_damage_options.damage_model == true then
|
||||
local id = timer.scheduleFunction(modelUnitDamage, foundUnits, timer.getTime() + 1.5) --allow some time for the game to adjust health levels before running our function
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
if (script_enable == 1) then
|
||||
gameMsg("SPLASH DAMAGE 2 SCRIPT RUNNING")
|
||||
env.info("SPLASH DAMAGE 2 SCRIPT RUNNING")
|
||||
timer.scheduleFunction(function()
|
||||
protectedCall(track_wpns)
|
||||
return timer.getTime() + refreshRate
|
||||
end,
|
||||
{},
|
||||
timer.getTime() + refreshRate
|
||||
)
|
||||
world.addEventHandler(WpnHandler)
|
||||
end
|
||||
54
resources/plugins/splashdamage2/plugin.json
Normal file
54
resources/plugins/splashdamage2/plugin.json
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"nameInUI": "Splash Damage 2.0 by RotorOps",
|
||||
"defaultValue": false,
|
||||
"specificOptions": [
|
||||
{
|
||||
"nameInUI": "Enable wave explosions",
|
||||
"mnemonic": "wave_explosions",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"nameInUI": "Enable damage model",
|
||||
"mnemonic": "damage_model",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"nameInUI": "Enable debug messages",
|
||||
"mnemonic": "debug",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"nameInUI": "Overall damage multiplier",
|
||||
"mnemonic": "explTable_multiplier",
|
||||
"minimumValue": 0.1,
|
||||
"maximumValue": 2.5,
|
||||
"defaultValue": 1.0
|
||||
},
|
||||
{
|
||||
"nameInUI": "Static damage boost for wave explosions",
|
||||
"mnemonic": "static_damage_boost",
|
||||
"minimumValue": 500,
|
||||
"maximumValue": 5000,
|
||||
"defaultValue": 1000
|
||||
},
|
||||
{
|
||||
"nameInUI": "Maximum blast radius",
|
||||
"mnemonic": "blast_search_radius",
|
||||
"minimumValue": 10,
|
||||
"maximumValue": 1000,
|
||||
"defaultValue": 100
|
||||
}
|
||||
],
|
||||
"scriptsWorkOrders": [
|
||||
{
|
||||
"file": "Splash_Damage_2_0.lua",
|
||||
"mnemonic": "Splash Damage 2"
|
||||
}
|
||||
],
|
||||
"configurationWorkOrders": [
|
||||
{
|
||||
"file": "sd2-config.lua",
|
||||
"mnemonic": "sd2-config"
|
||||
}
|
||||
]
|
||||
}
|
||||
24
resources/plugins/splashdamage2/sd2-config.lua
Normal file
24
resources/plugins/splashdamage2/sd2-config.lua
Normal file
@ -0,0 +1,24 @@
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- configuration file for Splash Damage 2 Plugin
|
||||
--
|
||||
-- This configuration is tailored for a mission generated by DCS Retribution
|
||||
-- see https://github.com/dcs-retribution/dcs-retribution
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
-- SD2 plugin - configuration
|
||||
if dcsRetribution then
|
||||
-- retrieve specific options values
|
||||
if dcsRetribution.plugins then
|
||||
if dcsRetribution.plugins.splashdamage2 then
|
||||
env.info("DCSRetribution|Splash Damage 2 plugin - Setting Up")
|
||||
|
||||
splash_damage_options.wave_explosions = dcsRetribution.plugins.splashdamage2.wave_explosions
|
||||
splash_damage_options.damage_model = dcsRetribution.plugins.splashdamage2.damage_model
|
||||
splash_damage_options.debug = dcsRetribution.plugins.splashdamage2.debug
|
||||
splash_damage_options.explTable_multiplier = dcsRetribution.plugins.splashdamage2.explTable_multiplier
|
||||
splash_damage_options.static_damage_boost = dcsRetribution.plugins.splashdamage2.static_damage_boost
|
||||
splash_damage_options.blast_search_radius = dcsRetribution.plugins.splashdamage2.blast_search_radius
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user