import es import gamethread import random import playerlib import time import wcs from wcs import wcs raceName = 'Grendal' race = wcs.Race(raceName) """ Load the strings into the variable text """ text = race.loadStrings() """ ############################### """ """ ### Begin the configuration ### """ """ ############################### """ config = race.config() raceMinLevel = config.addVar('raceMinLevel', 0, 'The minimum total level a user must have before having the ability to play Grendal') config.addComment() config.addComment('********************') config.addComment('Tar') config.addComment(' This skill has a chance of halving a players speed for X amount of seconds.') config.addComment('********************') config.addComment() tarMaxLevel = config.addVar('tarMaxLevel', 6, 'The maximum level of the Tar skill') tarLevelInterval = config.addVar('tarLevelInterval', 1, 'The intervals between the abilities to upgrade their Tar skill') tarPercentage = config.addVar('tarPercentage', 25, 'This is the chance the skill will happen multiplied by their level.') config.addComment() config.addComment('********************') config.addComment('Tar Pits') config.addComment(' This skill places a tar pit at the players current location which attackes') config.addComment(' nearby enemies. Used by pressing the ability +ability') config.addComment('********************') config.addComment() tarMaxLevel = config.addVar('tarMaxLevel', 8, 'The maximum level of the Tar Pits skill') tarLevelInterval = config.addVar('tarLevelInterval', 1, 'The intervals between the abilities to upgrade their Tar Pits skill') tarMaxPits = config.addVar('tarMaxPits', 5, 'The maximum amount of pits at any 1 time.') config.addComment() config.addComment('********************') config.addComment('Invisibility') config.addComment(' This skill allows a playe to spawn with a higher 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', 20, 'The effect that the invisibility skill will have... A relativly high value is 30, whereas a low value is 10.') config.load(True) """ ##################### """ """ ### END OF CONFIG ### """ """ ##################### """ race.registerSkill('Tar', int(tarMaxLevel), int(tarLevelInterval), 'Tar slows your enemy!') race.registerSkill('Tar Pit', int(tarMaxLevel), int(tarLevelInterval), 'Spits out a toxic tar pit to attack the Grendal\'s enemies (+ability)') race.registerSkill('Invisibility', int(invisMaxlevel), int(invisLevelInterval), 'Makes you partially invisible.') race.registerUltimate('Enemy Disarm',10,5,1,'Press +Ultimate to throw away your enemies weapons.') race.registerMinLevel(int(raceMinLevel)) tarPitsDict = {} class tarPits(object): def __init__(self, userid, index): self.userid = str(userid) self.team = es.getplayerteam(self.userid) self.level = wcs.GetLevel(self.userid, raceName, 'Tar Pit') self.index = str(index) self.start = 0 self.location = tuple() def addLocation(self, x, y = None, z = None): if not (isinstance(x, list) or isinstance(x, tuple)): x = tuple((x, y, z)) self.location = x self.start = time.time() def hurtLoop(self): if time.time() - self.start <= 20: x, y, z = self.location wcs.effect.RingCustom('#a', '0', 'sprites/lgtning.vmt', x, y, z, 20, self.level * 40, 1, 20, 100, 1, 255, 150, 70, 100, 10) for player in filter(lambda x: es.getplayerteam(x) != self.team and not es.getplayerprop(x, 'CBasePlayer.pl.deadflag'), es.getUseridList() ): xx, yy, zz = es.getplayerlocation(player) if ((xx - x) ** 2 + (yy - y) ** 2 + (zz - z) ** 2) ** 0.5 <= (self.level * 40): wcs.Command(player).Damage(self.level * random.randint(4,6), 32, self.userid) wcs.effect.BeamCustom('#a', '0', 'sprites/lgtning.vmt', x, y, z + 30, xx, yy, zz + 30, 1, 10, 20, 255, 150, 70, 255) gamethread.delayedname(1, 'tar_loop', self.hurtLoop) else: if es.exists('userid', self.userid): es.tell(self.userid, '#multi', text('tar pit dissolved', {'index' : self.index}, playerlib.getPlayer(self.userid).get("lang") ) ) if len(tarPitsDict[self.userid]) == 1: del tarPitsDict[self.userid] else: del tarPitsDict[self.userid][self.index] def player_ability_on(ev): userid = str(ev['userid']) tar = wcs.GetLevel(userid, raceName, 'Tar Pit') if tar: cooldown = wcs.Command(userid).GetCoolDown('Tar Pit') if not cooldown: if not tarPitsDict.has_key(userid) or len(tarPitsDict[userid]) < int(tarMaxPits): if not tarPitsDict.has_key(userid): tarPitsDict[userid] = {} instance = tarPitsDict[userid]['1'] = tarPits(userid, '1') else: index = str(max(map(int, tarPitsDict[userid])) + 1) instance = tarPitsDict[userid][index] = tarPits(userid, index) instance.addLocation(es.getplayerlocation(userid)) instance.hurtLoop() wcs.Command(userid).SetCoolDown('Tar Pit', 3) else: es.tell(userid, '#green', text('max pits', lang = playerlib.getPlayer(userid).get("lang") ) ) else: es.tell(userid, '#multi', text('cooldown', {'skill':'Tar Pit', 'time': cooldown}, playerlib.getPlayer(userid).get("lang") ) ) def round_end(ev): tarPitsDict.clear() gamethread.cancelDelayed('tar_loop') def player_disconnect(ev): userid = ev['userid'] if tarPitsDict.has_key(userid): del tarPitsDict[userid] def player_hurt(ev): userid = int(ev['userid']) attacker = int(ev['attacker']) if ev['es_userteam'] != ev['es_attackerteam'] and attacker and not wcs.Command(userid).ReturnDict('Tared'): Tar = wcs.GetLevel(attacker, raceName, 'Tar') if Tar and (random.randint(1,100) <= (int(tarPercentage) * Tar)): wcs.Command(userid).UpdateDict('Tared', 1) speed = wcs.Command(userid).ReturnDict('Speed') divider = speed/(1 + (Tar * 0.3)) # This should divide the speed by: 1.2, 1.4, 1.6, 1.8, 2.0, 2.2 wcs.Command(userid).Speed(speed / divider) tokens = {} tokens['speed'] = round(125 * divider * speed, 1) tokens['attacker'] = ev['es_attackername'] tokens['victim'] = ev['es_username'] es.tell(userid, '#multi', text('tar victim', tokens, playerlib.getPlayer(userid).get("lang") ) ) es.tell(attacker, '#multi', text('tar attacker', tokens, playerlib.getPlayer(attacker).get("lang") ) ) gamethread.delayed(3, wcs.Command(userid).Speed, speed) gamethread.delayed(3, wcs.Command(userid).UpdateDict, ('Tared', 0) ) def player_ultimate_on(ev): userid = int(ev['userid']) dz = wcs.GetLevel(userid, raceName, 'Enemy Disarm') team = int(es.getplayerteam(userid)) if team == 2: filter = '#ct' elif team == 3: filter = '#t' if wcs.GetRace(userid) == 'Grendal': if dz: wcs.Command(userid).Near(dz*100,drop,filter) wcs.Command(userid).SetCoolDown('Enemy Disarm',dz*2) wcs.Effect().Ring1(userid, dz*100, 2, 244, 164, 96) es.tell(userid, '#multi', '#lightgreenEnemy Disarm #default- #greenYou have thrown away your enemies weapons.') def drop(userid, attacker): wcs.Command(userid).Drop() es.tell(userid, '#multi', '#lightgreenEnemy Disarm #default- #greenGrendal snatches your weapons away!') def player_spawn(ev): userid = int(ev['userid']) invis = wcs.GetLevel(userid, raceName, 'Invisibility') wcs.Command(userid).Color(alpha=255) invisi(userid) def invisi(userid): invis = wcs.GetLevel(userid, raceName, 'Invisibility') if invis: wcs.Command(userid).Color(alpha = 255 - (invis * int(invisibilityRating) + 90) )