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 2011-09-18 (original capture). Home · Forum · All archived topics · Downloads

Author Topic: [Tutorial] Using the Infinitely Useful wcs_dalias  (Read 398 times)

Offline PreDominance

  • Level 7 Expert
  • *****
  • Posts: 346
  • Country:
  • Creativity is your biggest restriction
    • ?WwT?
[Tutorial] Using the Infinitely Useful wcs_dalias
« on: May 31, 2011, 12:04:05 PM »
Hello there! I'm going to teach you guys how to use wcs_dalias.

Firstly, you must understand why wcs_dalias is useful. I'm going to show you a very basic skill that, to 95% of coders (or those who don't know wcs_dalias) will say is correct.

Code: [Select]
setting        = "es_xset wcs_damage 2|es_xset wcs_damage 5|es_xset wcs_damage 10|es_xset wcs_damage 15|es_xset wcs_damage 25"
      cmd            = "es_delayed 5 wcs_xalias racealias_hurt12"
  racealias_hurt12 = "if (event_var(es_userdead) = 0) then wcs damage event_var(userid) event_var(attacker) server_var(wcs_damage);es_tell event_var(userid) #darkgreen event_var(es_attackername) Has the final laugh, receieved server_var(wcs_damage) damage."
      sfx            = "es_delayed 5 wcs_xalias racealias_sfxhurt12"
racealias_sfxhurt12 = "es playerget location event_var(userid) wcs_x1 wcs_y1 wcs_z1;es_math wcs_z1 + 50;es est_effect 11 #a 0 sprites/purplelaser1.vmt server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) 1 2 255"

What does it look like? Simply a skill that does wcs_damage 5 seconds after attacking, or, in otherwords, a delayed damage skill. Easy, right? Wrong.
Take your time to look through it again. Remember that Eventscripts relies on server output, or in other words, event_variables (does the name EVENTscripts mean something now?). These variables change constantly. However, the most changed variables are probably the wcs_xyz1's, wcs_xyz2's, wcs_tmp1-15, wcs_player, and wcs_userid. Not only that, all event_variables ( event_var(userid), event_var(es_attackername), event_var(es_dmghealth) ) are always changing.

So take a look at my skill again. Notice the es_delayed 5 wcs_xalias. What do you think is wrong?
The answer is that event_var(userid), event_var(attacker), and server_var(wcs_damage) are EXTREMELY likely to change in 5 seconds. Anytime someone attacks someone else, THEY are now event_var(attacker) and the victim is event_var(attacker). If a race requires one to set wcs_damage, it's going to get changed as well.
Let me show you another skill, this time an ultimate.
Code: [Select]
[[skill4]]
setting = "es_xset wcs_duration 1;es_xset wcs_speedadd 0.1;es_xset wcs_gravity 0.8|es_xset wcs_duration 1;es_xset wcs_speedadd 0.2;es_xset wcs_gravity 0.7|es_xset wcs_duration 2;es_xset wcs_speedadd 0.3;es_xset wcs_gravity 0.6|es_xset wcs_duration 2|es_xset wcs_duration 2;es_xset wcs_speedadd 0.4;es_xset wcs_gravity 0.5|es_xset wcs_duration 3;es_xset wcs_speedadd 0.5;es_xset wcs_gravity 0.4|es_xset wcs_duration 3;es_xset wcs_speedadd 0.7;es_xset wcs_gravity 0.3|es_xset wcs_duration 4;es_xset wcs_speedadd 0.9;es_xset wcs_gravity 0.28"
cmd = "es_set wcs_tmp2 server_var(wcs_userid);es_copy wcs_tmp3 wcs_duration;es_copy wcs_tmp4 wcs_speedadd;es_copy wcs_tmp5 wcs_gravity;es playerset speedadd server_var(wcs_userid) server_var(wcs_speedadd);es wcs gravity server_var(wcs_userid) server_var(wcs_gravity);es_tell Sprint!;es_delayed server_var(wcs_duration) wcs_xalias racealias_rstskills"
racealias_rstskills = "es wcs_setfx speed server_var(wcs_userid) - server_var(wcs_speedadd);es wcs gravity server_var(server_var(wcs_userid)) 1;es_tell server_var(wcs_userid) #darkgreen Exhausted!"
sfx = "es_getplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_userid);es_xmath wcs_z1 + 15;es est_effect 7 #a 0 sprites/smoke.vmt server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) 100 10"
cooldown = "35"
This skill is for my wcs/zm server. It's a simple "sprint" skill that gives additional speed and gravity for up to 4 seconds.
What do you think is wrong with this one?
With ultimates, the userid is server_var(wcs_userid) (though you already know that). The problem is that wcs_userid changes EVERY TIME someone uses their ultimate. We don't want someone ELSE having their speed and gravity reduced, while the user roams free with his permanently increased.

The solution to both these problems is, as I'm sure you've guessed, is wcs_dalias.
Here is the command: wcs_dalias racealias_soandso <var1> <var2> <arg3> ... <var15>
Time for explaining.
Remember the variables that I highlighted before? The ones that changed? event_var(userid), event_var(attacker), and server_var(wcs_damage). These ones have a very high chance of changing between when the skill is activated and when the skill calls on the variables.
What wcs_dalias does, is it saves variables for the racealias. It immediately grabs the value of the variables you put inside of <var1> <var2> <var3>, etc, and stores them for the racealias.
And there's one more thing you need to know. Dalias changes your "arguments" into server_var(wcs_tmp1), server_var(wcs_tmp2), etc.
Do NOT make this more complicated than it seems! <var1> now becomes wcs_tmp1. <var2> is now wcs_tmp2.
To use your variables out ot "wcs_dalias racealias_soandso server_var(randnum) server_var(wcs_randnum2)", use wcs_tmp1 for randnum and wcs_tmp2 for randnum2.

Here is a simple command.
Code: [Select]
setting = "es_xset wcs_randnum 24|es_xset wcs_randnum2 77|es_xset wcs_randnum3 121294" #These mean nothing, just a filler/easter egg.
cmd = "es_xset wcs_uid event_var(userid);es_xset wcs_atckrname event_var(es_attackername);es_delayed 5 wcs_dalias racealias_showattacker server_var(wcs_uid) server_var(wcs_atckrname)"
racealias_showattacker = "es_tell server_var(wcs_tmp1) You were killed by server_var(wcs_tmp2)"
sfx = ""
This simply tells you your killer's name after death. First, we assign wcs_uid and wcs_atckrname to the event_var(userid) and event_var(es_attackername). Then we call wcs_dalias with the arguments server_var(wcs_uid) and servre_var(wcs_atckrname). All that happens is that dalias saves those two variables for that specific racealias. They will NOT change.
As you've noticed, we call them in the alias using wcs_tmp1 and wcs_tmp2 (wcs_uid was my first argument, wcs_atckrname was my second).

Let's look at a more advanced skill. The spring I used above. As you recall, server_var(wcs_userid) is bound to change. Not with dalias, however!
Code: [Select]
[[skill4]]
setting = "es_xset wcs_duration 1;es_xset wcs_speedadd 0.1;es_xset wcs_gravity 0.8|es_xset wcs_duration 1;es_xset wcs_speedadd 0.2;es_xset wcs_gravity 0.7|es_xset wcs_duration 2;es_xset wcs_speedadd 0.3;es_xset wcs_gravity 0.6|es_xset wcs_duration 2|es_xset wcs_duration 2;es_xset wcs_speedadd 0.4;es_xset wcs_gravity 0.5|es_xset wcs_duration 3;es_xset wcs_speedadd 0.5;es_xset wcs_gravity 0.4|es_xset wcs_duration 3;es_xset wcs_speedadd 0.7;es_xset wcs_gravity 0.3|es_xset wcs_duration 4;es_xset wcs_speedadd 0.9;es_xset wcs_gravity 0.28"
cmd = "es_set wcs_uid server_var(wcs_userid);es playerset speedadd server_var(wcs_userid) server_var(wcs_speedadd);es wcs gravity server_var(wcs_userid) server_var(wcs_gravity);es_tell server_var(wcs_userid) Sprint!;es_delayed server_var(wcs_duration) es wcs_dalias racealias_rstskills server_var(wcs_uid) server_var(wcs_speedadd) "
racealias_rstskills = "es wcs_setfx speed server_var(wcs_tmp1) - server_var(wcs_tmp2);es wcs gravity server_var(wcs_tmp1) 1;es_tell server_var(wcs_tmp1) #darkgreen Exhausted!"
sfx = "es_getplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_userid);es_xmath wcs_z1 + 15;es est_effect 7 #a 0 sprites/smoke.vmt server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) 100 10"
cooldown = "35"
Let's take it slowly. Look at the cmd only.
First I set wcs_uid to my ultimate's userid, or server_var(wcs_userid). Then I call dalias with a delay, and use my userid (wcs_uid) and I ALSO call the amount of speed I added, as I'll need that variable. In my dalias'd racealias, wcs_uid is now wcs_tmp1, and wcs_speedadd is now wcs_tmp2.

That's right ladies and gentlemen, wcs_dalias is actually quite simple when you wrap your head around it. It will save you tons of frustration in having variables change, and it will help you in becoming a better coder. Remember, what you can do is usually only restricted by your ability to think of a way to do it. Short version: BE CREATIVE!
Need help?

Steam:penumbra789                                      
Clan:?WwT? Wcs/Zm mod.                  
ClanWeb:wwt-clan.info


Offline Kamiqawa

  • Moderator
  • Level 7 Expert
  • Posts: 416
  • Country:
Re: [Tutorial] Using the Infinitely Useful wcs_dalias
« Reply #1 on: May 31, 2011, 12:10:06 PM »
Thank you for this very, very useful tutorial. I bet that this helps many coders here, especially when creating own cool custom ultimates and other skills.

Thank you.
Quote from: $Diablo$
You are banana dabass... Kami tried to proof point here and you ruin it >.>



Click here for wcs content made by me.


Offline pookzabazz

  • Level 6 Experienced
  • *****
  • Posts: 127
  • Country:
  • Twk Member
    • TWK
Re: [Tutorial] Using the Infinitely Useful wcs_dalias
« Reply #2 on: May 31, 2011, 01:32:56 PM »
Very nice cheers

What surprises me though, this week is the first time i've ever heard about the fact that these changing problems excist...

If this really is such a common issue, how come it barely happens at all ? like on spawn cmd's ?

One last critical Question ;) Does this 'saving' take a lot of cpu space ? if you'd use it for all your races for example ? Do they stack into becoming a big pile of data?

Thanks in advance


Offline PreDominance

  • Level 7 Expert
  • *****
  • Posts: 346
  • Country:
  • Creativity is your biggest restriction
    • ?WwT?
Re: [Tutorial] Using the Infinitely Useful wcs_dalias
« Reply #3 on: May 31, 2011, 01:46:22 PM »
Very nice cheers
Thanks!  :)
What surprises me though, this week is the first time i've ever heard about the fact that these changing problems excist...

If this really is such a common issue, how come it barely happens at all ? like on spawn cmd's ?
When you spawn, you're usually given abilities instantly. These issues only happen when you delay something and then call an ever-changing variable.
One last critical Question ;) Does this 'saving' take a lot of cpu space ? if you'd use it for all your races for example ? Do they stack into becoming a big pile of data?
It shouldn't. It uses predefined variables (save for wcs_tmp1), in wcs_tmp2, wcs_tmp3 ... wcs_tmp15. Besides, you're only setting the ones you define. Think of it as nothing more than a racealias and a few es_sets.
Thanks in advance
No problem!  ;)
Need help?

Steam:penumbra789                                      
Clan:?WwT? Wcs/Zm mod.                  
ClanWeb:wwt-clan.info

Offline pookzabazz

  • Level 6 Experienced
  • *****
  • Posts: 127
  • Country:
  • Twk Member
    • TWK
Re: [Tutorial] Using the Infinitely Useful wcs_dalias
« Reply #4 on: May 31, 2011, 02:34:01 PM »
Ah right, very well  ;)

Gonna put it to a good use now, some of mine custom ultimates mistake players from time to time, i've been swearing on em for a while now, but this explains  ;D

Thanks
« Last Edit: June 01, 2011, 04:29:40 PM by pookzabazz »


Offline PreDominance

  • Level 7 Expert
  • *****
  • Posts: 346
  • Country:
  • Creativity is your biggest restriction
    • ?WwT?
Re: [Tutorial] Using the Infinitely Useful wcs_dalias
« Reply #5 on: May 31, 2011, 03:37:41 PM »
What do you mean? Using dalias in block style?
Need help?

Steam:penumbra789                                      
Clan:?WwT? Wcs/Zm mod.                  
ClanWeb:wwt-clan.info

Offline PreDominance

  • Level 7 Expert
  • *****
  • Posts: 346
  • Country:
  • Creativity is your biggest restriction
    • ?WwT?
Re: [Tutorial] Using the Infinitely Useful wcs_dalias
« Reply #6 on: June 01, 2011, 04:27:42 PM »
I don't understand...you lose absolutely no freedom. Could you perhaps give me an example? There's no reason dalias should limit you (other than a max of 15 assigned variables :P).
Need help?

Steam:penumbra789                                      
Clan:?WwT? Wcs/Zm mod.                  
ClanWeb:wwt-clan.info

Offline pookzabazz

  • Level 6 Experienced
  • *****
  • Posts: 127
  • Country:
  • Twk Member
    • TWK
Re: [Tutorial] Using the Infinitely Useful wcs_dalias
« Reply #7 on: June 01, 2011, 04:29:08 PM »
Doesn't matter lolz, i'll erase my posts


Offline RedNäck

  • Level 7 Expert
  • *****
  • Posts: 322
  • Country: us
  • My new WCS-Server is Coming: 188.138.84.147:28125
    • www.fallen-unit.com
Re: [Tutorial] Using the Infinitely Useful wcs_dalias
« Reply #8 on: June 08, 2011, 11:13:20 PM »
very nice tutorial!!!

now the hard part, change all ultimates which require wcs_dalias
Ok here is a usefull Code:

cmd = "if (Pi != 3.147) then es_tell event_var(userid) YOU ARE BETTER THAN CHUCK NORRIS"

Offline Aenima

  • Level 6 Experienced
  • *****
  • Posts: 125
  • Country:
  • Learn to Swim !
Re: [Tutorial] Using the Infinitely Useful wcs_dalias
« Reply #9 on: September 08, 2011, 07:34:55 PM »
hello, lil question here:

is there any way to cancel a delayed alias/command so it doesnt execute after a new round starts ?

for example, this skill does random dmg every 4 sec for up to 8 times:
Code: [Select]
es_delayed .1 wcs_dalias dmgx1 event_var(userid) event_var(attacker)
es_delayed 4 wcs_dalias dmgx1 event_var(userid) event_var(attacker)
es_delayed 8 wcs_dalias dmgx1 event_var(userid) event_var(attacker) 
es_delayed 12 wcs_dalias dmgx1 event_var(userid) event_var(attacker)
es_delayed 16 wcs_dalias dmgx1 event_var(userid) event_var(attacker)
es_delayed 20 wcs_dalias dmgx1 event_var(userid) event_var(attacker)
es_delayed 24 wcs_dalias dmgx1 event_var(userid) event_var(attacker)
es_delayed 28 wcs_dalias dmgx1 event_var(userid) event_var(attacker)
wcs_xalias dmgx1 "es playerget isdead wcs_tmp6 server_var(wcs_tmp1);if (server_var(wcs_tmp6) = 0) then wcs_xalias dmgx2"
wcs_xalias dmgx2 "es_xrand wcs_dmg 2 5;es wcs damage server_var(wcs_tmp1) server_var(wcs_tmp2) server_var(wcs_dmg)"

but if "userid" dies after a few seconds he will get the remaining dmg waves after respawn,
i tried to set some check vars at round end/start, freezetime start/end  but its useless since the command is already "registered" ...

i have the feeling there's some obvious way to prevent this, but i can't figure right now..
any idea would be much appreciated  ::)

edit: nvm i found a way .. (just had to think more than 5 min)
« Last Edit: September 09, 2011, 04:42:42 PM by Aenima »


 


Powered by EzPortal