Skip to content

Commit

Permalink
Add Attack Heli Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
olijeffers0n committed Jan 31, 2022
1 parent 2e7e504 commit 0799b53
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 83 deletions.
2 changes: 1 addition & 1 deletion rustplus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

__name__ = "rustplus"
__author__ = "olijefferson"
__version__ = "5.2.2"
__version__ = "5.2.3"
__support__ = "Discord: https://discord.gg/nQqJe8qvP8"
Binary file added rustplus/api/icons/patrol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion rustplus/api/rust_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ async def get_map(self, add_icons: bool = False, add_events: bool = False, add_v

for marker in mapMarkers:
if add_events:
if marker.type == 2 or marker.type == 4 or marker.type == 5 or marker.type == 6:
if marker.type == 2 or marker.type == 4 or marker.type == 5 or marker.type == 6 or marker.type == 8:
icon = convert_marker(str(marker.type), marker.rotation)
print(marker.type)
if marker.type == 8:
icon.show()
if marker.type == 6:
x = marker.x
y = marker.y
Expand Down
166 changes: 85 additions & 81 deletions rustplus/utils/rust_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

from ..api.structures import RustTime

def format_time(protobuf) -> RustTime:

def format_time(protobuf) -> RustTime:
def convert_time(time) -> str:

HOURS, MINUTES = divmod(time * 60, 60)

return f"{int(HOURS)}:0{int(MINUTES)}" if MINUTES <= 9 else f"{int(HOURS)}:{int(MINUTES)}"
Expand All @@ -19,8 +18,8 @@ def convert_time(time) -> str:

return RustTime(protobuf.response.time.dayLengthMinutes, SUNRISE, SUNSET, PARSED_TIME, protobuf.response.time.time)

def format_cood(x, y, map_size) -> tuple:

def format_cood(x, y, map_size) -> tuple:
y = map_size - y - 75
x -= 75

Expand All @@ -31,70 +30,75 @@ def format_cood(x, y, map_size) -> tuple:
if y < 0:
y = 0
if y > map_size:
y = map_size-150
y = map_size - 150

return x, y

def convert_marker(name, angle) -> Image:

nameToFile = {
"2" : "explosion.png",
"4" : "chinook.png",
"5" : "cargo.png",
"6" : "crate.png",
def convert_marker(name, angle) -> Image:
name_to_file = {
"2": "explosion.png",
"4": "chinook.png",
"5": "cargo.png",
"6": "crate.png",
"8": "patrol.png",
}
with resources.path("rustplus.api.icons", nameToFile[name]) as path:

with resources.path("rustplus.api.icons", name_to_file[name]) as path:
icon = Image.open(path).convert("RGBA")
if name == "6":
icon = icon.resize((85,85))
icon = icon.resize((85, 85))
elif name == "2":
icon = icon.resize((96,96))
icon = icon.resize((96, 96))
elif name == "4":
with resources.path("rustplus.api.icons", "chinook_blades.png") as path:
blades = Image.open(path).convert("RGBA")
blades = blades.resize((100,100))
blades = blades.resize((100, 100))
icon.paste(blades, (64 - 50, 96 - 50), blades)
icon.paste(blades, (64 - 50, 32 - 50), blades)
elif name == "8":
icon = icon.resize((200, 200))
with resources.path("rustplus.api.icons", "chinook_blades.png") as path:
blades = Image.open(path).convert("RGBA")
blades = blades.resize((200, 200))
icon.paste(blades, (0, 0), blades)
icon = icon.rotate(angle)
return icon

def convert_monument(name : str, override_images : dict) -> Image:

def convert_monument(name: str, override_images: dict) -> Image:
name_to_file = {
"train_tunnel_display_name" : "train.png",
"supermarket" : "supermarket.png",
"mining_outpost_display_name" : "mining_outpost.png",
"gas_station" : "oxums.png",
"fishing_village_display_name" : "fishing.png",
"large_fishing_village_display_name" : "fishing.png",
"lighthouse_display_name" : "lighthouse.png",
"excavator" : "excavator.png",
"water_treatment_plant_display_name" : "water_treatment.png",
"train_yard_display_name" : "train_yard.png",
"outpost" : "outpost.png",
"bandit_camp" : "bandit.png",
"junkyard_display_name" : "junkyard.png",
"dome_monument_name" : "dome.png",
"satellite_dish_display_name" : "satellite.png",
"power_plant_display_name" : "power_plant.png",
"military_tunnels_display_name" : "military_tunnels.png",
"airfield_display_name" : "airfield.png",
"launchsite" : "launchsite.png",
"sewer_display_name" : "sewer.png",
"oil_rig_small" : "small_oil_rig.png",
"large_oil_rig" : "large_oil_rig.png",
"underwater_lab" : "underwater_lab.png",
"AbandonedMilitaryBase" : "desert_base.png"
"train_tunnel_display_name": "train.png",
"supermarket": "supermarket.png",
"mining_outpost_display_name": "mining_outpost.png",
"gas_station": "oxums.png",
"fishing_village_display_name": "fishing.png",
"large_fishing_village_display_name": "fishing.png",
"lighthouse_display_name": "lighthouse.png",
"excavator": "excavator.png",
"water_treatment_plant_display_name": "water_treatment.png",
"train_yard_display_name": "train_yard.png",
"outpost": "outpost.png",
"bandit_camp": "bandit.png",
"junkyard_display_name": "junkyard.png",
"dome_monument_name": "dome.png",
"satellite_dish_display_name": "satellite.png",
"power_plant_display_name": "power_plant.png",
"military_tunnels_display_name": "military_tunnels.png",
"airfield_display_name": "airfield.png",
"launchsite": "launchsite.png",
"sewer_display_name": "sewer.png",
"oil_rig_small": "small_oil_rig.png",
"large_oil_rig": "large_oil_rig.png",
"underwater_lab": "underwater_lab.png",
"AbandonedMilitaryBase": "desert_base.png"
}

overrideImages = override_images

try:
return overrideImages[name]
return override_images[name]
except KeyError:
pass

if name in name_to_file:
file_name = name_to_file[name]
with resources.path("rustplus.api.icons", file_name) as path:
Expand All @@ -116,45 +120,46 @@ def convert_monument(name : str, override_images : dict) -> Image:
icon = Image.open(path).convert("RGBA")
return icon

def translate_id_to_stack(id : int) -> str:

def translate_id_to_stack(id: int) -> str:
return {
"-1018587433" : "Animal Fat",
"609049394" : "Battery - Small",
"1719978075" : "Bone Fragments",
"634478325" : "CCTV Camera",
"-1938052175" : "Charcoal",
"-858312878" : "Cloth",
"204391461" : "Coal :(",
"-321733511" : "Crude Oil",
"1568388703" : "Diesel Fuel",
"1655979682" : "Empty Can of Beans",
"-1557377697" : "Empty Tuna Can",
"-592016202" : "Explosives",
"-930193596" : "Fertilizer",
"-265876753" : "Gun Powder",
"317398316" : "High Quality Metal",
"-1982036270" : "High Quality Metal Ore",
"-1579932985" : "Horse Dung",
"996293980" : "Human Skull",
"1381010055" : "Leather",
"-946369541" : "Low Grade Fuel",
"69511070" : "Metal Fragments",
"-4031221" : "Metal Ore",
"-1779183908" : "Paper",
"-804769727" : "Plant Fibre",
"-544317637" : "Research Paper",
"-277057363" : "Salt Water",
"-932201673" : "Scrap",
"-2099697608" : "Stones",
"-1581843485" : "Sulfur",
"-1157596551" : "Sulfur Ore",
"1523195708" : "Targeting Computer",
"-1779180711" : "Water",
"2048317869" : "Wolf Skull",
"-151838493" : "Wood"
"-1018587433": "Animal Fat",
"609049394": "Battery - Small",
"1719978075": "Bone Fragments",
"634478325": "CCTV Camera",
"-1938052175": "Charcoal",
"-858312878": "Cloth",
"204391461": "Coal :(",
"-321733511": "Crude Oil",
"1568388703": "Diesel Fuel",
"1655979682": "Empty Can of Beans",
"-1557377697": "Empty Tuna Can",
"-592016202": "Explosives",
"-930193596": "Fertilizer",
"-265876753": "Gun Powder",
"317398316": "High Quality Metal",
"-1982036270": "High Quality Metal Ore",
"-1579932985": "Horse Dung",
"996293980": "Human Skull",
"1381010055": "Leather",
"-946369541": "Low Grade Fuel",
"69511070": "Metal Fragments",
"-4031221": "Metal Ore",
"-1779183908": "Paper",
"-804769727": "Plant Fibre",
"-544317637": "Research Paper",
"-277057363": "Salt Water",
"-932201673": "Scrap",
"-2099697608": "Stones",
"-1581843485": "Sulfur",
"-1157596551": "Sulfur Ore",
"1523195708": "Targeting Computer",
"-1779180711": "Water",
"2048317869": "Wolf Skull",
"-151838493": "Wood"
}[str(id)]


def entity_type_to_string(id) -> str:
if id == 1:
return "Switch"
Expand All @@ -165,14 +170,13 @@ def entity_type_to_string(id) -> str:
else:
raise ValueError("Not Valid type")

def convert_xy_to_grid(coords : tuple, map_size : float, catch_out_of_bounds : bool = True) -> tuple:

def convert_xy_to_grid(coords: tuple, map_size: float, catch_out_of_bounds: bool = True) -> tuple:
GRIDSIZE = 146.25
grids = list(string.ascii_uppercase) + [f"A{letter}" for letter in list(string.ascii_uppercase)]

if coords[0] > map_size or coords[0] < 0 or coords[1] > map_size or coords[1] < 0:
if catch_out_of_bounds:
raise ValueError("Out of bounds")


return grids[int(coords[0] // GRIDSIZE)], int((map_size - coords[1]) // GRIDSIZE)

0 comments on commit 0799b53

Please sign in to comment.