name = 'Tank_Plant'

version = '0.1'

author = 'Buttering'

description = 'MMI TANK PLANT'





#script

from pyspades.constants import *

from pyspades.server import ServerConnection

import random

def get_entity_location(team, entity_id):



    if entity_id == BLUE_FLAG:

        return (257, 270, 27)

    if entity_id == GREEN_FLAG:

        return (256, 173, 42)

    if entity_id == BLUE_BASE:

        return (170, 332, 52)

    if entity_id == GREEN_BASE:

        return (189, 183, 52)



spawn_locations_blue = [
                       (155, 326, 52), 
                       (160, 349, 52), 
                       (171, 345, 52), 
                       (146, 337, 50)
]
spawn_locations_green = [
                       (183, 193, 52), 
                       (182, 176, 52), 
                       (176, 188, 52), 
                       (172, 180, 52)
]

def get_spawn_location(connection):
    if connection.team is connection.protocol.blue_team:
        x, y, z = random.choice(spawn_locations_blue)
    elif connection.team is connection.protocol.green_team:
        x, y, z = random.choice(spawn_locations_green)
    z -= 2.4 # magic numbers
    x += 0.5
    y += 0.5
    if connection.protocol.map.get_z(x, y) <= z:
        # allows spawning lower if the ground is destroyed
        return x, y, z
    else:
        return x, y, connection.protocol.map.get_z(x, y)