• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

2 Questions

Status
Not open for further replies.
Level 22
Joined
Jan 10, 2005
Messages
3,426
1) How do u create a rect in front of a unit with the angle of the units facing? I tried this:
Unit Group - Pick every unit in (Units in ((Rect(0.00, 0.00, 125.00, 800.00)) offset by ((X of (Casting unit)), (Y of (Casting unit))))

PS: The X and Y of unit are WEU functions

2) Whats the 'Death Damage Delay' in the spell incinerate for?
 
Level 22
Joined
Jan 10, 2005
Messages
3,426
1) It doesnt matter where units should be, but where the rect should be. (In my spell the casting unit moves instantly to his facing +800 range. Now I want to pick every unit that is in the rect that he passes (125,800) But the Rect must be in front of the casting unit (before he casts the spell) and the facing of the casting unit and size 125, 800

2) Yes, u must go to incenerate in object editor, there u can find it
 
Level 12
Joined
Apr 29, 2005
Messages
999
Ahaha! Someone else needs my über-function! I made a function in JASS called GetUnitsInAngledRectangle which is exactly what you ask for. I will upload it soon. You have no idea how hard it was to make...
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
1. It's not that difficult. It's pure math, and if I think a little bit at it, and make some geometry I will post you a GUI solution.

2. I can only suppose that it determines the period of time between the death of the unit, and the damage dealt by the spell. So, when the unit dies, it waits for 'Death Damage Delay''s field value, and then it deals the damage.

~Daelin
 
Level 22
Joined
Jan 10, 2005
Messages
3,426
Ahaha! Someone else needs my über-function! I made a function in JASS called GetUnitsInAngledRectangle which is exactly what you ask for. I will upload it soon. You have no idea how hard it was to make...

Cool, but I dunno anything of JASS, so how do I use it with a GIU spell, I must convert it first to text then. But then how do I know where 2 place it etc

1. It's not that difficult. It's pure math, and if I think a little bit at it, and make some geometry I will post you a GUI solution.

I'll use it if I dont understand the JASS stuff after Daminon explained it

2. I can only suppose that it determines the period of time between the death of the unit, and the damage dealt by the spell. So, when the unit dies, it waits for 'Death Damage Delay''s field value, and then it deals the damage.

Ah. ok, thnx
 
Level 12
Joined
Apr 29, 2005
Messages
999
Daelin would you like to explain the math behind your method? I would really like to see if your method is the same as mine. Make one or more pictures displaying how you do the geometri. If you like I can do the same. :) Microsoft Word works good for it.
 
Level 22
Joined
Jan 10, 2005
Messages
3,426
That wud b nice, 2 guys making a math thing of the trigger.
I have tried it to but didnt work:

Unit Group - Pick every unit in (Units in ((Rect(0.00, 0.00, 125.00, 800.00)) offset by ((X of (Casting unit)), (Y of (Casting unit))))

PS: The X and Y of unit are WEU functions
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
Well, I am still thinking about an efficient method. Because last night, I tried using some analytical geometry. I can determine the rect, but then, checking when the units are inside... I split the rectangle into two triangles, and then I just tried checking if the point is in any of the triangles. However, that stuff requires determinants, stuff I didn't learn yet. And yes, it is far too complicated.

Conclusion, I am trying to play a little with first grade functions right now. But you were right, it is more complicated than I thought. I hate that my math is a little limited, because I need analitical geometry, and all I learnt was self-teaching. But the solution is somewhere close, I can feel it.

Edit: Ok, after making some research on the internet, and adapting the code, here is my JASS, much simpler I'd say. http://www.wc3sear.ch/index.php?p=JASS&ID=317

~Daelin
 
Level 12
Joined
Apr 29, 2005
Messages
999
Ok, here is my method.

P == point
An == angle

enumangrec03fv.jpg

First we calculate the positions of a right-angled rectangle that tangents the angled one. Then we enum group units in it.

enumangrec16uh.jpg

Let's say that we have a unit here, P[Test] grouped. Now my method is to get the angle between P[1] and P[Test], draw a line in that angle and then figure out the maximum distance for that line until it crosses the angled rectangle. Sometimes when An[1] is very small it tends to be 360 to greater than it should be. Therefore we must check if it is grater than 360 and if it is true degrease it with 360. Now we have the true angle.

If An[1] is greater than 180 we know that it can't be inside the angled rectangle.

We can see on the picture that the given unit isn't in the angled rectangle but we have to prove it mathematicly.

To do that we see the line as the hypotenuze of a right-angled triangle. To get it's lenght we need two attributes of the triangle. And we have, An[1] and B/2. Now we can get the hypotenuze by (B / 2) / CosBJ(An[1]).

Know that if An[1] is greater than 90 the hypotenuze formual will be a little bit different, tha angle has to be degreased.

enumangrec23fz.jpg

But is it really that simple? What happens if An[1] is like in the picture? Then one of the cathetus is too long to be inside the angled rectangle. To solve this we need to get another angle.

enumangrec39dc.jpg

Here we have An[2]. To get the length of the hypotenuze we can only use (B / 2) / CosBJ(An[1]) if An[1] is less or equal to An[2]. Otherwise we must calculate it from the other cathetus with modified vaule of An[1] like this A / CosBJ(90 - An[1]).
Code:
As a summary:
if (An[1] < 90) then
    if (An[1] < An[2]) then
        Hypotenuze = (B / 2) / CosBJ(An[1])
    elseif (An[1] > 90) then
        Hypotenuze = A / CosBJ(90 - An[1])
    endif
elseif (An[1] > 90) then
    if (An[1] < An[2]) then
        Hypotenuze = A / CosBJ(An[1] - 90)
    elseif (An[1] > 90) then
        Hypotenuze = (B / 2) / CosBJ(180 - An[1])
    endif
endif

Now we just have to compare the distance from P[Test] to P[1] with P[1] and the hypotenuze.

If the distance is shorter or equal to the hypotenuze then the unit is in the angled rectangle. I hope you understand. :wink:
 
Level 22
Joined
Jan 10, 2005
Messages
3,426
Yes, I understand. It was damn hard :p Also I had to look what those words mentin my language
I only dont get why u use Cosinus (Thats the 'cos' right?)

But I get it

PS: So u dont need JASS after all? or are there some flaws or other leaks or somethingg when u do it like this?
 
Level 12
Joined
Apr 29, 2005
Messages
999
Ramza said:
Yes, I understand. It was damn hard :p
Guess if it was to figure it out. I think I worked 6 hours with paper, pencil, protractor and high school calculator, painting and gauging arcs and lines. The cathetus problem took me 3 hours before I understod it. And the -360-thing was also a time consumer.

Ramza said:
I only dont get why u use Cosinus (Thats the 'cos' right?)
Ehm, if you use the angle as one of the two needed attributes in a triangle to get another one then you have to use trigonometry. And in this case Cosinus is needed.
Cos = short for Cosinus
Sin = short for Sinus
Tan = short for Tangens

CSC = short for Cosecant
SEC = short for Secant
COT = short for Cotangens

Ramza said:
PS: So u dont need JASS after all? or are there some flaws or other leaks or somethingg when u do it like this?
There are always leaks when using non-numberic, string or boolean variables (non object variables). But it can be used with GUI yes.
 
Status
Not open for further replies.
Top