Post your map scripts here!!! (please )

Small patches, updates, and extensions of preexisting code.
3 posts Page 1 of 1 First unread post
JoJoe_Stinky
Mapper
Mapper
Posts: 173
Joined: Thu Oct 24, 2013 3:53 pm


Hi all,

I lost all my script snipplets, and had to find al of the information agin.

Thanks to Izzy, Lostmotel, and Kuma I have recovered most of it.

Feel free to post your script pieces here for other mappers to learn from.

This script lets you define a spawn volume
Code: Select all
AREA = (109, 157, 405, 353)
PAD = 23
WIDTH = 20
BLUE_RECT = (AREA[0] + PAD, AREA[1] + PAD, AREA[0] + PAD + WIDTH, AREA[3] - PAD)
GREEN_RECT = (AREA[2] - PAD - WIDTH, AREA[1] + PAD, AREA[2] - PAD, AREA[3] - PAD)
HALF_X = AREA[0] + (AREA[2] - AREA[0]) / 2
HALF_Y = AREA[1] + (AREA[3] - AREA[1]) / 2
GOAL = (8, 32, 40)
 
name = 'Heir Kraken'
version = '1.0'
author = 'jojoe'
area = AREA
ball = (HALF_X, HALF_Y, 40)

def get_spawn_location(connection):
    if connection.team is connection.protocol.blue_team:
        return connection.protocol.get_random_location(True, BLUE_RECT)
    elif connection.team is connection.protocol.green_team:
        return connection.protocol.get_random_location(True, GREEN_RECT)
 
from pyspades.constants import *
from pyspades.server import ServerConnection

def get_entity_location(team, entity_id):
    if entity_id == GREEN_FLAG:
        return (364, 385, 62)
    if entity_id == BLUE_FLAG:
        return (133, 385, 62)
    if entity_id == GREEN_BASE:
        return (372, 443, 60)
    if entity_id == BLUE_BASE:
        return (151, 443, 60)

Just define a the AREA=() for the rectange. The margin and padding can also be tweaked.

At the bottom you can dfefine the green and blue flags and bases. Ignore the BALL, it is for the football game mode.



This snipplet lets you pick an exact spawn point , 1 for green and one for blue:
Code: Select all
def get_spawn_location(connection):
    if connection.team is connection.protocol.blue_team:
       x, y, z = ServerConnection.get_spawn_location(connection)
       return ServerConnection.set_location_safe(connection, (375, 255, 60))
    if connection.team is connection.protocol.green_team:
       x, y, z = ServerConnection.get_spawn_location(connection)
       return ServerConnection.set_location_safe(connection, (108, 255, 60))
This does the same as above but only needs X and y, the Z is automatic.
Code: Select all
name = 'McKrak Island'
version = '1.0'
author = 'JoJoe Stinky CC 2013'
description = 'McKrak Island'

# script

from pyspades.constants import *
from pyspades.server import ServerConnection
from random import choice

def get_entity_location(team, entity_id):
    if entity_id == GREEN_FLAG:
        return (217, 243, 36)
    if entity_id == BLUE_FLAG:
        return (293, 242, 36)
    if entity_id == GREEN_BASE:
        return (198, 239, 34)
    if entity_id == BLUE_BASE:
        return (306, 240, 32)

spawn_locations_blue = [

(336, 229),
(329, 233),
(329, 242),
(341, 220),
(341, 276),
(341, 270),
(341, 241),
(341, 250),
(341, 260),
(366, 277),
(336, 252)

]

spawn_locations_green = [

(176, 250),
(176, 260),
(164, 250),
(164, 240),
(164, 260),
(157, 255),
(157, 240),
(157, 260),
(165, 255),
(165, 216),
(176, 240)

]

def get_spawn_location(connection):
    if connection.team is connection.protocol.blue_team:
        x, y = choice(spawn_locations_blue)
        z = connection.protocol.map.get_z(x, y)
        return x, y, z
    if connection.team is connection.protocol.green_team:
        x, y = choice(spawn_locations_green)
        z = connection.protocol.map.get_z(x, y)
        return x, y, z

Here is a "Pain" volume, It is like water damage:
Code: Select all
extensions = {
	#'water_damage' : 1,
	'boundary_damage' : {
		'left' : 64,
		'top' : 64,
		'right' : 448,
		'bottom' : 448,
		'damage' : 30
	}
}
Hopefully we can build a library of script tricks for mappers :)
learn_more
Coder
Coder
Posts: 891
Joined: Sun Mar 24, 2013 9:59 pm


you can remove the line with #water_damage
# infront means comment, so it is ignored ;)

i'll look into making a minefield map extension somewhat later this week. (hopefully included in the next pysnip release)

Code: Select all
name = 'MapName'
author = 'Author'
version = '1.0'
description = 'Awesome map!'
extensions = {
	# all extension stuff here.
}

def gen_script(basename, seed):
	#see random.txt or classicgen.txt
	return vxl

def on_map_change(self, map):
	#initialize stuff
	pass

def on_map_leave(self):
	#cleanup shit
	pass

def on_block_destroy(self, x, y, z, mode):
	# mode = DESTROY_BLOCK, SPADE_DESTROY, GRENADE_DESTROY
	pass

def is_indestructable(self, x, y, z):
	return False	#or True to be indestructable :)
JoJoe_Stinky
Mapper
Mapper
Posts: 173
Joined: Thu Oct 24, 2013 3:53 pm


Woo hoo, minefields! this is really neat.
Now the RTCW look I am working on can be complete :)

Thanks LearnMore!
3 posts Page 1 of 1 First unread post
Return to “Snippets”

Who is online

Users browsing this forum: No registered users and 2 guests