Help with this outdated script

So its probably really rude to start my first post off like this but I really needed some help figuring out what to do with this this thing, I have this python script which is outdated (like for 2.49 but only works with the 32 bit version)
I just want some guidance or help figuring out how to make this for blender 2.78 . Since I have no clue what would be considered " deprecated methods"

The script is for sims 2 and has some problems like duplicating vertices. I just want to make it compatible with the new blender, I also didn’t make the script
Its also to import smd files but the sims 2 kind

#!BPY

“”"
Name: ‘Sims 2 smd file’
Blender: 244
Group: ‘Import’
Tooltip: ‘imports a smd file from sims 2(doubt it will work on other smd’s)’
“”"
author = “Bobcatben”
url = ["", “”]
version = “0.3”

bpydoc = “”"
“”"

#9/12/2007 version 0.3: reAdded importing of normals(results in some duplicate vertices’s but fixes the normal problem, still recalculating them, but this keeps it from merging vertices’s with different normals)

from Blender import *
from Blender.Mathutils import *
from math import *

def mat(x,y,z,rx,ry,rz):
rotmat = RotationMatrix(rx,4,‘x’) * RotationMatrix(ry,4,‘y’) * RotationMatrix(rz,4,‘z’)
transmat = TranslationMatrix(Vector(x,y,z))
mat2 = rotmat * transmat
del rotmat
del transmat
return mat2

class Bone:
id = 0
name = “”
parentid = 0
matrix = None
def init(this,id,name,pid):
this.id = id
this.name = name
this.parentid = pid

def add(a, tup):
if tup in a:
return a.index(tup)
else:
a.append(tup)
return len(a)-1

def import_smd(path):
editmode = Window.EditMode()
if editmode: Window.EditMode(0)
IMPORT_SKELETON = Draw.Create(1)
IMPORT_MESH = Draw.Create(1)
pup_block = [
(‘Import Options’),
(‘Mesh’ ,IMPORT_MESH , ‘Import the Mesh?’),
(‘Skeleton’ ,IMPORT_SKELETON , ‘Import the Skeleton?’)
]
if not Draw.PupBlock(‘Import…’, pup_block):
return
import_mesh = IMPORT_MESH.val
import_skeleton = IMPORT_SKELETON.val
Window.WaitCursor(1)
name = path.split(’\’)[-1].split(’/’)[-1]
file = open(path, ‘r’)
scn = Scene.GetCurrent()
Bones = []
faces = []
verts = []
Window.DrawProgressBar(0.0,’’)
lines = file.readlines()
for i in range(0, len(lines)):
line = lines[i]
words = line.split()
#do the nodes
if line.startswith(‘nodes’) and import_skeleton:
Window.DrawProgressBar(0.0,‘Reading Nodes’)
arm = Armature.New(‘Bones’)
arm.envelopes = False
arm.makeEditable()
armob = scn.objects.new(arm,“Bones”)
start = i + 1
for i in range(start, len(lines)):
line = lines[i]
words = line.split()
if line.startswith(‘end’):
break
tmpbone = Armature.Editbone()
bonename = words[1][1:-1]
Bones.append(Bone(int(words[0]),bonename,int(words[2])))
if int(words[2]) > -1:
tmpbone.parent = arm.bones[ Bones[int(words[2])].name ]
arm.bones[bonename] = tmpbone
#do the skeleton
if line.startswith(‘skeleton’) and import_skeleton:
Window.DrawProgressBar(0.1,‘Reading Skeleton’)
start = i + 1
for i in range(start, len(lines)):
line = lines[i]
words = line.split()
if line.startswith(‘end’):
break
if len(words) <= 2:
continue
tx, ty, tz = float(words[1]), float(words[2]), float(words[3])
rx, ry, rz = degrees(float(words[4])), degrees(float(words[5])), degrees(float(words[6]))
boneindex = int(words[0])
bone = arm.bones[Bones[boneindex].name]
parentindex = Bones[boneindex].parentid
matrix = mat(tx,ty,tz,rx,ry,rz)
if(parentindex > -1):
parent = arm.bones[Bones[parentindex].name]
parentmatrix = Bones[parentindex].matrix
matrix = matrix * parentmatrix
myhead = Vector([0,0,0,1]) * matrix
mytail = Vector([0,0.1,0,1]) * matrix
myhead.resize3D()
mytail.resize3D()
bone.head = myhead
bone.tail = mytail
Bones[boneindex].matrix = matrix
else:
myhead = Vector([0,0,0,1]) * matrix
mytail = Vector([0,0.1,0,1]) * matrix
myhead.resize3D()
mytail.resize3D()
bone.head = myhead
bone.tail = mytail
Bones[boneindex].matrix = matrix
#do the mesh itself(triangles)
if line.startswith(‘triangles’) and import_mesh:
Window.DrawProgressBar(0.2,‘Reading Mesh’)
start = i + 1
faceverts = []
facetex = []
for i in range(start, len(lines)):
line = lines[i]
words = line.split()
if line.startswith(‘end’):
break
if len(words) < 3:
continue
#get the vertex data, excluding normals as they dont like to import correctly
#so we will just have blender recalculate normals at the end, after we remove duplicate vertex’s
x, y, z, tx, ty = float(words[1]), float(words[2]), float(words[3]), float(words[7]), float(words[8])
nx, ny, nz = float(words[4]), float(words[5]), float(words[6])
tmp = []
if len(words) >= 10:
for w in range(0,int(words[9])*2,2):
tmp.append([ int(words[10+w]), float(words[11+w]) ])
faceverts.append(add(verts,[x, y, z,nx,ny,nz, tmp])+1)
facetex.append([tx, ty])

			#faces every 3 vertex's
			if len(faceverts) == 3:
				faces.append([faceverts,facetex])
				facetex = []
				faceverts = []
		#now send them to blender.
		Window.DrawProgressBar(0.4,'Writing Vertices')	
		mesh = Mesh.New('Imported Object')
		meshob = scn.objects.new(mesh, 'Imported Object')
		mesh.verts.extend([[0,0,0]])
		for v in verts:
			mesh.verts.extend([[v[0],v[1],v[2]]])
			mesh.verts[-1:][0].no[0] = v[3]
			mesh.verts[-1:][0].no[1] = v[4]
			mesh.verts[-1:][0].no[2] = v[5]
		Window.DrawProgressBar(0.6,'Writing Faces')
		for f in faces:
			mesh.faces.extend([f[0]],ignoreDups=True)
			mesh.faces[len(mesh.faces)-1].image = Image.GetCurrent()
			mesh.faces[len(mesh.faces)-1].uv = [Vector(f[1][0]),Vector(f[1][1]),Vector(f[1][2])]
		mesh.verts.delete([0])
		mesh.calcNormals()
			
			
file.close()
if import_skeleton and import_mesh:
	Window.DrawProgressBar(0.9,'Creating vertex groups')
	for b in Bones:
		mesh.addVertGroup(b.name)
	Window.DrawProgressBar(0.95,'Weighting vertices')
	for vi in range(0, len(verts)):
		for weight in verts[vi][6]:
			mesh.assignVertsToGroup( Bones[weight[0]].name, [vi],weight[1],1)
if import_skeleton:
	arm.update()
if import_skeleton and import_mesh:
	armob.makeParentDeform([meshob], 0, 0)
Window.DrawProgressBar(1.0,'Done')
Window.WaitCursor(0)
Window.RedrawAll()

Window.FileSelector(import_smd, ‘Import’)’

Any help is appreciated

Most of the math functions and basic python stuff will not need changing. It’s the stuff like Window.Something and similar 2.49 functions that will need to be updated.