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.
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.
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.
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!
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!
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!


Logged

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?


).

