From 1b4f3db2f32ffdef3acb7657f37bca3a51ffe467 Mon Sep 17 00:00:00 2001 From: Skipper Date: Thu, 13 Feb 2025 22:09:59 +0000 Subject: Updated plugins and manager Added smoke on damage as a plugin And added in ability for plugin manager to use folder plugins (multi file if necessary) --- plugins/smoke_on_damage/Plugin.py | 47 +++++++++++++++++++++++++++++++++++++ plugins/smoke_on_damage/__init__.py | 2 ++ 2 files changed, 49 insertions(+) create mode 100644 plugins/smoke_on_damage/Plugin.py create mode 100644 plugins/smoke_on_damage/__init__.py (limited to 'plugins/smoke_on_damage') diff --git a/plugins/smoke_on_damage/Plugin.py b/plugins/smoke_on_damage/Plugin.py new file mode 100644 index 0000000..b3b4ccd --- /dev/null +++ b/plugins/smoke_on_damage/Plugin.py @@ -0,0 +1,47 @@ +"""TThis plugin will cause the aircraft to emit smoke if it's health is below a certain threshold. +It is also an example of a plugin as a folder/module.""" +from lib.PacketManager.packets import FSNETCMD_AIRCMD, FSNETCMD_AIRPLANESTATE, FSNETCMD_TEXTMESSAGE +from logging import debug +from config import SMOKE_LIFE, SMOKE_PLANE +ENABLED = True + +class Plugin: + def __init__(self): + self.plugin_manager = None + + def register(self, plugin_manager): + self.plugin_manager = plugin_manager + self.plugin_manager.register_hook('on_flight_data', self.on_flight_data) + self.plugin_manager.register_hook('on_weapon_config', self.on_weapon_config) + + def on_flight_data(self, data, player,message_to_client, message_to_server): + """After the initial incoming flight packet, check whether + the health is below the threshold, if so add smoke""" + if ENABLED and SMOKE_PLANE and player.aircraft.life