Example #1
0
def updateLoop(data = ''):
    global lastRecordedTime

    #D.debugUDP('U_TIME: %s' % (D.time_now()))
    delta = host.timer_getWallTime() - lastRecordedTime
    lastRecordedTime = host.timer_getWallTime()
    if G_TRACKEDVEHICLE != None:
        position = G_TRACKEDVEHICLE.getPosition()
        rotation = G_TRACKEDVEHICLE.getRotation()
        D.debug('POSROT: P%sP|R%sR|T(%s)T|D(%s)D' % (position, rotation, host.timer_getWallTime(), delta), ['udp', 'echo'])
Example #2
0
 def run(self):
     for attribute in self.settings.keys():
         values = self.settings[attribute]
         values = '/'.join(values)
         host.rcon_invoke("""
             ObjectTemplate.active %s
             ObjectTemplate.%s %s
             """ % (self.template, attribute, values))
         #D.debug('InvokeCommand:: host.rcon_invoke()')
         D.debug('ObjectTemplate.active %s' % (self.template))
         D.debug('ObjectTemplate.%s %s' % (attribute, values))
Example #3
0
def onGameStatusChanged(status):
    global G_isReady

    if status == bf2.GameStatus.Playing:
        host.registerHandler('ChatMessage', onChatMessage, 1) #registering chatMessage handler
        D.init()
        
        # test stuff
        #timer = bf2.Timer(setTestVehicle, 10, 1, 'ch_jet_su30')

        # test stuff2
        host.registerHandler('EnterVehicle', onEnterVehicle)
        host.registerHandler('ExitVehicle', onExitVehicle)
        
        setupDefaults()
        G_isReady = True
        #resetUpdateTimer()
        D.debug('===== FINISHED OBJMOD INIT =====')
Example #4
0
def selectQuery(index = '0'):
    global G_SELECTED_QUERY

    if index == '0': # because parsing str(chat)
        for query in G_QUERIES.keys():
            D.debug('selectQuery(): %s' % (G_QUERIES[query].template))
            for setting in G_QUERIES[query].settings.keys():
                D.debug('selectQuery(): %s %s' % (setting, G_QUERIES[query].settings[setting]))
        D.debug('selectQuery(): finished displaying %s queries' % (len(G_QUERIES)))
    else:
        G_SELECTED_QUERY = G_QUERIES[int(index)]
        D.debug('selectQuery(): selected query #%s' % (index))
Example #5
0
    def updateCommand(self, args):
        cmd_type = None

        #D.debug('InvokeCommand:: updateCommand(): args = %s' % (args))

        try:
            key = args[0]
            values = args[1:4]
            cmd_type = {
                1 : 1,
                3 : 3
                }[len(values)]
            cmd = C.templateProperties[cmd_type][key]
        except:
            D.debug('InvokeCommand::updateCommand(): failed to get settings!')
            D.debug('InvokeCommand::updateCommand(): key = %s' % (key))
            D.debug('InvokeCommand::updateCommand(): values = %s' % (values))
            D.debug('InvokeCommand::updateCommand(): cmd_type = %s' % (cmd_type))
            D.debug('InvokeCommand::updateCommand(): cmd = %s' % (cmd))

        try:
            self.settings[cmd] = values
        except:
            D.debug('failed to set settings!')
Example #6
0
def commandHandler(player, args):
    """
        commandHandler
            handling functions calls for ingame debug
    """
    
    if args[0].isdigit():
        selectQuery(args[0])
        return
    
    if args[0] in C.templateProperties[1].keys() or args[0] in C.templateProperties[3].keys():
        updateQuery(args)
        return
    
    if args[0] == 'run':
        runQuery()
        return
    
    if args[0] == 'round':
        return D.debug('Current round: %s' % (realitycore.currentRound()))
    
    if args[0] == 'reload':
        reload(C)
        return setupDefaults()
    
    if args[0] == 'upload':
        resetUpdateTimer()
        return

    if args[0] == 'sge1':
        templateName = 'ch_officer'
        templateAlias = templateName + '_127' # should be random
        team = 1
        teamOnVehicle = 1
        position = realitycore.getPositionFromPlayer(player, 4)
        rotation = player.getDefaultVehicle().getRotation()
        D.debug('kit position %s' % (str(position)))
        D.debug('kit rotation %s' % (str(rotation)))

        host.rcon_invoke("""
ObjectTemplate.create ObjectSpawner %s
ObjectTemplate.activeSafe ObjectSpawner %s
ObjectTemplate.isNotSaveable 1
ObjectTemplate.hasMobilePhysics 0
ObjectTemplate.setObjectTemplate %s %s
ObjectTemplate.TimeToLive 12000
ObjectTemplate.Distance 100
ObjectTemplate.team %s
ObjectTemplate.teamOnVehicle %s
Object.create %s
Object.absolutePosition %s/%s/%s
Object.rotation %s/%s%s
Object.setControlPointId 101
Object.team %s
Object.delete
""" % (templateAlias,\
        templateAlias,\
        team, templateName,\
        team,\
        teamOnVehicle,\
        templateAlias,\
        position[0], position[1], position[2],\
        rotation[0], rotation[1], rotation[2],\
        team))
        return
        
    createQuery(args)
Example #7
0
def setTestVehicle(template, data = ''):
    global G_TRACKEDVEHICLE

    objects = bf2.objectManager.getObjectsOfTemplate(template)
    G_TRACKEDVEHICLE = objects[0]
    D.debug('Selected object of template %s at %s' % (G_TRACKEDVEHICLE.templateName, str(G_TRACKEDVEHICLE.getPosition())))
Example #8
0
def onExitVehicle(player, vehicle):
    global G_TRACKEDVEHICLE

    G_TRACKEDVEHICLE = None
    D.debug('Player left %s' % (vehicle.templateName))
    resetUpdateTimer()
Example #9
0
def onEnterVehicle(player, vehicle, freeSoldier = False):
    global G_TRACKEDVEHICLE

    G_TRACKEDVEHICLE = vehicle
    D.debug('Player entered %s' % (G_TRACKEDVEHICLE.templateName))
    resetUpdateTimer()