Page 1 of 1

[Script request] Height limiter (for hallway)

Posted: Tue Jun 25, 2013 2:42 am
by GreaseMonkey
I thought this would be amusing to add to Iceball and PABH suggested that I make a request for a Pyspades script.

There are 3 ways to play hallway (not counting griefing and all that stupid crap):
1. Charge the middle.
2. Dig through the sides.
3. Climb to the roof, run to the enemy base, and spawncamp.

The purpose of this script is to stop people doing #3 so easily - that is, they actually have to dig a tunnel to spawncamp.

So here's my idea...

Make the top 2 layers (0 and 1) impenetrable and fully solid. The lower one should contain something that looks like a sky. The upper one should have the colour of the highest block that isn't on these two layers.

You will have to modify the spawning "get Z coordinate" code to ignore the top 2 layers when it calculates its blocks.

For bonus points, you could clamp the Z (vertical) coordinate of the player to always be >= 2 + head_bbox_top_offset.

Sound good?

Re: [Script request] Height limiter (for hallway)

Posted: Tue Jun 25, 2013 3:20 pm
by thepolm3
Here you go; Fresh out of the tin
Code: Select all
"""
thepolm3
how high can you go? designed to reduce the need for boundaries
Idea by Greasemonkey
"""

LIMIT=2 #highest players can go

def apply_script(protocol, connection, config):
    
    class LimitConnection(connection):
        last_safe_pos=(0,0,0)

        def on_spawn_location(self,pos):
            if pos<=LIMIT:
                for z in range(LIMIT,62):
                    if is_location_free(pos[0],pos[1],z):
                        return (pos[0],pos[1],z)
            return connection.on_spawn_location(self,pos)
                
        def on_position_update(self):
            pos=self.get_location()
            if pos[2]<=LIMIT:
                self.set_location(self.last_safe_pos)
            else:
                self.last_safe_pos=int(pos[0]),int(pos[1])+0.5,pos[2]-0.5
            return connection.on_position_update(self)

        def on_orientation_update(self,x,y,z):
            if self.get_location()[2]<=LIMIT: self.set_location(self.last_safe_pos)
            return connection.on_orientation_update(self,x,y,z)
    return protocol, LimitConnection

Re: [Script request] Height limiter (for hallway)

Posted: Tue Jun 25, 2013 6:18 pm
by Venator
thepolm3 deservers a golden Scripter badge.