 |   |  |  |
JASS Functions Approved JASS functions will be located here.
Remember to submit your own resources to the submission forum. |
 |
|
02-10-2008, 08:53 AM
|
#31 (permalink)
|
BBoy Silv
Join Date: Nov 2006
Posts: 866
|
We can make 5 000 000 of those, but it's ok, I guess.
Better to make stuff like:
function CreateUnitForPlayer takes player owner, integer unitID, real x, real y, real facing, player whichPlayer returns unit local integer i if GetLocalPlayer () == whichPlayer then set i = unitID endif return CreateUnit (owner, i, x, y, facing )endfunction
I don't know how this function works exactly, I don't understand how can you create a unit that exists only for one player, but I've seen it on TheHelper.
Or maybe:
function AddSpecialEffectForPlayer takes string path, real x, real y, player whichPlayer returns effect local string s if GetLocalPlayer () == whichPlayer then set s = path endif return AddSpecialEffect (s, x, y )endfunction
|
|
|
02-10-2008, 05:30 PM
|
#32 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
CreateUnitForPlayer will desynch. (Not necessarily upon call, but when the unit deals or receives damage, for example)
|
|
|
02-11-2008, 06:04 AM
|
#33 (permalink)
|
User Title
Join Date: Nov 2006
Posts: 1,029
|
Lol... I didn't see Disciple's Post... He already posted a GetNearestUnit xP
__________________
Vote For The Hive Workshop!
Funny but the TRUTH! :
Quote:
|
Originally Posted by Sopho
Unprotecting maps is not right its like crime and YOU GO MAKE YOUR OWN MAP AND BE HAPPY! Don't be gay n00b!
1. You can if it is yours but you should not if it is not. It is like stealing information and using it as if it is your own. It si gay stuff and people who unprotect maps are gay themselves.
|
|
|
|
02-11-2008, 10:45 AM
|
#34 (permalink)
|
BBoy Silv
Join Date: Nov 2006
Posts: 866
|
Quote:
|
CreateUnitForPlayer will desynch. (Not necessarily upon call, but when the unit deals or receives damage, for example)
|
With avoiding those, it can be useful.
Quote:
|
Lol... I didn't see Disciple's Post... He already posted a GetNearestUnit xP
|
Yeah, but his is more flexible, I think.
|
|
|
03-05-2008, 01:45 AM
|
#35 (permalink)
|
Me in a few words???
Join Date: Aug 2007
Posts: 949
|
GetClosestUnitFunction
I'm assuming that the function works, but could you explain it to me a bit better, kind of step by step
Mostly, I'm curious as to why (dx^2 + dy^2)/100000 > 100000 is the closest unit (I suppose that 100000 is the max size of all maps?)
__________________
77% of all people are neurotic
|
|
|
03-05-2008, 05:53 PM
|
#36 (permalink)
|
BBoy Silv
Join Date: Nov 2006
Posts: 866
|
No.
You see, I was trying to avoid SquareRoot function (as you can see, there isn't one in it). In the beginning, md variable represents a great distance (probably bigger than the map) which is compared to the location from which it is searching the closest unit. If distance from a picked unit and that location is lower than that distance (which it is), md becomes the distance between the picked unit and the location. Then it compares to the other units, if the distance from a certain unit to that location is lower than the current md, that md becomes that distance.
But, since I'm not using SquareRoot, the system compares each distance squared (since I'm not square rooting it), so md has to represent a distance greater than any other, but it has to be squared (since maybe some distance squared will be greater than that one), so with a little help from Disciple, I used this simple equation:
Code:
x = y
x/1000 = y/1000
I had to lower each number because there is a number limit in wc3 from which every next number becomes the negative value of that number (then I would be calculating with negative distances........yeah).
Get it?
|
|
|
03-08-2008, 12:45 AM
|
#37 (permalink)
|
Me in a few words???
Join Date: Aug 2007
Posts: 949
|
Hmmm
Ohhhhh now I got it
Your just getting the x and the y, then using pythagorean thereom
There isn't a ^ (1/2) function so it had to be a number that is much larger than any two squares could be (100000*100000)
But at the same time, x^2 and y^2 would get so big they would flip to negative(odd), so you just divided x^2 + y^2 by 100000
So, does it keep looping over and over, even after you got the unit??? (maybe you should add something so it doesn't loop with over 300 units or something)
_________________________________________________
EDIT
Finally, I'm starting to really understand JASS thanks to these little code snippets, thank you so much for this
__________________
77% of all people are neurotic
|
|
|
03-08-2008, 01:05 PM
|
#38 (permalink)
|
BBoy Silv
Join Date: Nov 2006
Posts: 866
|
Yeah, it loops through all units that satisfy the boolexpr condition. I can't make it run through less units because........because I just can't, I need to check every single one. This is supposed to be fast, so it shouldn't lag.
That flipping-to-negative is a stupid bug and people should be careful with it.
|
|
|
03-10-2008, 11:47 PM
|
#39 (permalink)
|
Me in a few words???
Join Date: Aug 2007
Posts: 949
|
Question
Do you think it would lag awfully in a timed trigger (.05) on a massive risk map??? (each unit has bout 100hp each, cost 1, and each player receives +100 gold per round)
__________________
77% of all people are neurotic
|
|
|
03-11-2008, 08:41 AM
|
#40 (permalink)
|
BBoy Silv
Join Date: Nov 2006
Posts: 866
|
First of all, this is getting offtopic, you should open a new thread or PM me, second of all, you really gave me little information, try to explain the details more (for example, I already lost you at the "massive risk map" part, since I don't know what that is).
|
|
|
03-11-2008, 08:54 PM
|
#41 (permalink)
|
Me in a few words???
Join Date: Aug 2007
Posts: 949
|
Eh nvm
I'm not gonna be making any risk maps any time soon, so it doesn't really matter just a bit curious
Btw, How come you wanted to avoid the SquareRoot function?
__________________
77% of all people are neurotic
|
|
|
03-11-2008, 10:23 PM
|
#42 (permalink)
|
BBoy Silv
Join Date: Nov 2006
Posts: 866
|
Arghhhh try to put all your questions in the fewest number of posts possible!
SquareRoot is a slow function, many good jassers are avoiding it. There are also other slow functions that should be avoided: Sin(), Cos(), Tan(), Pow()......
|
|
|
03-11-2008, 10:58 PM
|
#43 (permalink)
|
Me in a few words???
Join Date: Aug 2007
Posts: 949
|
Sorry bout that
Yeah the questions kind of just keep popping into my mind
Damn sin, cos, tan, pow, all are no good
That makes me sad
I suppose you would only use those if they were absolutely necessary, like a polar coordinate (I think uses one of those)
__________________
77% of all people are neurotic
|
|
|
03-12-2008, 09:01 AM
|
#44 (permalink)
|
BBoy Silv
Join Date: Nov 2006
Posts: 866
|
Yeah, sometimes you have to use those, but I think Pow() isn't necessary in any situation (since Pow(x, 3) = x * x * x).
But with the power of vJass sin, cos and tan won't make problems anymore (since every good vJass code is freakin fast).
If you got any more questions, PM me, that would be better.
|
|
|
03-12-2008, 07:19 PM
|
#45 (permalink)
|
Me in a few words???
Join Date: Aug 2007
Posts: 949
|
Ok sure
Something about the unit for one player, I suppose you could use it as a dummy unit, and create special effects for players who should see it, and not for players who couldn't see it
I'm not really sure when the situation would call for it, but I suppose it would be for an RPG or something
(Maybe a flare behind a wall???)
__________________
77% of all people are neurotic
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|  |  |  |  |   |  |
|