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 2009-10-08 (original capture). Home · Forum · All archived topics · Downloads
Warcraft-Source.com - WCS mod for CSS
January 03, 2010, 12:01:09 AM *
Welcome, Guest. Please login or register.
Login with username, password and session length
News: WCS Tournament being opened for applications!

Post here for signups!
Google  
  Home   Forum   Help Search Login Register   *
Pages: [1]   Go Down
  Print  
This topic has not yet been rated! You have not rated this topic. Select a rating:
Author Topic: WCS Python Ultimate Guide!  (Read 227 times)
freddukes
Level 7 Expert
*****
Offline Offline

United Kingdom

Posts: 292



« on: February 17, 2008, 10:59:06 PM »

Okay, so this time, the code for the ultimate is different... Instead of running 1 event, it will run 2... 2 you say? Yes 2... whenever the user preses/holds down the +ultimate key (it's + now not !)... it will fire the event: def player_ultimate_on(event_var): On the other hand, when the user lets go of the key, it runs the event: def player_ultimate_off(event_var): Now, what's the advantage of this? Well for starters, You can delay a command, then get how long the key has been held down, so you can 'charge' up ultimates now... phat_wizard cam up with the good idea that when you hold down the key, you will be frozen, then when you let go, you'll be flung where you are looking, the force dependant on how long you held the key. (like sonics spin attack)... Another example would be the ultimate would let you go invisible for the length you held the key, but you'd have a counter that would count down on how long you have got left... etc, the posibilities are endlless... Now, with these commands, I've also created a few extra commands....

Code
GeSHi (python):
a = wcs.Command(userid)
a.SetCoolDown('Skill Name',Time length)
 

Now the advantage of this, is that you can now set a cooldown time on ANY skill... However, a skill that ISNT a ultimate, you'll have to retrieve whether the cooldown has been activated... For this, you use the command a.GetCoolDown
Code
GeSHi (python):
a = wcs.Command(userid)
timelength = a.GetCoolDown('Skill Name')
if not timelength:
   es.msg('The skill no longer has a cooldown timer')
 

This enables you for more possibilities.. now, the correct way to run an ultimate event is as follows..

Code
GeSHi (python):
def player_ultimate_on(event_var):
   es.msg('We have 3 events')
   es.msg('The first event is userid - %s'%event_var['useird'])
   # event_var['userid'] dislayes the userid
   es.msg('The second event is steamid - %s'%event_var['es_steamid'])
   # event_var['es_steamid'] displays the users steamid
   es.msg('The third event is username - %s'%event_var['es_username'])
   # event_var['es_username'] displays the users name
 
   # Whenever we run an ultimate command, we MUST use the SetCoolDown if we want to set a cooldown...
   a = wcs.Command(ev['userid'])
   a.SetCoolDown('My Ultimate Name',30)
 
   # Set a cooldown time of 30 for my My Race and My Ultimate Name...

now I'll show you a way to use delayed to your advantage, to get how long a persons held the key down

Code
GeSHi (python):
players = {}
# Create a dictionary
 
def player_ultimate_on(event_var):
   user = wcs.Command(ev['userid'])
   user.SetCoolDown('Loop Counter',20)
   # Sets the cooldown timer to 20 seconds.
 
   players[ev['userid']] = 0
   # Sets a key in the dictionary to 0
   delay_name = 'delay_%s'%event_var['userid']
   # Format the delay name, so each delay is specific to the user running the command... for example, if userid was 3, it'd be delay_3
   gamethread.delayedname(1,delay_name,add_one,(delay_name,ev['userid']))
   # Delay the code for 1 second, with the name of delay_name, do the function add_one, and pass the variable delay_name and ev['userid']
 
def add_one(delay_name, userid):
   players[userid] += 1
   # Adds 1 to the current value of the users counter.. there is also -= *= and /=
   gamethread.delayedname(1,delay_name,add_one,(delay_name,userid))
   # Repeat the function 1 second later to add another counter
 
def player_ultimate_off(event_var):
   delay_name = 'delay_%s'%event_var['userid']
   # Again, we get the unique delay name
   gamethread.cancelDelayedD(delay_name)
   # Cancel the delay so it don't loop add_one again
   loop_counter = players[ev['userid']]
   # Gets the counter of length of time the user held down the key
   if loop_counter: # If the loop_counter is at least 1
       es.msg('You held down the key for %s seconds!'%loop_counter)
 

As you can see, I now hold how long (or how powerful etc) the loop counter is...Here we could do some math like distance = 20 * loop_counter so that the larger the loop_counter, the larger the distance... anything like that... Hope this helps you create races Wink.

-freddukes
« Last Edit: February 23, 2008, 11:06:15 AM by freddukes » Logged

Phat_Wizard
<WCS coder>
Level 7 Expert
*****
Offline Offline

Canada Canada

Posts: 229




Phat_Wizard
phatwizard
« Reply #1 on: February 17, 2008, 11:20:34 PM »

In the last example don't you have to GLOBAL the dict?
Logged

Frodo
Level 7 Expert
*****
Offline Offline

Posts: 853


Actinosphaerium eichhorni


WWW
ckenduro
aulix
« Reply #2 on: February 17, 2008, 11:22:31 PM »

He has to.

Nvm, how to create normal ultimates?

Sounds nice and pretty, thx.
« Last Edit: February 17, 2008, 11:49:42 PM by Frodo » Logged


Actually I found it as best Bux ever. Everything's automated!
Pages: [1]   Go Up
  Print  
 
Jump to:  

Last 7 Shouts:
January 02, 2010, 11:33:33 PM
i mean if you start 100 cmd instances and type ping google.com in all, after a while it will show timeout, but site will still be only for everyone but you Tongue
January 02, 2010, 11:33:01 PM
no you don't Tongue
a site can barely "crash"
though, it can have a timeout, and in this case it's in most case your i-net connection which has the timeout with the site
January 02, 2010, 11:24:47 PM
i think i crash the http://www.fpsbanana.com/ site.... after spamming logging...lol
January 02, 2010, 10:10:49 PM
Well thank you Smiley fucker. Tongue
January 02, 2010, 10:09:16 PM
Welcome back Pietro Tongue
January 02, 2010, 10:06:04 PM
Welcome back Eric Tongue
January 02, 2010, 09:29:49 PM
Oh god how i hate you chuck.
Recent
[January 02, 2010, 11:59:25 PM]

[January 02, 2010, 11:43:36 PM]

[January 02, 2010, 11:26:04 PM]

[January 02, 2010, 10:59:30 PM]

[January 02, 2010, 10:26:02 PM]

[January 02, 2010, 10:24:45 PM]

[January 02, 2010, 09:59:54 PM]

[January 02, 2010, 09:32:57 PM]

[January 02, 2010, 09:23:12 PM]

[January 02, 2010, 09:01:48 PM]
Theme switch

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.282 seconds with 25 queries.