| 03-14-2006, 09:24 PM | #1 |
Jumping Spell Template v2
A re-release of my old jump template, the first of its kind mind you, that I simply ported to structs and updated some of the non-optimized parts of. Its a simple template for simple needs, however, its easy to use and works as intended. This allows you to jump a unit from here to there, while being able to edit every little aspect you can think of: speed, animation, effects, area, damage, arc, and even the offset between where the unit lands and where the spell was cast. Version Info:
spell code://*************************************************************************** //* * //* Jumping Spell Template v2 * //* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ **URL in the works * //* Parabola function by Shadow1500 * //* System by emjlr3 * //* * //* Requires: * //* ¯¯¯¯¯¯¯¯¯ * //* * //* - A vJASS Preprocessor * //* - CSSafety module * //* - CSCache module * //* * //*************************************************************************** library JumpingSpellTemplate initializer InitJumpingSpellTemplate, needs CSSafety, CSCache globals private real Game_MaxX private real Game_MinX private real Game_MaxY private real Game_MinY endglobals private function InitJumpingSpellTemplate takes nothing returns nothing set Game_MaxX = GetRectMaxX(bj_mapInitialPlayableArea)-50. set Game_MinX = GetRectMinX(bj_mapInitialPlayableArea)+50. set Game_MaxY = GetRectMaxY(bj_mapInitialPlayableArea)-50. set Game_MinY = GetRectMinY(bj_mapInitialPlayableArea)+50. endfunction private function SafeX takes real x returns real if x<Game_MinX then return Game_MinX elseif x>Game_MaxX then return Game_MaxX endif return x endfunction private function SafeY takes real y returns real if y<Game_MinY then return Game_MinY elseif y>Game_MaxY then return Game_MaxY endif return y endfunction private struct dat timer t unit u real area real damage real arc real maxdist real movedist real cos real sin real diff string sfx integer i = 0 endstruct //Spell: private function Filt takes nothing returns boolean return IsUnitEnemy(GetFilterUnit(),bj_groupEnumOwningPlayer) and IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING)!=true endfunction private function Damage takes unit u, real dam, real x, real y, real area returns nothing local group g = CreateGroup() local unit v set bj_groupEnumOwningPlayer = GetOwningPlayer(u) call GroupEnumUnitsInRange(g, x, y, area, Condition(function Filt)) loop set v = FirstOfGroup(g) exitwhen v == null call GroupRemoveUnit(g,v) call UnitDamageTarget(u,v,dam,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null) endloop call DestroyGroup(g) set g = null endfunction private function Parabola takes real dist, real maxdist,real curve returns real local real t = (dist*2)/maxdist-1 return (-t*t+1)*(maxdist/curve) endfunction private function Movement takes nothing returns nothing local dat d = GetCSData(GetExpiredTimer()) local real dist local real height local real x local real y set d.i = d.i + 1 set dist = d.i*d.movedist set height = Parabola(dist,d.maxdist,d.arc) call SetUnitX(d.u,SafeX(GetUnitX(d.u)+d.movedist*d.cos)) call SetUnitY(d.u,SafeY(GetUnitY(d.u)+d.movedist*d.sin)) call SetUnitFlyHeight(d.u,height,0.) if d.i == 50 then call SetUnitTimeScalePercent(d.u, 100) elseif d.i == 100 then call PauseUnit( d.u,false ) call SetUnitPathing( d.u, true ) call SetUnitFlyHeight(d.u,GetUnitDefaultFlyHeight(d.u),0.) set x = GetUnitX(d.u) + d.diff * d.cos set y = GetUnitY(d.u) + d.diff * d.sin call DestroyEffect(AddSpecialEffect(d.sfx, x,y)) call Damage(d.u, d.area, x, y, d.damage) call ReleaseTimer(d.t) call d.destroy() endif endfunction //=========================================================================== function JumpingSpellTemplateCast takes unit u, real damage, real area, real arc, real diff, string anim, string sfx, real speed returns nothing local dat d = dat.create() local real ux = GetUnitX(u) local real uy = GetUnitY(u) local location l = GetSpellTargetLoc() local real ang = Atan2((GetLocationY(l)-uy),(GetLocationX(l)-ux)) local real x = GetLocationX(l) - diff * Cos(ang) local real y = GetLocationY(l) - diff * Sin(ang) set d.t = NewTimer() set d.u = u set d.damage = damage set d.area = area set d.arc = arc set d.sfx = sfx set d.maxdist = SquareRoot((ux-x)*(ux-x) + (uy-y)*(uy-y)) set d.cos = Cos(ang) set d.sin = Sin(ang) set d.movedist = d.maxdist/100 set d.diff = diff call PauseUnit( u,true ) call SetUnitPathing( u, false ) call UnitAddAbility( u,'Amrf' ) call UnitRemoveAbility( u,'Amrf' ) call SetUnitAnimation(u, anim) call SetUnitTimeScalePercent(u, 30) call TimerStart(d.t,speed,true,function Movement) call SetCSData(d.t,d) call RemoveLocation(l) set l = null endfunction endlibrary Please test, comment, and enjoy! |
| 03-14-2006, 09:40 PM | #2 |
I don't see why you are using a custom "fly trick" ability, when you could just have used Medivh's Crow Form ability, which is already in the game and works perfectly? Also, a thing that could be changed to optimize it would be using Atan2 instead of Atan2BJ. Then the returned angle would also be in radians, so you would not have to convert it everytime, hitting performance. I also think that allowing users to change the distance between the targeted point, where he hits the ground with his sword, and the point where he actually lands should be changeable by the user. Some models does not work too well with normal animation names, so an option to use animation indexes instead would be nice. Just a suggestion though. Else it is pretty good, not really very original though. I am approving it anyways, but try to do some thing with the two things I've mentioned above. |
| 03-15-2006, 03:19 AM | #3 |
Gives a pretty decent arc to it. But it still uses handles, which are lame. Also it uses locations. Which are also super lame. But meh, looks pretty cool. GJ |
| 03-15-2006, 05:31 AM | #4 |
updated to comply with Blades suggestions(even though Atan2BJ was used only once, i changed that too), though I didnt really get what you meant about the "animation indexes", i duno what those are btw, I use 'Fly Trick', which is just meta, which does the same thing as crow form(AFAIK), allows the units fly height to be changed and Chuckle, I use 1 location, once, which is an unavoidable one, this alone does not slow the spell down nor make it 'lame' And handlers too are fine, if ppl prefer tables, it just a matter of changing the names of the things to that for tables |
| 03-15-2006, 06:26 AM | #5 |
Don't call them handlers. The name of the type is handle, handles in the plural. The functions are called the Local Handle Vars. This is not to nitpick, but it is sad to see a guy asking for help with his script that is bugged, because he saw someone typing interger or handler and then writes that in his script. Please aviod that. And yes, I know Metamorphosis can do the same, but what is the need for a custom ability when it can do without? And yes, you only use Atan2BJ once, but you converted the real it returns in degress several times to radian everytime the timer expired, which was worthless. Animation indexes are a way to play a specific animation of a unit, for example SetUnitAnimation does not always play the right animation, when you want to play an attack animation and the unit has multiple. SetUnitAnimationByIndex takes an integer instead of a string that integer is the number that the animation comes in in the mdl file of the model. |
| 03-15-2006, 02:07 PM | #6 | |
Quote:
Teacher teacher, I have a question! Since he used the slam anim though, and he slowed down the animation(to properly align the ending with the landing), is there any way to get the length of an animation with jass? or do you need to throw in a calc to properly slow down the unit along with a value given in a constant function in the config section? |
| 03-15-2006, 06:13 PM | #7 |
Hey cool 3/5 ;) do more good spells! |
| 03-15-2006, 08:15 PM | #8 |
3/5....what is wrong, why is this template only 60% complete, please tell me so i can improve it |
| 03-15-2006, 08:57 PM | #9 | |
Quote:
|
| 03-21-2006, 12:23 PM | #10 |
runs smooth, very good, but it needs the possibility to stun on impact. then it would be 5/5 :) |
| 03-21-2006, 12:29 PM | #11 |
add a dummy caster at the end, order him to stomp when u land maybe ill add that in later, i guess a jump template isnt complete w/o an end AOE spell casted |
| 04-07-2006, 08:11 PM | #12 |
how do you add this spell to a map? i copied the jump ability, the fly trick ability, and the actual trigger, but when i go to run the game, i get a ton of script errors |
| 04-07-2006, 10:18 PM | #13 |
i think a good tool would be a spell importer, which would import all object data from one map to another, and not copy a functionif it already exists in a map (handle variables?) I've been asked like 5 times already on how to import my system/spell. |
| 04-07-2006, 11:58 PM | #14 | |
Quote:
JASS:local real ang = bj_RADTODEG * Atan2((GetLocationY(l)-uy),(GetLocationX(l)-ux)) local real x = GetLocationX(l) - Jump_Template_Difference() * Cos(ang * bj_DEGTORAD) local real y = GetLocationY(l) - Jump_Template_Difference() * Sin(ang * bj_DEGTORAD) Additionally, you don't need to compute Cos/Sin more than once, or even at all. http://www.wc3campaigns.net/showthread.php?t=81954 I suggest making the number of times the loop runs be a general parameter or, make it clear how to modify it. Instead of giving the user a .01s timer control, I would give them a measure of graininess (distance moved per step), along with a speed (distance moved per time between steps) and then compute the rest of your parameters. JASS:function Jump_Template_Parabola takes real dist, real maxdist,real curve returns real local real t = (dist*2)/maxdist-1 return (-t*t+1)*(maxdist/curve) endfunction |
| 04-08-2006, 12:53 AM | #15 |
i dont think anyone can click accuratly enough to hit the exact center of the unit.. |
