''' Copyright (C) 2011 by Aurora Pariseau Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software; the original author's name is included and/or given credit in all copies of the software; a copy of this license is included with the software. Permission is denied to merge, publish, distribute, sublicense, and/or sell copies of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' from __future__ import with_statement import es, os.path, cPickle, popuplib, random, spe, gamethread, time, cfglib info = es.AddonInfo() info.name = "World of Hell: Diablo" info.version = "0.1.r1234" info.author = "Aurora Pariseau" info.url = "http://addons.eventscripts.com/addons/view/wohd" info.description = 'Players gain abilities through a class and random items!' es.ServerVar('wohd_version',info.version,'World of Hell: Diablo By: %s'%info.author).makepublic() # NO NEED TO OPEN THIS SCRIPT TO CHANGE SETTINGS # AFTER LOADING, EDIT THE "wohd.CFG" FILE IN THE wohd FOLDER, THEN RESTART SERVER '''''''''''''''''''''''''''''''''''''''''''''''' config = cfglib.AddonCFG(es.getAddonPath("wohd") + "/wohd.cfg") config.text("******************************") config.text(" WORLD OF HELL SETTINGS") config.text("*****************************") config.text("Be careful when setting the names of commands so that they do not interfere") config.text("with other scripts you are running") config.text("******************************") wohd_menuCommand = config.cvar("wohd_menu", "/menu", "Text used to open the menu") wohd_resetAbilities = config.cvar("wohd_reset", "/reset", "Command used for a player to reset their abilities") wohd_resetEverything = config.cvar("wohd_global_reset", "/wohd_default", "Command used to restart EVERYONES abilities, requires RCON") wohd_killExp = config.cvar("wohd_exp", 50, "Amount of XP Gained for each kill") wohd_roundExp = config.cvar("wohd_roundExp", 40, "Amount of XP Gained for winning the round") wohd_bomb_plantedExp = config.cvar("wohd_plantedExp", 25, "Amount of XP Gained for planting the bomb") wohd_bomb_explodedExp = config.cvar("wohd_explodedExp", 25, "Amount of XP Gained for the bomb exploding") wohd_bomb_defusedExp = config.cvar("wohd_defusedExp", 50, "Amount of XP Gained for defusing the bomb") wohd_rescueExp = config.cvar("wohd_rescueExp", 10, "Amount of XP Gained for rescuing a hostage") wohd_allExp = config.cvar("wohd_allExp", 10, "Amount of XP Gained for rescuing all hostages") wohd_experiencePerLevel = config.cvar("wohd_experiencePerLevel", 2000, "The experience needed to get to the next level multipled by current level; wohd_experiencePerLevel X Current Level = experience needed for next level") wohd_levelCap = config.cvar("wohd_levelCap", 99, "The maximum level someone can achieve") wohd_skillPerLevel = config.cvar("wohd_skillPerLevel", 1, "The number of skills per level a player earns") config.write() # DO NOT EDIT BELOW THIS LINE OR THINGS MAY BREAK es.ServerVar('wohd_debug', 0) players = {} classes = [ 'Amazon', 'Barbarian', 'Druid', 'Paladin', 'Sorceror', 'Witch Doctor' ] AmazonSkills = ['Impale','Lightning Bolt','Dodge','Penetrate','Pierce','Cold Arrow','Lightning Strike'] items = [ 'Weapon', 'Armor', 'Ring', 'Amulet', 'Runestone', 'Jewel', 'Gem' ] def changeTeam(userid, newTeam, classId=0): '''Changes a player to a new team.''' if not es.exists('userid', userid): raise ValueError('userid (%s) doesn\'t exist.' % userid) # Change to new team es.changeteam(userid, newTeam) # No need to set class and hide menus if we aren't joining an active team if newTeam not in (2, 3): return # Get a random class if classId == 0: classId = random.randint(1, 4) # Terrorist if newteam == 2: es.setplayerprop(userid, 'CCSPlayer.m_iClass', classId) usermsg.showVGUIPanel(userid, 'class_ter', False, {}) # Counter-Terrorist else: es.setplayerprop(userid, 'CCSPlayer.m_iClass', classId+4) usermsg.showVGUIPanel(userid, 'class_ct', False, {}) def debug(message): if es.ServerVar('wohd_debug') == 1: es.msg('#multi', '#default', '[DIABLO]', '#green', message) def wohdMsg(message): es.msg('#multi', '#default', '[DIABLO]', '#green', message) def wohdTell(userid, message): es.tell(userid, '#multi', '#default', '[DIABLO]', '#green', message) def load(): config.execute() global players, round_started, unlocks round_started = 0 str_path = es.getAddonPath('wohd') + '/wohd.db' if os.path.isfile(str_path): file_users = open(str_path) players = cPickle.load(file_users) file_users.close() wohdMsg('Skill Database loaded succesfully') spe.registerPreHook("player_hurt", prepHurt) global main, classmenu, info main = popuplib.create('main') main.addline('World of Hell: Diablo Main Menu:') main.addline(':::::::::::::::::::') main.addline('-> 1. Classes') main.addline('-> 2. Skill Tree') main.addline('-> 3. Stats') main.addline('-> 4. Current Skills') main.addline('-> 5. Player Info') main.addline('-> 7. Help') main.addline(':::::::::::::::::::') main.addline('-> 8. Reset My Skills') main.addline('0. Exit') main.submenu(1, 'classmenu') main.submenu(7, 'infomenu') main.menuselect = mainSelection infomenu = popuplib.create('infomenu') infomenu.addline('WoH: Diablo Help Menu:') infomenu.addline(':::::::::::::::::::') infomenu.addline('This mod resembles the Diablo 2') infomenu.addline('game. By selecting a class and ') infomenu.addline('choosing skills in your tree, ') infomenu.addline('you gain special abilities. You') infomenu.addline('gain XP with kills and by doing ') infomenu.addline('objectives, making you stronger ') infomenu.addline('and giving you more skills.') infomenu.addline('Type "%s" to reopen the menu.'%wohd_menuCommand) infomenu.addline('bind ""') classmenu = popuplib.create('classmenu') classmenu.addline('WOH: Diablo Class Menu:') classmenu.addline(':::::::::::::::::::') x = 1 for i in classes: classmenu.addline('-> %i. %s'%(x, i)) x+=1 classmenu.addline(':::::::::::::::::::') classmenu.addline('-> 8. Main Menu') classmenu.addline('0. Exit') classmenu.submenu(8, 'main') classmenu.menuselect = classmenuselection es.unregsaycmd(wohd_menuCommand) es.regsaycmd(wohd_menuCommand, 'wohd/sendMain') es.unregclientcmd(wohd_resetAbilities) es.regclientcmd(wohd_resetAbilities, 'wohd/resetabilities') es.unregclientcmd('ability', 'wohd/ability') es.regclientcmd('ability') es.unregclientcmd('test') es.regclientcmd('test', 'wohd/test') #es.regcmd('cheat', 'wohd/cheat') es.regcmd(wohd_resetEverything, 'wohd/reset') es.regcmd('set', 'wohd/set') def es_map_start(ev): with open(es.getAddonPath('wohd') + "/filelist.txt") as f: for line in f: print es.stringtable("downloadables", "sound/wohd/" + line) def sendMain(): global main main.send(es.getcmduserid()) # Finish this soon def mainSelection(userid, choice, popupid): if choice == 2: skillmenu(userid) if choice == 3: sendinfo(userid, userid) if choice == 4: currentSkills(userid) if choice == 7: userid = es.getcmduserid() infomenu.send(userid) if choice == 5: playerinfo = '' if popuplib.exists('playerinfo'): popuplib.delete('playerinfo') playerinfo = popuplib.easymenu('playerinfo', '_popup_choice', choosePlayer) for x in es.getUseridList(): playerinfo.addoption(x, es.getplayername(x)) playerinfo.send(userid) if choice == 8: tempmenu = popuplib.create('tempmenu') tempmenu.addline('WoH: Diablo Reset Abilities Menu:') tempmenu.addline('::::::::::::::::::::') tempmenu.addline('CAUTION: DOING THIS WILL DELETE YOUR') tempmenu.addline('LEVELs, SKILLS, AND CURRENT XP') tempmenu.addline('YOU WILL NOT BE REFUNDED THIS AMOUNT') tempmenu.addline('ENTER "%s" in console'%resetAbilities) tempmenu.send(userid) popuplib.delete('tempmenu') def choosePlayer(userid, choice, popupid): sendinfo(userid, choice) def sendinfo(userid, target): player = Player(target) Class = player.getItem('Class') level = player.getLevel() xp = player.getExp() str = player.getItem('Strength') dex = player.getItem('Dexterity') vit = player.getItem('Vitality') eng = player.getItem('Energy') mana = player.getItem('Mana') armor = player.getItem('Armor') skillPoints = player.getSkillPoints() resistance = player.getItem('Resistance') connected = time.ctime(player.getItem('Last Connected')) statmenu1 = '' if popuplib.exists('stat1menu'): statmenu1 = popuplib.find('stat1menu') else: statmenu1 = popuplib.create('stat1menu') statmenu1.addline('') statmenu1.addline('') statmenu1.addline('') statmenu1.addline('') statmenu1.addline('') statmenu1.addline('') statmenu1.addline('') statmenu1.addline('') statmenu1.addline('') statmenu1.modline(1, 'WOH: Diablo Stat Menu:') statmenu1.modline(2, ':::::::::::::::::::') statmenu1.modline(3, '%ss Stats:'%es.getplayername(target)) if not level: statmenu1.modline(4, 'No class selected') else: statmenu1.modline(4, 'Level %s %s %s XP/%s XP'%(level, Class, xp, level * wohd_experiencePerLevel)) statmenu1.modline(5, 'Strength: %s Dexterity: %s Vitality: %s Energy: %s'%(str, dex, vit, eng)) statmenu1.modline(6, 'Mana: %s Armor: %s Resistance: %s'%(mana, armor, resistance)) statmenu1.modline(7, 'Free Skill Points: %i'%skillPoints) statmenu1.modline(8, 'Last Connected: %s'%connected) statmenu1.modline(9, '-> 0. Exit') statmenu1.send(userid) popuplib.delete('stat1menu') def classmenuselection(userid, choice, popupid): if choice < 8: Class = classes[choice - 1] Player(userid).setItem('Pick', choice) tempclasschoice = '' if popuplib.exists(Class): popuplib.delete(Class) tempclasschoice = popuplib.create(Class) tempclasschoice.addline('WoH: Diablo %s'%Class) tempclasschoice.addline(':::::::::::::::::::') if Class == 'Amazon': tempclasschoice.addline('The Amazon is a quick combatant') tempclasschoice.addline('excelling in quick skirmishes or') tempclasschoice.addline('long ranged combat. Gains bonuses') tempclasschoice.addline('with SMGs, pistols, and snipers') if Class == 'Assassin': tempclasschoice.addline('The Assassin is a close-combat') tempclasschoice.addline('expert, utilizing combos to swiftly') tempclasschoice.addline('exterminate enemies with a variety') tempclasschoice.addline('of magical attacks') if Class == 'Barbarian': tempclasschoice.addline('The Barbarian is a brutish wariror') tempclasschoice.addline('that relies on sheer strength and') tempclasschoice.addline('power to annihilate anyone who') tempclasschoice.addline('opposes him.') if Class == 'Druid': tempclasschoice.addline('The Druid harnesses the power of') tempclasschoice.addline('nature to morph into beasts to') tempclasschoice.addline('to tear his enemy to shreds, or') tempclasschoice.addline('or fries them with the elements.') if Class == 'Necromancer': tempclasschoice.addline('The Necromancer curses and devours') tempclasschoice.addline('the souls of others on his search') tempclasschoice.addline('for power over the spirit world.') tempclasschoice.addline('Excells at demorilizing others.') if Class == 'Paladin': tempclasschoice.addline('The Paladin calls upon the holy') tempclasschoice.addline('forces to protect and smite those') tempclasschoice.addline('who seek to corrupt the world.') tempclasschoice.addline('Provides auras and offensive capabilities') if Class == 'Sorceress': tempclasschoice.addline('The Sorceress casts either fire or') tempclasschoice.addline('electrical spells with which to') tempclasschoice.addline('decimate even the biggest adversaries,') tempclasschoice.addline('and applying various detrimental effects.') tempclasschoice.addline(':::::::::::::::::::') tempclasschoice.addline('-> %i. Select %s'%(choice, Class)) tempclasschoice.addline('-> 8. Classes') tempclasschoice.submenu(8, 'classmenu') tempclasschoice.addline('-> 9. Main Menu') tempclasschoice.submenu(9, 'main') tempclasschoice.addline('0. Exit') tempclasschoice.menuselect = classChosen tempclasschoice.send(userid) # Will do when def classChosen(userid, choice, popupid): if choice == Player(userid).getItem('Pick'): Player(userid).setItem('Pick', None) Player(userid).setClass(classes[choice-1]) def test(): global players userid = es.getcmduserid() level = int(es.getargv(1)) xp = int(es.getargv(2)) players[es.getplayersteamid(userid)][Player(userid).getClass()]['Level'] = level players[es.getplayersteamid(userid)][Player(userid).getClass()]['XP'] = xp def getViewPlayer(userid): es.entsetname(userid, 'targetplayer') for index in es.getEntityIndexes('player'): if es.entitygetvalue(index, 'targetname') == 'targetplayer': es.entitysetvalue(index, 'targetname', '') return es.getuserid(es.gethandlefromindex(index)) return None def playsound(userid, sound): es.emitsound("player", userid, "wohd/" + sound, 1, 0) def currentSkills(userid): if popuplib.exists('currentSkills '): popuplib.delete('currentSkills ') skills = popuplib.create('currentSkills') skills.addline('Your current skills:') Class = Player(userid).getClass() if not Class: wohdTell(userid, 'You don\'t have a class selected yet!') return 0 for k,v in players[es.getplayersteamid(userid)][Class]['Skills'].iteritems(): skills.addline('%s Level: %i'%(k, players[es.getplayersteamid(userid)][Class]['Skills'][k]['Level'])) skills.addline('-> 8. Main Menu') skills.submenu(8, 'main') skills.addline('-> 0. Exit') skills.send(userid) def skillmenu(userid): Class = Player(userid).getClass() if not Class: wohdTell(userid, 'You don\'t have a class selected yet!') return 0 skill_menu = None if not popuplib.exists('skill_menu'): skill_menu = popuplib.create('skill_menu') skill_menu.addline(' ') skill_menu.addline('::::::::::::::::::') skill_menu.addline(' ') skill_menu.addline(' ') skill_menu.addline(' ') skill_menu.addline(' ') skill_menu.addline(' ') skill_menu.addline(' ') skill_menu.addline(' ') skill_menu.addline('::::::::::::::::::') skill_menu.addline('-> 8. Main Menu') skill_menu.addline('-> 0. Exit') else: skill_menu = popuplib.find('skill_menu') skill_menu.modline(1, 'WoH: Diablo %s Skill Menu'%Class) x = 1 for k,v in players[es.getplayersteamid(userid)][Class]['Skills'].iteritems(): skill_menu.modline(x+2, '-> %i. %s'%(x, k)) if not popuplib.exists('%s'%k): tempSkillMenu = popuplib.create('%s'%k) tempSkillMenu.addline('%s'%k) tempSkillMenu.addline('Description:') tempSkillMenu.addline('%s'%players[es.getplayersteamid(userid)][Class]['Skills'][k]['Description']) tempSkillMenu.addline('-> 1. Select %s'%k) tempSkillMenu.addline('-> 8. Back') tempSkillMenu.addline('-> 0. Exit') tempSkillMenu.menuselect = tempSkillSelect x += 1 skill_menu.submenu(8, 'main') skill_menu.menuselect = skillSelect skill_menu.send(userid) def skillSelect(userid, choice, popupid): Class = Player(userid).getClass() x = 1 for k,v in players[es.getplayersteamid(userid)][Class]['Skills'].iteritems(): if x == choice: x = k break else: x += 1 Player(userid).setItem('Skill Pick', x) y = popuplib.find('%s'%x) y.send(userid) def tempSkillSelect(userid, choice, popupid): debug('skill select menu') if choice == 1: player = Player(userid) if player.getSkillPoints() > 0: # Do this for every class if player.getClass() == 'Amazon' and player.getItem('Skill Pick') in AmazonSkills: player.increaseSkill(player.getItem('Skill Pick')) player.setItem('Skill Pick', None) else: wohdTell(userid, 'You don\'t have enough Skill Points for your %s!'%player.getClass()) player.setItem('Skill Pick', 0) class Player(): def __init__(self, userid, values={}): global players userid = int(userid) if userid not in es.getUseridList(): wohdMsg('Player not found! : %s'%userid) else: self.userid = userid self.steamid = es.getplayersteamid(self.userid) if self.steamid == 'BOT': self.steamid = es.getplayername(userid) self.check() if values: for k,v in values.iteritems(): players[self.steamid][k] = v def check(self): global players if not players.has_key(self.steamid): if not es.isbot(self.userid): changeTeam(self.userid, 1) gamethread.delayed(1.5, wohdTell, (self.userid, 'Welcome to Diablo mod. Select a class to play to get started. Open the menu by typing \'%s\''%wohd_menuCommand)) gamethread.delayed(1.5, main.send, self.userid) wohdMsg('Welcome new player "%s" to Diablo! Please try and assist them with their questions!'%es.getplayername(self.userid)) players[self.steamid] = { 'Class':None, 'Strength':0, 'Dexterity':0, 'Vitality':100, 'Energy':0, 'Mana':0, 'Armor':0, 'Resistance':0, 'Armor Pen':0, 'Magic Pen':0, 'Gold':0, 'Skill 1':0, 'Skill 2':0, 'Skill 3':0, 'Skill 4':0, 'Skill 5':0, 'Skill 6':0, 'Skill 7':0, 'Inventory':{}, 'Equipped':{ 'Weapon':None, 'Armor':None, 'Ring 1':None, 'Ring 2':None, 'Amulet':None }, 'Last Connected':time.time(), 'Pick':None, 'Skill Pick':None } for Class in classes: players[self.steamid][Class] = { 'Skills':{}, 'Level':1, 'XP':0, 'Skill Points':0 } if Class == 'Amazon': players[self.steamid][Class]['Skills'] = { 'Impale': { 'Description':'You deal a guaranteed critical, but must reload after your shot. Increases Crit Damage. Use with "ability 1" (Only works with guns, Activate)', 'Level':0 }, 'Lightning Bolt':{ 'Description':'Your next shot deals bonus magic damage, and all damage dealt is magical. Use with "ability 2" (Activate)', 'Level':0 }, 'Lightning Strike':{ 'Description':'Your next attack activates a chain lightning. Use with "ability 3" (Activate)', 'Level':0 }, 'Dodge':{ 'Description':'You gain an increase in dodge chance. (Passive)', 'Level':0 }, 'Penetrate':{ 'Description':'Your attacks ignore some of the enemys Armor. (Passive)', 'Level':0 }, 'Pierce':{ 'Description':'Your attacks peirce and pass-through multiple enemies. Toggle with "ability 4" (Toggle)', 'Level':0 }, 'Cold Arrow':{ 'Description':'Your attacks deal bonus damage as magic, and have a chance to slow for the rest of the round. Toggle with "ability 5" (Toggle)', 'Level':0 } } else: if players[self.steamid]['Class'] == None: if not es.getplayersteamid(self.userid) == 'BOT': changeTeam(self.userid, 1) if es.getplayersteamid(self.userid) == 'BOT': self.setClass(random.choice(classes)) spe.respawn(self.userid) else: self.Class = self.getClass() def setAbilities(self, Class): global players if Class == 'Amazon': players[self.steamid]['Strength'] = int(12 + self.getLevel() / 2) players[self.steamid]['Dexterity'] = int(15 + self.getLevel() / 1.5) players[self.steamid]['Vitality'] = int(100 + self.getLevel() / 2) players[self.steamid]['Energy'] = int(12 + self.getLevel() / 2) if Class == 'Barbarian': players[self.steamid]['Strength'] = int(15 + self.getLevel() / 1.5) players[self.steamid]['Dexterity'] = int(12 + self.getLevel() / 1.8) players[self.steamid]['Vitality'] = int(115 + self.getLevel() / 1.75) players[self.steamid]['Energy'] = int(10 + self.getLevel() / 2.5) if Class == 'Druid': players[self.steamid]['Strength'] = int(15 + self.getLevel() / 2.25) players[self.steamid]['Dexterity'] = int(10 + self.getLevel() / 1.75) players[self.steamid]['Vitality'] = int(100 + self.getLevel() / 2) players[self.steamid]['Energy'] = int(15 + self.getLevel() / 2.25) if Class == 'Paladin': players[self.steamid]['Strength'] = int(13 + self.getLevel() / 2) players[self.steamid]['Dexterity'] = int(13 + self.getLevel() / 2) players[self.steamid]['Vitality'] = int(115 + self.getLevel() / 1.75) players[self.steamid]['Energy'] = int(13 + self.getLevel() / 2) if Class == 'Sorceror': players[self.steamid]['Strength'] = int(10 + self.getLevel() / 2.5) players[self.steamid]['Dexterity'] = int(12 + self.getLevel() / 2) players[self.steamid]['Vitality'] = int(100 + self.getLevel() / 2.25) players[self.steamid]['Energy'] = int(20 + self.getLevel() / 1.5) if Class == 'Witch Doctor': players[self.steamid]['Strength'] = int(10 + self.getLevel() / 2.5) players[self.steamid]['Dexterity'] = int(14 + self.getLevel() / 2) players[self.steamid]['Vitality'] = int(100 + self.getLevel() / 2.25) players[self.steamid]['Energy'] = int(18 + self.getLevel() / 1.5) def setClass(self, Class): global players if round_started: if not es.getplayerprop(self.userid, 'CBasePlayer.pl.deadflag'): wohdTell(self.userid, 'You will be a %s next round'%Class) self.setItem('Pick', Class) return 0 players[self.steamid]['Class'] = Class wohdTell(self.userid, 'You are now a %s'%Class) self.setAbilities(Class) def getClass(self): return players[self.steamid]['Class'] def getLevel(self, Class=None): global players if Class == None: if not self.getItem('Class'): return None return players[self.steamid][self.getItem('Class')]['Level'] else: return players[self.steamid][Class]['Level'] def giveExp(self, amount, reason=None): global players if self.getLevel() < wohd_levelCap: players[self.steamid][self.getItem('Class')]['XP'] += amount if reason: wohdTell(self.userid, 'You have gained #default%s XP#green for %s'%(amount, reason)) if self.getExp() >= self.getLevel() * wohd_experiencePerLevel: self.giveLevel() def getExp(self, Class=None): global players if Class == None: if not self.getItem('Class'): return 0 return players[self.steamid][self.getItem('Class')]['XP'] else: return players[self.steamid][Class]['XP'] def giveLevel(self): global players if self.getLevel() < wohd_levelCap: if self.getExp() >= self.getLevel() * wohd_experiencePerLevel: playsound(self.userid, "levelup.wav") players[self.steamid][self.getClass()]['XP'] -= players[self.steamid][self.getClass()]['Level'] * wohd_experiencePerLevel players[self.steamid][self.getClass()]['Level'] += 1 wohdMsg('Congratulations to %s for hitting level %s!'%(es.getplayername(self.userid), self.getLevel())) def getItem(self, stat): if players[self.steamid].has_key(stat): return players[self.steamid][stat] return 0 def setItem(self, item, value): players[self.steamid][item] = value def getMana(self): return players[self.steamid]['Mana'] def getSkillPoints(self): if self.getClass(): return players[self.steamid][self.getClass()]['Skill Points'] else: return 0 def increaseSkill(self, skill): players[self.steamid][Class]['Skills'][skill]['Level'] += 1 players[self.steamid][Class]['Skill Points'] -= 1 wohdTell(self.userid, 'You have leveled up #default%s#green!'%skill) def toggleSkill(self, skill): if player.getItem('Skill %s'%skill): player.setItem('Skill %s'%skill, 0) if self.Class == 'Amazon': if int(skill) == 1: wohdTell(self.userid, 'You deactivated Impale') if int(skill) == 2: wohdTell(self.userid, 'You deactivated Lightning Bolt') if int(skill) == 3: wohdTell(self.userid, 'You deactivated Lightning Strike') if int(skill) == 6: wohdTell(self.userid, 'You turned off Pierce') if int(skill) == 7: wohdTell(self.userid, 'You turned off Cold Arrows') else: player.setItem('Skill %s'%skill, 1) if self.Class == 'Amazon': if int(skill) == 1: if players[self.steamid][Class]['Skills']['Impale']['Level'] > 1: if not player.getItem('Skill 2') and not player.getItem('Skill 3'): if player.getMana() >= 10: wohdTell(self.userid, 'You activated Impale') else: wohdTell(self.userid, 'You dont have enough mana') else: wohdTell(self.userid, 'You may only have a single activated skill at a time') else: wohdTell(self.userid, 'You have not learned that skill') if int(skill) == 2: if players[self.steamid][Class]['Skills']['Lightning Bolt']['Level'] > 1: if not player.getItem('Skill 1') and not player.getItem('Skill 3'): if player.getMana() >= 5 + players[self.steamid][Class]['Skills']['Lightning Bolt']['Level']: wohdTell(self.userid, 'You activated Lightning Bolt') else: wohdTell(self.userid, 'You dont have enough mana') else: wohdTell(self.userid, 'You may only have a single activated skill at a time') else: wohdTell(self.userid, 'You have not learned that skill') if int(skill) == 3: if players[self.steamid][Class]['Skills']['Lightning Strike']['Level'] > 1: if not player.getItem('Skill 1') and not player.getItem('Skill 2'): if player.getMana() >= max(1, min(20, 20 - players[self.steamid][Class]['Skills']['Lightning Strike']['Level'])): wohdTell(self.userid, 'You activated Lightning Strike') else: wohdTell(self.userid, 'You dont have enough mana') else: wohdTell(self.userid, 'You may only have a single activated skill at a time') else: wohdTell(self.userid, 'You have not learned that skill') if int(skill) == 6: if players[self.steamid][Class]['Skills']['Pierce']['Level'] > 1: wohdTell(self.userid, 'You turned on Pierce') else: wohdTell(self.userid, 'You have not learned that skill') if int(skill) == 7: if players[self.steamid][Class]['Skills']['Cold Arrow']['Level'] > 1: wohdTell(self.userid, 'You turned on Cold Arrows') else: wohdTell(self.userid, 'You have not learned that skill') def set_round_started(x=1): global round_started round_started = x def round_start(ev): gamethread.delayed(es.ServerVar('mp_freezetime'), set_round_started) gamethread.cancelDelayed('wohdloops') def item_pickup(ev): if ev['item'] in ['vesthelm', 'item_assaultsuit', 'assaultsuit']: Player(ev['userid']).setItem(Player(ev['userid'].getItem('Armor') + 100)) def player_team(ev): if int(ev['team']) > 1: player = Player(ev['userid']) def preSpawn(ev): player = Player(ev['userid']) if player.getItem('Pick'): player.setItem('Class', player.getItem('Pick')) wohdTell(ev['userid'], 'You are now a %s'%player.getClass()) def player_spawn(ev): player = Player(ev['userid']) es.setplayerprop(ev['userid'], 'CBasePlayer.m_iHealth', player.getItem('Vitality')) player.setItem('Mana', player.getItem('Energy') * 2) player.setItem('Armor', 0) def player_activate(ev): Player(ev['userid'], {'Last Connected':time.time()}) def prepHurt(ev): #Remember to have strength buff damage userid = ev['userid'] attacker = ev['attacker'] if attacker in es.getUseridList() and userid in es.getUseridList(): victim = Player(userid) attacker = Player(attacker) damage = ev['dmg_health'] if attacker.getClass() == 'Amazon': #Impale if attacker.getItem('Skill 1'): damage *= 2 damage += damage * (players[attacker.steamid]['Amazon']['Skills']['Impale']['Level'] * .1) es.cexec(attacker.userid, 'reload') attacker.setItem('Mana', int(attacker.getMana()) - 10) attacker.toggleSkill(1) #Lightning Bolt if attacker.getItem('Skill 2'): es.setplayerprop(victim.userid, 'CBasePlayer.m_iHealth', int(es.getplayerprop(victim.userid, 'CBasePlayer.m_iHealth')) + damage) magicDamage = damage + damage * (players[attacker.steamid]['Amazon']['Skills']['Lightning Bolt']['Level'] * .05) Damage(victim.userid, attacker.userid, magicDamage, 'magical') attacker.setItem('Mana', int(attacker.getMana()) - 5 - players[attacker.steamid]['Amazon']['Skills']['Lightning Bolt']['Level']) attacker.toggleSkill(2) pass #Lightning Strike if attacker.getItem('Skill 3'): magicDamage = damage * .15 if es.getplayerteam(attacker.userid) == 2: damage(random.choice(playerlib.getPlayer(victim.userid).getNearPlayers('#ct', 600)), attacker.userid, magicDamage, 'magical') if es.getplayerteam(attacker.userid) == 3: damage(random.choice(playerlib.getPlayer(victim.userid).getNearPlayers('#t', 600)), attacker.userid, magicDamage, 'magical') attacker.setItem('Mana', int(attacker.getMana()) - max(1, min(20, 20 - players[attacker.steamid][Class]['Skills']['Lightning Strike']['Level']))) attacker.toggleSkill(3) #Pierce if attacker.getItem('Skill 6'): pierceDamage = damage pierceList = [] x,y = es.getplayerlocation(attacker.userid) if es.getplayerteam(attacker.userid) == 2: for a in playerlib.getPlayer(victim.userid).getNearPlayers('#ct', 600): x2,y2 = es.getplayerlocation(a) if abs( (x/y) - (x2/y2) ) <= .1: if int(attacker.getMana()) >= 5: pierceDamage *= .5 Damage(a, attacker.userid, pierceDamage) attacker.setItem('Mana', int(attacker.getMana()) - 5) if es.getplayerteam(attacker.userid) == 3: for a in playerlib.getPlayer(victim.userid).getNearPlayers('#t', 600): x2,y2 = es.getplayerlocation(a) if abs( (x/y) - (x2/y2) ) <= .1: if int(attacker.getMana()) >= 5: pierceDamage *= .5 Damage(a, attacker.userid, pierceDamage) attacker.setItem('Mana', int(attacker.getMana()) - 5) #Cold Arrow if attacker.getItem('Skill 7'): if int(attacker.getMana()) >= 7: Damage(vicitm.userid, attacker.userid, damage * .05, 'magical') if float(es.getplayerprop(victim.userid, "CBasePlayer.localdata.m_flLaggedMovementValue")) > .7: es.setplayerprop(victim.userid, "CBasePlayer.localdata.m_flLaggedMovementValue", float(es.getplayerprop(victim.userid, "CBasePlayer.localdata.m_flLaggedMovementValue")) - .05) attacker.setItem('Mana', int(attacker.getMana()) - 7) health = es.getplayerprop(victim.userid, 'CBasePlayer.m_iHealth') dodge = victim.getItem('Dodge') + victim.getItem('Dexterity') * .1 if victim.getClass() == 'Amazon': dodge += players[attacker.steamid]['Amazon']['Skills']['Dodge']['Level'] * .05 if random.randint(1,100) < dodge: es.setplayerprop(victim.userid, 'CBasePlayer.m_iHealth', int(es.getplayerprop(victim.userid, 'CBasePlayer.m_iHealth')) + damage) wohdTell(victim.userid, 'You have successfully evaded an attack!') pass if health > 0: crit = random.choice([0,1]) damageReduction = int(victim.getItem('Damage Reduction') + victim.getItem('Armor') / 100) extraDamage = victim.getItem('Damage') if attacker.getClass() == 'Amazon': if players[attacker.steamid]['Amazon']['Skills']['Penetrate']['Level']: extraDamage += players[attacker.steamid]['Amazon']['Skills']['Penetrate']['Level'] * 3 if crit: damage = damage - int(damage * damageReduction / 100) + damage - int(damage * damageReduction / 100) else: damage = damage - int(damage * damageReduction / 100) if damage + int(damage * extraDamage / 100) >= health: Damage(victim.userid, attacker.userid, int(damage * (extraDamage / 100))) def Damage(userid, attacker, damage, type='physical'): if type == 'physical': if es.getplayerprop(userid, 'CBasePlayer.m_iHealth') <= damage: es.server.queuecmd('damage %s %s 32 %s'%(userid, damage, attacker)) else: es.setplayerprop(userid, 'CBasePlayer.m_iHealth', int(es.getplayerprop(userid, 'CBasePlayer.m_iHealth'))-damage) if type == 'magical': # There is a % chance of mitigating all magic damage equal to their resistance + .1% for every level higher they are # compared to their victim. The same is also true for reducing magic damage dealt. difference = Player(attacker).getLevel() - Player(userid).getLevel() if random.randint(1,100) < Player(userid).getItem('Resistance') + difference / 10: pass else: damage = damage - ((Player(userid).getItem('Resistance') + difference / 10) / 100 * damage) if es.getplayerprop(userid, 'CBasePlayer.m_iHealth') <= damage: es.server.queuecmd('damage %s %s 32 %s'%(userid, damage, attacker)) else: es.setplayerprop(userid, 'CBasePlayer.m_iHealth', int(es.getplayerprop(userid, 'CBasePlayer.m_iHealth'))-damage) def player_death(ev): if ev['es_attackerteam'] != ev['es_userteam']: Player(ev['attacker']).giveExp(int(wohd_killExp), 'killing an enemy') ''' def player_jump(ev): userid = ev['userid'] if int(int(players[playerlib.uniqueid(userid)]['Jump'])): level = int(int(players[playerlib.uniqueid(userid)]['Jump'])) deBug(level) myVec = [es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[%s]' % x) * 1 for x in range(3)] if level == 1: myVec[0] = 0 myVec[1] = 0 myVec[2] *= .4 if level == 2: myVec[0] = .1 myVec[1] = .1 myVec[2] *= .4 if level == 3: myVec[0] = .2 myVec[1] = .2 myVec[2] *= .6 if level == 4: myVec[0] = .4 myVec[1] = .4 myVec[2] *= .7 if level > 0: deBug('Jump code') es.setplayerprop(userid, 'CBasePlayer.localdata.m_vecBaseVelocity', '%s,%s,%s' % tuple(myVec)) ''' def resetabilities(): global players userid = es.getcmduserid() players[ev['userid']]['class']['Level'] = 1 players[ev['userid']]['class']['XP'] = 0 players[ev['userid']]['class']['Skills'] = {} players[ev['userid']]['class']['Skill Points'] = 0 wohdTell(userid, ['Your abilities have been reset']) def reset(): global players players = {} str_path = open(es.getAddonPath('wohd') + '/wohd.db', 'w') cPickle.dump(players, str_path) str_path.close() wohdMsg("Everyone's Abilities have been reset to start a new...") gamethread.delayed(3, es.reload, ('wohd')) es.server.queuecmd('mp_restartgame 3') def unload(): str_path = open(es.getAddonPath('wohd') + '/wohd.db', 'w') cPickle.dump(players, str_path) str_path.close() spe.unregisterPreHook("player_hurt", prepHurt) def round_end(ev): set_round_started(0) gamethread.cancelDelayed('wohdloops') str_path = open(es.getAddonPath('wohd') + '/wohd.db', 'w') cPickle.dump(players, str_path) str_path.close() winner = int(ev['winner']) for userid in es.getUseridList(): if winner > 1: if es.getplayerteam(userid) == winner: Player(userid).giveExp(wohd_roundExp, 'winning the round') def bomb_planted(ev): Player(ev['userid']).giveExp(wohd_bomb_plantedExp, 'planting the bomb') def bomb_exploded(ev): Player(ev['userid']).giveExp(wohd_bomb_explodedExp, 'the bomb exploding') def bomb_defused(ev): Player(ev['userid']).giveExp(wohd_bomb_defusedExp, 'defusing the bomb') def hostage_rescued(ev): Player(ev['userid']).giveExp(wohd_rescueExp, 'rescuing a hostage') def hostage_rescued_all(ev): Player(ev['userid']).giveExp(wohd_allExp, 'rescuing all hostages') def ability(): if not es.getplayerprop(es.getcmduserid(), 'CBasePlayer.pl.deadflag'): player = Player(es.getcmduserid()) skill = es.getargv(1) if not int(skill): wohdTell(player.userid, 'You did not bind your skill correctly!') wohdTell(player.userid, 'bind "ability <1-7>"') return 0 if skill not in range(1,8): wohdTell(player.userid, 'You may only use skills in the range 1-7') return 0 if player.getClass() == 'Amazon': if skill in range(1,4): player.toggleSkill(skill) if skill in range(4,6): wohdTell(player.userid, 'This skill is passive and need not be activated!') if skill in range(6,8): player.toggleSkill(skill)