Port script to BGE 2.5 (BPY api 3)

Hi everyone!
Having seen how helpful the community of BlenderArtists are, i was wondering if there was anyone out there who could help port these scripts (movement, and ray shooter with bullet spawner) to the new blender 2.53 GE?!
I am having no luck:( Looking in Blender 2.49b console window still to no avail.
Bullet script:


import random
import math




# Get controllers
controller = GameLogic.getCurrentController()

# get the spawner's reference name
spawner = controller.owner
target_colider = controller.sensors["Target Colider"].owner

# Get sensors
ray = controller.sensors["ray"]
running = controller.sensors["run"].positive
fired = controller.sensors["fire"].positive
reload = controller.sensors["reload"].positive
scope = controller.sensors["scope"].positive


# Get actuators
recoil = controller.actuators["play_recoil"]
scope_in = controller.actuators["scope_in"]
#define variables
isFiring = False
ammo = getattr(controller.owner, "ammo")
clips = getattr(controller.owner, "clips")
scopeval = False
canfire = True
#define event
if scope:
    if not running:
        scopeval = not scopeval
        canfire = not canfire
GameLogic.addActiveActuator(scope_in, scopeval)
                    
        
if reload:
        if clips > 0:
            if ammo < 1:
                setattr(controller.owner, "clips", clips - 1)
                setattr(controller.owner, "ammo", 200)
                


if fired:
    if not running:
        if canfire == True:
            if ammo > 0:
                GameLogic.addActiveActuator(recoil, 1)
                setattr(controller.owner, "ammo", ammo -1)
    
            
                if ray.positive:
        
        
                #   Position & orient the "target collider"   #
                ###############################################
        
                #target_colider.worldPosition = ray.hitPosition
        
                #target_colider.worldOrientation = spawner.worldOrientation
        
        
        
                #   Make the hit object to loose health   #
                ###########################################
        
                    object_hit = ray.hitObject
        
        
                    try:
                        new_health = object_hit['Health'] - 9
                    except:
                        pass
                    else:
                        if new_health > 0:
                            object_hit['Health'] = new_health
                        else:
                            object_hit.endObject()
                
        
        
                #   Affect the object's velocity & torque   #
                #############################################
        
        
                # Set the bullet's force applied in one frame (In newtons)
                bullet_force = 200
        
        
        
                try:
                    velocity_obey_prop = object_hit['Velocity_Obey']
                except:
                    pass
                else:
                    if velocity_obey_prop > 0:
                
                
                        force_x = -spawner.worldOrientation[1][0] * (1-abs(spawner.worldOrientation[2][1])) * bullet_force * velocity_obey_prop
                        force_y = spawner.worldOrientation[0][0] * (1-abs(spawner.worldOrientation[2][1])) * bullet_force * velocity_obey_prop
                        force_z = spawner.worldOrientation[2][1] * bullet_force * velocity_obey_prop
                
                        force = (force_x,force_y,force_z)
                        object_hit.applyForce(force, 0)
                
            
        
        
                try:
                    torc_obey_prop = object_hit['Torc_Obey']
                except:
                    pass
                else:
                    if torc_obey_prop > 0:
                
                
                        force_x = -spawner.worldOrientation[1][0] * (1-abs(spawner.worldOrientation[2][1])) * bullet_force * velocity_obey_prop
                        force_y = spawner.worldOrientation[0][0] * (1-abs(spawner.worldOrientation[2][1])) * bullet_force * velocity_obey_prop
                        force_z = spawner.worldOrientation[2][1] * bullet_force * velocity_obey_prop
                
                        dx = ray.hitPosition[0] - object_hit.worldPosition[0]
                        dy = ray.hitPosition[1] - object_hit.worldPosition[1]
                        dz = ray.hitPosition[2] - object_hit.worldPosition[2]
                
                        tx = -(force_y * dz) + (force_z * dy)
                        ty = (force_x * dz) - (force_z * dx)
                        tz = -(force_x * dy) + (force_y * dx)
                
                        torque = (tx,ty,tz)
                
                        object_hit.applyTorque(torque, 0)
        
        
        
        


3 scripts to 2.53

MOVEMENT PT (1)

######################################################
#
#   Movement.py        Blender 2.49
#
#   Tutorial for using Movement.py can be found at
#
#    www.tutorialsforblender3d.com
#
#   Released under the Creative Commons Attribution 3.0 Unported License.    
#
#   If you use this code, please include this information header.
#
######################################################

def main():
     
    # get current controller
    controller = GameLogic.getCurrentController()
    
    # get object script attached to
    obj = controller.owner
    
    # get servo control named move
    servo = controller.actuators["move"]    
    
    # check for user added properties
    check_Prop(obj, servo)
    
    # extract linear velocity from servo
    lin_Speed = servo.linV
        
    ###############
            
    # moving forward/back
    lin_Speed = forward_back(obj, controller, lin_Speed)
    
    # moving left/right
    lin_Speed = left_right(obj, controller, lin_Speed)
    
    # running
    lin_Speed = run(obj, controller, lin_Speed) 
    
    # jumping
    lin_Speed = jump(obj, controller, lin_Speed)
    
    # diagonal movement 
    lin_Speed = move_Diagonal(obj, controller, lin_Speed)
        
    # ground
    touch_ground = ground(controller)
    
    # servo settings
    lin_Speed = servo_settings(obj, servo, touch_ground, lin_Speed)
        
    ###############

    # use servo control
    move(obj, controller, servo, lin_Speed)
    
    # stop without sliding
    stop(obj, controller, servo, touch_ground, lin_Speed)
    
    
#######################################################################

def check_Prop(obj, servo):
            
    # check for walk speed
    if obj.has_key("walking") == False:            
        
        # Not set? Use default walk speed
        obj["walking"] = 10.0                        

    # check for user set run speed
    if obj.has_key("running") == False:            
        
        # Not set? Use default run speed
        obj["running"] = 1.5 * obj["walking"]        

    # check user set jump amount
    if obj.has_key("jumping") == False:
        
        # Not set?  Use default jump force
        obj["jumping"] = 10.0
        
    # Check for jump once    
    if obj.has_key("jump_once") == False:
        
        # Not set?  Use default 
        obj["jump_once"] = 1
    
    # check for servo status        
    if obj.has_key("servo_status") == False:
        
        # not set?  use default
        obj["servo_status"] = "Off"
    
    # check for touch ground
    if obj.has_key("touch_ground") == False:
        
        # not set?  Use default
        obj["touch_ground"] = 0
    
#######################################################################

def forward_back(obj, controller, lin_Speed):
            
    # get sensors named forward and back
    forward = controller.sensors["forward"]
    back = controller.sensors["back"]
    
    # extract linX, linY and linZ from linV 
    linX, linY, linZ = lin_Speed        
                
    ######### ground -- forward/back 
                
    # forward key        
    if forward.positive == True and back.positive == False:    
        
        # forward linear velocity
        linY = obj["walking"]
                        
    # back key        
    elif back.positive == True and forward.positive == False:
        
        # back linear velocity
        linY = -obj["walking"]
    
    # no key
    elif back.positive == False and forward.positive == False:
        
        # no linear velocity
        linY = 0.0
    
    # both keys
    elif back.positive == True and forward.positive == True:
        
        # no linear velocity
        linY = 0.0


    ############ save linear velocity
    lin_Speed = [linX, linY, linZ]
    
    return lin_Speed


#######################################################################

def left_right(obj, controller, lin_Speed):

    # get sensors named left and right
    left = controller.sensors["left"]
    right = controller.sensors["right"]
    
    # extract linX, linY and linZ from linV 
    linX, linY, linZ = lin_Speed
            
    
    ###########  ground -- left/right

    # slide left key
    if left.positive == True and right.positive == False:
        
        # move left linear velocity
        linX = -obj["walking"]
                
    # slide right key
    elif right.positive == True and left.positive == False:
        
        # move right linear velocity
        linX = obj["walking"]
    
    # no key    
    elif left.positive == False and right.positive == False:
        
        # no linear velocity
        linX = 0.0
        
    # both keys    
    elif left.positive == True and right.positive == True:
        
        # no linear velocity
        linX = 0.0
                
    ############ save linear velocity
    lin_Speed = [linX, linY, linZ]
    
    return lin_Speed


########################################################################

def run(obj, controller, lin_Speed):

    # # extract x, y and z from linear speed
    linX, linY, linZ = lin_Speed
    
    # get keyboard sensor named run
    runSen = controller.sensors["run"]

    # running
    if runSen.positive == True:
        
        # forward/back
        linX_Run = obj["running"] * ( linX / obj["walking"] )
        
        # left/right
        linY_Run = obj["running"] * ( linY / obj["walking"] )
        
        # set running speed
        linX = linX_Run
        linY = linY_Run
        
    ############ save linear velocity
    lin_Speed = [linX, linY, linZ]
    
    return lin_Speed
        
########################################################################


movement pt (2)


def jump(obj, controller, lin_Speed):
    
    # get keyboard sensor named jump
    jump = controller.sensors["jump"]
    
    # extract x, y and z from linear speed
    linX, linY, linZ = lin_Speed
    
    ############# ground -- jumping
    
    # jump key pressed
    if jump.positive == True:
        
        # one key press = one jump
        if obj["jump_once"] == 1:
                    
            # only one jump
            obj["jump_once"] = 0
            
            # set jump force
            linZ = obj["jumping"]
            
    # jump key released
    elif jump.positive == False:
        
        # reset jump once to true
        obj["jump_once"] = 1
        
        # no jump force
        linZ = 0.0
            
    ############ save linear velocity
    lin_Speed = [linX, linY, linZ]
    
    return lin_Speed

    
#######################################################################

def move_Diagonal(obj, controller, lin_Speed):
            
    # # extract x, y and z from linear speed
    linX, linY, linZ = lin_Speed

    ###########  ground -- diagonal
    
    # diagonal movement
    if linX != 0.0 and linY != 0.0:
        
        # diagonal linear speed.
        linX = 0.707 * linX
        linY = 0.707 * linY
                
    ############ save linear velocity
    lin_Speed = [linX, linY, linZ]
    
    return lin_Speed
                    

########################################################################

def ground(controller):
    
    # get ground collision sensor named ground
    ground = controller.sensors["ground"]
        
    # Touching the ground?    
    if ground.positive == True:
        
        # 1 = True
        touch_ground = 1
    
    elif ground.positive == False:
        
        # 0 = False
        touch_ground = 0
    
    
    return touch_ground
    

########################################################################

def servo_settings(obj, servo, touch_ground, lin_Speed):    
        
    # # extract x, y and z from linear speed
    linX, linY, linZ = lin_Speed

    ###############
    
    # touching the ground 
    if touch_ground == 1:
                    
        # stop
        if linX == 0.0 and linY == 0.0 and linZ == 0.0:
    
            # set to stop without sliding
            servo.forceLimitX = [0.0, 0.0, False]        
            servo.forceLimitY = [0.0, 0.0, False]
            servo.forceLimitZ = [0.0, 0.0, False]
            
        # moving    
        elif (linX != 0.0 or linY != 0.0) and linZ == 0.0:
        
            # set force limits
            servo.forceLimitX = [-1000.0, 1000.0, True]    ####  for left/right movement    
            servo.forceLimitY = [-1000.0, 1000.0, True]    ####  for forward/back movement
            servo.forceLimitZ = [0.0, 0.0, True]        ####  for gravity        
        
        # jump
        elif linZ != 0.0:
            
            # force limits                
            servo.forceLimitX = [0.0, 0.0, True]            ####  sideways momentum        
            servo.forceLimitY = [0.0, 0.0, True]            ####  forward/back momentum
            servo.forceLimitZ = [-1000.0, 10000.0, True]       ####  jump force        
    
            
    ########## not touching the ground
    
    elif touch_ground == 0:
            
        # no force applied        
        linX = 0.0
        linY = 0.0
        linZ = 0.0
                        
        # in air -- no limits
        servo.forceLimitX = [0.0, 0.0, True]    ####  sideways momentum        
        servo.forceLimitY = [0.0, 0.0, True]    ####  forward/back momentum
        servo.forceLimitZ = [0.0, 0.0, True]    ####  gravity and jump momentum
                    
    ############ save linear velocity
    lin_Speed = [linX, linY, linZ]
    
    return lin_Speed

#####################################################################    
    
def move(obj, controller, servo, lin_Speed):
        
    # extract x, y and z from linear speed
    linX, linY, linZ = lin_Speed
    
    # only need to turn servo control on if it isn't turned off
    if (linX != 0.0 or linY != 0.0 or linZ != 0.0) and obj["servo_status"] != "On":
    
        # turn servo control on
        controller.activate(servo)
        
        # save servo status as on
        obj["servo_status"] = "On"                            
    
    # make it move 
    servo.linV = lin_Speed    
    
#####################################################################    

def stop(obj, controller, servo, touch_ground, lin_Speed):
    
    # extract x, y and z from linear speed
    linX, linY, linZ = lin_Speed
    
    # no force being applied    
    if linX == 0.0 and linY == 0.0 and linZ == 0.0:        

        # get delay sensor named stop
        stop_Delay = obj.sensors["stop"]
        
        # Stop if touching ground
        if touch_ground == 1 and obj["servo_status"] == "On": 
                                                    
            # start Delay sensor
            stop_Delay.reset()
            
            # save servo status as off        
            obj["servo_status"] = "Off"
                
        elif obj["servo_status"] == "Off":
                                                    
            # Delay sensor is done
            if stop_Delay.positive == False:
                
                # turn servo control off
                controller.deactivate(servo)                            
                
###################################################################    
# run main program
main()
cont = GameLogic.getCurrentController()
#define sensors
run = cont.sensors["run"].isPositive()
movew = cont.sensors["forward"].isPositive()
moves = cont.sensors["back"].isPositive()
movea = cont.sensors["left"].isPositive()
moved = cont.sensors["right"].isPositive()
running = cont.actuators["play_runanim"]
jup = cont.sensors["jump"].isPositive()
touch = ground(cont)
    
canrun = False
if run:
    if not jup:
        if touch == True:
            if movew:    
                canrun = True
            elif moves:
                canrun = True    
            elif movea:
                canrun = True    
            elif moved:
                canrun = True
    
        
GameLogic.addActiveActuator(running, canrun)    
    
    

GameLogic.setLogicTicRate(30)
GameLogic.setPhysicsTicRate(30)

Bullet Spawner

################################################################################
#                                                                              #
#                  This script has been written regarding                      #
#                   to a problem I noticed about blender.                      #
#                                                                              #
#                                                                              #
#     First, you got to know that when you create an object, you need to       #
#    specify "where"... which isn't a problem cuz usually, when you create     #
#       something, you have a good idea of where you want it to be. The        #
#     "spawning location", which is where your object will appear in the       #
#     game, is usually the center of another object (usually an empty for      #
#    "no-collision" purposes). When you do that, you tell blender to seek      #
#     for the center of the empty (Or the kind of object you choose) and       #
#        create your object there. Problem is that blender does have a         #
#      little "gap"... meaning that he will look for the location of the       #
#    object "FROM LAST FRAME". Therefore, blender will create your object      #
#   where your spawner* was one frame before. Since there's about 60 frames    #
#     each seconds, this gap doesn't seem big... but it is : A gap of one      #
#   frame from a spawner moving at 10 blender unit (meters) per second will    #
#     get a gap of 10/60 = .166 meters = 17 centimeters = bullet spawn way     #
#  off from the weapon and the player is not happy.... nor as the programmer.  #
#                                                                              #
#                                                                              #
#   To avoid this, I tried many way... but nothing simple seem to have any     #
#   impact on this problem : it's just the way blender think. So, to get rid   #
#    of this problem, I just offset the "spawner" from a distance relative     #
#  from the actual velocity of the spawner's parent. Therefore, the spawner's  #
#    position is approximately one frame ahead. So, if blender only consider   #
#     the position of the spawner one frame late, it's gonna be the actual     #
#    frame. And yes, the trick work. BUT, there is still a gap between the     #
#   created object and it's supposed location. This is due to the fact that    #
#  the approximation used to move the spawner one frame ahead does not take    #
#  the acceleration in consideration. Thus, the approximation would gain lot   #
# of precision by considering the acceleration, but relating to the fact that  # 
#    blender doesn't seem to already calculate it (not like the velocity),     #
#  there would be a need to calculate the acceleration from the 3 precedents   #
#   positions. These calculations could slow down the game and I will avoid    #
#  including them to the script as long as the gap isn't to bad... or until    #
#      I discover that the requested calculation power isn't that big.         #
#                                                                              #
#                                                                              #
#      Since the spawning point of the bullet may be set randomly anyway,      #
#        no need to get crazy about the exact supposed position of the         #
#        spawner : 10 centimeters off the weapon is quite too much, but        #
#                a few millimeters is pretty much reasonnable                  #
#                                                                              #
################################################################################



##########################
#                        #
# Initialization routine ################################
#                        #
##########################

# get the spawner's reference name
spawner = GameLogic.getCurrentController().owner


# Get properties
init_prop = spawner['Init']
locPos_prop = spawner['Local_Pos']


if init_prop == 0:
    spawner['Local_Pos'] = spawner.localPosition
    spawner['Init'] = 1




#######################################
#                                     #
#         *** ENOUGH TALK ***         ###################
#      Time for the real stuff ;)     ###################
#                                     #
#######################################


FRAME_RATE = 60

new_pos = [0,0,0]

for i in range (0,3):
    new_pos[i] = spawner['Local_Pos'][i] + (spawner.parent.parent.parent.getLinearVelocity(1)[i] / FRAME_RATE)

spawner.localPosition = new_pos