| 03-19-2006, 06:07 AM | #1 |
Today Ive started to learn jass, I kinda know the basics, so Ive been messing with the editor and I wanted to make something like Leopard Dash spell. I succeeded but since I dont understand many things I had to copy the most important part of Leopard tutorial into my code and thats not fair...I wanted to do it from scratch but I ended with a choppy movement for the unit that I wanted to dash because I used a loop from integer to integer function, so I replaced that part with Leopards code but I dont get how the hell anything related to the timer "t" works, most exactly: JASS:call TimerStart(t, 0.03, true, function DashSS) Also I would like to know if things like this: JASS:local location LOCTARGET = GetUnitLoc(TARGET) And why ppl doesnt like local handle variables too and they speak of tables instead, but what r really those? JASS:call SetUnitFlyHeightBJ( TARGETPARABOLA, Y, 0.03 ) Im attaching Leopards code so u can hav a look, hope noone gets upset by this. Im hoping someone will be kind enough to help me. Cause Im very confused Thnkz JASS://Raw codes //Leopard, 15 August 2005 function RawDSSJ takes nothing returns integer return 'A003' //Raw code for Dash (Same Speed) (JASS) ability endfunction function RawEvade takes nothing returns integer return 'A001' //Raw code for Evasion (Dash) ability endfunction //================================================================================= //Configuration function ss_constant takes nothing returns real return 5.00 //Set this real number higher to get faster speed, and lower to get slower speed endfunction //================================================================================= function Trig_Dash_Same_Speed_JASS_Conditions takes nothing returns boolean return GetSpellAbilityId() == RawDSSJ() endfunction function DashSS takes nothing returns nothing local unit caster = RetrieveUnit(GetExpiredTimer(), "caster") local real ss_const = GetStoredReal(Cache(),I2S(HandToInt(GetExpiredTimer())),"ss_const") local real faceangle = GetStoredReal(Cache(),I2S(HandToInt(GetExpiredTimer())),"faceangle") local location castloc = GetUnitLoc(caster) local location polarproj = PolarProjectionBJ(castloc, ( ss_const * 5.00 ), ( faceangle + 180.00 )) local effect dusteff call SetUnitPositionLocFacingBJ( caster, polarproj, faceangle ) set dusteff = AddSpecialEffectTarget("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl",caster,"origin") call DestroyEffectBJ( dusteff ) call RemoveLocation(castloc) call RemoveLocation(polarproj) set caster = null set castloc = null set polarproj = null set dusteff = null endfunction function Trig_Dash_Same_Speed_JASS_Actions takes nothing returns nothing local real ss_const = ss_constant() local unit caster = GetTriggerUnit() local location castloc = GetUnitLoc(caster) local location target = GetSpellTargetLoc() local real faceangle = AngleBetweenPoints(castloc, target) + 180.00 local real distance = DistanceBetweenPoints(castloc, target) local timer t = CreateTimer() if ( distance > 1200 ) then set distance = 1200 endif call UnitAddAbility(caster, RawEvade()) call SetUnitAnimation( caster, "ready" ) call StoreHandle(t, caster, "caster") call StoreReal(Cache(),I2S(HandToInt( t )),"ss_const",ss_const) call StoreReal(Cache(),I2S(HandToInt( t )),"faceangle",faceangle) call TimerStart(t, 0.03, true, function DashSS) call TriggerSleepAction( ( distance / ( ss_const * 200.00 ) ) ) call UnitRemoveAbility( caster, RawEvade()) call ResetUnitAnimation( caster ) call Flush(t) call DestroyTimer(t) call RemoveLocation(castloc) call RemoveLocation(target) set castloc = null set target = null set caster = null set t = null endfunction //=========================================================================== function InitTrig_Dash_Same_Speed_JASS takes nothing returns nothing set gg_trg_Dash_Same_Speed_JASS = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Dash_Same_Speed_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Dash_Same_Speed_JASS, Condition( function Trig_Dash_Same_Speed_JASS_Conditions ) ) call TriggerAddAction( gg_trg_Dash_Same_Speed_JASS, function Trig_Dash_Same_Speed_JASS_Actions ) endfunction EDIT: ALSO(sorry..) is there a program for jass that actually looks like this jass tag that wc3capaigns uses, cause it looks fancy |
| 03-19-2006, 06:51 AM | #2 | ||||
Quote:
Quote:
Quote:
JASS:
call RemoveLocation(LOCTARGET)
set LOCTARGET = null
so you won't have memory leaks. Quote:
|
| 03-19-2006, 05:01 PM | #3 |
thnkz, just one question, how do u know how much is that timer gonna last? because it isnt spedified in the code |
| 03-19-2006, 05:04 PM | #4 |
It lasts until is destroyed by JASS:call DestroyTimer(t) |
| 03-19-2006, 05:29 PM | #5 |
cool, u r very kind thankz |
| 03-19-2006, 05:32 PM | #6 |
No problem ^^ |
| 03-19-2006, 05:37 PM | #7 |
It shall be metioned that it is a good idea to first stop the timer before destroying it because othwerwise it might cause a crash in very rare situations. Stopping a timer is done with the following native: Code:
native PauseTimer takes timer whichTimer returns nothing Check out http://www.wc3jass.com/viewtopic.php?t=2373 as a reference. |
| 03-19-2006, 09:47 PM | #8 |
thnkz PitzeMike. I was also wondering why when I use this I get a choppy movement: JASS:loop set DISTANCER = DISTANCER + (COUNT1 * 6.00) call SetUnitPositionLocFacingBJ( TARGET, POLARPROJECTION, ANGLE ) set LOCTARGET = GetUnitLoc(TARGET) set POLARPROJECTION = PolarProjectionBJ(LOCTARGET, ( COUNT1 * 6.00 ), ( ANGLE )) call TriggerSleepAction( 0.03 ) exitwhen DISTANCER > 500 endloop and why calling a function that uses a similar code results in a smooth movement? EDIT: also is it true that game caches cannot be used in bnet? does this aply for multiplayer on lan too? |
| 03-19-2006, 09:49 PM | #9 |
You can;t do a wait for less than 0.1 seconds I believe |
| 03-20-2006, 05:35 AM | #10 |
the lowest wait is .27, thus your not getting your smooth run every .03, but every .27 no matter how low your call TriggerSleepAction() is, that is why we use timers, since they are very accurate and can run basically as fast you as you want, if used them down at .001 before in the end nothing below .03 is really needed however |
| 03-20-2006, 11:59 AM | #11 |
I don't think the minimum wait is that high. Blizzard itself uses a wait of 0.1 seconds in it's PolledWait function, do you really think that they wouldn't know just how short their minimum wait was? |
| 03-20-2006, 02:26 PM | #12 |
It is not 0.27 at least. jigrael: You can USE gamecaches in bnet, but you can't save them and load from them. But if it is just for a spell or os, it works fine, but for a save system it does not. |
| 03-20-2006, 02:37 PM | #13 |
thankz guys I understand now ![]() |
| 03-20-2006, 04:48 PM | #14 |
what is the min then, ive heard they go no lower then .1, then ive also heard the min is .27, anyone got a deff. answer? personally whenever i want a min wait I just use call TriggerSleepAction(0) |
| 03-20-2006, 05:30 PM | #15 |
JASS:function PolledWait takes real duration returns nothing local timer t local real timeRemaining if (duration > 0) then set t = CreateTimer() call TimerStart(t, duration, false, null) loop set timeRemaining = TimerGetRemaining(t) exitwhen timeRemaining <= 0 // If we have a bit of time left, skip past 10% of the remaining // duration instead of checking every interval, to minimize the // polling on long waits. if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then call TriggerSleepAction(0.1 * timeRemaining) else call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL) endif endloop call DestroyTimer(t) endif endfunction Could it be that this: JASS:
call TriggerSleepAction(0.1 * timeRemaining)
EDIT: Probably this: JASS:constant real bj_POLLED_WAIT_INTERVAL = 0.10 |
