| 11-10-2004, 11:58 PM | #1 |
Ok, here is my problem, I am trying to remake the spell system using triggering so that I can use resistances and to make spells beam based rather then target based and add reflection, but I can't get to all that fun stuff because of the problems I am running into with the targeting. How this works is I give every unit in the game a unique custom number, I then use this as a suffice for arrays of several values that I made. When a unit casts a spell like fireball, instead of modifying as current fireball spell I take two points, the point of the caster and the point of target. I take these two points and find the angle and make “fireballs� along this path at even intervals, thus creating a firebolt My system seems to find the correct degree that the spell is fired, however it seems that it does not create the “fireballs in the correct playses between the angles of ~ -75 to ~75 degrees and ~120 to ~ -120 degrees. I am not exactly sure it is those numbers. ![]() ![]() ![]() This if the code that gets the two points and finds the angle: Code:
Set spellTarget[((Custom value of (Triggering unit)) x 2)] = (Position of (Triggering unit)) Set spellTarget[(((Custom value of (Triggering unit)) x 2) + 1)] = (Target point of ability being cast) Set SpellAngle[(Custom value of (Triggering unit))] = Set SpellAngle[(Custom value of (Triggering unit))] = (Atan2(((Y of spellTarget[(((Custom value of (Triggering unit)) x 2) + 1)]) - (Y of spellTarget[((Custom value of (Triggering unit)) x 2)])), ((X of spellTarget[((((Custom value of (Triggering unit)) x 2) + 1) + 0)]) - (X of spellTarget[((Custom value of (Trigger Unit)) x 2)]) It just saves the two points in variables and then finds the angle by the ArcTangent of the height divided by the width of triangle between the two points. The code for that creation of the “fireballs is: Code:
For each (Integer A) from 1 to 20, do (Actions)
Loop – Actions
Set SpellMovement[(Custom value of (Triggering unit))] = (SpellMovement[(Custom value of (Triggering unit))] offset by (((Cos(SpellAngle[(Custom value of (Triggering unit))])) x 50.00), ((Sign(SpellAngle[(Custom value of (Triggering unit))])) x 50.00)))
Unit - Create 1 Fireball for Neutral Passive at SpellMovement[(Custom value of (Triggering unit))] facing Default building facing (270.0) degrees
Set SpellBolt[((Custom value of (Triggering unit)) x (Integer A))] = (Last created unit)...and has a cleanup loop that removes the fireballs from the game. The way it moves is it adds [Cosine(angle) x 50 (the hypotenuse I want)] to the X value of the point of the last “fireball� and [Sine(angle) x 50] to the Y. if you download the attached map you can get the readouts by typing “#debug� without the quotas. The folder the trigger is in is called “Casting� and the trigger name is “FindAngle� it's the only one, you can't miss it. |
| 11-11-2004, 11:58 AM | #2 |
Mmmm i know there is a problem with angles... unit angle goes from 0 to 360 degrees while angle between 2 points goes from -180 to +180... I didnt understand if you have this problem but you should add +360 to angles under 0° |
| 11-12-2004, 12:39 PM | #3 |
Let me get this straight, you are using a complex math equation to find the angle the unit is facing? If so, why don't you just use (facing of (triggering unit))? Anyways, I too was having a problem with casting stuff at the wrong angles when the unit is facing certain degrees. I think I fixed this by using variable for everything (stupid of me to not use them for everything, i know) but I'm not sure whats wrong with your triggers.... |
| 11-13-2004, 07:39 PM | #4 | ||
Quote:
No that was not his problem..... Quote:
(The reason to why I posted was to say Kishe was wrong (maybe unneccisary)) |
| 11-15-2004, 11:28 PM | #5 | |
Quote:
Well I found that the angles even though they are unusual work just the same in cos sin and tan as 181-359 degrees would, in my code I used "Sign" vs "Sine", what "sign" does is find if it is positive or negative while "sine" is the Trigonometric function we all know and love. @Kishe When the spell is cast the unit is not facing the direction that the spell is cast, he takes time to turn and if you get the degrees the unit is facing then you botch the whole thing because people will get pissed off if they shoot a spell at nothing they target at. |
| 11-16-2004, 01:40 AM | #6 |
Ah, I didn't really read the whole trigger, just kind of skimmed it. The problem I was having at first was with collision sizes and whatnot. But since you are creating the sfx at certain points, I don't see where the problem is. I'm just gonna dl the map and try out a few things. EDIT: Well I just tried to open the map, but it seems that you protected it. :\ |
| 11-16-2004, 05:58 AM | #7 |
Sine? no way! Tangent OWNS! lol, anyway, if there are specific angle you cant get to work, jut overdo them. I.E: 540degrees will look the same as 180 etc. sounds kool anyway! keep it up! -Garith |
| 11-16-2004, 06:45 PM | #8 | |
Quote:
You need andvanced WE or something like that to open it, there seem to be some pointless (not really) triggers where I used that make it so you cannot open it in standered WE |
