Right now this is still a beta release, all the races are added inside the file. You do not code them seperately then import. I will be looking into that option later on.
Basically the race class is what dictates what all the races are capable of, to make new races you simply copy the same format as any of the other races. Then modify it to suit the race. All that stuff you quoted at the bottom of the races is part of them as well. It's mostly for the menus, and tells wcs2 how to call your race instance.
GeSHi (python):
class Human(Race):
"Human Skills"
def __init__(self, wc_userid, wc_race='Human Alliance'):
# all this stuff here is for later reference, the ult_* are for determining what type of ultimate you are using.
global wc_users
wc_steamid = es.getplayersteamid(wc_userid)
self.steamid = wc_steamid
self.uid = wc_userid
wc_race = 'Human Alliance'
self.ln = wc_race
self.sn = 'Human'
self.race = wc_race
self.level = wc_users[wc_steamid][wc_race]['level']
self.ult_viewtarget = 0
self.ult_target = 0
self.ult_coord = 1
self.ult_skill = 0
# This sets up your skills, what values are used at what level
self.skills = {"bash": {1:11,2:22,3:33}, "invisibility": {1:200,2:175,3:135}, "devotion_aura": {1:15,2:30,3:45}, "teleport": {1:1}}
# this is in every race. This just sets all your current skills inside your temporary database entry
self.skill = {}
for wc_tmp in self.skills:
self.skill[wc_tmp] = wc_users[wc_steamid][wc_race][wc_tmp]
#this is how you define your skills, they should be named the same as above, and the return value from the menus
# any other functions that are run from your skills, can be named whatever you want
def invisibility(self,wc_lvl=0):
if not wc_lvl:
if not self.skill['invisibility']:
return 0
wc_lvl = self.skill['invisibility']
if wc_lvl > 0:
es.server.queuecmd('es_fire ' + str(self.uid) + ' !self addoutput \"rendermode 1\"')
es.server.queuecmd('es_fire ' + str(self.uid) + ' !self alpha ' + str(self.skills['invisibility'][wc_lvl]))
elif wc_lvl < 0:
es.server.queuecmd('es_fire ' + str(self.uid) + ' !self addoutput \"rendermode 1\"')
es.server.queuecmd('es_fire ' + str(self.uid) + ' !self alpha 255')
def devotion_aura(self,wc_lvl=0):
global wc_users
if not wc_lvl:
if not self.skill['devotion_aura']:
return 0
wc_lvl = self.skill['devotion_aura']
wc_tmp = playerlib.getPlayer(self.uid)
wc_tmphp = wc_tmp.get('health') + self.skills['devotion_aura'][wc_lvl]
gamethread.delayed(0.3,wc_tmp.set,('health',wc_tmphp))
wc_users[self.steamid]['maxhp'] += self.skills['devotion_aura'][wc_lvl]
def bash(self,wc_victim,wc_lvl=0):
if not wc_lvl:
if not self.skill['bash']:
return 0
wc_lvl = self.skill['bash']
wc_rand = random.randint(1,100)
if wc_rand <= self.skills['bash'][wc_lvl]:
wc_tmp = playerlib.getPlayer(wc_victim)
wc_tmp.set('freeze',1)
#es.msg('#green','Froze player: ' + es.getplayername(wc_victim))
gamethread.delayed(0.75,wc_tmp.set,('freeze',0))
def teleport(self,wc_viewcoord):
wc_player_coord = vecmath.vector(es.getplayerlocation(self.uid))
wc_tmpvec = wc_viewcoord - wc_player_coord
wc_tmplen = vecmath.length(wc_tmpvec)
if wc_tmplen > 50.0:
wc_tmplen -= 50.0
wc_tmp = vecmath.setlength(wc_tmpvec,wc_tmplen)
wc_teleportvec = wc_player_coord + wc_tmp
wc_blinkcheck = check_blinkcoord(self.uid,wc_teleportvec)
if not wc_blinkcheck:
wc_dir = es.getplayerprop(self.uid,'CBasePlayer.baseclass.baseclass.baseclass.baseclass.baseclass.m_angRotation')
wc_startvec = es.createvectorstring(wc_player_coord['x'],wc_player_coord['y'],wc_player_coord['z'])
wc_startvec2 = es.createvectorstring(wc_player_coord['x'],wc_player_coord['y'],wc_player_coord['z'] + 200.0)
wc_endvec = es.createvectorstring(wc_teleportvec['x'],wc_teleportvec['y'],wc_teleportvec['z'])
wc_endvec2 = es.createvectorstring(wc_teleportvec['x'],wc_teleportvec['y'],wc_teleportvec['z'] + 200.0)
wc_tmpdir = es.splitvectorstring(wc_dir)
wc_newdir = []
for wc_tdir in wc_tmpdir:
wc_newdir.append(wc_tdir * -1)
wc_enddir = es.createvectorstring(wc_newdir[0],wc_newdir[1],wc_newdir[2])
es.server.queuecmd('est_effect_26 #a!b 0.0 ' + wc_startvec + ' ' + wc_dir + ' 10 1')
es.server.queuecmd('est_Effect_06 #a!b 0.0 sprites/plasmabeam.vmt ' + wc_startvec + ' ' + wc_startvec2 + ' 15 1 50 75 10 1 255 255 255 150 50')
es.setpos(self.uid,wc_teleportvec['x'],wc_teleportvec['y'],wc_teleportvec['z'])
es.server.queuecmd('est_effect_26 #a!b 0.0 ' + wc_endvec + ' ' + wc_enddir + ' 10 1')
es.server.queuecmd('est_Effect_06 #a!b 0.0 sprites/plasmabeam.vmt ' + wc_endvec2 + ' ' + wc_endvec + ' 15 1 50 75 10 1 255 255 255 150 50')
es.server.queuecmd('est_fade ' + str(self.uid) + ' 0 0.5 0 255 255 255 126')
gamethread.delayed(0.5,self.check_teleport,wc_player_coord)
else:
es.server.queuecmd('est_csay ' + str(self.uid) + ' Teleport Blocked')
else:
gamethread.cancelDelayed('ult' + str(self.uid))
gamethread.delayedname(0.1,'ult' + str(self.uid),wc_enable_ult,self.uid)
es.server.queuecmd('est_csay ' + str(self.uid) + ' Teleport distance too short')
def check_teleport(self,wc_oldpos):
if int(es.getplayerprop(self.uid,"CBasePlayer.localdata.m_hGroundEntity")) == -1:
es.server.queuecmd('est_csay ' + str(self.uid) + ' Bad Teleport')
es.setpos(self.uid,wc_oldpos['x'],wc_oldpos['y'],wc_oldpos['z'])
gamethread.cancelDelayed('ult' + str(self.uid))
gamethread.delayedname(3.0,'ult' + str(self.uid),wc_enable_ult,self.uid)
# this is where the fun begins, This is what determines what to do on this event.
# the list of events are in the main Race class, any events you don't use, don't worry about the default class will take care of it
# as you can see here, humans only have 1 skill that's passed to an offensive attack, the wc_kill tells it wether the player is dead or not so you can determine whether to fire the skill or not
# no point in freezing them if they're already dead
# note that the inputs are default, you cannot change it, that is why this is here
# this allows you to pass the specific values that are needed for the skills
def offensive(self,wc_eventvars,wc_kill):
if not wc_kill:
self.bash(int(wc_eventvars['userid']))
# this determines the ultimate to use when they use the !ultimate command
# in this case we're passing a "victim" but it's not actually a userid, it's a vector for where they're looking
# python doesn't care what is in there, only that you pass it something, or in this case it can pass nothing since it defaults to 0
def ultimate(self,wc_victim=0):
self.teleport(wc_victim)
# this determines what skills are run on spawn, so nothing is needed to be passed
# the wc_users is the temporary db that stores the current players that are on the server
def spawn(self):
global wc_users
self.invisibility()
self.devotion_aura()
if self.skill['teleport']:
wc_users[self.steamid]['ultimate'] = 1
# now all of this below is mostly for the menus, and calling the instance of the race
# for the sake of having your menus come up in a specific order I have created a seperate list for just the race names
# wc_races_list stores all the menu info, the 'instance' is what is used to call the instance of your race, it has to be the same as the name of the race class you made
# Ultimates have 1 level, so they are defined as ultimates aka 'ult', they also are not accessible until the specified level (default 6)
wc_races_list['Human Alliance'] = {'instance':Human, 'skills': {"bash": 'skill', "invisibility": 'skill', "devotion_aura": 'skill', "teleport": 'ult'}}
wc_races_list['Human Alliance']['display'] = ['Invisibility','Devotion Aura','Bash','Teleport']
wc_races_list['Human Alliance']['return'] = ['invisibility','devotion_aura','bash','teleport']
wc_races_list['Human Alliance']['info'] = ['Partial Invisibility','Increases Your Max HP','Chance to Freeze Enemies for 1 sec','Teleport to Where You Look']
# this is where you add to the menu, w/o this you will not be able to see the race in the menu
wc_racelist.append('Human Alliance')
so where you place this race in the file, determines the order in which it will be displayed. Alternatively you could just make the list and take it out of the bottom of every race. I did it this way to make it easy.