def getSiteIndex(centerpos): for index in es.createentitylist('func_bomb_target'): current_min = vecmath.vector(es.getindexprop(index, 'CBaseEntity.m_Collision.m_vecMins')) current_max = vecmath.vector(es.getindexprop(index, 'CBaseEntity.m_Collision.m_vecMaxs')) if vecmath.isbetweenRect(centerpos, current_min, current_max): return index return 0
def drawLine(coord1, coord2, model="materials/sprites/laser.vmt", halo="materials/sprites/halo01.vmt", seconds=0, width=10, endwidth=10, red=255, green=255, blue=255, brightness=255, speed=10, fadelength=0, noise=0, framestart=0, framerate=0): """ Draw a line between two coordinates """ try: c1 = vector(coord1) c2 = vector(coord2) except TypeError: raise TypeError("Invalid parameter type for coordinates") # Draw it! mi = es.precachemodel(model) hi = es.precachemodel(halo) es.effect('beam', str(c1), str(c2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed)
def drawCircle(origin, radius, steps=12, axle1=(1,0,0), axle2=(0,1,0), normal=None, model="materials/sprites/laser.vmt", halo="materials/sprites/halo01.vmt", seconds=0, width=10, endwidth=10, red=255, green=255, blue=255, brightness=255, speed=10, fadelength=0, noise=0, framestart=0, framerate=0): """ Draw a circle on a plane defined by origin and two points (axles) """ try: o = vector(origin) a1 = vector(axle1) if not normal: a2 = vector(axle2) normal = a1.cp(a2) except TypeError: raise TypeError("Invalid parameter type for coordinates") # normalize steps to be modular by 4, rounding up steps = int(float(steps)/4.0+.9)*4 # calculate steps per line edgesteps = steps/4 # generate the corner vectors k = [] k.append(a1.setlength(radius)) k.append(normal.cp(a1).setlength(radius)) k.append(-k[0]) k.append(-k[1]) k.append(k[0]) # distance between steps steplength = vecmath.distance(k[0],k[1])/edgesteps # Draw all the edges mi = es.precachemodel(model) hi = es.precachemodel(halo) for edge in range(4): c1 = o+k[edge] minus = k[edge+1]-k[edge] for s in range(edgesteps): c2 = o+(k[edge]+minus.setlength(steplength*(s+1))).setlength(radius) es.effect('beam', str(c1), str(c2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) c1 = c2
def getSiteIndex(centerpos): for index in es.createentitylist('func_bomb_target'): current_min = vecmath.vector( es.getindexprop(index, 'CBaseEntity.m_Collision.m_vecMins')) current_max = vecmath.vector( es.getindexprop(index, 'CBaseEntity.m_Collision.m_vecMaxs')) if vecmath.isbetweenRect(centerpos, current_min, current_max): return index return 0
def siteCheck(): bombsitesNum.clear() managerindex = es.getentityindex('cs_player_manager') if managerindex > 0: index = getSiteIndex(vecmath.vector(es.getindexprop(managerindex, 'CCSPlayerResource.m_bombsiteCenterA'))) if index: bombsitesNum['A'] = index index = getSiteIndex(vecmath.vector(es.getindexprop(managerindex, 'CCSPlayerResource.m_bombsiteCenterB'))) if index: bombsitesNum['B'] = index
def square(start, end, frame=True, fill=False, steps=15, users='#all', delay=0, model='sprites/laser.vmt', halo=0, startframe=0, framerate=255, life=3, width=3, endwidth=3, fadelength=3, amplitude=0, r=255, g=255, b=255, a=255, speed=1, queue=True): ''' Creates a simple, rectangular square by entity indexes and/or coordinates. You can fill it by setting "fill" to True. If you decided to fill the square, you need to set "steps" to the number of lines should be used to fill it. You can also disable the frame by setting "frame" to False. ''' start = vector(getLocation(start)) end = vector(getLocation(end)) if frame: p1 = vector(start) p2 = vector(end) p1.z = end.z p2.z = start.z polygon((start, p1, end, p2), users, delay, model, halo, startframe, framerate, life, width, endwidth, fadelength, amplitude, r, g, b, a, speed, queue=queue) if not fill: return minz = min(start.z, end.z) step = (max(start.z, end.z) - minz) / (steps + 1) end.z = minz start.z = minz for x in xrange(steps): start.z += step end.z += step beamPoints(users, delay, start, end, model, halo, startframe, framerate, life, width, endwidth, fadelength, amplitude, r, g, b, a, speed, queue=queue)
def siteCheck(): bombsitesNum.clear() managerindex = es.getentityindex('cs_player_manager') if managerindex > 0: index = getSiteIndex( vecmath.vector( es.getindexprop(managerindex, 'CCSPlayerResource.m_bombsiteCenterA'))) if index: bombsitesNum['A'] = index index = getSiteIndex( vecmath.vector( es.getindexprop(managerindex, 'CCSPlayerResource.m_bombsiteCenterB'))) if index: bombsitesNum['B'] = index
def player_jump(ev): if not es.isbot(ev['userid']): dbg( 'player jumped') steamid = sid(ev) players.increment(steamid,'jump') vStartpos = vecmath.vector(es.getplayerlocation(ev['userid'])) players.update(steamid,'jump_startpos',str(vStartpos))
def Check_Runboost(userid): location = es.getplayerlocation(userid) steamid = es.getplayersteamid(userid) velocity = int( round( vector( (float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[2]')))).length(), 2)) gamethread.cancelDelayed("Check_Ground_%s" % userid) if playerOnTop(userid)[0] == "True": client[steamid]['loc'] = location client[steamid]['time'] = 0 client[steamid]['avs'] = [] client[steamid]['pre'] = velocity else: gamethread.cancelDelayed("Check_Ground_%s" % userid) Check_When_Grounded(userid, False, True) return gamethread.delayedname(0.001, 'Check_Runboost_%s' % userid, Check_Runboost, args=(userid))
def Set_Location(userid): check = es.getplayerprop(userid, 'CBasePlayer.m_fFlags') location = es.getplayerlocation(userid) steamid = es.getplayersteamid(userid) player = playerlib.getPlayer(userid) velocity = int( round( vector( (float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[2]')))).length(), 2)) if not check & 1: if not playerOnTop(userid)[0] == "True": if velocity < 400: gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) Check_When_Grounded(userid, False, False) else: gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) Check_When_Grounded(userid, True, False) else: gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) Check_Runboost(userid) return else: client[steamid]['loc'] = location client[steamid]['time'] = 0 client[steamid]['avs'] = [] client[steamid]['pre'] = velocity gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) if player.isdead: gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) gamethread.cancelDelayed("Set_Location_%s" % userid) esc.tell( userid, "#255,51,0[#255,137,0LJStats#255,51,0] #snowis no longer tracking you!" ) client[steamid]['lj'] = 0 return gamethread.delayedname(0.001, 'Set_Location_%s' % userid, Set_Location, args=(userid))
def sm2es_keyPress(ev): userid = ev["userid"] if es.exists("userid", userid): if ev['status'] == '0': return if es.isbot(userid): return ply = playerlib.getPlayer(userid) if ply.isdead: return velocity_x = float( es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) velocity_y = float( es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) velocity = int( vector( float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))).length()) steamid = es.getplayersteamid(userid) if analysis[steamid]['onground'] == 0: if ev["command"] == 'IN_MOVELEFT': if analysis[steamid]['move'] == 0: analysis[steamid]['move'] = 1 analysis[steamid]['view_angle_0'].append( ply.getViewAngle()[0]) analysis[steamid]['view_angle_1'].append( ply.getViewAngle()[1]) analysis[steamid]['intervals'].append(time.time()) analysis[steamid]['velocity'].append(velocity) analysis[steamid]['strafes'] += 1 if ev['command'] == 'IN_MOVERIGHT': if analysis[steamid]['move'] == 1: analysis[steamid]['move'] = 0 analysis[steamid]['view_angle_0'].append( ply.getViewAngle()[0]) analysis[steamid]['view_angle_1'].append( ply.getViewAngle()[1]) analysis[steamid]['intervals'].append(time.time()) analysis[steamid]['velocity'].append(velocity) analysis[steamid]['strafes'] += 1
def player_land(ev): if not es.isbot(ev['userid']): steamid = extendedstats.sid(ev) extendedstats.dbg('player land') pos = vecmath.vector(es.getplayerlocation(ev['userid'])) startpos = extendedstats.players.query(steamid,'jump_startpos') if startpos: distance = vecmath.distance(pos, vecmath.vector(startpos)) extendedstats.players.add(steamid,'jump_distance',distance) if distance > extendedstats.players.query(steamid,'jump_longest'): extendedstats.players.update(steamid,'jump_longest',distance) if dcfg['notify_longestjump'] == '1': name = extendedstats.getName(steamid) rank,allplayers = extendedstats.getRank(steamid,'jump_longest') rSteamid, rDistance = extendedstats.getToplist(1,'jump_longest')[0] rName = extendedstats.getName(rSteamid) if dcfg['notify_longestjump_all'] == '1': es.msg('%s just broke his record of his longest jump. His new record is: %.2f meters!' % (name,distance*0.01905)) es.msg('He is ranked %s of %s now. Longest jump overall is %.2f meters by %s' % (rank,allplayers,rDistance,rName)) else: es.tell(ev['userid'],'You just broke your record of your longest jump! Your new record is: %.2f meters!' % (distance*0.01905)) es.tell(ev['userid'],'You are now ranked %s of %s. Longest jump overall is %.2f meters by %s' % (rank,allplayers,rDistance,rName)) extendedstats.players.update(steamid,'jump_startpos',None)
def ball(origin, radius, steps=15, users='#all', delay=0, model='sprites/laser.vmt', halo=0, startframe=0, framerate=255, life=3, width=3, spread=0, amplitude=0, r=255, g=255, b=255, a=255, speed=1, flags=0, upper=True, lower=True, queue=True): ''' Creates a ball by an entity index or coordinate and a radius. NOTE: The number of steps is used for the lower and upper half. ''' step = float(radius) / steps for x in xrange(steps): dist = step * x org = vector(origin) org.z += dist rad = 2 * radius * (1 - (float(x) / steps) ** 2) ** 0.5 args = (users, delay, org, rad, rad-0.1, model, halo, startframe, framerate, life, width, spread, amplitude, r, g, b, a, speed, flags) if upper: beamRingPoint(queue=queue, *args) if not x or not lower: continue org.z -= 2 * dist beamRingPoint(queue=queue, *args)
def setentname_cmd(args): if gamename in ['cstrike', 'dod', 'hl2mp']: userid = es.getuserid() if userid: if len(args) > 1: entity = args[0] entityname = args[1] if entity.isdigit() and entityname: player = playerlib.getPlayer(userid) playerlocation = vecmath.vector(player.getLocation()) playermovetype = es.getplayerprop(int(player), 'CBaseEntity.movetype') if gamename == 'cstrike': playerviewangles = vecmath.vector((float(es.getplayerprop(int(player), 'CCSPlayer.m_angEyeAngles[0]')), float(es.getplayerprop(int(player), 'CCSPlayer.m_angEyeAngles[1]')), 0.0)) playerviewoffset = vecmath.vector((float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[0]')), float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[1]')), float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[2]')))) elif gamename == 'dod': playerviewangles = vecmath.vector((float(es.getplayerprop(int(player), 'CDODPlayer.m_angEyeAngles[0]')), float(es.getplayerprop(int(player), 'CDODPlayer.m_angEyeAngles[1]')), 0.0)) playerviewoffset = vecmath.vector((float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[0]')), float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[1]')), float(es.getplayerprop(int(player), 'CBasePlayer.localdata.m_vecViewOffset[2]')))) elif gamename == 'hl2mp': playerviewangles = vecmath.vector((float(es.getplayerprop(int(player), 'CHL2MP_Player.m_angEyeAngles[0]')), float(es.getplayerprop(int(player), 'CHL2MP_Player.m_angEyeAngles[1]')), 0.0)) playerviewoffset = vecmath.vector((float(es.getplayerprop(int(player), 'CHL2MP_Player.baseclass.baseclass.baseclass.baseclass.m_vecViewOffset[0]')), float(es.getplayerprop(int(player), 'CHL2MP_Player.baseclass.baseclass.baseclass.baseclass.m_vecViewOffset[1]')), float(es.getplayerprop(int(player), 'CHL2MP_Player.baseclass.baseclass.baseclass.baseclass.m_vecViewOffset[2]')))) playerviewvector = (vecmath.vector(vecmath.angles((1.0,1.0,1.0), playerviewangles))) * 0.5 entitylocation = vecmath.vector(es.getindexprop(entity, 'CBaseEntity.m_vecOrigin')) entityviewvector = (playerlocation - (playerviewoffset + playerviewvector)) + entitylocation player.freeze(1) player.setLocation(list(entityviewvector)) player.viewCoord(list(entitylocation)) es.entsetname(int(player), entityname) es.server.cmd('es_xsetang %s %s %s' % (int(player), playerviewangles[0], playerviewangles[1])) es.setplayerprop(int(player), 'CBaseEntity.movetype', playermovetype) player.setLocation(list(playerlocation)) else: es.dbgmsg(0, 'setentname: Invalid target user "%s" to setentname.' % target) else: es.dbgmsg(0, 'setentname: Not enough arguments to setentname. Syntax: setentname <entity-index#> <desired-name>') else: es.dbgmsg(0, 'setentname: No userid available. Sorry, no targetname set!') else: es.dbgmsg(0, 'setentname: Game "%s" is not supported. Sorry, no targetname set!' % gamename)
def player_jump(ev): userid = ev["userid"] steamid = es.getplayersteamid(userid) if not es.isbot(userid): analysis[steamid]["view_angle_0"] = [] analysis[steamid]["view_angle_1"] = [] analysis[steamid]["velocity"] = [] velocity = int( vector( float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))).length()) analysis[steamid]["velocity"].append(velocity)
def DoTheJump(userid): if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'): return if userid not in JumpsUsed['time'] or userid not in JumpsUsed['count']: ev = {} ev['userid'] = userid player_jump(ev) return if JumpsUsed['count'][userid] > Max_Uses and Max_Uses != -1: return newTime = time.time() timeBetween = newTime - JumpsUsed['time'][userid] if timeBetween > Intervals: if JumpsUsed['count'][userid] > 0: Push_Value2 = Push_Value if int(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]')) < 0: Push_Value2 += (round(vecmath.vector((float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')), float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]')))).length(), 2) * Extra_Boost_If_Falling) es.setplayerprop(userid,"CBasePlayer.localdata.m_vecBaseVelocity", "0,0,%s" %Push_Value2) JumpsUsed['time'][userid] = newTime JumpsUsed['count'][userid] += 1
def Check_When_Grounded(userid, bhop, runboost): name = es.getplayername(userid) steamid = es.getplayersteamid(userid) velocity = int( round( vector( (float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[2]')))).length(), 2)) client[steamid]["time"] += 0.01 client[steamid]["avs"].append(velocity) check = es.getplayerprop(userid, 'CBasePlayer.m_fFlags') if check & 1: location = es.getplayerlocation(userid) player = playerlib.getPlayer(userid) distance = (vecmath.distance( (float(client[steamid]['loc'][0]), float( client[steamid]['loc'][1])), (float(location[0]), float(location[1])))) + 32 index = 0 add = 0 for item in client[steamid]["avs"]: add += item index += 1 break av = add / index time = (client[steamid]["time"]) checker = float(client[steamid]['loc'][2]) - float(location[2]) average = 0 index = 1 for item in analysis[steamid]["view_angle_0"]: index += 1 average += item tell_average = float(average) / float(index) detections = 0 for x in analysis[steamid]["view_angle_0"]: if (x - tell_average) >= -1 and (x - tell_average) <= 4: detections -= 2 else: detections += 0.843 if detections < 0: detections = 0 if not runboost: if not bhop: if distance > 264 and distance < 280 and client[steamid][ "time"] < 0.9 and client[steamid]["time"] > 0.68: esc.tell( userid, '#snowPrestrafe:#255,137,0 %s u/s #snow| Strafes#255,137,0 %s' % (client[steamid]["pre"], analysis[steamid]["strafes"])) esc.tell( userid, '#snowAverage Speed:#255,137,0 %s u/s #snowand air time:#255,137,0 %s seconds' % (av, client[steamid]["time"])) esc.tell( userid, '#snowDistance:#255,137,0 %s units' % (round(distance, 3))) elif distance < 280 and client[steamid][ "time"] < 0.9 and distance > 240 and client[steamid][ "time"] > 0.68: esc.tell( userid, '#snowPrestrafe:#255,137,0 %s u/s #snow| Strafes#255,137,0 %s' % (client[steamid]["pre"], analysis[steamid]["strafes"])) esc.tell( userid, '#snowAverage Speed:#255,137,0 %s u/s #snowand air time:#255,137,0 %s seconds' % (av, client[steamid]["time"])) esc.tell( userid, '#snowDistance:#255,137,0 %s units' % (round(distance, 3))) else: if distance >= 485 and distance <= 580: esc.tell(userid, '#yellow- RUNBOOST -') esc.tell( userid, '#snowPrestrafe:#255,137,0 %s u/s #snow| Strafes#255,137,0 %s' % (client[steamid]["pre"], analysis[steamid]["strafes"])) esc.tell( userid, '#snowAverage Speed:#255,137,0 %s u/s #snowand air time:#255,137,0 %s seconds' % (av, client[steamid]["time"])) esc.tell( userid, '#snowDistance:#255,137,0 %s units' % (round(distance, 3))) analysis[steamid] = { 'move': 0, 'view_angle_0': [], 'view_angle_1': [], 'velocity': [], 'intervals': [], 'onground': 0, 'location': (0, 0, 0), 'msg': 0, 'strafes': 0, 'time': 0, 'cheated': 0, 'loyal': 0 } Set_Location(userid) return gamethread.delayedname(0.001, 'Check_Ground_%s' % userid, Check_When_Grounded, args=(userid, bhop, runboost))
def update(self): timer = es.import_addon('trikztimer/plugins/timer') """ Update the player's message showing his targets ranks. """ if not es.exists('userid', self.userid): return #if not es.exists('userid', self.target): # return if es.getplayerteam(self.userid) in (2, 3): if not playerlib.getPlayer(self.userid).isdead: Player(self.userid).delspec(self.userid, self.target, 1) return target = self.getspec() if target != -1: self.target = target steamid = es.getplayersteamid(self.target) name = es.getplayername(self.target) # PARTNER TIMER velocity = round( vector( float( es.getplayerprop( self.target, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( self.target, 'CBasePlayer.localdata.m_vecVelocity[1]'))).length( ), 2) Player(self.userid).addspec(self.userid, self.target) Player(self.userid).delspec(self.userid, self.target, 2) specs[self.userid]["last_spec"] = self.target if steamid in timer.player: string = timer.player[steamid]["text_display"] if timer.CheckPartner(self.target): string += "\n(Partnered)" else: string += "\n(Solo)" timer.player[steamid]['spectators'] = specs[self.target]['n'] if not es.isbot(target): hudhint(self.userid, "- %s -\nVel: %s\n%s" % (name, velocity, string)) name_list = "" if len(specs[self.target]['n']) > 0: for object in specs[self.target]['n']: s_name = str(es.getplayername(object)) if len(s_name) > 12: s_name = str(es.getplayername(object))[0:12] + "..." name_list += "\n" + s_name if timer.tournament["status"] == 0: keyhint( self.userid, "%s's Spectators: %s\n%s" % (name, len(specs[self.target]['n']), name_list)) else: string = "" string += "-- Tournament Mode --\n " if timer.tournament["turn"] in timer.tournament["queue"] > 0: turn = timer.tournament["turn"] string += "\n %s | %s is playing..\n \n Next couple in: %s \n \n \n" % ( timer.tournament["queue"][turn][0]["name"], timer.tournament["queue"][turn][1]["name"], timer.TimeFormat(timer.tournament["time"], None, True)) else: string += "\nNo teams available yet!\n \n" keyhint( self.userid, "Spectators: %s\n%s" % (string, name, len(specs[self.target]['n']), name_list)) else: Player(self.userid).delspec(self.userid, self.target, 2)
def sm2es_keyPress(ev): userid = ev["userid"] if es.exists("userid", userid): if ev['status'] == '0': return ply = playerlib.getPlayer(userid) if ply.isdead: return velocity_x = float( es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) velocity_y = float( es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) velocity = int( vector( float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))).length()) steamid = es.getplayersteamid(userid) check = es.getplayerprop(userid, 'CBasePlayer.m_fFlags') if not check & 1: if ev["command"] == 'IN_MOVELEFT': if analysis[steamid]['move'] == 0: analysis[steamid]['move'] = 1 analysis[steamid]['view_angle_0'].append( ply.getViewAngle()[0]) analysis[steamid]['view_angle_1'].append( ply.getViewAngle()[1]) analysis[steamid]['intervals'].append(time.time()) analysis[steamid]['velocity'].append(velocity) analysis[steamid]['strafes'] += 1 if ev['command'] == 'IN_MOVERIGHT': if analysis[steamid]['move'] == 1: analysis[steamid]['move'] = 0 analysis[steamid]['view_angle_0'].append( ply.getViewAngle()[0]) analysis[steamid]['view_angle_1'].append( ply.getViewAngle()[1]) analysis[steamid]['intervals'].append(time.time()) analysis[steamid]['velocity'].append(velocity) analysis[steamid]['strafes'] += 1 else: analysis[steamid] = { 'move': 0, 'view_angle_0': [], 'view_angle_1': [], 'velocity': [], 'intervals': [], 'onground': 0, 'location': (0, 0, 0), 'msg': 0, 'strafes': 0, 'time': 0, 'cheated': 0, 'loyal': 0 }
def drawBox( coord1, coord2, model="materials/sprites/laser.vmt", halo="materials/sprites/halo01.vmt", seconds=0, width=10, endwidth=10, red=255, green=255, blue=255, brightness=255, speed=10, fadelength=0, noise=0, framestart=0, framerate=0, ): """ Draw a rectangular box by using two coordinates """ try: c1 = vector(coord1) c2 = vector(coord2) except TypeError: raise TypeError, "Invalid parameter type for coordinates" # Create the additional corners for the box tc1 = vector(c1) tc2 = vector(c1) tc3 = vector(c1) tc4 = vector(c2) tc5 = vector(c2) tc6 = vector(c2) tc1[0] = c2[0] tc2[1] = c2[1] tc3[2] = c2[2] tc4[0] = c1[0] tc5[1] = c1[1] tc6[2] = c1[2] # Draw all the edges mi = es.precachemodel(model) hi = es.precachemodel(halo) es.effect( "beam", str(c1), str(tc1), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(c1), str(tc2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(c1), str(tc3), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(tc6), str(tc1), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(tc6), str(tc2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(tc6), str(c2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(tc4), str(c2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(tc5), str(c2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(tc5), str(tc1), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(tc5), str(tc3), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(tc4), str(tc3), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, ) es.effect( "beam", str(tc4), str(tc2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed, )
def drawCircle(origin, radius, steps=12, axle1=(1, 0, 0), axle2=(0, 1, 0), normal=None, model="materials/sprites/laser.vmt", halo="materials/sprites/halo01.vmt", seconds=0, width=10, endwidth=10, red=255, green=255, blue=255, brightness=255, speed=10, fadelength=0, noise=0, framestart=0, framerate=0): """ Draw a circle on a plane defined by origin and two points (axles) """ try: o = vector(origin) a1 = vector(axle1) if not normal: a2 = vector(axle2) normal = a1.cp(a2) except TypeError: raise TypeError("Invalid parameter type for coordinates") # normalize steps to be modular by 4, rounding up steps = int(float(steps) / 4.0 + .9) * 4 # calculate steps per line edgesteps = steps / 4 # generate the corner vectors k = [] k.append(a1.setlength(radius)) k.append(normal.cp(a1).setlength(radius)) k.append(-k[0]) k.append(-k[1]) k.append(k[0]) # distance between steps steplength = vecmath.distance(k[0], k[1]) / edgesteps # Draw all the edges mi = es.precachemodel(model) hi = es.precachemodel(halo) for edge in range(4): c1 = o + k[edge] minus = k[edge + 1] - k[edge] for s in range(edgesteps): c2 = o + (k[edge] + minus.setlength(steplength * (s + 1))).setlength(radius) es.effect('beam', str(c1), str(c2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) c1 = c2
def box(start, end, frame=True, fill=False, steps=15, users='#all', delay=0, model='sprites/laser.vmt', halo=0, startframe=0, framerate=255, life=3, width=3, endwidth=3, fadelength=3, amplitude=0, r=255, g=255, b=255, a=255, speed=1, queue=True): ''' Creates a simple rectangular box by entity indexes and/or coordinates. You can fill the walls by setting "fill" to True. If you decided to fill the box, you need to set "steps" to the number of lines should be used to fill it. You can also disable the frame by setting "frame" to False. ''' start = vector(getLocation(start)) end = vector(getLocation(end)) p1 = vector(start) p2 = vector(start) p3 = vector(start) p4 = vector(end) p5 = vector(end) p6 = vector(end) p1.x = end.x p2.y = end.y p3.z = end.z p4.x = start.x p5.y = start.y p6.z = start.z args = (model, halo, startframe, framerate, life, width, endwidth, fadelength, amplitude, r, g, b, a, speed) args2 = (False, fill, steps, users, delay) square(start, p4, queue=queue, *args2+args) square(start, p5, queue=queue, *args2+args) square(p1, end, queue=queue, *args2+args) square(p2, end, queue=queue, *args2+args) if not frame: return polygon((start, p1, p5, p3), users, delay, *args) polygon((end, p4, p2, p6), users, delay, *args) beamPoints(users, delay, start, p2, queue=queue, *args) beamPoints(users, delay, p1, p6, queue=queue, *args) beamPoints(users, delay, p5, end, queue=queue, *args) beamPoints(users, delay, p3, p4, queue=queue, *args)
def drawBox(coord1, coord2, model="materials/sprites/laser.vmt", halo="materials/sprites/halo01.vmt", seconds=0, width=10, endwidth=10, red=255, green=255, blue=255, brightness=255, speed=10, fadelength=0, noise=0, framestart=0, framerate=0): """ Draw a rectangular box by using two coordinates """ try: c1 = vector(coord1) c2 = vector(coord2) except TypeError: raise TypeError("Invalid parameter type for coordinates") # Create the additional corners for the box tc1 = vector(c1) tc2 = vector(c1) tc3 = vector(c1) tc4 = vector(c2) tc5 = vector(c2) tc6 = vector(c2) tc1[0] = c2[0] tc2[1] = c2[1] tc3[2] = c2[2] tc4[0] = c1[0] tc5[1] = c1[1] tc6[2] = c1[2] # Draw all the edges mi = es.precachemodel(model) hi = es.precachemodel(halo) es.effect('beam', str(c1), str(tc1), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(c1), str(tc2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(c1), str(tc3), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(tc6), str(tc1), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(tc6), str(tc2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(tc6), str(c2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(tc4), str(c2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(tc5), str(c2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(tc5), str(tc1), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(tc5), str(tc3), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(tc4), str(tc3), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed) es.effect('beam', str(tc4), str(tc2), mi, hi, framestart, framerate, seconds, width, endwidth, fadelength, noise, red, green, blue, brightness, speed)
def setentname_cmd(args): if gamename in ['cstrike', 'dod', 'hl2mp']: userid = es.getuserid() if userid: if len(args) > 1: entity = args[0] entityname = args[1] if entity.isdigit() and entityname: player = playerlib.getPlayer(userid) playerlocation = vecmath.vector(player.getLocation()) playermovetype = es.getplayerprop(int(player), 'CBaseEntity.movetype') if gamename == 'cstrike': playerviewangles = vecmath.vector( (float( es.getplayerprop( int(player), 'CCSPlayer.m_angEyeAngles[0]')), float( es.getplayerprop( int(player), 'CCSPlayer.m_angEyeAngles[1]')), 0.0)) playerviewoffset = vecmath.vector( (float( es.getplayerprop( int(player), 'CBasePlayer.localdata.m_vecViewOffset[0]') ), float( es.getplayerprop( int(player), 'CBasePlayer.localdata.m_vecViewOffset[1]' )), float( es.getplayerprop( int(player), 'CBasePlayer.localdata.m_vecViewOffset[2]' )))) elif gamename == 'dod': playerviewangles = vecmath.vector( (float( es.getplayerprop( int(player), 'CDODPlayer.m_angEyeAngles[0]')), float( es.getplayerprop( int(player), 'CDODPlayer.m_angEyeAngles[1]')), 0.0)) playerviewoffset = vecmath.vector( (float( es.getplayerprop( int(player), 'CBasePlayer.localdata.m_vecViewOffset[0]') ), float( es.getplayerprop( int(player), 'CBasePlayer.localdata.m_vecViewOffset[1]' )), float( es.getplayerprop( int(player), 'CBasePlayer.localdata.m_vecViewOffset[2]' )))) elif gamename == 'hl2mp': playerviewangles = vecmath.vector( (float( es.getplayerprop( int(player), 'CHL2MP_Player.m_angEyeAngles[0]')), float( es.getplayerprop( int(player), 'CHL2MP_Player.m_angEyeAngles[1]')), 0.0)) playerviewoffset = vecmath.vector(( float( es.getplayerprop( int(player), 'CHL2MP_Player.baseclass.baseclass.baseclass.baseclass.m_vecViewOffset[0]' )), float( es.getplayerprop( int(player), 'CHL2MP_Player.baseclass.baseclass.baseclass.baseclass.m_vecViewOffset[1]' )), float( es.getplayerprop( int(player), 'CHL2MP_Player.baseclass.baseclass.baseclass.baseclass.m_vecViewOffset[2]' )))) playerviewvector = (vecmath.vector( vecmath.angles( (1.0, 1.0, 1.0), playerviewangles))) * 0.5 entitylocation = vecmath.vector( es.getindexprop(entity, 'CBaseEntity.m_vecOrigin')) entityviewvector = ( playerlocation - (playerviewoffset + playerviewvector)) + entitylocation player.freeze(1) player.setLocation(list(entityviewvector)) player.viewCoord(list(entitylocation)) es.entsetname(int(player), entityname) es.server.cmd('es_xsetang %s %s %s' % (int(player), playerviewangles[0], playerviewangles[1])) es.setplayerprop(int(player), 'CBaseEntity.movetype', playermovetype) player.setLocation(list(playerlocation)) else: es.dbgmsg( 0, 'setentname: Invalid target user "%s" to setentname.' % target) else: es.dbgmsg( 0, 'setentname: Not enough arguments to setentname. Syntax: setentname <entity-index#> <desired-name>' ) else: es.dbgmsg( 0, 'setentname: No userid available. Sorry, no targetname set!') else: es.dbgmsg( 0, 'setentname: Game "%s" is not supported. Sorry, no targetname set!' % gamename)