Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
    def float_state(self):
        while True:
            self.ticks+=1
            self.float_ticks+=1
            self.floaty=12*math.cos(math.radians(self.float_ticks))
            self.y=self.starty+self.floaty

            if self.float_ticks > 360:
                self.float_ticks=0

            if vecmath.distance(self.x+self.sprite.hotwidth/2, self.y+self.sprite.hotheight/2,
                             engine.player.x+engine.player.sprite.hotwidth/2, engine.player.y+engine.player.sprite.hotheight/2) < self.scandistance: #within scanning range
                self.state=self.scan_state

                yield None
            yield None
Ejemplo n.º 3
0
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) 
Ejemplo n.º 4
0
    def scan_state(self):
        self.scanning=True
        self.scanwidth=1


        self.scansound.loop=True
        self.scansound.pitchshift=0.5
        self.scansound.Play()
        while True:

            self.scansound.pitchshift=0.5+(self.scanwidth/100.0)
            self.ticks+=1
            self.float_ticks+=1
            self.floaty=12*math.cos(math.radians(self.float_ticks))
            self.y=self.starty+self.floaty

            if self.float_ticks > 360:
                self.float_ticks=0


            if vecmath.distance(self.x+self.sprite.hotwidth/2, self.y+self.sprite.hotheight/2,
                             engine.player.x+engine.player.sprite.hotwidth/2, engine.player.y+engine.player.sprite.hotheight/2) > self.scandistance+16: #player moving out of scanning range, with a bit of buffer...

                if self.scanwidth>0:
                    self.scanwidth-=1
                else: #been out of range, stop scanning
                    self.state=self.float_state
                    self.scanning=False
                    self.scansound.Pause()
                    yield None

            else: #still within scanning range.
                if self.scanwidth<50:
                    self.scanwidth+=1

            yield None
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
def cp_menu_select(userid, choice, popupid):
    steamid = es.getplayersteamid(userid)
    velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]'))
    velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))
    velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]'))
    timer = es.import_addon("queue_timer/plugins/timer")
    if timer.CheckPartner(userid):
        timer_id = timer.player[steamid]["timer_id"]
        state = timer.timer[timer_id]["state"]

    if int(choice) == 1:
        if timer.CheckPartner(userid):
            cp_menu(userid)
        else:
            player = playerlib.getPlayer(userid)
            client[steamid]["view_angles"] = player.getViewAngle()
            view_angles = client[steamid]["view_angles"]
            client[steamid]['snapshot_1'] = es.getplayerlocation(userid)
            client[steamid]['save_speed'] = (velocity_x, velocity_y, velocity_z)
            esc.tell(userid,
                     '#124,252,0[ Trikz] #snowYou have saved your #yellow1st #245,61,0checkpoint')
            cp_menu(userid)

    if int(choice) == 2:
        if timer.CheckPartner(userid):
            cp_menu(userid)
        else:
            if client[steamid]['snapshot_1'] != (0, 0, 0):
                current_location = es.getplayerlocation(userid)
                location = client[steamid]['snapshot_1']
                distance = vecmath.distance(current_location, location)
                player = playerlib.getPlayer(userid)
                view_angles = client[steamid]["view_angles"]
                timer.TimerSolo_Stop(userid)
                client[steamid]["time"] = time.time()
                player.setColor(255, 255, 255, 255)
                player.noblock(0)
                if client[steamid]["stop_speed"] == "On":
                    es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2]))

                    velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]'))
                    velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))
                    velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]'))
                    myNewVector2 = es.createvectorstring(-velocity_x, -velocity_y, -velocity_z)

                    es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2)

                    gamethread.delayed(0.025, set_boost, args=(userid, 0))


                else:
                    es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2]))
                    velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]'))
                    velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))
                    velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]'))
                    myNewVector2 = es.createvectorstring(-velocity_x, -velocity_y, -velocity_z)
                    es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2)

                if client[steamid]["save_angles"] == "On":
                    es.server.queuecmd('es_xsetang %s %s %s %s' % (
                    userid, str(view_angles[0]), str(view_angles[1]), str(view_angles[2])))

            else:
                esc.tell(userid, '#124,252,0[ Trikz] #245,0,61You have not set your 1st checkpoint.')
            cp_menu(userid)

    if int(choice) == 3:
        if timer.CheckPartner(userid):
            cp_menu(userid)
        else:
            player = playerlib.getPlayer(userid)
            client[steamid]["view_angles_2"] = player.getViewAngle()
            client[steamid]['snapshot_2'] = es.getplayerlocation(userid)
            client[steamid]['save_speed_2'] = (velocity_x, velocity_y, velocity_z)
            esc.tell(userid,
                     '#124,252,0[ Trikz] #snowYou have saved your #yellow2nd #245,61,0checkpoint')
            cp_menu(userid)

    if int(choice) == 4:
        if timer.CheckPartner(userid):
            cp_menu(userid)
        else:
            if client[steamid]['snapshot_2'] != (0, 0, 0):
                current_location = es.getplayerlocation(userid)
                location = client[steamid]['snapshot_2']
                distance = vecmath.distance(current_location, location)
                player = playerlib.getPlayer(userid)
                view_angles = client[steamid]["view_angles_2"]
                client[steamid]["time"] = time.time()
                timer.TimerSolo_Stop(userid)
                player.setColor(255, 255, 255, 255)
                player.noblock(0)
                if client[steamid]["stop_speed"] == "On":
                    es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2]))

                    velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]'))
                    velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))
                    velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]'))
                    myNewVector2 = es.createvectorstring(-velocity_x, -velocity_y, -velocity_z)

                    es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2)

                    gamethread.delayed(0.025, set_boost, args=(userid, 1))
                else:

                    es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2]))

                    velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]'))
                    velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))
                    velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]'))
                    myNewVector2 = es.createvectorstring(-velocity_x, -velocity_y, -velocity_z)
                    es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2)

                if client[steamid]["save_angles"] == "On":
                    es.server.insertcmd('es_xsetang %s %s %s %s' % (
                    userid, str(view_angles[0]), str(view_angles[1]), str(view_angles[2])))

            else:
                esc.tell(userid, '#124,252,0[ Trikz] #245,0,61You have not set your 2nd checkpoint.')
            cp_menu(userid)

    if int(choice) == 5:
        if client[steamid]['stop_speed'] == "Off":
            esc.tell(userid,
                     '#124,252,0[ Trikz] #snowYour speed will now be restored when teleporting!')
            client[steamid]['stop_speed'] = "On"
            cp_menu(userid)
        else:
            esc.tell(userid, '#124,252,0[ Trikz] #snowYou will not save speed anymore!')
            client[steamid]['stop_speed'] = "Off"
            cp_menu(userid)

    if int(choice) == 6:
        if client[steamid]['save_angles'] == "Off":
            esc.tell(userid, '#124,252,0[ Trikz] #snowYou will now save ur angles!')
            client[steamid]['save_angles'] = "On"
            cp_menu(userid)
        else:
            esc.tell(userid, '#124,252,0[ Trikz] #snowYou angles wont be saved!')
            client[steamid]['save_angles'] = "Off"
            cp_menu(userid)

    if int(choice) == 8:
        trikz_menu(userid)
Ejemplo n.º 7
0
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))
Ejemplo n.º 8
0
def Average(userid):
    steamid = es.getplayersteamid(userid)
    anti_cheat = 0
    speed_detection = 0
    detections = 0
    case = []
    analysis[steamid]["velocity"].append(250)
    if time.time() - analysis[steamid]["time"] < 2:
        if analysis[steamid]["msg"] == 1:
            duplicates = list_duplicates(analysis[steamid]["view_angle_0"])
            for dup in duplicates:

                if duplicates[dup] >= 4 and duplicates[dup] <= len(
                        analysis[steamid]["view_angle_0"]) * 0.8:
                    detections += duplicates[dup]
                    case.append(1)

            duplicates = list_duplicates(analysis[steamid]["view_angle_1"])
            for dup in duplicates:
                if duplicates[dup] >= 4 and duplicates[dup] <= len(
                        analysis[steamid]["view_angle_1"]) * 0.8:
                    detections += duplicates[dup]
                    case.append(2)

            start = analysis[steamid]["velocity"][0]
            checks = []
            aw = 0
            for vel in analysis[steamid]["velocity"]:
                if len(analysis[steamid]["velocity"]) > aw + 1:
                    checks.append(analysis[steamid]["velocity"][aw + 1] - vel)
                aw += 1

            intervals = []
            ai = 0
            for ena in analysis[steamid]["intervals"]:
                if len(analysis[steamid]["intervals"]) > ai + 1:
                    intervals.append(analysis[steamid]["intervals"][ai + 1] -
                                     ena)
                ai += 1

            aintervals = []
            aix = 0
            for q in intervals:
                if len(intervals) > aix + 1:
                    aintervals.append(
                        float(
                            round(intervals[aix + 1], 5) - float(round(q, 5))))
                aix += 1

            quelz = 0
            for f in aintervals:
                if abs(f) < 0.009:
                    detections += 2
                    quelz += 2
                else:
                    detections -= 1
                    quelz -= 1
            for q in checks:
                if q >= 5 and q <= 75:
                    speed_detection += 1
                else:
                    speed_detection -= 1

            if time.time() - analysis[steamid]["time"] > 1:
                speed_detection = speed_detection * (time.time() -
                                                     analysis[steamid]["time"])
            average = 0
            index = 1

            for item in analysis[steamid]["view_angle_0"]:
                index += 1
                average += item

            tell_average = float(average) / float(index)

            collect_data = []
            for x in analysis[steamid]["view_angle_0"]:

                if (x - tell_average) >= -1 and (x - tell_average) <= 4:
                    detections += 0.4

                else:
                    detections -= 1

                collect_data.append(x - tell_average)

            if speed_detection <= 0:
                detections += speed_detection

            if detections >= 5:
                es.server.queuecmd('es_setpos %s %s %s %s' %
                                   (userid, analysis[steamid]["location"][0],
                                    analysis[steamid]["location"][1],
                                    analysis[steamid]["location"][2]))
                StopSpeed(userid)
                if anti_cheat == 0:
                    esc.tell(
                        userid,
                        "#255,51,0[#255,137,0Anti-Cheat#255,51,0] #snowYeah... No"
                    )
                    case.append(3)
                    anti_cheat = 1

            distance = vecmath.distance(analysis[steamid]["location"],
                                        es.getplayerlocation(userid)) + 32

            if distance > 250 and analysis[steamid][
                    "strafes"] <= 2 and analysis[steamid]["location"][
                        2] - es.getplayerlocation(userid)[2] >= -5 and analysis[
                            steamid]["location"][2] - es.getplayerlocation(
                                userid)[2] <= 5 and distance < 280:
                if time.time(
                ) - analysis[steamid]["time"] >= 0.70 and time.time(
                ) - analysis[steamid]["time"] <= 0.9:

                    es.server.queuecmd(
                        'es_setpos %s %s %s %s' %
                        (userid, analysis[steamid]["location"][0],
                         analysis[steamid]["location"][1],
                         analysis[steamid]["location"][2]))
                    StopSpeed(userid)
                    if anti_cheat == 0:
                        esc.tell(
                            userid,
                            "#255,51,0[#255,137,0Anti-Cheat#255,51,0] #snowFalse positive - your data has been logged. Thank you for improving the anti-cheat"
                        )
                        #esc.msg(
                        #    "#255,51,0[#255,137,0Anti-Cheat#255,51,0]#snow %s is using silent-strafes" % (es.getplayername(userid)))
                        anti_cheat = 1
                        case.append(4)

            if anti_cheat == 1:
                esc.msg(
                    "#255,51,0[#255,137,0Anti-Cheat#255,51,0]#yellow %s #snowis cheating"
                    % (es.getplayername(userid)))
                analysis[steamid]["cheated"] = 1
                esc.tell(
                    userid,
                    "#255,51,0[#255,137,0Anti-Cheat#255,51,0] #snowTotal detections %s | %s | C#: %s"
                    % (detections, speed_detection, str(case)))
                dump_data_to_file(userid, case, detections, collect_data,
                                  checks, speed_detection)
            else:
                analysis[steamid]["loyal"] += 1

            if analysis[steamid]["loyal"] >= 300:
                analysis[steamid]["loyal"] = 1

                esc.tell(
                    userid,
                    "#255,51,0[#255,137,0Anti-Cheat#255,51,0] #snowYour data has been logged. Thank you for improving the anti-cheat! The machine is learning from you!"
                )

        analysis[steamid]["intervals"] = []
        analysis[steamid]["time"] = time.time()
        analysis[steamid]["velocity"] = []
        analysis[steamid]["view_angle_0"] = []
        analysis[steamid]["view_angle_1"] = []