| 03-17-2006, 06:03 AM | #1 |
A jass script that allows you to jump a unit in a parabola. Allows you to set the time, height and distance traveled unlike similar maps which only allow you to do one or two of those things. Version 1.2 Reworked implementation and added some safety features. Version 1.1 Changed Cache System and fixed Vile's bug Version 1 Initial Release For those who use vJass (comes with JassNewGen), Malf has updated the script to take advantage of the new features. To implement, copy + paste into your custom script section. To use, call JumpUnit(unit, location target, real height, real duration). JASS:library JumpSystem private struct data unit u = null real s = 0 real ss = 0 real height = 0 real a = 0 real dist = 0 real angle = 0 real b = 0 endstruct globals private constant real RefreshRate = 0.035 private timer T = CreateTimer() private data array Data private integer N = 0 endglobals private function Update takes nothing returns nothing local integer i = 0 loop set i = i+1 exitwhen i > N call SetUnitX( Data[i].u, GetUnitX(Data[i].u) + Data[i].dist * Cos(Data[i].angle)) call SetUnitY( Data[i].u, GetUnitY(Data[i].u) + Data[i].dist * Sin(Data[i].angle)) call SetUnitFlyHeight( Data[i].u, Data[i].a*Data[i].s*Data[i].s+Data[i].height, 1000000 ) if (Data[i].s <= 1) then set Data[i].b = 1. endif if (Data[i].b==0.) then set Data[i].s = (Data[i].s) - 1 else set Data[i].s = (Data[i].s) + 1 endif if ( Data[i].s > Data[i].ss) then call SetUnitFlyHeight(Data[i].u, GetUnitDefaultFlyHeight(Data[i].u), 500) set Data[i] = Data[N] call Data[N].destroy() set N = N - 1 endif endloop if N == 0 then call PauseTimer(T) endif endfunction function JumpUnit takes unit u, location target, real height, real duration returns nothing local real dx local real dy local real s if duration == 0 then call SetUnitPositionLoc(u, target) else set dx = GetLocationX(target) if dx > GetRectMaxX(bj_mapInitialPlayableArea) - 50 then set dx = GetRectMaxX(bj_mapInitialPlayableArea) - 50 elseif dx < GetRectMinX(bj_mapInitialPlayableArea) + 50 then set dx = GetRectMinX(bj_mapInitialPlayableArea) + 50 endif set dx = dx - GetUnitX(u) set dy = GetLocationY(target) if dy > GetRectMaxY(bj_mapInitialPlayableArea) - 50 then set dy = GetRectMaxY(bj_mapInitialPlayableArea) - 50 elseif dy < GetRectMinY(bj_mapInitialPlayableArea) + 50 then set dy = GetRectMinY(bj_mapInitialPlayableArea) + 50 endif set dy = dy - GetUnitY(u) set s = (duration/RefreshRate)/2 call UnitAddAbility( u, 'Amrf' ) call UnitRemoveAbility( u, 'Amrf' ) if N == 0 then call TimerStart(T,RefreshRate, true, function Update) endif set N = N+1 set Data[N].u = u set Data[N].b = 0 set Data[N].s = s set Data[N].ss = s set Data[N].height = height set Data[N].a = -height/(s*s) set Data[N].dist = SquareRoot(dx * dx + dy * dy)/s/2 set Data[N].angle = Atan2(dy,dx) endif endfunction endlibrary |
| 03-17-2006, 07:10 AM | #2 |
Yay redundancy! It's like being a Nazi bureaucrat! Honestly though you don't really make the sell, i would be surprised if this gets approved since you are pretty general in how it's 'flexable' but 'inefficant' [sic]. Perhaps a more detailed feature list? |
| 03-17-2006, 10:21 AM | #3 |
Well, for a start the screen shot is a bit big. The main thing it features is the ability to choose the location and height you jump to. Most maps with a parabola only feature one of the two. Most of the other stuff is standard. By inefficant, I mean I over use the handle variables system, I start two timers when I should only use one and I use a couple of ineffeciant bj's. |
| 03-18-2006, 06:09 PM | #4 |
i was actually planning on chaninging that in mine, so you could chose between the height being relative to where you jump to or a set height, would not be to tough, but I ahve not gotten around to it yet |
| 03-18-2006, 06:14 PM | #5 |
Set heights tend to look lame, if I were you I wouldn't waste my time on it. |
| 03-19-2006, 07:24 PM | #6 |
I can not approve this at all in it's current form. It needs to be in the form of a real spell == effects when a spell is cast. If it is a spell, then it must be in form of a spell, please. |
| 03-20-2006, 05:04 AM | #7 |
It's not actually a spell. I'll make it use a spell and optimize it a bit tonight. Edit: Okay I've updated the map, and I'm switching it to the Table system now. |
| 03-20-2006, 05:33 AM | #8 | |
Quote:
how do u suggest doing a jump spell then? |
| 03-20-2006, 05:41 AM | #9 |
Well, if it is not a spell, then you don't have to make it as a spell. But you need to make it easier to test, so you don't have to restart the map everytime, please. |
| 03-20-2006, 06:05 AM | #10 |
Okay done, also improved the coding a bit. |
| 03-20-2006, 04:58 PM | #11 |
You are using functions from Vex's Caster System, I do not see any credits. Fix that. |
| 03-21-2006, 06:21 AM | #12 |
Opps, sorry people I ripped off. Updated. |
| 03-21-2006, 06:30 AM | #13 |
slight improvement, if you care, saves a few lines of code JASS:function Trig_Jump_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A000' endfunction also, a GUI trigger that would copy the needed globals over may be better too |
| 03-21-2006, 01:57 PM | #14 |
emjlr3, maybe it is just me, but I do not see it at all in the code. Anyways, I am approving this, but you could maybe optimize it a bit more, by just using * bj_DEGTORAD once, when you save the value. Since it is a function and a map that demonstrates how to use it, I think it will belong best in samples. |
| 03-23-2006, 02:30 PM | #15 |
er what? |
