| 01-15-2008, 03:47 PM | #1 |
I'm making a spell that shots away a footman and then when it reaches the target it explodes. Ive done the basic movement now but I want it 3D. Im using a curve that goes up 2/3 of the time and goes down the rest 1/3 to making it looking realistic. But when I run it the unit is just going up with the same angle forever. Then stops at the target position. JASS:// What the values are. // WHAT = Which run // ANGLE = Which angle // BIG = What it should be bigger then //! textmacro Angle takes WHAT, ANGLE, BIG if (d.distdone/100*$WHAT$) <= d.disttotal and (d.distdone/100*$WHAT$ > d.distdone/100*$BIG$) then set d.tmpangle = $ANGLE$ set d.z = d.z+HEIGHTDOTS*Tan(d.tmpangle*bj_DEGTORAD) call SetUnitFlyHeight(d.dummy, d.z, 0) endif //! endtextmacro scope MoveFootman globals private constant integer DAMAGEDONE = 150 private constant integer ABILID = 'A002' private constant integer DUMMYFOOT = 'h001' private constant integer DOTS = 10 // How fast it moves private constant integer HEIGHTDOTS = 1 endglobals struct dat unit cunit // Casting Unit player cplayer // Casting player real distdone = 0 real disttotal real angle real x1 real y1 real x2 real y2 timer t unit dummy real z real tmpangle endstruct private function Move takes nothing returns nothing local timer t = GetExpiredTimer() local dat d = GetTimerStructA(t) local real x = GetUnitX(d.dummy) local real y = GetUnitY(d.dummy) set d.z = GetUnitFlyHeight(d.dummy) set x = x+DOTS*Cos(d.angle*bj_DEGTORAD) set y = y+DOTS*Sin(d.angle*bj_DEGTORAD) if d.distdone >= d.disttotal then call SetUnitFlyHeight(d.dummy, 0, 0) call PauseTimer(t) call DestroyTimer(t) set t = null call dat.destroy(d) else // Set unit pos call SetUnitX(d.dummy, x) call SetUnitY(d.dummy, y) // Set flyingheight //! runtextmacro Angle("10","45","0") //! runtextmacro Angle("20","37.5","10") //! runtextmacro Angle("30","30","20") //! runtextmacro Angle("40","22.5","30") //! runtextmacro Angle("50","15","40") //! runtextmacro Angle("60","7.5","60") //! runtextmacro Angle("65","0","60") //! runtextmacro Angle("70","10","65") //! runtextmacro Angle("80","20","70") //! runtextmacro Angle("90","40","80") //! runtextmacro Angle("100","60","90") // Make ready for next loop set d.distdone = d.distdone+DOTS endif endfunction private function Conditions takes nothing returns boolean return GetSpellAbilityId() == ABILID endfunction private function Actions takes nothing returns nothing local dat d = dat.create() local integer i local timer t = CreateTimer() local location l local real extra1 local real extra2 set d.cunit = GetSpellAbilityUnit() set d.cplayer = GetOwningPlayer(d.cunit) set l = GetSpellTargetLoc() set d.x1 = GetUnitX(d.cunit) set d.y1 = GetUnitY(d.cunit) set d.x2 = GetLocationX(l) set d.y2 = GetLocationY(l) set d.angle = bj_RADTODEG * Atan2((d.y2-d.y1), (d.x2-d.x1)) set extra1 = (d.x2-d.x1) set extra2 = (d.y2-d.y1) set d.disttotal = SquareRoot(extra1 * extra1 + extra2 * extra2) set d.dummy = CreateUnit(d.cplayer, DUMMYFOOT, d.x1,d.y1, 270) call SetTimerStructA(t, d) call TimerStart(t, 0.02, true, function Move) // Remove leaks //call PauseTimer(t) //call DestroyTimer(t) //set t = null call RemoveLocation(l) set l = null //call dat.destroy(d) endfunction //=========================================================================== public function InitTrig takes nothing returns nothing local trigger trig set trig = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_CHANNEL ) call TriggerAddCondition( trig, Condition( function Conditions ) ) call TriggerAddAction( trig, function Actions ) endfunction endscope |
| 01-15-2008, 04:16 PM | #2 |
i know it's not a problem but : JASS:set d.angle = bj_RADTODEG * Atan2((d.y2-d.y1), (d.x2-d.x1)) set extra1 = (d.x2-d.x1) set extra2 = (d.y2-d.y1) JASS:set extra1 = (d.x2-d.x1) set extra2 = (d.y2-d.y1) set d.angle = bj_RADTODEG * Atan2(extra2, extra1) Can we see the SetTimerStructA function, or maybe it's a part of cohadar's system ? JASS://! runtextmacro Angle("10","45","0") //! runtextmacro Angle("20","37.5","10") //! runtextmacro Angle("30","30","20") //! runtextmacro Angle("40","22.5","30") //! runtextmacro Angle("50","15","40") //! runtextmacro Angle("60","7.5","60") //! runtextmacro Angle("65","0","60") //! runtextmacro Angle("70","10","65") //! runtextmacro Angle("80","20","70") //! runtextmacro Angle("90","40","80") //! runtextmacro Angle("100","60","90") why you change the flying height 11 times, instead of only one ... |
| 01-15-2008, 04:52 PM | #3 |
Im changing it because the curve should look better. I got told there's no way to do the curve I wanted so I splitted it up in 11 smalls parts. Like: The first 10% it goes with 45% angle the next 10% it's 37.5% angle and so on so it's a smooth curve and when it goes downhill it's the same it should just look more realistic. |
| 01-15-2008, 06:50 PM | #4 | |
Quote:
i don't think any human can see 11 different pictures in less than 0.01 s :p |
| 01-15-2008, 07:15 PM | #5 |
... It's not in 0.01 s :D But it would make it running nice if it works. and I really want that curve XD So now go and find out whats wrong :P |
| 01-15-2008, 07:42 PM | #6 | |
Quote:
But if this condition is true many times : JASS:if (d.distdone/100*$WHAT$) <= d.disttotal and (d.distdone/100*$WHAT$ > d.distdone/100*$BIG$) then then you will change the flying height more than one time, in less than 0.01s (don't know the value but it's more little) A better way : JASS://! runtextmacro Angle("10","45","0") //! runtextmacro Angle("20","37.5","10") //! runtextmacro Angle("30","30","20") //! runtextmacro Angle("40","22.5","30") //! runtextmacro Angle("50","15","40") //! runtextmacro Angle("60","7.5","60") //! runtextmacro Angle("65","0","60") //! runtextmacro Angle("70","10","65") //! runtextmacro Angle("80","20","70") //! runtextmacro Angle("90","40","80") //! runtextmacro Angle("100","60","90") call SetUnitFlyHeight(d.dummy, d.z, 0) With the macro without the set UnitFlyHeight |
| 01-15-2008, 08:40 PM | #7 |
Tested that didn't change anything. It goes in a stright line up and then when it's done it goes down to height 0 so it doesn't bug up :D |
| 01-15-2008, 08:50 PM | #8 |
My apologies but your procedure with textmacros is just.... horrible :P If you need to emulate a parabolic movement, check thi thread: http://www.wc3campaigns.net/showthre...=parabolic+arc |
| 01-16-2008, 07:19 AM | #9 |
The problem is that I don't want a Parabolic movement. The movement I want is in attached. |
| 01-16-2008, 03:14 PM | #10 | |
Quote:
Parabolic motion is realistic, your idea is just a visual approximation. |
| 01-16-2008, 03:44 PM | #12 |
How to use that? Can you show me a example? |
| 01-16-2008, 04:19 PM | #14 | ||
Quote:
Quote:
|
| 01-16-2008, 06:02 PM | #15 |
You know there's an "easy" way to use parabolic movement... just move the "centre" of the parabola CLOSER to the target. |
