Release 0.9.0
This commit is contained in:
55
bot/modules/locations/actions/bc-export.py
Normal file
55
bot/modules/locations/actions/bc-export.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from bot import loaded_modules_dict
|
||||
from os import path, pardir
|
||||
|
||||
module_name = path.basename(path.normpath(path.join(path.abspath(__file__), pardir, pardir)))
|
||||
action_name = path.basename(path.abspath(__file__))[:-3]
|
||||
|
||||
|
||||
def main_function(module, event_data, dispatchers_steamid):
|
||||
event_data[1]["action_identifier"] = action_name
|
||||
|
||||
active_dataset = module.dom.data.get("module_game_environment", {}).get("active_dataset", None)
|
||||
location_identifier = event_data[1].get("location_identifier")
|
||||
location_dict = (
|
||||
module.dom.data.get("module_locations", {})
|
||||
.get("elements", {})
|
||||
.get(active_dataset, {})
|
||||
.get(dispatchers_steamid, {})
|
||||
.get(location_identifier, None)
|
||||
)
|
||||
|
||||
coordinates = module.get_location_volume(location_dict)
|
||||
if coordinates is not None:
|
||||
command = (
|
||||
"bc-export {location_to_be_exported} {pos_x} {pos_y} {pos_z} {pos_x2} {pos_y2} {pos_z2}"
|
||||
).format(
|
||||
location_to_be_exported=location_dict.get("identifier"),
|
||||
**coordinates
|
||||
)
|
||||
|
||||
module.telnet.add_telnet_command_to_queue(command)
|
||||
module.callback_success(callback_success, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
module.callback_fail(callback_fail, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
|
||||
def callback_success(module, event_data, dispatchers_steamid, match=None):
|
||||
pass
|
||||
|
||||
|
||||
def callback_fail(module, event_data, dispatchers_steamid):
|
||||
pass
|
||||
|
||||
|
||||
action_meta = {
|
||||
"description": "Will export everything inside the locations Volume. Will only work for 'box' locations",
|
||||
"main_function": main_function,
|
||||
"callback_success": callback_success,
|
||||
"callback_fail": callback_fail,
|
||||
"requires_telnet_connection": False,
|
||||
"enabled": True
|
||||
}
|
||||
|
||||
loaded_modules_dict["module_" + module_name].register_action(action_name, action_meta)
|
||||
97
bot/modules/locations/actions/bc-import.py
Normal file
97
bot/modules/locations/actions/bc-import.py
Normal file
@@ -0,0 +1,97 @@
|
||||
from bot import loaded_modules_dict
|
||||
from os import path, pardir
|
||||
|
||||
module_name = path.basename(path.normpath(path.join(path.abspath(__file__), pardir, pardir)))
|
||||
action_name = path.basename(path.abspath(__file__))[:-3]
|
||||
|
||||
|
||||
def fix_coordinates_for_bc_import(location_dict: dict, coordinates: dict, player_dict=None) -> bool:
|
||||
shape = location_dict.get("shape", None)
|
||||
dimensions = location_dict.get("dimensions", None)
|
||||
location_coordinates = location_dict.get("coordinates", None)
|
||||
|
||||
if shape == "box":
|
||||
if player_dict is None:
|
||||
if int(float(location_coordinates["x"])) < 0: # W Half
|
||||
coordinates["pos_x"] = int(float(coordinates["pos_x"]) - float(dimensions["width"]) + 1)
|
||||
if int(float(location_coordinates["x"])) >= 0: # E Half
|
||||
coordinates["pos_x"] = int(float(coordinates["pos_x"]) - float(dimensions["width"]))
|
||||
else:
|
||||
if int(float(player_dict.get("pos", {}).get("x"))) < 0: # W Half
|
||||
coordinates["pos_x"] = int(float(player_dict.get("pos", {}).get("x")) - float(dimensions["width"]) - 1)
|
||||
if int(float(player_dict.get("pos", {}).get("x"))) >= 0: # E Half
|
||||
coordinates["pos_x"] = int(float(player_dict.get("pos", {}).get("x")) - float(dimensions["width"]))
|
||||
|
||||
coordinates["pos_y"] = int(float(player_dict.get("pos", {}).get("y")))
|
||||
|
||||
if int(float(player_dict.get("pos", {}).get("z"))) < 0: # S Half
|
||||
coordinates["pos_z"] = int(float(player_dict.get("pos", {}).get("z")) - 1)
|
||||
if int(float(player_dict.get("pos", {}).get("z"))) >= 0: # N Half
|
||||
coordinates["pos_z"] = int(float(player_dict.get("pos", {}).get("z")))
|
||||
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def main_function(module, event_data, dispatchers_steamid):
|
||||
event_data[1]["action_identifier"] = action_name
|
||||
|
||||
active_dataset = module.dom.data.get("module_game_environment", {}).get("active_dataset", None)
|
||||
location_identifier = event_data[1].get("location_identifier")
|
||||
spawn_in_place = event_data[1].get("spawn_in_place")
|
||||
location_dict = (
|
||||
module.dom.data.get("module_locations", {})
|
||||
.get("elements", {})
|
||||
.get(active_dataset, {})
|
||||
.get(dispatchers_steamid, {})
|
||||
.get(location_identifier, None)
|
||||
)
|
||||
|
||||
coordinates = module.get_location_volume(location_dict)
|
||||
|
||||
if coordinates is not None:
|
||||
if spawn_in_place:
|
||||
player_dict = (
|
||||
module.dom.data.get("module_players", {})
|
||||
.get("elements", {})
|
||||
.get(active_dataset, {})
|
||||
.get(dispatchers_steamid, {})
|
||||
)
|
||||
fix_coordinates_for_bc_import(location_dict, coordinates, player_dict)
|
||||
else:
|
||||
fix_coordinates_for_bc_import(location_dict, coordinates)
|
||||
|
||||
command = (
|
||||
"bc-import {location_to_be_imported} {pos_x} {pos_y} {pos_z}"
|
||||
).format(
|
||||
location_to_be_imported=location_dict.get("identifier"),
|
||||
**coordinates
|
||||
)
|
||||
|
||||
module.telnet.add_telnet_command_to_queue(command)
|
||||
module.callback_success(callback_success, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
module.callback_fail(callback_fail, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
|
||||
def callback_success(module, event_data, dispatchers_steamid, match=None):
|
||||
pass
|
||||
|
||||
|
||||
def callback_fail(module, event_data, dispatchers_steamid):
|
||||
pass
|
||||
|
||||
|
||||
action_meta = {
|
||||
"description": "Imports a saved prefab. Needs to have a location first!",
|
||||
"main_function": main_function,
|
||||
"callback_success": callback_success,
|
||||
"callback_fail": callback_fail,
|
||||
"requires_telnet_connection": False,
|
||||
"enabled": True
|
||||
}
|
||||
|
||||
loaded_modules_dict["module_" + module_name].register_action(action_name, action_meta)
|
||||
82
bot/modules/locations/actions/edit_location.py
Normal file
82
bot/modules/locations/actions/edit_location.py
Normal file
@@ -0,0 +1,82 @@
|
||||
from bot import loaded_modules_dict
|
||||
from os import path, pardir
|
||||
module_name = path.basename(path.normpath(path.join(path.abspath(__file__), pardir, pardir)))
|
||||
action_name = path.basename(path.abspath(__file__))[:-3]
|
||||
|
||||
|
||||
def main_function(module, event_data, dispatchers_steamid):
|
||||
location_identifier = event_data[1].get("location_identifier", None)
|
||||
active_dataset = module.dom.data.get("module_game_environment", {}).get("active_dataset", None)
|
||||
|
||||
event_data[1]["action_identifier"] = action_name
|
||||
event_data[1]["fail_reason"] = []
|
||||
|
||||
location_owner = event_data[1].get("location_owner", dispatchers_steamid)
|
||||
location_name = event_data[1].get("location_name", None)
|
||||
if location_identifier is None or location_identifier == "":
|
||||
location_identifier = ''.join(e for e in location_name if e.isalnum())
|
||||
|
||||
location_shape = event_data[1].get("location_shape", module.default_options.get("standard_location_shape", None))
|
||||
location_types = event_data[1].get("location_type", [])
|
||||
location_coordinates = event_data[1].get("location_coordinates", {})
|
||||
location_teleport_entry = event_data[1].get("location_teleport_entry", {})
|
||||
location_dimensions = event_data[1].get("location_dimensions", {})
|
||||
location_enabled = event_data[1].get("is_enabled", False)
|
||||
last_changed = event_data[1].get("last_changed", False)
|
||||
|
||||
if all([
|
||||
location_name is not None and len(location_name) >= 3,
|
||||
location_identifier is not None,
|
||||
location_shape is not None,
|
||||
active_dataset is not None,
|
||||
location_owner is not None
|
||||
]):
|
||||
module.dom.data.upsert({
|
||||
module.get_module_identifier(): {
|
||||
"elements": {
|
||||
active_dataset: {
|
||||
str(location_owner): {
|
||||
location_identifier: {
|
||||
"name": location_name,
|
||||
"identifier": location_identifier,
|
||||
"dataset": active_dataset,
|
||||
"shape": location_shape,
|
||||
"type": location_types,
|
||||
"coordinates": location_coordinates,
|
||||
"teleport_entry": location_teleport_entry,
|
||||
"dimensions": location_dimensions,
|
||||
"owner": str(location_owner),
|
||||
"is_enabled": location_enabled,
|
||||
"selected_by": [],
|
||||
"last_changed": last_changed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, dispatchers_steamid=dispatchers_steamid, max_callback_level=4)
|
||||
module.callback_success(callback_success, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
event_data[1]["fail_reason"].append("not all conditions met!")
|
||||
module.callback_fail(callback_fail, module, event_data, dispatchers_steamid)
|
||||
|
||||
|
||||
def callback_success(module, event_data, dispatchers_steamid, match=None):
|
||||
pass
|
||||
|
||||
|
||||
def callback_fail(module, event_data, dispatchers_steamid):
|
||||
pass
|
||||
|
||||
|
||||
action_meta = {
|
||||
"description": "manages location entries",
|
||||
"main_function": main_function,
|
||||
"callback_success": callback_success,
|
||||
"callback_fail": callback_fail,
|
||||
"requires_telnet_connection": False,
|
||||
"enabled": True
|
||||
}
|
||||
|
||||
loaded_modules_dict["module_" + module_name].register_action(action_name, action_meta)
|
||||
48
bot/modules/locations/actions/onslaught.py
Normal file
48
bot/modules/locations/actions/onslaught.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from bot import loaded_modules_dict
|
||||
from os import path, pardir
|
||||
from time import sleep, time
|
||||
import re
|
||||
|
||||
module_name = path.basename(path.normpath(path.join(path.abspath(__file__), pardir, pardir)))
|
||||
action_name = path.basename(path.abspath(__file__))[:-3]
|
||||
|
||||
|
||||
def main_function(module, event_data, dispatchers_steamid):
|
||||
action = event_data[1].get("action", None)
|
||||
event_data[1]["action_identifier"] = action_name
|
||||
location_identifier = event_data[1].get("location_identifier", None)
|
||||
|
||||
if action == "start onslaught":
|
||||
event_data = ['say_to_player', {
|
||||
'steamid': dispatchers_steamid,
|
||||
'message': '[66FF66]Onslaught[-][FFFFFF] Started for location [66FF66]{}[-]'.format(location_identifier)
|
||||
}]
|
||||
module.trigger_action_hook(module.players, event_data=event_data)
|
||||
elif action == "stop onslaught":
|
||||
event_data = ['say_to_player', {
|
||||
'steamid': dispatchers_steamid,
|
||||
'message': '[66FF66]Onslaught[-][FFFFFF] in location [66FF66]{}[-] Ended[-]'.format(location_identifier)
|
||||
}]
|
||||
module.trigger_action_hook(module.players, event_data=event_data)
|
||||
|
||||
module.callback_success(callback_success, module, event_data, dispatchers_steamid)
|
||||
|
||||
|
||||
def callback_success(module, event_data, dispatchers_steamid, match=None):
|
||||
pass
|
||||
|
||||
|
||||
def callback_fail(module, event_data, dispatchers_steamid):
|
||||
pass
|
||||
|
||||
|
||||
action_meta = {
|
||||
"description": "manages the onslaught event on dedicated locations",
|
||||
"main_function": main_function,
|
||||
"callback_success": callback_success,
|
||||
"callback_fail": callback_fail,
|
||||
"requires_telnet_connection": True,
|
||||
"enabled": True
|
||||
}
|
||||
|
||||
loaded_modules_dict["module_" + module_name].register_action(action_name, action_meta)
|
||||
42
bot/modules/locations/actions/teleport_to_coordinates.py
Normal file
42
bot/modules/locations/actions/teleport_to_coordinates.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from bot import loaded_modules_dict
|
||||
from os import path, pardir
|
||||
|
||||
module_name = path.basename(path.normpath(path.join(path.abspath(__file__), pardir, pardir)))
|
||||
action_name = path.basename(path.abspath(__file__))[:-3]
|
||||
|
||||
|
||||
def main_function(module, event_data, dispatchers_steamid):
|
||||
event_data[1]["action_identifier"] = action_name
|
||||
location_coordinates = event_data[1].get("location_coordinates", {})
|
||||
player_steamid = event_data[1].get("steamid", dispatchers_steamid)
|
||||
if location_coordinates:
|
||||
module.trigger_action_hook(
|
||||
module.players, event_data=["teleport_player", {
|
||||
"steamid": player_steamid,
|
||||
"coordinates": location_coordinates
|
||||
}])
|
||||
module.callback_success(callback_success, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
module.callback_fail(callback_fail, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
|
||||
def callback_success(module, event_data, dispatchers_steamid, match=None):
|
||||
pass
|
||||
|
||||
|
||||
def callback_fail(module, event_data, dispatchers_steamid):
|
||||
pass
|
||||
|
||||
|
||||
action_meta = {
|
||||
"description": "Teleports a player to a set of coordinates",
|
||||
"main_function": main_function,
|
||||
"callback_success": callback_success,
|
||||
"callback_fail": callback_fail,
|
||||
"requires_telnet_connection": False,
|
||||
"enabled": True
|
||||
}
|
||||
|
||||
loaded_modules_dict["module_" + module_name].register_action(action_name, action_meta)
|
||||
59
bot/modules/locations/actions/toggle_enabled_flag.py
Normal file
59
bot/modules/locations/actions/toggle_enabled_flag.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from bot import loaded_modules_dict
|
||||
from os import path, pardir
|
||||
|
||||
module_name = path.basename(path.normpath(path.join(path.abspath(__file__), pardir, pardir)))
|
||||
action_name = path.basename(path.abspath(__file__))[:-3]
|
||||
|
||||
|
||||
def main_function(module, event_data, dispatchers_steamid):
|
||||
event_data[1]["action_identifier"] = action_name
|
||||
action = event_data[1].get("action", None)
|
||||
location_origin = event_data[1].get("dom_element_origin", None)
|
||||
location_owner = event_data[1].get("dom_element_owner", None)
|
||||
location_identifier = event_data[1].get("dom_element_identifier", None)
|
||||
|
||||
if all([
|
||||
action is not None
|
||||
]):
|
||||
if action == "enable_location_entry" or action == "disable_location_entry":
|
||||
element_is_enabled = action == "enable_location_entry"
|
||||
|
||||
module.dom.data.upsert({
|
||||
"module_locations": {
|
||||
"elements": {
|
||||
location_origin: {
|
||||
location_owner: {
|
||||
location_identifier: {
|
||||
"is_enabled": element_is_enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, dispatchers_steamid=dispatchers_steamid, min_callback_level=4)
|
||||
|
||||
module.callback_success(callback_success, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
module.callback_fail(callback_fail, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
|
||||
def callback_success(module, event_data, dispatchers_steamid, match=None):
|
||||
pass
|
||||
|
||||
|
||||
def callback_fail(module, event_data, dispatchers_steamid):
|
||||
pass
|
||||
|
||||
|
||||
action_meta = {
|
||||
"description": "Sets or removes the enabled flag of a location",
|
||||
"main_function": main_function,
|
||||
"callback_success": callback_success,
|
||||
"callback_fail": callback_fail,
|
||||
"requires_telnet_connection": False,
|
||||
"enabled": True
|
||||
}
|
||||
|
||||
loaded_modules_dict["module_" + module_name].register_action(action_name, action_meta)
|
||||
@@ -0,0 +1,72 @@
|
||||
from bot import loaded_modules_dict
|
||||
from os import path, pardir
|
||||
|
||||
module_name = path.basename(path.normpath(path.join(path.abspath(__file__), pardir, pardir)))
|
||||
action_name = path.basename(path.abspath(__file__))[:-3]
|
||||
|
||||
|
||||
def main_function(module, event_data, dispatchers_steamid):
|
||||
event_data[1]["action_identifier"] = action_name
|
||||
action = event_data[1].get("action", None)
|
||||
location_owner = event_data[1].get("dom_element_owner", None)
|
||||
location_identifier = event_data[1].get("dom_element_identifier", None)
|
||||
location_origin = event_data[1].get("dom_element_origin", None)
|
||||
|
||||
# Support for prefilled coordinates from map
|
||||
prefill_x = event_data[1].get("prefill_x", None)
|
||||
prefill_y = event_data[1].get("prefill_y", None)
|
||||
prefill_z = event_data[1].get("prefill_z", None)
|
||||
|
||||
if action == "show_options":
|
||||
current_view = "options"
|
||||
elif action == "show_frontend":
|
||||
current_view = "frontend"
|
||||
elif action == "show_create_new":
|
||||
current_view = "create_new"
|
||||
elif action == "edit_location_entry":
|
||||
current_view = "edit_location_entry"
|
||||
elif action == "show_special_locations":
|
||||
current_view = "special_locations"
|
||||
elif action == "show_map":
|
||||
current_view = "map"
|
||||
else:
|
||||
module.callback_fail(callback_fail, module, event_data, dispatchers_steamid)
|
||||
return
|
||||
|
||||
view_data = {
|
||||
"current_view": current_view,
|
||||
"location_owner": location_owner,
|
||||
"location_identifier": location_identifier,
|
||||
"location_origin": location_origin
|
||||
}
|
||||
|
||||
# Add prefill data if creating new location
|
||||
if current_view == "create_new" and any([prefill_x, prefill_y, prefill_z]):
|
||||
view_data["prefill_coordinates"] = {
|
||||
"x": prefill_x,
|
||||
"y": prefill_y,
|
||||
"z": prefill_z
|
||||
}
|
||||
|
||||
module.set_current_view(dispatchers_steamid, view_data)
|
||||
module.callback_success(callback_success, module, event_data, dispatchers_steamid)
|
||||
|
||||
|
||||
def callback_success(module, event_data, dispatchers_steamid, match=None):
|
||||
pass
|
||||
|
||||
|
||||
def callback_fail(module, event_data, dispatchers_steamid):
|
||||
pass
|
||||
|
||||
|
||||
action_meta = {
|
||||
"description": "manages location stuff",
|
||||
"main_function": main_function,
|
||||
"callback_success": callback_success,
|
||||
"callback_fail": callback_fail,
|
||||
"requires_telnet_connection": False,
|
||||
"enabled": True
|
||||
}
|
||||
|
||||
loaded_modules_dict["module_" + module_name].register_action(action_name, action_meta)
|
||||
Reference in New Issue
Block a user