| 01-06-2008, 06:48 AM | #1 |
JASS:function Trig_Test_A_Actions takes nothing returns nothing local real x local real y local location point local real l set udg_Clear = 0 set l = -128.0 loop set l = l + 1 set udg_Clear = (udg_Clear + 1) set x = ( l * 2.5) set y = ( ( Pow( (x/2.5), 2.00) / 1.00 ) * 10.00 ) set point = Location(x, y) call AddSpecialEffectLocBJ( point, "Abilities\\Weapons\\BloodElfMissile\\BloodElfMissile.mdl" ) call RemoveLocation(point) set udg_SpecialEffects[(R2I(l) + 128)] = GetLastCreatedEffectBJ() exitwhen (l == 128) endloop endfunction //=========================================================================== function InitTrig_Test_A takes nothing returns nothing set gg_trg_Test_A = CreateTrigger( ) call TriggerRegisterPlayerChatEvent( gg_trg_Test_A, Player(0), "-create a", true ) call TriggerAddAction( gg_trg_Test_A, function Trig_Test_A_Actions ) endfunction That was originally GUI, except I changed it to JASS. I managed to do everything off memory from how I knew how locals worked, except I had to have a small peek at Vex's tutorial on how to do the loops. What this does is that it basically just placing a parabola displayed by graphics. Am I going in the right direction? EDIT! I just went back and saw there was a post or two after mine in my previous topic... does this count as going from a GUI-->JASS "spell" conversion? I see it as a form of conversion to begin with. |
| 01-06-2008, 06:54 AM | #2 |
Since you're already dealing with x and y coordinates rather than locations, you should use x and y functions. JASS:function Trig_Test_A_Actions takes nothing returns nothing local real x local real y local real l = -128 // you can initialize it here set udg_Clear = 0 loop set l = l + 1 set udg_Clear = (udg_Clear + 1) set x = ( l * 10.00) set y = ( ( Pow( (x/10), 2.00) / 1.00 ) * 10.00 ) set udg_SpecialEffects[(R2I(l)+128)] = AddSpecialEffect("Abilities\\Weapons\\BloodElfMissile\\BloodElfMissile.mdl",x,y) exitwhen (l == 128) endloop endfunction Additionally, you'll notice that you can simply set your effect variable to the effect function because the add effect function returns the effect that it creates. (native AddSpecialEffect takes string modelName, real x, real y returns effect) I didn't look at your code functionally speaking...I just fixed what could obviously be a little better. As to why I used x and y--it's faster because most location functions involve simply deriving x and y from the location, so you're saving the computer a step by using an x y function. |
| 01-06-2008, 07:02 AM | #3 |
just take note that locations are pretty useless in Jass, you can totally avoid them unless you are trying to store data with it (see cs_cache location storing method) btw your mac can use JassCraft? if can, you really should get that thing :) it shows all the natives and u can avoid using bj's crappy function |
| 01-06-2008, 07:33 AM | #4 | |
Quote:
JASS:function Trig_Test_A_Actions takes nothing returns nothing local real x local real y local integer i = -128 loop set i = i + 1 set x = i * 10. set y = x * x / 10 // No need to divide by one, lol set udg_SpecialEffects[i + 128] = AddSpecialEffect("Abilities\\Weapons\\BloodElfMissile\\BloodElfMissile.mdl", x, y) exitwhen i == 128 endloop set udg_Clear = i + 128 endfunction I've also cleaned up the constant increase of udg_Clear, since its going to be 128 greater than i at all times there is no need to constantly set it. I hope this helped. |
| 01-06-2008, 08:59 AM | #5 |
Oh that's true, I was using the bj_LoopBlizzardthingo before. Also, this may be too advanced so just tell me, but how would one go abouts using radians? It's been explained to me but I forgot. I know what they are, though. |
| 01-06-2008, 09:40 AM | #6 |
Radians are just a harder to visualize version of degrees, they are pretty well exactly the same as using degrees. Say you have a triangle that projects at an angle of 15 degrees, and a length of 15. In order to find the sides (in wc3) you would have to do this: JASS:set x = 15 * Cos(15 * bj_DEGTORAD) set y = 15 * Sin(15 * bj_DEGTORAD) There you have your sides written as x and y. Generally in warcraft the reason for using these triangles is for projection, in which case you would find the angle between two coordinates, as follows: JASS:function AngleBetweenCoordinates takes real x1, real y1, real x2, real y2 returns real return Atan2(y2-y1, x2-x1) endfunction Because functions that return degrees (such as Atan2) return them in radians, it allows you to put this angle directly into the Cos and Sin parameters, without having to convert them to degrees, as follows: JASS:local real angle = Atan2(y2-y1, x2-x1) // some angle in radians local real diagonal = 15.00 // just some diagonal of a triangle local real x = diagonal * Cos(angle) local real y = diagonal * Sin(angle) As you can see, there is no longer a need to multiply by bj_RADTODEG, thus speeding up the arithmetic ever so slightly. Clear? |
| 01-06-2008, 04:43 PM | #7 |
Some warcraft 3 functions require degrees as an argument. When this is the case, its better to work in degrees. When you are just doing raw math, its better to work in radians. |
| 01-07-2008, 12:10 AM | #8 |
So... for spells (as a start) I'd use degrees and for physics-like things I'd use radians, right? |
| 01-07-2008, 12:31 AM | #9 |
It really depends what functions you are planning on using. *edit* When I first posted this it posted the same message 20 times one after the other. I re-visited the thread now and they are all gone. Has anybody else observed this before? |
| 01-07-2008, 12:47 AM | #10 |
Hm, just curious, but does anyone have the link to that website that's packed with every imaginable JASS native thingy? JASSVault or something it is, I think... |
| 01-07-2008, 12:50 AM | #11 | |
Quote:
Its best to get JassCraft which has a built in JASS API browser at: http://www.hiveworkshop.com/resources_new/tools/469/ However to answer your question, here is a website with a JASS API browser: http://jass.sourceforge.net/doc/api/index.shtml >> http://jass.sourceforge.net/doc/api/functions.shtml Also, you can use an MPQ viewing software to extract the file common.j, common.ai, and blizzard.j from the war3.mpq under the directory script. The files mentioned contain some tips, although rarely useful, on certain functions. |
| 01-07-2008, 12:56 AM | #12 |
Download vJass, it comes with a syntax highlighter called TESH and has a built-in API browser. |
| 01-07-2008, 01:04 AM | #13 |
My Mac won't (it's probably a can't) run JassCraft. vJass also (now it does) seem a lil' too complicated. EDIT! I'm starting to like the JASS Syntax checker. |
| 01-07-2008, 01:19 AM | #14 | |
Quote:
Ouch, no jasscraft... You might want to try the third method i mentioned; the one about the MPQ. Extracting those files allow you to see what various BJ functions makeup are... and why they are so looked down upon. I have no clue on where to find/get a MAC MPQ view/extracter. |
| 01-07-2008, 01:33 AM | #15 |
The JASS Syntax Checker comes with the .j stuff to poke 'n' prod at. JASS:function Trig_Test_C_Actions takes nothing returns nothing local real d local real ang local real x local real y local integer i local location pnt local location mid set mid = GetRectCenter(GetPlayableMapRect()) call DisplayTextToForce( GetPlayersAll(), "Test C before loop has been run" ) loop set ang = i * 2 set d = (i + 4) * 5 set x = GetLocationX(pnt) + d * Cos(ang * bj_DEGTORAD) set y = GetLocationY(pnt) + d * Sin(ang * bj_DEGTORAD) set udg_SPFXClear[i + 128] = AddSpecialEffect("Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl", x, y) set i = i + 1 exitwhen (i==180) endloop call DisplayTextToForce( GetPlayersAll(), "Test C after loop has been run" ) call RemoveLocation(pnt) call RemoveLocation(mid) call DisplayTextToForce( GetPlayersAll(), "Test C is finished" ) endfunction //=========================================================================== function InitTrig_Test_C takes nothing returns nothing set gg_trg_Test_C = CreateTrigger( ) call TriggerRegisterPlayerChatEvent( gg_trg_Test_C, Player(0), "create c", true ) call TriggerAddAction( gg_trg_Test_C, function Trig_Test_C_Actions ) endfunction I started another graphic manipulation but this one has a problem that I can't see. I placed the 3 messages (before loop, after loop and finish) but it seems that only call DisplayTextToForce( GetPlayersAll(), "Test C before loop has been run" ) is being displayed. The other two aren't. Also the thing that's meant to be made (spiral) is not showing. I know I've definitely done something wrong, but I can't spot it. My guess is the shameful attempt of trying to imitate the polar projection. |
