Archived copy of warcraft-source.com, the Warcraft: Source (WCS) forum (2007–2011), rebuilt from the Internet Archive by wc3mods.net. This page was captured on 2010-03-30 (original capture). Home · Forum · All archived topics · Downloads

Author Topic: Tampering with Python  (Read 340 times)

Zawmbee

  • Guest
Tampering with Python
« on: October 30, 2009, 06:04:12 PM »
Well, just wondering if someone can look into this race and see any problems there may be...  First time coding with python, so I just looked at original coding and put a race together...  Appreciate any help, just looking to become educated with both python and regular...

Race: Riddick
Skills: (4)
[Combined Skills from Human Alliance and Night Elf]

1.) Stealth - Evasion and Invisibility mix.
2.) Furion Devotion - Extra Health
3.) Sweet Spot - Extra Damage and Bash mix.
4.) Rage of the Furion - Avatar settings re-arranged and modified.

Code: [Select]
import es
import random
import playerlib
import gamethread
 
import wcs
from wcs import wcs

raceName = 'Riddick'
race     = wcs.Race(raceName)

""" Load the strings into the variable text """
text     = race.loadStrings()


""" ### Begin the configuration ### """

config   = race.config()

config.addComment()
config.addComment('********************')
config.addComment('Stealth')
config.addComment('  This skill allows a player to have evasion and an invisibility effect')
config.addComment('********************')
config.addComment()
invisMaxlevel      = config.addVar('invisMaxlevel',      6,  'The maximum level of the Invisibility skill')
invisLevelInterval = config.addVar('invisLevelInterval', 2,  'The intervals between the abilities to upgrade their Invisibility skill')
invisibilityRating = config.addVar('invisibilityRating', 30, 'The effect that the invisibility skill will have... A relativly high value is 30, whereas a low value is 10.')

config.addComment()
config.addComment('********************')
config.addComment('Furion Devotion')
config.addComment('  This skill allows a player to spawn with more health')
config.addComment('********************')
config.addComment()
devotMaxlevel        = config.addVar('devotMaxlevel',         4, 'The maximum level of the Devotion skill')
devotLevelInterval   = config.addVar('devotLevelInterval',    1, 'The intervals between the abilities to upgrade their Devotion skill')
devotHealthIncrement = config.addVar('devotHealthIncrement', 25, 'The amount of health devotion gives the player, multiplied by their level')

config.addComment()
config.addComment('********************')
config.addComment('Sweet Spot')
config.addComment('  This skill has a chance to stun enemies')
config.addComment('  as well as causes internal bleeding')
config.addComment('  every time the player attacks another')
config.addComment('********************')
config.addComment()
sweetMaxlevel      = config.addVar('sweetMaxlevel',      4, 'The maximum level of the sweet spot skill')
sweetLevelInterval = config.addVar('sweetLevelInterval', 3, 'The intervals between the abilities to upgrade their sweet spot skill')
sweetPercentage    = config.addVar('sweetPercentage',    8, 'The chance a player will use their sweet spot skill, multiplied via their level')

config.addComment()
config.addComment('********************')
config.addComment('Rage of the Furion')
config.addComment('  This ultimate gives the player')
config.addComment('  better attributes for a certain')
config.addComment('  time, including health, speed and')
config.addComment('  extra damage. However, when the effect')
config.addComment('  runs out, the player will be severely')
config.addComment('  vulnerable.')
config.addComment('********************')
config.addComment()
rageMinLevel      = config.addVar('rageMinLevel',      8, 'The level required before a player can buy level 1 in the Avatar Skill')
rageMaxLevel      = config.addVar('rageMaxLevel',      3, 'The maximum level of the Avatar skill')
rageLevelInterval = config.addVar('rageLevelInterval', 4, 'The intervals between the abilities to upgrade their Avatar skill')
rageDuration      = config.addVar('rageDuration',      4, 'The number of seconds multiplied via their level that the Avatar effect will last for')
rageCoolDown      = config.addVar('rageCoolDown',      20, 'The amount of seconds after the avatar effect has worn off before the player can use the skill again.')

config.load(True)

""" ### END OF CONFIG ### """

if wcs.game is not 'Pirates, Vikings, and Knights':
    race.registerSkill('Stealth', int(invisMaxlevel), int(invisLevelInterval), 'Makes you partially invisible.')
race.registerSkill('Furion Devotion', int(devotMaxlevel), int(devotLevelInterval), 'Gives you additional health each round.')
race.registerSkill('Sweet Spot', int(sweetMaxlevel), int(sweetLevelInterval), 'Have a chance to stun and cause internal bleeding.')
race.registerUltimate('Rage of the Furion', int(rageMinLevel), int(rageLevelInterval), int(rageLevelInterval), 'Feel the Strength of the Furion.')

def player_spawn(ev):
    userid = int(ev['userid'])
    if not wcs.GetLevel(userid, raceName, 'Stealth'):
        wcs.Command(userid).Color(alpha=255)
    invisi(userid)
    devotion = wcs.GetLevel(userid, raceName, 'Furion Devotion') * int(devotHealthIncrement)
    if devotion:
        wcs.Command(userid).HealthAdd(devotion)
        es.tell(userid, '#multi', text('devotion', {'health' : devotion}, playerlib.getPlayer(userid).get("lang") ) )
        wcs.effect.Misc1(userid, 1)
    #wcs.Command(userid).UpdateDict('furion', 0)
    wcs.Command(userid)['furion'] = 0
    
def item_pickup(ev):
    userid = int(ev['userid'])
    #furion = wcs.Command(userid).ReturnDict('furion')
    furion = wcs.Command(userid)['furion']
    if not furion and wcs.dir != 'pvkii':
        invisi(userid)
        
def prep_hurt(ev):
    userid   = int(ev['userid'])
    attacker = int(ev['attacker'])
    if attacker:
        damage  = int(ev['dmg_health'])
        evasion = wcs.GetLevel(userid, raceName, 'Sweet Spot') * 5
        if evasion:
            if evasion >= random.randint(1,100):
                wcs.Command(userid).SaveLife(damage)
                es.tell(userid, '#multi', text('evasion', {'damage' : damage}, playerlib.getPlayer(userid).get("lang") ) )

def player_hurt(ev):
    userid   = int(ev['userid'])
    attacker = int(ev['attacker'])
    if attacker:
        damage = int(ev['dmg_health'])
        sweet spot   = wcs.GetLevel(attacker, raceName, 'Sweet Spot') * int(sweetPercentage)
        extra damage = wcs.GetLevel(attacker, raceName, 'Sweet Spot') * (30 * .01)
        if sweet spot >= random.randint(1,100):
            wcs.effect.Beam1(userid, attacker, 1.5, 0, 0, 255)
            wcs.Command(userid).Damage(damage * trueshot, 32, attacker)
            wcs.Command(userid).Freeze(4)
            es.tell(attacker, '#multi', text('sweet spot', {'damage' : damage * extra damage}, playerlib.getPlayer(attacker).get("lang") ) )
            es.tell(attacker, '#multi', text('sweet spot', {'victim' : es.getplayername(userid)}, playerlib.getPlayer(attacker).get("lang") ) )
            wcs.effect.Beam2(attacker, userid, 1.5, 0, 200, 150)
        if wcs.dir in ('cstrike', 'dod'):
            furion = wcs.GetLevel(attacker, raceName, 'Rage of the Furion')
            if furion:
                #state = wcs.Command(attacker).ReturnDict('furion')
                state = wcs.Command(attacker)['furion']
                if state:
                    wcs.Command(userid).Damage(damage * .3, 32, attacker)
                    
def player_ultimate_on(event_var):
    userid = int(event_var['userid'])
    furion = wcs.GetLevel(userid, raceName, 'Rage of the Furion') * int(rageDuration)
    #if fur and not wcs.Command(userid).ReturnDict('furion'):
    if furion and not wcs.Command(userid)['furion']:
        es.tell(userid, '#multi', text('furion on', {'time' : furion}, playerlib.getPlayer(userid).get("lang") ) )
        command = wcs.Command(userid)
        #wcs.Command(userid).UpdateDict('furion', 1)
        command['furion'] = 1
        command.HealthAdd(100)
        command.Color(red=255)
        command.Delayed(furion, furoff, userid)
        wcs.effect.Ring1(userid, 50, 2, 0, 50, 255)
        
def invisi(userid):
    invis = wcs.GetLevel(userid, raceName, 'Stealth')
    if invis:
        wcs.Command(userid).Color(alpha = 255 - (invis * int(invisibilityRating) + 90) )
        
def furoff(userid):
    command = wcs.Command(userid)
    #state = wcs.Command(userid).ReturnDict('furion')
    state = command['furion']
    if state:
        es.tell(userid, '#multi', text('furion off', lang = playerlib.getPlayer(userid).get("lang") ) )
        #command.UpdateDict('furion', 0)
        command['furion'] = 0
        command.SetCoolDown('Rage of the Furion', int(rageCoolDown) )
        invisi(userid)
        wcs.effect.Ring1(userid, 50, 2, 0, 255, 50)
        if es.getplayerprop(userid, 'CBasePlayer.m_iHealth') >= 101:
            wcs.Command(userid).HealthAdd(-100)
        else:
            wcs.Command(userid).Health(1)
« Last Edit: October 30, 2009, 06:23:17 PM by Zawmbee »

Offline DanMister

  • Level 7 Expert
  • *****
  • Posts: 205
  • no autographs, please.
Re: Tampering with Python
« Reply #1 on: October 31, 2009, 06:46:19 AM »
ok, all that "config" stuff at the begining isn't necessary! its just:

race.registerskill('name of skill',<level requirment>,<level cap>,'description of skill)

and thats it, then you go onto the next one.

and for the ultimate its just:

race.registerUltimate('ultimate name',<level requirement>,<level intervals>,<level cap>,('description of ultimate')


I'll go over the rest of the race later! but for now, i'd change that (I'm assuming it took you quite a bit of time to type all that config stuff  :P)
Quote


Quote
"Genius may have its limitations, but stupidity is not thus handicapped."   Elbert Hubbard


Zawmbee

  • Guest
Re: Tampering with Python
« Reply #2 on: October 31, 2009, 05:21:39 PM »
ok, all that "config" stuff at the begining isn't necessary! its just:

race.registerskill('name of skill',<level requirment>,<level cap>,'description of skill)

and thats it, then you go onto the next one.

and for the ultimate its just:

race.registerUltimate('ultimate name',<level requirement>,<level intervals>,<level cap>,('description of ultimate')


I'll go over the rest of the race later! but for now, i'd change that (I'm assuming it took you quite a bit of time to type all that config stuff  :P)


I just retyped the original codes that were in the original races such as human alliance... that was my only example for the moment to go based off of...  If it works for human alliance, it works for me... I don't mind typing a lot...

Offline F.o.R

  • Level 0 Beginner
  • Posts: 16
  • I'm a newb - I do my best - live with it
    • [D-u-G] Danish United Gamers
Re: Tampering with Python
« Reply #3 on: October 31, 2009, 06:01:46 PM »
wohoo, a race 4 me??

nice skillbuild!!!!
Wating for a new better working version of WCS:Python

Zawmbee

  • Guest
Re: Tampering with Python
« Reply #4 on: October 31, 2009, 07:07:20 PM »
wohoo, a race 4 me??

nice skillbuild!!!!


just trying to get familiar with python....

Offline DanMister

  • Level 7 Expert
  • *****
  • Posts: 205
  • no autographs, please.
Re: Tampering with Python
« Reply #5 on: November 01, 2009, 07:46:05 PM »
well, go to the python wcs wiki and look at there guides, there extremely helpful! : )
Quote


Quote
"Genius may have its limitations, but stupidity is not thus handicapped."   Elbert Hubbard


Offline DanMister

  • Level 7 Expert
  • *****
  • Posts: 205
  • no autographs, please.
Re: Tampering with Python
« Reply #6 on: November 28, 2009, 08:27:29 PM »
hey, zawmbee, if i re-made this/changed the skills up and added some effects and still gave you credit for the original idea.
would you mind? I can completely understand if you do its no big deal if you wish to keep the idea for yourself. just wondering cuz im running out of race ideas quick! :P
Quote


Quote
"Genius may have its limitations, but stupidity is not thus handicapped."   Elbert Hubbard


Offline AvasT

  • Level 7 Expert
  • *****
  • Posts: 825
Re: Tampering with Python
« Reply #7 on: November 28, 2009, 08:58:09 PM »
Hey zawmbee do u code python? :O
Lol?

Zawmbee

  • Guest
Re: Tampering with Python
« Reply #8 on: November 28, 2009, 09:39:00 PM »
hey, zawmbee, if i re-made this/changed the skills up and added some effects and still gave you credit for the original idea.
would you mind? I can completely understand if you do its no big deal if you wish to keep the idea for yourself. just wondering cuz im running out of race ideas quick! :P


Sure, I do not care...

Offline DanMister

  • Level 7 Expert
  • *****
  • Posts: 205
  • no autographs, please.
Re: Tampering with Python
« Reply #9 on: November 28, 2009, 09:44:40 PM »
thanks zawmbee! ill be sure to give you credit!
Quote


Quote
"Genius may have its limitations, but stupidity is not thus handicapped."   Elbert Hubbard