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

Author Topic: [Tutorial] The usage of wcs_nearcoord  (Read 413 times)

iMak

  • Moderator
  • Level 7 Expert
  • Posts: 469
  • Pokemon Master!
[Tutorial] The usage of wcs_nearcoord
« on: January 09, 2011, 07:39:02 PM »
Hey guys today I'll show you how to use wcs_nearcoord! First of all do not try to use est_near, est_nearcoord or es nearcoord as they wont work propably!

For wcs_nearcoord we have the following syntax:

Code: [Select]
wcs_nearcoord <var> <identifier> <x coord> <y coord> <z coord> <range> <"command to run">

1. The first thing we have to do is to set the Variable.

If you want to use any variable with wcs_ infront of it thats most of the time enought. If you want to use your "own" variables (they can be whatever you want e.g xyz or uber_race_variable1) you have to "create" them first by adding:

Code: [Select]
es_xset <variable> 0
Be sure to have that in the skill BEFORE you use the variable. For our example we will use wcs_players

2. Now we come to the identifier.

The identifier tells the wcs_nearcoord what team / what persons to affect and which persons it should leave alone.

Basicly there are the three "big" identifiers, #ct , #t and #all.
You can find the other identifiers here : http://www.eventscripts.com/pages/Foreach_player
Using identifier teamspecific within an ultimate will require you to get the players team first and then set the target team according to that. For example :

Code: [Select]
es_getplayerteam wcs_team server_var(wcs_userid)
if (server_var(wcs_team) = 2) then es_xset wcs_targetteam #ct
if (server_var(wcs_team) = 3) then es_xset wcs_targetteam #t

This would set targetteam to your enemys team. For using nearcoord on your own team just exchange #ct with #t.

3. The Coordinates:

This is quite easy as its the same for every nearcoord over and over again. You can either get the players location or the location he is looking at.
For players location it would be :

Code: [Select]
es_getplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_userid)
For viewcoords it would be:

Code: [Select]
es playerget viewcoords server_var(wcs_userid) wcs_x1 wcs_y1 wcs_z1
Thats it for coords already.

4. Adjusting the range.

The range defines in what range your nearcoord command should work. A players height is about 90-100 game units (just to make it less abstract). So adding a 100 range to wcs_nearcoord would make it a circle that has 100 game units in every direction starting from the coordinates given. So range is the same as the geometrical word radius.


5. Last but not Least : The Command!

Now lets come to the command. Most commands require some userid given. For example wcs_setfx speed 2 = 2 5.
This would set speed of player with userid 2 to 2 for 5 seconds. But we dont have ONE specific userid so nearcoord gets around that using the variable we gave it before.
So in our case it would be :

Code: [Select]
es wcs_setfx speed server_var(wcs_players) = 2 5
Basicly Nearcoord loops through all userids in range and puts them to wcs_players variable.

6 The Result:

All together we had this:

Code: [Select]
es_getplayerteam wcs_team server_var(wcs_userid)
if (server_var(wcs_team) = 2) then es_xset wcs_targetteam #ct
if (server_var(wcs_team) = 3) then es_xset wcs_targetteam #t
es_getplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_userid)
es wcs_nearcoord wcs_players server_var(wcs_targetteam) server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) 300 "es wcs_setfx speed server_var(Wcs_players) = 2 5"


La Muerte

  • Administrator
  • Level 7 Expert
  • Posts: 1246
  • 85.234.148.14:27025
Re: [Tutorial] The usage of wcs_nearcoord
« Reply #1 on: January 10, 2011, 03:58:12 AM »
Nice & thanks!

svave

  • Level 0 Beginner
  • Posts: 15
  • Wcsmod cool!!
Re: color!
« Reply #2 on: January 22, 2011, 07:49:56 PM »
how to set the black race now please tell me.

tintinibar

  • Level 7 Expert
  • Posts: 170
Re: [Tutorial] The usage of wcs_nearcoord
« Reply #3 on: January 25, 2011, 08:43:02 PM »
great tutorial but I have 2 questions:
1. How do you set it so if it picks up a user then it doesn't loop through any more users
2. what is the best method to check if a player is dead? My commands always count dead players and utilize commands on them.


 


* Ads