thats nice ace 
ok so I was able to abstract a bit further, and at the same time expand the functionality
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
from mathutils import Vector
if 'Armature' not in own:
for child in own.children:
if 'ArmaTag' in child:
own['Armature']=child
if own['Run']>=1:
own['Run']-=1
G = cont.sensors['Collision']
def Animate(Data):
print('calling anim')
anim = Data[0]
start = Data[1]
end = Data[2]
rate = Data[3]
mode = Data[4]
chan = Data[5]
s = str(chan)+"_frame"
frame = own['Armature'][s]
if mode=="Loop":
f = own['Armature'][s]+rate
if f>end:
f= f-end
if f< start:
f = end-f
if len(Data)==6:
own['Armature'].playAction(anim, f, f, chan, 0, 0, 0, 0.0, 0, 0.0, 0)
else:
own['Armature'].playAction(anim, f, f, chan, 0, Data[6], 0, 0.0, 0, 0.0, 0)
own['Armature'][s]=f
def idle(point):
print('calling idle')
if G.positive:
own.localLinearVelocity*=.1
def Rot(point):
print(point[0])
local = point[0]-own.worldPosition
local = own.worldOrientation.inverted()*local
own['D']=str(local)
#print('set')
if local.x>0:
own.applyRotation([0,0,(local.y/8)],1)
if local.y>.05:
own.applyRotation((0,0,.01),1)
elif local.y<.05:
own.applyRotation((0,0,-.01),1)
else:
own.applyRotation([0,0,(local.y/18)],1)
if local.y>.05:
own.applyRotation((0,0,.05),1)
elif local.y<.05:
own.applyRotation((0,0,-.05),1)
def Move(point):
if G.positive:
v2 = own.getVectTo(point[0])
local = point[0]-own.worldPosition
local = own.worldOrientation.inverted()*local
if local.x>0 and (abs(local.y)-abs(local.x))<0:
if own.localLinearVelocity.x<5:
own.applyForce((50,0,0),1)
own.localLinearVelocity.y*=.5
Pos = own.worldPosition
Movement_Dict = {}
Movement_Dict.update({str(['UP']):[ [Move,[Pos+Vector([0,-1,0])] ],[Rot,[Pos+Vector([0,-1,0])]],[Animate,['walk',0,23,own.localLinearVelocity.x*.1,"Loop",0] ] ] })
Movement_Dict.update({str(['UP', 'LEFT']):[ [Move,[Pos+Vector([1,-1,0])] ],[Rot,[Pos+Vector([1,-1,0])]],[Animate,['walk',0,23,own.localLinearVelocity.x*.1,"Loop",0] ] ] })
Movement_Dict.update({str(['LEFT', 'DOWN']):[ [Move,[Pos+Vector([1,1,0])] ],[Rot,[Pos+Vector([1,1,0])]],[Animate,['walk',0,23,own.localLinearVelocity.x*.1,"Loop",0] ] ] })
Movement_Dict.update({str(['DOWN']):[ [Move,[Pos+Vector([0,1,0])]],[Rot,[Pos+Vector([0,1,0])]],[Animate,['walk',0,23,own.localLinearVelocity.x*.1,"Loop",0] ] ] })
Movement_Dict.update({str(['DOWN', 'RIGHT']):[ [Move,[Pos+Vector([-1,1,0])]],[Rot,[Pos+Vector([-1,1,0])]],[Animate,['walk',0,23,own.localLinearVelocity.x*.1,"Loop",0] ] ] })
Movement_Dict.update({str(['LEFT']):[ [Move,[Pos+Vector([1,0,0])] ],[Rot,[Pos+Vector([1,0,0])]],[Animate,['walk',0,23,own.localLinearVelocity.x*.1,"Loop",0] ] ] })
Movement_Dict.update({str(['RIGHT']):[ [Move,[Pos+Vector([-1,0,0])] ],[Rot,[Pos+Vector([-1,0,0])]],[Animate,['walk',0,23,own.localLinearVelocity.x*.1,"Loop",0] ] ] })
Movement_Dict.update({str(['UP', 'RIGHT']):[ [Move,[Pos+Vector([-1,-1,0])] ],[Rot,[Pos+Vector([-1,-1,0])]],[Animate,['walk',0,23,own.localLinearVelocity.x*.1,"Loop",0] ] ] })
Movement_Dict.update({str([]):[ [idle,[]] ]})
def main():
own['D']=own['Move']
if str(own['Move']) in Movement_Dict:
command = Movement_Dict[str(own['Move'])]
for part in command:
function = part[0]
function(part[1])
if len(own['Move'])>0:
cont.deactivate(cont.actuators['Idle'])
else:
cont.activate(cont.actuators['Idle'])
own['Move']=[]
main()
now instead of directly calling 1 function for each state, a list of functions is called.
next up is building GOAP and adding goals to pop the GOAP to the functions to be able to be called
(Timer(timeEnd,Time), Point(Vector or agent), AnyKey(‘PUNCH’))