예제 #1
0
def getViewCoords(userid, mask=0xFFFFFFFF, collisiongroup=0):
    player = playerlib.getPlayer(userid)
    startvec = player.getEyeLocation()

    # Create start and end vector pointers
    pStart = createVector(*startvec)
    pEnd   = createVector(*list(Vector(startvec) + Vector(player.viewvector) \
        * MAX_COORD_RANGE))

    # Allocate space for the CGameTrace object
    ptr = spe.alloc(SIZE_TRACE_T)

    # Call UTIL_TraceLine()
    spe.call('TraceLine', pStart, pEnd, mask, spe.getPlayer(int(userid)),
             collisiongroup, ptr)

    # Wrap the end vector...
    x = spe.makeObject('Vector', ptr + 12)

    # ... and save the result
    result = x.x, x.y, x.z

    # Deallocate reserved space
    spe.dealloc(pStart)
    spe.dealloc(pEnd)
    spe.dealloc(ptr)

    # Finally, return the result
    return result
예제 #2
0
def createVector(x, y, z):
    obj = spe.makeObject('Vector', spe.alloc(SIZE_VECTOR))
    obj.x = x
    obj.y = y
    obj.z = z

    return obj.base
예제 #3
0
def createVector(x, y, z):
    obj = spe.makeObject('Vector', spe.alloc(SIZE_VECTOR))
    obj.x = x
    obj.y = y
    obj.z = z

    return obj.base
예제 #4
0
def getViewCoords(userid, mask=0xFFFFFFFF, collisiongroup=0):
    player   = playerlib.getPlayer(userid)
    startvec = player.getEyeLocation()

    # Create start and end vector pointers
    pStart = createVector(*startvec)
    pEnd   = createVector(*list(Vector(startvec) + Vector(player.viewvector) \
        * MAX_COORD_RANGE))

    # Allocate space for the CGameTrace object
    ptr = spe.alloc(SIZE_TRACE_T)

    # Call UTIL_TraceLine()
    spe.call('TraceLine', pStart, pEnd, mask, spe.getPlayer(int(userid)),
        collisiongroup, ptr)

    # Wrap the end vector...
    x = spe.makeObject('Vector', ptr + 12)

    # ... and save the result
    result = x.x, x.y, x.z

    # Deallocate reserved space
    spe.dealloc(pStart)
    spe.dealloc(pEnd)
    spe.dealloc(ptr)

    # Finally, return the result
    return result
예제 #5
0
    def __new__(cls, x=0, y=0, z=0):
        '''
        Creates a pointer and sets the coordinates.
        '''

        pointer = spe.alloc(12)
        spe.setLocVal('f', pointer,     float(x))
        spe.setLocVal('f', pointer + 4, float(y))
        spe.setLocVal('f', pointer + 8, float(z))
        return super(cls, cls).__new__(cls, pointer)
예제 #6
0
    def __new__(cls, users):
        '''
        Adds all given users to the new created pointer.
        '''

        pointer = spe.alloc(40)
        spe.call('RecipientFilterConst', pointer)
        for userid in getUsers(users):
            player = spe.getPlayer(userid)
            spe.call('AddRecipient', pointer, player)

        return super(cls, cls).__new__(cls, pointer)