Пример #1
0
DMF = 16.0                # for world locations
DNF = 100.0               # for normalized vectors
DVELF = 1.0               # for playerspeed based velocity vectors

# weapon detail constants
MAXRAYS = 20
EXP_SELFDAMDIV = 2.0
EXP_SELFPUSH = 2.5
EXP_DISTSCALE = 1.5

# map file constants
MAXENTS = 10000

DEATHMILLIS = 300

base_entity_types = enum('ET_EMPTY', 'ET_LIGHT', 'ET_MAPMODEL', 'ET_PLAYERSTART', 'ET_ENVMAP', 'ET_PARTICLES', 'ET_SOUND', 'ET_SPOTLIGHT', 'ET_GAMESPECIFIC')

game_entity_types = enum(                     # static entity types
    'NOTUSED',                                  # entity slot not in use in map
    'LIGHT',                                    # lightsource, attr1 = radius, attr2 = intensity
    'MAPMODEL',                                 # attr1 = angle, attr2 = idx
    'PLAYERSTART',                              # attr1 = angle, attr2 = team
    'ENVMAP',                                   # attr1 = radius
    'PARTICLES',
    'MAPSOUND',
    'SPOTLIGHT',
    'I_SHELLS', 'I_BULLETS', 'I_ROCKETS', 'I_ROUNDS', 'I_GRENADES', 'I_CARTRIDGES',
    'I_HEALTH', 'I_BOOST',
    'I_GREENARMOUR', 'I_YELLOWARMOUR',
    'I_QUAD',
    'TELEPORT',                                 # attr1 = idx, attr2 = model, attr3 = tag
Пример #2
0
from twisted.internet import reactor

from cube2common.utils.enum import enum
from spyd.game.timing.callback import Callback, call_all
from spyd.game.timing.resume_countdown import ResumeCountdown
from spyd.game.timing.scheduled_callback_wrapper import ScheduledCallbackWrapper, resume_all, pause_all

states = enum('NOT_STARTED', 'RUNNING', 'PAUSED', 'RESUMING', 'INTERMISSION',
              'ENDED')


class GameClock(object):

    clock = reactor

    def __init__(self):
        self._state = states.NOT_STARTED

        self._last_resume_time = None
        self._time_elapsed = None

        self._intermission_duration_seconds = None

        self._intermission_start_scheduled_callback_wrapper = None
        self._intermission_end_scheduled_callback_wrapper = None
        self._resume_countdown = None

        self._timed = True

        self._paused_callbacks = []
        self._resumed_callbacks = []
Пример #3
0
import traceback

from twisted.internet import reactor

from cube2common.constants import weapon_types, armor_types, DMF, guns, EXP_SELFDAMDIV, EXP_DISTSCALE, DNF, client_states
from cube2common.utils.enum import enum
from cube2common.vec import vec
from spyd.game.gamemode.bases.mode_base import ModeBase
from spyd.game.server_message_formatter import info
from spyd.game.timing.expiry import Expiry
from spyd.protocol import swh
from spyd.registry_manager import register

# TODO: rivedere e riscrivere

tist_states = enum('UNINITIALIZED', 'WAITING_PLAYERS', 'WAITING_TRAITOR',
                   'PLAYING')


# @register('gamemode')
class Traitors(ModeBase):
    isbasemode = False
    clientmodename = 'traitors'
    clientmodenum = 3
    timed = False
    timeout = 0
    hasitems = False
    hasflags = False
    hasteams = False
    hasbases = False
    spawnarmour = 0
    spawnarmourtype = armor_types.A_BLUE
Пример #4
0
from twisted.internet import reactor

from cube2common.utils.enum import enum


states = enum('NOT_STARTED', 'RUNNING', 'ENDED')


class StateError(Exception): pass

class ResumeCountdown(object):

    clock = reactor

    def __init__(self, seconds, tick_callback, ended_callback):
        self._seconds = seconds
        self._tick_callback = tick_callback
        self._ended_callback = ended_callback
        self._delayed_calls = []
        self._state = states.NOT_STARTED

    def start(self):
        if self._state != states.NOT_STARTED:
            raise StateError()
        for seconds_left in xrange(1, int(self._seconds)):
            self._delayed_calls.append(self.clock.callLater(self._seconds - seconds_left, self._tick, seconds_left))
        self._delayed_calls.append(self.clock.callLater(self._seconds, self._ended))
        self._state = states.RUNNING

    def cancel(self):
        if self._state != states.RUNNING:
Пример #5
0
DNF = 100.0  # for normalized vectors
DVELF = 1.0  # for playerspeed based velocity vectors

# weapon detail constants
MAXRAYS = 20
EXP_SELFDAMDIV = 2.0
EXP_SELFPUSH = 2.5
EXP_DISTSCALE = 1.5

# map file constants
MAXENTS = 10000

DEATHMILLIS = 300

base_entity_types = enum('ET_EMPTY', 'ET_LIGHT', 'ET_MAPMODEL',
                         'ET_PLAYERSTART', 'ET_ENVMAP', 'ET_PARTICLES',
                         'ET_SOUND', 'ET_SPOTLIGHT', 'ET_GAMESPECIFIC')

game_entity_types = enum(  # static entity types
    'NOTUSED',  # entity slot not in use in map
    'LIGHT',  # lightsource, attr1 = radius, attr2 = intensity
    'MAPMODEL',  # attr1 = angle, attr2 = idx
    'PLAYERSTART',  # attr1 = angle, attr2 = team
    'ENVMAP',  # attr1 = radius
    'PARTICLES',
    'MAPSOUND',
    'SPOTLIGHT',
    'I_SHELLS',
    'I_BULLETS',
    'I_ROCKETS',
    'I_ROUNDS',
Пример #6
0
from twisted.internet import reactor # type: ignore

from cube2common.utils.enum import enum


states = enum('NOT_STARTED', 'RUNNING', 'ENDED')


class StateError(Exception): pass

class ResumeCountdown(object):

    clock = reactor

    def __init__(self, seconds, tick_callback, ended_callback):
        self._seconds = seconds
        self._tick_callback = tick_callback
        self._ended_callback = ended_callback
        self._delayed_calls = []
        self._state = states.NOT_STARTED

    def start(self):
        if self._state != states.NOT_STARTED:
            raise StateError()
        for seconds_left in range(1, int(self._seconds)):
            self._delayed_calls.append(self.clock.callLater(self._seconds - seconds_left, self._tick, seconds_left))
        self._delayed_calls.append(self.clock.callLater(self._seconds, self._ended))
        self._state = states.RUNNING

    def cancel(self):
        if self._state != states.RUNNING:
Пример #7
0
from cube2common.utils.enum import enum



authentication_states = enum('PENDING_CHALLENGE', 'PENDING_ANSWER', 'PENDING_RESPONSE')

possible_commands = ('failreg', 'succreg', 'addgban', 'cleargbans', 'chalauth', 'failauth', 'succauth')
Пример #8
0
from twisted.internet import reactor

from cube2common.constants import weapon_types, armor_types, DMF, guns, EXP_SELFDAMDIV, EXP_DISTSCALE, DNF, client_states
from cube2common.utils.enum import enum
from cube2common.vec import vec
from spyd.game.gamemode.bases.fighting_base import FightingBase
from spyd.game.gamemode.bases.mode_base import ModeBase
from spyd.game.gamemode.bases.spawning_base import SpawningBase
from spyd.game.gamemode.bases.spectating_base import SpectatingBase
from spyd.game.server_message_formatter import info
from spyd.game.timing.expiry import Expiry
from spyd.protocol import swh
from spyd.registry_manager import register


tist_states = enum('UNINITIALIZED', 'WAITING_PLAYERS', 'WAITING_TRAITOR', 'PLAYING')

@register('gamemode')
class Traitors(ModeBase, FightingBase, SpawningBase, SpectatingBase):
    isbasemode = False
    clientmodename = 'traitors'
    clientmodenum = 3
    timed = False
    timeout = 0
    hasitems = False
    hasflags = False
    hasteams = False
    hasbases = False
    spawnarmour = 0
    spawnarmourtype = armor_types.A_BLUE
    spawnhealth = 1