November 20, 2017, 10:19:58 AM

Author Topic: [Skill] Tweak  (Read 10953 times)

Offline Goku

  • Level 7 Expert
  • *****
  • Posts: 154
  • Country: 00
  • Decend.
    • World Wide Terror
[Skill] Tweak
« on: April 17, 2014, 10:38:14 AM »
Tweak
Something I randomly thought up over the last hour or so. Tweak is an ultimate. When used, you receive a certain amount of "drugs" described by a tell event. Using the ultimate registers the command !inject. This is the second part of the ultimate. To actually receive any effect of the ultimate, the user must type !inject. Once input, depending on how much drugs you were given, it will give you a certain speed boost as well as drug induced screen. This skill can be customized to the user's/server operators liking, by simply changing some values within the Python file. You  can make each level of drug injection do whatever you want it to, for how long you want it to. Also, please read the readme file included in the .zip as it contains some important instructions (while basic)  on how to setup the skill. Here is the source code itself and some of the things you can change within it:

Code: [Select]
import es
import random
import usermsg
import cmdlib


def pytweak():
global dosage
global wcs_user
userid = int(es.ServerVar("wcs_userid"))
wcs_user = int(userid)
has_tweaked = es.exists('saycommand', '!inject')
if has_tweaked == 0:
cmdlib.registerSayCommand('!inject', inject, "Injects your dose.")
dosage = random.randint(1, 100)
es.tell(userid, '#multi', "#green[Tweak]#lightgreen Type !inject to inject %i g of opiates into your blood." % dosage)
else:
es.tell(userid, '#multi', "#green[Tweak]#lightgreen Sorry, you've already prepared your dose.")


def inject(userid, args):
es.set('extra', wcs_user)
if userid == wcs_user:
es.tell(userid, '#multi', "#green[Tweak]#lightgreen You've taken the opiates. Prepare yourself.")
if dosage >= 1 and dosage <= 25:
#es.tell(userid, "Dosage was 1 - 25") <---------------customize
usermsg.fade(userid, 0, 1, 2500, 0, 55, 200, 175)  # <-----------customize
es.server.queuecmd('es wcs_setfx speed server_var(extra) = 1.25') #<--------------customize
es.delayed(5, "es wcs_setfx speed server_var(extra) = 1.0") #<------------------customize
if dosage >= 26 and dosage <= 50:
#es.tell(userid, "Dosage was 26 - 50")
usermsg.fade(userid, 0, 1, 5000, 55, 150, 0, 175)
es.server.queuecmd('es wcs_setfx speed server_var(extra) = 1.50')
es.delayed(10, "es wcs_setfx speed server_var(extra) = 1.0")
if dosage >= 51 and dosage <= 75:
#es.tell(userid, "Dosage was 51 - 75")
usermsg.fade(userid, 0, 1, 7500, 200, 0, 25, 175)
es.server.queuecmd('es wcs_setfx speed server_var(extra) = 1.75')
es.delayed(15, "es wcs_setfx speed server_var(extra) = 1.0")
if dosage >= 76 and dosage <= 100:
#es.tell(userid, "Dosage was 76 - 100")
usermsg.fade(userid, 0, 1, 10000, 255, 255, 255, 155)
es.server.queuecmd('es wcs_setfx speed server_var(extra) = 2.0')
es.delayed(20, "es wcs_setfx speed server_var(extra) = 1.0")
cmdlib.unregisterSayCommand('!inject')
else:
es.tell(userid, '#multi', '#green[WCS]#lightgreen Sorry, but you are not authorized to run that command.')


def unload():
cmdlib.unregisterSayCommand('!inject')

The lines where I have arrows pointing to the code and the word customize next to it are where you can put the effects you want, as in the actual skill, not special effects. This also applies to the lines below it that are in the same format, but that I just didn't want to draw lines for as it's 2:30 am and I'm tired. You can also change the actual command itself as well as the text events. I wouldn't recommend changing anything else unless you know how to code in Python as it can screw with stuff on your server and/or cause the skill/plugin to break. I'll also include in this post, below, the simple test race I used the skill on, as a general format:

Code: [Select]
[Tweak]

    required           = 0

    maximum            = 0

    restrictteam       = 0

    teamlimit          = 0

    restrictmap        = ""

    restrictitem       = "sockf50"

    author             = "Mizery"

    desc               = ""

    spawncmd           = ""

    deathcmd           = ""

    roundstartcmd      = ""

    roundendcmd        = ""

    preloadcmd         = ""

    allowonly          = "STEAM_0:1:46426328"

    racecategory       = "Private races"

    onchange           = ""

    numberofskills     = 1

    numberoflevels     = 1

    skillnames         = "Python Power"

    skilldescr         = "The power of the py."

    skillcfg           = "player_ultimate"

    skillneeded        = "0"

   

    [[skill1]]

        setting        = ""

        cmd            = "es_doblock tweak/pytweak; es_set wcs_userid server_var(wcs_userid)"

        sfx            = ""

        cooldown       = "21"

If anything is not working, please post here, or fix yourself if you know how to. I'll be more than happy to fix anything that's going on with it or troubleshoot why it's not working on your server. I'm also open to customizing it to the needs of your server, if you just ask and tell me what exactly you need. Thanks.

=-=MizeЯy=-=
"The whole secret of existence is to have no fear. Never fear what will become of you, depend on no one. Only the moment you reject all help are you freed."

Offline Kamiqawa

  • Watchdog
  • Level 7 Expert
  • *****
  • Posts: 779
  • Country: fi
Re: [Skill] Tweak
« Reply #1 on: April 17, 2014, 10:54:30 AM »
YAY PYTHON!

Well this looks really unique and new :o Great job!! I will look through the code and give it a try in a minute.

Ps. race probably has to has some placeholder command in it's setting or it may give an error
Want your own custom color for your forum username? No worries! La Muerte is here ready to fulfill your every rainbow-colored wish!

As a special offer of the day you can go talk with Tha Pwned first, and come ahead of the line!

I AM PINK!


Offline Goku

  • Level 7 Expert
  • *****
  • Posts: 154
  • Country: 00
  • Decend.
    • World Wide Terror
Re: [Skill] Tweak
« Reply #2 on: April 17, 2014, 10:56:23 AM »
Like I said, if anything is wrong, it's because it's now 3 in the morning. Everything worked fine for me though. I'm so tired, I'll even add a smiley face because that came across as grouchy lol. :)
"The whole secret of existence is to have no fear. Never fear what will become of you, depend on no one. Only the moment you reject all help are you freed."

Offline Goku

  • Level 7 Expert
  • *****
  • Posts: 154
  • Country: 00
  • Decend.
    • World Wide Terror
Re: [Skill] Tweak
« Reply #3 on: April 17, 2014, 11:12:54 AM »
Also, one thing I planned on doing beyond what is already there is adding a get function so you can recheck your dosage before you use it. I was working with dictionaries earlier, but I decided against it as I'd rather just have already set groups of dosages and plus it's a lot messier. When I get around to it, the function will essentially work like this:

Code: [Select]
if args[0] == "get":
    es.tell(userid, '#multi', "#green[Tweaker]#lightgreen Your current set dosage is: %i grams." % dosage)

Syntax, in general, will be:

Code: [Select]
!inject <set/get> , set being the original, plain !inject, or !inject with no arguments being the same as it is currently.
"The whole secret of existence is to have no fear. Never fear what will become of you, depend on no one. Only the moment you reject all help are you freed."

Offline Kamiqawa

  • Watchdog
  • Level 7 Expert
  • *****
  • Posts: 779
  • Country: fi
Re: [Skill] Tweak
« Reply #4 on: April 17, 2014, 01:11:13 PM »
Hmm.. first off I found your code a bit strange: on ultimate press register a say cmd and later unregister it... But I guess it works fine afterall. Only thing I can imagine messing the thing up is another instance of this race using the ultimate at the same time... But yeah, anyways, it's a really nice and unique skill and I like it overall.

Thanks for contributing and sharing your code!
Want your own custom color for your forum username? No worries! La Muerte is here ready to fulfill your every rainbow-colored wish!

As a special offer of the day you can go talk with Tha Pwned first, and come ahead of the line!

I AM PINK!


Offline Joao

  • Level 7 Expert
  • *****
  • Posts: 604
  • Country: br
Re: [Skill] Tweak
« Reply #5 on: April 19, 2014, 04:43:29 AM »
can you add some cool sfx/effects to it?

Offline Tha Pwned

  • Watchdog
  • Level 7 Expert
  • *****
  • Posts: 201
  • Country: dk
  • 5% coder, 85% derp, 10% herp
Re: [Skill] Tweak
« Reply #6 on: April 19, 2014, 05:54:55 AM »
It's 5:54 in the morning and I'm bored:
Code: [Select]
import cmdlib
import es
import gamethread
import random
import usermsg

from wcs.core.wcsgroup import wcsgroup


userid = es.ServerVar('wcs_userid')
speed = es.ServerVar('wcs_speed')


def pytweak():
    dosage = random.randint(1, 99)

    es.tell(userid, '#multi', '#green[Tweak]#lightgreen Type !inject to inject %s g of opiates into your blood.' % dosage)

    wcsgroup.setUser(userid, 'opiates_dosage', dosage/25)

def inject(userid, args):
    dosage = wcsgroup.getUser(userid, 'opiates_dosage')

    if dosage:
        es.tell(userid, '#multi', '#green[Tweak]#lightgreen You\'ve taken the opiates. Prepare yourself.')

        es.setplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue', es.getplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue')+speed*dosage)

        gamethread.delayed(5*dosage, lambda userid, speed: es.setplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue', es.getplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue')-speed), (userid, speed*dosage))

        usermsg.fade(userid, 0, 1, 2500*dosage, (dosage-1)*55, *((0, 55, 200, 175), (55, 150, 0, 175), (200, 0, 25, 175), (255, 255, 255, 155))[dosage-1])

        wcsgroup.setUser(userid, 'opiates_dosage', 0)

def load():
    cmdlib.registerSayCommand('!inject', inject, 'Injects your dose.')

def unload():
    cmdlib.unregisterSayCommand('!inject')

And for the skill:
Code: [Select]
[[skill1]]
    setting        = "es_xset wcs_speed 0.25;es_xset wcs_speed 0.25;es_xset wcs_speed 0.25;es_xset wcs_speed 0.25"
    cmd            = "es_xdoblock tweak/pytweak"
    sfx            = ""
    cooldown      = "21"

Remember to place:
Code: [Select]
es wcsgroup set server_var(wcs_userid) opiates_dosage 0
in the onchange key. I haven't tested it, as I'm not bored enough for that.
Quote from: La Muerte
17:44 - #La Muerte: FU whipe your ass so you hear better!
Quote from: La Muerte
13:41 - Muerte: what is it with you and I talking about asses in eachothers quotes?
13:41 - Muerte: ass buddies!
If you need help, got a question about Python, or just need to chat with a friendly guy, feel free to add me on Steam.

Offline Joao

  • Level 7 Expert
  • *****
  • Posts: 604
  • Country: br
Re: [Skill] Tweak
« Reply #7 on: April 19, 2014, 06:02:51 AM »
It's 5:54 in the morning and I'm bored:
Code: [Select]
import cmdlib
import es
import gamethread
import random
import usermsg

from wcs.core.wcsgroup import wcsgroup


userid = es.ServerVar('wcs_userid')
speed = es.ServerVar('wcs_speed')


def pytweak():
    dosage = random.randint(1, 99)

    es.tell(userid, '#multi', '#green[Tweak]#lightgreen Type !inject to inject %s g of opiates into your blood.' % dosage)

    wcsgroup.setUser(userid, 'opiates_dosage', dosage/25)

def inject(userid, args):
    dosage = wcsgroup.getUser(userid, 'opiates_dosage')

    if dosage:
        es.tell(userid, '#multi', '#green[Tweak]#lightgreen You\'ve taken the opiates. Prepare yourself.')

        es.setplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue', es.getplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue')+speed*dosage)

        gamethread.delayed(5*dosage, lambda userid, speed: es.setplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue', es.getplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue')-speed), (userid, speed*dosage))

        usermsg.fade(userid, 0, 1, 2500*dosage, (dosage-1)*55, *((0, 55, 200, 175), (55, 150, 0, 175), (200, 0, 25, 175), (255, 255, 255, 155))[dosage-1])

        wcsgroup.setUser(userid, 'opiates_dosage', 0)

def load():
    cmdlib.registerSayCommand('!inject', inject, 'Injects your dose.')

def unload():
    cmdlib.unregisterSayCommand('!inject')

And for the skill:
Code: [Select]
[[skill1]]
    setting        = "es_xset wcs_speed 0.25;es_xset wcs_speed 0.25;es_xset wcs_speed 0.25;es_xset wcs_speed 0.25"
    cmd            = "es_xdoblock tweak/pytweak"
    sfx            = ""
    cooldown      = "21"

Remember to place:
Code: [Select]
es wcsgroup set server_var(wcs_userid) opiates_dosage 0
in the onchange key. I haven't tested it, as I'm not bored enough for that.


    setting        = "es_xset wcs_speed 0.25|es_xset wcs_speed 0.25|es_xset wcs_speed 0.25|es_xset wcs_speed"

i guess? what u changed btw?

Offline Tha Pwned

  • Watchdog
  • Level 7 Expert
  • *****
  • Posts: 201
  • Country: dk
  • 5% coder, 85% derp, 10% herp
Re: [Skill] Tweak
« Reply #8 on: April 19, 2014, 06:16:26 AM »
It's 5:54 in the morning and I'm bored:
Code: [Select]
import cmdlib
import es
import gamethread
import random
import usermsg

from wcs.core.wcsgroup import wcsgroup


userid = es.ServerVar('wcs_userid')
speed = es.ServerVar('wcs_speed')


def pytweak():
    dosage = random.randint(1, 99)

    es.tell(userid, '#multi', '#green[Tweak]#lightgreen Type !inject to inject %s g of opiates into your blood.' % dosage)

    wcsgroup.setUser(userid, 'opiates_dosage', dosage/25)

def inject(userid, args):
    dosage = wcsgroup.getUser(userid, 'opiates_dosage')

    if dosage:
        es.tell(userid, '#multi', '#green[Tweak]#lightgreen You\'ve taken the opiates. Prepare yourself.')

        es.setplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue', es.getplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue')+speed*dosage)

        gamethread.delayed(5*dosage, lambda userid, speed: es.setplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue', es.getplayerprop(userid, 'CBasePlayer.localdata.m_flLaggedMovementValue')-speed), (userid, speed*dosage))

        usermsg.fade(userid, 0, 1, 2500*dosage, (dosage-1)*55, *((0, 55, 200, 175), (55, 150, 0, 175), (200, 0, 25, 175), (255, 255, 255, 155))[dosage-1])

        wcsgroup.setUser(userid, 'opiates_dosage', 0)

def load():
    cmdlib.registerSayCommand('!inject', inject, 'Injects your dose.')

def unload():
    cmdlib.unregisterSayCommand('!inject')

And for the skill:
Code: [Select]
[[skill1]]
    setting        = "es_xset wcs_speed 0.25;es_xset wcs_speed 0.25;es_xset wcs_speed 0.25;es_xset wcs_speed 0.25"
    cmd            = "es_xdoblock tweak/pytweak"
    sfx            = ""
    cooldown      = "21"

Remember to place:
Code: [Select]
es wcsgroup set server_var(wcs_userid) opiates_dosage 0
in the onchange key. I haven't tested it, as I'm not bored enough for that.


    setting        = "es_xset wcs_speed 0.25|es_xset wcs_speed 0.25|es_xset wcs_speed 0.25|es_xset wcs_speed"

i guess? what u changed btw?
I modified the code to be more effecient, does allow multiple users to use it, allow modifying the setting (speed) on multiple races, and fixed it, so it wouldn't break the speed of the players.
Quote from: La Muerte
17:44 - #La Muerte: FU whipe your ass so you hear better!
Quote from: La Muerte
13:41 - Muerte: what is it with you and I talking about asses in eachothers quotes?
13:41 - Muerte: ass buddies!
If you need help, got a question about Python, or just need to chat with a friendly guy, feel free to add me on Steam.

Offline Goku

  • Level 7 Expert
  • *****
  • Posts: 154
  • Country: 00
  • Decend.
    • World Wide Terror
Re: [Skill] Tweak
« Reply #9 on: April 19, 2014, 06:25:33 AM »
You have to love being bored at 5'oclockish in the morning. Anyway, yes, I'll add some effects to it in a little while and post back.
"The whole secret of existence is to have no fear. Never fear what will become of you, depend on no one. Only the moment you reject all help are you freed."

Offline Muerte

  • Administrator
  • Level 7 Expert
  • *****
  • Posts: 1801
  • Country: be
    • Fortitude
Re: [Skill] Tweak
« Reply #10 on: April 19, 2014, 12:52:21 PM »
MizeRy, you must be awesome if you can get tha pwned to actually log in and post on a forum (normally he is to lazy to even consider doing it) :D

Great skill :o
Anyways why you all code so late? Or early? Don't you guys sleep at all?
Sleep? What's that? Just put a wire up your arse and charge while you code during the night. Doesn't all do that, or is it just me??

Offline Kamiqawa

  • Watchdog
  • Level 7 Expert
  • *****
  • Posts: 779
  • Country: fi
Re: [Skill] Tweak
« Reply #11 on: April 19, 2014, 01:09:20 PM »
Agreed with La Muerte; getting Tha Pwned to comment on your stuff is a great honor and achievement ;D

As I said, already it's a really nice idea to make a skill like that. Anyways why you all code so late? Or early? Don't you guys sleep at all?
Want your own custom color for your forum username? No worries! La Muerte is here ready to fulfill your every rainbow-colored wish!

As a special offer of the day you can go talk with Tha Pwned first, and come ahead of the line!

I AM PINK!


Offline Tha Pwned

  • Watchdog
  • Level 7 Expert
  • *****
  • Posts: 201
  • Country: dk
  • 5% coder, 85% derp, 10% herp
Re: [Skill] Tweak
« Reply #12 on: April 19, 2014, 01:21:39 PM »
Anyways why you all code so late? Or early? Don't you guys sleep at all?
Sleep? What's that? Just put a wire up your arse and charge while you code during the night. Doesn't all do that, or is it just me??
Quote from: La Muerte
17:44 - #La Muerte: FU whipe your ass so you hear better!
Quote from: La Muerte
13:41 - Muerte: what is it with you and I talking about asses in eachothers quotes?
13:41 - Muerte: ass buddies!
If you need help, got a question about Python, or just need to chat with a friendly guy, feel free to add me on Steam.

Offline Ryziou

  • Level 2 Apprentice
  • **
  • Posts: 56
  • Why is this blank?
Re: [Skill] Tweak
« Reply #13 on: April 19, 2014, 02:53:33 PM »
Anyways why you all code so late? Or early? Don't you guys sleep at all?
Sleep? What's that? Just put a wire up your arse and charge while you code during the night. Doesn't all do that, or is it just me??

Lmao, that must be a new technique that I've never heard of! I usually just stay up till 5am watching stuff :l

Offline Joao

  • Level 7 Expert
  • *****
  • Posts: 604
  • Country: br
Re: [Skill] Tweak
« Reply #14 on: April 19, 2014, 04:41:02 PM »
You have to love being bored at 5'oclockish in the morning. Anyway, yes, I'll add some effects to it in a little while and post back.

k appreciate it but hope you do it on Pwned's code right ? ;]

I was thinking about some kind of green effect like puking or something... can you think of anything?